method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
7f1e2710-523e-4204-9355-1e1ce2bea5d7
2
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); LineWidget lineOne = new LineWidget(shell, LineDirection.Horizontal, 50, 5, 10); lineOne.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); LineWidget lineTwo = new LineWidget(shell, LineDirection.Vertical, 50, 5, 10); lineTwo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
1082761e-0f39-4a4d-89f4-5f0518d2423a
7
@Override public void keyPressed(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_ENTER){ String text = input.getText(); data.setLastLine(text); if (response){ data.setText(text + "\n" +data.getText()); } output.setText(data.getText()); input.setText(""); } if(e.getKeyCode() == 107 && e.isControlDown()){ //+ fontSize++; updateFont(); } if(e.getKeyCode() == 109 && e.isControlDown()){ //- fontSize--; updateFont(); } if(e.getKeyCode() == 27 ){ //Esc System.exit(0); } }
1b9d04d3-3750-442a-880a-ad1afaac9078
8
protected void compareDatasets(Instances data1, Instances data2) throws Exception { if (!data2.equalHeaders(data1)) { throw new Exception("header has been modified\n" + data2.equalHeadersMsg(data1)); } if (!(data2.numInstances() == data1.numInstances())) { throw new Exception("number of instances has changed"); } for (int i = 0; i < data2.numInstances(); i++) { Instance orig = data1.instance(i); Instance copy = data2.instance(i); for (int j = 0; j < orig.numAttributes(); j++) { if (orig.isMissing(j)) { if (!copy.isMissing(j)) { throw new Exception("instances have changed"); } } else if (orig.value(j) != copy.value(j)) { throw new Exception("instances have changed"); } if (orig.weight() != copy.weight()) { throw new Exception("instance weights have changed"); } } } }
dd2ae915-2a81-4512-9fc0-b9a056f6a329
0
@Override public void setResponseRemoteCallObject(IRemoteCallObject rco) { response = rco; }
9c266eac-3b14-491c-b686-3f860f07791c
5
final protected void update(){ if(createWhen()){ list.add(create()); } for(int i=0;i<list.size();i++){ SingleObject bl=list.get(i); if(inRange(bl)){ whenCrash(); } if(removeWhen(bl)){ list.remove(bl); i--; } } for(int i=0;i<list.size();i++){ SingleObject bl=list.get(i); bl.move(); } }
ee31c5fa-7763-42c3-9351-9d8c6f49b6c3
0
public void setIP(String ip) { clientIP = ip; }
0b5c4588-f4cf-4e52-a312-9e86be332952
7
private int minmax(Color p, Board b, int d, int cutoff, ArrayList<Integer> moves) { bestSoFar = Integer.MIN_VALUE; moves.clear(); if (d == 0) { return staticEval(p, b); } for (int move = 0; move < b.size() * b.size(); move += 1) { if (b.isLegal(p, move)) { b.addSpot(p, move); if (b.getWinner() != null) { response = Integer.MAX_VALUE; } else { response = minmax(p.opposite(), b, d - 1, -bestSoFar, new ArrayList<Integer>()); } b.undo(); if (move > cutoff) { moves.clear(); return response; } if (-response >= bestSoFar) { moves.clear(); if (-response == bestSoFar) { moves.add(move); bestSoFar = -response; } } } } return bestSoFar; }
c39b6369-d40f-4f94-9d23-5a636558c4ae
3
public static ArrayList<BillItem> listBillItems(int billID) { String query = "SELECT *" + "FROM `billItem`" + "WHERE `billItem`.`billId` = '%d';"; ArrayList<BillItem> listOfBillItems = new ArrayList<>(); DBA dba = Helper.getDBA(); try { ResultSet rs = dba.executeQuery(String.format(query, billID)); if (rs != null) { while (rs.next()) { BillItem newBillItem = new BillItem(); newBillItem.setBillId(rs.getInt("billId")); newBillItem.setMedicineId(rs.getInt("medicineId")); newBillItem.setQuanitity(rs.getInt("quantity")); listOfBillItems.add(newBillItem); } rs.close(); dba.closeConnections(); } } catch (SQLException sqlEx) { dba.closeConnections(); Helper.logException(sqlEx); } return listOfBillItems; }
1c07307d-0fef-4384-b2eb-8744b91a9fb6
2
private int setStats(int idx, int value){ int bonus = 0; this.stats[idx] += value; if(stats[idx] < 0){ bonus = stats[idx]; stats[idx] = 0; }else if(stats[idx] > getMaxStats(idx)){ bonus = stats[idx] - maxStats[idx]; stats[idx] = maxStats[idx]; } return bonus; }
2eee69b5-108c-4930-af10-b807a10340f0
8
private final Path getPathFunc(final String[] names, int offset) { Path p = this; for (int i = offset; i < names.length; ++i) { final String name = names[i]; final PathReference pWeak; if (name.startsWith(".")) { if (name.equals(".")) { continue; } else if (name.equals("..")) { if (p.parent == null) { continue; } p = p.parent; continue; } } else { final Path pTmp = rootMap.get(name); if (pTmp != null) { p = pTmp; continue; } } final Path pTmp; synchronized (Path.finalizerMonitor) { pWeak = p.successors.get(name); if (pWeak == null) { return new Path(p, names, i); } pTmp = pWeak.get(); if (pTmp == null) { return new Path(p, names, i); } } p = pTmp; } return p; }
0700dfef-b0c4-4841-9917-522714bbd23e
7
public void moveRight(){ switch (polygonPaint) { case 0: line.moveRight(); repaint(); break; case 1: curv.moveRight(); repaint(); break; case 2: triangle.moveRight(); repaint(); break; case 3: rectangle.moveRight(); repaint(); break; case 4: cu.moveRight(); repaint(); break; case 5: elipse.moveRight(); repaint(); break; case 6: arc.moveRight(); repaint(); break; } repaint(); }
71e28fef-4349-4e9e-8a42-1a7546fd85d8
4
@SuppressWarnings("unchecked") public Class<Mapper<Writable, Writable, Writable, Writable>> loadClass () throws IOException, ClassNotFoundException { /* Load Jar file */ String jarFilePath = this.task.getJarEntry().getLocalPath(); JarFile jarFile = new JarFile(jarFilePath); Enumeration<JarEntry> e = jarFile.entries(); URL[] urls = { new URL("jar:file:" + jarFilePath +"!/") }; ClassLoader cl = URLClassLoader.newInstance(urls); Class<Mapper<Writable, Writable, Writable, Writable>> mapperClass = null; /* Iterate .class files */ while (e.hasMoreElements()) { JarEntry je = e.nextElement(); if(je.isDirectory() || !je.getName().endsWith(".class")){ continue; } String className = je.getName().substring(0, je.getName().length() - 6); className = className.replace('/', '.'); if (className.equals(this.task.getMapperClassName())) { mapperClass = (Class<Mapper<Writable, Writable, Writable, Writable>>) cl.loadClass(className); } } return mapperClass; }
d746175e-8979-4b22-a84e-2a5c50e1b3e8
8
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { //System.out.println(localName+" "+qName); if (qName.equalsIgnoreCase("layer")) { rightLayer = true; } else if (qName.equalsIgnoreCase("srs")) {//Odotetaan että XML-documentissa esiintyy SRS rightSRS = true; layer = new MapLayers(); } else if (qName.equalsIgnoreCase("name") && rightSRS && rightLayer) { bName = true; } else if (qName.equalsIgnoreCase("title") && rightSRS && rightLayer) { bTitle = true; } }
7f5de43e-9ce4-4bef-a10d-9255012ac649
4
private int checkHeight(BTPosition<T> current) { if (current == null) return 0; int leftH = checkHeight(current.getLeft()); if (leftH == -1) return -1; int rightH = checkHeight(current.getRight()); if (rightH == -1) return -1; int diff = leftH - rightH; if (Math.abs(diff) > 1) return -1; else return Math.max(leftH, rightH) + 1;// subtree+currentNode's height }
07390d75-efde-4156-a47a-13c965cbc56c
1
public void sendInitiatedNotification() { for (long uid : this.aWaitingId) { JointAppointmentInitiated notification = new JointAppointmentInitiated(this); Notification.add(uid, notification); } }
c065e5fc-b2aa-4bb0-84b2-c489bcf9d734
4
public int getequal2(String newtitle) { try{ @SuppressWarnings("resource") ObjectInputStream osi = new ObjectInputStream(new FileInputStream("bookcollection.txt"));///óϾ , Ͼ׳ϴ° ҽ߰ this.setBookCount(osi.readInt()); collectionb.clear(); for( int i= 0; i< this.getBookCount();i++){ Book ms = (Book)osi.readObject(); collectionb.add(i,ms); } for(i = 0; i<this.getBookCount() ; i++){ if((collectionb.elementAt(i).title).indexOf(newtitle)>=0) return 1; } return -1; }catch(Exception e){ return -1; } }
5becc97f-ab5e-4c5e-9f69-5d7f71e6a402
9
public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[59]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 0; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 59; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.add(jj_expentry); } } jj_endpos = 0; jj_rescan_token(); jj_add_error_token(0, 0); int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = jj_expentries.get(i); } return new ParseException(token, exptokseq, tokenImage); }
2873bbee-e912-4571-a68c-14df48967b43
4
public void appendValue(String value) throws NoSuchMethodException { try { String currentValue = getValue(); setValue((currentValue == null ? "" : currentValue) + value); } catch (NoSuchMethodException e) { // try "add" try { Method method = target.getClass().getMethod("add"+name, String.class); method.invoke(target, value); } catch (InvocationTargetException e1) { e1.printStackTrace(); throw new RuntimeException(e); } catch (IllegalAccessException e1) { e1.printStackTrace(); throw new RuntimeException(e); } } }
35fac22e-20b9-469e-863d-9bd641ddb946
7
private void calculate() { int termLength, payFreq; loanScheduleTableModel.setRowCount(0); // set PDL paydown amount try { String aprStr = aprTextField.getText(); calculator.setInstallAPR(Double.parseDouble(aprStr)); } catch (NullPointerException npe) { String msg = "Please enter a number for the APR"; printErrorMsg(npe, msg); return; } catch (NumberFormatException nfe) { String msg = "Invalid Number: Please enter a valid number for the APR"; printErrorMsg(nfe, msg); return; } payFreq = calculator.getInstallPayFreq(); if (payFreq == PayFrequency.MONTHLY.getLoanPeriod()) { termLength = calculator.getTermLength(); } else { termLength = calculator.getTermLength() * 2; // set for all but monthly } // calculate the totalPayments payment amount per period calculator.calculateInstallPmt(); // payday loan payoff amount // ----------------------------- ArrayList<Double> pdlPmts = new ArrayList<Double>(); pdlPmts = calculator.calculatePdlPayoffAmt(); int row = 0; double principal = (double) calculator.getInstallPrincipal(); double totalPayments = 0, payment = 0; double totalIntPayments = 0, intPayment; double totalPrinPayments = 0, prinPayment; double balance = principal; double payOffAmt; while (row < termLength) { loanScheduleTableModel.addRow(new Object[][]{null, null, null, null, null, null}); // set total payment, interest, princpal amounts nf.setMaximumFractionDigits(2); payment = calculator.getInstallPaymentAmt() * -1; intPayment = calculator.calculateInstallIntPmt(row + 1) * -1; prinPayment = payment - intPayment; // running totals totalPrinPayments += prinPayment; totalIntPayments += intPayment; totalPayments += payment; balance -= prinPayment; payOffAmt = (payment * (row + 1)) + balance; //loanScheduleTable.setValueAt(df.format(dueDate), row, 0); loanScheduleTable.setValueAt(row + 1, row, 0); loanScheduleTable.setValueAt("$" + nf.format(payment), row, 1); loanScheduleTable.setValueAt("$" + nf.format(prinPayment), row, 2); loanScheduleTable.setValueAt("$" + nf.format(intPayment), row, 3); loanScheduleTable.setValueAt("$" + nf.format(payOffAmt), row, 4); ++row; } // skip a row for spacing ++row; // add row for totals // ------------------ loanScheduleTableModel.addRow(new Object[][]{null, null}); loanScheduleTableModel.addRow(new Object[][]{null, null}); loanScheduleTable.setValueAt("Total", row, 0); loanScheduleTable.setValueAt("$" + nf.format(totalPayments), row, 1); loanScheduleTable.setValueAt("$" + nf.format(totalPrinPayments), row, 2); loanScheduleTable.setValueAt("$" + nf.format(totalIntPayments), row, 3); if (payFreq == PayFrequency.BI_WEEKLY.getLoanPeriod()) { paymentLabel.setText("Bi-Weekly Payment:"); } else if (payFreq == PayFrequency.MONTHLY.getLoanPeriod()) { paymentLabel.setText("Monthly Payment:"); } else if (payFreq == PayFrequency.SEMI_MONTHLY.getLoanPeriod()) { paymentLabel.setText("Semi-Monthly Payment:"); } else { paymentLabel.setText("Weekly Payment:"); } installPayValLabel.setText("$" + nf.format(payment)); nf.setMinimumFractionDigits(3); }
dbddaff6-be39-4ad6-a5cb-9191fb61f7cd
1
public void setFechaConstru(long fechaConstru) { if (this.fechaConstru > fechaConstru) this.fechaConstru = fechaConstru; }
992bd8b8-c076-4fac-aead-a392f8b59fa5
4
public TableModel Update() { String columnNames[] = { "Lib Classe","Liste Filiere"}; DefaultTableModel defModel = new DefaultTableModel(); defModel.setColumnIdentifiers(columnNames); SequenceController seq_classe= new SequenceController(); seq_classe.CreateSequence("SEQ_CLASSE"); try { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection con = DriverManager.getConnection(DBURL, DBUSER, DBPASS); if (con == null) System.out.println("con classe ko "); else System.out.println("con classe ok "); Statement statement = con.createStatement(); if (statement == null) System.out.println("statement classe ko "); else System.out.println("statement classe ok "); //System.out.println("test1 : " + SaisieNom.getText()); ResultSet rs = statement.executeQuery("select * from \"CLASSE\" c join \"FILIERE\" f on c.CODEFILIERE=f.CODEFILIERE order by LIBCLASSE" ); //ResultSet rs = statement.executeQuery("select * from \"classe\" where nom='"+SaisieNom.getText()+"'" ); //ResultSet rs = statement.executeQuery("SELECT table_name FROM user_tables" ); String LibClasse = ""; String LibFiliere = ""; while (rs.next()) { LibClasse=rs.getString("LIBCLASSE"); LibFiliere = rs.getString("LIBFILIERE");; defModel.addRow(new Object [] {LibClasse,LibFiliere} ); } rs.close(); statement.close(); con.close(); } catch (SQLException ex) { Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex); } return defModel; }
b529e09a-57f2-4d3d-8b8c-f3bf490effb0
2
public void tick() { entities.removeAll(removeList); snake.removeEntities(removeList); for (Entity entity : entities) { ((EntityBody) entity).tick(); Random r = new Random(); int vx = r.nextInt(30)-15; int vy = r.nextInt(30)-15; snake.particles.create(entity.x, entity.y,vx,vy, Color.WHITE); } if (entities.isEmpty()) { Snake.alive(true); vX = 0; vY = 0; } }
30818f5f-6f23-4cb9-8ff8-6758c61f81f7
8
void output(int code, OutputStream outs) throws IOException { cur_accum &= masks[cur_bits]; if (cur_bits > 0) cur_accum |= (code << cur_bits); else cur_accum = code; cur_bits += n_bits; while (cur_bits >= 8) { char_out((byte) (cur_accum & 0xff), outs); cur_accum >>= 8; cur_bits -= 8; } // If the next entry is going to be too big for the code size, // then increase it, if possible. if (free_ent > maxcode || clear_flg) { if (clear_flg) { maxcode = MAXCODE(n_bits = g_init_bits); clear_flg = false; } else { ++n_bits; if (n_bits == maxbits) maxcode = maxmaxcode; else maxcode = MAXCODE(n_bits); } } if (code == EOFCode) { // At EOF, write the rest of the buffer. while (cur_bits > 0) { char_out((byte) (cur_accum & 0xff), outs); cur_accum >>= 8; cur_bits -= 8; } flush_char(outs); } }
475f6070-ad67-4161-9350-6031ba92c8f6
2
public static boolean propertyEqualsAsBoolean(PropertyContainer container, String key, boolean test_value) { if (container != null) { try { boolean value = getPropertyAsBoolean(container, key); return value == test_value; } catch (NullPointerException npe) { return false; } } else { throw new IllegalArgumentException("Provided PropertyContainer was null."); } }
1cc65202-fc25-4d1d-a0c9-b36088a174c9
8
static public String repair(String input) { int cast = 0; if( input.length() == 3) { char num1 = '\0', num2 = '\0'; char c = '\0'; for(int i = 0; i < input.length(); i++) { char temp = input.charAt(i); if(Character.isDigit(temp)) { if( num1 == '\0') { num1 = temp; cast++; } else if( num2 == '\0') { num2 = temp; cast++; } } else if (Character.isAlphabetic(temp)){ if( c == '\0') { c = temp; cast++; } } } if (cast == 3) { char[] retcs = new char[3]; retcs[0] = num1; retcs[1] = c; retcs[2] = num2; String ret = String.valueOf(retcs); return ret; } else { return " "; } } return " "; }
b25de456-1ff1-49df-bc05-dd5c37c375aa
2
public boolean intervalContainsGeometry(RoadGeometry section, int beginning, int end) { for (int i = beginning; i <= end; i++) { if (stakes.get(section).contains(i)) { return true; } } return false; }
29b2d93a-a80f-480e-a1c8-3fef3425ebda
4
public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) { Container panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0); gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridx = 0; panel.add(new JLabel(instruction), gbc); gbc.gridy++; gbc.gridwidth = GridBagConstraints.RELATIVE; JTextField[] texts = new JTextField[prompt.length]; for (int i = 0; i < prompt.length; i++) { gbc.fill = GridBagConstraints.NONE; gbc.gridx = 0; gbc.weightx = 1; panel.add(new JLabel(prompt[i]), gbc); gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weighty = 1; if (echo[i]) { texts[i] = new JTextField(20); } else { texts[i] = new JPasswordField(20); } panel.add(texts[i], gbc); gbc.gridy++; } if (JOptionPane.showConfirmDialog(null, panel, destination + ": " + name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { String[] response = new String[prompt.length]; for (int i = 0; i < prompt.length; i++) { response[i] = texts[i].getText(); } return response; } else { return null; // cancel } }
04ade75e-a5a9-4218-a26b-6dcc4cea5dc2
3
public static boolean date(int h, int m) { String hh, mm; if (h == 0) { if (m < 10) return true; else { mm = m + ""; return mm.charAt(0) == mm.charAt(1); } } else if (h < 10) { hh = h + ""; mm = format(m); return hh.charAt(0) == mm.charAt(1); } hh = format(h); mm = format(m); return hh.equals(((new StringBuilder(mm)).reverse()).toString()); }
233f217a-4953-40c5-9ed7-22da3d1a05d7
2
public boolean equals(final Object duration) { if (duration == this) { return true; } if (duration instanceof Duration) { return compare((Duration) duration) == DatatypeConstants.EQUAL; } return false; }
5efae2f2-6c51-4c30-baca-af2070ddd4e6
4
public void write_single(short address, short msg) throws IOException { if ((this.mode==0) || (this.mode==SET_MODE_I2C_SERIAL)) this.set_mode(SET_MODE_I2C_100); byte[] data=new byte[3]; data[0]=(byte)RW_SINGLE; data[1]=(byte)address; data[2]=(byte)msg; byte[] result = this.sendAndReceive(data, COM_TIMEOUT, 1); if (result.length==0) throw new IOException("no answer from device"); if (result[0]!=0) throw new IOException("device error: "+result[0]); }
b1e9fe89-b530-48f8-a106-b7d520369ea7
3
void clear () { checked = grayed = false; texts = null; textWidths = new int [1]; fontHeight = 0; fontHeights = null; images = null; foreground = background = null; displayTexts = null; cellForegrounds = cellBackgrounds = null; font = null; cellFonts = null; cached = false; super.setText (""); super.setImage (null); int columnCount = parent.columns.length; disposeAccessibles(); accessibles = new Accessible [columnCount > 0 ? columnCount : 1]; if (columnCount > 0) { displayTexts = new String [columnCount]; if (columnCount > 1) { texts = new String [columnCount]; textWidths = new int [columnCount]; images = new Image [columnCount]; } } }
f6806146-753f-463b-90b1-9bbd6430f088
8
public static String readDecodedString(LittleEndianAccessor llea) { int strLength; byte b = llea.readByte(); if (b == 0x00) { return ""; } if (b >= 0) { // UNICODE BABY if (b == 0x7F) { strLength = llea.readInt(); } else { strLength = (int) b; } if (strLength < 0) { log.error("Strlength < 0"); return ""; } byte str[] = new byte[strLength * 2]; for (int i = 0; i < strLength * 2; i++) { str[i] = llea.readByte(); } return DecryptUnicodeStr(str); } else { // THIS BOAT IS ASCIIIIII if (b == -128) { strLength = llea.readInt(); } else { strLength = (int) (-b); } if (strLength < 0) { log.error("Strlength < 0"); return ""; } byte str[] = new byte[strLength]; for (int i = 0; i < strLength; i++) { str[i] = llea.readByte(); } return DecryptAsciiStr(str); } }
19199952-7856-48e5-a362-62157a9d33c9
7
public Entity getEntityByClass(String className){ for(Class<?> c : entitys){ if(c.getName().equals(className)){ try { return (Entity) c.newInstance(); } catch (Exception e) { e.printStackTrace(); } } } try { Class<?> c = Class.forName(className); if(Entity.class.isAssignableFrom(c)){ return (Entity) c.newInstance(); } } catch (Exception e) { e.printStackTrace(); } return null; }
c231160c-469f-498f-928b-76e1ca6d608d
9
@SuppressWarnings("unchecked") public boolean isInitialized() { // Check that all required fields are present. for (final FieldDescriptor field : getDescriptorForType().getFields()) { if (field.isRequired()) { if (!hasField(field)) { return false; } } } // Check that embedded messages are initialized. for (final Map.Entry<FieldDescriptor, Object> entry : getAllFields().entrySet()) { final FieldDescriptor field = entry.getKey(); if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { if (field.isRepeated()) { for (final Message element : (List<Message>) entry.getValue()) { if (!element.isInitialized()) { return false; } } } else { if (!((Message) entry.getValue()).isInitialized()) { return false; } } } } return true; }
80f17aae-677a-4af8-9549-3e5cfb0cc313
7
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(this.codCliente <= 0){ errors.add("Errores", new ActionMessage("error.codigo.cliente.no.valido")); } if(this.codMedida <= 0){ errors.add("Errores", new ActionMessage("error.codigo.medida.no.valido")); } if(this.objetivoCliente == null || this.objetivoCliente.equalsIgnoreCase("")){ errors.add("Errores", new ActionMessage("error.objetivo.no.ingresado")); } if(this.enfermadadesCliente == null || this.enfermadadesCliente.equalsIgnoreCase("")){ errors.add("Errores", new ActionMessage("error.enfermades.no.ingresadas")); } if(this.valorMedida <= 0.0){ errors.add("Errores", new ActionMessage("error.valor.medida.invalido")); } return errors; }
af937606-5772-4dae-8d3b-5ef17b8933bd
0
public String toString() { return this.getPrefix() + this.getNick(); }
d9ce43d1-53aa-438b-b9b4-f67b2b97d756
5
private static double[] getSupportPoints(int lineNumber, double[] lowPrices) { double[] sPoints = new double[lineNumber]; for(int i =0;i<lineNumber-1;i++){ double price = 999999999; for(int j=-28;j<=0;j++){ if((i+j>=0) && (i+j<lineNumber-1) && lowPrices[i+j]<price){ price =lowPrices[i+j]; sPoints[i]=price; } } } return sPoints; }
33533a88-138d-451e-9be6-3e4a96e160b0
9
@Override public void broadcast(AIPlayer p, gamelogic.PublicGameBoard board) { String message = "5/" + p.getID() + ","; BoardCoordinate c = _target.location(); int v = -1; boolean exp = board.isExpanded(); int nv = (exp)? NUM_VERTICES_EXP:NUM_VERTICES; Map<Integer, List<Integer>> x_gr = (exp)? X_GROUPS_EXP:X_GROUPS; Map<Integer, List<Integer>> y_gr = (exp)? Y_GROUPS_EXP:Y_GROUPS; Map<Integer, List<Integer>> z_gr = (exp)? Z_GROUPS_EXP:Z_GROUPS; for (int i = 0; i < nv; i++) { if (x_gr.get(c.x()).contains(i) && y_gr.get(c.y()).contains(i) && z_gr.get(c.z()).contains(i)) { v = i; break; } } if (v == -1) { System.out.println("Could not locate proper vertex index!"); // TODO: Debug line return; } gamelogic.CoordPair coords = board.getCoordsFromInt(v); message += Integer.toString(coords.getX()) + "," + Integer.toString(coords.getY()); p.broadcast(message); }
8e61345b-4b0a-4d31-ae44-694412ec49a6
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Feeds.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Feeds.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Feeds.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Feeds.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Feeds().setVisible(true); } }); }
3b32c07e-8ab6-4059-a175-a10bdcfff26b
2
public int nEquipa(String cod_competicao){ try { int i=0; Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery("SELECT cod_equipa FROM EquipaCampeonato where cod_competicao='"+cod_competicao+"'"); for (; rs.next(); i++); rs.close(); stm.close(); return i; } catch (SQLException e) { JOptionPane.showMessageDialog(null, e.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE); return -1; } }
321cfed6-4134-42b9-b49c-a10a6df1aa63
1
public void remover(InstituicaoSubmissao instituicaosubmissao) throws Exception { String sql = "DELETE FROM instituicaosubmissao WHERE id = ?"; try { PreparedStatement stmt = ConnectionFactory.getConnection().prepareStatement(sql); stmt.setLong(1, instituicaosubmissao.getId()); stmt.executeUpdate(); } catch (SQLException e) { throw e; } }
30c42044-0cba-43c8-a178-70d97f080b2b
6
private void compileParameters() throws IllegalArgumentException, IllegalAccessException, MalformedLayarRequestException { Field[] fields = LayarGetPOIsRequest.class.getFields(); for (Field f : fields) { String fName = f.getName(); Class fClass = f.getType(); if(parameters.containsKey(fName)) { String[] ss = parameters.get(fName); Object v = ss[0]; try { if (fClass == Integer.class) { v = Integer.parseInt((String)v); } else if (fClass == Long.class) { v = Long.parseLong((String)v); } else if (fClass == Double.class) { v = Double.parseDouble((String)v); } } catch (NumberFormatException exc) { throw new MalformedLayarRequestException(fName +"("+v+") is not a valid " + fClass); } f.set(layarRequest, v); } } }
b675596f-bae3-4160-8e5d-3b464d0f29c5
1
public void testWithFieldAdded_unknownField() { YearMonth test = new YearMonth(2004, 6); try { test.withFieldAdded(DurationFieldType.hours(), 6); fail(); } catch (IllegalArgumentException ex) {} }
f7cb4906-22ef-45d9-9b4c-d8cd9fd7d622
3
public Aluno pesquisaAlunoPelaMatricula(String matricula) throws AlunoInexistenteException { Aluno alunoAchado = null; for (Aluno e : alunos) { if (e.getMatricula().equals(matricula)) { alunoAchado = e; break; } } if (alunoAchado != null) { return alunoAchado; } else { throw new AlunoInexistenteException("Aluno Inexistente"); } }
d8bc62d1-a6e5-4da2-babb-46aa17b373f4
3
@Override public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { ListSelectionModel lsm = (ListSelectionModel) event.getSource(); if (lsm.isSelectionEmpty() == false) { try { int selectedRow = lsm.getMinSelectionIndex(); // da in der Tabelle die Autosortierung mit // setAutoCreateRowSorter(true) gesetzt wurde, ist die // Convertierung notwendig, damit die korrekte Zeile/Spalte // ausgewählt wird String id = String .valueOf(guiBook .getBookTable() .getModel() .getValueAt( guiBook.getBookTable() .convertRowIndexToModel( selectedRow), 0)); Book myBook = new BookDB().findByID(id); guiBook.getBookIdText().setText( String.valueOf(myBook.getId())); guiBook.getIsbnText().setText( String.valueOf(myBook.getIsbn())); guiBook.getTitleText().setText( String.valueOf(myBook.getTitle())); guiBook.getAuthorText().setText( String.valueOf(myBook.getAuthor())); guiBook.getPublicationDateText().setText( String.valueOf(myBook.getPublicationDate())); guiBook.getFormatCombo().setSelectedItem( String.valueOf(myBook.getFormat())); guiBook.getShortDescriptionArea().setText( myBook.getShortDescription()); guiBook.getCategoryCombo().setSelectedItem( String.valueOf(myBook.getCategory())); guiBook.getCommentArea().setText( String.valueOf(myBook.getComment())); guiBook.getReadCombo().setSelectedItem( String.valueOf(myBook.getRead())); // Button "löschen" wird sichtbar gesetzt guiBook.getDeleteButton().setEnabled(true); } catch (Exception e) { System.out.println(e.toString()); // Ein Dialogfenster mit entsprechender Meldung soll erzeugt // werden String errorText = "Der ausgewählte Datensatz kann nicht angezeigt werden."; new InfoError().showMessage(errorText); } } } }
22a67782-ee66-4fd7-b331-07cd88366123
8
final void method3049(ByteBuffer class348_sub49, int i, int i_39_) { while_209_: do { try { anInt9384++; if (i_39_ == 31015) { int i_40_ = i; do { if ((i_40_ ^ 0xffffffff) != -1) { if ((i_40_ ^ 0xffffffff) != -2) { if (i_40_ == 2) break; break while_209_; } } else { anInt9402 = class348_sub49.getWord(13638); return; } anInt9390 = (class348_sub49.getByte() << 1365062124) / 100; return; } while (false); anInt9398 = (class348_sub49.getByte() << 1792937036) / 100; break; } break; } catch (RuntimeException runtimeexception) { throw Class348_Sub17.method2929(runtimeexception, ("vj.F(" + (class348_sub49 != null ? "{...}" : "null") + ',' + i + ',' + i_39_ + ')')); } } while (false); }
fe15d6b7-21cd-4991-9eb6-23b5d953db09
7
public int findBomb(int startIndex, int stopIndex) { startIndex=(startIndex+LANDNUM)%LANDNUM; stopIndex=(stopIndex+LANDNUM)%LANDNUM; if(startIndex>stopIndex){ for(int i=startIndex;i<LANDNUM;i++){ LandForm tempLandForm=(LandForm)landList.get(i); if(tempLandForm.bombFlag){ return tempLandForm.index; } } for(int i=0;i<stopIndex;i++){ LandForm tempLandForm=(LandForm)landList.get(i); if(tempLandForm.bombFlag){ return tempLandForm.index; } } } else{ for(int i=startIndex;i<stopIndex;i++){ LandForm tempLandForm=(LandForm)landList.get(i); if(tempLandForm.bombFlag){ return tempLandForm.index; } } } return -1; }
1573bf8a-5eaa-44f5-9e7c-b013c0368b0c
6
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length < 1) { showHelp(sender); return true; } String[] newArgs = new String[args.length - 1]; for (int i = 1; i < args.length; i++) { newArgs[i - 1] = args[i]; } AbstractCommand commandClass; switch (args[0].toLowerCase()) { case "reload": commandClass = new ReloadCommand(plugin, "reload"); break; case "regen": commandClass = new RegenCommand(plugin, "regen"); break; case "update": commandClass = new UpdateCommand(plugin, "update"); break; default: showHelp(sender); return true; } if (!commandClass.execute(sender, newArgs)) { showHelp(sender); } return true; }
c6d5e31e-8d1d-4677-8978-67c3b05c1cf2
7
public static int Compare(NaturalNumber n, NaturalNumber m) { int i, comparison; if(n.size != m.size) { /* the longer one is not necessarily the greater, if the difference is all leading zeroes -- scan the excess: if there is a nonzero digit, then the longer one is the greater, else proceed as if they were of equal length. */ NaturalNumber longer = null, shorter = null; if(n.size > m.size) { comparison = 1; longer = n; shorter = m; } else { comparison = -1; longer = m; shorter = n; } for(i = longer.size - 1; i >= shorter.size; i--) { if(longer.digits[i] > 0) { return comparison; } } } else { i = n.size - 1; } /* starting from the most significant position, see if any digits are unequal: if so, then the one with the greater digit is the greater number; if not, then they are equal. */ while(i >= 0) { if(n.digits[i] > m.digits[i]) { return 1; } if(n.digits[i] < m.digits[i]) { return -1; } i--; } return 0; }
4f49c892-f1df-4e5e-bb87-8fb901f4a275
8
public boolean defilerTemps(Joueur j) { /* Methode qui compare le temps du systeme au temp de jeu d'un joueur. * Met fin à la partie si le temps de jeu est ecoule. */ // MAJ temps boolean fini = false; do { try { Thread.sleep(1000); j.setTempsEcoule(j.getTempsEcoule() - 1); System.out.println("Joueur " + j.getNom() + " : " + j.getTempsEcoule()); } catch (InterruptedException exception){} } while(!((j.getCouleur() == "blanc" && this.tour%2 != 0 && this.caseCliquee == this.mesDestinations.lastElement()) || (j.getCouleur() == "noir" && this.tour%2 == 0 && this.caseCliquee == this.mesDestinations.lastElement())) && j.getTempsEcoule() > 0); fini = true; return fini; }
6d9d0aae-d761-4920-9c91-604f5e060753
5
private void bfs(Graph G, int s) { Queue<Integer> q = new LinkedList<Integer>(); q.add(s); marked[s] = true; while (!q.isEmpty()) { adjCount[s]++; int v = q.remove(); for (int w : G.adj(v)) if (!marked[w]) { edgeTo[w] = v; marked[w] = true; distTo[w] = distTo[v] + 1; q.add(w); } } // calculate eccentricity of s for (int i = 0; i < distTo.length; i++) if (distTo[i] > eccentricity) eccentricity = distTo[i]; }
d206dca7-4da3-4f35-821f-ba2b43ca1994
8
protected String getJSONBaseString() { StringBuilder json = new StringBuilder(); if(this.getId()!=null) json.append("\"id\":").append(JSONObject.quote(this.getId())).append(","); json .append("\"type\":\"").append(this.getType()).append("\"," ) .append("\"text\":").append(JSONObject.quote(this.getText())).append("," ); if(this.getPriority()!=null) json.append("\"priority\":").append(this.getPriority()).append(","); if(this.getNotes()!=null && !this.getNotes().contentEquals("")) json.append("\"notes\":").append(JSONObject.quote(this.getNotes())).append("," ); json.append("\"value\":").append(this.getValue()).append(","); if(this.getTagsId()!=null && this.getTagsId().size()!=0) { json.append("\"tags\":{"); for(String tagId : this.getTagsId()) { json.append("").append(JSONObject.quote(tagId)).append(":").append("true").append(","); } json.deleteCharAt(json.length()-1); json.append("},"); } if(this.getAttribute()!=null) { json.append("\"attribute\":\"").append(this.getAttribute()).append("\","); } return json.toString(); }
816df931-518b-4aed-b28c-4d789883953c
5
public void advance() { if (location == null) { location = new Location(map.start[0], map.start[1]); grid.add(location, this); }else if(health <= 0) { kill(); }else{ if(step > speed) { step = 0; Location l = Path.findNext(Location.toPath(location), pathsNotTaken).toLocation(); if (grid.add(l, this)){ grid.remove(location); Path.remove(location,pathsNotTaken); location = l; } }else{ step++; } } if(location.equals(End.location)){ GameLogic.itsNotOver = false; Var.GAME_END_STRING = "HEROES WIN"; } }
9730faa5-2624-4aa4-abb7-6b36dd1d3ade
3
public void putRecent(String f) { // Trim from back end if too long while (recentNames.size() > maxRecentFiles - 1) { recentNames.remove(recentNames.size()-1); } // Move filename to front: Remove if present, add at front. if (recentNames.contains(f)) { recentNames.remove(f); } recentNames.add(0, f); // Now save from List into Prefs for (int i = 0; i < recentNames.size(); i++) { String t = recentNames.get(i); prefsNode.put(makeName(i), t); } // Finally, load menu again. callCallBack(); }
f6b53ee0-743b-4653-bbed-6bf1416477a9
2
public ArrayList<ArrayList<String>> readData() throws IOException { ArrayList<ArrayList<String>> datas = new ArrayList<ArrayList<String>>(); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String str = ""; while (!(str = reader.readLine()).equals("")) { StringTokenizer tokenizer = new StringTokenizer(str); ArrayList<String> s = new ArrayList<String>(); while (tokenizer.hasMoreTokens()) { s.add(tokenizer.nextToken()); } datas.add(s); } return datas; }
3d310bf4-ec28-45ad-ab3b-9d56531fc35d
0
public static void main(String[] args) { FilePrompt.filePrompt(); }
dad704d9-17b0-4906-9f06-f78a0adc8744
1
public Question(String question,String a,String b,int i){ if(i > 1){ i = 1; } formattedQuestion = question; answers = new String[2]; answers[0] = a; answers[1] = b; answer = i; }
248ed3fb-733f-4dc3-a27c-b4f522570a71
2
@Override public void mouseClicked(MouseEvent event) { if(event.getClickCount()==2){ int linha = janela.getTabelaContatos("todos").getSelectedRow(); System.out.println("Linha selecionada foi "+linha); } else if (event.getClickCount()==1){ } }
74e4855c-a6d1-4f43-a5c5-d7b83264d4a9
0
private void onIncorrect() { isCorrect = false; dispose(); }
356624c2-9e49-40a4-834c-20aff231864b
9
public static void moveAll() { Map map = Map.getInstance(); Random rand = new Random(); int num = 0; for (Party enemy : list) { num = rand.nextInt(10); if(num == 0 && map.moveParty(enemy, Direction.NORTH)) enemy.move(Direction.NORTH); else if(num == 1 && map.moveParty(enemy, Direction.SOUTH)) enemy.move(Direction.SOUTH); else if(num == 2 && map.moveParty(enemy, Direction.WEST)) enemy.move(Direction.WEST); else if(num == 3 && map.moveParty(enemy, Direction.EAST)) enemy.move(Direction.EAST); } }
81aae110-c158-4916-81bd-cb48093ec9a6
9
private void setField(FieldDictionary dictionary, OMMFieldEntry fentry, FidDef fiddef, boolean ripple, boolean add) { FieldValue field = getValue(fiddef.getName()); if (field == null) { if (add) { short type = fentry.getDataType(); if (type == OMMTypes.UNKNOWN) type = fiddef.getOMMType(); int listCount = _entries.size(); int row = _row; int col = _column; if (row == -1) row = listCount; else if (col == -1) col = listCount; field = new FieldValue(_model, fiddef); _entries.put(fiddef.getName(), field); field.update(fentry); } } else if (ripple && (fiddef.getRippleFieldId() != 0)) { Object tmp = field.getStringValue(); setFirstField(fentry, fiddef, field); while ((fiddef.getRippleFieldId() != 0) && ((field = getValue(dictionary.getFidDef(fiddef.getRippleFieldId()).getName())) != null)) { tmp = field.setValue(tmp); short fieldId = field.getFieldId(); fiddef = dictionary.getFidDef(fieldId); } } else { setFirstField(fentry, fiddef, field); } }
9fb4fbda-b841-4d30-974b-af3c4c102046
3
public JSONObject putOnce(String key, Object value) throws JSONException { if (key != null && value != null) { if (this.opt(key) != null) { throw new JSONException("Duplicate key \"" + key + "\""); } this.put(key, value); } return this; }
e9c57661-77c0-4445-acfb-734f843e7e4f
8
private void hazardCheckLine(int p,Point2D.Double p1,Point2D.Double p2) { int h = 0; Point2D.Double pointIntersect; Line2D.Double lineR = new Line2D.Double(); lineR.setLine(p1, p2); while (h < main.map.hazards) { h++; MapHazard hz = main.map.getHazard(h); if (hz != null) { if (hz.shape == MapHazard.SHAPE_RECTANGLE) { Point2D.Double hp1 = new Point2D.Double(); Point2D.Double hp2 = new Point2D.Double(); hp1.x = hz.point[1].x; hp1.y = hz.point[1].y; hp2.x = hz.point[2].x; hp2.y = hz.point[2].y; // if (hp1.x > hp2.x) { // double tmp = hp2.x; // hp2.x = hp1.x; // hp1.x = tmp; // } // if (hp1.y > hp2.y) { // double tmp = hp2.y; // hp2.y = hp1.y; // hp1.y = tmp; // } Line2D.Double lineH = new Line2D.Double(); lineH.x1 = hp1.x; lineH.y1 = hp1.y; lineH.x2 = hp1.x; lineH.y2 = hp2.y; pointIntersect = getIntersectionPoint(lineR,lineH); if (pointIntersect != null) { hazardAddIntersect(p,h,pointIntersect); } lineH.x1 = hp1.x; lineH.y1 = hp2.y; lineH.x2 = hp2.x; lineH.y2 = hp2.y; pointIntersect = getIntersectionPoint(lineR,lineH); if (pointIntersect != null) { hazardAddIntersect(p,h,pointIntersect); } lineH.x1 = hp2.x; lineH.y1 = hp2.y; lineH.x2 = hp2.x; lineH.y2 = hp1.y; pointIntersect = getIntersectionPoint(lineR,lineH); if (pointIntersect != null) { hazardAddIntersect(p,h,pointIntersect); } lineH.x1 = hp2.x; lineH.y1 = hp1.y; lineH.x2 = hp1.x; lineH.y2 = hp1.y; pointIntersect = getIntersectionPoint(lineR,lineH); if (pointIntersect != null) { hazardAddIntersect(p,h,pointIntersect); } } if (hz.shape == MapHazard.SHAPE_CIRCLE) { Circle circle = new Circle(); circle.x = hz.point[1].x; circle.y = hz.point[1].y; circle.radius = hz.radius; getCircleLineIntersect(p,h,lineR,circle); } } } }
f5186550-f149-41b0-a788-0a6b29f6bec9
8
private void printSemiIfNeed(JsNode node) { if (!(node instanceof JsFunction) && (node instanceof JsLiteral || node instanceof JsInvocation || node instanceof JsArrayAccess || node instanceof JsBinaryOperation || node instanceof JsUnaryOperation || node instanceof JsOperator || node instanceof JsNameRef)) { semi(); } }
1b4930ae-dfbf-4168-8308-d0002221c26d
9
private static A convert(String regex) { List<String> groups = splitAndGroup(regex); A curr = new A(); if (groups.size() > 1) { for (String s : groups) { A tmp = convert(s); curr.stateNames.addAll(tmp.stateNames); curr.transitionsForState.putAll(tmp.transitionsForState); curr.addTransition(curr.begin, Automaton.EPSILON, tmp.begin); curr.addTransition(tmp.end, Automaton.EPSILON, curr.end); } } else { String prev = curr.begin; for (int i = 0; i < regex.length(); ++i) { String s1; String s2; if (isEscapedAt(regex, i)) { s1 = createNewState(); s2 = createNewState(); curr.stateNames.add(s1); curr.stateNames.add(s2); curr.addTransition(s1, Character.toString(unescape(regex.charAt(i))), s2); } else { if (regex.charAt(i) == '\\') continue; if (regex.charAt(i) != '(') { s1 = createNewState(); s2 = createNewState(); curr.stateNames.add(s1); curr.stateNames.add(s2); curr.addTransition(s1, regex.charAt(i) == '$' ? Automaton.EPSILON : Character.toString(regex.charAt(i)), s2); } else { int j = findMatchingParenthesis(regex, i); A tmp = convert(regex.substring(i + 1, j)); curr.stateNames.addAll(tmp.stateNames); curr.transitionsForState.putAll(tmp.transitionsForState); s1 = tmp.begin; s2 = tmp.end; i = j; } } if (i + 1 < regex.length() && regex.charAt(i + 1) == '*') { String innerBegin = s1; String innerEnd = s2; curr.stateNames.add(s1 = createNewState()); curr.stateNames.add(s2 = createNewState()); curr.addTransition(s1, Automaton.EPSILON, innerBegin); curr.addTransition(innerEnd, Automaton.EPSILON, s2); curr.addTransition(s1, Automaton.EPSILON, s2); curr.addTransition(innerEnd, Automaton.EPSILON, innerBegin); ++i; } // / curr.addTransition(prev, Automaton.EPSILON, s1); prev = s2; } curr.addTransition(prev, Automaton.EPSILON, curr.end); } return curr; }
57aa2184-cefa-4532-803e-4472b398265f
8
public static void compileJarAssetsFile(String prjCompileDir, String prjGameName, String prjDir) { File selectedFile = new File(prjCompileDir + File.separator + prjGameName.toLowerCase() + ".assets.jar"); File content = new File(prjDir); File[] files = content.listFiles(); assert files != null; Main.log.warning("Starting JarAssetsCompiler for " + selectedFile.toString()); List<File> preparedFiles = new ArrayList<File>(); for (File f : files) { if (!f.isDirectory()) { int code = checkAndAddFile(preparedFiles, f); if (code == 0) { Main.log.severe("The compiler has returned error code 0 : invalid_argument_#size"); return; } else if (code == 1) { Main.log.severe("The compiler has returned error code 1 : invalid_argument_#extention"); return; } else if (code == 2) { Main.log.severe("The compiler has returned error code 2 : unknown_error"); return; } else if (code == 3) { Main.log.severe("The compiler has returned error code 3 : file_load_failure"); return; } } else { addDirectoryToCompileList(f, preparedFiles); } } File[] finalFiles = new File[preparedFiles.size()]; for (int i = 0; i < preparedFiles.size(); i++) { finalFiles[i] = preparedFiles.get(i); } try { craeteZip(finalFiles, selectedFile); } catch (IOException e1) { Main.log.warning("JarAssetsCompiler failure"); Main.log.severe("Compiler has stopped running, closing..."); return; } Main.log.fine("JarAssetsCompiler succeeded !"); }
2f0a6db5-f107-404b-bd8f-04a16dcde61d
9
public boolean equals(Object obj) { if (!(obj instanceof JavaAdapterSignature)) return false; JavaAdapterSignature sig = (JavaAdapterSignature) obj; if (superClass != sig.superClass) return false; if (interfaces != sig.interfaces) { if (interfaces.length != sig.interfaces.length) return false; for (int i=0; i < interfaces.length; i++) if (interfaces[i] != sig.interfaces[i]) return false; } if (names.size() != sig.names.size()) return false; ObjToIntMap.Iterator iter = new ObjToIntMap.Iterator(names); for (iter.start(); !iter.done(); iter.next()) { String name = (String)iter.getKey(); int arity = iter.getValue(); if (arity != names.get(name, arity + 1)) return false; } return true; }
a7f8e2e6-cf13-40fb-a7fe-9918526a5222
1
public MainFrame(User user) { super(JGSystem.NAME); this.user = user; this.DEFAULT_MAIN_FRAMESIZE = new Dimension(1024, 768); this.PREFERRED_PANEL_SIZE = new Dimension(1024-5-25, 768-25-25); this.setSize(this.DEFAULT_MAIN_FRAMESIZE); this.setMaximumSize(this.DEFAULT_MAIN_FRAMESIZE); this.setLayout(new BorderLayout()); JPanel jpnlMainPanel = new JPanel(); jpnlMainPanel.setPreferredSize(this.PREFERRED_PANEL_SIZE); jpnlMainPanel.setLayout(new BorderLayout()); JPanelMainFrameHeader jpnlHeader = new JPanelMainFrameHeader(); jpnlHeader.setPreferredSize(new Dimension(this.DEFAULT_MAIN_FRAMESIZE.width, 110)); jpnlMainPanel.add(jpnlHeader, BorderLayout.NORTH); JPanel jpnlWest = new JPanel(); jpnlWest.setLayout(new BoxLayout(jpnlWest, BoxLayout.Y_AXIS)); UserPanel userPanel = new UserPanel(user); userPanel.setPreferredSize(new Dimension(200, 110)); jpnlWest.add(userPanel); jpnlWest.add(Box.createVerticalStrut(30)); ChatPanel chatPanel = new ChatPanel(user); chatPanel.setPreferredSize(new Dimension(200, 500)); jpnlWest.add(chatPanel); jpnlMainPanel.add(jpnlWest, BorderLayout.WEST); JPanel jpnlCenter = new JPanel(); jpnlCenter.setLayout(new BorderLayout()); ContentPanel contentPanel = new ContentPanel(); contentPanel.setPreferredSize(new Dimension(770, 485)); jpnlCenter.add(contentPanel, BorderLayout.CENTER); MenuPanel menuPanel = new MenuPanel(contentPanel, user); menuPanel.setPreferredSize(new Dimension(this.DEFAULT_MAIN_FRAMESIZE.width - 200, 110)); jpnlCenter.add(menuPanel, BorderLayout.NORTH); jpnlMainPanel.add(jpnlCenter, BorderLayout.CENTER); JScrollPane jscrllMainScrollPane = new JScrollPane(jpnlMainPanel); this.add(jscrllMainScrollPane, BorderLayout.CENTER); this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.addWindowListener(new WLMainFrame()); // this.addMouseListener(new MLMainFrame()); // this.addComponentListener(new CLMainFrame()); this.setLocationRelativeTo(null); this.setVisible(true); if(!checkNickname(user)){ requestNickname(user); userPanel.updatePanel(user); revalidate(); } }
c807f286-f1c8-41ba-b218-3bf7424ce7c5
9
private void genTextMaps(){ Session session = sessionFactory.openSession(); session.beginTransaction(); Query q1 = session.createQuery("from Intro_learn"); @SuppressWarnings("unchecked") List<Intro_learn> list_intro = q1.list(); Intro_learn intro = new Intro_learn(); String introduction; text_cls tc; cls_cls cc; for(int i=0;i<list_intro.size();i++){ intro = list_intro.get(i); introduction = intro.getIntroduction(); list_text.clear(); list_cls.clear(); try{ StrHandler.introString2array(introduction, list_text, list_cls); }catch(Exception e){ System.out.println(introduction); } for(int j=0;j<list_text.size()-1;j++){ tc = new text_cls(); cc = new cls_cls(); tc.text=list_text.get(j); tc.cls=list_cls.get(j); cc.cls1=list_cls.get(j); cc.cls2=list_cls.get(j+1); if(cls_map.containsKey(list_cls.get(j))) cls_map.put(list_cls.get(j), cls_map.get(list_cls.get(j))+1); else cls_map.put(list_cls.get(j),1); if(text_cls_map.containsKey(tc)) text_cls_map.put(tc, text_cls_map.get(tc)+1); else text_cls_map.put(tc, 1); if(cls_cls_map.containsKey(cc)) cls_cls_map.put(cc, cls_cls_map.get(cc)+1); else cls_cls_map.put(cc, 1); } } Iterator<Entry<text_cls , Integer>> iter = text_cls_map.entrySet().iterator(); Entry<text_cls , Integer> entry; while (iter.hasNext()) { entry = iter.next(); if(entry.getValue()>10){ if(!distc_text.contains((entry.getKey()).getText())) distc_text.add((entry.getKey()).getText()); } } session.flush(); session.clear(); session.getTransaction().commit(); session.close(); }
cf153d92-663f-4410-87e9-7f0660d1a634
8
final public NodeToken ValueExpansion() throws ParseException { Token value; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case VALUE_IDENTIFIER_T: value = jj_consume_token(VALUE_IDENTIFIER_T); break; case NOT_IMPLEMENTED_T: value = jj_consume_token(NOT_IMPLEMENTED_T); break; case CURRENT_T: value = jj_consume_token(CURRENT_T); break; case DEPRECATED_T: value = jj_consume_token(DEPRECATED_T); break; case OBSOLETE_T: value = jj_consume_token(OBSOLETE_T); break; case MANDATORY_T: value = jj_consume_token(MANDATORY_T); break; default: jj_la1[54] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return makeNodeToken(value);} throw new Error("Missing return statement in function"); }
20088638-c1a4-4a00-aafd-420d9abaafe8
0
private PDestination(String whereTo) { label = whereTo; }
f85dcf62-2015-4606-865e-41d995a23015
1
public static void createWindow(int width, int height, String title) { Display.setTitle(title); try { Display.setDisplayMode(new DisplayMode(width, height)); // DisplayMode displayMode = null; // DisplayMode[] modes = Display.getAvailableDisplayModes(); // // for (int i = 0; i < modes.length; i++) // { // if (modes[i].getWidth() == width // && modes[i].getHeight() == height // && modes[i].isFullscreenCapable()) // { // displayMode = modes[i]; // } // } // Display.setFullscreen(true); //Display.setVSyncEnabled(true); Display.create(); Keyboard.create(); Mouse.create(); } catch (LWJGLException e) { e.printStackTrace(); } }
7da3b6ac-dddf-430c-8858-7913f81d4ac7
6
@Override public void update() { super.update(); boolean doUpdate = !gameController.getIsMasterPaused(); HUD hud = null; for (int i = 0; i < huds.size(); i++) { hud = huds.get(i); if (doUpdate || hud.getName().equals("Pause") || hud.getName().equals("Tutorial") || hud.getName().equals("Credits")) { hud.update(); } if (hud.isDirty()) { hud = null; huds.remove(i); } } }
f1107e70-5b16-4c32-bb0c-aff1e08667f1
3
private MetadataEntry getUserMetadata(GoogleDocs googleDocs) throws ServiceException { DocsService docsService = new DocsService("spring-social-google-docs/1.0"); docsService = googleDocs.setAuthentication(docsService); try { return docsService.getEntry(new URL(METADATA_URL), MetadataEntry.class); } catch (MalformedURLException e) { throw new ApiException(e.getMessage()); } catch (IOException e) { throw new ApiException(e.getMessage()); } catch (ServiceException e) { throw e; } }
d713919d-9194-4c0d-b6e9-44bfb98486bd
1
public ArrayList<String> getAllArtists() { ArrayList<String> songArtists = new ArrayList<>(); //Run through each song and get artist, set in array for (Song s : songList) { songArtists.add(s.getArtist()); } //Return array of artists return songArtists; }
8ea367f2-b0c5-4fb9-b022-eecb1c9b38bb
5
@Override public double train(Collection<_Doc> trainSet) { ArrayList<_Doc> graph = new ArrayList<_Doc>(); String lastItemID = null; for(_Doc d:trainSet) { if (lastItemID == null) lastItemID = d.getItemID(); else if (lastItemID != d.getItemID()) { if (graph.size()>10)//otherwise the graph is too small calcPageRank(graph); graph.clear(); lastItemID = d.getItemID(); } graph.add(d); } //for the last product if (graph.size()>5)//otherwise the graph is too small calcPageRank(graph); return 0; }
586c57bc-1a65-499b-a30d-a50a2a6439b6
3
public static void main(final String[] args) { parseArgs(args); /* load icons */ for (final Command c : Command.values()) { final ImageIcon image = loadIcon("/genetic/res/" + c.toString() + ".png"); COMMAND_ICONS.put(c, image); } /* load & prepare (in constructor) */ final Field field = new Field(); /* show the gui */ final Gui guiFrame = new Gui(field); EventQueue.invokeLater(guiFrame); /* start the simulation */ while (true) { try { final double sleepTime = MS_PER_SECOND / Parameter.SIMULATION_SPEED.getValue(); Thread.sleep((int) sleepTime); } catch (final InterruptedException e) { e.printStackTrace(); } field.tick(); } }
4a202313-51c8-4f77-a7c5-d720a0675fb3
0
@Test public void testGetMarker() { System.out.println("getMarker"); Mark instance = new Mark(6,9); int expResult = 6; int result = instance.getMarker(); assertEquals(expResult, result); }
5c34fcd3-962d-4397-bb40-cea101564c4c
0
public void setItemId(int itemId) { this.itemId = itemId; }
59f819d0-9b49-4ff0-a2e4-a1734da7a6a6
5
@Test public void depthest11opponent3() { for(int i = 0; i < BIG_INT; i++) { int numPlayers = 4; //assume/require > 1, < 7 Player[] playerList = new Player[numPlayers]; ArrayList<Color> factionList = Faction.allFactions(); playerList[0] = new Player(chooseFaction(factionList), new SimpleAI()); playerList[1] = new Player(chooseFaction(factionList), new DepthEstAI(1,1, new StandardEstimator())); playerList[2] = new Player(chooseFaction(factionList), new SimpleAI()); playerList[3] = new Player(chooseFaction(factionList), new SimpleAI()); Color check = playerList[1].getFaction(); GameState state = new GameState(playerList, new Board(), gameDeck, gameBag, score); Set<Player> winners = Game.run(state, new StandardSettings()); boolean won = false; for(Player p : winners) { if(p.getFaction().equals(check)) { won = true; wins++; if(winners.size() > 1) { tie++; } } } if(!won) { loss++; } } assertEquals(true, wins/(wins+loss) > .8); }
30c0306c-0fbe-46f3-9c8b-71e04da0c836
9
@SuppressWarnings({ "deprecation", "static-access" }) public void loadInventory() { try { Connection conn = MineAuction.db.getConnection(); PreparedStatement ps = conn .prepareStatement("SELECT * FROM ma_items WHERE playerID=? ORDER BY qty ASC LIMIT 54"); // Prepare statement int playerID = DatabaseUtils.getPlayerId(this.player.getUniqueId()); ps.setInt(1, playerID); // Result ResultSet rs = ps.executeQuery(); int i = 0; // Reset inventory this.inventory.clear(); // Work with result while (rs.next()) { try { if (rs.getInt("qty") < 1) continue; // Get data int itemID = rs.getInt("itemID"); short itemDamage = rs.getShort("itemDamage"); int qty = rs.getInt("qty"); String itemData = rs.getString("itemMeta"); Map<Enchantment, Integer> itemEnch = WebInventoryMeta .getItemEnchantmentMap(rs.getString("enchantments")); // Modified/Special value for chest render Material mat = Material.getMaterial(itemID); int visualQty = qty > mat.getMaxStackSize() ? mat .getMaxStackSize() : qty; String visualLore = String .format("%s: %d", MineAuction.lang .getString("auction_item_quantity"), qty); // get ItemStack ItemStack is = null; if (itemData != null && itemData != "") { // Yaml metadata is = WebInventoryMeta.getItemStack(itemData); } else { // No yaml metadata is = new ItemStack(Material.getMaterial(itemID), qty, itemDamage); } // setup qty lore List<String> tempList = new ArrayList<String>(); if (is.getItemMeta().clone().hasLore()) { tempList = is.getItemMeta().getLore(); tempList.add(visualLore); } else { tempList.add(visualLore); } // Overwrite values is.setAmount(visualQty); is.addEnchantments(itemEnch); if(ItemUtils.canHaveDamage(is.getTypeId())) { InputStream stream = new ByteArrayInputStream(itemData.getBytes(StandardCharsets.UTF_8)); YamlConfiguration yac = YamlConfiguration.loadConfiguration(stream); short dur = (short) yac.getInt("damage"); is.setDurability(dur); Bukkit.broadcastMessage("Dur:" +dur); } else { is.setDurability(itemDamage); } // Overwrite qty lore ItemMeta im = is.getItemMeta().clone(); im.setLore(tempList); is.setItemMeta(im); // Send item to inventory this.inventory.setItem(i, is); i++; } catch (Exception e) { int itemID = rs.getInt("itemID"); ItemStack is = new ItemStack(Material.getMaterial(itemID)); this.player .sendMessage(MineAuction.plugin.prefix + ChatColor.RED + String.format( "Skipping item %s, because it has some errors.", is.getType().name())); } } } catch (Exception e) { e.printStackTrace(); } }
85e4aa9e-b3c5-46f4-a4f1-b3f38bcfd777
2
public static boolean isBlankRow(Row row) { Iterator<Cell> iterator = row.iterator(); boolean isBlankRow = true; while (iterator.hasNext()) { Cell curCell = iterator.next(); if (curCell.getCellType() != Cell.CELL_TYPE_BLANK) { isBlankRow = false; break; } } return isBlankRow; }
d9d86ba6-9734-4d7e-86ed-f70329f02fab
8
public static void main(String[] args) throws Exception{ if(ClientModel.isMac()){ System.setProperty("com.apple.mrj.application.apple.menu.about.name","Enigma"); System.setProperty("apple.laf.useScreenMenuBar", "false"); } splash.setVisible(true); Mode mode=Mode.NORMAL; if(args.length>0){ if(args[0].equals("-h") || args[0].equals("-help")){ showHelp(); return; }else if(args[0].equals("-n") || args[0].equals("-noenceypt")){ mode=Mode.NO_ENCRYPT; System.out.println("start-up in no encrypt mode"); }else if(args[0].equals("-l") || args[0].equals("-limit")){ mode=Mode.VIEW_LIMIT; System.out.println("start-up in view limited mode"); } }else{ System.out.println("start-up in normal mode"); } File newdir = new File("resource"); newdir.mkdir(); Example stream = new Example(mode); stream.startUserStream(); }
43587592-af4d-4388-b815-b52cc37cc4ef
7
public static void main(String[] args) throws IOException { StringBuilder out = new StringBuilder(); l = new Cube[223]; // Pre calculate int cont = 0; long a = 0; double a_3 = 0, aux; for (int i = 2; i <= 199; i++) for (int j = i; j <= 199; j++) if (p3(i) + p3(j) <= LIMIT) for (int k = j; k <= 199; k++) { a = p3(i) + p3(j) + p3(k); a_3 = (int) Math.round(Math.pow(a, 1 / 3.0)); aux = Math.pow(a_3, 3); if (a <= LIMIT && Math.abs(aux - a) <= EPS) l[cont++] = new Cube((int) a_3, i, j, k); } Arrays.sort(l); for (int i = 0; i < cont; i++) out.append(l[i] + "\n"); System.out.print(out); }
30056950-15a9-4a0a-a4b2-a821dff86181
2
public Collection<String> getCatNos() throws SQLException { if (catnos == null || catnos.size() == 0) catnos = GetRecords.create().getCatNos(number); return catnos; }
7b080399-85bf-47dc-86f7-1a53d33f53db
4
@SuppressWarnings("unchecked") public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { String serviceName = (String) table.getValueAt(row, column - 1); HashMap<String, String> userStatusAssoc; User user = instanceGUI.getUser(); // Check if a transfer has been started => // return null so as not to edit a thing if (user.getServiceTransfer(serviceName) != null) return null; // Add "Inactive" if the servicelist is empty if (user.isEmptyServiceList() || user.isEmptyService(serviceName)) { JLabel label = new JLabel(StatusMessages.inactive.toUpperCase()); label.setHorizontalAlignment(SwingConstants.CENTER); return label; } // Add matching users to a combobox JComboBox<String> combo = (JComboBox<String>) super.getTableCellEditorComponent( table, value, isSelected, row, column); userStatusAssoc = instanceGUI.getUser().getServiceProviders(serviceName); Set<String> keySet = userStatusAssoc.keySet(); Iterator<String> userNameIt = keySet.iterator(); // Center elements in the combo ((JLabel) combo.getRenderer()) .setHorizontalAlignment(SwingConstants.CENTER); // Clear combo combo.removeAllItems(); while (userNameIt.hasNext()) { String userName = userNameIt.next(); String status = userStatusAssoc.get(userName); combo.addItem(userName + " " + status.toUpperCase()); } Object element = combo.getItemAt(0); combo.getModel().setSelectedItem(element); return combo; }
1c5f2f96-3633-4bce-9b4b-8c5b31616dc4
0
public int getHora() { return hora; }
58ca45ab-9fec-4ddd-b834-edc900046b3e
1
public boolean operate(Boolean boolean1, Boolean boolean2) { boolean b1 = (java.lang.Boolean) boolean1; boolean b2 = (java.lang.Boolean) boolean2; return b1 && b2; }
6f927167-5508-49ed-a3c7-e70b6f877d4e
3
public void startDownloading(ThreadPoolExecutor executorService) { if (this.started) throw new IllegalStateException("Cannot start download job that has already started"); this.started = true; if (this.allFiles.isEmpty()) { //Launcher.getInstance().println("Download job '" + this.name + "' skipped as there are no files to download"); this.listener.onDownloadJobFinished(this); } else { int threads = executorService.getMaximumPoolSize(); this.remainingThreads.set(threads); //Launcher.getInstance().println("Download job '" + this.name + "' started (" + threads + " threads, " + this.allFiles.size() + " files)"); for (int i = 0; i < threads; i++) executorService.submit(new Runnable() { public void run() { DownloadJob.this.popAndDownload(); } }); } }
f0097420-2654-4770-a4bd-4fef9ac0270d
8
@SuppressWarnings("incomplete-switch") /* package */void processInputMessage (BitTorrentMessage msg) { assert msg != null; switch (msg.getMessageType()) { case HANDSHAKE_START: HandShakeStart hss = (HandShakeStart) msg; remoteFlags.or(hss.getFlags()); remoteHash = hss.getHash(); remoteProtocol = hss.getProtocolName(); remoteHandShakeStarted = true; break; case HANDSHAKE_END: HandShakeEnd hse = (HandShakeEnd) msg; remotePeerId = hse.getPeerId(); remoteHandShakeFinished = true; break; case CHOKE: remoteChoking = true; break; case UNCHOKE: remoteChoking = false; break; case INTERESTED: remoteInterested = true; break; case UNINTERESTED: remoteInterested = false; break; case HAVE: remoteClaimedPieces.set(((HaveMessage) msg).getPieceIndex()); break; case BITFIELD: remoteClaimedPieces.or(((BitFieldMessage) msg).getBitField()); break; } }
35b06cf5-d74f-4b67-a190-e4f3f1c37033
8
public Map<String,Object> getMapObject(){ Map<String, Object> desc = new LinkedHashMap<String, Object>(); if ( format_ != null ) desc.put("format",format_); if ( name_ != null ) desc.put("name",name_); if ( subscribe_ != null ) desc.put("subscribe",subscribe_); if ( visibility_ != null ) desc.put("visibility",visibility_); Map<String, Object> retentionObj = new LinkedHashMap<String, Object>(); boolean hasElement = false; if( retention.getCount() != null ) { retentionObj.put("count",retention.getCount()); hasElement = true; } if( retention.getDuration() != null ) { retentionObj.put("duration",retention.getDuration()); hasElement = true; } if (hasElement){ desc.put("retention",retentionObj); } if ( preprocess.size() > 0 ){ desc.put("preprocess",preprocess); } return desc; }
b823d135-a99d-4357-8c94-eb7a3f27f045
7
@Override public void mouseExited(MouseEvent e) { switch (((JButton) (e.getSource())).getText()) { case "Start": break; case "Turn": break; case "Move": break; case "Shoot": break; case "Refresh": break; case "Validate": break; default: if (pw.getGameModel().isStarted()) { ((JButton) (e.getSource())).setText(""); } } }
8ba16673-cdf8-419c-866e-0aaa5c0aa6e3
7
public ClientConnectionProperties(ClientDavParameters clientDavParameters) throws ConnectionException { super( null, null, clientDavParameters.getUserName(), clientDavParameters.getUserPassword(), clientDavParameters.getCommunicationParameters().getSendKeepAliveTimeout(), clientDavParameters.getCommunicationParameters().getReceiveKeepAliveTimeout(), clientDavParameters.getAdjustedOutputBufferSize(), clientDavParameters.getAdjustedInputBufferSize() ); try { String comProtocol = clientDavParameters.getLowLevelCommunicationName(); if(comProtocol == null) { throw new InitialisationNotCompleteException("Unbekannter Kommunikationsprotokollname."); } Class aClass = Class.forName(comProtocol); if(aClass == null) { throw new InitialisationNotCompleteException("Unbekannter Kommunikationsprotokollname."); } ConnectionInterface connection = (ConnectionInterface)aClass.newInstance(); setLowLevelCommunication( new LowLevelCommunication( connection, clientDavParameters.getAdjustedOutputBufferSize(), clientDavParameters.getAdjustedInputBufferSize(), clientDavParameters.getCommunicationParameters().getSendKeepAliveTimeout(), clientDavParameters.getCommunicationParameters().getReceiveKeepAliveTimeout(), LowLevelCommunication.HANDLE_CONFIG_RESPONCES_MODE, false ) ); String authentificationName = clientDavParameters.getAuthentificationProcessName(); if(authentificationName == null) { throw new InitialisationNotCompleteException("Unbekanntes Authentifikationsverfahren."); } aClass = Class.forName(authentificationName); if(aClass == null) { throw new InitialisationNotCompleteException("Unbekanntes Authentifikationsverfahren."); } setAuthentificationProcess((AuthentificationProcess)aClass.newInstance()); _applicationName = clientDavParameters.getApplicationName(); _incarnationName = clientDavParameters.getIncarnationName(); _applicationTypePid = clientDavParameters.getApplicationTypePid(); _configurationPid = clientDavParameters.getConfigurationPid(); _address = clientDavParameters.getDavCommunicationAddress(); _subAddress = clientDavParameters.getDavCommunicationSubAddress(); _communicationParameters = clientDavParameters.getCommunicationParameters(); } catch(ClassNotFoundException ex) { throw new InitialisationNotCompleteException("Fehler beim Erzeugen der logischen Verbindung zum Datenverteiler.", ex); } catch(InstantiationException ex) { throw new InitialisationNotCompleteException("Fehler beim Erzeugen der logischen Verbindung zum Datenverteiler.", ex); } catch(IllegalAccessException ex) { throw new InitialisationNotCompleteException("Fehler beim Erzeugen der logischen Verbindung zum Datenverteiler.", ex); } }
6fe138dc-69bc-4af7-8fdd-c1247deaf91b
6
public static void main(String[] args) { if(args.length < 1) { System.out.println("Erreur : vous devez spécifier un jeu à lancer"); System.exit(1); } if(args[0].equals("diaballik")) { new Diaballik(false); } else if(args[0].equals("diaballik_variante")) { new Diaballik(true); } else if(args[0].equals("diaballik_modif")) { new Diaballik("./jeu/diaballik/initGrid.txt"); } else if (args[0].equals("morpion")) { new Morpion(); } else if (args[0].equals("fjorde")) { new Fjorde(); } else { System.out.println("Jeu inconnu"); } }
6f010dea-7e81-487d-b06c-0d69ddd94646
3
public void login() throws Throwable { char[] pword_onChar = passwordField.getPassword(); String pword = ""; for (char k : pword_onChar) { pword += k; } Users user = new Users(); Integer auth = new Integer(user.login(textField.getText(), pword)); System.out.println(auth); if (textField.getText().equals("") || auth.intValue()==0){ Auth_frame.auth_prompt(null); dispose(); } else { MainFrame m = new MainFrame(auth); m.defaultView(); dispose(); } }
61e86106-c3ce-4149-8ce1-80a277cea989
8
public static ArrayList <RecipeData> loadData() { File load = new File("resources/files/RecipeData/"); Gson loader = new Gson(); ArrayList <RecipeData> res = new ArrayList <RecipeData>(); for (File f : load.listFiles()) { BufferedReader br = null; FileReader fi = null; try { fi = new FileReader(f); br = new BufferedReader(fi); } catch (FileNotFoundException e) { e.printStackTrace(); } RecipeData read = null; try { read = loader.fromJson(br.readLine(), RecipeData.class); res.add(read); } catch (JsonSyntaxException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if(br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } if(fi != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } } return res; }
dcfbee0e-f6ca-4a4a-8fc1-67eba1de7bc0
5
private void updateNodeColours(){ if(armyColours) { for(Node N : network) { if(N.id != clicked) { D.getGraphPanel().setNodeColorNoRepaint(N.id, Color.getHSBColor(colourMap.get(((GossipicoFAB)N.getFAB(0)).beacon.A), 1f, 1f)); } else { D.getGraphPanel().setNodeColorNoRepaint(N.id, Color.MAGENTA); } } D.getGraphPanel().repaint(); } else { float h=0; for(Node N : network) { if(N.id == clicked) { h = 5f/6f; } else { h = 0.33f*(float)((GossipicoFAB)N.getFAB(0)).count.SC/(float)network.size(); } D.getGraphPanel().setNodeColorNoRepaint(N.id, Color.getHSBColor(h, 1, 1)); } } D.getGraphPanel().repaint(); updateNodeInfo(); }
4e908952-543f-4a8e-bbf1-a4e151e63048
3
public void visitCallMethodExpr(final CallMethodExpr expr) { if (expr.receiver == from) { expr.receiver = (Expr) to; ((Expr) to).setParent(expr); } else { for (int i = 0; i < expr.params.length; i++) { if (expr.params[i] == from) { expr.params[i] = (Expr) to; ((Expr) to).setParent(expr); return; } } expr.visitChildren(this); } }
11d40240-3192-4923-9a68-2b11c38d5230
8
private void set(String id, String in) { if (id.equals(MovieShowColumn.HOUSE_ID)) { house_id = in; } else if (id.equals(MovieShowColumn.SHOWING_ID)) { showing_id = in; } else if (id.equals(MovieShowColumn.MOVIE_ID)) { movie_id = in; } else if (id.equals(MovieShowColumn.SHOWING_STARTDATE)) { showing_startDate = in; } else if (id.equals(MovieShowColumn.SHOWING_STARTTIME)) { showing_startTime = in; } else if (id.equals(MovieShowColumn.SHOWING_ENDDATE)) { showing_endDate = in; } else if (id.equals(MovieShowColumn.SHOWING_ENDTIME)) { showing_endTime = in; } else if (id.equals(MovieShowColumn.TICKET_PRICE)) { ticket_price = in; } this.setChangedTrue(); }
8770fc65-3015-490f-907e-5e2fd5a2fcef
9
public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); String line; TreeSet<String> set = new TreeSet<String>(); while ((line = br.readLine()) != null) { StringBuilder sb = new StringBuilder(); char[] c = line.toCharArray(); for (int i = 0; i < line.length(); i++) { if ((c[i] >= 'a' && c[i] <= 'z') || (c[i] >= 'A' && c[i] <= 'Z')) { sb.append(c[i]); } else if (sb.length() > 0) { set.add(sb.toString().toLowerCase()); sb = new StringBuilder(); } } if (sb.length() > 0) { set.add(sb.toString().toLowerCase()); } } for (String s : set) { pw.println(s); } pw.flush(); pw.close(); br.close(); }