method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
b4248664-61a3-46e4-ab0f-d8dbca2353c3
4
public void basicSetCardio(Cardio myCardio) { if (this.cardio != myCardio) { if (myCardio != null) { if (this.cardio != myCardio) { Cardio oldcardio = this.cardio; this.cardio = myCardio; if (oldcardio != null) oldcardio.unsetWorkout(); } } } }
1b74e9c7-4ae3-4cf6-9292-5cf2c0bb2d49
0
public void setURI(String value) { this.uri = value; }
4abd22f2-25a2-47ca-9042-1cab8b62dbf5
7
public static String doubleToString(double d) { if (Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } // Shave off trailing zeros and decimal point, if possible. String string = Double.toString(d); if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { while (string.endsWith("0")) { string = string.substring(0, string.length() - 1); } if (string.endsWith(".")) { string = string.substring(0, string.length() - 1); } } return string; }
85ff45b1-cf07-4d3a-885d-817392588ec7
7
protected void setTeamRep() { User[] userArray = null; String[][] teamMember = debateSelected.getTeam(); int teamNub = 0, teamNub2 = 0; for (int i = 0; i < teamMember.length; i++) { for (int j = 0; j < teamMember[i].length; j++) { if (teamMember[i][j].equals(userLogin.getName())) { teamNub = i; teamNub2 = j; break; } } } teamMemberSTRDLM.removeAllElements(); for (int i = 0; i < teamMember[teamNub].length; i++) { if (!(teamMember[teamNub][i] == null || teamMember[teamNub][i].equals("null"))) { teamMemberSTRDLM.addElement(teamMember[teamNub][i]); } } if (teamRepDLM.size() != 0) { teamRepSTRJlbl.setText("Team Representative:" + teamRepDLM.get(0).toString()); } }
656efe90-c6d6-48c2-965c-bcf2a199517a
2
public int[] update() { int[] pos = new int[6]; if(oldx != -1) {pos[0] = Math.round(oldx); oldx = -1;} else {pos[0] = Math.round(x);} if(oldy != -1) {pos[1] = Math.round(oldy); oldy = -1;} else {pos[1] = Math.round(y);} timePassed = System.currentTimeMillis() - lastUpdate; lastUpdate = System.currentTimeMillis(); x += vx*timePassed; y += vy*timePassed; hitBox.setLocation((int) x, (int) y); pos[2] = Math.round(x); pos[3] = Math.round(y); pos[4] = maxDim.width; pos[5] = maxDim.height; return pos; }
3076569a-0b4f-4717-911f-bc9ddff936d3
4
public static Boolean locationEqualsXYZW(Location l, Integer x, Integer y, Integer z,String w) { if(l.getX() == x && l.getY() == y && l.getZ() == z && l.getWorld().getName() == w) return true; return false; }
70eb9a42-d2f0-4d05-a49b-446b579a2ee8
1
private void loadPreviousFonts() { this.previousFonts = new ArrayList<Font>(); for (int i = this.startFrom; i <= this.endAt; i++) { this.previousFonts .add(this.document.getChildren().get(i).getFont()); } }
4b18b154-bfdd-4952-896f-5321b871b1a0
9
private static void read(String filePath) { Scanner s = null; double[] maxima = null; boolean isMax = false; double[][] table = null; boolean[] onlyPositive = null; BufferedReader in; try { int cols; int rows; in = new BufferedReader(new FileReader(filePath)); int correction = getCorrection(in); in.close(); in = new BufferedReader(new FileReader(filePath)); //reopen String[] tmp = in.readLine().split(";"); cols = Integer.parseInt(tmp[0]) + 1; rows = Integer.parseInt(tmp[1]) + correction + 1; table = new double[rows][cols]; isMax = readTargetFunction(in, table, rows, cols); //read canbeNeg onlyPositive = new boolean[cols - 1]; tmp = in.readLine().split(";"); boolean nonNegative = true; for (int i = 0; i < cols - 1; i++) { boolean b = "true".equals(tmp[i].trim()); onlyPositive[i] = b; nonNegative = nonNegative & b; } readTable(in, table, rows, cols); if (!nonNegative) maxima = handleNegativity(table, onlyPositive, rows, cols); } catch (Exception e) { e.printStackTrace(); } if (table != null) { Simplex simple = new Simplex(table, isMax); try { //simple.printTable(); double solution = simple.solve(); //simple.printTable(); double[] vars = simple.getSolutionPerVar(); //more bla for non negativity if (maxima != null) { for (int i = 0; i < onlyPositive.length; i++) { if (!onlyPositive[i]) { vars[i] = vars[i] - maxima[i]; } } solution = simple.insertInTargetFunction(vars); } for (int i = 0; i < vars.length; i++) System.out.print(vars[i] + " "); System.out.print(solution); System.out.println(); System.out.println(simple.getBla()); } catch (SimplexException e) { System.out.println(e.getMessage()); } } }
6a7d0617-e069-45c7-bed1-52e737f17e7c
3
private void acao141(Token token) throws SemanticError { try{ idAtual = tabela.get(token.getLexeme(), nivelAtual); if (idAtual instanceof IdentificadorVariavelCampoRegistro) { if (regAtual.getListaCampos().contains(idAtual)) { tipoLadoEsquerdo = ((IdentificadorVariavel) idAtual).getTipo(); } else { throw new SemanticError(token.getLexeme() + " não é campo do registro atual", token.getPosition()); } } else { throw new SemanticError("Esperava-se um campo de registro", token.getPosition()); } }catch(IdentificadorNaoDefinidoException ex){ throw new SemanticError(ex.getMessage(), token.getPosition()); } }
00f6fd6c-d863-4466-9a9b-dfb4ee14eb38
6
@Override public Component getListCellRendererComponent( JList<? extends State> list, State value, int index, boolean isSelected, boolean cellHasFocus) { State state = value; this.setFont(fFont); setIcon(null); if (state.messageWaiting) { setText("! " + state.item); setForeground(Color.red); } else if (state.notBeThere) { setText("x " + state.item); setForeground(Color.blue); } else { if (fSimpleList) { setText(state.item); } else { setText(" " + state.item); } setForeground(isSelected ? Color.white : Color.black); } this.setBackground(isSelected ? textBackground.darker() : textBackground); return this; }
7005a661-a454-4c78-9dfc-e509569c2db1
5
void testHyperlinks() { WorkBookHandle tbo = new WorkBookHandle(); String sheetname = "Sheet1"; WorkSheetHandle sheet1 = null; try { sheet1 = tbo.getWorkSheet( sheetname ); } catch( WorkSheetNotFoundException e ) { System.out.println( "couldn't find worksheet" + e ); } try { tbo.copyWorkSheet( sheetname, "copy of " + sheetname ); } catch( WorkSheetNotFoundException e ) { System.out.println( e ); } String st4 = "G"; try { // CellHandle salary3 = sheet1.getCell(st4); String ht = "E3:E10"; for( int t = 3; t <= 10; t++ ) { sheet1.add( "ExtenXLS Home Page", "E" + t ); CellHandle link1 = sheet1.getCell( "E" + t ); sheet1.moveCell( link1, st4 + t ); link1.setURL( "http://www.extentech.com/estore/product_detail.jsp?product_group_id=1" ); } } catch( CellNotFoundException e ) { System.out.println( e ); } catch( CellPositionConflictException r ) { System.out.println( r ); } testWrite( tbo ); }
f26dedf4-72b8-40bb-b809-3cca2880f7a7
1
public ArrayList<String> getNeighbours() { ArrayList<String> neighbours = new ArrayList<String>(); for (Edge e : this.startingEdges) { neighbours.add(e.getDestination().getName()); } return neighbours; }
fdb4596d-edea-42b6-a827-daffbad79004
0
public static byte[] hash(byte[] data) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-1"); md.update(data); return md.digest(); }
05cff970-6af2-4c99-8fb7-f0747e41ffe9
7
public void write(OutputStream os, int tempo, int sps) throws IOException { int ndur = (int) ((60.0 / (double) tempo) * sps * beats); if (name == ' ') { for (int x = 0; x < ndur; x++) os.write(0); return; } String noteName = String.format("%c%c%s",scale < 10 ? scale + '0' : scale,name,sharp ? "#" : ""); Double freq = notes.get(noteName); if (freq == null) System.err.println(noteName); for (int x = 0; x < ndur; x++) { byte b = (byte) ((volume * Math.sin((double) x / (sps / freq) * 2 * Math.PI) * (ndur - x < 100 ? (ndur - x) / 100. : 1))); os.write(b); } os.write(0); }
1922e5e0-b427-4480-975f-23bc9d6753c9
4
public static String getBanReason(String playerName){ String reason = "Not Banned"; if(isBanned(playerName)){ try { SQL_STATEMENT = SQL_CONNECTION.createStatement(); SQL_RESULTSET = SQL_STATEMENT.executeQuery("SELECT * FROM bans WHERE username='" + playerName + "'"); // This loop checks all bans on record for the user to see if any tempbans are still active // Note tempbans are done in DAYS, the argument is a Double // For example 0.5 would be 0.5(1 day)=12hours // .1 -> 2.4 hours // 7 = 7 days, etc. while (SQL_RESULTSET.next()) { if(SQL_RESULTSET.getLong("expire") > System.currentTimeMillis()){ reason = SQL_RESULTSET.getString("reason"); } } SQL_RESULTSET.close(); SQL_STATEMENT.close(); } catch(SQLException e){ e.printStackTrace(); } } return reason; }
cb5fa203-cfcc-4ce7-b98d-09fdb7e6b5ac
8
private void jbtnCreerThemeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCreerThemeActionPerformed try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); } catch (ClassNotFoundException ex) { JOptionPane.showMessageDialog(this, "Driver non trouvé " + ex.getMessage()); } Connection connexion = null; try { connexion = DriverManager.getConnection(sqlConnexion); } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "Erreur de connexion a la base" + ex.getMessage()); } Statement stmt = null; try { stmt = connexion.createStatement(); } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "Erreur Compte Utilisateur" + ex.getMessage()); } try { if (jtfNewTheme.getText()!=""){ if(jrbtTheme.isSelected()){ stmt.executeUpdate("INSERT INTO theme VALUES('"+jtfNewTheme.getText()+"')"); } if(jrbtSousTheme.isSelected()){ if(jcbTheme.getSelectedIndex()!=-1){ Theme th = (Theme)jcbTheme.getSelectedItem(); int idTheme = th.getId_theme(); stmt.executeUpdate("INSERT INTO soustheme VALUES("+idTheme+",'"+jtfNewTheme.getText()+"')"); }else{ JOptionPane.showMessageDialog(this, "Veuillez selectionner un theme parent"); } } }else{ JOptionPane.showMessageDialog(this, "Nom de theme ou sous Theme non valide"); } } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "Erreur Base de données \n"+" Intitulé déjà existant !"); } jtTheme.setModel(initTreeModel()); jcbTheme.setModel(initTheme()); }//GEN-LAST:event_jbtnCreerThemeActionPerformed
5de8cc43-527a-4bf5-a2a9-85ab137c5df3
7
final public Column Column() throws ParseException { String name1 = null; String name2 = null; String name3 = null; // [schema.][tabella.]colonna name1 = RelObjectName(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 93: jj_consume_token(93); name2 = RelObjectName(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 93: jj_consume_token(93); name3 = RelObjectName(); break; default: jj_la1[19] = jj_gen; ; } break; default: jj_la1[20] = jj_gen; ; } String colName = null; Table table = null; if (name3 != null) { table = new Table(name1, name2); colName = name3; } else if (name2 != null) { table = new Table(null, name1); colName = name2; } else { table = new Table(null, null); colName = name1; } {if (true) return new Column(table, colName);} throw new Error("Missing return statement in function"); }
c4837341-36ee-4a5a-881d-36d504af7c49
5
public static BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage) image; } // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); // Determine if the image has transparent pixels; for this method's // implementation, see e661 Determining If an Image Has Transparent // Pixels boolean hasAlpha = hasAlpha(image); // Create a buffered image with a format that's compatible with the // screen BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { // Determine the type of transparency of the new buffered image int transparency = Transparency.OPAQUE; if (hasAlpha) { transparency = Transparency.BITMASK; } // Create the buffered image GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); } catch (HeadlessException e) { // The system does not have a screen } if (bimage == null) { // Create a buffered image using the default color model int type = BufferedImage.TYPE_INT_RGB; if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); } // Copy image to buffered image Graphics g = bimage.createGraphics(); // Paint the image onto the buffered image g.drawImage(image, 0, 0, null); g.dispose(); return bimage; }
71408b03-fb24-42d0-b356-f5824605778a
1
@Override public boolean supports(Class<?> arg0) { return Image.class.equals(arg0); }
8424f325-fef4-41f2-bb1b-8c376cb1e527
2
public boolean isIon() { for(int i = 0; i < ions.length; i++) if(this.equals(new MiniCompound(ions[i]))) return true; return false; }
b4d98621-0673-4e47-8c7c-12d77e37499d
7
public void paintComponent(Graphics g){ if (mapDrawer != null){ if (mapImage == null || this.getWidth() != mapImage.getWidth(this) || this.getHeight() != mapImage.getHeight(this) || this.repaintMap){ mapImage = new BufferedImage(getWidth(),getHeight(),BufferedImage.TYPE_INT_RGB); colorImage = new BufferedImage(getWidth(),getHeight(),BufferedImage.TYPE_INT_RGB); Graphics gImage = mapImage.getGraphics(); mapDrawer.setSize(getWidth(), getHeight()); mapDrawer.drawMap(gImage); Graphics cImage = colorImage.getGraphics(); mapDrawer.drawMap(cImage,sqColorChooses); repaintMap = false; } g.drawImage(mapImage,0,0,Color.WHITE,this); Graphics2D g2d = (Graphics2D) g; if (rect != null){ g2d.draw(rect); } if (line != null){ g2d.draw(line); } } }
033e1f66-d44a-4e2e-b8c0-59ec4bd0534b
5
public PercSerializationInstantiator(Class type) { // Find the first unserializable parent class Class unserializableType = type; while(Serializable.class.isAssignableFrom(unserializableType)) { unserializableType = unserializableType.getSuperclass(); } try { // Get the special Perc method to call Class percMethodClass = Class.forName("COM.newmonics.PercClassLoader.Method"); newInstanceMethod = ObjectInputStream.class.getDeclaredMethod("noArgConstruct", new Class[] {Class.class, Object.class, percMethodClass}); newInstanceMethod.setAccessible(true); // Create invoke params Class percClassClass = Class.forName("COM.newmonics.PercClassLoader.PercClass"); Method getPercClassMethod = percClassClass.getDeclaredMethod("getPercClass", new Class[] {Class.class}); Object someObject = getPercClassMethod.invoke(null, new Object[] {unserializableType}); Method findMethodMethod = someObject.getClass().getDeclaredMethod("findMethod", new Class[] {String.class}); Object percMethod = findMethodMethod.invoke(someObject, new Object[] {"<init>()V"}); typeArgs = new Object[] {unserializableType, type, percMethod}; } catch(ClassNotFoundException e) { throw new ObjenesisException(e); } catch(NoSuchMethodException e) { throw new ObjenesisException(e); } catch(InvocationTargetException e) { throw new ObjenesisException(e); } catch(IllegalAccessException e) { throw new ObjenesisException(e); } }
95fe254c-3ac6-46ec-8dcd-d8866dc3e150
3
@Test public void testLipidPercentage() { MealRepartition mr = new MealRepartition(); try { mr.setLipidPercentage(0.34); fail("A BadLipidPercentageException should have been thrown."); } catch (BadLipidPercentageException e) {} try { mr.setLipidPercentage(0.41); fail("A BadLipidPercentageException should have been thrown."); } catch(BadLipidPercentageException e) {}; try { mr.setLipidPercentage(0.35); } catch(BadLipidPercentageException e) { fail("A BadLipidPercentageException has been thrown."); } }
e517fe45-f439-4c25-b99e-3c8ea2275f30
8
public Loc<T> location(final Path... path) { Loc<T> l = this.root(); for (Path p : path) { switch (p) { case DOWN: l = l.down(); break; case LEFT: l = l.left(); break; case RIGHT: l = l.right(); break; case UP: l = l.up(); break; case LEFT_MOST: l = l.leftMost(); break; case RIGHT_MOST: l = l.rightMost(); break; case NEXT: l = l.next(); break; } } return l; }
9280efa9-d8f4-4570-93ea-81dd7b8eaa34
5
public PartialMessage read(PartialMessage read) { try { int buffLength = 4096 * 2; int len = 0; byte[] b = new byte[buffLength]; //rawIn is a Socket.getInputStream(); while(!this.socket.isClosed()){ //Read the first two bytes of the message, the frame type byte - and the payload length byte byte[] buf = readBytes(2); //System.out.println("Headers:"); //Print them in nice hex to console //convertAndPrint(buf); //And it with 00001111 to get four lower bits only, which is the opcode int opcode = buf[0] & 0x0F; int msgend = buf[0] & 0x80; //Opcode 8 is close connection if (opcode == 8) { //Client want to close connection! System.out.println("Client closed!"); //this.queue.interrupt(); this.requestedClosing = true; socket.shutdownInput(); this.shutdown(); return null; //TODO: Server should unregister the client } else if (opcode == 0) { final int payloadSize = getSizeOfPayload(buf[1]); //System.out.println("Payloadsize: " + payloadSize); //Read the mask, which is 4 bytes, and than the payload buf = readBytes(MASK_SIZE + payloadSize); //System.out.println("Payload:"); //convertAndPrint(buf); //method continues below! buf = unMask(Arrays.copyOfRange(buf, 0, 4), Arrays.copyOfRange(buf, 4, buf.length)); String message = new String(buf); read = new PartialMessage(message); read.setComplete(msgend != 0); return read; } //Else I just assume it's a single framed text message (opcode 1) else { int payloadSize = getSizeOfPayload(buf[1]); if (payloadSize == 126) { byte[] eps = new byte[2]; socket.getInputStream().read(eps); payloadSize = (eps[0] & 0xFF) * 0x100 + (eps[1] & 0xFF); } //System.out.println("Payloadsize: " + payloadSize); //Read the mask, which is 4 bytes, and than the payload buf = readBytes(MASK_SIZE + payloadSize); //System.out.println("Payload:"); //convertAndPrint(buf); //method continues below! buf = unMask(Arrays.copyOfRange(buf, 0, 4), Arrays.copyOfRange(buf, 4, buf.length)); String message = new String(buf); read = new PartialMessage(message); read.setComplete(msgend != 0); return read; } } } catch (IOException ex) { Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex); } return null; }
ab8b1877-ec80-46c0-b35c-d5544e0fdb7a
8
public static void javaOutputForeach(Cons loop) { { Stella_Object continuationtest = loop.rest.value; Cons valueassignments = ((Cons)(loop.rest.rest.value)); Cons nextassignments = ((Cons)(loop.fourth())); int nofnextassignments = nextassignments.length(); Cons body = ((Cons)(loop.fifth())); boolean eolseparateexpressionsP = (nofnextassignments > 2) || (((Integer)(Stella.$JAVA_INDENT_CHARS$.get())).intValue() > 35); if (nofnextassignments == 0) { ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.print("while ("); Stella_Object.javaOutputStatement(continuationtest); ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println(") {"); Stella.javaBumpIndent(); Cons.javaOutputStatements(valueassignments.concatenate(body, Stella.NIL)); Stella.javaUnbumpIndent(); Stella.javaIndent(); ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("}"); return; } ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.print("for (;"); Stella.javaBumpIndent(); Stella.javaBumpIndent(); Stella.javaBumpIndent(); Stella_Object.javaOutputStatement(continuationtest); ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.print("; "); if (!(nextassignments == Stella.NIL)) { if (eolseparateexpressionsP) { ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println(); } { Stella_Object next = null; Cons iter000 = nextassignments; int i = Stella.NULL_INTEGER; int iter001 = 1; for (;!(iter000 == Stella.NIL); iter000 = iter000.rest, iter001 = iter001 + 1) { next = iter000.value; i = iter001; if (eolseparateexpressionsP) { Stella.javaIndent(); } Stella_Object.javaOutputStatement(next); if (!(i == nofnextassignments)) { if (eolseparateexpressionsP) { ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println(","); } else { ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.print(", "); } } } } } ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println(") {"); Stella.javaUnbumpIndent(); Stella.javaUnbumpIndent(); Cons.javaOutputStatements(valueassignments.concatenate(body, Stella.NIL)); Stella.javaUnbumpIndent(); Stella.javaIndent(); ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("}"); } }
de4bf6b2-1048-4292-a7d3-79acdd3fc082
8
private void reDrawList(int x, int y) { if(type == 0) { //Initialize head if(head == null) { if(myInfo.getHead() != null) head = new linkedButton(myInfo.getHead(),null); tail = head; } //Inserts new buttons if nesscessary if(head != null && tail.getInfo() != myInfo.getTail()) { nameList hld = myInfo.getHead(); linkedButton lBut = head; while(hld != null) { if(lBut == null) tail = new linkedButton(hld,tail); else lBut = lBut.getNext(); hld = hld.getNext(); } } } //Place the list if(head != null) { head.setCasLocation(x,y); } }
b301d4b9-c65a-43a2-9d03-50c28ee3933e
9
public static List<String> getClassNamesFromPackage(String packageName, ClassLoader classLoader) throws IOException { URL packageURL; ArrayList<String> names = new ArrayList<>(); packageName = packageName.replace(".", "/"); packageURL = classLoader.getResource(packageName); if(packageURL != null && packageURL.getProtocol().equals("jar")) { // Loop through all things in the jar String jarFileName; JarFile jf ; Enumeration<JarEntry> jarEntries; String entryName; jarFileName = URLDecoder.decode(packageURL.getFile(), "UTF-8"); jarFileName = jarFileName.substring(5,jarFileName.indexOf("!")); jf = new JarFile(jarFileName); jarEntries = jf.entries(); while(jarEntries.hasMoreElements()) { // Get the jar file and loop through everything in it entryName = jarEntries.nextElement().getName(); if(entryName.startsWith(packageName) && entryName.endsWith(".class") && entryName.length() > packageName.length() + 5){ names.add(entryName.replace(".class", "").replace('/', '.')); // Put the stuff back again } } jf.close(); } else if(packageURL != null) { // Otherwise loop through all things in the classpath File folder = new File(packageURL.getFile()); File[] content = folder.listFiles(); String entryName; if (content != null) { for(File file : content) { entryName = file.getName(); names.add(entryName.replace(".class", "").replace('/', '.')); } } } return names; }
c40a489d-1331-43d1-bfa2-80f01b6dba36
4
public void unreadFrame() throws BitstreamException { if (wordpointer==-1 && bitindex==-1 && (framesize>0)) { try { source.unread(frame_bytes, 0, framesize); } catch (IOException ex) { throw newBitstreamException(STREAM_ERROR); } } }
1503f49a-0700-4948-93bb-29f848bb48d2
7
private void jButtonParcourirINActionPerformed( final java.awt.event.ActionEvent evt) { // TODO add your handling code here: final String mss = "Bouton Parcourir : " + "action interdite car"; final int nb = 300; switch (etat) { case INIT_JSON_XML: selct = new SelecteurDeFichier(jsonFilter, this); selct.setSize(nb, nb); selct.setVisible(true); break; case INIT_XML_JSON: selct = new SelecteurDeFichier(xmlFilter, this); selct.setSize(nb, nb); selct.setVisible(true); break; case OUTPUT_JSON_XML: throw new RuntimeException(mss + " Etat OUTPUT_JSON_XML"); case OUTPUT_XML_JSON: throw new RuntimeException(mss + "Etat OUTPUT_XML_JSON"); case OUTPUT_XML_JSON_VIA_DOM: throw new RuntimeException(mss + "Etat OUTPUT_XML_JSON"); case VIEW_JSON_XML: throw new RuntimeException(mss + "Etat VIEW_JSON_XML"); case VIEW_XML_JSON: throw new RuntimeException(mss + "Etat VIEW_XML_JSON"); default: break; } }
84e7eb0b-0a86-4678-bc95-234e784747fe
4
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final User other = (User) obj; if (!Objects.equals(this.username, other.username)) { return false; } if (!Objects.equals(this.ip, other.ip)) { return false; } return true; }
5ed530d9-d979-401d-b7b5-37023d3d51c6
7
public static void lagKompaktGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) { SpringLayout layout; try { layout = (SpringLayout) parent.getLayout(); } catch (ClassCastException exc) { System.err.println("The first argument to lagKompaktGrid must use SpringLayout."); return; } //Align all cells in each column and make them the same width. Spring x = Spring.constant(initialX); for (int c = 0; c < cols; c++) { Spring width = Spring.constant(0); for (int r = 0; r < rows; r++) { width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth()); } for (int r = 0; r < rows; r++) { SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols); constraints.setX(x); constraints.setWidth(width); } x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad))); } //Align all cells in each row and make them the same height. Spring y = Spring.constant(initialY); for (int r = 0; r < rows; r++) { Spring height = Spring.constant(0); for (int c = 0; c < cols; c++) { height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight()); } for (int c = 0; c < cols; c++) { SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols); constraints.setY(y); constraints.setHeight(height); } y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad))); } SpringLayout.Constraints pCons = layout.getConstraints(parent); pCons.setConstraint(SpringLayout.SOUTH, y); pCons.setConstraint(SpringLayout.EAST, x); }
929fc1a1-0424-4c5e-90b5-5bcb1ebcf3a5
3
private static double[][] generateIdentity(int l){ double[][] T = new double[l][l]; for(int i = 0; i<l; i++){ for(int j = 0; j<l; j++){ if(i == j) T[i][j] = 1; else T[i][j] = 0; } } return T; } //end generateIdentity
d533a39d-4100-4fc5-97b4-9cc50a90f3af
4
public static void copyTo(File file, String filePath) { System.out.println("Copying file "+file.getAbsolutePath()+ " to "+filePath); //System.exit(0); try { int b; inputStream = new FileInputStream(file); outputStream = new FileOutputStream(filePath); if(!file.canRead()) return; while((b=inputStream.read())!=-1) { outputStream.write(b); } inputStream.close(); outputStream.close(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
f5168bf6-1081-405f-a127-f74a4aaf4e91
6
public static double findAccuracy(Set<RepairedCell> truth, Set<RepairedCell> found){ if(found.size()!=0){ HashMap<Integer,HashSet<String>> truthMap = new HashMap<Integer,HashSet<String>>(); for(RepairedCell cell:truth){ HashSet<String> columnIds = null; if(truthMap.get(cell.getRowId())==null){ columnIds = new HashSet<String>(); }else{ columnIds = truthMap.get(cell.getRowId()); } columnIds.add(cell.getColumnId()); truthMap.put(cell.getRowId(), columnIds); } int tAndF = 0; for(RepairedCell cell:found){ if(truthMap.get(cell.getRowId())!=null){ if(truthMap.get(cell.getRowId()).contains(cell.getColumnId())){ tAndF++; } } } double precision = tAndF*1.0/found.size(),recall = tAndF*1.0/truth.size(); return 2*precision*recall/(precision+recall); } return 0; }
588940ed-c97f-4a57-b10b-8cc0b322a19f
1
private void testReferrers(String[] referrerStrings, Application expectedApplication) { for (String agentString : referrerStrings) { assertEquals(expectedApplication, Application.parseReferrerString(agentString)); } }
5d7e97a5-e781-4ae0-93dc-c7ac21e9b38b
4
public boolean equalsExpr(final Expr other) { return (other != null) && (other instanceof ArithExpr) && (((ArithExpr) other).operation == operation) && ((ArithExpr) other).left.equalsExpr(left) && ((ArithExpr) other).right.equalsExpr(right); }
440fa993-fff8-4f6e-8f45-26d2d3b4efaa
7
@EventHandler public void onClick(InventoryClickEvent event) { if (event.getSlot() == 999) event.getWhoClicked().closeInventory(); for (Inventory inv : ClashOfBlocks.getInstance().getInventoryManager().getInventories()) { if (inv == null) break; if (inv.isInventory(event.getInventory())) { event.setCancelled(true); for (MenuItem item : inv.getMenuItems()) { if (item == null) break; if (event.getSlot() == item.getItemPosition()) { item.onClick(event); break; } } break; } } }
89acab1e-d4fa-4791-8270-0cc1bba2b9b7
1
public void draw(Graphics2D g) { for (Entity entity : entities) { entity.draw(g); } super.draw(g); }
8674fefb-075d-4efd-8a0b-63073842be7e
3
public void create() throws IrodsException { try { JargonCollection parent = getParentCollection(); if (parent != null && !parent.exists()) { parent.create(); } conn.irodsFileSystem.mkdir(irodsFile, false); } catch (JargonException ex) { throw new IrodsException(ex); } }
c5212a87-0768-4865-8817-e9f50c98d21c
5
@Override public String send(String msg) throws ConnectionException { FileReader fileReader = null; //DatagramSocket socket = null; Socket socket = null; String output = null; try { String serverString = ""; String portString = ""; fileReader = new FileReader("src/main/resources/server"); LineNumberReader lineNumberReader = new LineNumberReader(fileReader); serverString = lineNumberReader.readLine(); InetAddress serverAddress = InetAddress.getByName(serverString); fileReader.close(); fileReader = new FileReader("src/main/resources/port"); lineNumberReader = new LineNumberReader(fileReader); portString = lineNumberReader.readLine(); int portInt = Integer.parseInt(portString); fileReader.close(); logger.info(serverString); logger.info(portString); socket = new Socket(serverAddress, portInt); PrintWriter out = new PrintWriter(socket.getOutputStream()); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); logger.info("sending Msg"); out.println(msg); out.flush(); logger.info("Msg sent"); logger.info("receiving Msg"); output = in.readLine(); logger.info("Msg received"); out.close(); in.close(); /* socket = new DatagramSocket(); DatagramPacket packet = new DatagramPacket(msg.getBytes(), msg.getBytes().length, serverAddress, portInt); logger.info("sending Datagram"); socket.send(packet); logger.info("Datagram sent"); byte[] buffer = new byte[256]; packet = new DatagramPacket(buffer, buffer.length); logger.info("receiving Datagram"); socket.receive(packet); logger.info("Packet received"); output = new String(packet.getData()); logger.info("Packet decrypted: " + output); */ } catch (FileNotFoundException e) { throw new ConnectionException(e.getMessage()); } catch (IOException e) { throw new ConnectionException(e.getMessage()); } finally { try { if (fileReader != null) { fileReader.close(); } if (socket != null) { socket.close(); } } catch (IOException e) { throw new ConnectionException(e.getMessage()); } } return output; }
1f0f1059-bae5-4e41-80f6-60b5fe5949aa
4
public static String readPassword(String pPrompt){ if(System.console() == null) { //Hack for JDev debugging as it doesn't provide a console when running if("DEV".equals(ScriptRunnerVersion.getVersionNumber())){ return readArg(pPrompt, false); } throw new ExFatalError("Could not locate a console. ScriptRunner must be invoked from an interactive command shell or have all arguments provided when invoked."); } String lPassword = null; int lTries = 0; String lPrompt = pPrompt; while(XFUtil.isNull(lPassword)){ if(lTries > 0){ lPrompt = "[Password cannot be null, try again] " + pPrompt; } lPassword = new String(System.console().readPassword(lPrompt)); lTries++; } return lPassword; }
a4d0a15a-21f9-4732-82cd-a7746958f00c
3
public final void setMaxMeasuredValueDecimals(final int MAX_MEASURED_VALUE_DECIMALS) { final int DECIMALS = MAX_MEASURED_VALUE_DECIMALS > 5 ? 5 : (MAX_MEASURED_VALUE_DECIMALS < 0 ? 0 : MAX_MEASURED_VALUE_DECIMALS); if (null == maxMeasuredValueDecimals) { _maxMeasuredValueDecimals = MAX_MEASURED_VALUE_DECIMALS; } else { maxMeasuredValueDecimals.set(DECIMALS); } }
ba58ac3c-315f-42be-b891-91ed4f5c1206
1
public String getResultRunCompiledPHPCode(String fileSource) { if(cekAnnotation(fileSource)) { return getFilteredPHPSource(fileSource) + " $ob = new " + getClassName(getFilteredPHPSource(fileSource)) + ";$ob -> " + getMethodName(getAnnotationClientMethod(fileSource)); } else { return getNativePHPSource(fileSource) + " $ob = new " + getClassName(getNativePHPSource(fileSource)) + ";$ob -> " + "main();"; } }
d5a53539-43ae-4366-b6e4-831826238cbe
2
public boolean matches( Class<?> clazz ) { return Modifier.isInterface( clazz.getModifiers() ) && !clazz.isAnnotation(); }
3366c336-e1fb-43ce-a14c-0e147710f1ff
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; User other = (User) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; }
82dc78a7-0e4e-4596-93eb-0facaa9c8868
0
public void mouseExited(MouseEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
e3f76a20-096d-4e0c-bcca-6a890581acaa
9
public void distributeWithOrders() { logger.info("Starting distributing..."); do { // 1. get all orders from the container List<Order> orderList = null; try { orderList = sharedWorkspace.getUnfinishedOrders(); // add marked "order" to the end of the order list // if the for loop reaches this "order" a normal computer is produced Order orderNormalProduction = new Order(ORDER_NORMAL_PRODUCTION_ID, 0, null, 0, false); orderList.add(orderNormalProduction); } catch (SharedWorkspaceException e2) { logger.severe(e2.getMessage()); } // 2. process orders in given (fifo) order for(Order order:orderList) { try { if(order.getId() == ORDER_NORMAL_PRODUCTION_ID) { distributeNormalComputer(); break; } sharedWorkspace.startTransaction(); // check if all computers for this order are ready if(sharedWorkspace.testOrderCountMet(order)) { List<Computer> computerList = sharedWorkspace.takeAllOrderedComputers(order); int i = 1; for(Computer computer:computerList) { computer.getWorkers().add(this); // if too much computers have been produced for this order // ship the rest as normal computers if(i > order.getComputerCount()) computer.setOrder(null); sharedWorkspace.shipComputer(computer); i++; } } sharedWorkspace.finishOrder(order); sharedWorkspace.commitTransaction(); } catch(SharedWorkspaceException e) { logger.severe(e.getMessage()); try { sharedWorkspace.rollbackTransaction(); } catch (SharedWorkspaceException e1) { logger.severe(e1.getMessage()); } } } } while(true); }
d4bacfdf-27c8-4095-a134-be8b7db1cc65
7
public void init() { System.out.println("###### Applet init() #######"); started = false; stopping = false; currentDisk = null; if (cpu == null) { SIDMixer.DL_BUFFER_SIZE = 16384; System.out.println("starting CPU"); cpu = new CPU(imon, getCodeBase().toString(), new SELoader()); System.out.println("Status: initializing"); doubleScreen = getParameterAsInt("doubleScreen", 0); int freescale = getParameterAsInt("freescale", 0); screen = new C64Screen(imon, doubleScreen > 0); cpu.init(screen); screen.init(cpu); if (freescale != 0) { screen.setIntegerScaling(false); } // Not when emulating 1541!! // cpu.patchROM(this); memory = cpu.getMemory(); setLayout(new BorderLayout()); setBackground(Color.black); setForeground(lblue); // Get the diskdrive reader!!! reader = new C64Reader(); reader.setCPU(cpu); canvas = (C64Canvas) screen.getScreen(); fullscreen(fullscreen); screen.registerHotKey(KeyEvent.VK_BACK_SPACE, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK , "reset()", cpu); screen.registerHotKey(KeyEvent.VK_F12, KeyEvent.CTRL_DOWN_MASK , "toggleFullscreen()", this); repaint(); validate(); addKeyListener(canvas); canvas.requestFocus(); // A test... for real 1541 emulation... cpu.getDrive().setReader(reader); AudioClip trackSound = null; AudioClip motorSound = null; URL url = getClass().getResource("sounds/track.wav"); System.out.println("Audio URL:" + url); if (url != null) trackSound = Applet.newAudioClip(url); url = getClass().getResource("sounds/motor.wav"); if (url != null) motorSound = Applet.newAudioClip(url); screen.setSounds(trackSound, motorSound); setColorSet(getParameterAsInt("colorset", 0)); int rq1541 = getParameterAsInt("require1541", 0); require1541 = (rq1541 == 1); for (int i = 0, n = 12; i < n; i++) { String f1 = getParameter("hotkey-f" + (i + 1)); if (f1 != null && f1.length() > 0) { // 0 - 11 => ALT-F1-12 screen.registerHotKey(KeyEvent.VK_F1 + i, KeyEvent.ALT_DOWN_MASK, f1, this); } } System.out.println("*** INIT END ***"); } }
075fd622-a6ca-4007-afb2-b3759a321891
0
public long duration() { return (now()-startTime); }
701b9ce2-298b-4458-94b9-4ba968e3ab14
2
public void collides(GameObject source, Collection<GameObject> objects){ for(GameObject object : objects){ if(source.collidesWith(object)){ gameEventListener.handleGameEvent(new CollisionEvent(this, Type.COLLISION, source, object)); } } }
7a3c4316-7421-45ce-8c5d-0f03a71ee36f
4
public void createNodesForThisGraph() { int paperListLength = Array.getLength(paperList); System.out.println("NODES CREATION,paperlist hossza: " + paperListLength); //here we set the attributes for each node from the paperlist for (int i = 0;i < 3;i++) { try { Node n = graph.addNode(paperList[i].getTitle()); //==== a node's uniqe identifier is its title n.addAttribute("ui.label", paperList[i].getTitle()); n.addAttribute("Title", paperList[i].getTitle()); n.addAttribute("Authors", paperList[i].getAuthors()); n.addAttribute("Date", paperList[i].getDate()); n.addAttribute("Link", paperList[i].getLink()); n.addAttribute("DOI", paperList[i].getDOI()); n.addAttribute("CitationCount", 0 ); n.addAttribute("Comment", paperList[i].getComment()); System.out.println("n pont címe " + n.getAttribute("Title")); System.out.println("n pont szerzoi " + n.getAttribute("Authors")); System.out.println("n pont datum " + n.getAttribute("Date")); System.out.println("n pont link " + n.getAttribute("Link")); System.out.println("n pont DOI " + n.getAttribute("DOI")); System.out.println(""); //==== the list's first paper will be the parent //==== so we add an EXPANDED attribute to it to easily find it if(i == 0) { n.addAttribute("ui.class","EXPANDED"); paperList[0].setCitCount( (paperListLength - 1) ); } } catch (IdAlreadyInUseException e) { Node n = graph.addNode(paperList[i].getTitle() + "duplicate with: " + i); n.addAttribute("ui.label", paperList[i].getTitle()); n.addAttribute("Title", paperList[i].getTitle()); n.addAttribute("Authors", paperList[i].getAuthors()); n.addAttribute("Date", paperList[i].getDate()); n.addAttribute("Link", paperList[i].getLink()); n.addAttribute("DOI", paperList[i].getDOI()); n.addAttribute("CitationCount", 0 ); n.addAttribute("Comment", paperList[i].getComment()); } catch (Exception f) { f.printStackTrace(); } } }
e17a56c5-3d5f-4643-bc97-a0be798cff5d
5
private void generateAllDeploymentAlternatives() { if (project.getDeploymentAlternatives().size() == 0) { List<HardwareSet> sequenceHardwareSets = new LinkedList<>(); int hardwarePossibilities[] = new int[project.getComponents().size()]; int repetitions[] = new int[project.getComponents().size()]; int k = 0; int alternatives = 1; for (Component sc : project.getComponents()) { hardwarePossibilities[k] = sc.getHardwareSets().size(); alternatives *= sc.getHardwareSets().size(); repetitions[k++] = alternatives / sc.getHardwareSets().size(); for (HardwareSet hws : sc.getHardwareSets()) addHardwareSetIfNotPresent(sequenceHardwareSets, hws); } for (int i = 0; i < alternatives; i++) { DeploymentAlternative deploymentAlternative = new DeploymentAlternative(); for (int j = 0; j < project.getComponents().size(); j++) { int index = (i / repetitions[j]) % project.getComponents().get(j).getHardwareSets().size(); HardwareSet hws = project.getComponents().get(j).getHardwareSets().get(index); DeployedComponent deployedComponent = new DeployedComponent(project.getComponents().get(j), hws); deploymentAlternative.getDeployedComponents().add(deployedComponent); } deploymentAlternative.initializeId(); project.getDeploymentAlternatives().add(deploymentAlternative); } } }
c6e62ef5-39d6-4cd8-97c4-6019ca856f7d
1
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { e.printStackTrace(); } new GuiDriver(); }
c3ee46c0-903f-4b17-b65d-424b2e2629d1
9
public static void checkQuizTakingAchievements(String username, int percent, int quizId, int elapsed) { List<Score> quizzes = UserInfo.getHistory(username); List<Integer> achs = UserInfo.getAchievements(username); List<Score> top = UserInfo.getTopTen(quizId); if (quizzes.size() >= QUIZ_MACHINE_VALUE && !achs.contains(QUIZ_MACHINE_ID)) { UserInfo.addAchievment(username, QUIZ_MACHINE_ID); } if(quizzes.size() >= JAQUIZZ_ICAL_VALUE && !achs.contains(JAQUIZZ_ICAL_ID)){ UserInfo.addAchievment(username, JAQUIZZ_ICAL_ID); } if (top.size() > 0) { if ((top.get(0).getScore() < percent || (top.get(0).getScore() == percent && top.get(0).getElapsed() >= elapsed)) && !achs.contains(THE_GREATEST_ID)) { UserInfo.addAchievment(username, THE_GREATEST_ID); } } else { UserInfo.addAchievment(username, THE_GREATEST_ID); } }
ffb023d3-bc45-443f-92f5-917d1f7700c7
0
public void removeFileDownloadItem(FileDownloadItem item){ items.remove(item); }
800ef023-9f5c-4410-bf01-8a6ec36546a2
7
public void combineFilterSummaries(String folder){ File Folder = new File(folder); Map<Integer,File> M = new HashMap<>(); General g = new General(); ArrayList<Integer> thresholds = new ArrayList<>(); // first create a map of all files and thresholds found in this folder for(File f : Folder.listFiles()) { if(f.getName().contains("summary") && !f.getName().equals(Folder.getName()+"summary.txt")) { int t = g.findNumberInString(f.getName()); System.out.println("t: " + t +" file: " + f.getAbsolutePath()); M.put(t, f); thresholds.add(t); } } String header = Folder.getName() + "_Threshold,"; String[] names = new String[]{"N","L","Ng","Lg","dav","dia","cc","rho","bet","corM","corA"}; for(int i =0;i<names.length;i++) { header += Folder.getName() + "_" + names[i]; if(i < names.length-1) { header += ","; } } try { BufferedWriter out = new BufferedWriter(new FileWriter(Folder.getAbsolutePath() + File.separator + Folder.getName()+"summary.txt")); out.write(header + "\n"); // go over all files in order and copy data Collections.sort(thresholds); for(int i:thresholds) { out.write(i+","+readAndParseSummaryFileContent(M.get(i).getAbsolutePath())+ "\n"); } out.flush(); out.close(); } catch (IOException ex) { Logger.getLogger(NetworkAnalyser.class.getName()).log(Level.SEVERE, null, ex); } }
7da991ee-9c45-4e49-94c7-6672fda38f25
3
public Object getValueAt(int row, int col) { if (data == null) { return null; } if (row < 0 || col < 0) { return null; } return data[row][col]; }
0f0cfb89-53da-47d3-86fe-ead0c2d1c908
7
public static void main(String[] args) { int[] rat = { 2, 1, 3 }; int[] avg = { 1, 2, 3 }; double[][] cov = new double[3][3]; int row = 0; for (int i = 0; i < 3; i++) { int col = 0; for (int j = 0; j < 3; j++) { if (i <= j) { double numerator = 0.0; System.out.println("numerator = (" + rat[i] + " - " + avg[i] + ") * (" + rat[j] + " - " + avg[j] + ")"); numerator = (rat[i] - avg[i]) * (rat[j] - avg[j]); // if (movie1ID == movie2ID) { // System.out.println(numerator); // } if (numerator == 0 && row == col) { // TODO: deal with singular matrix // Problem: If double value is too small, then // the matrix will be interpreted as singular. // Double.MIN_VALUe e.g. is too small... cov[row][col] = 0.1; } else { cov[row][col] = numerator; cov[col][row] = numerator; } } col++; } row++; } for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++){ System.out.print(cov[i][j] + "\t"); } System.out.println(); } }
a1063d52-8a1e-430d-8be7-7e1f01a7e683
8
public int canCompleteCircuit(int[] gas, int[] cost) { int i = 0,len = gas.length; if(gas == null || cost == null || len < 0) return -1; for(i = 0; i< len; i++){ int k = i; int myGas = 0; int j = 0; for(;j < len;j++) { //from i to i; myGas += gas[k]; if(myGas < cost[k]) break; myGas -= cost[k]; k++; if(k >= len) k -= len; } if(j >= len) return i; else i += j; } return -1; }
90050d2f-f894-4bbb-b432-5e7fbc50caff
0
private ClosureTaker() { }
700dbbaf-ef26-4c90-ae10-67b294858366
2
public void addProperty() { DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); Entity past_string = null; try { Key key = KeyFactory.createKey("past_string", "onlyOne"); past_string = datastore.get(key); } catch (Throwable t) { } past_string.setProperty("past_update", new String("")); if(false)datastore.put(past_string); }
6fbd2f8f-ccd9-4211-a87d-9afa06e42244
0
protected void onSetChannelLimit(String channel, String sourceNick, String sourceLogin, String sourceHostname, int limit) {}
aac191df-01e4-4267-9dde-dff81fed2e05
0
public LoadFileProtocolClassCommand(String name) { super(name); }
e43b87e1-15e8-454d-b03e-397a5aa0d829
1
public void writeLine(String line) { try { BufferedWriter CSVFile = new BufferedWriter(new FileWriter(fileName)); CSVFile.write(line); CSVFile.newLine(); CSVFile.close(); } catch (IOException ex) { System.out.println(ex); } }
035bdda1-9734-42d3-ace0-f1844ca85a4e
4
private Path handleImage(Path img, int resnumber) { assert FileUtil.control(img) && (resnumber > 0); Path ret = null; if (FileUtil.control(img)) { try { ret = Bitmap.convertToBMP(img, this.imageDir, "" + resnumber); if (!img.getFileName().toString().endsWith(Constants.DEFAULT_SKINIMAGE_TYPE)) { FileUtil.copyFile(img, this.imageDir.resolve(resnumber + Constants.DEFAULT_INPUTIMAGE_TYPE), false); } } catch (IOException | InterruptedException e) { Main.handleUnhandableProblem(e); ret = null; } } return ret; }
046d0182-e831-4c7c-b74c-963ba9756755
6
private String readField(Field field) { try { Class<?> type = field.getType(); if (type.equals(int.class)) return String.valueOf(field.getInt(this)); else if (type.equals(boolean.class)) return String.valueOf(field.getBoolean(this)); else if (type.equals(double.class)) return String.valueOf(field.getDouble(this)); else if (type.equals(String.class)) return (String) field.get(this); else throw new Exception("Unsupported field class: " + type); } catch (Exception e) { e.printStackTrace(); } return null; }
b538566b-b9b2-41fb-be22-0fe92fd27339
8
public final void quant(final float[] lsp, final float[] qlsp, final int order, final Bits bits) { int i; float tmp1, tmp2; int id; float[] quant_weight = new float[MAX_LSP_SIZE]; for (i = 0; i < order; i++) qlsp[i] = lsp[i]; quant_weight[0] = 1 / (qlsp[1] - qlsp[0]); quant_weight[order - 1] = 1 / (qlsp[order - 1] - qlsp[order - 2]); for (i = 1; i < order - 1; i++) { tmp1 = 1 / (qlsp[i] - qlsp[i - 1]); tmp2 = 1 / (qlsp[i + 1] - qlsp[i]); quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2; } for (i = 0; i < order; i++) qlsp[i] -= (.3125f * i + .75f); for (i = 0; i < order; i++) qlsp[i] *= 256; id = lsp_quant(qlsp, 0, high_lsp_cdbk, 64, order); bits.pack(id, 6); for (i = 0; i < order; i++) qlsp[i] *= 2; id = lsp_weight_quant(qlsp, 0, quant_weight, 0, high_lsp_cdbk2, 64, order); bits.pack(id, 6); for (i = 0; i < order; i++) qlsp[i] *= 0.0019531f; for (i = 0; i < order; i++) qlsp[i] = lsp[i] - qlsp[i]; }
bf9481ba-a199-4042-9a82-24ea862c419f
8
public void check() { RunIterator itr = iterator(); int[] curr = itr.hasNext() ? itr.next() : null; if (curr == null) return; long sum = (long)curr[0]; while (itr.hasNext()) { int[] next = itr.next(); if (curr[0] == next[0] && curr[1] == next[1] && curr[2] == next[2] && curr[3] == next[3]) { throw new RuntimeException("Consecutive runs have been found."); } curr = next; sum += (long)curr[0]; } if (sum != width * height) throw new RuntimeException("Invalid run lengths"); }
4622ca01-a4ed-42bc-ae46-c96720d39c28
9
private void processEvents() { while (true) { WatchKey key; try { key = watcher.take(); } catch (InterruptedException x) { logger.debug("'WatchDir' thread was interrupted!"); return; } Path dir = keys.get(key); if (dir == null) { System.err.println("WatchKey not recognized!!"); continue; } for (WatchEvent<?> event : key.pollEvents()) { WatchEvent.Kind<?> kind = event.kind(); if (kind == OVERFLOW) { continue; } WatchEvent<Path> ev = cast(event); Path name = ev.context(); Path fullpath = dir.resolve(name); if (kind == ENTRY_CREATE) { putPathToStorage(fullpath); logger.debug("Fullpath '{}' add in pathStorage", fullpath); System.out.format("%s: %s\n", event.kind().name(), name); } } boolean valid = key.reset(); if (!valid) { keys.remove(key); } } }
0baf673b-f801-48ef-a2d8-14f8bbb11376
0
public double elapsedTime() { long now = System.currentTimeMillis(); return (now - start) / 1000.0; }
d4ce5d58-6019-4fce-be52-b113f389a217
1
@Override public int getSlotSpacingY() { return isNotPlayerInventory() ? 0 : 18; }
b2d0f820-7a98-4e47-b17b-ef37054253c3
5
public static String getJavaMethodParameter(Method var0) { Class[] var1 = var0.getParameterTypes(); Class[] var2 = var0.getExceptionTypes(); String var3 = ""; String var4 = ""; for (int len = 0; len < var1.length; ++len) { var3 += var1[len].getName() + (len == var1.length - 1 ? "" : ", "); } for (int len = 0; len < var2.length; ++len) { var4 += var2[len].getName() + (len == var2.length - 1 ? "" : ", "); } return String.format("%s %s %s(%s)%s;", Modifier.toString(var0.getModifiers()), var0.getReturnType().getName(), var0.getName(), var3, var4 != "" ? " throws " + var4 : ""); }
56e205c2-969b-447f-9aa5-3319c9d4809e
5
public static Map<Integer, Map<String, Object>> decodeUserPositions() { Map<Integer, Map<String, Object>> ComputationResponse = new HashMap<Integer, Map<String, Object>>(); String JSONRaw = JSONRawMain[1]; if(JSONRaw.trim().equals("false")){ Util.logC("Warning: There are no users currently online"); return ComputationResponse; } else { if(!JSONRaw.equals("") && !JSONRaw.equals("true")){ Object obj=JSONValue.parse(JSONRaw); JSONArray array=(JSONArray)obj; Util.logC("There are " + array.size() + " users online. Find there data using Map<String, Object> userInfo = otherUserInfo.get(PLAYER_NUMBER);"); for (int i = 0; i< array.size(); i++){ Map<String, Object> UserDetails = new HashMap<String, Object>(); JSONObject playerDetails=(JSONObject)array.get(i); try { UserDetails.put("uId", Integer.parseInt(playerDetails.get("id").toString())); UserDetails.put("uName", playerDetails.get("userName").toString()); UserDetails.put("uSkin", playerDetails.get("skin").toString()); UserDetails.put("yPos", Float.parseFloat(playerDetails.get("yPos").toString())); UserDetails.put("xPos", Float.parseFloat(playerDetails.get("xPos").toString())); UserDetails.put("zPos", Float.parseFloat(playerDetails.get("zPos").toString())); UserDetails.put("rotY", Float.parseFloat(playerDetails.get("rotY").toString())); UserDetails.put("isMoving", Boolean.parseBoolean(playerDetails.get("yPos").toString())); } catch (Exception ex) { System.out.println("Error converting the user positions w/ data : " + JSONRaw); } ComputationResponse.put(i, UserDetails); } } } return ComputationResponse; }
3fc12ba9-d204-436d-ab5f-a7af1c4e7efe
6
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Color)) { return false; } Color other = (Color) obj; if (a != other.a) { return false; } if (b != other.b) { return false; } if (g != other.g) { return false; } return r == other.r; }
77168941-f227-46a4-959a-551cc0ec8e51
8
@Override public String toString() { StringBuilder s = new StringBuilder("---------------\n"); s.append("Players ("+players.size()+"):\n"); for (Player player : players) { s.append(player.getNumber()+" "+player.getNickname()+": "+player.getPoints()+"\n"); } s.append("\nGame state: ready "+isReady()+" running "+isRunning()+"\n"); int catNo = getCategoryCount(); int rowNo = getRowCount(); for (int x = 0; x < catNo; x++) { String catName = categories.get(x).getDisplayName(); s.append("["+catName + "] "); } s.append("\n\n"); for (int y = 1; y <= rowNo; y++) { for (int x = 1; x <= catNo; x++) { Field field = getField(x, y); s.append("["+field.getPoints()+"|"+field.getAnswer()+"] "); } s.append("\n"); for (int x = 1; x <= catNo; x++) { Field field = getField(x, y); String statustext; FieldStatus status = field.getStatus(); if (FieldStatus.OPEN_SOLVED.equals(status)) { Player solvedBy = field.getSolvedBy(); statustext = solvedBy == null ? "solvedBy is null" : solvedBy.getNickname(); } else { statustext = status == null ? "status is null" : status.toString(); } s.append("["+statustext+"] "); } s.append("\n\n"); } return s.toString(); }
490bdddc-0621-40ac-a49c-6e8e21eb09dd
0
public static List<Appointment> findByMonth(long uid, long month) throws SQLException { List<Appointment> aAppt = new ArrayList<Appointment>(); long month2 = DateUtil.getStartOfMonth(month + 32 * DateUtil.DAY_LENGTH); long endOfMonth = month2 - DateUtil.DAY_LENGTH; // once aAppt.addAll(Appointment.findOnceByDaySpan(uid, month, endOfMonth)); // daily aAppt.addAll(Appointment.findDailyByDaySpan(uid, month, endOfMonth)); // weekly aAppt.addAll(Appointment.findWeeklyByDaySpan(uid, month, endOfMonth)); // monthly aAppt.addAll(Appointment.findMonthlyByDaySpan(uid, month, endOfMonth)); return aAppt; }
2673dcf1-e0ec-49d9-8549-3a62496741b0
4
public static float dayValue(World world) { final float time = worldTime(world) ; if (time <= morning_end ) return (time + HF) / fade ; if (time <= evening_start) return 1 ; if (time <= evening_end ) return (evening_end - time) / fade ; if (time <= morning_start) return 0 ; else return (time - morning_start) / fade ; }
b9f2415c-f62a-4319-b021-5c5f6f4e8768
1
private JLabel getJLabel1() { if (jLabel1 == null) { jLabel1 = new JLabel(); jLabel1.setText("EXECUTE SUCCESSFUL!"); } return jLabel1; }
6cb0181a-6f5e-42d9-b3e3-4bfdd6e28d73
1
public static Color getBanding(boolean primary) { return primary ? Color.WHITE : new Color(232, 255, 232); }
fa2ba293-c109-49d1-ad32-d18ad62e4423
1
@Test public void out_a_car_when_it_parking_second_park() { for(int i = 0; i < 5; i ++) { parkBoy.in(new Car(String.valueOf(i))); } Car car = new Car(); Ticket ticket = parkBoy.in(car); Assert.assertEquals(parkBoy.getParkSize(1), this.SECOND_PARK_SIZE - 1); Assert.assertSame(car, parkBoy.out(ticket)); }
eaf77c1f-1221-46a8-acec-0585f739ce97
2
public boolean checkObjectiveType(UQuest plugin, String type) { for(Objective objective : this.objectives){ if(objective.getType() == type) return true; } return false; }
3c1c7c90-96ef-46e3-b2a8-de43c974e392
9
public static void menu_Eventos() { do { System.out.println("********************************************"); System.out.println("* Menu Eventos *"); System.out.println("* *"); System.out.println("* 1 - Criar *"); System.out.println("* 2 - Editar *"); System.out.println("* 3 - Editar Campo Individual *"); System.out.println("* 4 - Apagar *"); System.out.println("* 5 - Listar *"); System.out.println("* V - Voltar *"); System.out.println("* *"); System.out.println("********************************************"); opcao = teclado.next(); opcao2 = opcao.charAt(0); switch (opcao2) { case '1': WEvento.criar_Evento(); break; case '2': WEvento.alterar_Evento(); break; case '3': menu_Alterar_Individual_Evento(); break; case '4': WEvento.remover(); break; case '5': WEvento.listar(); break; case 'v': case 'V': break; default: System.out.println("Introduzio uma opcao errada! Por favor tente de novo!"); } } while (opcao2 != 'v' && opcao2 != 'V'); }
c03a0310-407f-4770-a7fd-5a82f7ecea2a
8
protected void printTopWord(int k, String topWordFile) { System.out.println("TopWord FilePath:" + topWordFile); Arrays.fill(m_sstat, 0); for (_Doc d : m_trainSet) { for (int i = 0; i < number_of_topics; i++) m_sstat[i] += m_logSpace ? Math.exp(d.m_topics[i]) : d.m_topics[i]; } Utils.L1Normalization(m_sstat); try { PrintWriter topWordWriter = new PrintWriter(new File(topWordFile)); for (int i = 0; i < topic_term_probabilty.length; i++) { MyPriorityQueue<_RankItem> fVector = new MyPriorityQueue<_RankItem>( k); for (int j = 0; j < vocabulary_size; j++) fVector.add(new _RankItem(m_corpus.getFeature(j), topic_term_probabilty[i][j])); topWordWriter.format("Topic %d(%.5f):\t", i, m_sstat[i]); for (_RankItem it : fVector) topWordWriter.format("%s(%.5f)\t", it.m_name, m_logSpace ? Math.exp(it.m_value) : it.m_value); topWordWriter.write("\n"); } topWordWriter.close(); } catch (Exception ex) { System.err.print("File Not Found"); } }
63b5ae8b-c67e-441e-9bbb-b32aac7401db
9
private void drawMap(GameMap map) throws GLException { gl.glPushMatrix(); //gl.glTranslatef(-map.getHeight() / 2, -map.getWidth() / 2, 0.0f); if (vViewChange == null) { vViewChange = Vector.O; gs.cnt = vViewChange; } for (int i = 0; i < map.getHeight(); i++) { for (int j = 0; j < map.getWidth(); j++) { // Load unique name for this tile. gl.glLoadName(i * map.getHeight() + j + 1); TileType type = map.getTile(i, j).getType(); gl.glColor3f(1, 1, 1); switch (type) { case DEEP_WATER: //gl.glColor3f(0, 0, 1); deepWater.bind(gl); break; case SHALLOW_WATER: //gl.glColor3f(0, 1, 0); shallowWater.bind(gl); break; case LAND: //gl.glColor3f(1, 0, 0); land.bind(gl); break; } // Draw tile. gl.glBegin(GL_QUADS); gl.glTexCoord2d(0, 0); gl.glVertex3d(0, 0, 0); gl.glTexCoord2d(1, 0); gl.glVertex3d(1, 0, 0); gl.glTexCoord2d(1, 1); gl.glVertex3d(1, 1, 0); gl.glTexCoord2d(0, 1); gl.glVertex3d(0, 1, 0); gl.glEnd(); //} // Draw inhabitants. gl.glPushMatrix(); gl.glPushAttrib(GL_CURRENT_BIT); empty.bind(gl); Inhabitant inhabitant = map.getTile(i, j).getInhabitant(); gl.glPushMatrix(); // TODO: replace by more meaningful, non-glut objects. gl.glTranslatef(0.5f, 0.5f, 0); /*if (inhabitant instanceof LandCreature) { gl.glColor3f(0, 1, 0); //gl.glRotatef(90, 1, 0, 0); //glut.glutSolidTeapot(0.5); new GraphicalObjects(gl).drawCylinder(0.5f, 2); } else */ if (inhabitant instanceof Food) { gl.glColor3f(1, 1, 1); //gl.glRotatef(90, 1, 0, 0); //glut.glutSolidTeapot(0.5); new GraphicalObjects(gl).drawCylinder(0.5f, 2); } gl.glPopMatrix(); gl.glPopAttrib(); gl.glPopMatrix(); // Move to the next column. gl.glTranslatef(1, 0, 0); } //Move to the next row and back to the first column. gl.glTranslatef(-map.getHeight(), 1, 0); } gl.glPopMatrix(); gl.glPushMatrix(); for (Player p : game) { for (Creature c : p) { Vector currentLocation = creatureViews.get(c).getCurrentLocation(); gl.glTranslated(currentLocation.x(), currentLocation.y(), currentLocation.z()); new GraphicalObjects(gl).drawCylinder(0.5f, 2); } } gl.glPopMatrix(); }
52e6cc63-63ca-4d3c-b7bc-d65259a01780
0
public static GeneralValidator isLessEqualsToThan() { return LESS_THAN_EQUALS_TO_VALIDATOR; }
fdbc0be5-4168-468f-8fd8-eddff5ad2a93
9
public Location getAdjacentLocation(int direction) { // reduce mod 360 and round to closest multiple of 45 int adjustedDirection = (direction + HALF_RIGHT / 2) % FULL_CIRCLE; if (adjustedDirection < 0) adjustedDirection += FULL_CIRCLE; adjustedDirection = (adjustedDirection / HALF_RIGHT) * HALF_RIGHT; int dc = 0; int dr = 0; if (adjustedDirection == EAST) dc = 1; else if (adjustedDirection == SOUTHEAST) { dc = 1; dr = 1; } else if (adjustedDirection == SOUTH) dr = 1; else if (adjustedDirection == SOUTHWEST) { dc = -1; dr = 1; } else if (adjustedDirection == WEST) dc = -1; else if (adjustedDirection == NORTHWEST) { dc = -1; dr = -1; } else if (adjustedDirection == NORTH) dr = -1; else if (adjustedDirection == NORTHEAST) { dc = 1; dr = -1; } return new Location(getRow() + dr, getCol() + dc); }
19dca397-7cf7-4ac4-ae3d-fdf50b49e488
4
public boolean contains(Point point) { if((point.x > x && point.x < x + sprite.getWidth()) && (point.y > y && point.y < y + sprite.getHeight())) return true; return false; }
ad0d94d1-8c12-4a3e-b253-a33cf90c3428
4
public void save() { variable = "@Variable:" + nameField.getText() + ":"; if(stringField.isEnabled()) { variable += stringField.getText(); } else if(intSpinner.isEnabled()) { variable += getAdjustType() + ":" + intSpinner.getValue(); } else if(booleanBox.isEnabled()) { variable += booleanBox.isSelected(); } else if(floatSpinner.isEnabled()) { variable += getAdjustType() + ":" + floatSpinner.getValue(); } }
fa0bf515-141b-4908-b819-689120942a16
1
public void logToFile(String msg){ try { BufferedWriter writer = new BufferedWriter(new FileWriter(new File(getDataFolder(),"BlacklistCheck.log"),true)); writer.write(msg); writer.newLine(); writer.close(); }catch (java.io.IOException e) { logMessage("Unable to write to BlacklistCheck.log: "+e.getMessage()); } }
96978a52-e5c6-4c18-a655-8ee7d0ad4e72
8
@Override public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { String subCmd = null; final String[] newArgs = new String[Constants.GENERAL_ARRAY_SIZE]; ProcessState state = null; if ( args.length > 1 ) { subCmd = args[0]; for (int i = 1; i < args.length; i++) newArgs[i - 1] = args[i]; } else if ( args.length == 1 ) subCmd = args[0]; if ( subCmd != null ) { final SubCmd subCmd2 = this.subCmds.get(subCmd); if ( subCmd2 != null ) state = subCmd2.execute(sender, cmd, label, newArgs); } else state = new ProcessState(false); // Validate the ProcessState // If not assigned, there was a general error. @Dev you suck if ( state == null ) return false; if ( state.isError( ) || Constants.fdebug ) this.logger.info(state.getMsg( )); return state.isState( ); }
571da258-7928-4341-b59e-6c249feb306c
7
public void testConstructor_int_int_int_int_int_int_int_DateTimeZone() throws Throwable { DateTime test = new DateTime(2002, 6, 9, 2, 0, 0, 0, PARIS); // +02:00 assertEquals(ISOChronology.getInstance(PARIS), test.getChronology()); assertEquals(TEST_TIME_NOW, test.getMillis()); try { new DateTime(Integer.MIN_VALUE, 6, 9, 0, 0, 0, 0, PARIS); fail(); } catch (IllegalArgumentException ex) {} try { new DateTime(Integer.MAX_VALUE, 6, 9, 0, 0, 0, 0, PARIS); fail(); } catch (IllegalArgumentException ex) {} try { new DateTime(2002, 0, 9, 0, 0, 0, 0, PARIS); fail(); } catch (IllegalArgumentException ex) {} try { new DateTime(2002, 13, 9, 0, 0, 0, 0, PARIS); fail(); } catch (IllegalArgumentException ex) {} try { new DateTime(2002, 6, 0, 0, 0, 0, 0, PARIS); fail(); } catch (IllegalArgumentException ex) {} try { new DateTime(2002, 6, 31, 0, 0, 0, 0, PARIS); fail(); } catch (IllegalArgumentException ex) {} new DateTime(2002, 7, 31, 0, 0, 0, 0, PARIS); try { new DateTime(2002, 7, 32, 0, 0, 0, 0, PARIS); fail(); } catch (IllegalArgumentException ex) {} }
462a462b-62bd-4c9d-b229-04638bc62c01
2
@Override public void actionPerformed(ActionEvent ae) { Object source = ae.getSource(); if (source == classements.getRetour() ){ this.setVisible(false); Fenetre topFrame = (Fenetre) SwingUtilities.getWindowAncestor(this); if (topFrame.getJeu() == null) topFrame.visibleMenuPrincipal(true); else{ topFrame.getJeu().resume(); topFrame.visibleInterfaceJeu(true); } } }
c62cc184-aea0-469f-aa88-c05d9c9a619e
0
public String getNewValue(){ return newValue.getText(); }
ec6477de-d608-45b1-b800-176d53c07aaf
8
private void processAttack(){ if(!(this.friendVictory)){ if (!(this.enemyVictory)){ if (jList1.getSelectedIndex() != -1){ Attack friendlyAttack = this.character.getAttacks().get(jList1.getSelectedIndex()); int friendlyDamage = this.character.getAttacks().get(jList1.getSelectedIndex()).attack(this.character.getAttacks().get(jList1.getSelectedIndex())); if (friendlyDamage != -1){ this.getEnemy().setHealth(this.getEnemy().getHealth() - friendlyDamage); jlblEnemyHealth.setText(String.valueOf(this.getEnemy().getHealth())); } else { System.out.println("miss!"); } if (this.enemy.getHealth() <= 0){ this.enemy.setHealth(0); jlblEnemyHealth.setText(String.valueOf(this.getEnemy().getHealth())); this.friendVictory = true; } if (!(this.friendVictory)){ int enemyAttackNumber = this.getEnemy().randomAttack(); System.out.println("enemy attack:" + enemyAttackNumber); Attack enemyAttack = this.getEnemy().getAttacks().get(enemyAttackNumber); int enemyDamage = this.getEnemy().getAttacks().get(enemyAttackNumber).attack(this.enemy.getAttack(enemyAttackNumber)); if (enemyDamage != -1){ this.character.setHealth(this.character.getHealth() - enemyDamage); jlblYourHealth.setText(String.valueOf(this.character.getHealth())); } else { System.out.println("enemy miss!"); } showMoves(friendlyAttack, friendlyDamage, enemyAttack, enemyDamage, this.getEnemy().getName()); if (this.character.getHealth() <= 0){ this.character.setHealth(0); jlblYourHealth.setText(String.valueOf(this.getCharacter().getHealth())); defeat(); this.enemyVictory = true; } } else { victory(); } // System.out.printf("Selected attack = #%d %s\n",jList1.getSelectedIndex(), jList1.getSelectedValue().toString()); // System.out.printf("Look up attack as %s\n", this.moves.get(jList1.getSelectedIndex()).getDisplay()); } } } }
1bd829b4-9c32-4c47-a860-3525fa4a04b9
0
@Override public int getHeight() { return height; }
bdcee0b0-04d1-4cdc-a8d2-b00ee503bc51
4
public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); if (nbtTagCompound.hasKey("teDirection")) { this.orientation = ForgeDirection.getOrientation(nbtTagCompound .getByte("teDirection")); } if (nbtTagCompound.hasKey("teState")) { this.state = nbtTagCompound.getByte("teState"); } if (nbtTagCompound.hasKey("CustomName")) { this.customName = nbtTagCompound.getString("CustomName"); } if (!(nbtTagCompound.hasKey("owner"))) return; this.owner = nbtTagCompound.getString("owner"); }
4dd62dca-ca6d-4151-99ca-b283d1bd448c
7
private void setLocationWithTile(Tile tile, int position) { int xLocation, yLocation; if ( position == 1 || position == 4) { xLocation = tile.getX()+(position == 1?Tile.IMG_WIDTH:-Tile.IMG_WIDTH); yLocation = tile.getY(); } else { xLocation = tile.getX()+(position == 0 || position == 2?Tile.IMG_WIDTH/2:-Tile.IMG_WIDTH/2); yLocation = tile.getY()+(position == 2 || position == 3?Tile.IMG_HEIGHT/2+Tile.IMG_HEIGHT/4:-(Tile.IMG_HEIGHT/2+Tile.IMG_HEIGHT/4)); } this.setBounds(xLocation, yLocation, Tile.IMG_WIDTH, Tile.IMG_HEIGHT); }
391c68e0-bf20-40e1-be54-cafea6760ab1
1
public void ensureCapacity(int minimumCapacity) { int[ ] biggerArray; if (data.length < minimumCapacity) { biggerArray = new int[minimumCapacity]; System.arraycopy(data, 0, biggerArray, 0, manyItems); data = biggerArray; } }
0ebe1330-3d89-4355-8c71-9cff72c0b87f
2
@Test public void getChildrenIngredients_should_say_chicken_is_poultry(){ List<Ingredient> children = rep.getChildrenIngredients(poultry); for(Ingredient ingredient : children){ if(ingredient.getName().equalsIgnoreCase("chicken")){ return; } } Assert.fail(); }