method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
2ddc470e-8a7c-4de8-86e5-197176d4374c
6
private void listSubjectMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listSubjectMouseClicked //disable all text fields dateTextField.setEditable(false); toTextField.setEditable(false); fromTextField.setEditable(false); subjectTextField.setEditable(false); bodyTextArea.setEditable(false); //get the selected email String selectedMessage = listSubject.getSelectedValue().toString(); //set text fields to empty dateTextField.setText(""); toTextField.setText(""); fromTextField.setText(""); subjectTextField.setText(""); bodyTextArea.setText(""); //disable send, reply, and delete button sendButton.setEnabled(false); replyButton.setEnabled(true); deleteButton.setEnabled(true); //remove the <html> tags and then <br> tags in email String[] ditchHtml = selectedMessage.split("<html>"); String[] splitted = ditchHtml[1].split("<br>"); bodyTextArea.setText(selectedMessage); //for loop to set date, to, from, subject, and body text fields for(int i = 0; i < 5; i++) { switch(i){ case 0: dateTextField.setText(splitted[i]); break; case 1: toTextField.setText(splitted[i]); break; case 2: fromTextField.setText(splitted[i]); break; case 3: subjectTextField.setText(splitted[i]); break; case 4: bodyTextArea.setText(splitted[i]); break; } } }//GEN-LAST:event_listSubjectMouseClicked
f0da809e-d3f8-4450-ac3c-107ae931b6b6
7
protected String getRedoText() { if (!canRedo()) { return "Cannot redo."; } int i = insertionPoint; if ((i < maxInsertionPoint) && (edits.get(i).isSignificant())) { String description = edits.get(i).describeRedo(); if (!description.equals("redo")) { return description; } } for(i = i + 1; (i < maxInsertionPoint) && (!edits.get(i).isSignificant()); i++) { String description = edits.get(i).describeUndo(); if (!description.equals("redo")) { return description; } } return "redo"; }
219cce29-7b70-401c-8f7e-4e13968c7445
8
public boolean attributesMatched(String uri, String localName, String name, Attributes atts) { if ((atts == null || atts.getLength() == 0) && (parsedAttributeName == null || parsedAttributeName .isEmpty())) { return true; } if (atts == null) { return false; } if ((atts.getLength() > 0 && parsedAttributeName.equals(atts .getLocalName(0))) && atts.getValue(parsedAttributeName).startsWith( parsedAttributeValue)) { return true; } return false; }
ac46249d-b4fc-42e3-a0c0-842e598d5133
2
@Test public void testStartPosition() { System.out.println("testStartPosition"); Tile[][] MapTemplate = new Tile[5][5]; for (int j = 0; j < 5; j++) { for (int k = 0; k < 5; k++) { MapTemplate[j][k] = new Tile('W'); } } map.MapArray=MapTemplate; MapTemplate[2][2].setType('G'); Position startPos = map.startPosition(); assertEquals(2,startPos.getX()); assertEquals(2,startPos.getY()); }
48c7c422-7d5f-4c94-aaff-3e39ca0a59ef
5
@FXML private void seidelResultClick(MouseEvent me) { int curMethod = 2; if (me.getButton().equals(MouseButton.PRIMARY)) { if (coef == null || free == null || results[curMethod] == null) { return; } if (curMode[curMethod]) { curMode[curMethod] = false; seidelResult.setText(VECTOR + results[curMethod]); } else { curMode[curMethod] = true; seidelResult.setText(CHECK + Checker.getResult(coef, free, results[curMethod])); } } }
f47909b5-8a9f-4bde-b5e1-829f9abda841
0
public RegularToAutomatonTransitionTool(AutomatonPane view, AutomatonDrawer drawer, REToFSAController controller) { super(view, drawer); this.controller = controller; }
6a7be0de-cf95-45ac-88a0-4d46bd13f4c4
5
@Test(expected=BadPostfixException.class) public void evaluatePostfix4() throws DAIndexOutOfBoundsException, DAIllegalArgumentException, NumberFormatException, NotEnoughOperandsException, BadPostfixException { try { postfix.addLast("5"); String result = calc.evaluatePostfix(postfix); } catch (DAIndexOutOfBoundsException e) { throw new DAIndexOutOfBoundsException(); } catch (DAIllegalArgumentException e) { throw new DAIllegalArgumentException(); } catch (NumberFormatException e) { throw new NumberFormatException(); } catch (NotEnoughOperandsException e) { throw new NotEnoughOperandsException(); } catch (BadPostfixException e) { throw new BadPostfixException(); } }
6ef005ae-fafa-4c61-905d-5a0f91bb178f
3
private void play() { int counter = 0; passCards(); System.out.println("Trump: " + pack.getTrump() + ";"); while (!isGameEnded()) { System.out.println("Pack: " + pack.getCardAmount()); System.out.print(currentPlayer.getName() + ": "); currentPlayer.listCards(); System.out.print(opponentPlayer.getName() + ": "); opponentPlayer.listCards(); counter++; Vector<Card> currentPlayerMove = currentPlayer.makeMove(null); System.out.print(counter + "| "); printMove(currentPlayer.getName(), currentPlayerMove); Vector<Card> opponentPlayerMove = opponentPlayer.makeMove(currentPlayerMove); System.out.print(counter + "| "); printMove(opponentPlayer.getName(), opponentPlayerMove); passCards(); // If a player took cards, then don't change players if (currentPlayerMove.size() == opponentPlayerMove.size()) { Player temp = currentPlayer; currentPlayer = opponentPlayer; opponentPlayer = temp; } } if (first.getAmountOfCards() == 0) { System.out.println("Game ended! " + first.getName() + " won!"); } else { System.out.println("Game ended! " + second.getName() + " won!"); } }
2dc8106b-9201-4970-ac06-243f2bf03736
4
public boolean addSong(String email, Song song) { String id = "song" + getSongs().size() + 1; Song newSong = new Song(id, song.getTitle(), song.getLyrics(), song.getSpeed()); if (!song.getArtists().isEmpty()) { for (Artist a : song.getArtists()) { newSong.addArtist(createArtist(a.getName())); } } for (Genre g : song.getGenres()) { newSong.addGenre(g); } for (Tag t : song.getTags()) { newSong.addTag(t); } User user = getUserByEmail(email); user.addSong(newSong); songs.add(newSong); return true; }
787c1067-c19a-420b-b91e-d46bdd41375d
3
static void checkUnqualifiedName(int version, final String name, final String msg) { if ((version & 0xFFFF) < Opcodes.V1_5) { checkIdentifier(name, msg); } else { for (int i = 0; i < name.length(); ++i) { if (".;[/".indexOf(name.charAt(i)) != -1) { throw new IllegalArgumentException("Invalid " + msg + " (must be a valid unqualified name): " + name); } } } }
19757978-ba3b-4a31-a7f2-da08c37ff84d
0
public String getPeerUsername() { return target.getUsername(); }
9ca3a639-07b6-4976-a621-178dfe91e6ad
4
public void setFaceDir(double faceDir) { if (faceDir > 359) { while (faceDir > 359) { faceDir = faceDir - 360; } } if (faceDir < 0) { while (faceDir < 0) { faceDir = faceDir + 360; } } this.faceDir = faceDir; }
2068432e-4f14-4025-89f0-a1f914179fd9
3
* @return Returns true if the given cell is locked. */ public boolean isCellLocked(Object cell) { mxGeometry geometry = model.getGeometry(cell); return isCellsLocked() || (geometry != null && model.isVertex(cell) && geometry .isRelative()); }
feaed914-01bd-4bbd-8b1d-a4e0a14f970b
9
public ArrayList<Integer> obtenerJugadasGanadorasDeHoy(ArrayList<Integer> boletosDeHoy, ArrayList<Integer> numerosGanadores, int loteria_id){ Verificadora verificadora = new Verificadora(); Connection cn = conexion.Conectar(); PreparedStatement pst; ResultSet rs; String query; ArrayList<Integer> jugadasDeHoy = new ArrayList<>(); int numerog1, numerog2, numerog3; numerog1 = numerosGanadores.get(0); numerog2 = numerosGanadores.get(1); numerog3 = numerosGanadores.get(2); int coincidencias=0; for(int i=0; i<boletosDeHoy.size(); i++){ query = "SELECT jugada_id, combinacion, monto, formato_id FROM jugadas WHERE boleto_id = "+boletosDeHoy.get(i)+" AND loteria_id ="+loteria_id; try{ pst = cn.prepareStatement(query); rs = pst.executeQuery(); while(rs.next()){ String comb = separarCombinacion(rs.getString("combinacion")).get(0); String [] combinacion = rs.getString("combinacion").split("-"); int formato = rs.getInt("formato_id"); int jugada_id = rs.getInt("jugada_id"); numerosGanadores.clear(); numerosGanadores.add(numerog1); numerosGanadores.add(numerog2); numerosGanadores.add(numerog3); coincidencias = verificadora.verificarCoincidencias(separarCombinacion(rs.getString("combinacion")), numerosGanadores); System.out.println("jugada: "+jugada_id); System.out.println("coinc: "+coincidencias); System.out.println("Formato: "+formato); if(coincidencias==1 && formato == 2){//QUINIELA jugadasDeHoy.add(jugada_id); calcularQuiniela(jugada_id, Integer.parseInt(combinacion[0]), numerog1, numerog2, numerog3, Double.parseDouble(rs.getString("monto"))); System.out.println("Quiniela ganó: "+jugada_id); }else if(coincidencias==2 && formato == 3){//PALE jugadasDeHoy.add(jugada_id); calcularPale(jugada_id, Integer.parseInt(combinacion[0]), Integer.parseInt(combinacion[1]), numerog1, numerog2, numerog3, Double.parseDouble(rs.getString("monto"))); }else if(coincidencias==3 && formato == 1){//TRIPLETA jugadasDeHoy.add(jugada_id); calcularTripleta(jugada_id,Double.parseDouble(rs.getString("monto")) ); } } }catch(SQLException ex){ System.out.println(ex); } } //System.out.println("El fucking ganador: "+jugadasDeHoy.get(0)); return jugadasDeHoy; }
29736622-c410-4a4b-929e-5daefb9f4672
5
@Override public void setCell(int x, int y, boolean live) { if (y<0 || y>=getHeight()) return; if (x<0 || x>=getWidth()) return; if (live) world[y][x] = 0; }
206013f9-6560-47df-a4cf-6dbc20818be8
6
public boolean collision(double d, boolean isDy) { int tileX; int tileY; if (isDy) { tileX = (int) (v.getX()) >> 5; tileY = (int) (v.getY() + d) >> 5; } else { tileX = (int) (v.getX() + d) >> 5; tileY = (int) (v.getY()) >> 5; } if (tileX < 0 || tileX >= BusinessSim.bs.level.width) { return true; } if (tileY < 0 || tileY >= BusinessSim.bs.level.height) { return true; } if (BusinessSim.bs.level.getObject(tileX, tileY).sprite.equals(Sprite.emptySprite)) { // if it's empty return false; } return true; // if it's not empty }
b530998b-7ca6-4b88-9f04-95b723bc9a61
9
@Override public CPUStatus getCPUStatus() throws RemoteException { try { /* establish a Session */ establishSession(); int RunningNum = 0; int BlockingNum = 0; int InterruptNum = 0; int ContextSwitchNum = 0; float UserPercent = 0; float SystemPercent = 0; float IdlePercent = 0; float IOWaitPercent = 0; InputStream stdout; BufferedReader br; int linenum = 0; boolean cmdflag = true; /* Execute a command */ sess.execCommand("vmstat"); stdout = new StreamGobbler(sess.getStdout()); br = new BufferedReader(new InputStreamReader(stdout)); linenum = 0; while (true) { String linein = br.readLine(); if (linein == null) { if(linenum == 0) { cmdflag = false; } break; } linenum++; String line = null; if(linein.length() >= 1) { line = deleteExtraSpace(linein); } if(line.length()<=1 || line.charAt(0) == 'p' || line.charAt(0) == 'r') { continue; } String linesplit[] = line.split(" "); RunningNum = Integer.parseInt(linesplit[0]); BlockingNum = Integer.parseInt(linesplit[1]); InterruptNum = Integer.parseInt(linesplit[10]); ContextSwitchNum = Integer.parseInt(linesplit[11]); UserPercent = Float.parseFloat(linesplit[12]); SystemPercent = Float.parseFloat(linesplit[13]); IdlePercent = Float.parseFloat(linesplit[14]); IOWaitPercent = Float.parseFloat(linesplit[15]); } stdout.close(); br.close(); /* RecCPUStatus */ RecCPUStatus cpusta = new RecCPUStatus(); cpusta.setBlockingNum(BlockingNum); cpusta.setContextSwitchNum(ContextSwitchNum); cpusta.setIdlePercent(IdlePercent); cpusta.setInterruptNum(InterruptNum); cpusta.setIOWaitPercent(IOWaitPercent); cpusta.setRunningNum(RunningNum); cpusta.setSystemPercent(SystemPercent); cpusta.setUserPercent(UserPercent); /* Close the session */ closeSession(); if(cmdflag == false) { throw new IOException("Command vmstat Execution failed."); } return cpusta; } catch (IOException e) { throw new RemoteException(e.getMessage()); } }
4d9c99fb-3edc-4159-8118-7ab65e88272b
0
public DumpCommand(TotalPermissions p) { plugin = p; }
6a9e6716-b8a7-47cc-b866-06cca02c2f40
9
private Boolean isPartOfTernaire ( MCDLien mcdLien ) { // la cardinalité est 1,1 sur ce lien Boolean ternaire = false ; MCDAssociation association = ( MCDAssociation ) mcdLien.getElement ( Constantes.MCDENTITE1 ) ; MCDLien entiteLink = null, ws_lien = null ; String v0_name, v1_name, entite0_name = null , entite1_name = null ; MCDObjet obj ; List<MCDLien> vLinks = null, vLinks_rech = null ; // on récupère l'entité associée vLinks = association.links ; for ( int k=0; k < vLinks.size() ; k++ ) if ( ! ( ( MCDLien ) vLinks.get( k ) ).equals( mcdLien ) ) { entiteLink = ( MCDLien ) vLinks.get( k ) ; entite0_name = (( MCDEntite ) mcdLien.getElement( Constantes.MCDENTITE2 )).getName () ; entite1_name = (( MCDEntite ) entiteLink.getElement( Constantes.MCDENTITE2 )).getName () ; break ; } // on cherche une autre association reliant les 2 entités for (Iterator<ZElement> e = this.elementsZElements(); e.hasNext();) { obj = (MCDObjet) e.next(); if (obj instanceof MCDAssociation) { vLinks_rech = ( (MCDAssociation) obj ).links ; // Les liens de l'association sont dans un vecteur if ( ! obj.equals( association ) ) { ws_lien = ( MCDLien ) vLinks_rech.get( 0 ) ; v0_name = (( MCDEntite ) ws_lien.getElement( Constantes.MCDENTITE2 )).getName () ; ws_lien = ( MCDLien ) vLinks.get( 1 ) ; v1_name = (( MCDEntite ) ws_lien.getElement( Constantes.MCDENTITE2 )).getName () ; if ( ( v0_name.equals ( entite0_name ) && v1_name.equals ( entite1_name ) ) || ( v0_name.equals ( entite1_name ) && v1_name.equals ( entite0_name ) ) ) { ternaire = true ; break ; } } } } ternaire = false ; // je sais ... un bug en suspens pour ceux qui ont suivi le pb des relations ternaires return ternaire ; }
bba2fa1f-218b-4c0f-8fec-04898e90cb10
9
public void set(Protocol con, Component widget, JSONObject obj, Map styleMap) throws JSONException { if (obj.has("item")) { JSONArray array = obj.getJSONArray("item"); for (int j = 0; j < array.length(); j++) { JSONObject itemObj = array.getJSONObject(j); String path = ""; if (itemObj.has("path")) { path = itemObj.getString("path"); } String title = ""; if (itemObj.has("title")) { title = itemObj.getString("title"); } boolean showDialog = true; if (itemObj.has("showdialog")) { int v = itemObj.getInt("showdialog"); showDialog = v == 1; } int retry = 0; if (itemObj.has("retry")) { retry = itemObj.getInt("retry"); } if (!path.isEmpty() && !title.isEmpty()) { if (con.getServerType().startsWith("glserver")) { con.addPrintRequest(path, title, retry, showDialog); } } } } }
d642d2c5-9de7-4a76-8f67-6a17cb933848
3
public int indexOf(final AbstractInsnNode insn) { if (check && !contains(insn)) { throw new IllegalArgumentException(); } if (cache == null) { cache = toArray(); } return insn.index; }
e2292c38-e9fa-4d0e-9d49-8c962eb50590
4
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.BLACK); g2d.setFont(font); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); int width = g.getFontMetrics().charWidth('a'); g2d.setColor(GRID_COLOR); for (int x = 0; x < wordSearch.getSize(); x++) for (int y = 0; y < wordSearch.getSize(); y++) g2d.drawRect(cellSize * x, cellSize * y, cellSize, cellSize); g2d.setColor(Color.BLACK); for (int x = 0; x < wordSearch.getSize(); x++) for (int y = 0; y < wordSearch.getSize(); y++) g2d.drawString(String.valueOf(wordSearch.getGrid()[y][x]), (x * cellSize) + (width * 0.4f), (y * cellSize) + (g2d.getFontMetrics().getHeight() * 0.75f)); }
382cc68b-9be7-4fd9-bd43-f7ea65b52b9c
7
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { try { if (sender instanceof Player) { Player player = (Player)sender; int rank = 1; try { rank = HyperPVP.getStorage().readInt32("SELECT rank FROM users WHERE username = '" + player.getName() + "'"); } catch (SQLException e) { e.printStackTrace(); } if (rank >= 6) { return true; } } if (HyperPVP.isCycling()) { sender.sendMessage(ChatColor.RED + "Can't cycle while another cycle is in progress."); return true; } if (args.length != 1) { CycleUtil.cycleNext(true, null, null); } else if (args.length == 1) { CycleUtil.cycleNext(true, null, args[0]); } //this.plugin.getThreads().put(ThreadType.FIGHT, new FightThread(this.plugin)); //this.plugin.getThreads().get(ThreadType.FIGHT).start(); } catch (Exception e) { e.printStackTrace(); } return true; }
7cff4eab-e12a-48ab-a194-b90c64772826
2
private PrintWriter fluxSortant() { if (emetteur != null) { try { return new PrintWriter(emetteur.getOutputStream()); } catch (IOException e) { System.out .println("Problème de récupération du flux sortant sur le client."); } } return null; }
96ba01b7-9783-4cae-9a6a-2d527872c3ec
2
public void render(Screen screen) { if (time >= lifeTime - 6 * 20) { if (time / 6 % 2 == 0) return; } int xt = 8; int yt = 13; // screen.render(x - 4, y - 4 - 2, xt + yt * 32, Color.get(-1, 555, 555, 555), random.nextInt(4)); // screen.render(x - 4, y - 4 + 2, xt + yt * 32, Color.get(-1, 000, 000, 000), random.nextInt(4)); }
679dd984-ffbf-4830-af98-839a87f8de4a
7
private JPanel createJvmPanel() { JPanel total = new JPanel(new BorderLayout()); total.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); JPanel panel = new JPanel(new BorderLayout()); total.add(panel, BorderLayout.CENTER); DefaultTableModel tableModel = new DefaultTableModel() { public boolean isCellEditable(int row, int column) { return false; } }; String[] columnNames = { " ", " " }; String[][] rowData = new String[7][2]; // row 1 String s = Modeler.getInternationalText("Vendor"); rowData[0][0] = (s != null ? s : "Vendor") + ":"; rowData[0][1] = System.getProperty("java.vendor"); // row 2 s = Modeler.getInternationalText("Version"); rowData[1][0] = (s != null ? s : "Version") + ":"; rowData[1][1] = System.getProperty("java.version"); // row 3 s = Modeler.getInternationalText("Location"); rowData[2][0] = (s != null ? s : "Location") + ":"; rowData[2][1] = System.getProperty("java.home"); Runtime rt = Runtime.getRuntime(); // row 4 s = Modeler.getInternationalText("AvailableProcessors"); rowData[3][0] = (s != null ? s : "Number of Processors") + ":"; rowData[3][1] = "" + rt.availableProcessors(); // row 5 s = Modeler.getInternationalText("MaximumMemoryAllocated"); rowData[4][0] = (s != null ? s : "Maximum Memory Allocated") + ":"; rowData[4][1] = Math.round(rt.maxMemory() / 1048576.f) + " MB"; // row 6 s = Modeler.getInternationalText("TotalMemoryUsed"); rowData[5][0] = (s != null ? s : "Total Memory Used") + ":"; rowData[5][1] = Math.round(rt.totalMemory() / 1048576.f) + " MB"; // row 7 s = Modeler.getInternationalText("FreeMemory"); rowData[6][0] = (s != null ? s : "Free Memory") + ":"; rowData[6][1] = Math.round(rt.freeMemory() / 1048576.f) + " MB"; tableModel.setDataVector(rowData, columnNames); jvmTable = new JTable(tableModel); jvmTable.setBorder(BorderFactory.createLineBorder(jvmTable.getGridColor())); jvmTable.setRowMargin(10); jvmTable.setRowHeight(jvmTable.getRowHeight() + 5); ((DefaultTableColumnModel) jvmTable.getColumnModel()).setColumnMargin(10); jvmTable.getColumnModel().getColumn(0).setPreferredWidth(150); jvmTable.getColumnModel().getColumn(1).setPreferredWidth(250); JScrollPane sp = new JScrollPane(jvmTable); sp.setPreferredSize(new Dimension(400, 300)); panel.add(sp, BorderLayout.NORTH); return total; }
711a31c3-318e-49bc-b214-89393b6116e2
0
public float getFOV() { return cam.getFOV(); }
dba2b8ba-a1cc-42cc-a030-d2aece6d6d6c
3
public JSONArray toJSONArray(JSONArray names) throws JSONException { if (names == null || names.length() == 0) { return null; } JSONArray ja = new JSONArray(); for (int i = 0; i < names.length(); i += 1) { ja.put(this.opt(names.getString(i))); } return ja; }
24910a1a-6b92-4920-8ed2-97a0da8c619a
0
public int getCurrentBits() { return currentBits; }
11166660-ba86-49f6-b9af-7cf2fcda37cf
4
public void recursivePrint(TreeNode root, int parentPosition, Node innerNode, Node p, int i) { Node innerParent; int position; if (root != null) { int height = heightRootToNode(root); int nextTop = getRectNextTop(height); if (innerNode != null) innerParent = innerNode; else innerParent = p; if (root.parent.left != null && root.parent.left.equals(root)) { position = getRectNextLeft(parentPosition, height); innerNode = makeNode(String.valueOf(root.key), new Point(position, nextTop), Node.COLOR_LEFT, i); } else { position = getRectNextRight(parentPosition, height); innerNode = makeNode(String.valueOf(root.key), new Point(position, nextTop), Node.COLOR_RIGHT, i); } innerNode.setParent(innerParent); parentPosition = position; // -- recursivePrint(root.left, parentPosition, innerNode, p, i); recursivePrint(root.right, parentPosition, innerNode, p, i); } }
bdaf7d36-7906-44e0-82df-6ae180858302
7
private static String htmlFilter(String message){ if(message == null) return null; int len = message.length(); StringBuffer result = new StringBuffer(len + 20); char aChar; for(int i =0; i< len; i++){ aChar = message.charAt(i); switch (aChar) { case '<': result.append("&lt;"); break; case '>': result.append("&gt;"); break; case '&': result.append("&amp;"); break; case '"': result.append("&quot;"); break; case ';': result.append("&no;"); break; default: result.append(aChar); } } return (result.toString()); }
f99b3212-6af4-467f-b7ef-a2b4b9c45a9c
8
public String CalcMAC(byte strInput[]) { int i, ii; int lenInput; byte newMAC[] = new byte[16]; byte tempmac[] = new byte[8]; byte strMAC[] = new byte[8]; byte tempstr3[] = new byte[8]; int j, k; byte temp1[] = new byte[1], temp2[] = new byte[1]; lenInput = strInput.length; i = lenInput % 8; if(i!=0){ k = lenInput + (8 - i); } else{ k=lenInput; } byte strInputBack[] = new byte[k]; for (j = 0; j < k; j++) { if (j < lenInput) strInputBack[j] = strInput[j]; else strInputBack[j] = 0x00; } lenInput = k; for (i = 0; i < 8; i++) { strMAC[i] = '0'; } for (i = 0; i < lenInput; i += 8) { for (j = i; j < i + 8; j++) { tempmac[j % 8] = strInputBack[j]; } for (int m = 0; m < 16; m++) { newMAC[m] = 0; } for (ii = 0; ii < 8; ii++) { temp1[0] = strMAC[ii]; temp2[0] = tempmac[ii]; BigInteger t1 = new BigInteger(temp1); BigInteger t2 = new BigInteger(temp2); BigInteger t3 = t1.xor(t2); tempstr3[ii] = t3.byteValue(); } tempstr3 = this.getEncCode(tempstr3); System.arraycopy(tempstr3, 0, strMAC, 0, 8); } return this.convertByteToHexString(tempstr3); }
6d63b7eb-4d15-40d0-81e2-607302dadc0e
8
public int compare(String o1, String o2) { String s1 = (String)o1; String s2 = (String)o2; int thisMarker = 0; int thatMarker = 0; int s1Length = s1.length(); int s2Length = s2.length(); while (thisMarker < s1Length && thatMarker < s2Length) { String thisChunk = getChunk(s1, s1Length, thisMarker); thisMarker += thisChunk.length(); String thatChunk = getChunk(s2, s2Length, thatMarker); thatMarker += thatChunk.length(); // If both chunks contain numeric characters, sort them numerically int result = 0; if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) { // Simple chunk comparison by length. int thisChunkLength = thisChunk.length(); result = thisChunkLength - thatChunk.length(); // If equal, the first different number counts if (result == 0) { for (int i = 0; i < thisChunkLength; i++) { result = thisChunk.charAt(i) - thatChunk.charAt(i); if (result != 0) { return result; } } } } else { result = thisChunk.compareTo(thatChunk); } if (result != 0) return result; } return s1Length - s2Length; }
0af2d42a-d677-4151-ac59-ea7abe0fc544
5
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html;charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; _jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">\n"); out.write("<html>\n"); out.write(" <head>\n"); out.write(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n"); out.write(" <title>JSP Page</title>\n"); out.write(" </head>\n"); out.write(" <body>\n"); out.write(" <form action=\"UserLogin.do\" method=\"post\">\n"); out.write(" <ul>\n"); out.write(" <li>ID :<input name=\"id\" value=\"\"/></li>\n"); out.write(" <li>Password :<input name=\"password\" type=\"password\" value=\"\"/></li>\n"); out.write(" <li><input type=\"submit\" value=\"Login\"/>\n"); out.write(" <input type=\"reset\" value=\"Abort\"/></li>\n"); out.write(" </ul>\n"); out.write(" </form>\n"); out.write(" </body>\n"); out.write("</html>\n"); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
11a927f3-61e5-4015-8d0a-2fba441fd661
7
public CheckResultMessage checkTotal1(int i) { int r1 = get(2, 2); int c1 = get(3, 2); int r2 = get(4, 2); BigDecimal sum = new BigDecimal(0); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); for (int j = 1; j < r2 - r1; j++) { sum = sum.add(getValue(r1 + j, c1 + i, 0)); } if (0 != getValue(r2, c1 + i, 0).compareTo(sum)) { return error("支付机构单个账户报表<" + fileName + ">sheet1-1:" + "本月所有日期合计:A0" + (1 + i) + "错误"); } in.close(); } catch (Exception e) { } } else { try { in = new FileInputStream(file); xWorkbook = new XSSFWorkbook(in); for (int j = 1; j < r2 - r1; j++) { sum = sum.add(getValue1(r1 + j, c1 + i, 0)); } if (0 != getValue1(r2, c1 + i, 0).compareTo(sum)) { return error("支付机构单个账户报表<" + fileName + ">sheet1-1:" + "本月所有日期合计:A0" + (1 + i) + "错误"); } in.close(); } catch (Exception e) { } } return pass("支付机构单个账户报表<" + fileName + ">sheet1-1:" + "本月所有日期合计:A0" + (1 + i) + "正确"); }
533a1b2b-9eb9-4262-825a-20573c744062
8
private void getReminderDateTime(String command, TaskData t) { Object obj = reminderParser.parse(command); if (obj == null) { reminderDateTime = null; reminderMinutes = null; } else if (obj instanceof LocalDateTime) { reminderDateTime = (LocalDateTime) obj; } else if (obj instanceof Integer) { reminderMinutes = (Integer) obj; if (reminderMinutes == -1) { reminderDateTime = LocalDateTime.MIN; reminderMinutes = null; return; } if ((t.getStartDateTime() == null) && (t.getEndDateTime() == null)) { reminderDateTime = null; } else if (t.getStartDateTime() != null) { reminderDateTime = t.getStartDateTime().minusMinutes( reminderMinutes); } else if (t.getEndDateTime() != null) { reminderDateTime = t.getEndDateTime().minusMinutes( reminderMinutes); } } }
05a0c4c1-c415-4227-8fd5-392cc0c401c1
1
@Test public void testCreatingAddressBookWithNullLabelShouldFail() { try { new Book(null); fail("Was expecting an Exception when no label is provided."); } catch (IllegalArgumentException iae) { Assert.assertEquals("Please provide a value for Label as it is a non-nullable field.", iae.getMessage()); } }
75474d73-7640-44ee-b78e-18c8d6968cb6
2
public String toString() { StringBuilder bookString = new StringBuilder(); Iterator<String> it = keywords.iterator(); bookString.append("-Book- \n").append("author: ").append(author).append('\n'); bookString.append("# pages: ").append(pageNum).append('\n'); bookString.append("title: ").append(title).append('\n'); bookString.append("keywords: "); while (it.hasNext()) { String s = it.next(); bookString.append(s); if (it.hasNext()) { bookString.append(','); } } bookString.append('\n').append('\n'); return bookString.toString(); }
20007645-1434-435d-9394-fb1f97e7a0b3
6
public static Object sub(Object o1, Object o2){ if (o1 instanceof List){ List newList = new ArrayList((List)o1); if (o2 instanceof List){ newList.removeAll((List)o2); } else { newList.remove(o2); } return newList; } if (o1 instanceof String || o2 instanceof String){ return o1; } if (o1 instanceof Integer && o2 instanceof Integer){ return ((Integer)o1) - ((Integer)o2); } else { return ((Number)o1).doubleValue() - ((Number)o2).doubleValue(); } }
007772fc-2776-4ae7-86ba-c83f4c9006b0
2
private PathSet lookupPaths(Class<?> clazz) { PathSet paths = pathMap.get(clazz); if (paths == null) { paths = new PathSet(clazz); pathMap.put(clazz, paths); } return paths; }
0b34194f-bf62-45c4-922f-83380713b12c
2
public static final int typeIndex(Class type) { Class[] list = primitiveTypes; int n = list.length; for (int i = 0; i < n; i++) if (list[i] == type) return i; throw new RuntimeException("bad type:" + type.getName()); }
d64330d4-e1a9-4ab3-bffd-dab185a7e08a
3
public boolean contains(double posX, double posY) { return (posX >= (x - 5) && posX <= (x + width + 5) && posY >= (y - 5) && posY <= (y + height + 5)); }
548557f8-232f-42df-b5f5-1c98d9734631
1
public void dumpInstruction(TabbedPrintWriter writer) throws java.io.IOException { writer.println("break" + (label == null ? "" : " " + label) + ";"); }
ebe2f7a9-28f2-43d3-bfdc-d0a5ba870f04
0
public void setjButtonClose(JButton jButtonClose) { this.jButtonClose = jButtonClose; }
c0df2fdb-b912-4c89-b777-6a445546a9d2
0
private int readComplexValue (ResTable_Map map, byte[] remainingData, int offset) throws IOException { map.name = readUInt32(remainingData, offset); offset += 4; return readValue(map.value, remainingData, offset); }
859808e6-05ad-41a0-9f79-0ab1576cb904
9
static ArrayList<Pair> surround(Pair start) { // System.out.printf("start is (%d, %d)", start.x, start.y); ArrayList<Pair> prlist = new ArrayList<Pair>(); for (int i=0; i<4; i++) { Pair tmp0 = new Pair(start); Pair tmp; if (i==0) { if (start.x>0) { tmp = new Pair(tmp0.x-1,tmp0.y); prlist.add(tmp); } } if (i==1) { if (start.x<size-1) { tmp = new Pair(tmp0.x+1,tmp0.y); prlist.add(tmp); } } if (i==2) { if (start.y>0) { tmp = new Pair(tmp0.x, tmp0.y-1); prlist.add(tmp); } } if (i==3) { if (start.y<size-1) { tmp = new Pair(tmp0.x, tmp0.y+1); prlist.add(tmp); } } } return prlist; }
9dbddc1a-cd1e-4cc2-af8f-357a227eb5df
8
public static void main(String[] args) { //TODO Make tests have less ugly code GameWindow window = new GameWindow(); panel = new RenderPanel() { long lastRender = 0, lastSec = 0; int tickCount = 0, tickSec = 0, renderSec = 0, currTick = 0, currRender = 0; public void onTick() { tickCount++; tickSec++; } public void onPostPaint(Graphics2D g) { renderSec++; long time = new Date().getTime(); if (lastSec + 1000 < time) { lastSec = time; currTick = tickSec; currRender = renderSec; renderSec = 0; tickSec = 0; } g.setColor(Color.WHITE); g.setFont(new Font("Courier New", Font.BOLD, 20)); g.drawString("MS: " + (time - lastRender), 10, 25); g.drawString("Ticks: " + tickCount, 10, 45); g.drawString("FPS: " + currRender, 10, 65); g.drawString("TPS: " + currTick, 10, 85); g.drawString("ROT: "+engine.camera.getRotation(), 10, 105); tickCount = 0; lastRender = time; } }; GameTick tick = new GameTick(); tick.setRenderDelay(0); tick.setThreadDelay(10); listener = new GameListener() { }; window.setRenderPanel(panel); window.setGameTick(tick); window.setGameListener(listener); window.start(); engine = new Engine(); engine.setVerticalFOV(30); Camera cam = new Camera(200, 0,50, 0); engine.useCamera(cam); engine.camera.setRotation(0); Render2D render = new Render2D() { public Polygon[] polygons; public Bounds3D box; public int x = 0, y = 0, z = 0, rotate = 0; public void onInit() { box = new Bounds3D(100, 95, 25, 100, 100, 10); } public void tick() { if(listener.keyDown['a']) rotate -= 1; if(listener.keyDown['d']) rotate += 1; if(listener.keyDown['w']) z -= 1; if(listener.keyDown['s']) z += 1; if(listener.keyDown['t']) { x += 1; box.setX(100 + x); } if(listener.keyDown['g']) { x -= 1; box.setX(100 + x); } //box.rotateZ(rotate); //int rot = (int) (new Date().getTime() * 0.1 % 360); //engine.camera.setRotation(rot); //int pos = (int) (new Date().getTime() * 0.05 % 200); //engine.camera.setZ(pos - 50); //engine.camera.setX(pos + 50); engine.camera.setZ(z); //box.setZ(z); //box.rotateX(rotate); //box.rotateY(rotate); //box.rotateZ(rotate); engine.camera.setRotation(rotate + 90); //System.out.println(engine.camera.getRotation()); //polygons = CopyOfRenderTest2.engine.debuggingRendering(box, // CopyOfRenderTest2.panel.getWidth(), // CopyOfRenderTest2.panel.getHeight()); } public void draw(Graphics2D r) { if (polygons == null) return; r.setStroke(new BasicStroke(5)); r.setColor(Color.RED); r.fillPolygon(polygons[0]); r.setColor(Color.WHITE); r.drawPolygon(polygons[0]); r.setColor(Color.GREEN); r.fillPolygon(polygons[1]); r.setColor(Color.WHITE); r.drawPolygon(polygons[1]); r.setColor(Color.BLUE); r.fillPolygon(polygons[2]); r.setColor(Color.WHITE); r.drawPolygon(polygons[2]); } }; panel.add(render); }
813a9707-8d34-4ea8-a41a-8f4fe363dbcc
0
public ParagraphInputDialog(String paragraph) { super(); setTitle("Podaj opis"); setSize(794,458); getContentPane().setLayout(null); textArea = new JTextArea(); textArea.setText(paragraph); textArea.setBounds(20,20,740,500); scrollPane = new JScrollPane(textArea); scrollPane.setBounds(20,20,740,346); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); getContentPane().add(scrollPane); btnOk = new JButton("Ok"); btnOk.setBounds(596,377,164,30); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { dispose(); } } ); getContentPane().add(btnOk); setVisible(true); }
6175e372-bedb-43d6-940e-1767f7f9bdbd
8
public String getDisplayValue() { StringBuilder buf = new StringBuilder(); appendValue(buf, value); appendValue(buf, adr1); appendValue(buf, adr2); appendValue(buf, adr3); appendValue(buf, (city != null ? city : "")+(city != null && stae != null ? ", " : "")+(stae != null ? stae : "")+ ((city != null || stae != null) && post != null ? " " : "")+(post != null ? post : "")); appendValue(buf, ctry); return buf.toString(); }
449f34c7-3133-481b-9eb1-d37750b48bc6
7
public static int[] convertBase(int[] digits, int baseA, int baseB, int precisionB) { //check for bad input if(baseA < 2 || baseB < 2 || precisionB <1) return null; for(int i=0; i<precisionB ; i++){ if(digits[i] < 0 || digits[i] >= baseA) return null; } int[] ret = new int[precisionB]; int carry = 0; for(int i=precisionB-1;i>=0;i--){ int x = (digits[i]*baseB)+carry; digits[i] = x % baseA; carry = x / baseA; ret[i] = carry; } return ret; }
d1ab003a-53b3-457d-b987-abeb39e49160
4
public boolean checkForHorizontalStrike(String input) { for (int i = 0; i < boardSize; i++) { int count = 0; for (int j = 0; j < boardSize; j++, count++) { if (boardArray[i][j].equalsIgnoreCase(input)) { continue; } break; } if (count == boardSize){ setWinner(input); return true; } } return false; }
69973343-0b01-4aea-a0d4-f73d6718edfd
8
public DbTable LoadTableContent(DbTable table) { //Baseline table contents for(int i =0; i<100; i++) { record = new DbTableRecord(); //Primary key StringBuffer primaryKeyValue = new StringBuffer(); for(String pk:table.get_tableDefinition().getPkColumns()) { primaryKeyValue = primaryKeyValue.append(getColumnValue(pk)); } record.set_primaryKey(primaryKeyValue.toString()); //all columns String[] columnValues = new String[table.get_tableDefinition().getTableColumns().size()]; int columnIndex = 0; String columnValue = null; for(String column:table.get_tableDefinition().getTableColumns()) { columnValue = column; columnValues[columnIndex++] =columnValue; } record.set_values(columnValues); allRecords.add(record); } table.set_tableBaselineContent(allRecords); //Target table contents allRecords = new ArrayList<DbTableRecord>(); for(String pk:table.get_tableDefinition().getPkColumns()) { IdGenerator.ResetID(pk); } for(int i =0; i<100; i++) { record = new DbTableRecord(); //Primary key StringBuffer primaryKeyValue = new StringBuffer(); for(String pk:table.get_tableDefinition().getPkColumns()) { primaryKeyValue = primaryKeyValue.append(getColumnValue(pk)); } record.set_primaryKey(primaryKeyValue.toString()); //all columns String[] columnValues = new String[table.get_tableDefinition().getTableColumns().size()]; int columnIndex = 0; String columnValue = null; for(String column:table.get_tableDefinition().getTableColumns()) { if(i%10==0) { columnValue = column + "_" + i; columnValues[columnIndex++] = columnValue; } else { columnValue = column; columnValues[columnIndex++] = columnValue; } } record.set_values(columnValues); allRecords.add(record); } table.set_tableTargetContent(allRecords); return table; }
30a9571d-98f1-41b4-8116-7cecf233ed26
8
private boolean check() { if (N == 0) { if (first != null) return false; } else if (N == 1) { if (first == null) return false; if (first.next != null) return false; } else { if (first.next == null) return false; } // check internal consistency of instance variable N int numberOfNodes = 0; for (Node x = first; x != null; x = x.next) { numberOfNodes++; } if (numberOfNodes != N) return false; return true; }
025e033a-aa69-4a12-8429-7abf5c3a095b
7
@Override public int compare(Object o1, Object o2) { if ((o1.getClass() != Vertex.class && o1.getClass() != Point.class) || (o2.getClass() != Vertex.class && o2.getClass() != Point.class)) return 0; Vertex v1 = (Vertex)o1; Vertex v2 = (Vertex)o2; if (v1.X() == v2.X()) return (v1.Y() < v2.Y()) ? -1: 1; return (v1.X() < v2.X()) ? -1: 1; }
1a2742ac-18ca-42a2-bde0-160529153053
8
public void inferYBoundsFromSeries() { if (seriesElements.size()==0) { axes.setDataBounds(0, 1, 0, 1); } else { double ymin = seriesElements.get(0).getMinY(); if (ymin > 0) ymin = 0; double ymax = seriesElements.get(0).getMaxY(); for(int i=1; i<seriesElements.size(); i++) { double serMaxY = seriesElements.get(i).getMaxY(); if (serMaxY > ymax) ymax = serMaxY; double serMinY = seriesElements.get(i).getMinY(); if (serMinY < ymin) ymin = serMinY; } if (ymax > 0) ymax = upperVal(ymax); if (ymax == ymin) { if (Math.abs(ymax)<1e-12) { ymin = 0; ymax = 0.001; } else { ymin /= 2.0; ymax *= 1.5; } } axes.setDataBounds(axes.getXMin(), axes.getXMax(), ymin, ymax); axes.setRationalTicks(); } }
c8129f8a-8e23-4b25-9397-f08d76f9419b
6
private String getCountersLink(String taskDetailsJsp, boolean isMapper) { Document mapDetails = HtmlFetcher.getHtml(taskDetailsJsp); Element tr = null; if(useHistory) { tr = mapDetails.getElementsByTag("tbody").first().child(1); } else { for(Element elem : mapDetails.getElementsByTag("tbody").first().children()) { if(elem.child(2).text().equals("SUCCEEDED")) { tr = elem; break; } } } String countersLink; if(isMapper) { if(useHistory) { countersLink = tr.child(8).child(0).absUrl("href"); } else { countersLink = tr.child(8).child(0).absUrl("href"); } } else { if(useHistory) { countersLink = tr.child(10).child(0).absUrl("href"); } else { countersLink = tr.child(10).child(0).absUrl("href"); } } return countersLink; }
01b7d03b-f9cb-4a2f-9fa5-342970bb4516
1
private static int sumOfSquares(int n) { if (n <= 0) { return n; } else { return (n * n + sumOfSquares(n - 1)); } }
fc99498e-c66b-43d9-990e-20fb5ac59a20
3
@Override public boolean removeAllUsers() { FileWriter writer = null; try { writer = new FileWriter(OnlineUsers.directory+OnlineUsers.flatfileData); writer.write(""); } catch (Exception e1) { log.log(Level.SEVERE, "Exception setting all offline from " + OnlineUsers.directory+OnlineUsers.flatfileData, e1); } finally { try { if (writer != null) { writer.close(); return regenFlatFile(); } } catch (IOException ex) { } } return false; }
973bc3ef-36f3-4d71-8ad5-aa6eec806f97
7
public Color getColor(int x){ switch(x){ case 1: BlockColor = Color.BLACK; break; case 2: BlockColor = Color.GREEN; break; case 3: BlockColor = Color.BLUE; break; case 4: BlockColor = Color.ORANGE; break; case 5: BlockColor = Color.MAGENTA; break; case 6: BlockColor = Color.BLUE; break; case 7: BlockColor = Color.RED; break; } return BlockColor; }
0ca5ffff-4b49-4312-a632-487dc9961452
8
public static double countRuns(Board b) { int run = 0; //LEFT/RIGHT for (int i = 0; i < 4; i++){ for (int j = 0; j < 3; j++){ if (nextNum(b.boardState[i][j], b.boardState[i][j+1])){ run++; } if (nextNum(b.boardState[i][j+1], b.boardState[i][j])){ run++; } } } //UP/DOWN for (int j = 0; j < 4; j++){ for (int i = 0; i < 3; i++){ if (nextNum(b.boardState[i][j], b.boardState[i+1][j])){ run++; } if (nextNum(b.boardState[i+1][j], b.boardState[i][j])){ run++; } } } return adjToScore(run); }
d46f9dc5-dc94-4861-8961-4b5b32cac90c
0
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed nuevo.setVisible(false); }//GEN-LAST:event_jButton3ActionPerformed
0e2bcedc-8213-4b51-a628-56af8d3e8ca4
6
private static void mousePressed(Point pressedMousePosition) { Point eventPosition = Camera.untranslatePoint(pressedMousePosition); Model pressed = OurWorld.getModel(eventPosition); if (!rollPlate.contains(new Point(Mouse.getX(), Display.getHeight() - Mouse.getY()))) { if (pressed!=null && (!pressed.getIsComplex() | (isContainsActive=pressed.equals(OurWorld.getPlayerShip())))) { isDragged=true; if (draggedModel!=null) draggedModel.unselect(); draggedModel = pressed.getIsComplex() ? pressed.getModelUnderPoint(eventPosition) : pressed; draggedModel.select(); } else { if (draggedModel!=null) { draggedModel.unselect(); draggedModel = null; } } } pressPoint = new Point(Mouse.getX(), Display.getHeight() - Mouse.getY()); startPlate=new GeometricModel(rollPlate); }
af2c37b9-bdaf-4aac-9a3c-7db4339393a8
1
public Effect getFirstEffectOnPosition(Position position) { List<Effect> effectsOnPosition = getEffectsOnPosition(position); if (!effectsOnPosition.isEmpty()) return getEffectsOnPosition(position).get(0); return null; }
b1c50b8b-dfc9-4b1d-b2d6-c4335cfdcac7
7
public boolean getCanSpawnHere() { if (this.worldObj.rand.nextInt(3) == 0) { return false; } else { if (this.worldObj.checkIfAABBIsClear(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).size() == 0 && !this.worldObj.isAnyLiquid(this.boundingBox)) { int var1 = MathHelper.floor_double(this.posX); int var2 = MathHelper.floor_double(this.boundingBox.minY); int var3 = MathHelper.floor_double(this.posZ); if (var2 < 63) { return false; } int var4 = this.worldObj.getBlockId(var1, var2 - 1, var3); if (var4 == Block.grass.blockID || var4 == Block.leaves.blockID) { return true; } } return false; } }
c65dc78a-441e-4ec2-a5ea-e8f516b481b4
5
@Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub switch (e.getKeyCode()) { case KeyEvent.VK_DOWN: { downPressed=false; } break; case KeyEvent.VK_UP: { upPressed=false; } break; case KeyEvent.VK_RIGHT: { rightPressed=false; } break; case KeyEvent.VK_LEFT: { leftPressed=false; } break; case KeyEvent.VK_SPACE: { spacePressed=false; } break; } }
bba6030d-00ef-417c-9d4d-2ad2c28b78c5
3
public String toString() { String plateauAsciiArt = " 0 1 2 3 4 5 6 7 \n"; for (int numeroDeLigne = 0; numeroDeLigne < NOMBRE_DE_LIGNES; numeroDeLigne++) { plateauAsciiArt += numeroDeLigne + " "; for (int numeroDeColonne = 0; numeroDeColonne < NOMBRE_DE_COLONNES; numeroDeColonne++) { if (this.cases[numeroDeColonne][numeroDeLigne].obtenirPion() != null) plateauAsciiArt += this.cases[numeroDeColonne][numeroDeLigne] .obtenirPion().obtenirCouleur().toString(); else plateauAsciiArt += "+ "; } plateauAsciiArt += "\n"; } return plateauAsciiArt; }
94864b5e-a1f9-4b17-826e-1284cd3ca104
4
public VariableTable registerVarDecl(DeclResult type, ArrayList<String> varList) { VariableTable vTable = new VariableTable(); switch (type.getType()) { case VAR: for (String identi : varList) { vTable.registerVar(identi); } break; case ARRAY: for (String identi : varList) { vTable.registerArray(identi, type.getSizeList()); } break; default: throw new IllegalArgumentException( "in var declaration only allowed VAR and ARRAY, but now is:" + type.getType()); } return vTable; }
9a7146c1-4ddb-4d9a-b8a7-d700a2315efb
1
public ResultSet getAllComponentOfType(String category, int processorType){ ResultSet res = null; try{ String query = "Select componentId as 'Id', componentDescription as 'Component', componentPrice as 'Price',"+ " componentCategoryName as 'Device', componentBrandName as 'Brand' from components" + " inner join component_category on" + " components.componentCategoryID = component_category.componentCategoryID" + " inner join component_brand on" + " components.componentBrandID = component_brand.componentBrandID" + " where componentCategoryName=?" + " and (compatibleWithID =? OR compatibleWithID = 3) ORDER BY componentPrice"; stmnt = CONN.prepareStatement(query); // Bind Parameters stmnt.setString(1, category); stmnt.setInt(2, processorType); res = stmnt.executeQuery(); } catch (SQLException ex) { handleSqlExceptions(ex); } return res; }
1605e364-c4f8-4ff5-acb4-1436401ff160
2
public void setNametextZoomedFont(String font) { if ((font == null) || font.equals("")) { this.nametextZoomedFont = UIFontInits.NAMEZOOMED.getFont(); } else { this.nametextZoomedFont = font; } somethingChanged(); }
d25f44c6-0140-4081-ac93-4d726bc89f1d
9
public void tick(long c64Cycles) { while (cycles < c64Cycles) { // Run one instruction! - with special overflow "patch" - // Always fake 'byte ready' for fast read! // boolean o = overflow; if (byteReady && chips.byteReadyOverflow) { // Set overflow and clear byte ready! overflow = true; byteReady = false; } // overflow = (chips.via2PerControl & 0x0e) == 0x0e ? true : o; // Debugging? if (DEBUG) { String msg; if ((msg = getDebug(pc)) != null) { System.out.println("C1541: " + Integer.toHexString(pc) + "****** " + msg + " Data: " + Integer.toHexString(memory[0x85]) + " => '" + (char) memory[0x85] + '\''); } } if (DEBUG && (monitor.isEnabled() || interruptInExec > 0)) { monitor.disAssemble(memory,pc,acc,x,y, (byte)getStatusByte(),interruptInExec, lastInterrupt); } emulateOp(); if (chips.nextCheck < cycles) { chips.clock(cycles); } // Back to what it was... // overflow = o; } }
687e911c-fd59-426b-bf44-5f266e7a22f4
7
public void testExhaustive(){ Random r= new Random(); int trials = 1000; for(int i = 0; i < trials; i++) { int c1 = r.nextInt(10), r1= r.nextInt(10); int c2 = r.nextInt(10), r2 = r.nextInt(10); Matrix m1 = new Matrix(r1,c1); Matrix m2 = new Matrix(r2,c2); //Test multiplication bounds Object result = m1.times(m2); if(m1.numColumns == m2.numRows) assertNotNull(result); if(m1.numColumns != m2.numRows) assertNull(result); //Test addition result = m1.plus(m2); if( m1.numColumns == m2.numColumns && m1.numRows == m2.numRows) assertNotNull(result); if((m1.numColumns != m2.numColumns || m1.numRows != m1.numRows)) assertNull(result); } }
95cb8ee6-90bd-421a-a287-b197db4232c3
1
public static GameData load(File f) { GameData gD = new GameData(); try { DataFile dF = new DataFile(); dF.load(new FileInputStream((new StringBuilder()).append(f.getAbsolutePath()).toString())); gD.dir = f.getAbsolutePath(); gD.mode = dF.getProperty("mode"); } catch(Exception e) { } return gD; }
170ac6f0-6934-4824-ac9b-432d855acdb5
6
@Override public void run(){ while(true){ int result=-1; // for each thread // check if namenodelocation is available for(Task t : taskQueue){ try { if(t instanceof MapperTask){ result = ((MapperTask) t).performOperation(); } else if(t instanceof ReducerTask){ result = ((ReducerTask) t).performOperation(); } } finally{ if(result==0) taskQueue.remove(t); else Logger.log("Error while executing task " + t.taskId); } } try{ Thread.sleep(1000); }catch(InterruptedException e){ Logger.log("Task Queue interrupted"); } } }
ff8e8a05-2269-4f7d-a64d-52469a5a720e
4
public void update() { if(this.pwidth != this.getWidth() || this.pheight != this.getHeight()) if(this.currentGui != null) { this.currentGui.setBounds(0, 0, this.getWidth(), this.getHeight()); this.currentGui.init(); } this.pwidth = this.getWidth(); this.pheight = this.getHeight(); if(this.currentGui == null) this.world.update(); else this.currentGui.update(this.input.mouseX, this.input.mouseY, this.input.isMouseButtonDown(0)); }
2c6e11dc-079d-4db8-979f-4019fb957092
1
public void mergeBreakedStack(VariableStack stack) { if (breakedStack != null) breakedStack.merge(stack); else breakedStack = stack; }
b12939fc-d591-4d84-ade5-8fef10023c55
0
public String getAlias() { return alias; }
721fe5b5-d62f-41e2-b824-5e9abb610605
5
@EventHandler (priority = EventPriority.HIGHEST) public void onPlayerLogin (PlayerLoginEvent event) { reloadConfig(); if (getConfig().getString("Player."+event.getPlayer().getName()+".CR") == null) getConfig().set("Player."+event.getPlayer().getName()+".CR", "Default"); if (getConfig().getString("Player."+event.getPlayer().getName()+".CC") == null) getConfig().set("Player."+event.getPlayer().getName()+".CC", "Default"); if (getConfig().getString("Player."+event.getPlayer().getName()+".PR") == null) getConfig().set("Player."+event.getPlayer().getName()+".PR", "false"); if (getConfig().getString("Player."+event.getPlayer().getName()+".PW") == null) getConfig().set("Player."+event.getPlayer().getName()+".PW", "0000"); if (getConfig().getString("Player."+event.getPlayer().getName()+".NM") == null) getConfig().set("Player."+event.getPlayer().getName()+".NM", event.getPlayer().getName()); saveConfig(); }//close onPlayerLogin
5f274b33-595f-4874-8c3e-7be473d975e1
5
public Logcat() { mLogcatBeans = new ArrayList<LogcatBean>(); Process.getInstance().getProcessesFromDaemon(); final FrameLogCat logCatFrame = new FrameLogCat(); logCatFrame.setVisible(true); DaemonExecute.getInstance() .setCommand(DaemonCommands.LOGCAT, new DaemonCallback() { @Override public void response(String line) { mLogcatBeans.add(new LogcatBean(line)); try { logCatFrame.getDoc().insertString(0, line, null); logCatFrame.getDoc().insertString(0, "\n", null); } catch (BadLocationException e) { System.out.println(e.getMessage()); } switch (line.charAt(0)) { case 'I': logCatFrame.getDoc().setCharacterAttributes(0, line.length() + 1, logCatFrame.getiStyle(), false); break; case 'D': logCatFrame.getDoc().setCharacterAttributes(0, line.length() + 1, logCatFrame.getdStyle(), false); break; case 'E': logCatFrame.getDoc().setCharacterAttributes(0, line.length() + 1, logCatFrame.geteStyle(), false); break; case 'W': logCatFrame.getDoc().setCharacterAttributes(0, line.length() + 1, logCatFrame.getwStyle(), false); break; default: break; } } }).run(); }
6ce5cad1-d96f-412c-acdb-d2e64531ade6
2
private int collectRows(HashSet<Row> set, int index) { Row row = getRowAtIndex(index); int max = mRows.size(); set.add(row); index++; while (index < max) { Row next = getRowAtIndex(index); if (next.isDescendantOf(row)) { set.add(next); index++; } else { break; } } return index; }
397bf315-3727-4a99-97f5-93b65d89c854
6
public void paint(Graphics g) { w1.draw(g); w2.draw(g); Color c = g.getColor(); g.setColor(Color.RED); g.drawString("missiles count: " + missiles.size(), 10, 50); g.drawString("explosions count: " + explosions.size(), 10, 70); g.drawString("enemyTanks count: " + enemyTanks.size(), 10, 90); g.drawString("MyTank blood : " + myTank.getBlood(), 10, 110); g.setColor(c); if(myTank.isLive() == false){ this.initial(); } myTank.hitOtherTanks(enemyTanks); myTank.eatBloodMedicine(bm); myTank.draw(g); for(int i = 0 ; i < missiles.size() ; i++){ Missile m = missiles.get(i); m.hitTanks(enemyTanks); m.hitTank(myTank); m.hitWall(w1); m.hitWall(w2); m.draw(g); } for(int i = 0 ; i < explosions.size(); i++){ explosions.get(i).draw(g); } if(enemyTanks.size() == 0){ this.initial(); } for(int i = 0 ; i < enemyTanks.size();i ++){ Tank t = enemyTanks.get(i); t.hitWall(w1); t.hitWall(w2); t.hitOtherTanks(enemyTanks); t.draw(g); } if(bm.isLive()) bm.draw(g); }
202db2c3-0b52-41b5-99ee-b929b148c055
9
private float[][] unrollLoop(int beg, int len, boolean loop, boolean pingpong) { // FEATURE SUGGESTION: this could possibly do some anticlick stuff --GM // some thresholds... // TODO: not require such a huge mixSpill value if(!loop) { beg = this.length; len = 1; } int mixSpill = (c5speed<<6)*10/(32*4) + 100; int loopSize = (loop ? (pingpong ? len*2-1 : len) : 1); // allocate float[][] xdata = new float[2][beg + loopSize + mixSpill]; // copy start int p = 0; for(int i = 0; i < beg; i++) { xdata[0][p] = data[0][i]; xdata[1][p++] = data[1][i]; } // copy loop if necessary if(loop) { for(int i = 0; i < len; i++) { xdata[0][p] = data[0][i+beg]; xdata[1][p++] = data[1][i+beg]; } if(pingpong) { for(int i = len-2; i >= 0; i--) { xdata[0][p] = data[0][i+beg]; xdata[1][p++] = data[1][i+beg]; } } } else { xdata[0][p] = 0.0f; xdata[1][p++] = 0.0f; } // unroll to end while(p < xdata[0].length) { xdata[0][p] = xdata[0][p-loopSize]; xdata[1][p] = xdata[1][p-loopSize]; p++; } // return return xdata; }
9479b0b2-90ef-4349-8196-854797b64f84
4
public void appendBlock(StructuredBlock block, int length) { SlotSet succIn = new SlotSet(); SlotSet succKill = new SlotSet(); VariableSet succGen = new VariableSet(); block.fillInGenSet(succIn, succKill); succGen.addAll(succKill); if (this.block == null) { this.block = block; lastModified = block; block.setFlowBlock(this); block.fillSuccessors(); this.length = length; in = succIn; gen = succGen; for (Iterator i = successors.values().iterator(); i.hasNext();) { SuccessorInfo info = (SuccessorInfo) i.next(); info.gen = new VariableSet(); info.kill = new SlotSet(); info.gen.addAll(succGen); info.kill.addAll(succKill); } } else if (!(block instanceof EmptyBlock)) { checkConsistent(); if ((GlobalOptions.debuggingFlags & GlobalOptions.DEBUG_FLOW) != 0) { GlobalOptions.err.println("appending Block: " + block); } SuccessorInfo succInfo = (SuccessorInfo) successors .get(NEXT_BY_ADDR); succIn.merge(succInfo.gen); succIn.removeAll(succInfo.kill); succGen.mergeGenKill(succInfo.gen, succKill); succKill.mergeKill(succInfo.kill); this.in.addAll(succIn); this.gen.addAll(succKill); removeSuccessor(lastModified.jump); lastModified.removeJump(); lastModified = lastModified.appendBlock(block); block.fillSuccessors(); succInfo = (SuccessorInfo) successors.get(NEXT_BY_ADDR); succInfo.gen = succGen; succInfo.kill = succKill; this.length += length; checkConsistent(); doTransformations(); } checkConsistent(); }
0fa60991-eb38-44c0-988e-8e33e91c8ee6
1
synchronized public Element getElementForPage(String pageURL) { String searchXPath = String.format(ELEMENT_BY_URL_XPATH, pageURL); List<Element> result = queryXPathList(searchXPath); return result.size()>0?(Element)result.get(0).clone():null; }
7fe0d61d-aef4-4de3-aa80-3f04855e6f27
4
public final int update(short[] var1, int var2) { if(this.seek >= (float)this.data.data.length) { return 0; } else { for(int var3 = 0; var3 < var2; ++var3) { int var4 = (int)this.seek; short var5 = this.data.data[var4]; short var6 = var4 < this.data.data.length - 1?this.data.data[var4 + 1]:0; var1[var3] = (short)((int)((float)var5 + (float)(var6 - var5) * (this.seek - (float)var4))); this.seek += this.pitch; if(this.seek >= (float)this.data.data.length) { return var3; } } return var2; } }
f439f9ac-13e5-4b64-bc24-2f7e5bf808ef
0
@Override public void setNationality(String nationality) { super.setNationality(nationality); }
b3d2beed-5e61-40d5-9632-fda416ae535a
1
@Override public int getCount(ArrayList<FilterBean> hmFilter) throws Exception { int pages; try { oMysql.conexion(enumTipoConexion); pages = oMysql.getCount("usuario", hmFilter); oMysql.desconexion(); return pages; } catch (Exception e) { throw new Exception("UsuarioDao.getCount: Error: " + e.getMessage()); } }
426bde9a-db58-45e7-a9a9-9b49c4f4122b
8
public CreateRandomTime(String connectStr, String userName, String pass, String outputTable, Time t1StartTime, int t1DurationMillis, Time t2StartTime, int t2DurationMillis, Time t3StartTime, int t3DurationMillis, String experiment) throws SQLException { this.EXP_STR = experiment; this.t1StartTime = t1StartTime; this.t2StartTime = t2StartTime; this.t3StartTime = t3StartTime; this.t1Inc = t1DurationMillis / NUM_PER_NODE; this.t2Inc = t2DurationMillis / NUM_PER_NODE; this.t3Inc = t3DurationMillis / NUM_PER_NODE; this.connexion = DriverManager.getConnection(connectStr, userName, pass); this.outputTable = outputTable; this.rand = new java.util.Random(System.currentTimeMillis()); this.RACK_STRS = new ArrayList<String>(); this.NODES = new ArrayList<Integer>(); RACK_STRS.add("A1"); RACK_STRS.add("A3"); RACK_STRS.add("A4"); RACK_STRS.add("B1"); RACK_STRS.add("B2"); RACK_STRS.add("B3"); RACK_STRS.add("B4"); NODES_IN_RACK = new HashMap<String, List<Integer>>(); List<Integer> a1 = new ArrayList<Integer>(); a1.add(56); a1.add(70); a1.add(83); NODES_IN_RACK.put("A1", a1); List<Integer> a3 = new ArrayList<Integer>(); a3.add(28); a3.add(42); a3.add(55); NODES_IN_RACK.put("A3", a3); List<Integer> a4 = new ArrayList<Integer>(); a4.add(0); a4.add(14); a4.add(27); NODES_IN_RACK.put("A4", a4); List<Integer> b1 = new ArrayList<Integer>(); b1.add(84); b1.add(98); b1.add(111); NODES_IN_RACK.put("B1", b1); List<Integer> b2 = new ArrayList<Integer>(); b2.add(112); b2.add(126); b2.add(139); NODES_IN_RACK.put("B2", b2); List<Integer> b3 = new ArrayList<Integer>(); b3.add(140); b3.add(154); b3.add(166); NODES_IN_RACK.put("B3", b3); List<Integer> b4 = new ArrayList<Integer>(); b4.add(167); b4.add(181); b4.add(191); NODES_IN_RACK.put("B4", b4); NODES.add(0); NODES.add(14); NODES.add(27); NODES.add(28); NODES.add(42); NODES.add(55); NODES.add(56); NODES.add(70); NODES.add(83); NODES.add(84); NODES.add(98); NODES.add(111); NODES.add(112); NODES.add(126); NODES.add(139); NODES.add(140); NODES.add(154); NODES.add(166); NODES.add(167); NODES.add(181); NODES.add(191); this.HD_RACK_STRS = new ArrayList<String>(); this.HD_NODES = new ArrayList<Integer>(); HD_RACK_STRS.add("A1"); HD_RACK_STRS.add("A3"); HD_RACK_STRS.add("A4"); HD_RACK_STRS.add("B1"); HD_RACK_STRS.add("B2"); HD_RACK_STRS.add("B3"); HD_RACK_STRS.add("B4"); HD_NODES_IN_RACK = new HashMap<String, List<Integer>>(); for (int n = 0; n < 192; n++) HD_NODES.add(n); List<Integer> a1Nodes = new ArrayList<Integer>(); for (int n = 56; n <= 83; n++) a1Nodes.add(n); HD_NODES_IN_RACK.put("A1", a1Nodes); List<Integer> a3Nodes = new ArrayList<Integer>(); for (int n = 26; n <= 55; n++) a3Nodes.add(n); HD_NODES_IN_RACK.put("A3", a3Nodes); List<Integer> a4Nodes = new ArrayList<Integer>(); for (int n = 0; n <= 27; n++) a4Nodes.add(n); HD_NODES_IN_RACK.put("A4", a4Nodes); List<Integer> b1Nodes = new ArrayList<Integer>(); for (int n = 84; n <= 111; n++) b1Nodes.add(n); HD_NODES_IN_RACK.put("B1", b1Nodes); List<Integer> b2Nodes = new ArrayList<Integer>(); for (int n = 112; n <= 139; n++) b2Nodes.add(n); HD_NODES_IN_RACK.put("B2", b2Nodes); List<Integer> b3Nodes = new ArrayList<Integer>(); for (int n = 140; n <= 166; n++) b3Nodes.add(n); HD_NODES_IN_RACK.put("B3", b3Nodes); List<Integer> b4Nodes = new ArrayList<Integer>(); for (int n = 167; n <= 191; n++) b4Nodes.add(n); HD_NODES_IN_RACK.put("B4", b4Nodes); }
6c2a564c-2782-4649-ac10-7d7ea02b15e2
4
* @parameter pos, position of the private array where is the shape to be * returned */ public MyShape getShape(int pos) { try { if ((pos >= 0) && (pos < 100) && (pos < this.getShapeCount())) { return this.shapes[pos]; } else { throw null; } } catch (NullPointerException NullPointerException) { System.err.printf("\nException: in method getShape %s\n", NullPointerException); } return null; }
a8a7e913-f70d-4ab7-8c67-02ac7fc3a384
2
public static void main(String[] args) throws ClassNotFoundException { //Class 类是java反射的入口点 //获取类的class对象 // Class<?> classType = Class.forName("java.lang.String"); Class<?> classType = Class.forName(args[0]); Method[] methods = classType.getDeclaredMethods(); for(Method method : methods){ System.out.println(method); } }
b4ba4fe4-e204-4ca7-9b10-f37c18a22f32
0
public String toString() { return path; }
73e26a68-f950-457a-9fff-20e8898070e5
3
private void writeDescriptions() { DefaultTreeCellRenderer treeCellRenderer = new DefaultTreeCellRenderer(); treeCellRenderer.setLeafIcon(null); treeCellRenderer.setOpenIcon(null); treeCellRenderer.setClosedIcon(null); instructionDescriptionTree.setCellRenderer(treeCellRenderer); javax.swing.tree.DefaultMutableTreeNode rootNode = new javax.swing.tree.DefaultMutableTreeNode("rootNode"); javax.swing.tree.DefaultMutableTreeNode haltNoop = new javax.swing.tree.DefaultMutableTreeNode("<html><b>Halt and no operation</b></html>"); javax.swing.tree.DefaultMutableTreeNode jumps = new javax.swing.tree.DefaultMutableTreeNode("<html><b>Jumps</b></html>"); javax.swing.tree.DefaultMutableTreeNode inputOutput = new javax.swing.tree.DefaultMutableTreeNode("<html><b>Input/output</b></html>"); javax.swing.tree.DefaultMutableTreeNode dataMovement = new javax.swing.tree.DefaultMutableTreeNode("<html><b>Data movement</b></html>"); javax.swing.tree.DefaultMutableTreeNode digitwiseManipulation = new javax.swing.tree.DefaultMutableTreeNode("<html><b>Digitwise manipulation</b></html>"); javax.swing.tree.DefaultMutableTreeNode digitShifts = new javax.swing.tree.DefaultMutableTreeNode("<html><b>Digit shifts</b></html>"); javax.swing.tree.DefaultMutableTreeNode arithmetic = new javax.swing.tree.DefaultMutableTreeNode("<html><b>Arithmetic</b></html>"); List<DefaultMutableTreeNode> topNodes = new ArrayList<>(); topNodes.add(haltNoop); topNodes.add(jumps); topNodes.add(inputOutput); topNodes.add(dataMovement); topNodes.add(digitwiseManipulation); topNodes.add(digitShifts); topNodes.add(arithmetic); for (DefaultMutableTreeNode defaultMutableTreeNode : topNodes) { rootNode.add(defaultMutableTreeNode); } List<Word> lowerLimitWords = new ArrayList<>(); lowerLimitWords.add(Word.valueOfLastDigitsOfInteger(10)); lowerLimitWords.add(Word.valueOfLastDigitsOfInteger(20)); lowerLimitWords.add(Word.valueOfLastDigitsOfInteger(30)); lowerLimitWords.add(Word.valueOfLastDigitsOfInteger(40)); lowerLimitWords.add(Word.valueOfLastDigitsOfInteger(60)); lowerLimitWords.add(Word.valueOfLastDigitsOfInteger(70)); lowerLimitWords.add(Word.valueOfLastDigitsOfInteger(99)); int categoryIndex = 0; Word lowerLimitOfNextCategory = lowerLimitWords.get(categoryIndex); DefaultMutableTreeNode currentTopNode = topNodes.get(categoryIndex); for (InstructionFromSet instructionFromSet : InstructionFromSet.values()) { if (instructionFromSet.getOpcode().compareToUnsigned(lowerLimitOfNextCategory) != -1) { categoryIndex++; lowerLimitOfNextCategory = lowerLimitWords.get(categoryIndex); currentTopNode = topNodes.get(categoryIndex); } currentTopNode.add(makeNode(instructionFromSet)); } instructionDescriptionTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode)); }
125b755b-3aa4-418f-9bb6-68d28857a818
3
public void setCondicao(PExpLogica node) { if(this._condicao_ != null) { this._condicao_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); } this._condicao_ = node; }
0b9dc9ca-c9e8-40c5-afbb-bdd95784788e
0
public int getId() { return id; }
514da52c-755c-475e-b604-7a9e5ccb0973
8
public static void envoyerCommande(String nomB,String nomC, ArrayList<String> listeIdProduits) throws IOException { try { gbu = (IGestionBoutiques) Naming.lookup("rmi://localhost/GestionBoutiques"); } catch (NotBoundException ex) { Logger.getLogger(ConnexionThreadClientCommandes.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(ConnexionThreadClientCommandes.class.getName()).log(Level.SEVERE, null, ex); } catch (RemoteException ex) { Logger.getLogger(ConnexionThreadClientCommandes.class.getName()).log(Level.SEVERE, null, ex); } String port = gbu.getPortCommandesBoutique(nomB); String ip = gbu.getPortIPBoutique(nomB); Element racine = new Element("connexion"); org.jdom2.Document doc = new Document(racine); racine.setAttribute("action", "envoyerCommande"); Element commande = new Element("commande"); racine.addContent(commande); Element idCli = new Element("idCli"); commande.addContent(idCli); idCli.setText(nomC); Element date = new Element("date"); commande.addContent(date); date.setText(String.valueOf(new Date().getTime())); Element produits = new Element("produits"); commande.addContent(produits); for (String i : listeIdProduits) { Element produit = new Element("produit"); produits.addContent(produit); produit.setAttribute("id", i); } //envoie XML XMLOutputter sortie = new XMLOutputter(Format.getCompactFormat()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); sortie.output(doc, baos); byte[] tampon = baos.toByteArray(); DatagramSocket socket = null; // Creation du socket try { socket = new DatagramSocket(); } catch (Exception e) { System.err.println("Erreur lors de la creation du socket"); System.exit(-1); } // Creation du message DatagramPacket msg = null; try { InetAddress adresse = InetAddress.getByName(ip); msg = new DatagramPacket(tampon, tampon.length, adresse, Integer.valueOf(port)); } catch (Exception e) { System.err.println("Erreur lors de la creation du message"); System.exit(-1); } // Envoi du message try { socket.send(msg); } catch (Exception e) { System.err.println("Erreur lors de l'envoi du message"); System.exit(-1); } // Fermeture du socket try { socket.close(); } catch (Exception e) { System.err.println("Erreur lors de la fermeture du socket"); System.exit(-1); } }
01fbbd6d-0b20-417d-bcb0-e1a331a4b8ab
9
@Override public void update(Object obj) { if (obj instanceof Vendedor) { Vendedor editar = (Vendedor) obj; Vendedor vendedor; for (int i = 0; i < vendedores.size(); i++) { vendedor = vendedores.get(i); if (vendedor.getIdentificacion() == editar.getIdentificacion()) { vendedores.set(i, editar); break; } } } else if (obj instanceof Mueble) { Mueble editar = (Mueble) obj; Mueble mueble; for (int i = 0; i < muebles.size(); i++) { mueble = muebles.get(i); if (mueble.getReferencia() == editar.getReferencia()) { muebles.set(i, editar); break; } } } else if (obj instanceof Usuario) { Usuario editar = (Usuario) obj; Usuario usuario; for (int i = 0; i < usuarios.size(); i++) { usuario = usuarios.get(i); if (usuario.getLogin().equals(editar.getLogin())) { usuarios.set(i, editar); break; } } } }
a943bafe-0e71-4a8f-9755-fc89974c5c54
0
public static void main(String[] args) { }
c7b67b99-bce0-4d23-b253-eb22f6506004
8
private String getLoadReplacementSignature(int opcode) throws BadBytecode { switch (opcode) { case AALOAD: return "(Ljava/lang/Object;I)Ljava/lang/Object;"; case BALOAD: return "(Ljava/lang/Object;I)B"; case CALOAD: return "(Ljava/lang/Object;I)C"; case DALOAD: return "(Ljava/lang/Object;I)D"; case FALOAD: return "(Ljava/lang/Object;I)F"; case IALOAD: return "(Ljava/lang/Object;I)I"; case SALOAD: return "(Ljava/lang/Object;I)S"; case LALOAD: return "(Ljava/lang/Object;I)J"; } throw new BadBytecode(opcode); }
58bd3f19-0f02-469f-8486-2614c9c41043
7
public boolean containsValue(Object value) { Entry tab[] = table; if (value == null) { for (int i = tab.length ; i-- > 0 ;) { for (Entry e = tab[i] ; e != null ; e = e.next) { if (e.value == null) { return true; } } } } else { for (int i = tab.length ; i-- > 0 ;) { for (Entry e = tab[i] ; e != null ; e = e.next) { if (value.equals(e.value)) { return true; } } } } return false; }
29efeb86-f67e-4dfe-a5c0-a2773c12ea17
9
public void start() { Random random = new Random(); int finishY = track.getFinishY(); int startY = track.getStartY(); int tracks[] = track.getTracks(); for (int t=0; t<turtles.length; t++) { turtles[t].setTrackX(tracks[t]); turtles[t].jumpTo(tracks[t], startY); turtles[t].penDown(); } boolean passedHalf = false; double trackWidth = track.getTrackWidth(); int delay = 10; while (!anyPassed(finishY)) { for (Turtle t : turtles) { if (t.getX() <= t.getTrackX()-trackWidth/6) { t.left(-1); } else if (t.getX() >= t.getTrackX()+trackWidth/6) { t.left(1); } else { t.left(random.nextInt(5)-2); } t.forward(random.nextInt(2+1)); } SimpleWindow.delay(delay); if (!passedHalf && anyPassed((startY-finishY)/2 + finishY)) { Vector<Integer> leaders = getLeaders(); String msg; if (leaders.size() == 1) { msg = "Sköldpadda " + leaders.get(0) + " är först med att ha tagit sig halva sträckan!"; } else { msg = "Sköldpaddorna " + leaders.toString() + " ligger lika och är först med att ha tagit sig halva sträckan!"; } console.print(msg); SimpleWindow.delay(2000); passedHalf = true; } } Vector<Integer> leaders = getLeaders(); for (Integer i : leaders) { console.print("Sköldpadda " + i + " kom på förstaplats!"); } }
f6c9ff9e-24b0-405e-9a5c-c78ad3410aed
9
@Override public boolean handleDownloadDirCommand(String providedCommandLine, PrintStream outputStream, IServerStatusInterface targetServerInterface) { boolean retVal = false; String[] commParts = GenericUtilities.splitBySpace(providedCommandLine); if(commParts != null && commParts.length >= 2) { String toSetLev = commParts[1]; if(toSetLev.equals("get")) { outputStream.println("Current Download Directory:"+DownloadCommandServerHandler.downloadDir); retVal = true; } else if(toSetLev.equals("set") && commParts.length > 2) { File toSetDir = new File(commParts[2]); try { if(!toSetDir.exists()) { toSetDir.mkdirs(); retVal = true; } else if(toSetDir.isDirectory()) { retVal = true; } if(retVal) { DownloadCommandServerHandler.downloadDir = toSetDir.getAbsolutePath(); outputStream.println("Successfully set provided directory as download directory"); } } catch(Exception e) { retVal = false; outputStream.println("Error:Improper directory provided."); } } } return retVal; }