method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
0e95e5c4-b0c2-4a7e-ab15-1a729642921e
6
private float[] validateAgainstRange(float[] values) { // Range is an array of 2xn numbers, where n is the number of output // values. for (int j = 0, max = values.length; j < max; j++) { if (range != null && values[j] < range[2 * j]) { values[j] = range[2 * j]; ...
5aa1c178-a0f0-4f33-898c-34f1c9864fff
1
public void deleteScreenshot() { if (!deleted) { new File(screenShotPath).delete(); deleted = true; } }
87eed0d1-250e-4375-9c0f-b826be3358c8
9
public boolean exist(char[][] board, String word) { if (word == null) return false; if ("".equals(word)) return true; if (board.length ==0 ||board[0].length==0) return false; boolean[][] visit = new boolean[board.length][]; for (int i = 0; i < board.length; i ++) { visit[i] = new bo...
58e918e7-92c7-46bb-b464-ed688074c378
6
private Initialisable.TicketType transportSelection(Initialisable.TicketType ticketType, Integer newNode) { Object[] possibilities = new Object[5]; possibilities[0] = "Taxi"; possibilities[1] = "Bus"; possibilities[2] = "Underground"; if(playerVisualisable.getMrXIdList().contains(currentPlayerID)) { ...
7314c65c-6ce1-4f5a-b227-b7d4e153ae8e
0
public int degree(Object vertex) { return adjacent(vertex).size(); }
2cbefa92-d0bd-4bdb-8eea-3cfe55d46a36
1
@Override public Resource getResourceById(String id) { if (resources.containsKey(id)) { Resource resource = resources.get(id); return resource; } else { return null; } }
644d515d-3959-47d6-839a-09f2f4ac706b
2
public ProductionPanel(int controlPanelHeight, ControlPanel controlPanel, Building building) { super(); this.owner = controlPanel; this.setPreferredSize(new Dimension(200, controlPanelHeight)); this.setBackground(Color.RED); GridLayout layout = new GridLayout(size, size); layout.setHgap(10); layout.setVga...
0a565168-0fcc-41f9-a277-9fbf2eb086e3
1
@Override public boolean equals(Object other) { if (other instanceof UrlWrapper) { UrlWrapper otherUrlWrapper = (UrlWrapper) other; return otherUrlWrapper.toUrl().equals(toUrl()); } else { return false; } }
5b77f517-7439-4ef7-aef6-e06f9f89b916
2
private void btnSalvarAlteracaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarAlteracaoActionPerformed Departamento DEP = new Departamento(); String Nome = txtNomeDepartamento.getText(); String CodDep = txtCodDepartamnento.getText(); DEP.setNome(Nome); ...
952bd2be-8076-4e9e-b37d-79704d7d1f9a
8
public static Cons clListDirectoryFiles(String directory) { { Cons files = null; String dirsep = Stella.directorySeparatorString(); boolean checkduplicatesP = false; String normfile = null; Cons normalizedfiles = Stella.NIL; if (files == null) { checkduplicatesP = true; ...
94fcce61-0fb7-4299-bec1-fea70e89d15c
8
public static void build_square(char[][] square, String key) { boolean[] filled=new boolean[26]; String key_u=key.toUpperCase(); int cur_row=0; int cur_col=0; for(int i=0;i<key.length();i++) { char cur_c=key_u.charAt(i); if(cur_c=='J') { cur_c='I'; } int pos=cur_c-'A'; if(!filled[pos]...
f12edebe-1f7f-41d8-a6b4-37811cea843b
3
public void apply(PermissionBase base, CommandSender sender, World world) { List<String> permissions = base.getPermissions(world == null ? null : world.getName()); PermissionAttachment att = sender.addAttachment(plugin); for (String perm : permissions) { att.setPermission(perm.starts...
d8413a68-a25e-4a13-80ac-d8ecc0a39eee
6
public static Rezervacija dajRezervacijuZaSobu(Soba soba, Date datumOD, Date datumDO, int redniBroj) { Session session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery("from " + Rezervacija.class.getName() + " rezervacija where rezervacija.soba is not null and rezervacija.soba....
a3f329ef-5559-47bd-ad69-073b9ac50177
2
public static void main(String args[]) { try { ServerSocket serverSocket=new ServerSocket(4331); Socket clientSocket=null; String str; DataInputStream in=null; DataOutputStream out=null; clientSocket = serverSocket.accept();//ܿͻ in=new DataInputStream(clientSocket.getInputStream());//ȡ׽ֵ o...
07b3552b-6378-4b4a-92e8-3590f8d11d31
8
protected byte[] processMsdpList(final Session session, final String var, final Map<Object,Object> reportables) throws UnsupportedEncodingException, IOException { final ByteArrayOutputStream buf=new ByteArrayOutputStream(); final MSDPListable type=(MSDPListable)CMath.s_valueOf(MSDPListable.class, var.toUpperCase()...
cf5d0812-dc46-438a-89c4-d71e1ba1f3a9
1
public static void main(String argv[]) { Frame frame = new Frame(GlobalOptions.copyright); Window win = new Window(frame); String cp = System.getProperty("java.class.path"); if (cp != null) win.setClassPath(cp.replace(File.pathSeparatorChar, Decompiler.altPathSeparatorChar)); String cls = win.getClas...
312172a5-526b-46cb-91e6-1ce36dab5ec0
1
private boolean setupPermissions() { RegisteredServiceProvider<Permission> permissionProvider = getServer() .getServicesManager().getRegistration( net.milkbowl.vault.permission.Permission.class); if (permissionProvider != null) { permission = permissionProvider.getProvider(); } return (permission !...
f782cc5a-cd11-48bb-bf91-ec7fd9b02333
1
@Override public Iterable<Key> keys() { LinkedList<Key> i = new LinkedList<Key>(); for (Node x = first; x != null; x = x.next) i.addFirst(x.key); return i; }
5513e587-3d5c-4c0c-b5c0-8381e48cfe25
3
@Override public Class getColumnClass(int column) { Class returnValue; if ((column >= 0) && (column < getColumnCount())) { if(getValueAt(0, column)==null) return String.class; returnValue = getValueAt(0, column).getClass(); ...
556e1a77-96f6-4cb4-98b8-ad918fba1a4c
0
public int getFoodNum() { return this.foodSpawnCells.size() * 5; }
250ff758-faf0-4107-a22f-18a50c241182
7
protected String buildQeuryString() { String query = "INSERT INTO register_info ("; String args = ""; String vals = ""; String updates = ""; Set<Map.Entry<String, String[]>> entries = this.paramMap.entrySet(); Iterator<Map.Entry<String, String[]>> it = entries.iterator()...
5ee2b0cd-d594-4ecc-8ff7-44cd4f307d91
0
public static InterfaceCommand get(String command) { return commands.get(command); }
2eed2219-6be7-476f-a705-700663953aee
4
public void addListener (Listener listener) { if (listener == null) throw new IllegalArgumentException("listener cannot be null."); synchronized (listenerLock) { Listener[] listeners = this.listeners; int n = listeners.length; for (int i = 0; i < n; i++) if (listener == listeners[i]) return; Listene...
a203a1ea-cc0d-4306-a96e-afe3dec6e91c
4
private void writeUnpackInfo(List<Folder> folders) throws IOException { if (folders.isEmpty()) return; writeByte((byte) Header.NID.kUnPackInfo); writeByte((byte) Header.NID.kFolder); writeNumber(folders.size()); { writeByte((byte) 0); for (Fo...
97bfdd85-b9f5-4001-b892-14328af5a2c3
3
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed Transferable clipboardContent = getToolkit().getSystemClipboard().getContents(this); if ((clipboardContent != null) && (clipboardContent.isDataFlavorSupported(DataFlavor.stri...
10552963-088c-4a98-bd3f-5ab139204403
5
public static byte[] revert10padding(byte[] input) throws InputMismatchException{ // An empty input array does not fulfil the requirements. // Even an empty message would be padded to [1]. if(input.length == 0) { throw new InputMismatchException("The provided input is malformed."); } int paddingStart = in...
5eb2c86b-aa6a-4bb9-8b27-9e6a70f80586
8
final public void Function_call_expression() throws ParseException { /*@bgen(jjtree) Function_call_expression */ SimpleNode jjtn000 = new SimpleNode(JJTFUNCTION_CALL_EXPRESSION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); tr...
255bc369-00c0-4b3e-9408-0e6de4bf0626
4
public boolean isUpdate(String sql, String[] params) { boolean b = true; try { Class.forName(driver); System.out.println("ɹ"); connection = DriverManager.getConnection(url,username,password); //ݿ System.out.println("ݿɹ!"); ps = connection.prepareStatement(sql); //ȡPreparedStatement //ѭϣSQL...
86e76316-9036-448b-854c-207a129e29b0
2
public void increaseScore(AnswerSide answerSide, int score) { if (answerSide == AnswerSide.LEFT) increaseLeftScore(score); else if (answerSide == AnswerSide.RIGHT) increaseRightScore(score); }
de38d964-4f02-4f1e-b3cb-a11d10619f7e
7
public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) { SpringLayout layout; try { layout = (SpringLayout)pa...
1e3c4846-6259-4190-a312-c9a21a39ef9c
2
public short getShort(String key) { try { if(hasKey(key)) return ((NBTNumber<Short>) get(key)).getValue(); return 0; } catch (ClassCastException e) { return 0; } }
146b2152-b874-4aac-8da9-2e15765b8d48
9
private void prepareView() { setLayout(new BorderLayout(10, 10)); final DefaultListModel<AbstractTask> taskModel = new DefaultListModel<>(); final JList<AbstractTask> taskList = new JList<>(taskModel); taskList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JPanel taskPanel = new JPanel(new B...
cbbe7951-8f0c-4682-b91b-b3910999acb0
9
private static TypeData toPrimitiveTag(char c) { switch (c) { case 'Z' : case 'C' : case 'B' : case 'S' : case 'I' : return TypeTag.INTEGER; case 'J' : return TypeTag.LONG; case 'F' : return TypeTag.FLOAT; case '...
89b357cc-3cfc-406b-8f8b-d9a26b6c9b7b
0
static void test (Object x) { System.out.println("Testing x of type: " + x.getClass()); System.out.println("x instance of Base: " + (x instanceof Base)); System.out.println("x instance of Derived: " + (x instanceof Derived)); System.out.println("Base.class.isInstance(x): " + Base.class.i...
6804f5a5-d144-4f6d-a1b2-8a9c06dab0ef
1
public Object next() { if (next == null) { throw new NoSuchElementException(); } AbstractInsnNode result = next; prev = result; next = result.next; return result; }
7dfa360b-184f-488b-97ea-ad4daf84c5fc
6
private void receiveDatafromClient() { while(true) { try { DatagramPacket receivePacket = new DatagramPacket(rx_buff, rx_buff.length); serverReceiver.receive(receivePacket); rx_buff = receivePacket.getData(); IPAddressOfCurrentClient =receivePacket.getAddres...
4ce2db78-a77d-4201-ab54-d8b60e8f454b
1
protected void drawGameObject(GameObject gameObject){ if(gameObject != null){ offscreenGraphics.drawImage(gameObject.getCurrentImage(), gameObject.getX(), gameObject.getY(), this); } }
6e31274e-b50f-4cee-93bb-cd9adaee2a9a
2
@Override public void setConfiguration( ConnectionLabelConfiguration configuration ) { if( configuration == null ) { throw new IllegalArgumentException( "configuration must not be null" ); } if( !this.configuration.equals( configuration ) ) { this.configuration = configuration; DefaultConnectionLabe...
07999d85-2a7d-455b-a9b0-e813bb75272a
9
public Matrix decomposeLU(boolean LUP) { if(rows != cols) { throw new IllegalArgumentException("Matrica nije kvadratna!"); } Matrix P = new Matrix(rows); for(int i = 0; i < rows - 1; i++) { if(LUP) { // ako je LUP postupak odabran napravi pivotiranje po stupcima int pivotIndex = i; ...
48d5ff1c-a1b4-4c73-a687-8ea377345d11
8
final public void Program_declaration() throws ParseException { /*@bgen(jjtree) Program_declaration */ SimpleNode jjtn000 = new SimpleNode(JJTPROGRAM_DECLARATION); boolean jjtc000 = true; jjtree.openNodeS...
52f69fe1-67ea-4542-af3f-a8593c9f9fa4
3
public Share getShare(String searchstring) throws WrongNameException { if (isShareListed(searchstring)){ throw new WrongNameException("playername could not been found"); } int i; for (i = 0; i < availableShare.size(); i++) { if(availableShare.get(i).na...
8d66961b-2503-46fd-b43d-ea942810fbea
3
private static int calcYears(GregorianCalendar birthDay, GregorianCalendar checkDay, int birthMonth, int checkMonth) { int years = checkDay.get(GregorianCalendar.YEAR) - birthDay.get(GregorianCalendar.YEAR); if ( checkMonth < birthMonth ) { years --; } else if (che...
50feee40-dc0c-4cdf-b86c-a920e2892a1e
4
public void test_03_Nmers() { long seed = 20100615; Random rand = new Random(seed); int numTests = 100; // Test all lengths for( int len = 1; len <= 32; len++ ) { for( int t = 0; t < numTests; t++ ) { String seq = randSeq(len, rand); // Create a random sequence if( verbose ) System.out.println("N...
fe48eeb4-6896-463c-932d-d192e1e06938
1
public void rotACW() { // Rotations : (a;b) (-b;a) (-a;-b) (b;-a) // Rotation : (a;b) (a-x;b-y) (y-b;a-x) (y-b+x;a-x+y) synchronized (this) { for (int i = 0; i < etat.length; i++) { etat[i].setValue(centre.get(1) - etat[i].get(1) + centre.get(0), etat[i].get(0) - cent...
1334bd93-f81e-48cc-a7ce-02bec4890e8b
7
@Override public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source instanceof JButton) { if (btnAdd == source) { try { verify(); if (JOptionPane.YES_OPTION == JOptionPane .showConfirmDialog(null, "Do you want to add this task?", "Con...
da317708-0f42-4205-bb60-b23df14c2b62
3
private Socket connect () { Socket socket = null; int attempts = 0; do { attempts ++; try { socket = new Socket(Utils.REGISTRAR_ADDR, Utils.REGISTRAR_PORT); socket.setKeepAlive(true); socket.setSoTimeout(0); } catch (Exception e) { String msg = String.format("Warning: connection attempt ...
e75827d9-899a-4887-8d05-ec15740dd72a
6
public static void adjustHeap(int[] heap, int location, int unSortlength) { int temp; int tempLoc; if ((tempLoc = (location + 1) * 2) < unSortlength) { //如果左右节点存在 if (heap[tempLoc] >= heap[tempLoc - 1]) { //判断左右节点大小 if (heap[location] < heap[tempLoc]) { //判断父节点与子节点的大小,若父节点小,则与大的子节点换位 temp = heap[locat...
7f04f4e4-4cfd-4521-8a71-a23a9e7ca980
6
static void remove(File f, int index) throws FileNotFoundException, IOException { File in = new File (ExtractorModel.appDir + "/" + "bookmarks.txt"); File out = new File(ExtractorModel.appDir + "/" + "tmp.txt"); out.createNewFile(); try(FileOutputStream fout = new FileOutputStream(out); ...
d976d8b9-f03e-43ec-96b5-5a9e6586eb89
8
public int compare(Object a, Object b) { String sa = (String)a; String sb = (String)b; int alen = sa.length(); int blen = sb.length(); int mlen = Math.min(alen, blen); for (int i=0; i<mlen; i++) { char ca =...
6f441cb4-10c0-41e1-bcf5-1f8d99782d3d
6
private void setupCrossHair(Weapon<? extends Projectile> weapon) { if (weapon instanceof actor.ship.weapon.AlternatingWeapon<?>) { crosshair = Texture.findOrCreateByName(CROSSHAIRDUAL); gunammo = Texture.findOrCreateByName(GUNAMMODOUBLE); } else if (weapon instanceof actor.ship....
a9dd7bec-f9f0-44a3-ae96-84062f67d5db
0
private void setDefaultExportFileFormat(SaveFileFormat aFileFormat) { defaultExportFileFormat = aFileFormat; }
23c9aecb-60f8-4564-aa10-9c098d2455a0
0
public JTextField getjTextFieldAdresse() { return jTextFieldAdresse; }
7ed75fe5-12c0-458b-be48-2aa4974cedbb
5
public static void attack(PlanetWars pw, int objective) { // Objective is 0 GR, 1 planet, 2 ships, 3 Dcal + distance // Tested Planet source = null; Planet dest = null; List<Planet> asw; switch (objective){ case 0 : asw = forGR(pw); break; case 1 : asw = forPlanet(pw); break; case 2 : asw = ...
22f00fb2-2b67-4b38-8783-6c878c1835c8
3
@Override public void addSymptom(SymptomDTO symptom) throws SQLException { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.save(symptom); session.getTransaction().commit(); ...
3eca4cb9-7710-4e09-9af3-985b6644c575
6
public static String numberToString(Number number) throws JSONException { if (number == null) { throw new JSONException("Null pointer"); } testValidity(number); // Shave off trailing zeros and decimal point, if possible. String string = number.toString(); if (string.indexOf('.') > 0 && string.indexOf('...
e343ce4c-202e-4aa5-8710-8a891a766b72
0
public Long getMaxFailedAttempts() { return maxFailedAttempts; }
92e6ee49-d38a-4b74-b0b0-59555b285123
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Flight other = (Flight) obj; if (flightClass == null) { if (other.flightClass != null) return false; } else if (!flightClass.equals(othe...
3a4aec37-5224-41c3-bc94-d0b35df23944
5
/* */ public void checkFiring() /* */ { /* 50 */ for (int i = 0; i < Core.units.size(); i++) { /* 51 */ Unit u = (Unit)Core.units.get(i); /* 52 */ if ((this.firingAngle.intersects(u.collision)) && (!this.inRange.contains(u))) { /* 53 */ this.inRange.add(u); /* 54 */ System.out....
89476345-102a-442c-878c-eebd1a1296b2
1
public int[] getInput() { if(userInput == null) return getPreset(); else return userInput; }
3cacf6ba-a7ef-4941-b67b-333fa29d04ce
4
public static void addLibraryDir(String s) throws IOException { try { // This enables the java.library.path to be modified at runtime // From a Sun engineer at // http://forums.sun.com/thread.jspa?threadID=707176 // Field field = ClassLoader.class.getDeclaredField("usr_paths"); field.setAccessible(t...
f223c53e-f29e-4866-9a95-4a69ac1d6261
0
@Before public void setUp() { }
44cc35f5-91d1-475a-9022-e798d095d365
6
@Override public ServerModel discardCards(DiscardCardsRequest request, CookieParams cookie) throws InvalidMovesRequest{ if(request == null) { throw new InvalidMovesRequest("Error: invalid discard cards request"); } ServerModel serverGameModel = serverModels.get(cookie.getGameID()); serverGameModel.ge...
8046df6b-14ed-4c05-930e-7a482cb6af6f
5
public Path getImgPath_ShutdownMenu(Imagetype type) { Path ret = null; switch (type) { case MOUSEFOCUS_KEYFOCUS: ret = this.imgShutdownMenu_KFocMFoc; break; case KEYFOCUS: ret = this.imgShutdownMenu_KFoc; break; ...
781530a9-2a74-4eb2-b0b9-257fd20bf4ad
8
public void calGraphicPieceArray(int [][] a){ int hp = h/11; pieces = new Piece [8][8]; for (int row = 0; row < 8; row++){ for (int col = 0; col < 8; col++){ if (a [row][col] == 0 || a [row][col] == -1){ pieces [row][col] = null; } else if (a [row][col] == 2){ pieces [row][col] = new ...
305fc656-8037-4065-ba3a-70e5af3ca77b
2
public void draw_grid(){ for (int x=0; x<40; x++){ Graphics.pen.drawLine(40*x, 0, 40*x, 600); } for (int y=0; y<30; y++){ Graphics.pen.drawLine(0, 40*y, 800, 40*y); } }
e792d97b-8368-40d2-94eb-78396b80ae6e
2
private void handleFatal( WebSocket conn, Exception e ) { onError( conn, e ); try { stop(); } catch ( IOException e1 ) { onError( null, e1 ); } catch ( InterruptedException e1 ) { Thread.currentThread().interrupt(); onError( null, e1 ); } }
f5e72dac-9bf7-45ea-b29c-cfbbbe8076b1
7
private boolean isBlockAhead(Engine engine) { int nextX = x; int nextY = y; switch (direction) { case 0: nextX++; break; case 1: nextY++; break; case 2: nextX--; break; case 3: nextY--; break; } if (engine.isBlockAhead(1.0)) { block(nextX, nextY); return true; } int next = ge...
a72af8ec-41a9-4f95-8183-e685c1fd6773
3
public static void render(){ int x = Game.PLAYER.getCameraX(); int y = Game.PLAYER.getCameraY(); int windowX = x + Game.SCREEN_WIDTH/2-width/2; int windowY = y + Game.SCREEN_HEIGHT/2-height/2; GL11.glDisable(GL11.GL_TEXTURE_2D); // border GL11.glColor3f(0.5f, 0.5f, 0.5f); GL11.glBegin(GL11.GL_QUA...
5aaefda1-afb6-4a8b-a487-2cf06ca1987b
7
private void addMountedMovementStat(double par1, double par3, double par5) { if (this.ridingEntity != null) { int var7 = Math.round(MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5) * 100.0F); if (var7 > 0) { if (this.ridingEntity in...
4dc74de2-4afb-4dec-9696-14d5d599229a
1
public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) popup.show(e.getComponent(), e.getX(), e.getY()); }
0c440fd5-2d0b-4459-9355-52babdb0086c
2
private void expandRecentConnectionsMenu(String newRecentConnection) { connectRecent.setEnabled(true); final JMenu recentConMenu = new JMenu(newRecentConnection); final JMenuItem connectToRecent = new JMenuItem("Connect"); final JMenuItem removeRecent = new JMenuItem("Remove"); recentConMenu.add(connectToR...
accf6b19-4801-4077-8b50-f17cb4fe6c22
5
public String spellCheckEditDistance(String wrong) { String correct; int distance=0; //System.out.println("Calculating distances of wrong word from all possible words..."); int min = Integer.MAX_VALUE; Set<String> candidates = new HashSet<String>(); for (int i = 0 ; i < correctWords.size() ; i++...
c2d4873f-6311-4e0d-9157-e8bd6e663d4b
9
public int CheckPoints() { if(player.getPoints() == 21) { gameover = true; return 1; //Player gets blackjack } else if(player.getPoints() > 21) { gameover = true; return 2; //Player busts } else if(dealer.getPoints() == 21) { gameover = true; return 3; //Dealer gets blackjack } else if(d...
6bad4963-b910-4b27-bbeb-8ca07220ac44
7
@Override public void deserialize(Buffer buf) { firstNameId = buf.readShort(); if (firstNameId < 0) throw new RuntimeException("Forbidden value on firstNameId = " + firstNameId + ", it doesn't respect the following condition : firstNameId < 0"); lastNameId = buf.readShort(); ...
db5e1625-4ae2-4acb-87aa-926c525eb354
7
public String getPlayerOrganismsView(int orgID){ String dataAsString = ""; // The string to return. // Some efficiency data caching String orgWorld = org.getWorld(orgID); int orgX = org.getX(orgID); int orgY = org.getY(orgID); // The logic. ...
a4def88f-bd60-440c-a61d-fb86afbc5858
2
public Currency execute() throws IOException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while (true){ System.out.println("Introduzca el código de una divisa"); currency = CurrencySet.getInstance().get(reader.readLine()); if (currenc...
01ba15d6-f74b-456d-aae3-daca856b8d89
5
public static String convertDealsListToJson(List<Deals> deals, List<String> merchantNameList, List<String> dealPicURLList) { if (deals.size() != merchantNameList.size() || deals.size() != dealPicURLList.size()) { return null; } JSONArray j_array = new JSONArray(); for (int i = 0; i < deals.size(); i...
096d0acb-d854-44a7-8034-5173933784e7
3
public static void saveCloudTest(JSlider numberOfUsersSlider, JSpinner durationSpinner, JSpinner iterationsSpinner, JSpinner rampupSpinner) { BmTestManager bmTestManager = BmTestManager.getInstance(); ...
d27e0581-3982-4690-977f-be2cb4dba86e
4
public int read(BitReader bitreader) throws JSONException { try { this.width = 0; Symbol symbol = this.table; while (symbol.integer == none) { this.width += 1; symbol = bitreader.bit() ? symbol.one : symbol.zero; } tick(...
aac918b1-444e-4bc2-98ab-dbd9364ff4a7
6
public static void main(String[] args) { // TODO Auto-generated method stub try{ String currentPath = new java.io.File( "." ).getCanonicalPath(); if(Utility.DBG) System.out.println("Current dir:"+currentPath); BufferedReader br = Utility.openFileToRead(currentPath+"\\src\\Input\\Problem2"); String...
630de6d8-7c0e-4b80-964d-c3d26264e9ff
5
boolean headMatch(String s, int fromIndex, String p) { if (s.length() < fromIndex + p.length() || fromIndex < 0) return false; for (int i = 0; i < p.length(); i++) { if (p.charAt(i) != '?' && p.charAt(i) != s.charAt(i + fromIndex)) return false...
d281ccf4-7a2f-48a7-a3c0-bf1a8c5b6f5a
4
public void loadSong(String fileName, String name) { try { URL songURL = Helpers.getResourceURL(this, fileName); Clip song = AudioSystem.getClip(); AudioInputStream inputStream = AudioSystem.getAudioInputStream(songURL); song.open(inputStream); songs.put(name, song); } catch(UnsupportedA...
a86d6861-1096-414d-8d95-78718fe504e7
1
public void testFormatParse_textYear_France() { DateTimeFormatter dateFormatter = new DateTimeFormatterBuilder() .appendLiteral('$') .appendText(DateTimeFieldType.year()) .toFormatter() .withLocale(Locale.FRANCE).withZoneUTC(); String str = new Da...
bf0288d4-bd73-4944-8c6e-596781939300
6
@Override public boolean canProvideEquipment(EquipmentType equipmentType) { BuildableType buildable = getCurrentlyBuilding(); for (AbstractGoods goods : equipmentType.getGoodsRequired()) { int available = getGoodsCount(goods.getType()); int breedingNumber = goods.getType().g...
d464073f-ffe5-48df-92d6-dfca79a6e400
2
private int findConfigIndex(String configName){ for (int i=0;i<configs.length;i++){ if (configs[i].startsWith(configName)){ return i; } } return -1; }
cf38d72c-bc48-4d44-a8ce-741ef653b387
4
@Override public void paintComponent(Graphics g) { int backgroundX, backgroundY; backgroundX = backgroundY = 0; Point p; p = house.player.getPosition(); backgroundX = this.getWidth() / 2 - p.x; backgroundY = this.getHeight() / 2 - p.y; if (backgroundX > 0) backgroundX = 0; els...
311fde88-cc7e-4c7d-a0d4-6a7144ddcf31
5
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; /**" * dial" of the sundial * draws out each line of the sundial accordingly and adds labels to each line * all lines are the same length "350", except for the two 6 hour lines if they are < -90 or >90 * all lines start at position 400...
0e5280ef-ab1f-4760-b5d3-c59e9d699f3d
3
private void sendIsland(Island island) { try { Game.server.sendPacketToAllClients(new Packet9Island(island)); for (Entity e : island.getEntities()) { if (e instanceof EntityBuilding) Game.server.sendPacketToAllClients(new Packet10EntityBuilding((EntityBuilding) e, map.islands.indexOf(island))); } }...
aae6e3ab-7b69-4841-9f61-02909b76c2a9
9
@Override public BlockFace giveRouterDirection() { // check if we are in the good region if (this.getSignAddress().isValid() && this.getSignAddress().getRegion().getAmount() != getWandererRegion()) { // case this is not the right region DirectionRegistry dir = RoutingTable.getDirection(getWandererRegion(...
fec120e7-1105-4742-bff8-8121edd2978a
2
@Override public void actionPerformed(ActionEvent e) { String person,weapon,room; Card disproveCard = null; person = (String) personGuess.getSelectedItem(); weapon = (String) weaponGuess.getSelectedItem(); room = (game.getHuman().getCurrentRoom()); Solution accusation = new Solution(person, weapon,...
f1410628-d48a-4d5d-b7b4-0f68f88319ec
1
public boolean isDone() { SubLWorkerStatus status = getStatus(); return !((status == SubLWorkerStatus.NOT_STARTED_STATUS) || (status == SubLWorkerStatus.WORKING_STATUS)); }
049ebeed-b7b5-45c9-bbd5-d1e643044ee1
2
public void putAll(Map<? extends K, ? extends List<V>> m) { this.map.putAll(m); }
ca57fc58-6602-451b-b39f-ebb0b897bb82
5
private static ArrayList<Position> possibleStartPositions(State state){ ArrayList<Position> positions = new ArrayList<Position>(); for(Position box : state.boxes){ if(state.isFree(box.x+1,box.y)){ positions.add(new Position(box.x+1,box.y)); } ...
657a45b5-61c9-4e60-95e0-de9dd910402f
1
public String toString(boolean showTimestamp){ String chatString = username + ": " + message; if(showTimestamp){ DateFormat formatter = new SimpleDateFormat("HH:mm:ss"); String formattedDate = formatter.format(messageDate); return "[" + formattedDate + "] " + chatString; }else{ return chatString; } ...
0c46dfde-d43b-4834-8956-bf26bc65cf54
5
void setListVC() { hasSuperUser = false; vc_files = new ArrayList<String>(); // String[] filenames; File f = new File("."); String files[] = f.list(); for (int i = 0; i < files.length; i++) { if (files[i].endsWith(".vc")) { if (files[i].equals(...
d48d271e-2495-4f53-b298-cab2018ee5b4
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; TestResponse other = (TestResponse) obj; if (balance == null) { if (other.balance != null) return false; } else if (!balance.equals(othe...
20af5987-9330-4ca7-a440-f280c68260df
8
private void init() { this.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); JPanel infoPanel = new JPanel(); // set up info panel directoryLabel = new JLabel("Directory: "); FrameSequencer frameSequencer = videoHandler.getFrameSequencer(); String dir = frameSequencer....
fc6aafa4-c988-4348-ab58-ccd09a1b33e5
1
public int getIntegerItem(String... names) throws ReaderException { try { return Ints.checkedCast(getLongItem(names)); } catch (IllegalArgumentException e) { throw new ReaderException("No key exists with this type, keys: " + _parseMessage(names) + ". In file: " + ConfigurationManager.config_file_path); } ...
56bfe889-5e21-4c6f-ace4-865e170a6f9c
7
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(in.readLine()); int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int k = Integer.parseInt(st.nextToken(...
822ac9f5-bc8d-4f46-afde-091e63d3a9e1
2
public Collection<SingleStatProcessor> getProcessors() { if ( lastUpdate != xml.lastModified()) { logger.info("XML file change detected"); try { init(); lastUpdate = xml.lastModified(); } catch (Exception e) { logger...