method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
0f23df15-e4a3-48f7-a3b2-b55db0c3f0a0
2
private boolean isSkill(final String checkSkill) { for (String skill : SKILLS) { if (skill.equalsIgnoreCase(checkSkill)) return true; } return false; }
6dbb5dcf-b945-4923-915a-03b7b16f746f
2
public String createMessage(String forumId, String subForumId, User user, String title, String content) { Forum forum = this.getForum(forumId); if (forum != null) { SubForum subforum = forum.getSubForumById(subForumId); if (subforum != null) return subforum.createMessage(user, title, content); } return null; }
501eec7c-213e-474a-b3e0-f9dcaf33f089
6
private void initUsermenuImageMenu(Color bg) { this.usermenuImageMenu = new JPanel(); this.usermenuImageMenu.setBackground(bg); this.usermenuImageMenu.setLayout(new VerticalLayout(5, VerticalLayout.LEFT)); // size int[] size = new int[] { this.skin.getUsertileImageWidth(), this.skin.getUsertileImageHeight() }; this.usermenuImageMenu.add(new SizeField(size, 4, bg, strSizeFieldTitle, true) { private final long serialVersionUID = 1L; @Override public void widthOnKeyReleased(String input) { if (!UsertileChangesMenu.this.skin.setUsertileImageWidth(parseInt(input))) { updateWidthfieldColor(Color.RED); } } @Override public void heightOnKeyReleased(String input) { if (!UsertileChangesMenu.this.skin.setUsertileImageHeight(parseInt(input))) { updateHeightfieldColor(Color.RED); } } @Override public void resetOnClick() { UsertileChangesMenu.this.skin.setUsertileImageWidth(-1); UsertileChangesMenu.this.skin.setUsertileImageHeight(-1); update(UsertileChangesMenu.this.skin.getUsertileImageWidth(), UsertileChangesMenu.this.skin.getUsertileImageHeight()); } }); // padding final int[] padding = this.skin.getUsertileImagePadding(); this.usermenuImageMenu.add(new PaddingField(padding, bg, strPaddingFieldTitle) { private final long serialVersionUID = 1L; private int[] tmp = (padding == null) ? new int[] { 0, 0, 0, 0 } : padding; @Override public void topFieldOnKeyReleased(String input) { controlAndSet(input, 1); } @Override public void rightFieldOnKeyReleased(String input) { controlAndSet(input, 2); } @Override public void leftFieldOnKeyReleased(String input) { controlAndSet(input, 0); } @Override public void bottomFieldOnKeyReleased(String input) { controlAndSet(input, 3); } private void controlAndSet(String s, int index) { int i = FAILURE; if (s != null) { try { i = Integer.parseInt(s); } catch (NumberFormatException e) { i = FAILURE; } } if (i == FAILURE) { UsertileChangesMenu.this.skin.setUsertileImagePadding(null); } else { this.tmp[index] = i; UsertileChangesMenu.this.skin.setUsertileImagePadding(this.tmp); } } @Override public int[] reset() { UsertileChangesMenu.this.skin.setUsertileImagePadding(null); this.tmp = UsertileChangesMenu.this.skin.getUsertileImagePadding(); return this.tmp; } }); // position Position pos = this.skin.getUsertileImagePosition(); boolean[] active = { false, false, false, true, true, true, false, false, false }; this.usermenuImageMenu.add(new PositionField(pos, active, bg, strPosFieldTitle) { private final long serialVersionUID = 1L; @Override public void toprightOnPressed() { } @Override public void topleftOnPressed() { } @Override public void topOnPressed() { } @Override public void centerrightOnPressed() { UsertileChangesMenu.this.skin.setUsertileImagePosition(Position.RIGHT); } @Override public void centerleftOnPressed() { UsertileChangesMenu.this.skin.setUsertileImagePosition(Position.LEFT); } @Override public void centerOnPressed() { UsertileChangesMenu.this.skin.setUsertileImagePosition(Position.CENTER); } @Override public void bottomrightOnPressed() { } @Override public void bottomleftOnPressed() { } @Override public void bottomOnPressed() { } }); }
16354ed0-4269-4373-baca-d7c49bb8ce63
8
private boolean isFullHouse(ArrayList<Card> player) { ArrayList<Integer> sortedHand=sortHand(player); int doubleCounter=0; int tripleCounter=0; for(int i=0;i<player.size()-1;i++) { if(sortedHand.get(i)==sortedHand.get(i+1)) { if(tripleCounter==1) { sortedHand.remove(i+1); sortedHand.remove(i); tripleCounter++; break; } else { if(i==1) tripleCounter=0; else tripleCounter++; } } else tripleCounter=0; } if(tripleCounter==2) { sortedHand.trimToSize(); int size=sortedHand.size(); for(int i=0;i<(size-1);i++) { if(sortedHand.get(i)==sortedHand.get(i+1)) doubleCounter++; } } else return false; if(doubleCounter>=1) return true; else return false; }
d9a2be8a-40d0-4055-bbe1-8aef6296290f
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Utilisateur)) { return false; } Utilisateur other = (Utilisateur) object; if ((this.mail == null && other.mail != null) || (this.mail != null && !this.mail.equals(other.mail))) { return false; } return true; }
64521956-5402-4eb2-ac51-626f8b92f481
5
private void actionBtStart() { // test de source et dest if(dirSource==null) { JOptionPane.showMessageDialog(null, "Veuillez sélectionner un dossier SOURCE.", "ERREUR",JOptionPane.ERROR_MESSAGE); return; } if(!(new File(dirSource.getPath())).isDirectory()) // cas où le dossier est suppr par le user apres selection { JOptionPane.showMessageDialog(null, dirSource.getPath()+" n'est pas un dossier valide.", "ERREUR",JOptionPane.ERROR_MESSAGE); return; } if(dirDest==null) { JOptionPane.showMessageDialog(null, "Veuillez sélectionner un dossier de DESTINATION.", "ERREUR",JOptionPane.ERROR_MESSAGE); return; } if(!(new File(dirDest.getPath())).isDirectory()) // cas où le dossier est suppr par le user apres selection { JOptionPane.showMessageDialog(null, dirDest.getPath()+" n'est pas un dossier valide.", "ERREUR",JOptionPane.ERROR_MESSAGE); return; } // Demande de confirmation int r=JOptionPane.showConfirmDialog(null, "Le contenu du dossier :\n"+ dirDest.getPath()+"\n"+ "sera modifié pour contenir une copie de :\n"+ dirSource.getPath()+"\n"+ "Voulez-vous continuer ?", "Veuillez confirmer",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE); //oui=0, non=1, fermeture fenetre = ? if(r!=0) {return;} effaceLbl(); ManageHDD copier=new ManageHDD(dirSource,dirDest,this); copier.start(); }
75fa0669-7206-4334-a307-d69f651b6a19
2
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { RequestDispatcher rd = null; try { producten.changeMinVoorraad(Integer.parseInt(req.getParameter("onderdeelId")), Integer.parseInt(req.getParameter("minVoorraad"))); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(Integer.parseInt(req.getParameter("type")) == 2){ rd = req.getRequestDispatcher("onderdelen_bestellen.jsp"); }else{ rd = req.getRequestDispatcher("brandstof_bestellen.jsp"); } rd.forward(req, resp); }
8bafc16c-90b3-45fd-a1a4-7118fa9426ea
1
public double bonusDefense(Territoire t, Peuple attaquant) { return t.has(Laboratoire.class) ? 2.0 : 0.0; }
757f2986-ae50-4cac-afaf-b077bc00673a
9
public static void floodfill(Room r, int x, int y) { if(x < 0 || x >= h) { return; } if(y < 0 || y >= w) { return; } if(roomA[x][y] == null) { roomA[x][y] = r; r.incrementSize(); // west wall if(castle[x][y]%2 == 0) { floodfill(r, x, y-1); } // north wall if((castle[x][y]/2)%2 == 0) { floodfill(r, x-1, y); } // east wall if((castle[x][y]/4)%2 == 0) { floodfill(r, x, y+1); } // south wall if((castle[x][y]/8)%2 == 0) { floodfill(r, x+1, y); } } }
82b9b646-98c3-4a3d-9015-66c543779654
1
public void testConstructor_Object2_Chronology() throws Throwable { LocalTime test = new LocalTime("T10:20"); assertEquals(10, test.getHourOfDay()); assertEquals(20, test.getMinuteOfHour()); assertEquals(0, test.getSecondOfMinute()); assertEquals(0, test.getMillisOfSecond()); try { new LocalTime("T1020"); fail(); } catch (IllegalArgumentException ex) {} }
297f0569-d1af-417b-8fca-c513d7197a87
9
private boolean r_Step_4() { int among_var; int v_1; // (, line 140 // [, line 141 ket = cursor; // substring, line 141 among_var = find_among_b(a_7, 18); if (among_var == 0) { return false; } // ], line 141 bra = cursor; // call R2, line 141 if (!r_R2()) { return false; } switch(among_var) { case 0: return false; case 1: // (, line 144 // delete, line 144 slice_del(); break; case 2: // (, line 145 // or, line 145 lab0: do { v_1 = limit - cursor; lab1: do { // literal, line 145 if (!(eq_s_b(1, "s"))) { break lab1; } break lab0; } while (false); cursor = limit - v_1; // literal, line 145 if (!(eq_s_b(1, "t"))) { return false; } } while (false); // delete, line 145 slice_del(); break; } return true; }
f5556184-438f-4493-b2dc-b3f3c5959091
3
public synchronized void saveAllImages() { if (history.isEmpty()) { System.out.println("No images to save"); return; } JFileChooser jfc = new JFileChooser(); jfc.setCurrentDirectory(new java.io.File(".")); jfc.setDialogTitle("Choose a Directory"); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // disable the "All files" option. jfc.setAcceptAllFileFilterUsed(false); jfc.showDialog(null, "Done"); jfc.setVisible(true); String outDir = jfc.getCurrentDirectory().getAbsolutePath(); for (int i = 0; i < history.size(); i++) { try { ImageIO.write(history.get(i), "png", new File(outDir + "\\" + "imgGen" + i + ".png")); } catch (IOException e) { System.out.println("Failed to write to file :("); } finally { textArea.append(i + 1 + " of " + history.size() + "done\n"); } } }
056ad4af-e697-466c-9600-baca5d5c79ff
8
public void optimizeParam(int numItns) { assert wordTopicHist != null; // update histograms int njMax = wordTopicCountsNorm[0]; for (int j=1; j<T; j++) if (wordTopicCountsNorm[j] > njMax) njMax = wordTopicCountsNorm[j]; wordTopicNormHist = new int[njMax + 1]; for (int j=0; j<T; j++) wordTopicNormHist[wordTopicCountsNorm[j]]++; // optimize hyperparameters for (int i=0; i<numItns; i++) { double denominator = 0.0; double currentDigamma = 0.0; for (int n=1; n<wordTopicNormHist.length; n++) { currentDigamma += 1.0 / (paramSum + n - 1); denominator += wordTopicNormHist[n] * currentDigamma; } paramSum = 0.0; for (int w=0; w<W; w++) { double oldParam = param[w]; param[w] = 0.0; currentDigamma = 0; for (int n=1; n<wordTopicHist[w].length; n++) { currentDigamma += 1.0 / (oldParam + n - 1); param[w] += wordTopicHist[w][n] * currentDigamma; } param[w] *= oldParam / denominator; if (param[w] == 0.0) param[w] = 1e-10; paramSum += param[w]; } } }
de6f3b5b-7368-4621-8683-5a3233a64730
9
void RendreVelo(Utilisateur user) { Velo velo = null; for (Velo s : ConfigGlobale.velos) { if (s.getId_velo() == user.getFk_id_velo()) { velo = s; break; } } ArrayList<Borne> listeBorneStation = new ArrayList<Borne>(); Iterator<Borne> itr = ConfigGlobale.bornes.iterator(); while (itr.hasNext()) { Borne borne = itr.next(); //on recupere chaque borne ayant comme clé étrangere l'id de notre station if (borne.getFk_id_station() == ConfigGlobale.IDSTATIONTEST && borne.getEtat().equals("ok")) { listeBorneStation.add(borne); } } ArrayList<Borne> listeBornesPasDispos = new ArrayList<Borne>(); for (Velo velotemp : ConfigGlobale.velos) { int idbornetemp = velotemp.getFk_id_borne(); Borne bornetemp = null; for (Borne g : ConfigGlobale.bornes) { if (g.getId_borne() == idbornetemp) { bornetemp = g; break; } } listeBornesPasDispos.add(bornetemp); } listeBorneStation.removeAll(listeBornesPasDispos); if (!listeBorneStation.isEmpty()) { //mise a jour des champs de la base de données showConfirmMessage("Vous pouvez rendre le vélo : " + velo.getId_velo() + " sur la borne : " + listeBorneStation.get(1).getId_borne()); velo.setFk_id_borne(listeBorneStation.get(1).getId_borne()); DAO.Mapper.modifierVelo(velo); user.setFk_id_velo(-1); DAO.Mapper.modifierUtilisateur(user); } else { //TODO station la plus proche } }
72427f8e-680c-4534-af64-92cab62261f4
4
public static <T> boolean contains( final T[] array, final T v ) { for ( final T e : array ) if ( e == v || v != null && v.equals( e ) ) return true; return false; }
9549bce6-12fb-414b-9b16-3bc5f72739b6
3
private BigDecimal processBudgetItemsList(Budget budget, List<? extends BudgetItem> budgetItems) throws BudgetItemsMissingException { if(budget.getCoreBudgetItemList() != null && budget.getSocialBudgetItemList() != null) { return calculateTotalBudgetItems(budgetItems); } else { throw new BudgetItemsMissingException("BudgetItemList is null."); } }
57daa6e4-1b02-4052-94ec-06803c8fd4fa
2
private ArrayList<Tilausrivi> paivitaTuote(HttpServletRequest request, ArrayList<Tilausrivi> tilausrivit) { // otetaan vastaan tuotteen muokattavat tiedot int tilausriviNumero = Integer.parseInt(request.getParameter("btn").substring(5)); int kplmaara = Integer.parseInt(request.getParameter("kpl-maara")); String kokoStr = request.getParameter("koko"); String oregStr = request.getParameter("oregano"); String vsipStr = request.getParameter("valkosipuli"); String ltonStr = request.getParameter("laktoositon"); String gtonStr = request.getParameter("gluteeniton"); // etsitään tuote tilausrivit-listasta for (int i = 0; i < tilausrivit.size(); i++) { if (i == tilausriviNumero) { // asetetaan uudet kpl-määrä ja koko tilausrivit.get(i).setKplmaara(kplmaara); tilausrivit.get(i).setKokoStr(kokoStr); // lasketaan pizzalle tai juomalle uusi rivihinta laskeUusiRivihinta(tilausrivit, kplmaara, i); asetaLisavalinnat(tilausrivit, oregStr, vsipStr, ltonStr, gtonStr, i); break; // tuote löytyi ja tiedot asetettu, lopetetaan etsiminen listasta } } return tilausrivit; }
6cbf2295-fba7-4c64-ad87-67e7246eec7e
9
public final static boolean isArchiveFileName(String name) { int nameLength = name == null ? 0 : name.length(); int suffixLength = SUFFIX_JAR.length; if (nameLength < suffixLength) return false; // try to match as JAR file for (int i = 0; i < suffixLength; i++) { char c = name.charAt(nameLength - i - 1); int suffixIndex = suffixLength - i - 1; if (c != SUFFIX_jar[suffixIndex] && c != SUFFIX_JAR[suffixIndex]) { // try to match as ZIP file suffixLength = SUFFIX_ZIP.length; if (nameLength < suffixLength) return false; for (int j = 0; j < suffixLength; j++) { c = name.charAt(nameLength - j - 1); suffixIndex = suffixLength - j - 1; if (c != SUFFIX_zip[suffixIndex] && c != SUFFIX_ZIP[suffixIndex]) return false; } return true; } } return true; }
486924ac-07c3-44e7-93d3-e7633bce3f82
4
public static Date getDateFromRange(String dropdownValue) { if (dropdownValue == null) { throw new IllegalArgumentException("Logic Error: input argument may not be null"); } int nDays = -1; for (Range d : dateRanges) { if (dropdownValue.equals(d.choiceValue)) { nDays = d.days; break; } } if (nDays == -1) { throw new IllegalArgumentException( String.format("Logic Error: Days dropdown value %s invalid (not one we provided)", dropdownValue)); } /** Today's date */ Calendar now = Calendar.getInstance(); // Add a "# of days" increment (really a decrement) to the existing Calendar object now.add(Calendar.DATE, -nDays); Date dateStart = now.getTime(); // System.out.println("New date is " + dateStart); return dateStart; }
b37dc0d3-2204-4e96-8bd6-acf0f682f7f3
4
@Override final public void compute() { // // reset time. // final int last = this.frameidx; this.setFrameIdx(0); // for (int t = 0; t <= last; t++) { // if (t > 0) { this.copyOutput(this.frameidx - 1, this.frameidx); } // // from first to last layer. // for (int l = 0; l < this.structure.layers.length; l++) { this.computeLayerActivations(l); } // if (t < last) this.incrFrameIdx(); } }
4cbb522e-32d9-4b42-95b1-f0b322c2e346
2
private void writeMsgLength(OutputStream out) throws IOException { int msgLength = messageLength(); int val = msgLength; do { byte b = (byte) (val & 0x7F); val >>= 7; if (val > 0) { b |= 0x80; } out.write(b); } while (val > 0); }
2b16e969-8487-40d0-8417-7b4066904fcb
4
void parstt() { double[] xMax = new double[numOfParams]; double[] xMin = new double[numOfParams]; double[] xMean = new double[numOfParams]; double delta = Math.pow(10, -20); // double delta = 10E-20; double peps = Math.pow(10, -3); // minimum standard deviation // double peps = 10E-3; // minimum standard deviation double gSum = 0; for (int k = 0; k < numOfParams; k++) { xMax[k] = Double.MIN_VALUE; xMin[k] = Double.MAX_VALUE; double xSum1 = 0; double xSum2 = 0; for (int i = 0; i < totalNumOfPoints; i++) { xMax[k] = Math.max(pointsX[i][k], xMax[k]); xMin[k] = Math.min(pointsX[i][k], xMin[k]); xSum1 = xSum1 + pointsX[i][k]; xSum2 = xSum2 + pointsX[i][k] * pointsX[i][k]; } xMean[k] = xSum1 / (double) totalNumOfPoints; stdDevOfPopulation[k] = xSum2 / (double) totalNumOfPoints - xMean[k] * xMean[k]; if (stdDevOfPopulation[k] <= delta) { stdDevOfPopulation[k] = delta; } stdDevOfPopulation[k] = Math.sqrt(stdDevOfPopulation[k]) / bound[k]; gSum += Math.log(delta + (xMax[k] - xMin[k]) / bound[k]); } normalizedGeometricMean = Math.pow(Math.E, gSum / (double) numOfParams); paramConvergenceSATISFIED = false; if (normalizedGeometricMean <= peps) { paramConvergenceSATISFIED = true; } }
c16d8947-a368-43be-9634-cc6e7fe775af
1
private void endFormals() { if (hasFormals) { hasFormals = false; buf.append('>'); } }
2cc48e76-5f33-46c9-8c79-ca664e0bd959
7
@Override protected boolean hasRightNumberOfPieces(Map<PieceType, Integer> redPieceCount, Map<PieceType, Integer> bluePieceCount) { int redOffby = 0; int blueOffby = 0; for(PieceType piece : validPieceCount.keySet()) { int requiredNumber = validPieceCount.get(piece); Integer redCount = redPieceCount.get(piece); Integer blueCount = bluePieceCount.get(piece); if(redCount == null || blueCount == null) { return false; } if(redCount != requiredNumber){ redOffby += Math.abs(redCount - requiredNumber); } if(blueCount != requiredNumber) { blueOffby += Math.abs(blueCount - requiredNumber); } } if (redOffby > 1 || blueOffby > 1){ return false; } return true; }
622295e8-2b0b-450b-917e-6c28c3b95823
4
private int findNextStartIndex(String[] words, int start, int L, List<String> lines) { // find end index for a line int i = start; List<String> lineWords = new ArrayList<String>(); int len = 0; while (len < L && i < words.length) { String word = words[i]; if (len + word.length() <= L) { lineWords.add(word); len += 1 + word.length(); i++; } else { break; } } lines.add(formatLine(lineWords, L, i == words.length || lineWords.size() == 1)); return i; }
0e22f653-e69d-4d3a-8273-29ec760f0858
8
public ArrayList<String> search(String title){ boolean find = false; byte count = 0; ArrayList<String> res = new ArrayList<String>(); ArrayList<String> html=null; try { html = getHTML("http://www.lyricsmania.com/searchnew.php?k="+URLEncoder.encode(title,"UTF-8")+"&x=0&y=0");//"http://webservices.lyrdb.com/lookup.php?q="+URLEncoder.encode(title,"UTF-8")+"&for=fullt&agent=GrooveJaar"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } for (int i = 0;i<html.size();i++){ if (find && count<10){ Pattern p = Pattern.compile("<a href=.(.*?).>"); Matcher m = p.matcher(html.get(i)); while (m.find()) { if (m.group(1).contains("\"")){ res.add(m.group(1).substring(1,m.group(1).indexOf("\""))); count++; } } } if (!find){ if (html.get(i).contains("songs found:<br><br>")){ find = true; } } } return res; }
3b75a3eb-d86e-4499-9db2-d7512c5ec4b4
5
private List<LastFMEventMetaData> processingSearchResults( JSONObject response) { JSONObject responseEvents = (JSONObject) response.get("events"); List<LastFMEventMetaData> container = new ArrayList<LastFMEventMetaData>(); if (responseEvents.containsKey("event") && responseEvents.containsKey("event")) { JSONObject responseAttr = (JSONObject) responseEvents.get("@attr"); int responseLimit = Integer.parseInt(responseAttr.get("perPage") .toString()); int responseTotal = Integer.parseInt(responseAttr.get("total") .toString()); if (responseLimit > 1 && responseTotal > 1) { JSONArray responseEventsEvent = (JSONArray) responseEvents .get("event"); for (int i = 0; i < responseEventsEvent.size(); i++) { LastFMEventMetaData temp = new LastFMEventMetaData(); JSONObject responseEventEntry = (JSONObject) responseEventsEvent .get(i); processingData(responseEventEntry, temp); container.add(temp); } } else { LastFMEventMetaData temp = new LastFMEventMetaData(); JSONObject responseEventsEvent = (JSONObject) responseEvents .get("event"); processingData(responseEventsEvent, temp); container.add(temp); } return container; } else { System.out.println("No entries found!"); return container; } }
2477c16f-effc-4a9c-a770-b42d40eb100d
4
public JSONObject apiHome(String endpoint, String urlParameters, String method){ String YOUR_REQUEST_URL = "http://chicosystems.com:3000/api/"+endpoint; // String YOUR_REQUEST_URL = "http://chicosystems.com:3000/api/imgurdl/adduse"; URL imgURL; String os = System.getProperty("os.name"); String ver = getVersion(); urlParameters += "&os="+os+"&ver="+ver; try { // Desktop.getDesktop().browse(new URI("http://localhost:3000/api/imgurdl/test/adduse")); imgURL = new URL(YOUR_REQUEST_URL); HttpURLConnection conn = (HttpURLConnection) imgURL.openConnection(); conn.setDoOutput( true ); conn.setRequestMethod(method); //conn.setRequestProperty("time", "2002002002"); //conn.setRequestProperty("term", "this is the term"); //conn.setRequestProperty("os", "windows"); // String urlParameters = "&term="+term+"&os="+os+"&ver="+ver; byte[] postData = urlParameters.getBytes( StandardCharsets.UTF_8 ); int postDataLength = postData.length; conn.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded"); conn.setRequestProperty( "charset", "utf-8"); conn.setRequestProperty( "Content-Length", Integer.toString( postDataLength )); try( DataOutputStream wr = new DataOutputStream( conn.getOutputStream())) { wr.write( postData ); } //conn.setRequestProperty("Authorization", "Client-ID " + Client_ID); BufferedReader bin = null; bin = new BufferedReader(new InputStreamReader(conn.getInputStream())); //below will print out bin String jsonString = ""; String line; while ((line = bin.readLine()) != null){ jsonString = jsonString + line; } bin.close(); JSONParser parser = new JSONParser(); try{ if(jsonString.equals("success")){ return null; }else{ JSONObject obj = (JSONObject) parser.parse(jsonString); System.out.println(obj.toString()); return obj; } }catch(ParseException pe){ //if(isRunning) // gui.mainCanvas.header.inputArea.textField.setText("No Results!"); //System.out.println("pe: "+pe.toString()); // System.out.println("position: " + pe.getPosition()); //System.out.println(pe); } } catch (IOException e) { // TODO Auto-generated catch block //e.printStackTrace(); System.out.println(e.toString()); //} catch (URISyntaxException e) { // TODO Auto-generated catch block // e.printStackTrace(); } return null; }
2b3bc109-c239-4585-af4b-4c4eb75b9467
8
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(ID())!=null) { mob.tell(target,null,null,L("<S-NAME> <S-IS-ARE> already BEHEMOTH in size.")); return false; } if(!super.invoke(mob,commands,givenTarget,auto,asLevel)) return false; final boolean success=proficiencyCheck(mob,0,auto); if(success) { final CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),auto?"":L("^S<S-NAME> @x1.^?",prayWord(mob))); if(mob.location().okMessage(mob,msg)) { mob.location().send(mob,msg); target.location().show(target,null,CMMsg.MSG_OK_VISUAL,L("<S-NAME> grow(s) to BEHEMOTH size!")); beneficialAffect(mob,target,asLevel,0); CMLib.utensils().confirmWearability(target); } } else return beneficialWordsFizzle(mob,target,L("<S-NAME> @x1, but nothing happens.",prayWord(mob))); // return whether it worked return success; }
308e729e-9fb5-46cd-ba94-b93fefadc987
3
public int binair_zoeken(char target) { int top = rij.length -1; //Maximale arry index positie of maximale positie na een breuk int bottom = 0; //start positie of laagste positie na een breuk while (bottom <= top) // zolang de bottom waarde kleiner is dan top waarde herhaalt de loop zich. { int mid = (top + bottom) / 2; // midden berekenen if (rij[mid] == target) // als de target gevonden is geef deze terug { return (mid); } else // als de target kleiner is dan + 1 if (rij[mid] < target) { bottom = mid + 1; } else // als de target groter is dan - 1 { top = mid - 1; } } return -1; }
2d2b237f-2236-439f-83a1-94dcb3a3ef54
5
private void checkFilename(String filename, int len) throws BadHttpRequest { for (int i = 0; i < len; ++i) { char c = filename.charAt(i); if (!Character.isJavaIdentifierPart(c) && c != '.' && c != '/') throw new BadHttpRequest(); } if (filename.indexOf("..") >= 0) throw new BadHttpRequest(); }
604c89f5-3506-4dad-afe1-160a83302e84
2
private List<AchievementRecord> readAchievements(InputStream in) throws IOException { int achievementCount = readInt(in); List<AchievementRecord> achievements = new ArrayList<AchievementRecord>(achievementCount); for (int i = 0; i < achievementCount; i++) { String achName = readString(in); int diffFlag = readInt(in); Difficulty diff; switch( diffFlag ) { case 1: diff = Difficulty.NORMAL; break; default: diff = Difficulty.EASY; } achievements.add( new AchievementRecord( achName , diff ) ); } return achievements; }
75ed4ffe-00fe-4300-b594-c587f276fec2
1
public static void listDatabase() { for(String s : database) { System.out.println(s); } }
f2bdedca-d68f-4762-85ad-215bf21d1a4b
3
public DuplexLink get_link(int port) { if (this.links.containsValue(port)) { Iterator<DuplexLink> itr = this.links.keySet().iterator(); while (itr.hasNext()) { DuplexLink link = itr.next(); if (this.links.get(link) == port) return link; } } return null; }
12189be7-c88e-496a-adfd-a084170704a7
3
public void deleteElement(ValueType value) throws NotExistException { ListElement<ValueType> previous = head; ListElement<ValueType> current = head.next; if (exist(value)) { while (current != tail.next) { if (current.value == value) { previous.next = current.next; count--; return; } else { previous = current; current = current.next; } } } else { throw new NotExistException("Element with current value doesn't exist!"); } }
4037789b-013a-4af8-9966-f9bb3d86df64
3
public void setString(PString node) { if(this._string_ != null) { this._string_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); } this._string_ = node; }
b71a7d4c-b323-4e24-bb79-4f8ab02bec2e
2
@Override public boolean stopVideoProcessing() { // First clean created data ... cleanUp(); // Then attempt to stop the processThread if (processThread == null || !processThread.isAlive()) return false; // Didn't find any better way to kill the thread processThread.stop(); return true; }
a7c4c0ca-a338-4bcd-a31a-ec48d42b195f
1
protected String[] doparse(String str) { List<String> list = new LinkedList<String>(); for (String s : str.split(",")) { list.add(s); } String[] result = new String[list.size()]; list.toArray(result); return result; }
f42feba6-7ae7-4cc1-8441-8226e368f8bb
0
public void onPriceChanged(int price) { setText(INIT_TEXT + price); }
57fd1ad9-d823-4a80-924a-b29b9306b8b3
7
private String GetPrecision(String value) { String precision = "undefined"; // 1991-12-23 // 1992-9-3T10:00.... if (value.matches("^(1[6789][0-9]{2}|20[0-9]{2})-[0-9]{1,2}-[0-9]{1,2}(T.*)?$")) { precision = "day"; } // 1991-12 // 1991-9 else if (value.matches("^(1[6789][0-9]{2}|20[0-9]{2})-[0-9]{1,2}$")) { precision = "month"; } // 1991-Q3 // 1991-H1 else if (value.matches("^(1[6789][0-9]{2}|20[0-9]{2})-(Q[1-4]|H[1-2]|SP|SU|FA|WI)$")) { precision = "months"; } // 1991-W12 // 1991-W12-WE (weekend) else if (value.matches("^(1[6789][0-9]{2}|20[0-9]{2})-W[0-9]{1,2}(-WE)?$")) { precision = "days"; } // 1990 else if (value.matches("^(1[6789][0-9]{2}|20[0-9]{2})$")) { precision = "year"; } // 19 // 198 // 198X else if (value.matches("^(1[6789]|20)([0-9]X?)?$")) { precision = "years"; } // PAST_REF // PRESENT_REF // FUTURE_REF else if (value.matches("^(PAST|PRESENT|FUTURE)_REF(T.*)?$")) { precision = "ref"; } return precision; }
beabd6fc-1efa-4794-a06d-12499ca55805
1
public void salvar() { if (dao.Salvar(entidade)) { exibirMensagem("Salvo"); entidade = new Pessoa(); } else { exibirMensagem("Erro!"); } }
7fc19b25-29e9-411f-b26d-00a64fee8a35
7
@Override public void build(String catadata) { List<XMLLibrary.XMLTag> V=null; if((catadata!=null)&&(catadata.length()>0)) { V=CMLib.xml().parseAllXML(catadata); final XMLTag piece=CMLib.xml().getPieceFromPieces(V,"CATALOGDATA"); if((piece!=null)&&(piece.contents()!=null)&&(piece.contents().size()>0)) { category=CMLib.xml().restoreAngleBrackets(piece.getParmValue( "CATAGORY")); if(category==null) category=""; lmaskStr=CMLib.xml().restoreAngleBrackets(piece.getValFromPieces("LMASK")); final String ratestr=piece.getValFromPieces("RATE"); rate=CMath.s_pct(ratestr); lmaskV=null; if(lmaskStr.length()>0) lmaskV=CMLib.masking().maskCompile(lmaskStr); live=CMath.s_bool(piece.getValFromPieces("LIVE")); } } else { lmaskV=null; lmaskStr=""; live=false; rate=0.0; } }
4580b91d-061b-4216-b484-2e41a8f1da4e
6
public static Stella_Object finishWalkingArgumentListTree(Slot self, Cons tree, StandardObject firstargtype, Object [] MV_returnarray) { if (self.slotName == Stella.SYM_STELLA_ALLOCATE_ITERATOR) { { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get(); try { Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true); Stella.signalTranslationError(); if (!(Stella.suppressWarningsP())) { Stella.printErrorContext(">> ERROR: ", Stella.STANDARD_ERROR); { Stella.STANDARD_ERROR.nativeStream.println(); Stella.STANDARD_ERROR.nativeStream.println(" Cannot invoke `" + Stella_Object.deUglifyParseTree(self) + "' directly, use `foreach' instead."); } ; } } finally { Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000); } } return (Stella_Object.walkDontCallMeTree(tree, Stella.SGT_STELLA_ARGUMENT_LIST_ITERATOR, MV_returnarray)); } if (self.slotOwner == Stella.SGT_STELLA_CONS) { { Object old$PrintreadablyP$001 = Stella.$PRINTREADABLYp$.get(); try { Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true); Stella.signalTranslationNote(); if (!(Stella.suppressWarningsP())) { Stella.printErrorContext(">> NOTE: ", Stella.STANDARD_OUTPUT); { System.out.println(); System.out.println(" Applying CONS-methods to &rest-arguments is deprecated."); System.out.println(" `" + Stella_Object.deUglifyParseTree(tree) + "'"); System.out.println(" Use `foreach' or explicitly coerce with `coerce-&rest-to-cons'."); } ; } } finally { Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$001); } } firstargtype = MethodSlot.yieldListifiedVariableArgumentsType(((MethodSlot)(Stella.$METHODBEINGWALKED$.get()))); } if (MethodSlot.passVariableArgumentsAsListP(((MethodSlot)(Stella.$METHODBEINGWALKED$.get())))) { if (self.slotName == Stella.SYM_STELLA_LENGTH) { return (Stella_Object.sysTree(Cons.list$(Cons.cons(Stella.SYM_STELLA_SYS_CALL_METHOD, Cons.cons(StandardObject.typeSpecToBaseType(MethodSlot.yieldListifiedVariableArgumentsType(((MethodSlot)(Stella.$METHODBEINGWALKED$.get())))), Cons.cons(tree.concatenate(Stella.NIL, Stella.NIL), Stella.NIL)))), Stella.SGT_STELLA_INTEGER, MV_returnarray)); } else { return (self.finishWalkingCallSlotTree(tree, firstargtype, MV_returnarray)); } } else { return (self.finishWalkingCallSlotTree(tree, firstargtype, MV_returnarray)); } }
23a9bc7f-7d09-48a6-8f9e-8eec1bb5ccff
5
public void removeItem(DrawableItem item) { if (item == null) { return; } if (item instanceof PathItem) { boolean active = false; if (((PathItem) item).getPanel() != null) { for (PathItem pi : ((PathItem) item).getPanel().getLines()) { if (!pi.isHidden()) { active = true; } } } // ((PathItem) item).getLayer().setActive(active); } items.remove(item); repaint(); }
53490b96-2954-44fb-99a0-ff6023c9b01e
1
public long previousTransition(long instant) { return (instant > transition ? transition : transition - 180L * DateTimeConstants.MILLIS_PER_DAY); }
10b415fb-4433-49c1-a81f-9fbe75135248
2
public static MonthOfYearEnum fromValue(String v) { for (MonthOfYearEnum c: MonthOfYearEnum.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
ca84c1eb-8a86-49ab-80d4-1a720e6320da
9
private void visit(GraphRelationship graphRel, GraphNode graphNode, List<GraphComponent> currentPathList) { if (currentPathList.contains(graphNode)) { // we've come round to a node that we've already visited so add at end of list and return currentPathList.add(graphNode); // no further action //System.out.println("visit - this node is already in currentPath: " + graphNode); } else { if ((graphRel == null) && (_graphFragment.findAllRelationshipsForNode(graphNode).size() == 0)) { currentPathList.add(graphNode); } else if ((graphRel == null) && (_graphFragment.findFromRelationshipsForNode(graphNode).size() == 0)) { // don't add } else { GraphRelationship nextOutboundRelationship = null; for (GraphRelationship compareRel : _graphFragment.findFromRelationshipsForNode(graphNode)) { if (!_visitedRelationships.contains(compareRel)) { nextOutboundRelationship = compareRel; break; } } if (nextOutboundRelationship != null) { currentPathList.add(graphNode); //System.out.println("visit - next following outbound relationship: " + nextOutboundRelationship); _visitedRelationships.add(nextOutboundRelationship); currentPathList.add(nextOutboundRelationship); visit(nextOutboundRelationship, nextOutboundRelationship.getToNode(), currentPathList); } else { if (graphRel != null) { // came in on a non-null relationship so this is the end of this path currentPathList.add(graphNode); //System.out.println("visit - non-null graphRel, no unvisited outbound relationships on: " + graphNode + ", adding as last element in path"); } else { //System.out.println("visit - null graphRel, no unvisited outbound relationships on: " + graphNode + ", not adding any path"); } } } } }
7f1625be-910d-4dbc-b0c1-a103b9b8d0f4
1
@SuppressWarnings("deprecation") void pauseExecution() { for(ThreadsInformation threadInfo : ThreadsAgent) threadInfo.threadInfo.suspend(); }
48fe22fa-b7bb-4013-bf97-a058403e42fa
9
public void update() { // If master volume has been changed, update all volumes if(adjustVolume) { // Sound effects for(int x = 0; x<soundEffects.size(); x++) { soundEffects.get(x).adjustVolume(masterVolume); } // Tracks for(int x = 0; x<tracks.size(); x++) { tracks.get(x).adjustVolume(masterVolume); } background.adjustVolume(masterVolume); // Reset volume adjustment variable adjustVolume = false; } // Handling sound effect clean up for(int x = 0; x<soundEffects.size(); x++) { if(soundEffects.get(x).getClip().stopped()) { soundEffects.get(x).getClip().close(); soundEffects.remove(x); x--; } } // Handling track clean up for(int x = 0; x<tracks.size(); x++) { tracks.get(x).update(); if(tracks.get(x).getClip().stopped()) { tracks.get(x).getClip().close(); tracks.remove(x); x--; } } if(background != null) { background.update(); if(background.getClip().stopped()) background.play(); } }
c8dc4858-6c18-45de-b8d1-888fbb1406d1
3
private byte[] trim(byte[] in) { // remove the extra space of a byte array byte[] temp = in; int realLength = 0; for (int i = 0; i < temp.length; i++) {// count length if (temp[i] != 0) { realLength = i + 1; } } byte[] out = new byte[realLength]; for (int j = 0; j < out.length; j++) {// copy data out[j] = temp[j]; } return out; }
64d90537-c67b-4b84-a534-3307e502e73c
4
public void run(SensesPackage senses) { //TODO this code is potentially buggy because it doesn't check collision always. if (senses.playerVisible()) { //Check if the player is visible and update the path as necessary path = Pathfinding.pathTo(parent.getPos(), senses.getPlayerLocation(), senses); pathing = true; pathindex = 1; } boolean moved = followPath();//Follow the path (if there is one) //Can it attack? if (!moved && senses.playerVisible()) { if (parent.getPos().adjacentTo(senses.getPlayerLocation())) { ActionHandler.attackPlayer(parent); } } }
751409db-49e9-4791-a5f9-c81c90d56dc5
2
private static void createDirt(int width, int height) { for(int x = 0; x < width; x++) { for(int y = dirtBoundary + 1; y < stoneBoundary; y++) { blockSheet[x][y] = World.DIRT; } } }
7b80e6bf-9994-4d96-955e-4bcb00bf773c
3
private static final Object[] decodeString(byte[] bencoded_bytes, int offset) throws BencodingException { StringBuffer digits = new StringBuffer(); while(bencoded_bytes[offset] > '/' && bencoded_bytes[offset] < ':') { digits.append((char)bencoded_bytes[offset++]); } if(bencoded_bytes[offset] != ':') { throw new BencodingException("Error: Invalid character at position " + offset + ".\nExpecting ':' but found '" + (char)bencoded_bytes[offset] + "'."); } offset++; int length = Integer.parseInt(digits.toString()); byte[] byte_string = new byte[length]; System.arraycopy(bencoded_bytes, offset, byte_string, 0, byte_string.length); return new Object[] {new Integer(offset+length), ByteBuffer.wrap(byte_string)}; }
2273285d-82d8-4d94-a5e7-66f0cb95617f
7
public boolean hasAccount(String account) { Connection conn = null; ResultSet rs = null; PreparedStatement ps = null; boolean exists = false; try { conn = iConomy.getiCoDatabase().getConnection(); ps = conn.prepareStatement("SELECT * FROM " + Constants.SQLTable + "_BankRelations WHERE account_name = ? AND bank_id = ? LIMIT 1"); ps.setString(1, account); ps.setInt(2, this.id); rs = ps.executeQuery(); exists = rs.next(); } catch (Exception ex) { exists = false; } finally { if (ps != null) try { ps.close(); } catch (SQLException ex) { } if (rs != null) try { rs.close(); } catch (SQLException ex) { } if (conn != null) try { conn.close(); } catch (SQLException ex) { } } return exists; }
b33bc90a-0872-49b7-80b9-4d09f7bde43a
3
private final void writeAbcTrack(final OutputStream out, final DropTarget<JPanel, JPanel, JPanel> abcTrack, final Map<DragObject<JPanel, JPanel, JPanel>, Integer> abcPartMap) { for (final DragObject<JPanel, JPanel, JPanel> midiTrack : abcTrack) { final Integer pitch = BruteParams.PITCH.getLocalValue(midiTrack, abcTrack); final Integer volume = BruteParams.VOLUME.getLocalValue(midiTrack, abcTrack); final Integer delay = BruteParams.DELAY.getLocalValue(midiTrack, abcTrack); this.io.write(out, String.format( "miditrack %d pitch %d volume %d delay %d", Integer.valueOf(midiTrack.getId()), pitch, volume, delay)); final int total = midiTrack.getTargets(); if (total > 1) { int part = 0; if (abcPartMap.containsKey(midiTrack)) { part = abcPartMap.get(midiTrack); } abcPartMap.put(midiTrack, part + 1); this.io.writeln(out, String.format( " prio 100 " + "split %d %d", total, part)); } else { this.io.write(out, "\r\n"); } } }
c8e47b8e-270a-4ff2-ac34-39a8ec7c832f
1
public Element(Grid grid) { if (grid == null) throw new IllegalArgumentException("The given Grid is invalid!"); this.grid = grid; }
8f9742e2-6ff4-4522-90e8-f80578a3fd07
5
void solve() { NHL nhl = new NHL(in); double e1 = 0, c = 0, e2 = 0; double minProfit = -0; int cBets = 0; double prPerBank = 0; nhl.deep = 6; for (double eps1 = 0.5; eps1 <= 0.5; eps1 += 0.25) for (double eps2 = 0.5; eps2 <= 0.5; eps2 += 0.25) for (double rich = 3; rich <= 6; rich += 0.5) { nhl.eps1 = eps1; nhl.eps2 = eps2; nhl.cOfRich = rich; double profit = testPredicting(nhl); if (count >= 100 && profit < minProfit) { minProfit = profit; e1 = eps1; c = rich; e2 = eps2; cBets = count; prPerBank = profit / count; } } out.println(minProfit); out.println(e1 + " e2: " + e2 + " substract: " + c + " cbets: " + cBets + " %: " + prPerBank); nhl.eps1 = 0.5; nhl.eps2 = 0.5; nhl.cOfRich = 5; printResult(nhl); }
51e74f73-2624-4661-b03c-e253a7e1b765
3
@SuppressWarnings("unchecked") private AsyncComponent<T> getAsyncComponent() { if (asyncComponent == null) { // distinguish components that are already wrapped with AsyncComponent if (this instanceof AsyncComponent<?>) { asyncComponent = ((AsyncComponent<T>) this); } else { asyncComponent = new AsyncComponent<T>(this); } } return asyncComponent; }
d5a63d66-bb1b-4199-b37d-4eb8a4d6c18e
0
public CommandListener(Trd_match plugin) { this.plugin = plugin; }
8f05cabc-5996-4176-b252-db2bb7729345
3
public static int getArgumentSize(String methodTypeSig) { int nargs = 0; int i = 1; for (;;) { char c = methodTypeSig.charAt(i); if (c == ')') return nargs; i = skipType(methodTypeSig, i); if (usingTwoSlots(c)) nargs += 2; else nargs++; } }
e0ef72e5-7db0-448f-ac30-52bef9f8eeb8
2
public void skipTag(String name) throws IOException { String marker; if (SHOW_SKIPPED_TAGS) { Log.warn("Skipping tag: " + name); //$NON-NLS-1$ } require(XMLNodeType.START_TAG, name); marker = getMarker(); do { next(); } while (withinMarker(marker)); }
8dd840e9-5c01-4813-ab74-5af856f22144
6
private void populateList(String[] list){ for(int i = 0; i < list.length; i++){ if(list[i].endsWith(".jpg") || list[i].endsWith(".gif") || list[i].endsWith(".png") || list[i].endsWith(".jpeg") || list[i].endsWith(".tiff")){ downloadedFiles.add(list[i]); System.err.println(list[i]); } } }
eea9eb87-3c80-4fa9-b167-77b6c7109fca
1
public boolean passable() { return this == TILE_TREASURE || this == TILE_FLOOR; }
17f2dce7-661c-4044-82e7-25ec8f7259d1
5
public void set(String path, Object value) { Configuration root = getRoot(); if (root == null) { throw new IllegalStateException("Cannot use section without a root"); } final char separator = root.options().pathSeparator(); // i1 is the leading (higher) index // i2 is the trailing (lower) index int i1 = -1, i2; ConfigurationSection section = this; while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) { String node = path.substring(i2, i1); ConfigurationSection subSection = section.getConfigurationSection(node); if (subSection == null) { section = section.createSection(node); } else { section = subSection; } } String key = path.substring(i2); if (section == this) { if (value == null) { map.remove(key); } else { map.put(key, value); } } else { section.set(key, value); } }
9efc4e6d-9d41-4f4c-af3b-bc9a6478c723
4
@EventHandler public void onPlayerInteract(PlayerInteractEvent event){ if(event.getClickedBlock()==null) return; if(!(event.getClickedBlock().getState() instanceof Chest)) return; Chest chest = (Chest) event.getClickedBlock().getState(); Player player = event.getPlayer(); if(!plugin.isCoffer(chest)) return; if(plugin.getCofferOwner(chest).equals(player)) return; plugin.sendPlayerMessage(player, ChatColor.DARK_RED+"Thief! "+ChatColor.WHITE+"That is not your coffer!"); event.setCancelled(true); }
3e0fca11-6456-481a-aef5-06886ff52ee6
3
public boolean isEdgeIgnored(Object edge) { mxIGraphModel model = graph.getModel(); return !model.isEdge(edge) || !graph.isCellVisible(edge) || model.getTerminal(edge, true) == null || model.getTerminal(edge, false) == null; }
87e3082b-c88d-4723-9489-e7fb422273e0
5
private Constants.Error createTemporaryData() { { LOGGER.debug("Creating Temporary Data!"); } Constants.Error ret = null; ret = createBackUpFiles(); if (ret == null) { try { FileUtil.createDirectory(Constants.PROGRAM_TMP_PATH); FileUtil.createDirectory(Constants.PROGRAM_TMPSKIN_PATH); FileUtil.createDirectory(Constants.PROGRAM_SKINS_PATH); FileUtil.copyFile(Constants.SYSTEMFILE_AUTHUI_BAKPATH, Constants.SYSTEMFILE_AUTHUI_TMPPATH, true); FileUtil.copyFile(Constants.SYSTEMFILE_BASEBRD_BAKPATH, Constants.SYSTEMFILE_BASEBRD_TMPPATH, true); if (Files.exists(Constants.SYSTEMFILE_AUTHUI_TMPPATH, LinkOption.NOFOLLOW_LINKS) && Files.exists(Constants.SYSTEMFILE_BASEBRD_TMPPATH, LinkOption.NOFOLLOW_LINKS)) { FileUtil.copyFile(Constants.UITEXT_WORKBASE, Constants.UITEXT_TMP, false); if (!FileUtil.control(Constants.UITEXT_TMP)) { ret = Error.COPIED_UIFILE_NOT_AVAILABLE; } } } catch (IOException e) { ret = Error.TEMP_CREATION_ERROR; } } return ret; }
f2d8c4bd-de78-4263-8ecf-9577bfbb36f4
8
public E put(E obj, int x, int y, int z) throws ConstraintException { if (obj == null) { return null; } if (x > sideLength || y > sideLength || z > sideLength || x < 0 || y < 0 || z < 0) { throw new ConstraintException("Cannot place a data value at that point!"); } if (array[x][y][z] == null) { array[x][y][z] = obj; return null; } else { E temp = (E) array[x][y][z]; array[x][y][z] = obj; return (E) temp; } }
9b889047-66f8-40ed-9ae8-8e69d5c9e044
1
public int getUpperLeftY() { if (y1 > y2) { return y1; } else { return y2; } }
20cf51ab-1d2f-4df0-a966-dcbc059af2c2
8
public void checkLasers(){ for (Iterator<Laser> iterator = lasers.iterator(); iterator.hasNext(); ) { Laser b = iterator.next(); if(collisionCircle(getX(),getY(),h/2+h/4,(int)b.getX(),(int)b.getY(),2)&&b.kind!=kind){ health-=b.getDamage(); for(int y=0;y<3;y++){ if(b.kind==2) Alpha.fx.add(new Particles(new Color(255,0,0,(int)(255)),1,b.x,b.y,(Math.random()*.25),Math.random()*Math.toRadians(360),(b.speed/2*Math.random())+b.speed/2,0)); else if(kind==1) Alpha.fx.add(new Particles(new Color(0,255,255,(int)(255)),1,b.x,b.y,(Math.random()*.25),Math.random()*Math.toRadians(360),(b.speed/2*Math.random())+b.speed/2,0)); else Alpha.fx.add(new Particles(new Color(0,255,0,(int)(255)),1,b.x,b.y,(Math.random()*.25),Math.random()*Math.toRadians(360),(b.speed/2*Math.random())+b.speed/2,0)); } b.kill(); } if(b.kind==4&&health<=0) mined=true; } }
4145fd72-c473-4058-a462-7f43368dcc93
7
public static <GSource, GTarget> Collection<GTarget> translatedCollection(final Collection<GSource> items, final Translator<GSource, GTarget> translator) throws NullPointerException { if (items == null) throw new NullPointerException("items = null"); if (translator == null) throw new NullPointerException("translator = null"); return new AbstractCollection<GTarget>() { @Override public boolean add(final GTarget item2) { return items.add(translator.toSource(item2)); } @Override @SuppressWarnings ("unchecked") public boolean addAll(final Collection<? extends GTarget> items2) { return items.addAll(Collections.translatedCollection((Collection<GTarget>)items2, Translators.reverseTranslator(translator))); } @Override public boolean remove(final Object item2) { if (!translator.isTarget(item2)) return false; return items.remove(translator.toSource(item2)); } @Override @SuppressWarnings ("unchecked") public boolean removeAll(final Collection<?> items2) { return items.removeAll(Collections.translatedCollection((Collection<GTarget>)items2, Translators.reverseTranslator(translator))); } @Override @SuppressWarnings ("unchecked") public boolean retainAll(final Collection<?> items2) { return items.retainAll(Collections.translatedCollection((Collection<GTarget>)items2, Translators.reverseTranslator(translator))); } @Override public int size() { return items.size(); } @Override public void clear() { items.clear(); } @Override public boolean isEmpty() { return items.isEmpty(); } @Override public boolean contains(final Object item2) { if (!translator.isTarget(item2)) return false; return items.contains(translator.toSource(item2)); } @Override public Iterator<GTarget> iterator() { return Iterators.convertedIterator(Translators.toTarget(translator), items.iterator()); } }; }
844ecc54-3b2a-4d36-a922-64928fe88ade
0
private PieceMessage(ByteBuffer buffer, int piece, int offset, ByteBuffer block) { super(Type.PIECE, buffer); this.piece = piece; this.offset = offset; this.block = block; }
aefc5fd7-f48c-4edd-a8c1-0ef4e915c442
5
private void doBankCommand(Command command) throws RemoteException, RejectedException { CommandName inputCommand = command.getCommandName(); String userOrItemName = command.getUserOrItemName(); Float amount = command.getAmount(); account = bankobj.getAccount(clientname); switch (inputCommand) { case balance: System.out.println("balance: $" + account.getBalance()); break; case deleteAccount: clientname = null; bankobj.deleteAccount(userOrItemName); break; case deposit: account.deposit(amount); break; case getAccount: System.out.println(account); break; case withdraw: account.withdraw(amount); break; default: System.out.println("Illegal command."); break; } }
8fa979af-992a-41c5-b859-9f6c714b4bc2
8
public boolean bodyCall(Node[] args, int length, RuleContext context) { checkArgs(length, context); BindingEnvironment env = context.getEnv(); Node n1 = getArg(0, args, context); Node n2 = getArg(1, args, context); if (n1.isLiteral() && n2.isLiteral()) { Object v1 = n1.getLiteralValue(); Object v2 = n2.getLiteralValue(); Node diff = null; if (NumberUtil.isNumber(v1) && NumberUtil.isNumber(v2)) { if (v1 instanceof Float || v1 instanceof Double || v2 instanceof Float || v2 instanceof Double) { double dv1 = Double.parseDouble(v1.toString()); double dv2 = Double.parseDouble(v2.toString()); diff = Util.makeDoubleNode(dv1 - dv2); } else { long lv1 = Long.parseLong(v1.toString()); long lv2 = Long.parseLong(v2.toString()); diff = Util.makeLongNode(lv1 - lv2); } return env.bind(args[2], diff); } } // Doesn't (yet) handle partially bound cases return false; }
1d5f1589-f4c4-42dc-8bfe-7882e8a108b2
0
@FXML private void handleTextFieldAction() { target = addrField.getText(); }
39e2f7ed-c57a-480c-a7a7-ef042977fc01
8
public Unit getUnitAt(Position p) { if ( p.getRow() == 2 && p.getColumn() == 3 || p.getRow() == 3 && p.getColumn() == 2 || p.getRow() == 3 && p.getColumn() == 3 ) { return new StubUnit(GameConstants.ARCHER, Player.RED); } if ( p.getRow() == 4 && p.getColumn() == 4 ) { return new StubUnit(GameConstants.ARCHER, Player.BLUE); } return null; }
41e55c94-493b-4796-8d6f-a9851e0c1b20
2
protected List<Teleporter> getTeleporterList(int amount) { final List<Teleporter> teleports = new ArrayList<Teleporter>(); for (int i = 0; i < amount; i++) teleports.add(getTeleporter()); for (Teleporter tp : teleports) tp.setDestination(getRandomDestination(tp, teleports)); return teleports; }
6f56d8e9-c065-4f16-b010-39172dcc6a9e
1
public void deposit(int value) { if(value >= 0) { notifyPropertyChangeListeners(money, money + value); money += value; } else { throw new IllegalArgumentException("You can't deposit a negative number of dollars!"); } }
27be73b7-804c-4fae-b6d2-a69b4c81fed5
9
@Override public String toString() { String result = getClass().getSimpleName() + " "; if (name != null && !name.trim().isEmpty()) result += "name: " + name; if (city != null && !city.trim().isEmpty()) result += ", city: " + city; if (country != null && !country.trim().isEmpty()) result += ", country: " + country; if (foundationYear != null) result += ", foundationYear: " + foundationYear; if (stadium != null && !stadium.trim().isEmpty()) result += ", stadium: " + stadium; return result; }
1d8e9379-7171-41cf-be3f-81f6b1e26177
2
public static void clear() { try { root.clear(); String[] children = root.childrenNames(); for (int i = 0; i < children.length; i++) { Preferences node = root.node(children[i]); node.removeNode(); } root.sync(); } catch(BackingStoreException e) { vlog.error(e.getMessage()); } }
7a746010-1c93-4240-bf8f-6dc92e37bc95
0
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new BounceFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); }
a66189cb-65eb-4741-9c3f-5a15a3a4be2d
1
@Override public void adjust() { boolean enable = false; Duplicatable duplicatable = getTarget(Duplicatable.class); if (duplicatable != null) { enable = duplicatable.canDuplicateSelection(); } setEnabled(enable); }
7fc15760-fa4e-4972-9624-76f1740c64d8
1
public void removePush() { StructuredBlock[] subBlocks = getSubBlocks(); for (int i = 0; i < subBlocks.length; i++) subBlocks[i].removePush(); }
106b08dc-5bf0-466d-af5a-19a2ba81bab6
4
@EventHandler public void onInteract(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().hasPermission("decapitation.info") && event.getClickedBlock().getType() == Material.SKULL) { Skull s = (Skull) event.getClickedBlock().getState(); if (s.hasOwner()) { event.getPlayer().sendMessage(ChatColor.GREEN + "The head of " + s.getOwner()); } else { event.getPlayer().sendMessage(ChatColor.GREEN + "That head has no name attached"); } } }
d4bd59a7-3b18-457a-b439-105db0571340
4
Dimension getThumbDimensions(){ Dimension returnDim = null; switch(fullType){ case Original: returnDim = originalImage.thumbDimensions; case Filtered: returnDim = filteredImage.thumbDimensions; case Icon: returnDim = iconImage.thumbDimensions; default: returnDim = originalImage.thumbDimensions; } if(returnDim==null) returnDim = new Dimension(0,0); return returnDim; }
35c1d530-f7fb-493c-ba30-370c6b0daf76
2
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((wordid1 == null) ? 0 : wordid1.hashCode()); result = prime * result + ((wordid2 == null) ? 0 : wordid2.hashCode()); return result; }
20fd2865-a7ef-4bd5-808c-639dfd117101
7
static void dradf4(int ido, int l1, float[] cc, float[] ch, float[] wa1, int index1, float[] wa2, int index2, float[] wa3, int index3){ int i, k, t0, t1, t2, t3, t4, t5, t6; float ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; t0=l1*ido; t1=t0; t4=t1<<1; t2=t1+(t1<<1); t3=0; for(k=0; k<l1; k++){ tr1=cc[t1]+cc[t2]; tr2=cc[t3]+cc[t4]; ch[t5=t3<<2]=tr1+tr2; ch[(ido<<2)+t5-1]=tr2-tr1; ch[(t5+=(ido<<1))-1]=cc[t3]-cc[t4]; ch[t5]=cc[t2]-cc[t1]; t1+=ido; t2+=ido; t3+=ido; t4+=ido; } if(ido<2) return; if(ido!=2){ t1=0; for(k=0; k<l1; k++){ t2=t1; t4=t1<<2; t5=(t6=ido<<1)+t4; for(i=2; i<ido; i+=2){ t3=(t2+=2); t4+=2; t5-=2; t3+=t0; cr2=wa1[index1+i-2]*cc[t3-1]+wa1[index1+i-1]*cc[t3]; ci2=wa1[index1+i-2]*cc[t3]-wa1[index1+i-1]*cc[t3-1]; t3+=t0; cr3=wa2[index2+i-2]*cc[t3-1]+wa2[index2+i-1]*cc[t3]; ci3=wa2[index2+i-2]*cc[t3]-wa2[index2+i-1]*cc[t3-1]; t3+=t0; cr4=wa3[index3+i-2]*cc[t3-1]+wa3[index3+i-1]*cc[t3]; ci4=wa3[index3+i-2]*cc[t3]-wa3[index3+i-1]*cc[t3-1]; tr1=cr2+cr4; tr4=cr4-cr2; ti1=ci2+ci4; ti4=ci2-ci4; ti2=cc[t2]+ci3; ti3=cc[t2]-ci3; tr2=cc[t2-1]+cr3; tr3=cc[t2-1]-cr3; ch[t4-1]=tr1+tr2; ch[t4]=ti1+ti2; ch[t5-1]=tr3-ti4; ch[t5]=tr4-ti3; ch[t4+t6-1]=ti4+tr3; ch[t4+t6]=tr4+ti3; ch[t5+t6-1]=tr2-tr1; ch[t5+t6]=ti1-ti2; } t1+=ido; } if((ido&1)!=0) return; } t2=(t1=t0+ido-1)+(t0<<1); t3=ido<<2; t4=ido; t5=ido<<1; t6=ido; for(k=0; k<l1; k++){ ti1=-hsqt2*(cc[t1]+cc[t2]); tr1=hsqt2*(cc[t1]-cc[t2]); ch[t4-1]=tr1+cc[t6-1]; ch[t4+t5-1]=cc[t6-1]-tr1; ch[t4]=ti1-cc[t1+t0]; ch[t4+t5]=ti1+cc[t1+t0]; t1+=ido; t2+=ido; t4+=t3; t6+=ido; } }
7f95afd7-b3a1-424d-8072-2d3ae5ffe19f
4
@Test public void missingSubPatternReplacementTest() throws URISyntaxException { patternReplacer = new PatternReplacer( "{scheme:3} {host:0} {port} {path:0} {fragment:0}") .setScheme(SCHEME_PATTERN) .setHost( HOST_PATTERN ) .setPath( PATH_PATTERN ) .setFragment( FRAGMENT_PATTERN ); try { patternReplacer.populate(PATTERN_MATCH_URI); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { assertEquals("Subpattern 3 does not exist in "+SCHEME_PATTERN+" matching http", e.getMessage()); } patternReplacer = new PatternReplacer( "{scheme:0} {host:3} {port} {path:0} {fragment:0}", patternReplacer); try { patternReplacer.populate(PATTERN_MATCH_URI); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { assertEquals("Subpattern 3 does not exist in "+HOST_PATTERN+" matching bax.example.com", e.getMessage()); } // patternReplacer = new PatternReplacer( // "{scheme:0} {host:0} {port:3} {path:0} {fragment:0}", patternReplacer); // try { // patternReplacer.populate(PATTERN_MATCH_URI); // fail("Should have thrown IllegalArgumentException"); // } catch (IllegalArgumentException e) { // assertEquals("Subpattern 3 does not exist in "+PORT_PATTERN+" matching bax.example.com", // e.getMessage()); // } patternReplacer = new PatternReplacer( "{scheme:0} {host:0} {port} {path:3} {fragment:0}", patternReplacer); try { patternReplacer.populate(PATTERN_MATCH_URI); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { assertEquals("Subpattern 3 does not exist in "+PATH_PATTERN+" matching /foo/foo2", e.getMessage()); } patternReplacer = new PatternReplacer( "{scheme:0} {host:0} {port} {path:0} {fragment:3}", patternReplacer); try { patternReplacer.populate(PATTERN_MATCH_URI); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { assertEquals("Subpattern 3 does not exist in "+FRAGMENT_PATTERN+" matching bar", e.getMessage()); } }
c67c7edb-48ca-4259-b774-0cf11c0370f0
3
@Override public void printWay() { ArrayList<Coordinate> finderWay = new ArrayList<Coordinate>(); while(finderDuo_1.fHistory.top > 0 ) finderWay.add(finderDuo_1.fHistory.popLocation()); for(int i = finderWay.size()-1 ; i >= 0 ; i--) System.out.println(finderWay.get(i)); while(finderDuo_2.fHistory.top > 0 ) System.out.println(finderDuo_2.fHistory.popLocation()); }
04657e61-71b6-4ba2-8127-24b85325f495
6
private ArrayList<String> validPossible(String s) { ArrayList<String> possible = new ArrayList<String>(); if (s.length() >= 1) { possible.add(s.substring(0, 1)); } if (s.length() >= 2) { String xx = s.substring(0, 2); if (!xx.startsWith("0")) { possible.add(s.substring(0, 2)); } } if (s.length() >= 3) { String xx = s.substring(0, 3); if (Integer.valueOf(xx) <= 255 && !xx.startsWith("0")) { possible.add(xx); } } return possible; }
820735cf-729f-4869-b77b-94e88a782f3b
5
private static List<ItemStack> parseItems(List<String> raw) { List<ItemStack> result = new ArrayList<ItemStack>(raw.size()); for (String string : raw) { String[] split = string.split(","); if (split.length == 0 || split.length == 1) { result.add(new ItemStack(Integer.parseInt(string))); } else if (split.length == 2) { result.add(new ItemStack(Integer.parseInt(split[0]), Integer .parseInt(split[1]))); } else if (split.length == 3) { result.add(new ItemStack(Integer.parseInt(split[0]), Integer .parseInt(split[1]), (short) 0, Byte .parseByte(split[2]))); } } return result; }
2be38cc5-995e-4489-88b7-f206b5cb72e7
5
public static void main(String[] args) { IConsumes BMW = new Car_luxury("Registered E92"); IConsumes Oldsmobile = new Car_oldies("Unregistered Alero"); Car Lastun = new Car_oldies("Unregistered Dacia"); Car Ferrari = new Car_luxury("Registered 599 GTO"); Car_luxury Mercedes = new Car_luxury("Registered Mercedes G63AMG"); try { BMW.consumes(); BMW.pollutes(); } catch (IssuesException e) { System.out.println("Exception thrown: " + e.getMessage()); } try { Oldsmobile.consumes(); Oldsmobile.pollutes(); } catch (IssuesException e) { System.out.println("Exception thrown: " + e.getMessage()); } try { Mercedes.pollutes(); Mercedes.consumes(); System.out.println("^^ fooarte putin, doar 20l/100km"); }catch (IssuesException e){ System.out.println("Exception thrown: " + e.getMessage()); } try { ((Car_oldies) Lastun).pollutes(); }catch (IssuesException e){ System.out.println("Exception thrown: " + e.getMessage()); } Lastun.setName("Dacia 500"); System.out.println("Numele nou este: " + Lastun.getName()); try { System.out.println("Numele vechi: " + Ferrari.getName()); Ferrari.setName("Registered 458 Italia"); System.out.println("Numele nou: " + Ferrari.getName()); }catch(Exception e){ e.printStackTrace(); } }
34d04568-ed16-45fd-9916-fb7987c77072
7
public void processMyoEvent(MyoEvent me){ //System.out.println(me.frame.pose); if(me.frame.pose.contains("fingersSpread")) { System.out.println("All off received"); reset(); /* while(track.size() > 0) { for(int i = 0; i < track.size(); i++) { track.remove(track.get(i)); } } for(int i = 0; i < 16; i ++) { for(int j = 0; j < 16; j ++) { track.add(makeEvent(noteOff, 9, instruments[i], 100, j)); } } */ } else if(me.frame.pose.contains("waveIn")) { currentInstrument -= 1; if(currentInstrument == -1) { currentInstrument = 15; } System.out.println("currentInstrument = " + currentInstrument); } else if(me.frame.pose.contains("waveOut")) { currentInstrument += 1; if(currentInstrument == 16) { currentInstrument = 0; } System.out.println("currentInstrument = " + currentInstrument); } else if(me.frame.pose.contains("fist")){ //System.out.println("currentInstrument = " + currentInstrument); int tick = getTick(); setNote(currentInstrument, tick); if(seqButtons[currentInstrument][tick].isSelected() == true) { seqButtons[currentInstrument][tick].setSelected(false); } else { seqButtons[currentInstrument][tick].setSelected(true); } } else { // do nothing } //System.out.println("currentInstrument = " + currentInstrument); }
70d8b47c-e733-4369-9922-98c299703af5
8
public final void quant(final float[] lsp, final float[] qlsp, final int order, final Bits bits) { int i; float tmp1, tmp2; int id; float[] quant_weight = new float[MAX_LSP_SIZE]; for (i=0;i<order;i++) qlsp[i]=lsp[i]; quant_weight[0] = 1/(qlsp[1]-qlsp[0]); quant_weight[order-1] = 1/(qlsp[order-1]-qlsp[order-2]); for (i=1;i<order-1;i++) { tmp1 = 1/(qlsp[i]-qlsp[i-1]); tmp2 = 1/(qlsp[i+1]-qlsp[i]); quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2; } for (i=0;i<order;i++) qlsp[i]-=(.3125*i+.75); for (i=0;i<order;i++) qlsp[i]*=256; id = lsp_quant(qlsp, 0, high_lsp_cdbk, 64, order); bits.pack(id, 6); for (i=0;i<order;i++) qlsp[i]*=2; id = lsp_weight_quant(qlsp, 0, quant_weight, 0, high_lsp_cdbk2, 64, order); bits.pack(id, 6); for (i=0;i<order;i++) qlsp[i]*=0.0019531; for (i=0;i<order;i++) qlsp[i]=lsp[i]-qlsp[i]; }
d3c57bfd-a4e9-449d-adad-43e55bf66a8a
9
public static void printHandHidden(Hand hand) { // print hand header ArrayList<String> attrs = new ArrayList<String>(3); if(!hand.getDescription().equals("")) attrs.add(hand.getDescription()); if(hand.getBet() > 0.0f) attrs.add("bet: $" + hand.getBet()); output.println(hand.getPlayer().getName() + "\'s hand (" + join(attrs, ", ") + ")"); if(UNICODE) { // create a "buffer" to contain the ASCII hand List<Card> cards = hand.getCards(); StringBuilder[] buffer; buffer = new StringBuilder[5]; // card height is 5 for(int i=0; i<5; i++) buffer[i] = new StringBuilder(); try { printCardToBuffer(buffer, cards.get(0)); for(int i=1; i<cards.size(); i++) printHiddenCardToBuffer(buffer); } catch (Exception e) { e.printStackTrace(); } // hand buffer populated, print to output stream for(StringBuilder sb : buffer) output.println(sb.toString()); } else { boolean first=true; for(Card c : hand.getCards()) { if(first) { output.print(rank(c) + suit(c) + " "); first = false; } else{ output.print("## "); } } output.println(); } }
9768a0e3-33d7-4934-95ab-3892326e8f5d
9
public int[] twoSum(int[] numbers, int target) { int[] clone = Arrays.copyOf(numbers, numbers.length); Arrays.sort(clone); int i = 0, j = clone.length - 1; while (clone[i] + clone[j] != target) { if (clone[i] + clone[j] > target) { j--; } else if (clone[i] + clone[j] < target) { i++; } } int index1 = -1, index2 = -1; for (int k = 0; k < numbers.length; k++) { if (numbers[k] == clone[i]) { index1 = k; } } for (int k = 0; k < numbers.length; k++) { if (numbers[k] == clone[j] && index1 != k) { index2 = k; } } if (index1 < index2) { return new int[]{index1 + 1, index2 + 1}; } else { return new int[]{index2 + 1, index1 + 1}; } }
3a96fe8b-2666-4d94-a5b8-a02eeec8eedf
7
public boolean isWhitelistedItem(ItemStack item, String group) { List<String> whitelist = plugin.getWhitelistedItems(group); @SuppressWarnings("deprecation") int dataValue = item.getTypeId(); @SuppressWarnings("deprecation") int damageValue = item.getData().getData(); for (String whitelistedItem : whitelist) { Integer dataValueBlack = null; Integer damageValueBlack = null; if (whitelistedItem.contains(":")) { // For items such as wool. 35:1 String[] temp = whitelistedItem.split(":"); dataValueBlack = Integer.parseInt(temp[0]); damageValueBlack = Integer.parseInt(temp[1]); } else { dataValueBlack = Integer.parseInt(whitelistedItem); } if (dataValueBlack != null && damageValueBlack != null) { if (dataValue == dataValueBlack && damageValue == damageValueBlack) { return true; } } else { if (dataValue == dataValueBlack) { return true; } } } return false; }
403b29d3-f065-4937-a87d-546a15e5c3ac
5
@Override public <X> X getScreenshotAs(OutputType<X> outType) { try { if (driver instanceof FirefoxDriver) { return ((FirefoxDriver) driver).getScreenshotAs(outType); } else if (driver instanceof ChromeDriver) { return ((ChromeDriver) driver).getScreenshotAs(outType); } else if (driver instanceof RemoteWebDriver) { return ((RemoteWebDriver) driver).getScreenshotAs(outType); } else if (driver instanceof InternetExplorerDriver) { return ((InternetExplorerDriver) driver).getScreenshotAs(outType); } else { return null; } } catch (Exception e) { } return null; }
9af2c5ce-ee64-4164-8c18-d6f9005a0445
2
public static Properties getProperties() { if (config == null) { // Create once config = new Properties(); try { config.load(Configuration.class.getResourceAsStream(Constants.CONFIG_FILENAME)); } catch (IOException ex) { Logger.getLogger(Configuration.class.getName()).log(Level.INFO, null, ex); } } return config; }
af42d038-9a86-4b39-8111-99ec884bcadf
5
private static void ReadAttrisGrp(Element attrisgrpnode, GeneratorAttriGrp attrisgrp) { NodeList nodelist; Node node; Element elem; String name; int i; nodelist = attrisgrpnode.getChildNodes(); for (i = 0; i < nodelist.getLength(); i++) { node = nodelist.item(i); //find a attribute node if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(ATTRIBUTE)) { elem = (Element)node; GeneratorAttri attri = new GeneratorAttri(elem); attrisgrp.addAttri(attri); } //find a attributes group node if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(ATTRIBUTESGRP)) { elem = (Element)node; name = elem.getAttribute("name"); GeneratorAttriGrp grp = new GeneratorAttriGrp(name); attrisgrp.addAttriGrp(grp); ReadAttrisGrp(elem, grp); } } }