text
stringlengths
14
410k
label
int32
0
9
@EventHandler(priority=EventPriority.HIGH) public void onPlayerMove(PlayerMoveEvent e) { Player p = e.getPlayer(); Fruit f = null; if(FruitManager.getInstance().checkIfPlayerIsDFUser(p)) //Drown Devil Fruit users { f = FruitManager.getInstance().getFruitByPlayer(p); switch(f.getId()) { case 29: //Spider Fruit climbWall(p); break; default: } Material m = p.getLocation().add(0, 1, 0).getBlock().getType(); if (m == Material.STATIONARY_WATER || m == Material.WATER) { if(!p.hasPotionEffect(PotionEffectType.BLINDNESS)) p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 5*20, 3)); if(!p.hasPotionEffect(PotionEffectType.SLOW)){ p.sendMessage(ChatColor.RED + "You have lost your ability to swim. This is the curse of the Devil Fruit."); p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5*20, 10)); } if(p.getVelocity().getX() != 0 || p.getVelocity().getZ() != 0 || p.getVelocity().getY() > 0) { e.setCancelled(true); } p.setVelocity(new Vector(0,-0.6f,0)); } } }
9
public static void Inspect(String item) { Random number = new Random(); int i = number.nextInt(3); i = i+1; boolean shownInspection = false; for(int k=0; k<Items.itemDesc.length; k++) { if(item.equalsIgnoreCase(Items.itemDesc[k][0])) { GUI.log(Items.itemDesc[k][i]); shownInspection = true; } } if(!shownInspection) { GUI.log("Can't see a "+item+"."); } }
3
public void execute() throws Exception { Number amount; Currency currency; String input = ""; while (true) { try { input = readAmount(reader); amount = Number.valueOf(input); currencyDialog.execute("Introduzca la divisa origen: "); currency = currencyDialog.getCurrency(); this.money = new Money(amount, currency); break; } catch (NumberFormatException ex) { throw new Exception(input); } catch (IOException ex) { System.out.println("An exception has been catched."); } } }
3
public void play(){ int mode = mode(); if(mode == 1){ setup(_player1, _grid1); setup(_player2, _grid2); } else if(mode == 2){ setup(_player1, _grid1); setup(_comp1, _grid2); } else{ setup(_comp1, _grid1); setup(_comp2, _grid2); } while(!(_grid1.deathCount()==17 || _grid2.deathCount()==17)){ if (mode == 1){ System.out.println("\nPlayer 1's turn, shoot!\n"); humanOptions(_player1, _grid1, _grid2); System.out.println("\nPlayer 2's turn, shoot!\n"); humanOptions(_player2, _grid2, _grid1); } else if (mode == 2){ System.out.println("\nPlayer's turn, shoot!\n"); humanOptions(_player1, _grid1, _grid2); String temp1 = _comp1.shoot(); _comp1.updateGuess(shoot(_grid1, temp1), 0); System.out.println(_grid1.hidden()); } else{ String temp1 = _comp1.shoot(); _comp1.updateGuess(shoot(_grid2, temp1), 0); System.out.println(_grid2.hidden()); String temp2 = _comp2.shoot(); _comp2.updateGuess(shoot(_grid1, temp2), 0); System.out.println(_grid1.hidden()); } } if(_grid1.deathCount() == 17) System.out.println("Player 2 Wins!!!"); else if (_grid2.deathCount() == 17) System.out.println("Player 1 Wins!!!"); else System.out.println("Everybody Wins!!!"); }
8
public String getText() { if (content.size() == 0) { return ""; } // If we hold only a Text or CDATA, return it directly if (content.size() == 1) { final Object obj = content.get(0); if (obj instanceof Text) { return ((Text) obj).getText(); } else { return ""; } } // Else build String up final StringBuffer textContent = new StringBuffer(); boolean hasText = false; for (int i = 0; i < content.size(); i++) { final Object obj = content.get(i); if (obj instanceof Text) { textContent.append(((Text) obj).getText()); hasText = true; } } if (!hasText) { return ""; } else { return textContent.toString(); } }
6
@Override public boolean equals(Object obj){ if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof deltaQ)) return false; deltaQ another = (deltaQ)obj; if (another.i.u_id.equals(this.i.u_id) && another.j.u_id.equals(this.j.u_id) && another.dQ == this.dQ) return true; else return false; }
6
public static boolean isTypeMap(Class<?> type) { return (type != null && isAssignable(type, Map.class)); }
2
public Instruction findMatchingPush() { int count = 0; Instruction instr = this; int poppush[] = new int[2]; while (true) { if (instr.preds != null) return null; instr = instr.prevByAddr; if (instr == null || instr.succs != null || instr.doesAlwaysJump()) return null; instr.getStackPopPush(poppush); if (count < poppush[1]) { return count == 0 ? instr : null; } count += poppush[0] - poppush[1]; } }
7
public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (code > 0 && code < keys.length) { keys[code] = true; isMovingWithKey = true; } }
2
@Override public synchronized void close() { if (isClosed) { return; } isClosed = true; }
1
private void handle(Resource res) { InputStream in = null; try { res.error = null; res.source = src; try { try { in = src.get(res.name); res.load(in); res.loading = false; res.notifyAll(); return; } catch (IOException e) { throw (new LoadException(e, res)); } } catch (LoadException e) { if (next == null) { res.error = e; res.loading = false; res.notifyAll(); } else { next.load(res); } } catch (RuntimeException e) { throw (new LoadException(e, res)); } } finally { try { if (in != null) in.close(); } catch (IOException e) { } } }
6
@Test public void testValorTotalEmEstoque() { try { Assert.assertEquals(25653.1f, facade.getValorTotalEmEstoque(), 0.1); } catch (FacadeException e) { Assert.fail(e.getMessage()); } Produto p5 = new Produto(5,"Smartphone Samsung Galaxy Ace Preto, Desbloqueado Vivo, GSM, Android, C‚mera de 5MP, Tela Touchscreen 3.5\", 3G, Wi-Fi, Bluetooth e Cart„o de MemÛria 2GB",3, 499.00f); try { facade.cadastrarProduto(p5); Assert.assertEquals(27150.1f, facade.getValorTotalEmEstoque(), 0.1); } catch (FacadeException e) { Assert.fail(e.getMessage()); } try { facade.remover(1); Assert.assertEquals(18160.1f, facade.getValorTotalEmEstoque(), 0.1); } catch (FacadeException e) { Assert.fail(e.getMessage()); } try { facade.remover(2); Assert.assertEquals(4665.1f, facade.getValorTotalEmEstoque(), 0.1); } catch (FacadeException e) { Assert.fail(e.getMessage()); } try { facade.remover(3); Assert.assertEquals(1696.0f, facade.getValorTotalEmEstoque(), 0.1); } catch (FacadeException e) { Assert.fail(e.getMessage()); } try { facade.remover(4); Assert.assertEquals(1497f, facade.getValorTotalEmEstoque(), 0.1); } catch (FacadeException e) { Assert.fail(e.getMessage()); } try { facade.remover(5); //Assert.fail("deveria ter lanÁado uma exceÁ„o"); } catch (FacadeException e) { Assert.fail(e.getMessage()); // era para lanÁa exceÁ„o por que o valor da lista È 0 } }
7
public MoveSet getValidMoves(int player) { Move empty_move = new Move(); MoveSet rtn_mset = null; int[] dice; int dice_left; if ((dc1==dc2)&&(use_doubles)) { dice_left = 4; dice = new int[4]; dice[0]=dc1; dice[1]=dc1; dice[2]=dc1; dice[3]=dc1; int s_pos = player==1 ? 0 : NUM_POINTS-1; rtn_mset = getValidMovesDoublesRec(empty_move, player, dice_left, dice, s_pos); // Doubles version does not guarrantee maximum number of dice is used. if (rtn_mset != null) rtn_mset.maxify(); } else { dice_left = 2; dice = new int[2]; // Make two calls to getValidMovesRec, one for each ordering of the dice. // Remove duplicate moves later. dice[0]=dc1; dice[1]=dc2; rtn_mset = getValidMovesRec(empty_move, player, dice_left, dice); dice[0]=dc2; dice[1]=dc1; rtn_mset.addSet(getValidMovesRec(empty_move, player, dice_left, dice)); if (rtn_mset != null) { // Must use as many dice as possible. rtn_mset.maxify(); // If you can only move one die, the larger must be used. rtn_mset.bigify(dc1,dc2); } } // Remove duplicate moves from MoveSet. if (rtn_mset != null) { rtn_mset.uniquify(); // Moves must be in descending order for player 0, ascending order for player 1. for (Iterator iter = rtn_mset.getIterator(); iter.hasNext(); ) { if (player==0) ((Move) iter.next()).sortDescend(); else ((Move) iter.next()).sortAscend(); } } return rtn_mset; }
8
@Override public String toString() { return "ModelClassDesc [packgeName=" + packgeName + ", className=" + className + ", fileds=" + fileds + "]"; }
0
public InputEvent removeEvent() { return unprocessedEvents.remove(); }
0
private void sink(int k){ while(2*k <= N){ int j = 2*k; if(j < N && less(j, j+1)) ++j; if(!less(k,j)) break; exch(k, j); k = j; } }
4
private int getNrBlacks(int x, int y) { int number = 0; for (int i=(x>0?x-1:0); i<=x+1 && i<width; i++) { for (int j=(y>0?y-1:0); j<=y+1 && j<height; j++) { if (black[i][j] != null) number += black[i][j] ? 1 : 0; } } return number; }
8
public JSONObject toJSONObject(JSONArray names) throws JSONException { if (names == null || names.length() == 0 || this.length() == 0) { return null; } JSONObject jo = new JSONObject(); for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this.opt(i)); } return jo; }
4
public Model createNarfModelFromPDB(String aPdbId, NucleicAcid aNucleicAcid, List<Cycle<Nucleotide, InteractionEdge>> acycleList, boolean basepaironly) throws IOException { aPdbId = aPdbId.toUpperCase(); Random r_i = new Random(); int rand_i = r_i.nextInt()+1; Model rm = ModelFactory.createDefaultModel(); //add mcb computation resource Resource mcb_computation = rm.createResource( Vocab.narf_resource + CycleSerializer.MD5("mcb_computation"+rand_i)); //type it mcb_computation.addProperty(Vocab.rdftype, Vocab.narf_mcb_computation); rm.add(Vocab.narf_mcb_computation, Vocab.rdftype, Vocab.rdfs_class); mcb_computation.addProperty(Vocab.rdftype, Vocab.named_individual); //add a software resource Resource sw_res = rm.createResource(Vocab.narf_resource+CycleSerializer.MD5("software"+rand_i)); sw_res.addProperty(Vocab.rdftype, Vocab.narf_software); rm.add(Vocab.narf_software, Vocab.rdftype, Vocab.rdfs_class); sw_res.addProperty(Vocab.rdftype, Vocab.named_individual); //add a mcb resource Resource mcb_res = rm.createResource(Vocab.narf_resource+CycleSerializer.MD5("mcb"+rand_i)); mcb_res.addProperty(Vocab.rdftype, Vocab.narf_mcb); rm.add(Vocab.narf_mcb, Vocab.rdftype, Vocab.rdfs_class); mcb_res.addProperty(Vocab.rdftype, Vocab.named_individual); mcb_res.addLiteral(Vocab.rdfslabel, "Minimum Cycle Basis"); //connect them back to the mcb_computation mcb_computation.addProperty(Vocab.has_attribute, sw_res); mcb_computation.addProperty(Vocab.has_attribute, mcb_res); //create a resource for the pdb_structure Resource pdb_struct_resource = rm.createResource("http://bio2rdf.org/pdb:"+aPdbId.toUpperCase()); mcb_res.addProperty(Vocab.derived_from, pdb_struct_resource); for (Cycle<Nucleotide, InteractionEdge> acyc : acycleList) { Random rp = new Random(); int randp = rp.nextInt() + 1; // create a cycle resource Resource cycleRes = rm.createResource(Vocab.narf_resource + CycleSerializer.MD5(acyc.toString()+aPdbId)); // type it as a cycle cycleRes.addProperty(Vocab.rdftype, Vocab.narf_cycle); rm.add(Vocab.narf_cycle, Vocab.rdftype, Vocab.rdfs_class); cycleRes.addProperty(Vocab.rdftype, Vocab.named_individual); mcb_res.addProperty(Vocab.has_member, cycleRes); // add a label String lbl = "Cycle found in PDBID: " + aPdbId + " of size: " + acyc.size(); cycleRes.addLiteral(Vocab.rdfslabel, lbl); //add 1st degree neighbour cycle set //all the cycles that share one or more vertices with acyc List<Cycle<Nucleotide, InteractionEdge>> firstDegNeigh = aNucleicAcid.findMCBNeighbours(acyc); if(firstDegNeigh.size()>0){ String r = "r"+randp; Resource firstDegCNS = rm.createResource(Vocab.narf_resource+CycleSerializer.MD5(r)); String lb = "First degree cycle neighbourset"; //add a label firstDegCNS.addLiteral(Vocab.rdfslabel, lb); //type it as a 1st degree neighbour cycle set firstDegCNS.addProperty(Vocab.rdftype, Vocab.narf_firstDegreeCycleNeighbourSet); rm.add(Vocab.narf_firstDegreeCycleNeighbourSet, Vocab.rdftype, Vocab.rdfs_class); firstDegCNS.addProperty(Vocab.rdftype, Vocab.named_individual); cycleRes.addProperty(Vocab.has_attribute, firstDegCNS); //now iterate over the neighbours for (Cycle<Nucleotide, InteractionEdge> an : firstDegNeigh) { //create a resource for each Resource an_res = rm.createResource(Vocab.narf_resource+CycleSerializer.MD5(an.toString()+aPdbId)); //attach them to firstDegCNS using hasmember firstDegCNS.addProperty(Vocab.has_member, an_res); } } // add the size attribute Resource sizeRes = rm.createResource(Vocab.narf_resource + CycleSerializer.MD5("size" + randp)); // type it as a size sizeRes.addProperty(Vocab.rdftype, Vocab.narf_cycle_size); rm.add(Vocab.narf_cycle_size, Vocab.rdftype, Vocab.rdfs_class); sizeRes.addProperty(Vocab.rdftype, Vocab.named_individual); //add a label String l = "Cycle size"; sizeRes.addLiteral(Vocab.rdfslabel, l); // add the value sizeRes.addLiteral(Vocab.has_value, (int) acyc.size()); // connect the sizeRes to the cycleRes cycleRes.addProperty(Vocab.has_attribute, sizeRes); //create a gccontent res System.out.println(CycleHelper.computeCycleGCContent(acyc)); Resource gcCont = rm.createResource(Vocab.narf_resource+CycleSerializer.MD5("gcContent"+randp+acyc.hashCode())); gcCont.addProperty(Vocab.rdftype, Vocab.narf_gc_content); rm.add(Vocab.narf_gc_content, Vocab.rdftype, Vocab.rdfs_class); //add a label String l2 = "Cycle gc content"; gcCont.addLiteral(Vocab.rdfslabel, l2); gcCont.addProperty(Vocab.rdftype, Vocab.named_individual); double gc_cont = CycleHelper.computeCycleGCContent(acyc); gcCont.addLiteral(Vocab.has_value,gc_cont); cycleRes.addProperty(Vocab.has_attribute, gcCont); if(basepaironly){ Resource lvl_1 = rm.createResource(Vocab.narf_resource+CycleSerializer.MD5("lvl_1"+randp)); lvl_1.addProperty(Vocab.rdftype, Vocab.narf_cycle_profile_level_1); rm.add(Vocab.narf_cycle_profile_level_1, Vocab.rdftype, Vocab.rdfs_class); lvl_1.addProperty(Vocab.rdftype, Vocab.named_individual); //add a label String l3 = "Cycle profile level 1 "; lvl_1.addLiteral(Vocab.rdfslabel, l3); //get the level 1 normalized version of this string String lvl_1_str = CycleHelper.findMinmalNormalization(aNucleicAcid, acyc, true).toString(); lvl_1.addLiteral(Vocab.has_value,"#"+lvl_1_str); lvl_1.addLiteral(Vocab.hasMD5,CycleSerializer.MD5(lvl_1_str)); cycleRes.addProperty(Vocab.has_attribute, lvl_1); }else{ Resource lvl_1 = rm.createResource(Vocab.narf_resource+CycleSerializer.MD5("lvl_1"+randp)); lvl_1.addProperty(Vocab.rdftype, Vocab.narf_cycle_profile_level_1); rm.add(Vocab.narf_cycle_profile_level_1, Vocab.rdftype, Vocab.rdfs_class); lvl_1.addProperty(Vocab.rdftype, Vocab.named_individual); //add a label String l34 = "Cycle profile level 1 "; lvl_1.addLiteral(Vocab.rdfslabel, l34); //get the level 1 normalized version of this string String lvl_1_str = CycleHelper.findMinmalNormalization(aNucleicAcid, acyc, true).toString(); lvl_1.addLiteral(Vocab.has_value,"#"+lvl_1_str); lvl_1.addLiteral(Vocab.hasMD5,CycleSerializer.MD5(lvl_1_str)); cycleRes.addProperty(Vocab.has_attribute, lvl_1); Resource lvl_2 = rm.createResource(Vocab.narf_resource + CycleSerializer.MD5("norm_string_lvl_2" + randp)); lvl_2.addProperty(Vocab.rdftype, Vocab.narf_cycle_profile_level_2); rm.add(Vocab.narf_cycle_profile_level_2, Vocab.rdftype, Vocab.rdfs_class); lvl_2.addProperty(Vocab.rdftype, Vocab.named_individual); String l35 = "Cycle profile level 2 "; lvl_2.addLiteral(Vocab.rdfslabel, l35); String n_str_lvl_2 = CycleHelper.findMinmalNormalization(aNucleicAcid, acyc, false).toString(); lvl_2.addLiteral(Vocab.has_value, "#" + n_str_lvl_2); lvl_2.addLiteral(Vocab.hasMD5, CycleSerializer.MD5(n_str_lvl_2)); cycleRes.addProperty(Vocab.has_attribute, lvl_2); } // get the interaction edges List<InteractionEdge> edges = acyc.getEdgeList(); for (InteractionEdge anEdge : edges) { Set<NucleotideInteraction> interactions = anEdge .getInteractions(); Random ra = new Random(); int rand = ra.nextInt() + 1; for (NucleotideInteraction ni : interactions) { if (ni instanceof BasePair) { // get the first nucleotide Nucleotide fN = ((BasePair) ni).getFirstNucleotide(); Nucleotide sN = ((BasePair) ni).getSecondNucleotide(); // create a bio2rdf resource for each nucleotide Resource firstNucRes = rm .createResource(Vocab.pdb_resource + aPdbId + "/chemicalComponent_" + fN.getChainId() + fN.getResiduePosition()); Resource secondNucRes = rm .createResource(Vocab.pdb_resource + aPdbId + "/chemicalComponent_" + sN.getChainId() + sN.getResiduePosition()); // type them firstNucRes.addProperty(Vocab.rdftype, Vocab.pdb_residue); rm.add(Vocab.pdb_residue, Vocab.rdftype, Vocab.rdfs_class); firstNucRes.addProperty(Vocab.rdftype, Vocab.named_individual); secondNucRes.addProperty(Vocab.rdftype, Vocab.pdb_residue); secondNucRes.addProperty(Vocab.rdftype, Vocab.named_individual); // add these nucleotide resources as members of the // cycle cycleRes.addProperty(Vocab.has_part, firstNucRes); cycleRes.addProperty(Vocab.has_part, secondNucRes); // create a base pair resource Resource bpRes = rm.createResource(Vocab.narf_resource + CycleSerializer.MD5(fN.toString() + sN.toString())); // create a resource from the rnaoclass String rnaoClassStr = ((BasePair) ni).inferRnaOClass(); Resource rnaoClass = rm.createResource(rnaoClassStr); if (rnaoClass != null) { // type it using the rnaoClass resource bpRes.addProperty(Vocab.rdftype, rnaoClass); rm.add(rnaoClass, Vocab.rdftype, Vocab.rdfs_class); bpRes.addProperty(Vocab.rdftype, Vocab.named_individual); }else{ bpRes.addProperty(Vocab.rdftype, rm.createResource("http://purl.obolibrary.org/obo/RNAO_0000001")); bpRes.addProperty(Vocab.rdftype, Vocab.named_individual); rm.add(rm.createResource("http://purl.obolibrary.org/obo/RNAO_0000001"),Vocab.rdftype, Vocab.rdfs_class); } // base pair has part residues bpRes.addProperty(Vocab.has_part, firstNucRes); bpRes.addProperty(Vocab.has_part, secondNucRes); // add the paried with property between the residues firstNucRes .addProperty(Vocab.paired_with, secondNucRes); // add the base pair label bpRes.addLiteral(Vocab.rdfslabel, ((BasePair) ni).toString()); cycleRes.addProperty(Vocab.has_attribute, bpRes); } else if (ni instanceof PhosphodiesterBond) { // get the first nucleotide Nucleotide fN = ((PhosphodiesterBond) ni) .getFirstNucleotide(); Nucleotide sN = ((PhosphodiesterBond) ni) .getSecondNucleotide(); // create a bio2rdf resource for each nucleotide Resource firstNucRes = rm .createResource(Vocab.pdb_resource + aPdbId + "/chemicalComponent_" + fN.getChainId() + fN.getResiduePosition()); Resource secondNucRes = rm .createResource(Vocab.pdb_resource + aPdbId + "/chemicalComponent_" + sN.getChainId() + sN.getResiduePosition()); // type them firstNucRes.addProperty(Vocab.rdftype, Vocab.pdb_residue); firstNucRes.addProperty(Vocab.rdftype, Vocab.named_individual); secondNucRes.addProperty(Vocab.rdftype, Vocab.pdb_residue); secondNucRes.addProperty(Vocab.rdftype, Vocab.named_individual); // add these nucleotide resources as members of the // cycle cycleRes.addProperty(Vocab.has_part, firstNucRes); cycleRes.addProperty(Vocab.has_part, secondNucRes); // create a phosphodiesterbond resource Resource phdbRes = rm.createResource(Vocab.narf_resource + CycleSerializer.MD5("phdb" + rand)); // type it as a narf phdb phdbRes.addProperty(Vocab.rdftype, Vocab.narf_phosphodiester_bond); rm.add(rm.createResource(Vocab.narf_phosphodiester_bond), Vocab.rdftype, Vocab.rdfs_class); phdbRes.addProperty(Vocab.rdftype, Vocab.named_individual); // phosphodiester bond has part residuies phdbRes.addProperty(Vocab.has_part, firstNucRes); phdbRes.addProperty(Vocab.has_part, secondNucRes); // add the covalently connected to property between the // residues firstNucRes.addProperty(Vocab.covalenty_connected_to, secondNucRes); // add the phosphodiester bond label phdbRes.addLiteral(Vocab.rdfslabel, ((PhosphodiesterBond) ni).toString()); cycleRes.addProperty(Vocab.has_attribute, phdbRes); } } } } return rm; }
9
@Override public void render(GameContainer gc, Graphics g) { //our current y offset from the top int ypos = 0; Color reset = g.getColor(); for (Message m : messages) { switch(m.getType()) { case IMPORTANT: g.setColor(new HexColor(getImportantColor())); break; case ERROR: g.setColor(new HexColor(getErrorColor())); break; case SUCCESS: g.setColor(new HexColor(getSuccessColor())); break; case WARNING: g.setColor(new HexColor(getWarningColor())); break; } g.fill(new Rectangle(pos.getX(),pos.getY()+ypos,gc.getWidth()+2,height)); if (getFont()!=null) g.setFont(getFont()); g.setColor(new HexColor(getFontColor())); g.drawString(m.getMsg(), pos.getX(),pos.getY()+ypos+2); g.setColor(new Color(0,0,0,m.alphaValue)); g.fill(new Rectangle(pos.getX(),pos.getY()+ypos,gc.getWidth()+2,height)); if (m.alphaValue>255) messages.remove(m); ypos+=(height-1); } g.setColor(reset); }
7
private static ActionListener makeDBLoadButtonListener( final String buttonTitle, final JRadioButton yes) { return new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (yes.isSelected()) startLoadingDataBase(); else return; yes.setSelected(false); yes.setEnabled(false); addReportsTab(); } }; }
1
private String createColumnsSqLite(List<Columns> listColumns) { String columnString = ""; int index = 0; for (Columns columns : listColumns) { columnString += "'" + columns.getColomnName() + "'"; columnString += " " + columns.getTypeData().getTypeInString(); columnString += (!columns.isAutoIncremented()?" (" + (columns.getValue() != -1 ? columns.getValue() : columns.getDisplaySize() + "," + columns.getDecimalNumber()) + ")":"") + (columns.isPrimaryKey()?" PRIMARY KEY":"") + (columns.isAutoIncremented()?" AUTOINCREMENT":"") + (columns.isNull() ? " DEFAULT NULL" : " NOT NULL"); columnString += (index < listColumns.size() - 1 ? ", ":""); index++; } return columnString; }
7
private int countResults(ResultSet result) { if (result == null) { return -1; } int noof = 0; try { while (result.next()) { noof++; } } catch (Exception ex) {} return noof; }
3
public PowerUp(Animation anim) { super(anim); }
0
public static String composeDateWhere(String sql, String fieldName, String fieldValue, int action) { if (fieldValue == null || fieldValue.trim().compareTo("") == 0) return sql; String sTmp = fieldValue; String sOper = "="; switch (action) { case EQUAL: sTmp = "'" + sTmp + "'"; break; case LIKE: sTmp = "'%" + sTmp + "%'"; sOper = " like "; break; case GE: sTmp = "'" + sTmp + "'"; sOper = " >= "; break; case LE: sTmp = "'" + sTmp + "'"; sOper = " <= "; break; case IN: sTmp = "('" + sTmp + "')"; sOper = " in "; break; default: sTmp = "'" + sTmp + "'"; } if (sql == null || sql.trim().compareTo("") == 0) return " WHERE " + fieldName + sOper + sTmp; else return sql + " AND " + fieldName + sOper + sTmp; }
9
private ByteBuffer convertImageData(BufferedImage bufferedImage) { ByteBuffer imageBuffer; WritableRaster raster; BufferedImage texImage; int texWidth = bufferedImage.getWidth(); int texHeight = bufferedImage.getHeight(); // create a raster that can be used by OpenGL as a source // for a texture if (bufferedImage.getColorModel().hasAlpha()) { raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 4, null); texImage = new BufferedImage(glAlphaColorModel, raster, false, new Hashtable<Object, Object>()); } else { raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 3, null); texImage = new BufferedImage(glColorModel, raster, false, new Hashtable<Object, Object>()); } // copy the source image into the produced image Graphics g = texImage.getGraphics(); g.setColor(new Color(0f, 0f, 0f, 0f)); g.fillRect(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight()); g.drawImage(bufferedImage, 0, 0, null); // build a byte buffer from the temporary image // that be used by OpenGL to produce a texture. byte[] data = ((DataBufferByte) texImage.getRaster().getDataBuffer()).getData(); imageBuffer = ByteBuffer.allocateDirect(data.length); imageBuffer.order(ByteOrder.nativeOrder()); imageBuffer.put(data, 0, data.length); imageBuffer.flip(); return imageBuffer; }
1
private Map<String, Double> extractAdditionalFeatures(Map<String, Double> additionalFeatures, Document d, Query q, Map<String, Double> idfs) { Map<String, Double> newAdditionalFeatures = new HashMap<String, Double>(); if (additionalFeatures.containsKey("bm25")) { try { newAdditionalFeatures.put("bm25", bm25scorer.getBM25Score(d, q, idfs)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (additionalFeatures.containsKey("smallestwindow")) { try { newAdditionalFeatures.put("smallestwindow", smScorer.getSmallestWindow(d, q, idfs)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (additionalFeatures.containsKey("pagerank")) { newAdditionalFeatures.put("pagerank", (double) d.page_rank); } if (additionalFeatures.containsKey("percentage_of_query_terms_in_body")) { newAdditionalFeatures.put("percentage_of_query_terms_in_body", scorer.getPercentageOfQueryTermsInField(d, q).get("body")); } if (additionalFeatures.containsKey("percentage_of_query_terms_in_anchors")) { newAdditionalFeatures.put("percentage_of_query_terms_in_anchors", scorer.getPercentageOfQueryTermsInField(d, q).get("body")); } if (additionalFeatures.containsKey("num_of_unique_anchors")) { newAdditionalFeatures.put("num_of_unique_anchors", (double) scorer.getNumOfUniqueAnchors(d, q)); } if (additionalFeatures.containsKey("title_length")) { newAdditionalFeatures.put("title_length", (double) scorer.getTitleLength(d)); } return newAdditionalFeatures; }
9
private boolean jj_3R_83() { if (jj_scan_token(INTEGER)) return true; return false; }
1
public Object getValueAt(int rowIndex, int columnIndex) { Schedule schedule = scheduleList.get(rowIndex); switch (columnIndex) { case 0: return schedule.getName(); case 1: return schedule.getWeekDay(); case -1: return schedule; } return ""; }
3
public static <T> boolean isNominal(Class<T> classdef) { Class<?> classdef2 = getWrapper(classdef); return (classdef2 != null && (classdef2.isEnum() || classdef2 == Character.class || classdef2 == Boolean.class || classdef2 == Byte.class)); }
5
static boolean isThereAThree(Hand hand) { for(int x = 1;x < hand.size(); x++){ if(hand.get(x).getValue() < hand.get(x-1).getValue()) { Card card1 = hand.get(x); Card card2 = hand.get(x-1); hand.setElementAt(card2, x); hand.setElementAt(card1, x-1); }} for (int x =0; x < hand.size();x++){ int count = 0; for(int y=0;y < hand.size();y++) { if (hand.get(x).getValue() == hand.get(y).getValue()) count++; if (count == 3) return true; // three of a kind }} return false; }
6
private Set beginTry() { final Set beginTry = new HashSet(); final Iterator blocks = cfg.catchBlocks().iterator(); while (blocks.hasNext()) { final Block block = (Block) blocks.next(); final Handler handler = (Handler) cfg.handlersMap().get(block); if (handler != null) { final HashSet p = new HashSet(); final Iterator prots = handler.protectedBlocks().iterator(); while (prots.hasNext()) { final Block prot = (Block) prots.next(); p.addAll(cfg.preds(prot)); } p.removeAll(handler.protectedBlocks()); // Add the protected region blocks which have preds outside the // region to the beginTry set. final Iterator preds = p.iterator(); while (preds.hasNext()) { final Block pred = (Block) preds.next(); beginTry.addAll(cfg.succs(pred)); } } } return beginTry; }
4
@Override public Recipe getRecipeById(int recipeId) { try (Connection connection = DriverManager.getConnection(connectionString)) { Recipe recipe = new Recipe(); /* TODO: check the impact of fetching everything in one query */ PreparedStatement statement = connection.prepareStatement("select id, name, numPersons, cookingTime, restingTime, prepTime, steps from recipe where id = ?"); statement.setInt(1, recipeId); ResultSet rs = statement.executeQuery(); if(!rs.next()){ return null; } recipe.setRecipeId(rs.getInt("id")); recipe.setName(rs.getString("name")); recipe.setNumPersons(rs.getInt("numPersons")); recipe.setCookingTime(rs.getInt("cookingTime")); recipe.setPrepTime(rs.getInt("prepTime")); recipe.setRestTime(rs.getInt("restingTime")); recipe.setSteps(rs.getString("steps")); statement = connection.prepareStatement("select idIngredient, unit, numberOfUnits, fuzzy from recipeIngredients where idRecipe = ?"); statement.setInt(1, recipeId); rs = statement.executeQuery(); while(rs.next()){ Quantity q = new Quantity(); q.setFuzzy(rs.getBoolean("fuzzy")); q.setNumberOfUnits(rs.getBigDecimal("numberOfUnits")); q.setUnit(rs.getString("unit")); Ingredient i = ingredientRepository.getIngredient(rs.getInt("idIngredient")); recipe.addIngredient(i, q); } connection.close(); return recipe; } catch(SQLException ex){ ex.printStackTrace(); return null; } }
3
@Override public void mouseTouched(Actor actor, GGMouse mouse, Point spot) { if (enabled && isRunning()) { boolean last = hover; boolean lastP = pressed; switch (mouse.getEvent()) { case GGMouse.enter: hover = true; break; case GGMouse.leave: hover = false; break; case GGMouse.lPress: pressed = true; break; case GGMouse.lClick: clicked = true; break; case GGMouse.lRelease: // || dragEnded any where?? pressed = false; break; } if (last != hover || lastP != pressed) { // state changed createImage(); } } }
9
public static Supervisor getSupervisor(){ return instance; }
0
private int get(final int local) { if (outputLocals == null || local >= outputLocals.length) { // this local has never been assigned in this basic block, // so it is still equal to its value in the input frame return LOCAL | local; } else { int type = outputLocals[local]; if (type == 0) { // this local has never been assigned in this basic block, // so it is still equal to its value in the input frame type = outputLocals[local] = LOCAL | local; } return type; } }
3
private boolean jj_3R_50() { if (jj_3R_86()) return true; return false; }
1
@Override public void run() { while (m_blnRunning) { if (m_plugin.economyInstance.isEnabled()) { Player[] vPlayers = m_plugin.getServer().getOnlinePlayers(); if (vPlayers.length > 0) { m_plugin.log(Level.INFO, "Giving %s %s to %s player(s)", m_dblDepositAmount, m_plugin.economyInstance.currencyNamePlural(), vPlayers.length); for (int i = 0; i < vPlayers.length; i++) { Player player = vPlayers[i]; if (m_plugin.economyInstance.hasAccount(player)) { m_plugin.economyInstance.bankDeposit(player.getName(), m_dblDepositAmount); } else { } } } else { } try { Thread.sleep(m_nSleepInterval * 60 * 1000); } catch (InterruptedException e) { m_plugin.log(Level.SEVERE, "Exception occurred while trying to let thread sleep: %s\r\n%s", e.getMessage()); setRunning(false); } } else { } } }
6
public boolean update(int mx,int my){ if(mbi==null) return false; boolean go = (mx>x && mx<x+sx && my>y && my<y+sy && parent.isVisible() && visible); if(go){ if(data!=null) mbi.clicked(name+data,parent); if(data==null) mbi.clicked(name,parent); } return (go); }
9
public ArrayList<String> getWords() { // Create a list to return ArrayList<String> list = new ArrayList<String>(); //If this node represents a word, add it if (isWord) { list.add(getPathWord()); } // If any children if (!isLeaf) { // Add any words belonging to any children for (int i = 0; i < children.length; i++) { if (children[i] != null) { list.addAll(children[i].getWords()); } } } return list; }
4
public void clear() { exceptions.clear(); }
0
public void addInterface(String name) { cachedInterfaces = null; int info = constPool.addClassInfo(name); if (interfaces == null) { interfaces = new int[1]; interfaces[0] = info; } else { int n = interfaces.length; int[] newarray = new int[n + 1]; System.arraycopy(interfaces, 0, newarray, 0, n); newarray[n] = info; interfaces = newarray; } }
1
public void mouseClicked(int par1, int par2, int par3) { boolean var4 = par1 >= this.xPos && par1 < this.xPos + this.width && par2 >= this.yPos && par2 < this.yPos + this.height; if (this.canLoseFocus) { this.setFocused(this.isEnabled && var4); } if (this.isFocused && par3 == 0) { int var5 = par1 - this.xPos; if (this.enableBackgroundDrawing) { var5 -= 4; } String var6 = this.fontRenderer.trimStringToWidth(this.text.substring(this.field_50041_n), this.func_50019_l()); this.func_50030_e(this.fontRenderer.trimStringToWidth(var6, var5).length() + this.field_50041_n); } }
8
private void apply( DefaultConnectionLabelConfiguration config ) { DefaultConnectionLabelConfiguration.RESET.applyTo( this ); if( config != null ) { config.applyTo( this ); } }
1
protected void performGradientDescent(Pattern<?,?> pattern) throws NNException { try { network.process(pattern.getInputSignal()); // Calculate derivatives for the final layer: for (int i = 0; i < network.numberOfOutputs(); i++) { Neuron neuron = network.outputLayer.get(i); Double correctValue = pattern.getOutputSignal().get(i); derivatives.put(neuron, (neuron.lastResult - correctValue)*2); } // Iterate through layers backwards and compute layer's derivatives // and weights from the next layer's ones. LayerIterator iter = new LayerIterator(network); // Must start from the next to last layer: List<? extends Neuron> curLayer = iter.previous(); while (iter.hasPrevious()) { curLayer = iter.previous(); // The gist of calculation: for (Neuron curNeuron : curLayer) { double derivative = 0; for (Neuron nextNeuron : curNeuron.outputs) { double weight = nextNeuron.getInputWeight(curNeuron); double nextObjDeriv = derivatives.get(nextNeuron); double nextActivFeriv = nextNeuron.getActivationFunction().derivative(nextNeuron.accumulatedInput); derivative += weight * nextObjDeriv * nextActivFeriv; //System.out.println("Gradient is " + nextObjDeriv * nextActivFeriv * curNeuron.lastResult); weight -= gradientStep * nextObjDeriv * nextActivFeriv * curNeuron.lastResult; nextNeuron.setInputWeight(curNeuron, weight); } derivatives.put(curNeuron, Double.valueOf(derivative)); } } } catch (NNException e) { throw e; } catch (Exception e) { throw new NNException(e); } }
9
public void testGetFieldType_int() { LocalDate test = new LocalDate(COPTIC_PARIS); assertSame(DateTimeFieldType.year(), test.getFieldType(0)); assertSame(DateTimeFieldType.monthOfYear(), test.getFieldType(1)); assertSame(DateTimeFieldType.dayOfMonth(), test.getFieldType(2)); try { test.getFieldType(-1); } catch (IndexOutOfBoundsException ex) {} try { test.getFieldType(3); } catch (IndexOutOfBoundsException ex) {} }
2
private void createFeedbackTypes(Group parent) { parent.setLayout(new RowLayout(SWT.VERTICAL)); Button b = new Button(parent, SWT.CHECK); b.setText("FEEDBACK_SELECT"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button)e.widget; if (b.getSelection()) { dropFeedback |= DND.FEEDBACK_SELECT; } else { dropFeedback &= ~DND.FEEDBACK_SELECT; } } }); b = new Button(parent, SWT.CHECK); b.setText("FEEDBACK_SCROLL"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button)e.widget; if (b.getSelection()) { dropFeedback |= DND.FEEDBACK_SCROLL; } else { dropFeedback &= ~DND.FEEDBACK_SCROLL; } } }); b = new Button(parent, SWT.CHECK); b.setText("FEEDBACK_INSERT_BEFORE"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button)e.widget; if (b.getSelection()) { dropFeedback |= DND.FEEDBACK_INSERT_BEFORE; } else { dropFeedback &= ~DND.FEEDBACK_INSERT_BEFORE; } } }); b = new Button(parent, SWT.CHECK); b.setText("FEEDBACK_INSERT_AFTER"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button)e.widget; if (b.getSelection()) { dropFeedback |= DND.FEEDBACK_INSERT_AFTER; } else { dropFeedback &= ~DND.FEEDBACK_INSERT_AFTER; } } }); b = new Button(parent, SWT.CHECK); b.setText("FEEDBACK_EXPAND"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = (Button)e.widget; if (b.getSelection()) { dropFeedback |= DND.FEEDBACK_EXPAND; } else { dropFeedback &= ~DND.FEEDBACK_EXPAND; } } }); }
5
public void backToMenu() { int reply = JOptionPane.showConfirmDialog(null, "Would you like to return to the Main Menu?"); if(reply == JOptionPane.YES_OPTION) { timer.stop(); reply = JOptionPane.showConfirmDialog(null, "Would you like to save your progress before quiting?"); if(reply == JOptionPane.YES_OPTION) { saveGame(); JOptionPane.showMessageDialog(null, "Puzzle Saved", "Success", JOptionPane.INFORMATION_MESSAGE); MainMenu menu = new MainMenu(1000, 800, user); menu.setSize(1000, 800); menu.setVisible(true); menu.setTitle("CSE360 Sudoku Main Menu"); dispose(); } else { reply = JOptionPane.showConfirmDialog(null, "Would you like to see the solution?"); if(reply == JOptionPane.YES_OPTION) { MainMenu menu = new MainMenu(1000, 800, user); menu.setSize(1000, 800); menu.setVisible(true); menu.setTitle("CSE360 Sudoku Main Menu"); ShowSolution solution; switch(difficulty) { case "Easy": solution = new ShowSolution("easy9x9Solution.txt","9x9"); solution.setTitle("Easy 9x9 Solution"); break; case "Medium": solution = new ShowSolution("medium9x9Solution.txt", "9x9"); solution.setTitle("Medium 9x9 Solution"); break; case "Hard": solution = new ShowSolution("hard9x9Solution.txt", "9x9"); solution.setTitle("Hard 9x9 Solution"); break; default: solution = new ShowSolution("evil9x9Solution.txt", "9x9"); solution.setTitle("Evil 9x9 Solution"); break; } solution.setSize(500, 500); solution.setVisible(true); solution.setResizable(false); dispose(); } else { MainMenu menu = new MainMenu(1000, 800, user); menu.setSize(1000, 800); menu.setVisible(true); menu.setTitle("CSE360 Sudoku Main Menu"); dispose(); } } } }
6
public void loadConfig(final boolean initialLoad) throws Exception { // create directories FileStructure.createDir(pluginDir); // get config.yml path File file = new File(pluginDir, "config.yml"); if (!file.exists()) { FileStructure.extractResource("/config.yml", pluginDir, false, false); log.info("config.yml is not found! Created default config.yml!"); } plugin.reloadConfig(); conf = plugin.getConfig(); checkver(conf.getInt("ConfigVersion", 1)); // check vault useVault = conf.getBoolean("UseVault", false); if (!initialLoad && useVault && (plugin.getVault() == null || plugin.getEconomy() == null)) { plugin.setupVault(); } }
5
protected int getCorrectDirToOriginRoom(Room R, int v) { if(v<0) return -1; int dir=-1; Room R2=null; Exit E2=null; int lowest=v; for(int d=Directions.NUM_DIRECTIONS()-1;d>=0;d--) { R2=R.getRoomInDir(d); E2=R.getExitInDir(d); if((R2!=null)&&(E2!=null)&&(E2.isOpen())) { final int dx=commonRoomSet.indexOf(R2); if((dx>=0)&&(dx<lowest)) { lowest=dx; dir=d; } } } return dir; }
7
public void create(){ init = true; //hitbox if(this.shape.equals("circle")){ CircleShape shape = new CircleShape(); shape.setRadius((rw)/PPM); fdef.shape = shape; }else{ PolygonShape shape = new PolygonShape(); shape.setAsBox((rw)/PPM, (rh)/PPM); fdef.shape = shape; } bdef.position.set(x/PPM, y/PPM); bdef.type = bodyType; bdef.bullet = true; bdef.gravityScale = gScale; body = world.createBody(bdef); body.setUserData(this); fdef.isSensor = isSensor; fdef.restitution = restitution; fdef.filter.maskBits = (short) Vars.BIT_GROUND | Vars.BIT_LAYER1 | Vars.BIT_PLAYER_LAYER | Vars.BIT_LAYER3; fdef.filter.categoryBits = layer; body.createFixture(fdef).setUserData("projectile"); body.setLinearVelocity(velocity); String sound; Color c; switch(damageType){ case ELECTRO: sound = "chirp2"; c = new Color(Vars.SUNSET_GOLD); c.a =.5f; light = new PointLight(main.getRayHandler(), Vars.LIGHT_RAYS, c, 100, x, y); break; case DARKMAGIC: sound = "spooky"; c = new Color(Color.GREEN); c.a =.5f; light = new PointLight(main.getRayHandler(), Vars.LIGHT_RAYS, c, 75, x, y); break; case FIRE: sound = "swish1"; c = new Color(Vars.SUNSET_ORANGE); c.a =.5f; light = new PointLight(main.getRayHandler(), Vars.LIGHT_RAYS, c, 75, x, y); break; case ICE: sound = "sweep"; c = new Color(Color.CYAN); c.a =.5f; light = new PointLight(main.getRayHandler(), Vars.LIGHT_RAYS, c, 25, x, y); break; case ROCK: sound = "rockShot"; break; default: sound = "jump3"; } main.playSound(getPosition(), sound); }
6
public String nextToken() throws JSONException { char c; char q; StringBuffer sb = new StringBuffer(); do { c = next(); } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; for (;;) { c = next(); if (c < ' ') { throw syntaxError("Unterminated string."); } if (c == q) { return sb.toString(); } sb.append(c); } } for (;;) { if (c == 0 || Character.isWhitespace(c)) { return sb.toString(); } sb.append(c); c = next(); } }
9
public int maxProfit(int[] prices) { if(prices == null || prices.length == 0){ return 0; } int res = 0; for(int i = 1; i <= prices.length-1 ;i++){ if(prices[i-1] < prices[i]){ res += prices[i]-prices[i-1]; } } return res; }
4
public static boolean trashSlot(final int slot) { return getSlotType(slot) == ActionSlotType.NOTHING || (checkIndex(slot) && setLocked(false) && makeReadyForInteract() && dragBetween(getMainChild(slot), getTrashButton()) && new TimedCondition(2000) { @Override public boolean isDone() { return getSlotType(slot) == ActionSlotType.NOTHING; } }.waitStop()); }
5
public static final String getASCIIStr(byte[] bs, int index, int len) { StringBuffer ascii = new StringBuffer(); if ((bs == null) || (index > bs.length) || (index < 0) || (len <= 0) || (index + len > bs.length)) { return ascii.toString(); } for (int i = 0; i < len; i++) { ascii.append((char) bs[(i + index)]); } return ascii.toString(); }
6
@Override public int[] getInts(int par1, int par2, int par3, int par4) { int i1 = par1 - 1; int j1 = par2 - 1; int k1 = par3 + 2; int l1 = par4 + 2; int[] aint = this.parent.getInts(i1, j1, k1, l1); int[] aint1 = IntCache.getIntCache(par3 * par4); for (int i2 = 0; i2 < par4; ++i2) { for (int j2 = 0; j2 < par3; ++j2) { int k2 = aint[j2 + 1 + (i2 + 1 - 1) * (par3 + 2)]; int l2 = aint[j2 + 1 + 1 + (i2 + 1) * (par3 + 2)]; int i3 = aint[j2 + 1 - 1 + (i2 + 1) * (par3 + 2)]; int j3 = aint[j2 + 1 + (i2 + 1 + 1) * (par3 + 2)]; int k3 = aint[j2 + 1 + (i2 + 1) * k1]; aint1[j2 + i2 * par3] = k3; this.initChunkSeed(j2 + par1, i2 + par2); if (k3 <= 0 && k2 <= 0 && l2 <= 0 && i3 <= 0 && j3 <= 0 && this.nextInt(1000) < milleFill) { aint1[j2 + i2 * par3] = island.value(passer); } } } return aint1; }
8
public static <T> CycList<T> construct(final T object1, final Object object2) { final CycList<T> cycList = new CycList<T>(object1); if (object2.equals(CycObjectFactory.nil)) { return cycList; } if (object2 instanceof CycList) { final CycList cycList2 = (CycList) object2; cycList.addAll(cycList2); return cycList; } cycList.setDottedElement((T) object2); return cycList; }
2
public void updateScoreboard() { if(scoreboard == null) return; OfflinePlayer target = getServer().getOfflinePlayer(scoreboardText); objective.getScore(target).setScore((int) getTimeFromType(scoreboardScoreType)); for(Player player : getServer().getOnlinePlayers()) player.setScoreboard(scoreboard); }
2
public MalayansClient() { settingManager = SettingManager.getInstance(); settingManager.init(); logger = Logger.getLogger(MalayansClient.class.toString()); if (moduleInfo == null) { moduleInfo = new ModuleInfo(); moduleInfo.setDescription(Setting.str_ModuleDescription); moduleInfo.setId(Setting.str_ModuleID); } try { Class<?> taskClass = Class.forName(Setting.str_TaskClass); taskRunnable = (Runnable)taskClass.newInstance(); } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } }
5
@Test public void test_get_int() { Assert.assertEquals(8989, getInt("b_local_port")); }
0
public Object[] selectRegion(Rectangle rect, MouseEvent e) { Object[] cells = getCells(rect); if (cells.length > 0) { selectCellsForEvent(cells, e); } else if (!graph.isSelectionEmpty() && !e.isConsumed()) { graph.clearSelection(); } return cells; }
3
public void actionPerformed(ActionEvent e) { String act = e.getActionCommand(); if (act.equals("BLUR")) { Integer integer = IntegerDialog.getInteger(Resources.getString("EffectsMenu.BLUR_AMOUNT"),1,9,3,3); if (integer != null) applyAction(new Blur(integer)); return; } if (act.equals("SATURATION")) { Integer integer = IntegerDialog.getInteger(Resources.getString("EffectsMenu.SATURATION_AMOUNT"),0,200,100,50); if (integer != null) applyAction(new Saturation(integer)); return; } if (act.equalsIgnoreCase("VALUE")) { Integer integer = IntegerDialog.getInteger(Resources.getString("EffectsMenu.VALUE_AMOUNT"),-10,10,0,5); if (integer != null) applyAction(new Value((integer + 10) / 10.0f)); return; } if (act.equals("INVERT")) { applyAction(new Invert()); return; } if (act.equals("FADE")) { Integer integer = IntegerDialog.getInteger(Resources.getString("EffectsMenu.FADE_AMOUNT"),0,256,128,64); if (integer != null) applyAction(new Fade(Color.BLACK,((float) integer) / 256.0f)); return; } }
9
public void fromJSONObject(JSONObject o) throws ParseException { setPrompt((String)o.get(KEY_PROMPT)); setAnswer((String)o.get(KEY_ANSWER)); String type = (String)o.get(KEY_TYPE); setBonusType(BONUS_TYPE.valueOf(type)); JSONArray jChoices = (JSONArray)o.get(KEY_CHOICES); if (jChoices == null) { setChoices(null); } else { String[] choice = new String[jChoices.size()]; for (int i = 0; i < jChoices.size(); i++) { choice[i] = (String)jChoices.get(i); } setChoices(choice); } setWeek(((Number)o.get(KEY_WEEK)).intValue()); setNumber(((Number)o.get(KEY_NUMBER)).intValue()); }
2
public Annotation getParentAnnotation() { Annotation parent = null; Object ob = getObject("Parent"); if (ob instanceof Reference) ob = library.getObject((Reference) ob); if (ob instanceof Annotation) parent = (Annotation) ob; else if (ob instanceof Hashtable) parent = Annotation.buildAnnotation(library, (Hashtable) ob); return parent; }
3
@Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (PreciseDecimal.class.isInstance(obj)) { final PreciseDecimal other = (PreciseDecimal) obj; return this.base == other.base && this.factor == other.factor; } else { return false; } }
3
void applyBoundary(float[][] t) { if (boundary instanceof DirichletThermalBoundary) { DirichletThermalBoundary b = (DirichletThermalBoundary) boundary; float tUpper = b.getTemperatureAtBorder(Boundary.UPPER); float tLower = b.getTemperatureAtBorder(Boundary.LOWER); float tLeft = b.getTemperatureAtBorder(Boundary.LEFT); float tRight = b.getTemperatureAtBorder(Boundary.RIGHT); for (int i = 0; i < nx; i++) { t[i][0] = tUpper; t[i][ny1] = tLower; } for (int j = 0; j < ny; j++) { t[0][j] = tLeft; t[nx1][j] = tRight; } } else if (boundary instanceof ComplexDirichletThermalBoundary) { ComplexDirichletThermalBoundary b = (ComplexDirichletThermalBoundary) boundary; float[] tUpper = b.getTemperaturesAtBorder(Boundary.UPPER); float[] tLower = b.getTemperaturesAtBorder(Boundary.LOWER); float[] tLeft = b.getTemperaturesAtBorder(Boundary.LEFT); float[] tRight = b.getTemperaturesAtBorder(Boundary.RIGHT); for (int i = 0; i < nx; i++) { t[i][0] = tUpper[i]; t[i][ny1] = tLower[i]; } for (int j = 0; j < ny; j++) { t[0][j] = tLeft[j]; t[nx1][j] = tRight[j]; } } else if (boundary instanceof NeumannThermalBoundary) { NeumannThermalBoundary b = (NeumannThermalBoundary) boundary; float fN = b.getFluxAtBorder(Boundary.UPPER); float fS = b.getFluxAtBorder(Boundary.LOWER); float fW = b.getFluxAtBorder(Boundary.LEFT); float fE = b.getFluxAtBorder(Boundary.RIGHT); // very small conductivity at the border could cause strange behaviors (e.g., huge number of isotherm lines), so impose a minimum float minConductivity = 0.001f; for (int i = 0; i < nx; i++) { t[i][0] = t[i][1] + fN * deltaY / Math.max(conductivity[i][0], minConductivity); t[i][ny1] = t[i][ny2] - fS * deltaY / Math.max(conductivity[i][ny1], minConductivity); } for (int j = 0; j < ny; j++) { t[0][j] = t[1][j] - fW * deltaX / Math.max(conductivity[0][j], minConductivity); t[nx1][j] = t[nx2][j] + fE * deltaX / Math.max(conductivity[nx1][j], minConductivity); } } }
9
static final Class142_Sub27_Sub6 method562(boolean flag) { if (Class26.aNodeChildList_471 == null) { return null; } Class142_Sub18.aClass38_3546.method396((byte) -16, Class26.aNodeChildList_471); Class142_Sub27_Sub6 class142_sub27_sub6 = (Class142_Sub27_Sub6) Class142_Sub18.aClass38_3546.method399((byte) -109); if (flag) { method559((byte) -109); } Class45 class45 = Class117.method1058(class142_sub27_sub6.anInt4738, 22464); if (class45 != null && class45.aBoolean774 && class45.method588(0)) { return class142_sub27_sub6; } else { return Class6.method131((byte) -41); } }
5
private void loadSpelprojekt() { try { ArrayList<String> games = DB.fetchColumn("select sid from spelprojekt"); ArrayList<Spelprojekt> sp = new ArrayList<>(); cbAvalibleSpelprojekt.removeAllItems(); for (String st : games) { sp.add(new Spelprojekt(Integer.parseInt(st))); } for (Spelprojekt s : sp) { cbAvalibleSpelprojekt.addItem(s); } } catch (InfException e) { e.getMessage(); } }
3
public Msg readMsg(Socket socket, ObjectInputStream in) { try { if (!socket.isConnected()) { return null; } Msg msg = (Msg) in.readObject(); while (msg == null) { } return msg; } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } return null; }
3
@Override protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); if (kirjaudutaankoUlos(request)) { kirjauduUlos(request, response); } else if (onkoKirjautunut(request, response)) { try { if (HoitoOhje.haeHoitoOhjeetAsiakasIdlla(getKayttaja().getId()).isEmpty()) { request.setAttribute("hoitoOhjeenTila", "Sinulla ei ole hoito-ohjeita."); } List<HoitoOhje> hoitoOhjeet = HoitoOhje.haeHoitoOhjeetAsiakasIdlla(getKayttaja().getId()); List<Kayttaja> laakarit = new ArrayList<Kayttaja>(); List<String> paivamaarat = new ArrayList<String>(); for (HoitoOhje h : hoitoOhjeet) { Varaus v = Varaus.haeVarausIdlla(h.getVarausId()); Kayttaja l = v.getLaakari(); laakarit.add(l); } muunnaLisaysajankohdatSuomalaisiksi(request, hoitoOhjeet); request.setAttribute("hoitoOhjeet", hoitoOhjeet); request.setAttribute("laakarit", laakarit); } catch (Exception e) { naytaVirheSivu("Hoito-ohjeiden haku epäonnistui.", request, response); } avaaSivunakyma(request, response, "omatvaraukset", "viikkoaikataulu", "hoito-ohjeet", "web/hoitoOhjeet.jsp"); } }
5
private String getResponse(HttpURLConnection connection) throws Exception { InputStream in = null; // Load stream if(status != 200) { in = connection.getErrorStream(); } else { in = connection.getInputStream(); } BufferedInputStream input = new BufferedInputStream(in); StringBuffer sb = new StringBuffer(); int ch; while((ch = input.read()) != -1) { sb.append((char)ch); } input.close(); return sb.toString(); }
2
static public void main(String[] args){ //efficiency comparison Vector<Integer> container = new Vector<Integer>(); Random rand = new Random(); for(int i=0; i<2000000; i++) container.add(rand.nextInt()); //Testing my priority queue long time = System.currentTimeMillis(); MyPriorityQueue<Integer> test = new MyPriorityQueue<Integer>(10, false); for(Integer val:container) test.add(val); for(Integer i : test) System.out.println(i); System.out.println(System.currentTimeMillis()-time); //Testing the system one time = System.currentTimeMillis(); PriorityQueue<Integer> test2 = new PriorityQueue<Integer>(); for(Integer val:container) test2.add(val); for(int i=0; i<10; i++) System.out.println(test2.poll()); System.out.println(System.currentTimeMillis()-time); }
5
private void removeOld() { double[] location = this.locationStack.removeFirst(); KdTree<T> cursor = this; // Find the node where the point is while (cursor.locations == null) { if (location[cursor.splitDimension] > cursor.splitValue) { cursor = cursor.right; } else { cursor = cursor.left; } } for (int i = 0; i < cursor.locationCount; i++) { if (cursor.locations[i] == location) { System.arraycopy(cursor.locations, i + 1, cursor.locations, i, cursor.locationCount - i - 1); cursor.locations[cursor.locationCount - 1] = null; System.arraycopy(cursor.data, i + 1, cursor.data, i, cursor.locationCount - i - 1); cursor.data[cursor.locationCount - 1] = null; do { cursor.locationCount--; cursor = cursor.parent; } while (cursor.parent != null); return; } } // If we got here... we couldn't find the value to remove. Weird... }
5
public static Long getMaxDiagonal2Product(int[][] data, int numbers) { int max = Integer.MIN_VALUE; for (int x = 0; x + numbers <= DATA.length; x++) { for (int y = 0; y + numbers <= DATA.length; y++) { int sum = 1; for (int offset = 0; offset < numbers; offset++) { sum *= data[x + offset][y + offset]; } max = Math.max(max, sum); } } return (long) max; }
3
final public void Class_declaration() throws ParseException { /*@bgen(jjtree) Class_declaration */ SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DECLARATION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { Class_head(); Class_body(); Class_tail(); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0)); } } }
8
protected void printTopChild4Stn(String filePrefix){ String topChild4StnFile = filePrefix + "/topChild4Stn.txt"; try{ PrintWriter pw = new PrintWriter(new File(topChild4StnFile)); for(_Doc d:m_corpus.getCollection()){ if(d instanceof _ParentDoc){ _ParentDoc pDoc = (_ParentDoc)d; pw.println(pDoc.getName()+"\t"+pDoc.getSenetenceSize()); for(_Stn stnObj:pDoc.getSentences()){ // HashMap<String, Double> likelihoodMap = rankChild4StnByLikelihood(stnObj, pDoc); HashMap<String, Double> likelihoodMap = rankChild4StnByLanguageModel(stnObj, pDoc); // int i=0; pw.print((stnObj.getIndex()+1)+"\t"); for(Map.Entry<String, Double> e: sortHashMap4String(likelihoodMap, true)){ // if(i==topK) // break; pw.print(e.getKey()); pw.print(":"+e.getValue()); pw.print("\t"); // i++; } pw.println(); } } } pw.flush(); pw.close(); }catch (Exception e) { e.printStackTrace(); } }
5
@Column(name = "module_id") @Id public String getModuleId() { return moduleId; }
0
public void businessScoreDist() { double totalScore = 0; int totalBusinessCnt = 0; Map<Double, Integer> businessScoreMap = new TreeMap<Double, Integer>(); for (Business business:businessMap.values()) { //System.out.println("hello"); totalBusinessCnt += 1; double star = business.stars; totalScore += star; if (!businessScoreMap.containsKey(star)) { businessScoreMap.put(star,0); } businessScoreMap.put(star,businessScoreMap.get(star)+1); } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Double d:businessScoreMap.keySet()) { dataset.setValue((double)businessScoreMap.get(d)/totalBusinessCnt,"Percentage",String.valueOf(d)); } JFreeChart chart = ChartFactory.createBarChart("Business Score Distribution", "Business Score", "Percentage", dataset, PlotOrientation.VERTICAL, false, true, false); try { ChartUtilities.saveChartAsJPEG(new File("barchart.jpg"), chart, 500, 300); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } }
4
public void start() throws IllegalStateException { if (instructions == null || endgamewindow == null || gameboard == null || lobby == null || loginsingup == null || newgame == null) throw new IllegalStateException(); done = false; // Start Socket connection attempConnection(); setState(ModelStates.loginsingup); newgame.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); endgamewindow .setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); Thread myThread = new Thread(this); myThread.start(); }
6
public List getEntitiesWithinAABBExcludingEntity(Entity var1, AxisAlignedBB var2) { this.field_1012_M.clear(); int var3 = MathHelper.floor_double((var2.minX - 2.0D) / 16.0D); int var4 = MathHelper.floor_double((var2.maxX + 2.0D) / 16.0D); int var5 = MathHelper.floor_double((var2.minZ - 2.0D) / 16.0D); int var6 = MathHelper.floor_double((var2.maxZ + 2.0D) / 16.0D); for (int var7 = var3; var7 <= var4; ++var7) { for (int var8 = var5; var8 <= var6; ++var8) { if (this.chunkExists(var7, var8)) { this.getChunkFromChunkCoords(var7, var8).getEntitiesWithinAABBForEntity(var1, var2, this.field_1012_M); } } } return this.field_1012_M; }
3
public static Image rayleighNoise(Image original, double psi, double p) { if (original == null) return null; Image rayleigh = original.shallowClone(); for (int x = 0; x < original.getWidth(); x++) { for (int y = 0; y < original.getHeight(); y++) { double rand = Math.random(); double noise = 1; if (rand < p) { noise = rayleighGenerator(psi); } rayleigh.setPixel(x, y, RED, original.getPixel(x, y, RED) * noise); rayleigh.setPixel(x, y, GREEN, original.getPixel(x, y, GREEN) * noise); rayleigh.setPixel(x, y, BLUE, original.getPixel(x, y, BLUE) * noise); } } return rayleigh; }
4
public static String[] getFirstNums(String str) { if(str.length() == 1) if(Character.isDigit(str.charAt(0))) return new String[] { str, str.charAt(0) + "" }; // if there is a specified quantity, set quantity to that number int quantity = 1; if (Character.isDigit(str.charAt(0))) { int end = 0; for (int i = 0; i < str.length(); i++) { if (!Character.isDigit(str.charAt(i))) { end = i; break; } } quantity = Integer.parseInt(str.substring(0, end)); str = str.substring(end); } // System.out.println("getFirstNums: " + str+" -> "+quantity); String[] out = { str, quantity + "" }; return out; }
5
public AnnotationVisitor visitAnnotation( final String desc, final boolean visible) { return new SAXAnnotationAdapter(getContentHandler(), "annotation", visible ? 1 : -1, null, desc); }
1
public static <T extends DC> Equality getPhiEqu(Set<Pair<Pair<T,PT<Integer>>,Pair<T,PT<Integer>>>> done) { if(done!=null) { if(done.getNext()!=null) { return new Equality(done.getFst().fst().fst().delta(done.getFst().snd().fst()).equa().getValue()&&getPhiEqu(done.getNext()).getValue()); } else { return new Equality(done.getFst().fst().fst().delta(done.getFst().snd().fst()).equa().getValue()); } } else { return new Equality(false); } }
3
private static PathNode findTargetPath(AIUnit aiUnit, boolean deferOK) { if (invalidAIUnitReason(aiUnit) != null) return null; final Unit unit = aiUnit.getUnit(); final Tile startTile = unit.getPathStartTile(); if (startTile == null) return null; // Not on the map? Europe *must* be viable, so go there // (return null for now, path still impossible). PathNode path; final Player player = unit.getOwner(); final Europe europe = player.getEurope(); final Unit carrier = unit.getCarrier(); final CostDecider standardCd = CostDeciders.avoidSettlementsAndBlockingUnits(); final CostDecider relaxedCd = CostDeciders.numberOfTiles(); if (player.getNumberOfSettlements() <= 0) { // No settlements, so go straight to Europe. If Europe does // not exist then this mission is doomed. If a carrier is // present use it, otherwise relax the cost decider and at least // start working on a path. return (europe == null) ? null // Nowhere suitable at all! : (carrier != null) ? unit.findPath(startTile, europe, carrier, standardCd) : unit.findPath(startTile, europe, null, relaxedCd); } // Can the unit get to a cash in site? final GoalDecider gd = getGoalDecider(aiUnit, deferOK); path = unit.search(startTile, gd, standardCd, MAX_TURNS, carrier); if (path != null) return path; // One more try with a relaxed cost decider and no range limit. return unit.search(startTile, gd, relaxedCd, INFINITY, carrier); }
6
public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] comp = new int[n]; for(int i=0;i<n;i++){ comp[i]=in.nextInt(); } Arrays.sort(comp); int count = 0; for(int i=comp.length-1;i>=0;i--){ count++; if(count==k){ System.out.println(comp[i]); break; } } }
3
public static float getFovY() { return fovY; }
0
public static int allocateSchools(String id[]) { String schoolid=id[0]; System.out.println("in DAO school award"); System.out.println(schoolid); String testid="",awardid="",awardname=""; try{ con=DBConnection.getConnection(); System.out.println("in try"); String query1="select count(schoolid) from awardschool where schoolid=?"; pt=con.prepareStatement(query1); pt.setString(1, schoolid); rs=pt.executeQuery(); rs.next(); if(rs.getInt(1)==0){ String query="select * from awardstudent where schoolid=?"; pt=con.prepareStatement(query); pt.setString(1, schoolid); rs=pt.executeQuery(); while(rs.next()){ testid=rs.getString("testid"); awardid=rs.getString("awardid"); schoolid=rs.getString("schoolid"); awardname=rs.getString("awardname"); System.out.println(schoolid); } Statement stmt=con.createStatement(); query="insert into awardschool values('"+testid+"','"+awardid+"','"+schoolid+"','"+awardname+"')"; System.out.println(query); stmt.executeQuery(query); con.commit(); i=1; } else{ System.out.println("in else"); i=2; } } catch(Exception e){ } finally { try { con.close(); pt.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }System.out.println(i); return i; }
4
@Override public Card chooseCard(Player player, Card[] cards, GameState state) { //If there's only one choice, we have no choice but to do it if(cards.length == 1) { return cards[0]; } int alpha = Integer.MIN_VALUE; int beta = Integer.MAX_VALUE; Card choice = null; ArrayList<Color> playerList = new ArrayList<Color>(); for(Player p : state.getPlayerList()) { playerList.add(p.getFaction()); } playerList.remove(player.getFaction()); //We perform alpha beta search on each state to see if //it's the best for(Card card : cards) { ArrayList<Card> cardChoices = new ArrayList<Card>(); cardChoices.add(card); int check = alphabetaCardPicking(new GameState(state), new ArrayList<Color>(playerList), cardChoices, alpha, beta, player.getFaction(), maxDepth); System.out.println("\ncheck: " + check); //Check to see if this state is better if(check > alpha) { alpha = check; choice = card; } } return choice; }
4
public double minValue(KrakenState state, String player, double alpha, double beta) { if (expandedNodes==maxNodesExpand || game.isTerminal(state)){ if (heuristics==null) return heuristic.h(state); else return getHeuristicFusion(state); } expandedNodes++; double value = Double.POSITIVE_INFINITY; for (KrakenMove KrakenMove : game.getActions(state)) { value = Math.min(value, maxValue( game.getResult(state.clone(), KrakenMove).clone(), player, alpha, beta)); if (value <= alpha) return value; beta = Math.min(beta, value); } return value; }
5
public Transition getTransitionForUnitProduction(Production production, VariableDependencyGraph graph) { ProductionChecker pc = new ProductionChecker(); if (!ProductionChecker.isUnitProduction(production)) return null; String lhs = production.getLHS(); String rhs = production.getRHS(); State from = getStateForVariable(lhs, graph); State to = getStateForVariable(rhs, graph); return new VDGTransition(from, to); }
1
public void setChefVente(String chefVente) { this.chefVente = chefVente; }
0
@Override public boolean equals(Object other) { if(other instanceof Board) { Board board = (Board) other; if(deck.equals(board.deck)) { if(shipLoot.length == board.shipLoot.length) { for(int i = 0; i < shipLoot.length; i++) { if(!shipLoot[i].equals(board.shipLoot[i])) { return false; } } return true; } } } return false; }
5
@Test public void smallBoardSize2WithBishopAndRook() { Map<String, Integer> figureQuantityMap = new HashMap<>(); figureQuantityMap.put(BISHOP.toString(), 1); figureQuantityMap.put(ROOK.toString(), 1); int dimension = 2; Set<String> boards = prepareBoardsWithBishopAndRook(figureQuantityMap, dimension); assertThat("more than 1 figure is present", boards.contains("rx\n" + "x.\n"), is(true)); assertThat("more than 1 figure is present", boards.contains("xr\n" + ".x\n"), is(true)); assertThat("more than 1 figure is present", boards.contains(".b\n" + "x.\n"), is(true)); assertThat("more than 1 figure is present", boards.contains("b.\n" + ".x\n"), is(true)); assertThat("all elements are not present on each board", boards.stream() .filter(board -> !board.contains(KING.getFigureAsString()) && !board.contains(QUEEN.getFigureAsString()) && !board.contains(KNIGHT.getFigureAsString()) && board.contains(FIELD_UNDER_ATTACK_STRING) && board.contains(EMPTY_FIELD_STRING) && leftOnlyFigures(board).length() == 1) .map(e -> 1) .reduce(0, (x, y) -> x + y), is(8)); }
5
public boolean isBinaryTreeABST(Node head) { if (head != null) { if (head.left != null) { if ((Integer) head.left.value > (Integer) head.value) return false; } if (head.right != null) { if ((Integer) head.right.value < (Integer) head.value) return false; } } if (head.left != null) isBinaryTreeABST(head.left) ; if (head.right != null) isBinaryTreeABST(head.right); return true; }
7
protected void printSubMenuText(Integer number){ switch (number){ case 0: {System.out.print(MENU_TEXT_BACK_ANY);break;} case 1: {System.out.print(MENU_TEXT_411_ISBN);break;} case 2: {System.out.print(MENU_TEXT_411);break;} case 3: {System.out.print(MENU_TEXT_411_COUNT);break;} case 4: {System.out.print(MENU_TEXT_421);break;} case 5: {System.out.print(MENU_TEXT_431);break;} case 6: {System.out.print(MENU_TEXT_FILENAME);break;} } }
7
public static void updateFolders(){ try { registerFont(); GraphicsConfiguration.load(); } catch (FontFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if(!MAP_FOLDER.exists()){ MAP_FOLDER.mkdir(); FileTools.extract(new File(MAP_FOLDER_PATH+"default.smap"), "default.smap"); } if(!SKIN_FOLDER.exists()){ SKIN_FOLDER.mkdir(); FileTools.extract(new File(SKIN_FOLDER_PATH+"default.sskin"), "default.sskin"); } if(!TEMP_FOLDER.exists()){ TEMP_FOLDER.mkdir(); }else{ for( File file : TEMP_FOLDER.listFiles()){ file.delete(); } } }
6
protected boolean isFinished() { if(_goal < 0) { return _dist <= _goal; } else { return _dist >= _goal; } }
1
public static Records getQueryResults(PreparedStatement preparedStatement, Set<Column> selectedColumns, BaseDatabaseConnection dbConnection) throws SQLException { ResultSet resultSet = null; try { resultSet = preparedStatement.executeQuery(); Records results = new Records(); while (resultSet.next()) { Record record = parseResultSet(resultSet, selectedColumns); if (record != null) { results.addRecord(record); } } return results; } catch (SQLRecoverableException e) { dbConnection.resetConnection(); throw e; } finally { try { if (resultSet != null) { resultSet.close(); } preparedStatement.close(); } catch (SQLRecoverableException e) { LOG.error(e.toString()); dbConnection.resetConnection(); } catch (SQLException e) { LOG.error(e.toString()); } } }
6
public void build(File exportFile) throws TaskIOException { if (exportFile == null) { throw new TaskIOException(ApplicationSettings.getInstance().getLocalizedMessage("log.err.file")); } log.info(ApplicationSettings.getInstance().getLocalizedMessage("log.create.file")); m_taskList.setName(exportFile.getName()); try { DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbfactory.newDocumentBuilder(); Document doc = builder.newDocument(); Element root = doc.createElement("TASKLIST"); doc.appendChild(root); createXML(doc, root); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(exportFile); transformer.transform(source, result); } catch (ParserConfigurationException pce) { String err = ApplicationSettings.getInstance().getLocalizedMessage("txmlfb.pce") + ": " + pce.getLocalizedMessage(); log.error(err); throw new TaskIOException(err); } catch (TransformerConfigurationException e) { String err = ApplicationSettings.getInstance().getLocalizedMessage("txmlfb.tce") + ": " + e.getLocalizedMessage(); log.error(err); throw new TaskIOException(err); } catch (TransformerException e) { String err = ApplicationSettings.getInstance().getLocalizedMessage("txmlfb.ioe") + ": " + e.getLocalizedMessage(); log.error(err); throw new TaskIOException(err); } log.info(ApplicationSettings.getInstance().getLocalizedMessage("txmlfb.succ")); }
4