method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
07dd16cb-ff88-4754-b325-5b7e7f5abc3f
7
protected Operation [] getOptimalOperations(BayesNet bayesNet, Instances instances, int nrOfLookAheadSteps, int nrOfGoodOperations) throws Exception { if (nrOfLookAheadSteps == 1) { // Abbruch der Rekursion Operation [] bestOperation = new Operation [1]; bestOperation [0] = getOptimalOperation(bayesNet, instances); return(bestOperation); // Abbruch der Rekursion } else { double bestDeltaScore = 0; double currentDeltaScore = 0; Operation [] bestOperation = new Operation [nrOfLookAheadSteps]; Operation [] goodOperations = new Operation [nrOfGoodOperations]; Operation [] tempOperation = new Operation [nrOfLookAheadSteps-1]; goodOperations = getGoodOperations(bayesNet, instances, nrOfGoodOperations); for (int i = 0; i < nrOfGoodOperations; i++) { if (goodOperations[i] != null) { performOperation(bayesNet, instances, goodOperations [i]); tempOperation = getOptimalOperations(bayesNet, instances, nrOfLookAheadSteps-1, nrOfGoodOperations); // rekursiver Abstieg currentDeltaScore = goodOperations [i].m_fDeltaScore; for (int j = 0; j < nrOfLookAheadSteps-1; j++) { if (tempOperation [j] != null) { currentDeltaScore += tempOperation [j].m_fDeltaScore; } } performOperation(bayesNet, instances, getAntiOperation(goodOperations [i])); if (currentDeltaScore > bestDeltaScore) { bestDeltaScore = currentDeltaScore; bestOperation [0] = goodOperations [i]; for (int j = 1; j < nrOfLookAheadSteps; j++) { bestOperation [j] = tempOperation [j-1]; } } } else i=nrOfGoodOperations; } return(bestOperation); } } // getOptimalOperations
c30c0336-c57b-4852-a7ec-5c1f8a40e2f1
3
public static void main(String[] args) { String configFile = "snpEff.config"; String genomeToTest = ""; // Parse command line arguments if (args.length <= 0) { System.err.println("Usage: TestCaseCompareCds genomeToTest\n"); System.exit(-1); } // Command line argument parsing if (args[0].equals("-c")) { configFile = args[1]; genomeToTest = args[2]; } else if (args[0].equals("-d")) { debug = verbose = true; genomeToTest = args[1]; } else { genomeToTest = args[0]; } TestCompareCds.test(genomeToTest, configFile); }
e20dc9d1-412f-4b47-90be-fb09bcb4d062
4
@Override public void run() { try { String line; while (!isInterrupted()) { line = in.readLine(); if (line != null) try { queue.offer(line); } catch (NullPointerException npe) { System.out.println("failed message offer"); } else close(); } } catch (IOException exc) { close(); } }
0113b754-38e0-4632-8750-2c590b889b50
9
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int length = to.length(); char[] circle = new char[length]; /* * First fill the circle buffer with as many characters as are in the * to string. If we reach an early end, bail. */ for (i = 0; i < length; i += 1) { c = next(); if (c == 0) { return false; } circle[i] = c; } /* * We will loop, possibly for all of the remaining characters. */ for (;;) { j = offset; b = true; /* * Compare the circle buffer with the to string. */ for (i = 0; i < length; i += 1) { if (circle[j] != to.charAt(i)) { b = false; break; } j += 1; if (j >= length) { j -= length; } } /* * If we exit the loop with b intact, then victory is ours. */ if (b) { return true; } /* * Get the next character. If there isn't one, then defeat is ours. */ c = next(); if (c == 0) { return false; } /* * Shove the character in the circle buffer and advance the * circle offset. The offset is mod n. */ circle[offset] = c; offset += 1; if (offset >= length) { offset -= length; } } }
f7020f1f-74ab-44a2-80da-8226b05173ab
4
public Matrix plus(Matrix m) { //Once again test the boudns of each matrix. if(this.numRows != m.numRows || this.numColumns != m.numColumns){ System.out.println("Error: matrix arguments are not compatible for addition!"); return null; // placeholder } //Perform normative addition int[][] result = new int[this.numRows][this.numColumns]; for(int r = 0; r < this.numRows; r++) for(int c = 0; c < this.numColumns; c++) result[r][c] = this.data[r][c] + m.data[r][c]; return new Matrix(result); }
4c892a6f-370d-4e33-bfe9-926e616d0aed
9
protected Notification tryRegister(Iterable<? extends Converter> converters) { Notification notification = new Notification(); if(converters == null) return notification; // XXX can't use foreach here, since the hasNext() and next() operations themselves may fail try { Map<ConverterType, Converter> temp = new DependentConverterMap(getConverterMap()); Iterator<? extends Converter> iterator = converters.iterator(); // if hasNext() fails, there's no iterating to do; snitch and move on while(iterator.hasNext()) { try { // an individual next() may fail, but not necessarily all them will; // keep going and store all mishaps Converter converter = iterator.next(); temp.put(converter.getType(), converter); } catch(MultipleCausesException e) { notification.add(e.getCauses()); } catch(Exception e) { notification.add(e); } } if(notification.hasErrors()) // somebody blew up return notification; // everything worked so far... getConverterMap().putAll(temp); } catch(MultipleCausesException e) { notification.add(e.getCauses()); } catch(Exception e) { notification.add(e); } return notification; }
d53be42c-a76e-45ad-b6af-10d4116af257
9
public Rover(Integer x, Integer y, String direction) { super(); if (x == null) { throw new IllegalArgumentException("X co-ordinate can't be NULL"); } if (x < this.minBorder || x > this.maxBorder) { throw new IllegalArgumentException("X co-ordinate must be within 0 - 9"); } if (y == null) { throw new IllegalArgumentException("Y co-ordinate can't be NULL"); } if (y < this.minBorder || y > this.maxBorder) { throw new IllegalArgumentException("Y co-ordinate must be within 0 - 9"); } if (direction == null || direction.isEmpty()) { throw new IllegalArgumentException("Direction can't be NULL or Empty"); } Set<String> directions = new HashSet<String>(Arrays.asList(new String[]{ "N", "E", "S", "W" })); if (!directions.contains(direction)) { throw new IllegalArgumentException("Direction (case sensitive) must be in " + directions); } this.x = x; this.y = y; this.direction = direction; initDirDelTa(); initMappings(); }
e27c3426-0eff-449f-9264-bc406090a019
3
public TextLogger(String filename) { datestampformat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss"); timestampformat = new SimpleDateFormat("'['H':'mm':'ss'] '"); cal = Calendar.getInstance(); datestamp = datestampformat.format(cal.getTime()); try { if (writer != null) writer.close(); file = new File(filename); dir = file.getParentFile(); if (!dir.exists()) dir.mkdirs(); writer = new BufferedWriter(new FileWriter(file, true)); writer.write("-"); writer.newLine(); writer.write(datestamp); writer.newLine(); } catch (IOException e) { System.out.println(e.getMessage()); } }
845f92e4-3cd7-431e-a856-218323397dbb
1
public static boolean createFile(File file) throws IOException { if(! file.exists()) { makeDir(file.getParentFile()); } return file.createNewFile(); }
334c9315-69a8-4aac-82d9-1f227367effa
2
public double[][] getGridDydx2(){ double[][] ret = new double[this.nPoints][this.mPoints]; for(int i=0; i<this.nPoints; i++){ for(int j=0; j<this.mPoints; j++){ ret[this.x1indices[i]][this.x2indices[j]] = this.dydx2[i][j]; } } return ret; }
02786427-e6c4-44cf-ad78-90fbd9ca2d78
7
static double incompleteBetaFraction2( double a, double b, double x ) { double xk, pk, pkm1, pkm2, qk, qkm1, qkm2; double k1, k2, k3, k4, k5, k6, k7, k8; double r, t, ans, z, thresh; int n; k1 = a; k2 = b - 1.0; k3 = a; k4 = a + 1.0; k5 = 1.0; k6 = a + b; k7 = a + 1.0;; k8 = a + 2.0; pkm2 = 0.0; qkm2 = 1.0; pkm1 = 1.0; qkm1 = 1.0; z = x / (1.0-x); ans = 1.0; r = 1.0; n = 0; thresh = 3.0 * MACHEP; do { xk = -( z * k1 * k2 )/( k3 * k4 ); pk = pkm1 + pkm2 * xk; qk = qkm1 + qkm2 * xk; pkm2 = pkm1; pkm1 = pk; qkm2 = qkm1; qkm1 = qk; xk = ( z * k5 * k6 )/( k7 * k8 ); pk = pkm1 + pkm2 * xk; qk = qkm1 + qkm2 * xk; pkm2 = pkm1; pkm1 = pk; qkm2 = qkm1; qkm1 = qk; if( qk != 0 ) r = pk/qk; if( r != 0 ) { t = Math.abs( (ans - r)/r ); ans = r; } else t = 1.0; if( t < thresh ) return ans; k1 += 1.0; k2 -= 1.0; k3 += 2.0; k4 += 2.0; k5 += 1.0; k6 += 1.0; k7 += 2.0; k8 += 2.0; if( (Math.abs(qk) + Math.abs(pk)) > big ) { pkm2 *= biginv; pkm1 *= biginv; qkm2 *= biginv; qkm1 *= biginv; } if( (Math.abs(qk) < biginv) || (Math.abs(pk) < biginv) ) { pkm2 *= big; pkm1 *= big; qkm2 *= big; qkm1 *= big; } } while( ++n < 300 ); return ans; }
680f199c-5411-4f17-b861-75d65a20ecf1
1
public void doTest() { props.put("newKey1", "newVal1"); props.put("newKey2", "newVal2a=newVal2b"); props.put("newKey3", "items " + String.valueOf(props.size()+1) ); Iterator iter = props.entrySet().iterator(); while(iter.hasNext()) { Map.Entry entry = (Map.Entry)iter.next(); String key = (String)entry.getKey(); String val = (String)entry.getValue(); System.out.println(">>" + key + "<<" + val + ">>"); } }
2987769e-d59a-4d9b-b81c-9864c7589045
6
public static void main(final String[] args) { final int x = 1000; for (int i = 1; i < (x + 1); i++) for (int j = 1; j < (x + 1); j++) for (int z = 0; z < x; z++) { final int k = j + z; if ((((i * i) + (j * j)) == (k * k)) && (i < j)) if ((i + j + k) == x) // System.out.println("A: " + i + " B: " + j + " C: " + k); // System.out.println("A^2: " + i * i + " B^2: " + j * j + " C^2: " + k * k); System.out.println(i * j * k); } }
edea74ed-4e69-4ccc-abf3-fd58745e1b81
0
public String toString() { return this.operatingSystem.toString() + "-" + this.browser.toString(); }
0e9ae727-4b85-4bef-8617-45b6b27890be
1
public void removeKeyListener(KeyListener l) { if(l == null) { return; } this.keyListener = null; }
631b1a7c-e2c8-4785-903b-4c5ee2ea9343
9
Space[] won() { int n = numToWin - 1; if (lastSpaceMoved == null) return null; int[] pos = lastSpaceMoved.getPos(); for (int i = 0, rowInd = pos[0]; i <= n; i++, rowInd = pos[0] - i) for (int j = 0, colInd = pos[1]; j <= n; j++, colInd = pos[1] - j) { boolean outOfBounds = rowInd < 0 || colInd < 0 || rowInd + n >= rows || colInd + n >= cols; if (outOfBounds) continue; ExpBoard_B sub = new ExpBoard_B(this, rowInd, colInd, new int[] { i, j }); Space[] winningSet = sub.subWon(); if (winningSet != null) { for (Space sp : winningSet) sp.setPos(sp.getRow() + rowInd, sp.getCol() + colInd); return winningSet; } } return null; }
d28e9706-a333-4f3e-89db-616ca200dab1
0
private String escapeXMLAttribute(String text) { text = StringTools.replace(text, "&", "&amp;"); text = StringTools.replace(text, "<", "&lt;"); text = StringTools.replace(text, "\"", "&quot;"); text = StringTools.replace(text, ">", "&gt;"); return text; }
0aed729f-78d9-4767-b755-dd0dfefb22eb
2
public static void makeRandomDouble(Matrix matrix) throws MatrixIndexOutOfBoundsException { int rows = matrix.getRowsCount(); int cols = matrix.getColsCount(); double temp = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { // fill with random values temp = roundNumber(Math.random() * maxNumber, accuracy).doubleValue(); matrix.setValue(i, j, temp); } } }
0aab45df-2797-41db-acc4-8de61a47f1c0
0
public int size() { return this.length; }
1556d1b5-ee7b-4bf6-ae71-ff846f1bc0f1
0
@Override public String getErrorPath() { System.out.println("getErrorPath"); return super.getErrorPath(); }
c733d744-66bd-4fed-aa29-1ba9cf275762
6
public void handlePackReply(Node sender, Node receiver, PackReplyOldBetEtx message) { // o sink nao deve manipular pacotes do tipo Relay if(this.ID == message.getSinkID()){ return; } double etxToNode = getEtxToNode(message.getFwdID()); // necessaria verificacao de que o no ja recebeu menssagem de um // determinado descendente, isso e feito para evitar mensagens // duplicadas. // Se o nodo ainda nao recebeu menssagem de um descendente ele // deve 'processar' (recalcular o sbet) e propagar o pacote // desse descendente para que os outros nodos facam o mesmo if (!sons.contains(message.getSenderID()) && (message.getETX() > getEtxPath()) && (message.getSendToNodes().contains(this.ID)) /*(message.getSendTo() == this.ID)*/) { sons.add(message.getSenderID()); // se o nodo faz essa operacao ele eh relay this.setColor(Color.CYAN); setRole(NodeRoleOldBetEtx.RELAY); processBet(message); message.setSendTo(getNextHop()); message.setFwdID(this.ID); message.setSendToNodes(neighbors); TimerFwdReplyOldBetEtx fwdReply = new TimerFwdReplyOldBetEtx(message); fwdReply.startRelative(1, this); } // Uma mensagem foi recebida pelos ancestrais logo devo analisar se e o meu nextHop if (message.getETX() + etxToNode <= getEtxPath()){ if (message.getsBet() > getNeighborMaxSBet()) { //System.out.println("Antes\n"+this); setNeighborMaxSBet(message.getsBet()); setNextHop(message.getSenderID()); //System.out.println("Depois\n"+this+"\n\n"); } message = null; } }
b8fa1282-c1ab-452d-8b0f-6074f911a49e
3
public DisplayMode findFirstCompatibleMode(DisplayMode modes[]){ DisplayMode goodModes[] = vc.getDisplayModes(); for(int x=0;x<modes.length;x++){ for(int y=0;y<goodModes.length;y++){ if(displayModesMatch(modes[x], goodModes[y])){ return modes[x]; } } } return null; }
2d85d51e-e6d9-4e9f-9089-03d9679d2c0b
0
@Override public final boolean isDebug() { return debug; }
2193c569-fcca-45ec-aa32-69de4abbfcde
8
private String getPropertyValue(Properties properties, String key) { String value = properties.getProperty(key); if (!key.contains("$") && (value == null || !value.contains("$"))) { return value; } else { if (key.contains("$")) { value = key; } String[] array = value.split("\\$"); for (int i = 0; i < array.length; i++) { String str = array[i]; if (str.length() > 0) { str = str.substring(str.indexOf("{") + 1, str.indexOf("}")); String tempValue = getPropertyValue(properties, str); if (tempValue != null) { if (!tempValue.contains("$")) { value = value.replace("${" + str + "}", tempValue); } } } } properties.setProperty(key, value); return value; } }
84c5e0c3-1939-40f1-9766-d8b395754190
8
public void menuAction(JMenu selectMenu) { MainFrame mainFrame = MainFrame.getInstance(); AttdFrame workingFrame = mainFrame.getCurrentFrame(); workingFrame.setVisible(false); for (int i = 0; i < menu.length; i++) { if (menu[i].equals(selectMenu)) { switch(i) { case 0: mainFrame.setCurrentFrameEditCourse(); break; case 1: mainFrame.setCurrentFrameEditStudent(); break; case 2: mainFrame.setCurrentFrameCourseEnroll(); break; case 3: mainFrame.setCurrentFrameAttendance(); break; case 4: mainFrame.setCurrentFrameShowClassAR(); break; case 5: mainFrame.setCurrentFrameShowClassRP(); break; default: break; } break; //exit loop } } workingFrame = mainFrame.getCurrentFrame(); workingFrame.display(); }
74c8e05b-41e7-4d25-a3c3-d61b4990fe33
0
public String getUsername() { return username; }
eacbb2b4-999f-41c1-a412-0151fac98e39
7
public int compare(TradeOrder order1, TradeOrder order2) { if ((order1.isMarket()) && (order2.isMarket())) { return 0; } else if ((order1.isMarket()) && (order2.isLimit()) || (order1.isLimit()) && (order2.isMarket())) { return -1 * (int) Math.random() * 99; //Fun random negative value (kind of unnecessary, but what's compsci without some fun? :P ) } if (this.asc) { return (int) Math.round(100D * order1.getPrice()) - (int) Math.round(100D * order2.getPrice()); } return (int) Math.round(100D * order2.getPrice()) - (int) Math.round(100D * order1.getPrice()); }
5e274ade-06c3-468b-9741-25c0567d3657
1
public void setSalary(double newSalary) { if(newSalary >= 0.0) { salary = newSalary; } }
27593123-e4f1-428a-8bdc-39e5bf065270
4
@Override public Map<String, String> getParsedResults() { if (!resultingMap.isEmpty()) { return resultingMap; } String[] lines = stringBuilder.toString().split("\n"); for (String line : lines) { line = line.trim(); if (line.startsWith("时间:")) { parseStartAndEndTime(line.substring("时间:".length())); } else if (line.startsWith("地点:")) { resultingMap.put("address", line.substring("地点:".length())); } } return resultingMap; }
adb99e54-af3a-4e57-8d06-1e64ad814335
9
private void reduce_0(int reduction) throws IOException, LexerException, ParserException { switch(reduction) { case 0: /* reduce AFactorExpr */ { ArrayList<Object> list = new0(); push(goTo(0), list, false); } break; case 1: /* reduce AMaisExpr */ { ArrayList<Object> list = new1(); push(goTo(0), list, false); } break; case 2: /* reduce ASubtracaoExpr */ { ArrayList<Object> list = new2(); push(goTo(0), list, false); } break; case 3: /* reduce ATermFactor */ { ArrayList<Object> list = new3(); push(goTo(1), list, false); } break; case 4: /* reduce AMultiplicacaoFactor */ { ArrayList<Object> list = new4(); push(goTo(1), list, false); } break; case 5: /* reduce ADivisaoFactor */ { ArrayList<Object> list = new5(); push(goTo(1), list, false); } break; case 6: /* reduce ARestoFactor */ { ArrayList<Object> list = new6(); push(goTo(1), list, false); } break; case 7: /* reduce AInteiroTerm */ { ArrayList<Object> list = new7(); push(goTo(2), list, false); } break; case 8: /* reduce AExprTerm */ { ArrayList<Object> list = new8(); push(goTo(2), list, false); } break; } }
b98a6377-ff7c-4780-8860-a70dfb38c7a3
3
public List<File> filterDirectories() { List<File> f = new ArrayList<File>(); for (String s : l) { File sf = new File(s); if (sf.isDirectory() && sf.exists()) { f.add(sf); } } return f; }
a05c7a4f-7b93-40ce-bba9-4c5f449c3cf8
1
public static boolean isTheft(int s) { if(s==53185) return true; return false; }
bf927325-2780-4f03-8054-af980b577277
7
public void clicked() // changes the color of the buttons and if [x][y] is // "0" set the label to nothing { for (int x = 0; x < row; x++) { for (int y = 0; y < col; y++) { if (checkwinbool[x][y] == true && flag[x][y] == false && bomb[x][y] == false) table[x][y].setBackground(Color.darkGray); if (flag[x][y] == false && surroundingBombs(x, y) == 0) table[x][y].setLabel(""); } } }
bb5a81b0-6075-4c75-abe1-bb81063ff5e2
3
public void draw(Graphics g){ if(kind==1) g.setColor(new Color(0,255,255,(int)(alpha*255))); else if(kind==2) g.setColor(new Color(255,0,255,(int)(alpha*255))); else if(kind==4) g.setColor(new Color(0, 255, 0, (int) (alpha * 255))); else g.setColor(new Color(204, 204, 255, (int) (alpha * 255))); g.drawLine((int)x,(int)y,(int)(x-deltax*10),(int)(y-deltay*10)); }
851c3a19-8697-4e50-858f-0dfa64fef13c
0
@Override public void applyTemporaryToCurrent() {cur = tmp;}
e43399ad-b27d-4848-adaa-0ac4dfbd4bff
6
public ArrayList<Node> generateDoubleStart(int k, int type){ ArrayList<Node> nodes = new ArrayList<Node>(); for(int i =0;i<2*k;i++) { nodes.add(new Node(i)); } Link link; // Create first star with centre node k-1 for(int i=0;i<k-1;i++) { link = new Link(nodes.get(i)); nodes.get(k-1).addLink(link); link = new Link(nodes.get(k-1)); nodes.get(i).addLink(link); } // Create second start with centre node (2*k) - 1 for(int i=k;i<(2*k)-1;i++) { link = new Link(nodes.get(i)); nodes.get((2*k)-1).addLink(link); link = new Link(nodes.get((2*k)-1)); nodes.get(i).addLink(link); } // Connect stars switch (type) { case 0: // center centre link = new Link(nodes.get(k-1)); nodes.get((2*k)-1).addLink(link); link = new Link(nodes.get((2*k)-1)); nodes.get(k-1).addLink(link); break; case 1: // leaf leaf link = new Link(nodes.get(0)); nodes.get(k).addLink(link); link = new Link(nodes.get(k)); nodes.get(0).addLink(link); break; case 2: // leaf centre link = new Link(nodes.get(0)); nodes.get((2*k)-1).addLink(link); link = new Link(nodes.get((2*k)-1)); nodes.get(0).addLink(link); } return nodes; }
35960287-6ae2-4794-9f97-9fef4f82d431
0
public GameCanvas(ProBotGame game) { this.game = game; setIgnoreRepaint(true); setFocusable(false); }
736f342b-1f2f-4e68-9c94-37b0b2d12016
5
private void setConfig() { HashMap<String,Object> pl = null; Yaml yamlCfg = new Yaml(); Reader reader = null; try { reader = new FileReader("plugins/Clans/Config.yml"); } catch (final FileNotFoundException fnfe) { System.out.println("Config.YML Not Found!"); try{ String strManyDirectories="plugins/Clans"; boolean success = (new File(strManyDirectories)).mkdirs(); }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } } finally { if (null != reader) { try { pl = (HashMap<String,Object>)yamlCfg.load(reader); reader.close(); } catch (final IOException ioe) { System.err.println("We got the following exception trying to clean up the reader: " + ioe); } } } if(pl != null) { HashMap<String,Object> General = (HashMap<String,Object>)pl.get("General"); //General Currency = (int) General.get("Currency"); AllowTKToggle = (boolean) General.get("Allow TK Toggle"); TeamTKDefault = (boolean) General.get("Team TK Default"); AllowCapes = (boolean) General.get("Allow Capes"); HashMap<String,Object> Chat = (HashMap<String,Object>)pl.get("Chat"); //Chat UseTags = (boolean) Chat.get("Use Tags"); TagFormat = (String) Chat.get("Tag Format"); MessageFormat = (String) Chat.get("Message Format"); HashMap<String,Object> Areas = (HashMap<String,Object>)pl.get("Areas"); //Areas UseAreas = (boolean) Areas.get("Use Areas"); AreaMaxSize = (int) Areas.get("Max Size"); CapturableAreas = (boolean) Areas.get("Capturable"); AntiTNTInAreas = (boolean) Areas.get("No TNT Damage"); EnemyBedReset = (boolean) Areas.get("Enemy Bed Reset"); AllowUpgrades = (boolean) Areas.get("Allow Upgrades"); UPIntruderAlert = (boolean) Areas.get("UP Intruder Alert"); AlertThreshold = (int) Areas.get("Alert Threshold"); UPOfflineDamage = (boolean) Areas.get("UP Offline Defense"); OfflineDamageAmount = (int) Areas.get("Offline Damage"); ODCooldown = (int) Areas.get("Damager Cooldown"); UPBlockResist = (boolean) Areas.get("UP Block Resist"); ResistanceBlock = (int) Areas.get("Resistance Block"); UPCleanse = (boolean) Areas.get("UP Cleanser"); HashMap<String,Object> Score = (HashMap<String,Object>)pl.get("Score"); //Score UseScore = (boolean) Score.get("Use Score"); UseAreaPoints = (boolean) Score.get("Area Points"); UsePopulationPoints = (boolean) Score.get("Population Points"); TopRanksDisplay = (int) Score.get("Display Top List"); outputMySQL = (boolean) Score.get("Output MySQL"); MySQLHost = (String) Score.get("MySQL Host"); MySQLDB = (String) Score.get("MySQL DB"); MySQLUser = (String) Score.get("MySQL User"); MySQLPassword = (String) Score.get("MySQL Password"); HashMap<String,Object> Costs = (HashMap<String,Object>)pl.get("Costs"); //Costs TagCost = (int) Costs.get("Tag"); AreaCost = (int) Costs.get("Area"); incSizeCost = (int) Costs.get("Increase Size"); UPAlertsCost = (int) Costs.get("Alert Upgrade"); UPDamageCost = (int) Costs.get("Damage Upgrade"); UPResistCost = (int) Costs.get("Resist Upgrade"); UPCleanseCost = (int) Costs.get("Cleanse Upgrade"); HashMap<String,Object> ReqMem = (HashMap<String,Object>)pl.get("Req Member Counts"); //Population Reqs ReqMemColor = (int) ReqMem.get("Tag Color"); ReqMemArea = (int) ReqMem.get("Area"); HashMap<String,Object> ReqScore = (HashMap<String,Object>)pl.get("Req Score Ranks"); //Score Rank Reqs ReqScoreColor = (int) ReqScore.get("Color"); ReqScoreCape = (int) ReqScore.get("Cape"); HashMap<String,Object> Cleanup = (HashMap<String,Object>)pl.get("Clean Up"); //Clean Up CleanPlayerDays = (int) Cleanup.get("Clear Player Days"); ArrayList<String> exempt = (ArrayList<String>)pl.get("Do Not Delete Players"); exemptPlayers = new HashSet<String>(exempt); } }
e2e58aa4-6cb5-4939-8182-40f0bf841069
6
public IncomingPeerListener(int port) { super("TorrentListener"); log.debug("Binding incoming server socket"); while (port < 65535 && serverSocket == null) { try { serverSocket = new ServerSocket(port); } catch (Exception e) { log.debug("Cannot bind port " + port); port++; } } if (serverSocket == null) { log.error("Cannot bind the incoming socket"); return; } log.info("Listing for incoming peer on port " + port); this.port = port; setName(getName() + "-" + this.port); final IncomingPeerListener incomingPeerListener = this; addTask(new ThreadTask() { public boolean execute() throws Exception { try { Socket socket = serverSocket.accept(); receivedConnection++; TorrentPeer peer = new TorrentPeer(socket, incomingPeerListener); dispatchingPeers.add(peer); peer.start(); } catch (SocketException e) { return false; } return true; } public void interrupt() { try { serverSocket.close(); } catch (Exception e) { } } public void exceptionCought(Exception e) { log.error("Exception in " + IncomingPeerListener.this, e); throw new RuntimeException(e); } }); }
5d16f186-51b6-4829-a938-3dbb70ba532c
6
public void computerTurn() { myFrame.getContainerPanel().getButtonPanel().disableButton("s"); myFrame.getContainerPanel().getButtonPanel().disableButton("h"); myFrame.getContainerPanel().getButtonPanel().disableButton("n"); while (cHand.getHandValue() <= pHand.getHandValue() && cHand.getHandValue() <= 21 && cHand.getCards().size() <= 5) { transferCard("c",deck.randomCardIndex()); myFrame.getContainerPanel().getButtonPanel().setHandValue("c",cHand.getHandValue()); } if (cHand.checkHand() != Game.BUST && pHand.getHandValue() < cHand.getHandValue()) { score.incrementComputerScore(); } else if (cHand.checkHand() == Game.BUST) { score.incrementPlayerScore(); } myFrame.getContainerPanel().getButtonPanel().enableButton("n"); }
90e06fa9-b131-40bb-865d-5eb4d4e07278
4
public boolean containsFiveNinesNoMeld() { int numberOfNines = 0; for (Card card : currentCards) { if(card.face.equals(Face.Nine)) numberOfNines++; } if(numberOfNines >= 5 && new CalculateMeld(null, currentCards).calculate() == 0) return true; return false; }
20900098-4985-4499-a2d3-5ff0717606c1
7
@Test public void placeFiguresKnightAndKing() { HashMap<String, Integer> figureQuantityMap = new HashMap<>(); figureQuantityMap.put(KNIGHT.toString(), 2); figureQuantityMap.put(KING.toString(), 2); FiguresChain figuresChain = new King(figureQuantityMap); figuresChain.setNextFigure(new Knight(figureQuantityMap)); Set<String> objects = new HashSet<>(); objects.add(EMPTY_BOARD_SIZE_6); Set<String> boards = figuresChain.placeFigures(objects.stream()).collect(Collectors.toSet()); assertThat("figures are standing on different places", boards.contains("kxkxnn\n" + "xxxx..\n" + "...xxx\n" + "......\n" + "......\n" + "......\n"), is(true)); assertThat("all elements are not present on each board", boards .parallelStream() .filter(board -> board.contains(KING.getFigureAsString()) && board.contains(KNIGHT.getFigureAsString()) && !board.contains(QUEEN.getFigureAsString()) && !board.contains(ROOK.getFigureAsString()) && !board.contains(BISHOP.getFigureAsString()) && board.contains(FIELD_UNDER_ATTACK_STRING) && board.contains(EMPTY_FIELD_STRING) && leftOnlyFigures(board).length() == 4) .map(e -> 1) .reduce(0, (x, y) -> x + y), is(59392)); }
13ebe326-fc34-4670-be65-c904b3b8a127
8
public Node<T> reverse(Node<T> p_linkedList, Node<T> p_linkedList1, Comparator<T> p_comparator) { if(p_linkedList == null) { return p_linkedList1; } if(p_linkedList1 == null) { return p_linkedList; } Node<T> l_result = null; Node<T> l_list1 = p_linkedList; Node<T> l_list2 = p_linkedList1; Node<T> l_current = null; while(l_list1 != null || l_list2 != null) { Node<T> l_addedOne = null; if(l_list1 == null || (l_list2 != null && p_comparator.compare(l_list1.getValue(), l_list2.getValue()) > 0)) { l_addedOne = l_list2; l_list2 = l_list2.getNext(); } else { l_addedOne = l_list1; l_list1 = l_list1.getNext(); } if(l_result == null) { l_result = l_addedOne; l_current = l_result; } else { l_current.setNext(l_addedOne); l_current = l_current.getNext(); } l_addedOne = l_addedOne.getNext(); l_current.setNext(null); } return l_result; }
25c9a726-ac00-44ff-a006-dffc2a4830aa
1
private void drawOrbit(Subject subject, Coordinate parentPos) { double currentScale = radiusScale; if (subject.depth() > 2) { currentScale = radiusMoonScale; } double radius = subject.p.radius * currentScale; // g.setStroke(dashed); g.setColor(PATH_COLOR); g.drawOval((int) (parentPos.x - radius - 0.5), (int) (parentPos.y - radius - 0.5), (int) (2 * radius), (int) (2 * radius)); }
813fae7a-6955-48b0-9bec-3cecb91fbe85
1
public String getColumnName(int col) { try { return viewer.getColumnName(col); } catch (Exception err) { return err.toString(); } }
bc300ba1-74b2-47d2-ae11-f5c4803de8ff
2
public void mouseClicked(MouseEvent evt) { if (evt.getSource()==mapimage || evt.getSource()==newsimage){ display(); } }
9b6a31d4-7c30-4bdc-ba25-f52bd8aa46b3
6
private ColumnComparator makeSumColumnComparator(Element elSum) throws Exception { String type = elSum.getAttribute("type").toLowerCase(); boolean ascending = !(elSum.getAttribute("order").toLowerCase().equals("descending")); String defaultString = elSum.getAttribute("default"); ArrayList<NumberName> nnList = new ArrayList<NumberName>(); for (Element elColumn : getChildElementsByName(elSum, "column")) { nnList.add(new NumberName(elColumn)); } if (nnList.size()<1) { throw new Exception("Sum without summands"); } NumberName[] numberNames = nnList.toArray(new NumberName[nnList.size()]); if (type.equals("integer")) { return MultiColumnComparator.createIntegerComparator(numberNames, ascending, defaultString); } else if (type.equals("long")) { return MultiColumnComparator.createLongComparator(numberNames, ascending, defaultString); } else if (type.equals("double")) { return MultiColumnComparator.createDoubleComparator(numberNames, ascending, defaultString); } else if (type.equals("")) { throw new Exception("Error in <sortlines>: Sum without type"); } else { throw new Exception("Error in <sortlines>: Unknown sum type '"+type+"'"); } }
86cf5ddc-134b-40af-b6cd-e2f6b7ca9205
8
public void run(){ Logger.log("IN run"); Comparable<?>[] splits = null; try { splits = initTask.execute(); } catch (FileSystemException e) { //cannot happen checked file in constructor // TODO delete e.printStackTrace(); } int numberOfReducers = splits.length + 1; reducerTaskArray = new ReducerTask[numberOfReducers]; reducerClients = new String[numberOfReducers]; for(int i=0; i < numberOfReducers; i++){ if(i==0) reducerTaskArray[i] = new ReducerTask(this, i, null, splits[i], numberOfMappers); else if(i==numberOfReducers-1) reducerTaskArray[i] = new ReducerTask(this, i, splits[i-1], null, numberOfMappers); else reducerTaskArray[i] = new ReducerTask(this, i, splits[i-1], splits[i], numberOfMappers); } reducerTaskSuccessArray = new Boolean[numberOfReducers]; reducerTaskCompletion = new double[numberOfReducers]; for(int i=0; i < numberOfReducers; i++){ reducerTaskSuccessArray[i] = false; reducerTaskCompletion[i] = 0.0; } numMapperTasksComplete = 0; for(int i=0; i < mapperTaskArray.length; i++){ try { mapperTaskArray[i].setSplits(splits); mapperTaskArray[i].execute(); } catch (InvalidDataNodeException e) { e.printStackTrace(); handleFailure(); } } }
e0e6f74b-a542-438c-b9c8-0b06596638f9
4
public static List<Sale> formatOutputs(JSONArray results) { final List<Sale> ret = new ArrayList<Sale>(); for (int i = 0; i < results.length(); i++) { JSONObject r = null; if (results.get(i) instanceof JSONObject) r = (JSONObject) results.get(i); if (r != null) { final Sale s = new Sale(); s.setSector(r.get("sector").toString()); s.setCommodityGroup(r.get("commodityGroup").toString()); s.setArticle(r.get("article").toString()); s.setDeleted(toBool(r.get("deleted")).booleanValue()); s.setCashier(r.get("cashier").toString()); s.setUuid(r.get("uuid").toString()); s.setDescription(r.get("description").toString()); s.setItemNumber(r.get("itemNumber").toString()); s.setPos(r.get("pos").toString()); s.setGrossItemPrice(new BigDecimal(r.get("grossItemPrice") .toString())); s.setBaseItemPrice(new BigDecimal(r.get("baseItemPrice") .toString())); s.setQuantity(new BigDecimal(r.get("quantity").toString())); s.setItemPrice(new BigDecimal(r.get("itemPrice").toString())); s.setNetItemPrice(new BigDecimal(r.get("netItemPrice") .toString())); try { Date date = DatatypeConverter.parseDateTime( r.get("bookingTime").toString()).getTime(); s.setBookingTime(date); } catch (JSONException e) { e.printStackTrace(); } // "receiptIndex":0,s.setReceiptIndex(receiptIndex); // "deleted":false,s.setDeleted(deleted); // "revision":7621,s.setRevision(revision); ret.add(s); } } return ret; }
d50c2522-efef-4918-b9bb-b8f7deaecc47
9
public void drawRedraw(Graphics2D graphics) { if (running) { this.randomPoint.drawPoint(graphics); if (this.snake1.isWithinLimits() && this.snake1.canPlay()) { this.snake1.updateMovement(); this.snake1.drawPoints(graphics); if (this.snake1.interact(randomPoint)) { randomPoint.setCenter(Point.randomPoint(1, 49, 1, 49)); } this.snake1.crashWithOther(this.snake2.getPointList()); } else { this.snake1.setCanPlay(false); this.snake1.setColorAll(graphics, Color.RED); //Write Game Over Screen } if (this.snake2.isWithinLimits() && this.snake2.canPlay()) { this.snake2.updateMovement(); this.snake2.drawPoints(graphics); if (this.snake2.interact(randomPoint)) { randomPoint.setCenter(Point.randomPoint(1, 49, 1, 49)); } this.snake2.crashWithOther(this.snake1.getPointList()); } else { this.snake2.setCanPlay(false); this.snake2.setColorAll(graphics, Color.BLUE); //Write Game Over Screen } if (!this.snake1.canPlay() && !this.snake2.canPlay()) { this.running = false; } } else { //graphics. } }
bf5dbbdf-ceec-45fe-bfaf-288536f9ea1b
6
public static boolean wait(LoopCondition condition, int frequency, int tries) { tries = Math.max(1, tries + org.powerbot.script.Random.nextInt(-1, 2)); for (int i = 0; i < tries; i++) { try { Thread.sleep((long) Math.max(5, (int) ((double) frequency * org.powerbot.script.Random.nextDouble(0.85, 1.5)))); } catch (InterruptedException ignored) { } try { if (condition.exit.call()) { return true; } } catch (Exception ignored) { } try { if (condition.reset.call()) { i = 0; } } catch (Exception ignored) { } } return false; }
47d68894-a42f-45e0-bec7-c1ecf0b2dd73
2
public static String stripQuotes(String msg) { if (msg.startsWith("\"")) msg = msg.substring(1); if (msg.substring(msg.length() - 1).equals("\"")) msg = msg.substring(0, msg.length() - 1); return msg; }
0d5aab4e-a1dc-4766-8d64-b756979cf7d6
7
private void foundTrips() { rank = Rank.THREEOFAKIND; Card.Rank tripRank = null; // Find the biggest trips for (int i = 0; i < ranks.length; i++) { Card[] value = ranks[i]; if (value == null) continue; if (numRanks[i] == 3) { tripRank = RANKS[i]; for (int j = 0; j < numRanks[i]; j++) fiveCardHand.add(ranks[i][j]); break; } } int i = 0; for (Card card : hand) { if (card.getRank() != tripRank) { fiveCardHand.add(card); i++; } if (i == 2) break; } }
c2f8b155-ffef-467f-b1c2-900e4fec7152
6
private void createEmptyBoard(int cols, int rows) { for(int y = 0; y < cols; y++) { for(int x = 0; x < rows; x++) { if(y == 0 || x == 0) { squares[y][x] = SquareType.OUTSIDE; }else if(y == cols-1 || x == rows-1) { squares[y][x] = SquareType.OUTSIDE; }else { squares[y][x] = SquareType.EMPTY; } } } notifyListeners(); }
d6c90cb9-f370-47b6-a624-54f626e39e64
5
public static void testMouFitxa() { if ( taulers.size() > 0 ) { String jugador = llegeixParaula( "Escull un jugador (A, B, cap):" ); EstatCasella fitxa; if ( jugador.equalsIgnoreCase( "A" ) ) { fitxa = EstatCasella.JUGADOR_A; } else if ( jugador.equalsIgnoreCase( "B" ) ) { fitxa = EstatCasella.JUGADOR_B; } else { fitxa = EstatCasella.BUIDA; } int fila = llegeixEnter( "Escriu la fila de la casella:" ); int columna = llegeixEnter( "Escriu la columna de la casella:" ); try { taulers.get( actual ).mouFitxa( fitxa, fila, columna ); System.out.println( "[OK]\tLa fitxa s'ha mogut correctament." ); } catch ( IndexOutOfBoundsException excepcio ) { System.out.println( "[KO]\tNo s'ha pogut moure la fitxa: " + excepcio.getMessage() ); } catch ( IllegalArgumentException excepcio ) { System.out.println( "[KO]\tNo s'ha pogut moure la fitxa: " + excepcio.getMessage() ); } System.out.println( "\tEl tauler actual és: " + actual + ".\n\t" + "Les seves característiques són:\n" + taulers.get( actual ).toString() ); } else { System.out.println( "[KO]\tNo existeix cap tauler!" ); } }
dcc47ca6-7984-4e39-9dac-59be31e17bd4
6
public boolean isSameTree(TreeNode p, TreeNode q) { if (p == null && q == null) return true; if (p == null || q == null) return false; return (p.val == q.val && isSameTree(p.left,q.left) && isSameTree(p.right, q.right)); }
e786276a-e99b-4804-8bb5-503f769615ca
8
@Override public void actionPerformed(ActionEvent e) { if(e.getSource() == btnMakeAppointments) { //GOTO make appointments ViewAppointmentPanel vap = new ViewAppointmentPanel(parent, username); parent.getContentPane().add(vap); CardLayout cl = (CardLayout) parent.getContentPane().getLayout(); cl.next(parent.getContentPane()); } else if (e.getSource() == btnEditProfile) { //GOTO edit profile PatientEditProfilePanel pepp = new PatientEditProfilePanel(parent, username); parent.getContentPane().add(pepp); CardLayout cl = (CardLayout) parent.getContentPane().getLayout(); cl.next(parent.getContentPane()); } else if (e.getSource() == btnViewVisitHistory) { //GOTO View Visit History ViewVisitHistoryPanel vvhp = new ViewVisitHistoryPanel(parent, username); parent.getContentPane().add(vvhp); CardLayout cl = (CardLayout) parent.getContentPane().getLayout(); cl.next(parent.getContentPane()); } else if (e.getSource() == btnOrderMedication) { //GOTO Order Medication OrderMedicationPanel omp = new OrderMedicationPanel(parent, username); parent.getContentPane().add(omp); CardLayout cl = (CardLayout) parent.getContentPane().getLayout(); cl.next(parent.getContentPane()); } else if (e.getSource() == btnCommunicate) { //GOTO communicate PatientMessagingPanel pmp = new PatientMessagingPanel(parent, username); parent.getContentPane().add(pmp); CardLayout cl = (CardLayout) parent.getContentPane().getLayout(); cl.next(parent.getContentPane()); } else if (e.getSource() == btnRateADoctor) { //GOTO rate a doctor RateDoctorPanel rdp = new RateDoctorPanel(parent, username); parent.getContentPane().add(rdp); CardLayout cl = (CardLayout) parent.getContentPane().getLayout(); cl.next(parent.getContentPane()); } else if (e.getSource() == btnViewMessages){ //GOTO view messages InboxPanel ip = new InboxPanel(parent, username); parent.getContentPane().add(ip); CardLayout cl = (CardLayout) parent.getContentPane().getLayout(); cl.next(parent.getContentPane()); } else if (e.getSource() == btnLogout){ CardLayout cl = (CardLayout) parent.getContentPane().getLayout(); parent.getContentPane().remove(parent.getContentPane().getComponents().length-1); cl.last(parent.getContentPane()); } }
8f21d0e9-e9d0-4a00-85e8-1eed038efd95
9
public void actionPerformed(java.awt.event.ActionEvent arg0){ if (bankMode) // dans le cas d'echange avec la banque { if (arg0.getSource()==plusM){ deposit = true; quantiteM=quantiteM + specialization;} else if (arg0.getSource()==moinsM){ deposit = false; quantiteM=quantiteM - specialization;} // modifie les quantite echange en fonction des clics et met a jour les label correspondant else if (arg0.getSource()==plusT){ deposit = false; quantiteT++;} else if (arg0.getSource()==moinsT){ deposit = true; quantiteT--;} refresh(); } else // dans le cas d'echange entre joueurs { if (arg0.getSource()==plusM) quantiteM++; else if (arg0.getSource()==moinsM) quantiteM--; else if (arg0.getSource()==plusT) // modifie les quantite echange en fonction des clics et met a jour les label correspondant quantiteT++; else if (arg0.getSource()==moinsT) quantiteT--; refresh(); } }
327a069b-e2c0-4a23-945d-13cf74bbbce2
4
public void communicate() throws IOException { new Thread(new Runnable() { public void run() { try { String str = sbr.readLine(); while (str != null) { System.out.println(str); str = sbr.readLine(); } System.err.println("Disconnected by server"); } catch (IOException e) { System.err.println(e); } finally { try { socket.close(); } catch (IOException e) { e.printStackTrace(); } System.exit(0); } } }).start(); String str = br.readLine(); while (str != null) {// C-d spw.println(str); str = br.readLine(); } System.out.println("Disconnected by client"); socket.close(); System.exit(0); }
710c1090-9101-4464-a5bc-ef1c99d800ed
4
@Override public boolean retainAll(Collection<?> arg0) { boolean changed = false; for(int i = 1; i < mobs.length; i++) { if(mobs[i] != null) { if(!arg0.contains(mobs[i])) { mobs[i] = null; size--; changed = true; } } } return changed; }
028aec88-d031-445c-bd04-ad51c5b05a35
1
@Override protected void readMessage(InputStream in, int msgLength) throws IOException { super.readMessage(in, msgLength); int pos = 2; while (pos < msgLength) { QoS qos = QoS.valueOf(in.read()); addQoS(qos); pos++; } }
791611a5-eba7-4ab4-873f-fb740685cf39
8
public void setTraversalMap(int locx, int locy, MazeMap mazeMap) { int frontM, rightM, leftM; mazeVal = mazeMap.getMazeVal(locx, locy); //System.out.format("MazeVal(%d, %d): %x\n", locx, locy, mazeVal); switch (curDirec) { case 0: front = 0; right = 1; left = 3; frontM = 0x01; rightM = 0x02; leftM = 0x08; break; case 1: front = 1; right = 2; left = 0; frontM = 0x02; rightM = 0x04; leftM = 0x01; break; case 2: front = 2; right = 3; left = 1; frontM = 0x04; rightM = 0x08; leftM = 0x02; break; case 3: front = 3; right = 0; left = 2; frontM = 0x08; rightM = 0x01; leftM = 0x04; break; default: front = 0; right = 1; left = 3; frontM = 0x01; rightM = 0x02; leftM = 0x08; } if ((mazeVal & 0xf0) != 0xf0) { if ((mazeVal & frontM) == frontM) { traversal.setWall(locx, locy, front); } else { traversal.setChecked(locx, locy, front); } if ((mazeVal & rightM) == rightM) { traversal.setWall(locx, locy, right); } else { traversal.setChecked(locx, locy, right); } if ((mazeVal & leftM) == leftM) { traversal.setWall(locx, locy, left); } else { traversal.setChecked(locx, locy, left); } } }
8944b7af-4a34-4e72-a10b-509c8547b28f
9
private void extractAlignedSeqInfo(java.util.List<CigarElement> cigar, byte[] sequence, byte[] qual, SAMRecord aln) { // read info isReadReversed = aln.getReadNegativeStrandFlag(); // aligned seq info Vector<Byte> as = new Vector<Byte>(); Vector<Byte> aq = new Vector<Byte>(); int pos = 0; for (CigarElement op : cigar) { switch ( CigarOperator.enumToCharacter( op.getOperator() ) ) { case 'H': break; case 'S': pos += op.getLength(); break; case 'D': for (int n=0; n<op.getLength(); n++) { as.add( new Byte((byte)'N') ); aq.add( new Byte((byte)0) ); } break; default: try { for (int n=0; n<op.getLength(); n++) { as.add( sequence[pos] ); aq.add( qual[pos] ); pos++; } } catch (Exception e) { System.out.println("\nsequence: " + sequence.length); for (CigarElement optmp : cigar) System.out.print((char)CigarOperator.enumToCharacter(optmp.getOperator())); System.out.println("\npos: " + pos); System.out.println(new String(aln.getReadBases())); e.printStackTrace(System.out); } } } alignedSeq = new byte[as.size()]; alignedQual = new byte[as.size()]; for (int i=0; i<as.size(); i++) { alignedSeq[i] = as.get(i).byteValue(); alignedQual[i] = aq.get(i).byteValue(); } alignedPercentIdentity = calcAlignedPercentIdentity(aln); }
beecb6c3-e768-4c2b-b8a8-cff38aef3f6b
1
public static void run() { IMediaReader mediaReader = ToolFactory.makeReader(inputFilename); // stipulate that we want BufferedImages created in BGR 24bit color space mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR); ScreenShotsManager manager = new ScreenShotsManager(new File(inputFilename).getName()); mediaReader.addListener(new ImageSnapAdapter(manager)); // read out the contents of the media file and // dispatch events to the attached listener while (mediaReader.readPacket() == null) ; System.out.println("1: " + manager.compareScreensForShotBoundary(1)); System.out.println("150: " + manager.compareScreensForShotBoundary(150)); }
557642b2-c578-4acd-b00c-6104ec590048
6
@Override public void paintComponent(Graphics g) { GregorianCalendar currentTime = (GregorianCalendar) GregorianCalendar .getInstance(); hour = currentTime.get(Calendar.HOUR_OF_DAY); minutes = currentTime.get(Calendar.MINUTE); seconds = currentTime.get(Calendar.SECOND); int xcenter = 150, ycenter = 150; int xsecond = (int) (Math.cos(seconds * 3.14f / 30 - 3.14f / 2) * 120 + xcenter); int ysecond = (int) (Math.sin(seconds * 3.14f / 30 - 3.14f / 2) * 120 + ycenter); int xminute = (int) (Math.cos(minutes * 3.14f / 30 - 3.14f / 2) * 100 + xcenter); int yminute = (int) (Math.sin(minutes * 3.14f / 30 - 3.14f / 2) * 100 + ycenter); int xhour = (int) (Math.cos((hour * 30 + minutes / 2) * 3.14f / 180 - 3.14f / 2) * 80 + xcenter); int yhour = (int) (Math.sin((hour * 30 + minutes / 2) * 3.14f / 180 - 3.14f / 2) * 80 + ycenter); g.drawOval(0, 0, getWidth(), getHeight()); g.drawLine(getWidth() / 2, getHeight() / 2, xhour, yhour); g.drawLine(getWidth() / 2, getHeight() / 2, xminute, yminute); g.drawLine(getWidth() / 2, getHeight() / 2, xsecond, ysecond); int lastxs = 0, lastys = 0, lastxm = 0, lastym = 0, lastxh = 0, lastyh = 0; g.setColor(Color.magenta); if (xsecond != lastxs || ysecond != lastys) { g.drawLine(xcenter, ycenter, lastxs, lastys); } if (xminute != lastxm || yminute != lastym) { g.drawLine(xcenter, ycenter - 1, lastxm, lastym); g.drawLine(xcenter - 1, ycenter, lastxm, lastym); } if (xhour != lastxh || yhour != lastyh) { g.drawLine(xcenter, ycenter - 1, lastxh, lastyh); g.drawLine(xcenter - 1, ycenter, lastxh, lastyh); } g.setColor(Color.magenta); g.drawLine(xcenter, ycenter, xsecond, ysecond); g.setColor(Color.red); g.drawLine(xcenter, ycenter - 1, xminute, yminute); g.drawLine(xcenter - 1, ycenter, xminute, yminute); g.setColor(Color.green); g.drawLine(xcenter, ycenter - 1, xhour, yhour); g.drawLine(xcenter - 1, ycenter, xhour, yhour); lastxs = xsecond; lastys = ysecond; lastxm = xminute; lastym = yminute; lastxh = xhour; lastyh = yhour; }
508017d1-09bc-47ae-a0f4-f6ab6a4feee3
4
public static MessageAdaptor wrapMessage(Message message) throws JMSException { MessageAdaptor adaptor = null; if (CameraCaptureRequest.TYPE.equals(message.getJMSType())) { adaptor = new CameraCaptureRequest(); } else if (CameraCaptureResponse.TYPE.equals(message.getJMSType())) { adaptor = new CameraCaptureResponse(); } else if (MicroscopeCaptureRequest.TYPE.equals(message.getJMSType())) { adaptor = new MicroscopeCaptureRequest(); } else if (MicroscopeCaptureResponse.TYPE.equals(message.getJMSType())) { adaptor = new MicroscopeCaptureResponse(); } else { throw new JMSException(String.format("Unknown JMS type: %s", message.getJMSType())); } adaptor.fromMessage(message); return adaptor; }
f6b3d76e-392a-4ca0-a7a5-57b539a26292
1
public String bytesToHex(byte[] raw) { int length = raw.length; char[] hex = new char[length * 2]; for(int i = 0; i < length; i++) { int value = (raw[i] + 256) % 256; int highIndex = value >> 4; int lowIndex = value & 0x0f; hex[i * 2 + 0] = kDigits[highIndex]; hex[i * 2 + 1] = kDigits[lowIndex]; } return (new String(hex)).toString(); }
9bb34da8-3e85-4084-926c-b8f43f102862
7
public static void main(String[] args) throws FileNotFoundException, IOException{ Scanner scan = new Scanner(System.in); String file = "ptb-flat.txt"; WordsTree tree = new WordsTree(); boolean on = true; while(on) { System.out.println("BEM-VINDO AO EXTRACTDICTIONARY. POR FAVOR, ESCOLHA UMA DAS OPCOES:"); System.out.println("1 - AGRUPAR E IMPRIMIR TODAS AS PALAVRAS POR SEMELHANCA (TEMPO MEDIO DE 4 ~ 8 MINUTOS)"); System.out.println("2 - AGRUPAR E IMPRIMIR TODOS OS VERBOS POR SEMELHANCA (TEMPO MEDIO 10 ~ 20 SEGUNDOS)"); System.out.println("3 - AGRUPAR E IMPRIMIR TODOS OS SUBSTANTIVOS POR SEMELHANCA (TEMPO MEDIO 1 ~ 4 MINUTOS)"); System.out.println("4 - AGRUPAR E IMPRIMIR TODOS OS ADJETIVOS POR SEMELHANCA (TEMPO MEDIO 10 ~ 20 SEGUNDOS)"); System.out.println("5 - AGRUPAR E IMPRIMIR TODOS OS ADVERBIOS POR SEMELHANCA (TEMPO MEDIO 3 ~ 5 SEGUNDOS)"); System.out.println("6 - SAIR DO PROGRAMA"); String opt = scan.nextLine(); switch (opt.charAt(0)) { case '1': System.out.println("ESCOLHIDO [TODAS AS PALAVRAS]"); PTBParser parser = new AllPTBParser(file); parser.parse(tree); tree.wordMakeSets(); tree.printSimilarities(); break; case '2': System.out.println("ESCOLHIDO [VERBOS]"); parser = new VerbPTBParser(file); parser.parse(tree); tree.wordMakeSets(); tree.printSimilarities(); break; case '3': System.out.println("ESCOLHIDO [SUBSTANTIVOS]"); parser = new SubstantivePTBParser(file); parser.parse(tree); tree.wordMakeSets(); tree.printSimilarities(); break; case '4': System.out.println("ESCOLHIDO [ADJETIVOS]"); parser = new AdjectivePTBParser(file); parser.parse(tree); tree.wordMakeSets(); tree.printSimilarities(); break; case '5': System.out.println("ESCOLHIDO [ADVERBIOS]"); parser = new AdverbPTBParser(file); parser.parse(tree); tree.wordMakeSets(); tree.printSimilarities(); break; case '6': on = false; break; default: System.out.println("ERRO: DIGITE UMA OPCAO VALIDA!"); break; } } }
8dfacb8d-17e8-41b3-88bc-15a04701273a
5
public void deleteLayerFile(int selectedLayer) { File layer = new File(workingDir, "Layer" + selectedLayer + ".dat"); File layerColl = new File(workingDir, "Layer" + selectedLayer + "_Collision.dat"); if(layer.exists()) layer.delete(); if(layerColl.exists()) layerColl.delete(); if(Layers >= selectedLayer) { //rename all layer files after this one for(int i = (selectedLayer + 1); i <= (Layers + 1); i++) { File Old = new File(workingDir, "Layer" + i + ".dat"); File New = new File(workingDir, "Layer" + (i - 1) + ".dat"); Old.renameTo(New); if(colltype.equals(CollisionType.ADVANCED_COLLBOX)) { File Old2 = new File(workingDir, "Layer" + i + "_Collision.dat"); File New2 = new File(workingDir, "Layer" + (i - 1) + "_Collision.dat"); Old2.renameTo(New2); } } } }
f44ec76e-441c-4400-9250-a3dbc1d73e51
2
public void run() { String importantInfo[] = { "Mares eat oats", "Does eat oats", "Little lambs eat ivy", "A kid will eat ivy too" }; try { for (int i = 0; i < importantInfo.length; i++) { // Pause for 4 seconds Thread.sleep(4000); // Print a message threadMessage(importantInfo[i]); } } catch (InterruptedException e) { threadMessage("I wasn't done!"); } }
75dca812-e34b-4bdd-9a21-c33c6978ff0b
6
public LinearGradientPaintContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform t, RenderingHints hints, Point2D dStart, Point2D dEnd, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethodEnum cycleMethod, MultipleGradientPaint.ColorSpaceEnum colorSpace) throws NoninvertibleTransformException { super(cm, deviceBounds, userBounds, t, hints, fractions, colors, cycleMethod, colorSpace); // Use single precision floating points Point2D.Float start = new Point2D.Float((float) dStart.getX(), (float) dStart.getY()); Point2D.Float end = new Point2D.Float((float) dEnd.getX(), (float) dEnd.getY()); // A given point in the raster should take on the same color as its // projection onto the gradient vector. // Thus, we want the projection of the current position vector // onto the gradient vector, then normalized with respect to the // length of the gradient vector, giving a value which can be mapped into // the range 0-1. // projection = currentVector dot gradientVector / length(gradientVector) // normalized = projection / length(gradientVector) float dx = end.x - start.x; // change in x from start to end float dy = end.y - start.y; // change in y from start to end float dSq = dx * dx + dy * dy; // total distance squared //avoid repeated calculations by doing these divides once. float constX = dx / dSq; float constY = dy / dSq; //incremental change along gradient for +x dgdX = a00 * constX + a10 * constY; //incremental change along gradient for +y dgdY = a01 * constX + a11 * constY; float dgdXAbs = Math.abs(dgdX); float dgdYAbs = Math.abs(dgdY); if (dgdXAbs > dgdYAbs) pixSz = dgdXAbs; else pixSz = dgdYAbs; //constant, incorporates the translation components from the matrix gc = (a02 - start.x) * constX + (a12 - start.y) * constY; Object colorRend = hints.get(RenderingHints.KEY_COLOR_RENDERING); Object rend = hints.get(RenderingHints.KEY_RENDERING); fillMethod = DEFAULT_IMPL; if ((cycleMethod == MultipleGradientPaint.REPEAT) || hasDiscontinuity) { if (rend == RenderingHints.VALUE_RENDER_QUALITY) fillMethod = ANTI_ALIAS_IMPL; // ColorRend overrides rend. if (colorRend == RenderingHints.VALUE_COLOR_RENDER_SPEED) fillMethod = DEFAULT_IMPL; else if (colorRend == RenderingHints.VALUE_COLOR_RENDER_QUALITY) fillMethod = ANTI_ALIAS_IMPL; } }
70a7fc59-6935-4eaa-aea5-8e0de49a5f4c
5
public static int[] insertionSort(int[] array, boolean ascendingOrder) { if (array != null && array.length > 1) { for (int i = 1; i < array.length; i++) { for (int j = i; j >= 1; j--) { if (Utils.compareOrder(array[j], array[j - 1], ascendingOrder)) { Utils.swap(array, j, j - 1); } else { break; } } } } return array; }
049f0a96-8b59-43a2-9cfc-b6f8454b4570
0
public ClusterNode getLastNode() { return this.lastNode; }
fd74094f-7b75-4eb3-a51d-fffc1bbcc6e5
2
private boolean isEndOfLine(int c) throws IOException { // check if we have \r\n... if (c == '\r') { if (in.lookAhead() == '\n') { // note: does not change c outside of this method !! c = in.read(); } } return (c == '\n'); }
854fe807-e630-4e6b-a8ce-4686fcce316e
6
public static boolean[][] rectangle() { boolean patron[][] = new boolean[maxFil][maxCol]; for (int f=0; f<maxFil; f++) { for (int c=0; c<maxCol; c++) { if (f >= maxFil/4 && f <= 3*maxFil/4 && c >= maxCol/4 && c <= 3*maxCol/4) { patron[f][c] = true; } else { patron[f][c] = false; } } } return patron; }
30f045b7-c2e3-494f-b50e-5c96a3b1290c
1
public void generateUnit(Dimension size) { unit.value = (size.width < size.height ? size.width / (FIELD_DIMENSION.width + 2) : size.height / (FIELD_DIMENSION.height + 2)); }
53a051d8-039d-44ab-bea2-059859309868
3
public Type checkType(TypeMap tm) { Type t = new Type(); t.typeid = Type.TypeEnum.t_error; Type tmp = e.checkType(tm); if(tmp.OK()) { if(tmp.typeid == Type.TypeEnum.t_pair) { t.typeid = tmp.t1.typeid; } else { if(Type.isDebug) { System.out.println("TypeError! fst: "+tmp.typeid); System.out.println(this); } } } return t; }
63c3d39e-28e7-49ae-8fe5-410a6a39c23d
9
static double prim(double[][] mAdy,int n){ boolean[] v=new boolean[n]; double[] a=new double[n]; PriorityQueue<double[]> cola=new PriorityQueue<double[]>(n,new Comparator<double[]>(){ public int compare(double[] o1,double[] o2){ if(o1[0]<o2[0])return -1; if(o1[0]>o2[0])return 1; if(o1[1]<o2[1])return -1; if(o1[1]>o2[1])return 1; return 0; } }); Arrays.fill(a,Double.POSITIVE_INFINITY); a[0]=0;v[0]=true; cola.add(new double[]{0,0}); for(int h;!cola.isEmpty();){ double[] u=cola.poll(); v[h=(int)u[1]]=true; for(int i=0;i<n;i++) if(!v[i]&&a[i]>mAdy[h][i]) cola.add(new double[]{a[i]=mAdy[h][i],i}); } double res=0; for(double s:a)res+=s; return res; }
881238f1-9cd7-4ed9-9967-5e55bf15fe35
3
@WebMethod(operationName = "ReadSupplier") public ArrayList<Supplier> ReadSupplier(@WebParam(name = "sup_id") String sup_id) { Supplier sup = new Supplier(); ArrayList<Supplier> sups = new ArrayList<Supplier>(); ArrayList<QueryCriteria> qc = new ArrayList<QueryCriteria>(); if(!sup_id.equals("-1")){ qc.add(new QueryCriteria("sup_id", sup_id, Operand.EQUALS)); } ArrayList<String> fields = new ArrayList<String>(); ArrayList<QueryOrder> order = new ArrayList<QueryOrder>(); try { sups = sup.Read(qc, fields, order); } catch (SQLException ex) { Logger.getLogger(JAX_WS.class.getName()).log(Level.SEVERE, null, ex); } if(sups.isEmpty()){ return null; } return sups; }
0433d352-8b41-4b11-b1dd-3b2f59ec2bb2
8
@Override public SpeedVector getSpeedVector(Movable m) { SpeedVector currentSpeedVector, possibleSpeedVector; currentSpeedVector = m.getSpeedVector(); possibleSpeedVector = super.getSpeedVector(m); int nbTries = 10; while (true) { nbTries--; if ((possibleSpeedVector.getDirection().getX() == currentSpeedVector .getDirection().getX()) && (possibleSpeedVector.getDirection().getY() != -currentSpeedVector .getDirection().getY())) break; if ((possibleSpeedVector.getDirection().getX() != -currentSpeedVector .getDirection().getX()) && (possibleSpeedVector.getDirection().getY() == currentSpeedVector .getDirection().getY())) break; if ((possibleSpeedVector.getDirection().getX() != currentSpeedVector .getDirection().getX()) && (possibleSpeedVector.getDirection().getY() != currentSpeedVector .getDirection().getY())) break; possibleSpeedVector = super.getSpeedVector(m); if (nbTries < 1) break; } return (possibleSpeedVector); }
38f2121b-5e67-4dd3-a209-043c6f15bc94
8
public String longestCommonPrefix(String[] strs) { if (strs == null || strs.length == 0) { return ""; } else if (strs.length == 1) { return strs[0]; } String prefix = ""; int length = Integer.MAX_VALUE; for (String s : strs) { length = Math.min(s.length(), length); } for (int i = 0; i < length; i++) { boolean same = true; char c = strs[0].charAt(i); for (String s : strs) { if (s.charAt(i) != c) { same = false; break; } } if (same) { prefix += c; } else { break; } } return prefix; }
879798e6-e5f9-4b0c-8779-02777d8a08c4
0
public ArrayList<Day> getDays() { return days; }
b16dadae-4467-4eed-b48a-29363e3e8449
5
public boolean actionSmelt(Actor actor, Smelter smelter) { int success = 0 ; if (actor.traits.test(HARD_LABOUR, 10, 1)) success++ ; if (! actor.traits.test(CHEMISTRY, 5, 1)) success-- ; if (actor.traits.test(GEOPHYSICS, 15, 1)) success++ ; if (success <= 0) return false ; final Item sample = Item.withReference(SAMPLES, output) ; final float sampleAmount = smelter.stocks.amountOf(sample), outputAmount = smelter.stocks.amountOf(output), smeltLimit = Math.min(sampleAmount, Smelter.SMELT_AMOUNT - outputAmount) ; if (smeltLimit > 0) { final float bump = Math.min(smeltLimit, 0.1f * success) ; smelter.stocks.removeItem(Item.withAmount(sample, bump)) ; smelter.stocks.bumpItem(output, bump) ; } return true ; }
0a0ba700-99da-45d8-affd-8498159288d6
2
public static void DoTurn(PlanetWars pw) { //notice that a PlanetWars object called pw is passed as a parameter which you could use //if you want to know what this object does, then read PlanetWars.java //create a source planet, if you want to know what this object does, then read Planet.java Planet source = null; //create a destination planet Planet dest = null; //(1) implement an algorithm to determine the source planet to send your ships from //... code here //(2) implement an algorithm to deterimen the destination planet to send your ships to //... code here //(3) Attack if (source != null && dest != null) { pw.IssueOrder(source, dest); } }
a6959620-98a0-44e2-af6c-dda7a96742db
0
@XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "CipherData") public JAXBElement<CipherDataType> createCipherData(CipherDataType value) { return new JAXBElement<CipherDataType>(_CipherData_QNAME, CipherDataType.class, null, value); }
280d30a0-6bdf-4d25-820b-0cca50011635
0
public Object getValue(int index) { return params.get(index); }
dac57b41-0d48-49d3-9b96-fd7e080a4540
2
public static double[][] scale( double[][] mat, double fac ) { int m = mat.length; int n = mat[0].length; double[][] res = new double[m][]; for ( int i = 0; i < m; ++i ) { res[i] = new double[n]; for ( int j = 0; j < n; ++j ) res[i][j] = mat[i][j] * fac; } return(res); }
20a40354-8f7a-4346-8785-e8d20d730c5a
4
public void run() { RowDto<PixelDto> pixelRowDto; RowDto<HeightDto> heightRowDto; while (running.get() || ImageStorage.pixelRowHasNext()) { pixelRowDto = ImageStorage.getPixelRow(); if (pixelRowDto != null) { heightRowDto = new RowDto<HeightDto>(); while (pixelRowDto.hasMore()) { processPixel(pixelRowDto, heightRowDto); } saveData(heightRowDto); } else { this.sleep(); } } logger.info("Convert Rgb Thread ending"); }
5e7bd63a-2bff-4060-993d-7bc0aff1aaf5
6
public void actionPerformed(ActionEvent event) { if (event.getSource() == pTextField) { String text = String.format("%s", event.getActionCommand()); System.out.println("price == " + text); p = Double.parseDouble(text); } if (event.getSource() == dpTextField) { String text = event.getActionCommand(); System.out.println("downP == " + text); downP = Double.parseDouble(text); } if (event.getSource() == rTextField) { String text = event.getActionCommand(); System.out.println("rate == " + text); r = Double.parseDouble(text); } if (event.getSource() == tTextField) { String text = event.getActionCommand(); System.out.println("term == " + text); t = Integer.parseInt(text); } if (event.getSource() == calculateButton) { double[] ret = new double[3]; double financed = p - p * downP; int n = t * 12; double i = r / 12; double m = (financed * i) / (1 - (1 / Math.pow((1 + i), n))); ret[0] = m; ret[1] = m * n + p * downP; ret[2] = ret[1] - p; mTextArea.append(Double.toString(ret[0])); taTextArea.append(Double.toString(ret[1])); tiTextArea.append(Double.toString(ret[2])); System.out.printf("The monthly mortgage payment should be %.2f\n", ret[0]); System.out.printf("Total Amount Paid should be %.2f\n", ret[1]); System.out.printf("Total Interest Paid should be %.2f\n", ret[2]); // return ret; } if (event.getSource() == clearButton) { pTextField.setText(""); dpTextField.setText(""); rTextField.setText(""); tTextField.setText(""); mTextArea.setText(""); taTextArea.setText(""); tiTextArea.setText(""); p = 0.0; downP = 0.0; r = 0.0; t = 0; System.out.println("clear"); } }
190bd018-eb01-41b8-a4b8-a8ee81ffb0ba
0
public void update(Point p) { ((GeneralPath) shape).lineTo(p.x, p.y); dollar.pointerDragged(p.x, p.y); canvas.repaint(); }
249ed614-a11b-4670-8a3d-4333fd61ce2e
5
@Raw @Model private void setCurrentHitPoints(int hitPoints) { int oldHP = this.currentHitPoints; this.currentHitPoints = (hitPoints <= 0) ? 0 : Math.min(hitPoints, getMaximumHitPoints()); if (hitPoints <= 0 && oldHP > hitPoints && this.getWorld() != null && this.getWorld().getActiveWorm() == this) //so this doesn't get called by this.getCurrentHP() this.getWorld().nextTurn(); }
b22dc713-d30d-402d-b6d7-7bb6555f7dda
0
public String getFeetype() { return Feetype; }
b79b6883-f16c-4511-b714-6bd0e0ce6d90
7
public void renderSprite(int xp, int yp, Sprite sprite, boolean fixed) { if (fixed) { xp -= xOffset; yp -= yOffset; } for (int y = 0; y < sprite.getHeight(); y++) { int ya = y + yp; for (int x = 0; x < sprite.getWidth(); x++) { int xa = x + xp; if (xa < 0 || xa >= width || ya < 0 || ya >= height) continue; pixels[xa + ya * width] = sprite.pixels[x + y * sprite.getWidth()]; } } }
176d1f76-4f40-4107-a584-5927b1635852
1
public ThreadPool(int numThreads) { queue = new LinkedBlockingQueue<Runnable>(); threads = new Thread[numThreads]; int i = 0; for (Thread t : threads) { i++; t = new Worker("Thread "+i); t.start(); } }
9ad820e1-9595-46b6-a3d9-553ad0983cea
5
public void putBlock(Block block){ score++; statusBar.setText("SCORE = " + String.valueOf(score)); RestartButton.setText("Restart"); //int [][] theBlock = block.getBlock(); //int k = (int)(Math.random() * MAX_COL); BlockPosX = 5; BlockPosY = 0; int posX = 5; int posY = 0; BlockInControl = block; int x = 0; for(int i=0;i<MAX_COL;i++){ if(board[posY+1][i] == 1) { this.gameOver(); score = 0; break; } } for(int r=0;r<4;r++){ for(int c=0;c<4;c++){ if(block.getRowCol(r,c) == 1) { board[posY][posX]=1; color[posY][posX] = whichColor; } posX++; } posY++; posX-=4; } }
4a8a7021-fca4-4546-bd3f-af6f2225313f
8
XLightWebResponse( final HttpClient client, final BOSHClientConfig cfg, final CMSessionParams params, final AbstractBody request) { super(); IFutureResponse futureVal; try { String xml = request.toXML(); byte[] data = xml.getBytes(CHARSET); String encoding = null; if (cfg.isCompressionEnabled() && params != null) { AttrAccept accept = params.getAccept(); if (accept != null) { if (accept.isAccepted(ZLIBCodec.getID())) { encoding = ZLIBCodec.getID(); data = ZLIBCodec.encode(data); } else if (accept.isAccepted(GZIPCodec.getID())) { encoding = GZIPCodec.getID(); data = GZIPCodec.encode(data); } } } PostRequest post = new PostRequest( cfg.getURI().toString(), CONTENT_TYPE, data); if (encoding != null) { post.setHeader(CONTENT_ENCODING, encoding); } post.setTransferEncoding(null); post.setContentLength(data.length); if (cfg.isCompressionEnabled()) { post.setHeader(ACCEPT_ENCODING, ACCEPT_ENCODING_VAL); } futureVal = client.send(post); } catch (IOException iox) { toThrow = new BOSHException("Could not send request", iox); futureVal = null; } future = futureVal; }
468e3856-4171-4d8c-82d4-ee912b74f8a9
1
public static final Cycle getCycleCorrespondant(String nomCycle) throws Exception { Cycle cycle = null; if (nomCycle.equals("2012-2014")) { cycle = new Cycle2012_2014(); } else { throw new Exception("Cycle " + nomCycle + " n'est pas supporté."); } return cycle; }
6b0d4fab-51f8-4a44-9047-dde90c6a5581
7
public final int getNextCharWithBoundChecks() { if (this.currentPosition >= this.eofPosition) { return -1; } this.currentCharacter = this.source[this.currentPosition++]; if (this.currentPosition >= this.eofPosition) { this.unicodeAsBackSlash = false; if (this.withoutUnicodePtr != 0) { unicodeStore(); } return this.currentCharacter; } if (this.currentCharacter == '\\' && this.source[this.currentPosition] == 'u') { try { getNextUnicodeChar(); } catch (InvalidInputException e) { return -1; } } else { this.unicodeAsBackSlash = false; if (this.withoutUnicodePtr != 0) { unicodeStore(); } } return this.currentCharacter; }
8bca9657-ebb3-476b-b8be-87a103c7e591
2
public synchronized Entity getEntity(int id) { for (Entity e : getEntities()) { if (e.getId() == id) return e; } return null; }
1628feba-e385-4bc1-b6e6-978f2481ba75
1
private static final void pad2(int value, StringBuilder buffer) { if (value < 10) { buffer.append('0'); } buffer.append(value); }