method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
4ab568e2-08d2-43e2-b6e0-ed3d1bdec95e
7
public ListNode mergeTwoLists(ListNode l1, ListNode l2) { if (l1 == null) return l2; if (l2 == null) return l1; ListNode head, last, p1, p2; p1 = l1; p2 = l2; if (p1.val < p2.val) { head = p1; p1 = p1.next; } else { head = p2; p2 = p2.next; } last = head; while (p1 != null && p2 != null) { if (p1.val < p2.val) { last.next = p1; p1 = p1.next; } else { last.next = p2; p2 = p2.next; } last = last.next; } if (p1 != null) { last.next = p1; } else { last.next = p2; } return head; }
5a967968-8619-4ba8-aa46-5d2626ec3b6f
7
@Override public int compareTo(Object o) { if(compareType == 0) { String name1 = this.name; String name2 = ((Term) o).name; int size = name1.length(); if (name1.length() > name2.length()) size = name2.length(); for (int i = 0; i < size; i++) { char word1 = name1.charAt(i); char word2 = name2.charAt(i); if (word1 < word2) { return -1; } if (word1 > word2) { return 1; } } if (name1.length() < name2.length()) return -1; else return 1; } if(compareType == 1){ Integer count1 = this.getTotalFrequency(); Integer count2 = ((Term) o).getTotalFrequency(); return count1.compareTo(count2); } return 0; }
6fb6e532-7d2c-44de-8612-ceade2df92ee
0
public Grid(int width, int height, int intelligentX, int intelligentY, int targetX, int targetY) { super(); this.width = width; this.height = height; this.intelligentX = intelligentX; this.intelligentY = intelligentY; this.targetX = targetX; this.targetY = targetY; currentCells = new boolean[width * height]; nextCells = new boolean[width * height]; }
1ad7adc6-84c0-4a0e-8c64-5b5160d50e1a
4
private MoveResult checkresign(HantoPieceType pieceType, HantoCoordinate from, HantoCoordinate to) { MoveResult result = MoveResult.OK; if(pieceType == null && from == null && to == null) { if(turn.equals(HantoPlayerColor.BLUE)) { result = MoveResult.RED_WINS; } else { result = MoveResult.BLUE_WINS; } gameIsOver = true; } return result; }
e21a685b-dbe1-49f6-a893-8bd9b2ca8e9e
4
public static int triangleBmin(int x[][]) { int min = x[0][0]; for (int i = 0; i < x.length; i++) { System.out.print("\n"); for (int j = 0; j < x[i].length; j++) { if (i >= j) { System.out.print(x[i][j] + " "); if (min > x[i][j]) { min = x[i][j]; } } } } System.out.println(); return min; }
93b1e22c-89a1-4e1d-b650-d940dbd508da
4
public static BigInteger determinant(Matrix matrix) throws NoSquareException { if (!matrix.isSquare()) throw new NoSquareException("matrix need to be square."); if (matrix.size() == 1){ return matrix.getValueAt(0, 0); } if (matrix.size()==2) { return (matrix.getValueAt(0, 0).multiply(matrix.getValueAt(1, 1))).subtract(matrix.getValueAt(0, 1).multiply(matrix.getValueAt(1, 0))); } BigInteger sum = new BigInteger("0"); for (int i=0; i<matrix.getNcols(); i++) { sum = sum.add(BigInteger.valueOf(changeSign(i)).multiply(matrix.getValueAt(0, i)).multiply(determinant(createSubMatrix(matrix, 0, i)))); } return sum; }
0ad29986-6479-4da1-8c88-0be82a473768
1
public void drawSettingsMenu() { if (drawingSettingsMenu) setMenu.drawWindow(); }
8beaab24-cc7d-41a6-acb1-f00884e1000a
2
public void load(int ID) { if(Consumable.loadConsumable(ID) != null) { Consumable consumable = Consumable.loadConsumable(ID); textPane.setText(consumable.getFlavorText()); for(int x = 0; x<consumable.getEffectsTotal(); x++) { listModel.addElement(consumable.getStat(x) + ";" + consumable.getEffect(x) + ";" + consumable.getStat(x) + ";" + consumable.getPercent(x) + ";" + consumable.getDuration(x)); } } }
10d56ded-f0ee-4e95-b351-2722aa50b78b
4
void readGenomeConfig(String genVer, Properties properties) { String genomePropsFileName = dataDir + "/" + genVer + "/snpEff.config"; try { // Read properties file "data_dir/genomeVersion/snpEff.conf" // If the file exists, read all properties and add them to the main 'properties' Properties genomeProps = new Properties(); genomeProps.load(new FileReader(new File(genomePropsFileName))); // Copy genomeProperties to 'properties' for (Object propKey : genomeProps.keySet()) { String pk = propKey.toString(); String propVal = genomeProps.getProperty(pk); if (properties.getProperty(pk) == null) { properties.setProperty(pk, propVal); } else System.err.println("Ignoring property '" + pk + "' in file '" + genomePropsFileName + "'"); } } catch (Exception e) { if (debug) System.err.println("File '" + genomePropsFileName + "' not found"); // File does not exists? => OK } Genome genome = new Genome(genVer, properties); genomeByVersion.put(genVer, genome); }
8d17fd88-003c-4c66-960c-6266ee3cb4df
7
public String readWord() { StringBuffer buffer = new StringBuffer(128); char ch = ' '; int count = 0; String s = null; try { while (ready() && Character.isWhitespace(ch)) ch = (char)myInFile.read(); while (ready() && !Character.isWhitespace(ch)) { count++; buffer.append(ch); myInFile.mark(1); ch = (char)myInFile.read(); }; if (count > 0) { myInFile.reset(); s = buffer.toString(); } else { myErrorFlags |= EOF; } } catch (IOException e) { if (myFileName != null) System.err.println("Error reading " + myFileName + "\n"); myErrorFlags |= READERROR; } return s; }
c147d745-dccc-4266-b9f3-19c88904fa88
2
public ArrayList<Upgrade> getUpgradesByType(UpgradeType type){ ArrayList<Upgrade> matching = new ArrayList<Upgrade>(); for(Upgrade u : allUpgrades){ if(u.getType() == type){ matching.add(u); } } return matching; }
44def04b-16ab-483f-ab89-761ccce8c299
7
private int parseAndSaveToAlbum(Map root, Album album, boolean firstElementCount) { int count = 0; ArrayList<Object> photosMapsTmp = (ArrayList<Object>) root.get(RESPONSE); if (firstElementCount) { count = ((Double) photosMapsTmp.get(0)).intValue(); photosMapsTmp.remove(0); } ArrayList<Map<String, Object>> photosMaps = new ArrayList<>(); for (Object obj : photosMapsTmp) { System.out.println("obj : " + obj); photosMaps.add((Map<String, Object>) obj); } // ArrayList<Map<String, Object>> photosMaps = (ArrayList<Map<String, Object>>) root.get(RESPONSE); for (Map photoMap : photosMaps) { Photo photo = new Photo(); photo.setText((String) photoMap.get(TEXT)); String src = null; String[] keys = {"src_xxxbig", "src_xxbig", "src_xbig", "src_big", "src"}; for (String key : keys) { src = (String) photoMap.get(key); if (src != null && !src.equals("null")) { break; } } photo.setSrc(src); photo.setLikes(((Double) ((Map) (photoMap.get(LIKES))).get(COUNT)).intValue()); photo.setCreated(new Date(((Double) photoMap.get(CREATED)).longValue() * 1000)); photo.setAlbum(album); if (!photoContainsInAlbums(photo)) { album.addPhoto(photo); System.out.println(photo); } } return count; }
9f0cceba-1051-4a53-a44f-0e0b721cfe96
7
private void sortFields() { // Method Instances DiagramFieldPanel fieldPanel; if(isSort()) { for(int i = 0; i < fieldsPanel.getComponentCount()-1; i++) { String master = ((DiagramFieldPanel) fieldsPanel.getComponent(i)).getName(); for(int j = i + 1; j < fieldsPanel.getComponentCount(); j++) { String slave = ((DiagramFieldPanel) fieldsPanel.getComponent(j)).getName(); if(master.compareTo(slave) > 0) { fieldPanel = (DiagramFieldPanel) fieldsPanel.getComponent(j); fieldsPanel.remove(fieldPanel); fieldsPanel.add(fieldPanel, i); master = slave; } } } } else { for(int i = 0; i < fieldsPanel.getComponentCount() - 1; i++) { int master = ((DiagramFieldPanel) fieldsPanel.getComponent(i)).getFieldPosition(); for(int j = i + 1; j < fieldsPanel.getComponentCount(); j++) { int slave = ((DiagramFieldPanel) fieldsPanel.getComponent(j)).getFieldPosition(); if(master > slave) { fieldPanel = (DiagramFieldPanel) fieldsPanel.getComponent(j); fieldsPanel.remove(fieldPanel); fieldsPanel.add(fieldPanel, i); master = slave; } } } } queryBuilderPane.sqlDiagramViewPanel.repaint(); queryBuilderPane.sqlDiagramViewPanel.validate(); queryBuilderPane.sqlDiagramViewPanel.doResize(); }
a7f630bf-8235-4718-9f6c-6947bcf35e56
6
public static OS getPlatform() { String osName = System.getProperty("os.name").toLowerCase(); if (osName.contains("win")) return OS.windows; if (osName.contains("mac")) return OS.macos; if (osName.contains("solaris")) return OS.solaris; if (osName.contains("sunos")) return OS.solaris; if (osName.contains("linux")) return OS.linux; if (osName.contains("unix")) return OS.linux; return OS.unknown; }
41002b8f-8f9d-41f8-9a86-d30971486049
1
private static Status StatusObject(ResultSet rs) { Status newStatus = null; try { newStatus = new Status(rs.getInt(rs.getMetaData().getColumnName(1)), rs.getString(rs.getMetaData().getColumnName(2))); } catch (SQLException e) { Error_Frame.Error(e.toString()); } return newStatus; }
2ba8774c-fe56-4147-ae67-6fccfbeeee7c
2
private static Float getFloat() { Boolean flag; float numFloat = 0; do { Scanner scanner = new Scanner(System.in); try { numFloat = scanner.nextFloat(); flag = true; } catch (Exception e) { flag = false; System.out.println("Input type mismach!"); System.out.print("Please input in Float: "); } } while (!flag); return numFloat; }
632830ce-7bd8-4885-a96c-8f45b3295a61
7
@Override public void changeCatalogUsage(Physical P, boolean toCataloged) { synchronized(getSync(P).intern()) { if((P!=null) &&(P.basePhyStats()!=null) &&(!P.amDestroyed())) { if(toCataloged) { changeCatalogFlag(P,true); final CataData data=getCatalogData(P); if(data!=null) data.addReference(P); } else if(CMLib.flags().isCataloged(P)) { changeCatalogFlag(P,false); final CataData data=getCatalogData(P); if(data!=null) data.delReference(P); } } } }
dc1e4adb-bc6c-41aa-a3fd-2e61e2793f1b
0
public void addButton(Container c, String title, ActionListener listener) { JButton button = new JButton(title); c.add(button); button.addActionListener(listener); }
11467614-a53e-43c7-94b2-7bc167ad1004
3
@Override public void sell(Command cmd) { cmd.execute(); if(Storage.getInstance().getRevenue() < 10000.0) { restaurant.setState(restaurant.getBadstate()); }else if(Storage.getInstance().getRevenue() >= 10000.0 && Storage.getInstance().getRevenue() < 20000.0) { restaurant.setState(restaurant.getNormalstate()); } else { restaurant.setState(restaurant.getGoodstate()); } }
8af0537d-1118-4f62-9d11-39a2da560c58
6
public void moveFileFromJar(String jarFileName, String targetLocation, Boolean overwrite) { try { File targetFile = new File(targetLocation); if(overwrite || targetFile.exists() == false || targetFile.length() == 0) { InputStream inFile = getClass().getClassLoader().getResourceAsStream(jarFileName); FileWriter outFile = new FileWriter(targetFile); int c; while ((c = inFile.read()) != -1) { outFile.write(c); } inFile.close(); outFile.close(); } } catch(NullPointerException e) { getLogger().info("Failed to create " + jarFileName + "."); } catch(Exception e) { e.printStackTrace(); } }
96bd4c76-69a2-4c86-b668-2103eb7c4dbf
8
public static void handle(String[] tokens, Client client) { if(tokens.length != 3) { return; } Channel channel = Server.get().getChannel(tokens[1]); if(channel == null || !channel.getClients().contains(client)) { return; } if(client.isAway()) { client.setAway(false); } if(!client.isModerator()) { if (client.checkSpam(channel.getName())) { return; } } String message = tokens[2].trim(); if(message.isEmpty()) { return; } if(message.charAt(0) == '/') { CommandParser.parse(message, client, channel); } else { channel.broadcastMessage(message, client, false); } }
70139552-6b21-4e13-b485-4631b36008c0
1
static public void zoomIn() { if(zoom<17) { zoom++; zoomIndex++; } }
947fdbb6-dbba-4696-aa36-e8466b1b23f0
1
public void visitRetStmt(final RetStmt stmt) { if (CodeGenerator.DEBUG) { System.out.println("code for " + stmt); } genPostponed(stmt); final Subroutine sub = stmt.sub(); Assert.isTrue(sub.returnAddress() != null); method.addInstruction(Opcode.opcx_ret, sub.returnAddress()); }
b6c296f4-b5c2-4f1e-9bb2-39e823b0ed5e
9
private void paint(Display display, GC gc) { Color white = colors.getWhite(); Color black = colors.getBlack(); Color grey30 = colors.getGrey30(); Color grey50 = colors.getGrey50(); Color grey80 = colors.getGrey80(); Color grey120 = colors.getGrey120(); // Calculate left margin to center the keyboard. int clientWidth = nWhiteKeys * keyWidth + 10; int leftMargin = (getWidget().getBounds().width - clientWidth - 20) / 2 + 5; Pitch pitch; pitch = new Pitch("a0"); // Draw the border of the keyboard. gc.setBackground(grey30); gc.fillRectangle(leftMargin - borderWidth, topMargin - borderWidth - 1, nWhiteKeys * keyWidth + borderWidth * 2 + 1, keyHeight + borderWidth + 2); // Draw a gradient above the keyboard. gc.setBackground(grey30); gc.setForeground(grey120); gc.fillGradientRectangle(leftMargin - borderWidth + 1, topMargin - borderWidth, nWhiteKeys * keyWidth + borderWidth * 2 - 1, topMargin, true); // Draw every white key. for(int x = 0; x < nWhiteKeys; x++) { Color selected = getSelectedColor(pitch); // Draw rectangle for the key. gc.setForeground(black); gc.setBackground((selected != null) ? selected : white); gc.fillRectangle(leftMargin + keyWidth * x, topMargin, keyWidth, keyHeight); gc.drawRectangle(leftMargin + keyWidth * x, topMargin, keyWidth, keyHeight); // Get the pitch of the next white key. pitch = pitch.nextSemitone(); // Add an extra semitone except between B/C and E/F. if(x % 7 != 1 && x % 7 != 4) { pitch = pitch.nextSemitone(); } } pitch = new Pitch("a#0"); // Draw every black key. for(int x = 0; x < nWhiteKeys - 1; x++) { // Skip a black key between B/C and E/F. if(x % 7 == 1 || x % 7 == 4) { pitch = pitch.nextSemitone(); continue; } Color selected = getSelectedColor(pitch); int left = leftMargin + keyWidth * x + keyWidth / 2 + blackMargin; int width = keyWidth - blackMargin * 2 + 1; // Draw rectangle for this key. gc.setForeground(black); gc.setBackground((selected != null) ? selected : black); gc.fillRectangle(left, topMargin, width, blackKeyHeight); gc.drawRectangle(left, topMargin, width, blackKeyHeight); if(selected == null) { // Add a lower highlight to the key. gc.setBackground(grey50); gc.fillRectangle(left + 1, topMargin + blackKeyHeight - 5, width - 1, 5); gc.setForeground(grey80); gc.drawLine(left + 1, topMargin + blackKeyHeight - 5, left + width - 1, topMargin + blackKeyHeight - 5); } // Get the pitch of the next black key. pitch = pitch.nextSemitone(); pitch = pitch.nextSemitone(); } }
d81ee718-0bdf-422e-97cb-4472e897bf7e
2
public void simulate() { long _time = 1000000L; if (this._labyrinthType.equals("g")) { // This behavior is applied for // graph based labyrinths. // Load the labyrinth from the .xml file this._labyrinthFactory.setFilename(this._filename); de.unihannover.sim.labysim.model.graph.Labyrinth _labyrinth = this._labyrinthFactory .getGraphLabyrinth(); // Load the agents from the .xml file and provide them with the // engine and the labyrinth. this._agentFactory.setFilename(this._filename); this._agentFactory.setGraphLabyrinth(_labyrinth); this._agentFactory.setSimEngine(this._engine); LinkedList<GraphAgent> _agents = this._agentFactory .getGraphAgents(); // Run the simulation. this._engine.simulate(_time); // Save results to .xml file OutputWriter _outputWriter = new OutputWriter(_filename); _outputWriter.setGraphAgents(_agents); _outputWriter.write(); } else if (this._labyrinthType.equals("b")) { // This behavior is // applied for bitmap // based labyrinths. // Load the labyrinth from the .xml file this._labyrinthFactory.setFilename(this._filename); de.unihannover.sim.labysim.model.bmp.Labyrinth _labyrinth = this._labyrinthFactory .getBMPLabyrinth(); // Load the agents from the .xml file and provide them with the // engine and the labyrinth. this._agentFactory.setFilename(this._filename); this._agentFactory.setBMPLabyrinth(_labyrinth); this._agentFactory.setSimEngine(this._engine); LinkedList<BMPAgent> _agents = this._agentFactory .getBMPAgents(); // Run the simulation. this._engine.simulate(_time); // Save results to .xml file OutputWriter _outputWriter = new OutputWriter(_filename); _outputWriter.setBMPAgents(_agents); _outputWriter.write(); } else { printUsage(); } }
848e27c0-5a9f-456e-8eb2-5dd97936980f
9
private final void method645(r_Sub2 var_r_Sub2, boolean bool) { anInt5601++; if (anInt5665 > aGLToolkit5692.anIntArray6747.length) { aGLToolkit5692.anIntArray6749 = new int[anInt5665]; aGLToolkit5692.anIntArray6747 = new int[anInt5665]; } int[] is = aGLToolkit5692.anIntArray6747; int[] is_108_ = aGLToolkit5692.anIntArray6749; for (int i = 0; (anInt5672 ^ 0xffffffff) < (i ^ 0xffffffff); i++) { int i_109_ = -var_r_Sub2.anInt11064 + (anIntArray5595[i] - (anIntArray5588[i] * aGLToolkit5692.anInt6732 >> 8) >> aGLToolkit5692.anInt6611); int i_110_ = -var_r_Sub2.anInt11067 + (anIntArray5637[i] + -(aGLToolkit5692.anInt6717 * anIntArray5588[i] >> 8) >> aGLToolkit5692.anInt6611); int i_111_ = anIntArray5633[i]; int i_112_ = anIntArray5633[i - -1]; for (int i_113_ = i_111_; (i_113_ ^ 0xffffffff) > (i_112_ ^ 0xffffffff); i_113_++) { int i_114_ = -1 + aShortArray5679[i_113_]; if ((i_114_ ^ 0xffffffff) == 0) { break; } is[i_114_] = i_109_; is_108_[i_114_] = i_110_; } } if (bool != true) { method624(31, 63, null, true, 0); } for (int i = 0; (anInt5616 ^ 0xffffffff) < (i ^ 0xffffffff); i++) { if (aByteArray5658 == null || (aByteArray5658[i] ^ 0xffffffff) >= -129) { short s = aShortArray5622[i]; short s_115_ = aShortArray5683[i]; short s_116_ = aShortArray5706[i]; int i_117_ = is[s]; int i_118_ = is[s_115_]; int i_119_ = is[s_116_]; int i_120_ = is_108_[s]; int i_121_ = is_108_[s_115_]; int i_122_ = is_108_[s_116_]; if (-((i_119_ + -i_118_) * (-i_120_ + i_121_)) + (i_117_ + -i_118_) * (-i_122_ + i_121_) > 0) { var_r_Sub2.method2370(i_117_, i_120_, i_118_, i_121_, i_122_, i_119_, 86); } } } }
9af0bf64-6860-4d62-8df6-f2487f9da17c
8
static int process(String line) { if(line == null || line.trim().length() == 0) return 0; int[] inp = giveArray(line.trim().split(" ")); int n = inp[0], b = inp[1], h = inp[2], w = inp[3]; int[][] havail = new int[h][]; int[] hcost = new int[h]; for(int i = 0; i < h; i++) { hcost[i] = Integer.parseInt(readLine().trim()); havail[i] = giveArray(readLine().trim().split(" ")); } long cost = Long.MAX_VALUE; for(int i = 0; i < w; i++) { long min = Long.MAX_VALUE; for(int j = 0; j < h; j++) { if(havail[j][i] >= n) min = Math.min(min, hcost[j]); } if(min == Long.MAX_VALUE) { } else { cost = Math.min(min * n, cost); } } if(cost > b) { System.out.println("stay home"); } else System.out.println(cost); return 1; }
d2dd09cd-09cf-4eb8-9d16-e92b1d96368d
8
@SuppressWarnings({ "resource" }) public ConnectionTable(String filePath) throws Exception { BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new FileReader(filePath)); String currentLine = bufferedReader.readLine(); while(currentLine != null) { if(!currentLine.isEmpty()) { String[] namePair = getNamesFromInputLine(currentLine); if(namePair == null || namePair.length != 2) throw new Exception("File consists incorrectly formated input lines.Expected - 'name:name'"); String person1 = namePair[0]; String person2 = namePair[1]; if(!setOfperson.contains(person1)) { setOfperson.add(person1); connectionGraph.put(person1, new HashSet<String>()); } if(!setOfperson.contains(person2)) { setOfperson.add(person2); connectionGraph.put(person2, new HashSet<String>()); } connectionGraph.get(person1).add(person2); connectionGraph.get(person2).add(person1); } currentLine = bufferedReader.readLine(); } bufferedReader.close(); } catch (FileNotFoundException e) { if(bufferedReader != null) bufferedReader.close(); throw new IOException("File was not found. Check the path specified in the input"); } }
92f5ba49-b666-461b-a2e8-b9bf52e53716
8
public void keyPressed(KeyEvent e) { char c = e.getKeyChar(); int t = Integer.parseInt(editor.getText()); if (Character.isLetter(c)) { error(); editor.setText("" + t); } else { if (e.getKeyCode() == KeyEvent.VK_UP && e.isControlDown()) { if (t < maxim - 4) { editor.setText("" + (t + 4)); } } if (e.getKeyCode() == KeyEvent.VK_DOWN && e.isControlDown()) { if (t > minim + 4) { editor.setText("" + (t - 4)); } } if (e.getKeyCode() == KeyEvent.VK_ENTER) { valid(); } } }
52faa820-9c25-49f5-a04f-3b39d69cfe91
1
public void passWeekAll() { System.out.println("WEEK "+week+"!"); this.earnBonus(); for (int i=0; i<6; i++) { employees[i].workWeek(); System.out.println(employees[i]); } week+=1; }
35ccbc94-e693-4a37-9bc4-61c27fb4ec5b
9
public Outcome getOutcome(Choice c) { switch (this) { case ROCK: return c.equals(ROCK) ? Outcome.TIE : c.equals(PAPER) ? Outcome.LOSS : Outcome.WIN; case PAPER: return c.equals(PAPER) ? Outcome.TIE : c.equals(SCISSORS) ? Outcome.LOSS : Outcome.WIN; case SCISSORS: return c.equals(SCISSORS) ? Outcome.TIE : c.equals(ROCK) ? Outcome.LOSS : Outcome.WIN; default: return Outcome.TIE; } }
0e12902a-f806-40bb-b8f5-0d2b3f77f263
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(BuscaModelo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(BuscaModelo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(BuscaModelo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(BuscaModelo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new BuscaModelo().setVisible(true); } }); }
73af6826-8b63-463e-b594-1fa4d3ae12c0
0
public void setYAxisDeadZone(float zone) { setDeadZone(yaxis,zone); }
2d927f21-7966-42fb-881c-b685c2eb3ba0
3
public BCAlgorithm(String name) { super(); algName = name; if (algName.equalsIgnoreCase("SkipJack")) { keyLength = 8; } else if (algName.equalsIgnoreCase("TwoFish")) { keyLength = 16; } else if (algName.equalsIgnoreCase("Salsa20")) { keyLength = 16; } }
7d92af99-4e7a-4d2c-bcac-14e2785d228d
3
public static int getTotalEnergy() { if (Debug.active) { int total = energy; for (ArrayList<Organism> orgs : organisms) { for (Organism org: orgs) { total += org.life.get(); } } return total; } return 0; }
2dc451ea-9cdc-47ea-a06e-3d0d436cd15f
1
ObjectiveFunction getOF() { if (of == null) { throw new IllegalArgumentException("No Objective function method defined."); } return of; }
e5443eb9-aa94-4aff-8fdc-e754f104785e
4
public boolean isVictory(final HantoPlayerColor color){ boolean isVictory = false; HantoCell butterflyCell = null; int gridSize = occupiedCells.size(); for(int i = 0; i < gridSize - 1; i++){ HantoPiece curPiece = occupiedCells.get(i).getPiece(); if (curPiece.getType() == HantoPieceType.BUTTERFLY && curPiece.getColor() != color){ butterflyCell = occupiedCells.get(i); break; } } if (butterflyCell != null){ isVictory = isSurroundingCellsOccupied(butterflyCell); } return isVictory; }
078f8866-bd10-460d-8e1a-82c4c350f7d3
5
protected static Ptg calcAsc( Ptg[] operands ) { if( (operands == null) || (operands[0] == null) ) { return new PtgErr( PtgErr.ERROR_VALUE ); } // determine if Excel's language is set up for DBCS; if not, returns normal string WorkBook bk = operands[0].getParentRec().getWorkBook(); if( bk.defaultLanguageIsDBCS() ) { // otherwise just returns normal string byte[] strbytes = getUnicodeBytesFromOp( operands[0] ); if( strbytes == null ) { strbytes = (operands[0].getValue()).toString().getBytes(); } try { return new PtgStr( new String( strbytes, XLSConstants.UNICODEENCODING ) ); } catch( Exception e ) { } } return new PtgStr( operands[0].getValue().toString() ); }
91ca4e05-6d01-4126-9530-17d81e88a98e
4
public String getCurrentAnimationState(){ switch (currentAnimationState) { case 1: return "idle"; case 2: return "walk"; case 3: return "jump"; case 4: return "fall"; default: return "NOT DEFINED YET"; } }
60c69c88-ffad-4898-965b-e9f1d43f0bce
9
protected void doRetrieveMatchingFiles(String fullPattern, File dir, Set<File> result) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Searching directory [" + dir.getAbsolutePath() + "] for files matching pattern [" + fullPattern + "]"); } File[] dirContents = dir.listFiles(); if (dirContents == null) { if (logger.isWarnEnabled()) { logger.warn("Could not retrieve contents of directory [" + dir.getAbsolutePath() + "]"); } return; } for (File content : dirContents) { String currPath = StringUtils.replace(content.getAbsolutePath(), File.separator, "/"); if (content.isDirectory() && getPathMatcher().matchStart(fullPattern, currPath + "/")) { if (!content.canRead()) { if (logger.isDebugEnabled()) { logger.debug("Skipping subdirectory [" + dir.getAbsolutePath() + "] because the application is not allowed to read the directory"); } } else { doRetrieveMatchingFiles(fullPattern, content, result); } } if (getPathMatcher().match(fullPattern, currPath)) { result.add(content); } } }
694d0f9d-17c0-40b0-b99a-d28db4395d89
9
private static LinkedList<ElementSuffixe> trad49(TreeNode tree){ // tree symbol is <element suffixe> int r = tree.getRule() ; switch (r) { case 0 : // <element suffixe> --> <element access> <element suffixe> { ElementSuffixe x0 = trad52(tree.getChild(0)) ; LinkedList<ElementSuffixe> x1 = trad49(tree.getChild(1)) ; if (x1 == null) x1 = new LinkedList<ElementSuffixe>(); x1.push(x0); return x1 ; // a modifier } case 1 : // <element suffixe> --> <operation suffixe> <element suffixe> { ElementSuffixe x0 = trad53(tree.getChild(0)) ; LinkedList<ElementSuffixe> x1 = trad49(tree.getChild(1)) ; if (x1 == null) x1 = new LinkedList<ElementSuffixe>(); x1.push(x0); return x1; // a modifier } case 2 : // <element suffixe> --> <message sending suffixe> <element suffixe> { ElementSuffixe x0 = trad43(tree.getChild(0)) ; LinkedList<ElementSuffixe> x1 = trad49(tree.getChild(1)) ; if (x1 == null) x1 = new LinkedList<ElementSuffixe>(); x1.push(x0); return x1; } case 3 : // <element suffixe> --> <assignment expression suffixe> <element suffixe> { ElementSuffixe x0 = trad57(tree.getChild(0)) ; LinkedList<ElementSuffixe> x1 = trad49(tree.getChild(1)) ; if (x1 == null) x1 = new LinkedList<ElementSuffixe>(); x1.push(x0); return x1; } case 4 : // <element suffixe> --> <lambda> { return null ; // a modifier } default : return null ; } }
5071def1-5065-45c0-b05e-f9ec569f3079
9
public void render(Image image, Parameters params) { int width = image.getWidth(null); int height = image.getHeight(null); if (width == -1 || height == -1) { // Image is not ready yet. throw new IllegalArgumentException("image not loaded"); } Graphics g = image.getGraphics(); double minX = params.getMinX().doubleValue(); double maxX = params.getMaxX().doubleValue(); double minY = params.getMinY().doubleValue(); double maxY = params.getMaxY().doubleValue(); double dx = (maxX - minX) / width; double dy = (maxY - minY) / height; int dwellLimit = 100; // avoid using sqrt() repeatedly by squaring the escape radius. double escapeRadius = 4.0; // 2.0 ^ 2 boolean interrupted = false; for (int x = 0; x < width; x++) { double cr = dx * x + minX; for (int y = 0; y < height; y++) { double ci = dy * y + minY; double zr = cr; double zi = ci; double m; int iter = 1; do { // z = z * z + c double r = zr * zr - zi * zi; zi = 2.0 * zr * zi + ci; zr = r + cr; // magnitude (would use sqrt() normally) m = zr * zr + zi * zi; iter++; } while (m < escapeRadius && iter < dwellLimit); float h = (float) iter / (float) dwellLimit; float b = 1.0f - h * h; g.setColor(Color.getHSBColor(h, 0.8f, b)); g.drawLine(x, y, x, y); } if (Thread.interrupted()) { interrupted = true; break; } if (x % 25 == 0) { fireUpdate(100 * x / width); } } if (!interrupted) { fireUpdate(100); } }
9483cf56-35ee-426c-aa2f-4bf39bfb7e12
3
public boolean add(String word, int edit_distance) { // records the previous node Predecessor prev = this; // stores current node TopNode node = front; while( node != null) { if (edit_distance < node.getDistance()){ prev = node; node = node.getNext(); } else { break; } } TopNode newNode = new TopNode(word, edit_distance); prev.setNext(newNode); newNode.setNext(node); this.size++; if(this.size > topSize) { prev = this; node = front; this.setNext(front.getNext()); this.size--; } return true; }
f0a7e224-4ecf-493b-ba8e-6f0e5189d3ee
1
public List<QuadTree> getLeftNeighbors() { QuadTree sibling = this.getLeftSibling(); if ( sibling == null ) return new ArrayList<QuadTree>(); return sibling.getRightChildren(); }
ab522fc2-2093-46ea-82b5-72201947b7a7
0
public boolean isEmpty(){ return (top == -1); }
50689a5c-c2d5-49aa-a366-b5d82eb5d1ea
5
void headerOnMouseMove (Event event) { if (resizeColumn == null) { /* not currently resizing a column */ for (int i = 0; i < columns.length; i++) { CTableColumn column = columns [i]; int x = column.getX () + column.width; if (Math.abs (x - event.x) <= TOLLERANCE_COLUMNRESIZE) { if (column.resizable) { setCursor (display.getSystemCursor (SWT.CURSOR_SIZEWE)); } else { setCursor (null); } return; } } setCursor (null); return; } /* currently resizing a column */ /* don't allow the resize x to move left of the column's x position */ if (event.x <= resizeColumn.getX ()) return; /* redraw the resizing line at its new location */ GC gc = new GC (this); gc.setForeground (display.getSystemColor (SWT.COLOR_BLACK)); int lineHeight = clientArea.height; redraw (resizeColumnX - 1, 0, 1, lineHeight, false); resizeColumnX = event.x; gc.drawLine (resizeColumnX - 1, 0, resizeColumnX - 1, lineHeight); gc.dispose (); }
a41df28f-835b-46c1-a626-1df2f4865406
4
public boolean inBounds(int x, int y) { if(0 <= x && 20 >= x && 0 <= y && 20 >= y) return true; return false; }
37b9eb14-6c1a-446c-8b8f-bafcc27e0ee4
1
public void showScores(SnakeServerMessage SSM) { for (int i = 0 ; i < SSM.Players.length; i++){ playerScores[i].setVisible(true); playerScores[i].setEditable(false); } }
2d5fe6b9-5248-4013-a2f5-c856f8b4bd11
6
@Override public void run() { PlainSentence ps = null; try { while (true) { ps = in.take(); if ((ps = plainTextProcessor.doProcess(ps)) != null) { out.add(ps); } while (plainTextProcessor.hasRemainingData()) { if ((ps = plainTextProcessor.doProcess(null)) != null) { out.add(ps); } } if ((ps = plainTextProcessor.flush()) != null) { out.add(ps); } } } catch (InterruptedException e) { plainTextProcessor.shutdown(); } }
f2846494-76bf-490b-a4a7-a987fe4a91a1
8
public static void quickSorting(int array[], int left, int right) { if (left < right) { int i = left, j = right, x = array[left]; while (i < j) { while (i < j && array[j] >= x) { j--; } if (i < j) { array[i++] = array[j]; } while (i < j && array[i] < x) { i++; } if (i < j) { array[j--] = array[i]; } printArray(array, true); } array[i] = x; quickSorting(array, left, i - 1); quickSorting(array, i + 1, right); } }
7f66844c-ad7e-4d14-87ec-dc0620c13a8f
7
String checkSecurity(int iLevel, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request){ try { Object o1 = session.getAttribute("UserID"); Object o2 = session.getAttribute("UserRights"); boolean bRedirect = false; if ( o1 == null || o2 == null ) { bRedirect = true; } if ( ! bRedirect ) { if ( (o1.toString()).equals("")) { bRedirect = true; } else if ( (new Integer(o2.toString())).intValue() < iLevel) { bRedirect = true; } } if ( bRedirect ) { response.sendRedirect("Login.jsp?querystring=" + toURL(request.getQueryString()) + "&ret_page=" + toURL(request.getRequestURI())); return "sendRedirect"; } } catch(Exception e){}; return ""; }
9a00f3f1-66b2-4715-960c-301f7ddac956
2
public void loadFiles() throws IOException { for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) { DirFile node = new DirFile(i, j); DataBaseFile file = new DataBaseFile(getFullName(node), node.nDir, node.nFile, this, provider); files[node.getId()] = file; } } }
c3610f06-9fc2-4c48-b432-46238b3c53c2
2
public gameState state() { if (_gameModel.isGameOver()) { return gameState.GAME_OVER; } else if (_gameModel.isEndGame()) { return gameState.END_GAME; } else { return gameState.GAME_CONTINUED; } }
9b2eff4b-4dae-4326-9de9-8ad8857f9ff7
8
int doIO(ByteBuffer buf, int ops) throws IOException { /* * For now only one thread is allowed. If user want to read or write * from multiple threads, multiple streams could be created. In that * case multiple threads work as well as underlying channel supports it. */ if (!buf.hasRemaining()) { throw new IllegalArgumentException("Buffer has no data left."); // or should we just return 0? } while (buf.hasRemaining()) { if (closed) { return -1; } try { int n = performIO(buf); if (n != 0) { // successful io or an error. return n; } } catch (IOException e) { if (!channel.isOpen()) { closed = true; } throw e; } // now wait for socket to be ready. int count = 0; try { count = selector.select(channel, ops, timeout); } catch (IOException e) { // unexpected IOException. closed = true; throw e; } if (count == 0) { throw new SocketTimeoutException(timeoutExceptionString( channel, timeout, ops)); } // otherwise the socket should be ready for io. } return 0; // does not reach here. }
893df27f-ca24-40ea-9ed7-3d5173128a0b
8
public static boolean resolveOneSlotReferenceP(Proposition proposition, KeyValueList variabletypestable) { { Stella_Object firstargument = (proposition.arguments.theArray)[0]; Stella_Object predicate = null; { Surrogate testValue000 = Stella_Object.safePrimaryType(firstargument); if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PATTERN_VARIABLE)) { { PatternVariable firstargument000 = ((PatternVariable)(firstargument)); { List types = ((List)(variabletypestable.lookup(firstargument000))); if (types != null) { predicate = Logic.inferPredicateFromOperatorAndTypes(proposition.operator, ((List)(variabletypestable.lookup(firstargument000)))); } } } } else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_LOGIC_OBJECT)) { { LogicObject firstargument000 = ((LogicObject)(firstargument)); { Surrogate roottype = Logic.safeLogicalType(firstargument000); if (roottype != null) { predicate = Logic.inferPredicateFromOperatorAndTypes(proposition.operator, List.list(Cons.cons(roottype, Stella.NIL))); } } } } else { } } if (predicate != null) { if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(predicate), Logic.SGT_STELLA_SLOT)) { { Slot predicate000 = ((Slot)(predicate)); { Surrogate returntype = Logic.unwrapWrappedType(predicate000.slotBaseType); if (!Logic.booleanTypeP(returntype)) { proposition.kind = Logic.KWD_FUNCTION; if (Logic.variableP((proposition.arguments.theArray)[(proposition.arguments.length() - 1)])) { { PatternVariable lastargument = ((PatternVariable)((proposition.arguments.theArray)[(proposition.arguments.length() - 1)])); Skolem.updateSkolemType(lastargument, returntype); } } } proposition.operator = Logic.mostGeneralEquivalentSlotref(predicate000.slotSlotref); Proposition.evaluateNewProposition(proposition); return (true); } } } else { } } return (false); } }
a64ba6e6-7e68-445d-a604-eedee0dcf26a
0
public int getDepth() { return depth; }
2ebbcdab-2fe1-4354-80eb-bee0a8780ba2
6
public void drawItems() { itemList.removeAll(); OrderedItem orders[] = commande.getOrders(); for (int i = 0;i<orders.length;i++) { GridBagConstraints constraintLeft = new GridBagConstraints(),constraintRight = new GridBagConstraints(); constraintLeft.gridx = 0; constraintLeft.gridy = GridBagConstraints.RELATIVE; constraintLeft.fill = GridBagConstraints.HORIZONTAL; constraintRight.gridx = 1; constraintRight.gridy = GridBagConstraints.RELATIVE; constraintRight.fill = GridBagConstraints.HORIZONTAL; String itemText = orders[i].getItem().getNom(); if(itemText.length()>15){ itemText = itemText.substring(0,12)+"..."; } JLabel item = new JLabel(itemText); JPanel itemTextHolder = new JPanel(); itemTextHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE)); itemTextHolder.setBackground(Color.WHITE); itemTextHolder.add(item); itemList.add(itemTextHolder,constraintLeft); Color bg = Color.WHITE; String statusIcon = ""; JLabel itemStatus = new JLabel(); JPanel statusHolder = new JPanel(); switch (orders[i].getStatus()) { case 0: bg = Color.RED; statusIcon = "\u2718"; break; case 1: bg = Color.YELLOW; statusIcon = "\u2718"; break; case 2: bg = Color.GREEN; statusIcon = "\u2718"; break; case 3: bg = Color.GRAY; statusIcon = "\u2713"; break; } itemStatus.setText(statusIcon); statusHolder.setBackground(bg); statusHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE)); statusHolder.add(itemStatus); itemList.add(statusHolder,constraintRight); } validate(); repaint(); }
d290080e-788f-495d-b2ac-26cc440552c4
0
public TaskRunner(TaskSupplier<T> taskSupplier, TaskExecutor<T> taskExecutor) { this.taskSupplier = taskSupplier; this.taskExecutor = taskExecutor; }
1238dd42-7207-49bd-ae64-1596c9ab70d2
3
private void parseStartLevel(Node node) throws TemplateException { try { XPath xPath = XPathFactory.newInstance().newXPath(); NodeList nodeList = (NodeList) xPath.evaluate("element/interleave/ref", node, XPathConstants.NODESET); for (int i = 0, len = nodeList.getLength(); i < len; i++) { Node currentNode = nodeList.item(i); if (currentNode.getNodeType() == Node.ELEMENT_NODE) { Element currentElement = (Element) currentNode; // calls this method for all the children which is Element parseReference(tagBody, currentElement.getAttribute("name"), 0); } } } catch (XPathExpressionException e) { throw new TemplateException("XPathExpressionException", e); } }
bb59003e-84a4-4b71-9c23-a43b1ae03a0f
3
public static void main(String[] args ) { TextNavigator tn = new TextNavigator(); tn.text = "forbidden treasures. The common folk of the neigh-\n" + "borhood, peons of the estancias, vaqueros of the sea-\n" + "board plains, tame Indians coming miles to market\n" + "with a bundle of sugar-cane or a basket of maize worth\n" + "about threepence, are well aware that heaps of shin-\n" + "ing gold lie in the gloom of the deep precipices cleav-\n" + "ing the stony levels of Azuera. Tradition has it that\n" + "many adventurers of olden time had perished in the\n" + "search. The story goes also that within men's memory\n" + "two wandering sailors--Americanos, perhaps, but\n" + "gringos of some sort for certain--talked over a gam-\n" + "bling, good-for-nothing mozo, and the three stole a\n" + "234a\n" + "donkey to carry for them a bundle of dry sticks, a\n" + "water-skin, and provisions enough to last a few days.\n" + "Thus accompanied, and with revolvers at their belts,\n" + "they had started to chop their way with machetes"; StringBuilder sb = new StringBuilder(); char t = 0; tn.offset = 0; //tn.text.length()-1; // use this for backwards while ( t != (char)-1) { t = tn.next(); // forwards // t = tn.prev(); // backwards if ( t != (char)-1 ) sb.append(t); } // write it out backwards // for ( int i=sb.length()-1;i>=0;i-- ) // System.out.print(sb.charAt(i)); // use this for forwards for ( int i=0;i<sb.length();i++ ) System.out.print(sb.charAt(i)); }
928198d4-6afa-4e7d-8e1e-4593399a7ae8
4
private JSONObject readObject() throws JSONException { JSONObject jsonobject = new JSONObject(); while (true) { if (probe) { log("\n"); } String name = readName(); jsonobject.put(name, !bit() ? readString() : readValue()); if (!bit()) { return jsonobject; } } }
9805cd54-2947-4b7e-821c-2fff5e32e2e8
0
@Override public void documentAdded(DocumentRepositoryEvent e) {}
3ba9856f-fbdf-4008-94cb-770bad6acdc3
1
private String _toString(String delim) { String ret = Integer.toString(this.getId()) + delim + this.getDate() + delim; // inefficient but perhaps acceptable here for(Contact contact : this.getContacts()) { ret += delim + contact.getId(); } return ret; }
b40fdcdc-c300-4876-92a5-e8c8d3e43d13
4
void scoreMatrix() { score = new int[a.length + 1][b.length + 1]; // Initialize for (int i = 0; i <= a.length; i++) setScore(i, 0, deletion * i); for (int j = 0; j <= b.length; j++) setScore(0, j, deletion * j); // Calculate bestScore = Integer.MIN_VALUE; for (int i = 1; i <= a.length; i++) for (int j = 1; j <= b.length; j++) { int match = getScore(i - 1, j - 1) + simmilarity(i, j); int del = getScore(i - 1, j) + deletion; int ins = getScore(i, j - 1) + deletion; int s = Math.max(match, Math.max(del, ins)); setScore(i, j, s); bestScore = Math.max(bestScore, s); } }
8d416a09-83b2-42b6-8e7e-8501177f291a
6
public MusicObject getSongByPath(String folder, String fileName) { try { if (connection == null) { connection = getConnection(); } if (getSongByNameStmt == null) { getSongByNameStmt = connection.prepareStatement("select "+getColumnNames("music")+" from org.music music where folder_hash = ? and file_name = ?"); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("Error setting up connection: " + e.getMessage()); } try { // Reads against a folder_hash, not a folder, since I think this is doing table scans anyway so it should be matching a smaller string getSongByNameStmt.setString(1, Base64.encodeBase64String(Utils.getDigest(folder))); getSongByNameStmt.setString(2, fileName); log.info("Retrieving song details against folder '"+folder+"' and file '" + fileName +"'"); if (log.isLoggable(Level.FINE)) { log.log(Level.FINE,"FolderHash '"+Base64.encodeBase64String(Utils.getDigest(folder))+"'"); } ResultSet rs = getSongByNameStmt.executeQuery(); while (rs.next()) { return populateMusic(rs); } close(rs); } catch (Exception e) { log.log(Level.SEVERE,e.getMessage(),e); } return new MusicObject(); }
e7dd87aa-98cb-4efc-89e5-1cef9f9e8ed3
2
@Override public void compute(Vertex<Text, Text, NullWritable> vertex, Iterable<Text> messages) throws IOException { if (getSuperstep() == MAX_SIZE.get(getConf())) { vertex.voteToHalt(); return; } if (getSuperstep() == 0) { doFirstStep(vertex); } else { doStep(vertex, messages); } vertex.voteToHalt(); }
a694894c-7e72-4872-88bb-bb9abe64af8d
5
public static Resource getLatest(RepositoryConnection con, RepositoryResult<Statement> statementIterator, URI timeProperty) throws RepositoryException { Resource latestResource = null; SimpleDateFormat sdf = D2S_Utils.getSimpleDateFormat(); while (statementIterator.hasNext()) { Statement s = statementIterator.next(); Resource r = (Resource) s .getObject(); RepositoryResult<Statement> timeIterator = con .getStatements(r, timeProperty, null, true); Date latest = null; while (timeIterator.hasNext()) { Statement timeStatement = timeIterator .next(); String cacheTime = timeStatement.getObject() .stringValue(); Date time; try { time = sdf.parse(cacheTime); if (latest == null) { latest = time; latestResource = r; } else if (time.after(latest)) { latest = time; latestResource = r; } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return latestResource ; }
8c9ddf03-bead-4fbb-86ab-39436cb33625
9
private void songsnewfromRTFdir() { // jetzt Dateiauswahl anzeigen: JFileChooser pChooser = new JFileChooser(); pChooser.setDialogTitle(Messages.getString("GUI.15")); //$NON-NLS-1$ org.zephyrsoft.util.CustomFileFilter filter = new org.zephyrsoft.util.CustomFileFilter("", new String[] {".rtf"}); //$NON-NLS-1$ //$NON-NLS-2$ pChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int iValue = pChooser.showOpenDialog(getThis()); if (iValue == JFileChooser.APPROVE_OPTION) { File fFile = new File(pChooser.getSelectedFile().toString()); if (fFile.exists() && fFile.isDirectory()) { // Dateien darin importieren Song song = null; File[] dir = fFile.listFiles(filter); for (int i = 0; i < dir.length; i++) { File oneFile = dir[i]; RTFEditorKit rtf = new RTFEditorKit(); JEditorPane editor = new JEditorPane(); editor.setEditorKit(rtf); try { FileInputStream fi = new FileInputStream(oneFile); rtf.read(fi, editor.getDocument(), 0); } catch(FileNotFoundException e) { System.out.println("File not found: " + oneFile.getAbsolutePath()); //$NON-NLS-1$ } catch(IOException e) { System.out.println("I/O error: " + oneFile.getAbsolutePath()); //$NON-NLS-1$ } catch(BadLocationException e) { System.out.println("bad location: " + oneFile.getAbsolutePath()); //$NON-NLS-1$ } if (getSelectedSong() != null) { store(previouslySelectedIndex); } song = structure.insertNewSong(); try { song.setText(editor.getDocument().getText(0, editor.getDocument().getLength()-1)); } catch(BadLocationException e) { System.out.println("bad location"); //$NON-NLS-1$ } } reloadModel(false); setSelectedSong(song); load(table.getSelectedRow()); // Songtitel markieren zum überschreiben tabbedPane.setSelectedIndex(0); titel.setSelectionStart(0); titel.setSelectionEnd(titel.getText().length()); titel.requestFocus(); dbaltered = true; } else { JOptionPane.showMessageDialog(this, Messages.getString("GUI.82"), //$NON-NLS-1$ Messages.getString("GUI.83"), //$NON-NLS-1$ JOptionPane.ERROR_MESSAGE); } } }
07876170-3583-4474-877c-48ba0efbfbc7
4
public HTMLInput getInputByName(String regex) { Pattern patt = Pattern.compile(regex); for (HTMLInput i : inputs) { final String linksName = i.getName(); if (linksName == null) continue; if (regex.equals(linksName) || (patt.matcher(linksName).find())) { return i; } } return null; }
59acfe75-a845-404d-9d7c-31af28092a0c
7
private void checkReturnType(Method method) throws DaoGenerateException { Class<?> returnType = method.getReturnType(); isReturnId = (method.getAnnotation(ReturnId.class) != null); if (isReturnId) { if (ClassHelper.isTypePrimitive(returnType)) { returnType = ClassHelper.primitiveToWrapper(returnType); } if (!ClassHelper.isTypeNumber(returnType)) { throw new DaoGenerateException("方法[" + method + "]配置错误:配置了@ReturnId注解的方法只能返回java.lang.Number类型数据或者对应的基本类型,你能为[" + returnType + "]"); } } else { if (ClassHelper.isTypePrimitive(returnType)) { returnType = ClassHelper.primitiveToWrapper(returnType); } if (ClassHelper.isTypeVoid(returnType) || Integer.class.equals(returnType)) { return; } throw new DaoGenerateException("方法[" + method + "]配置错误:配置了@Update注解的方法只能返回void,int或者Integer;或者请增加@ReturnId注解"); } }
46814436-61ae-4438-a487-3abbf12a4d2f
0
public void beginScope() { marks = new Binder(null, top, marks); top = null; }
fd3d37c8-5e69-4cdd-9b5b-f7ccfa2a29d1
7
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } if (value.toString().startsWith("@")) { ImageIcon imageIcon = new ImageIcon(Ressources.getImage("Users/op.png")); setIcon(imageIcon); setText(value.toString().replace("@", "")); } else if (value.toString().startsWith("$")) { ImageIcon imageIcon = new ImageIcon(Ressources.getImage("Users/red.png")); setIcon(imageIcon); setText(value.toString().replace("$", "")); } else if (value.toString().startsWith("+")) { ImageIcon imageIcon = new ImageIcon(Ressources.getImage("Users/voiced.png")); setIcon(imageIcon); setText(value.toString().replace("+", "")); } else if (value.toString().startsWith("%")) { ImageIcon imageIcon = new ImageIcon(Ressources.getImage("Users/hop.png")); setIcon(imageIcon); setText(value.toString().replace("%", "")); } else if (value.toString().startsWith("~")) { ImageIcon imageIcon = new ImageIcon(Ressources.getImage("Users/owner.png")); setIcon(imageIcon); setText(value.toString().replace("~", "")); } else { setText(value.toString()); ImageIcon imageIcon = new ImageIcon(Ressources.getImage("Users/normal.png")); setIcon(imageIcon); } return this; }
6f294d33-e72d-421d-a9be-61f3d356372f
3
public boolean equals(Object o) { if (o == null) return false; if (o == this) return true; else { Position temp = (Position) o; return ((this.getX() == temp.getX()) && (this.getY() == temp.getY())); } }
f7937cf6-2696-494c-bc05-804d18edb42c
9
private int getDownElementIndex(int n) { if (n >= 80 && n < getMaxElementIndex()) return n; if (n >= 39 && n < 81) return n + 32; if (n >= 12 && n < 39) return n + 18; if (n >= 1 && n < 12) return n + 8; if (n == 0) return n + 2; return n; }
e2b9127e-6309-4510-a361-b4233beafc0a
1
public ByteVector putInt(final int i) { int length = this.length; if (length + 4 > data.length) { enlarge(4); } byte[] data = this.data; data[length++] = (byte) (i >>> 24); data[length++] = (byte) (i >>> 16); data[length++] = (byte) (i >>> 8); data[length++] = (byte) i; this.length = length; return this; }
b02ada47-b85b-4ce4-80c3-4b2886366895
6
@EventHandler public void WolfWaterBreathing(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getWolfConfig().getDouble("Wolf.WaterBreathing.DodgeChance") / 100; final double ChanceOfHappening = random.nextDouble(); if (ChanceOfHappening >= randomChance) { dodged = true; } if (plugin.getWolfConfig().getBoolean("Wolf.WaterBreathing.Enabled", true) && damager instanceof Wolf && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) { Player player = (Player) e; player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, plugin.getWolfConfig().getInt("Wolf.WaterBreathing.Time"), plugin.getWolfConfig().getInt("Wolf.WaterBreathing.Power"))); } }
b41a8ac8-0fef-49c6-b9c5-d0ba31dcc292
3
public void addConstant(String con, Object value){ if(value instanceof Integer) intConstantMap.put(con,(Integer)value); else if(value instanceof Float) floatConstantMap.put(con,(Float)value); else if(value instanceof Short) shortConstantMap.put(con,(Short)value); }
fae74a66-1ae6-4de9-b9b5-57d36e1d6b1e
1
public static void main(String[] args) { MyLogger myLogger1 = MyLogger.getMyLogger(); MyLogger myLogger2 = MyLogger.getMyLogger(); MyLogger myLogger3 = MyLogger.getMyLogger(); MyLogger myLogger4 = MyLogger.getMyLogger(); MyLogger myLogger5 = MyLogger.getMyLogger(); myLogger1.info("Leaning Singlton design pattern..."); List<MyLogger> myLoggerList = new ArrayList<MyLogger>(); myLoggerList.add(myLogger1); myLoggerList.add(myLogger2); myLoggerList.add(myLogger3); myLoggerList.add(myLogger4); myLoggerList.add(myLogger5); for (MyLogger myLogger : myLoggerList) { System.out.println(myLogger1.areWeSame(myLogger)); } }
58a52bdd-eb07-4971-a5f0-3770b9fe3b48
8
public ArrayList selectSingleList(String query) throws SQLException { ArrayList resultList = new ArrayList(); Connection connection = null; Statement statement = null; ResultSet result = null; String value = ""; try { Class.forName(driver); connection = DriverManager.getConnection(url, username, passwd); statement = connection.createStatement(); result = statement.executeQuery(query); while (result.next()) { value = result.getString(1); resultList.add(value); } result.close(); result = null; statement.close(); statement = null; connection.close(); connection = null; } catch (Exception e) { System.out.println(e); } finally { if (result != null) { try { result.close(); } catch (SQLException e) { System.out.println(e); } result = null; } if (statement != null) { try { statement.close(); } catch (SQLException e) { System.out.println(e); } statement = null; } if (connection != null) { try { connection.close(); } catch (SQLException e) { System.out.println(e); } connection = null; } } return resultList; }
8bcd4e0e-2d06-4083-bf4a-63dba8f188ba
4
@Override public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith(".jpg") || f.getName().toLowerCase().endsWith(".gif") || f.getName().toLowerCase().endsWith(".bmp") || f.getName().toLowerCase().endsWith(".png"); }
780ef282-d22f-48c5-bb4b-16a4f1945ad7
1
public int getij(int i,int j){ assert (i<n) && (j<m); return A[i][j]; }
44147cf5-8121-4a45-b717-bf07fd624454
9
private String buildheader(int codeIn, int fileextIn) { int code = codeIn; int fileext = fileextIn; String header = ""; if (code == 200) { header = "HTTP/1.1 200 OK"; } if (code == 404) { header = "HTTP/1.1 404 Not Found"; } header += "\r\n"; header += "Connection: close\r\n"; header += "Server: Nippelhttpd/0.1\r\n"; switch (fileext) { case 0: break; case 1: header += "Content-Type: image/jpeg\r\n"; break; case 2: header += "Content-Type: image/gif\r\n"; break; case 3: header += "Content-Type: image/png\r\n"; break; case 4: header += "Content-Type: application/xhtml+xml\r\n"; break; case 5: header += "Content-Type: application/xml\r\n"; break; case 6: header += "Content-Type: text/css\r\n"; break; default: header += "Content-Type: text/html\r\n"; break; } header += "\r\n"; log.debug(" the return header is:" + header); return header; }
2e1d9bdc-b088-4bce-a18b-5ddad1a85b7a
1
private void endArguments() { if (argumentStack % 2 != 0) { buf.append('>'); } argumentStack /= 2; }
8ff5f86a-9c56-4420-9d5c-c28bb72246d9
0
public void die(){ }
0db8be80-512c-4838-a4a9-3ebfb2c8bf33
8
public static String getCardString(Card card) { String string = ""; switch (card.value) { case (0) : string += 'A'; break; case (10) : string += 'J'; break; case (11) : string += 'Q'; break; case (12) : string += 'K'; break; default : string += (card.value + 1); } switch (card.suite) { case (CLUBS) : string += CLUBS_CHAR; break; case (DIAMONDS) : string += DIAMONDS_CHAR; break; case (SPADES) : string += SPADES_CHAR; break; case (HEARTS) : string += HEARTS_CHAR; break; default : string += '?'; } return string; }
c4eefb7f-4a03-4f5a-932f-d211cdb143ce
0
public GraphRect(String tid, int twhichOne, int x, int y, int w, int h) { super(x,y,w,h); whichOne=twhichOne; id=tid; }
60295427-53fb-489f-94e9-f44a77437fb3
2
private void setObject() { if (this.isString || this.isArray) { throw new RuntimeException(JSON__STATUS__ERROR); } this.isObject = true; }
ae5c9994-11ce-48c0-8b21-9f32e3cc853f
8
@Override public boolean canBeLearnedBy(MOB teacherM, MOB studentM) { if(!super.canBeLearnedBy(teacherM,studentM)) return false; if(studentM==null) return true; final CharClass C=studentM.charStats().getCurrentClass(); if(CMLib.ableMapper().getQualifyingLevel(C.ID(), false, ID())>=0) return true; final boolean crafting = ((classificationCode()&Ability.ALL_DOMAINS)==Ability.DOMAIN_CRAFTINGSKILL); final AbilityComponents.AbilityLimits remainders = CMLib.ableComponents().getSpecialSkillRemainder(studentM, this); if(remainders.commonSkills()<=0) { teacherM.tell(L("@x1 can not learn any more common skills.",studentM.name(teacherM))); studentM.tell(L("You have learned the maximum @x1 common skills, and may not learn any more.",""+remainders.maxCommonSkills())); return false; } if(remainders.specificSkillLimit()<=0) { if(crafting) teacherM.tell(L("@x1 can not learn any more crafting common skills.",studentM.name(teacherM))); else teacherM.tell(L("@x1 can not learn any more non-crafting common skills.",studentM.name(teacherM))); final int max = crafting ? remainders.maxCraftingSkills() : remainders.maxNonCraftingSkills(); if(crafting) studentM.tell(L("You have learned the maximum @x1 crafting skills, and may not learn any more.",""+max)); else studentM.tell(L("You have learned the maximum @x1 non-crafting skills, and may not learn any more.",""+max)); return false; } return true; }
9d46f059-7aa6-4a28-af32-f521c3697002
6
public static void saveToPng(Maze m, Path to, boolean withShortestPath) throws IOException { Logger logger = Logger.getLogger("fr.upem.algoproject"); int width = m.getWidth(); int bi_w = Math.max(100, width); int bi_h = Math.max(100, m.getHeight()); BufferedImage bi = new BufferedImage(bi_w, bi_h, BufferedImage.TYPE_INT_ARGB); logger.finest("Filling image with blue..."); for (int i = 0; i < bi_w; i++) { for (int j = 0; j < bi_h; j++) { bi.setRGB(i, j, Color.BLUE.getRGB()); } } logger.finest("Trying to paint white over the blue to represent the pathes"); for (Integer i : m.getGraph().getAllNodes()) { if (m.getGraph().getNeighbours(i).isEmpty()) { continue; } int y = i / width; int x = i % width; setTile(bi, Color.WHITE.getRGB(), bi_w, bi_h, width, m.getHeight(), x, y); } setTile(bi, Color.RED.getRGB(), bi_w, bi_h, width, m.getHeight(), m.getStart().x, m.getStart().y); setTile(bi, Color.RED.getRGB(), bi_w, bi_h, width, m.getHeight(), m.getEnd().x, m.getEnd().y); if (withShortestPath) { int shortestPath[] = m.getShortestPath(); int end = m.getEnd().y * width + m.getEnd().x; int start = m.getStart().y * width + m.getStart().x; int u = end; while (shortestPath[u] != -1) { setTile(bi, Color.GREEN.getRGB(), bi_w, bi_h, width, m.getHeight(), u % width, u / width); u = shortestPath[u]; } } File outputfile = to.toFile(); ImageIO.write(bi, "png", outputfile); logger.info("Done writing to file" + to.toAbsolutePath()); }
0a31caff-c8ca-4757-8395-f43745e66b93
4
@Override public boolean checkVersion(Player player, ReplicatedPermissionsContainer data) { if (data.modName.equals("all")) return true; for (ReplicatedPermissionsMappingProvider provider : this.mappingProviders) { if (!provider.checkVersion(this.parent, player, data) && !player.hasPermission(ReplicatedPermissionsPlugin.ADMIN_PERMISSION_NODE)) return false; } return true; }
5ec72269-5859-4257-af95-18da797df45e
2
private boolean validTarget(Sprite s){ boolean returnVal = false; if(validTargetDistance(s) && validTargetNotParent(s)) returnVal = true; return returnVal; }
713bcd1a-3a8c-46ea-a12b-0f78c99c9e17
6
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); while ((line = in.readLine()) != null && line.length() != 0) { int[] MN = readInts(line); m = new char[MN[0]][MN[1]]; char[] curLine; for (int i = 0; i < MN[0]; i++) { curLine = in.readLine().toCharArray(); System.arraycopy(curLine, 0, m[i], 0, curLine.length); } int[] XY = readInts(in.readLine()); t = m[XY[0]][XY[1]]; floodFill(XY[0], XY[1], '*', '*'); m[XY[0]][XY[1]] = '`'; int max = 0; for (int i = 0; i < MN[0]; i++) for (int j = 0; j < MN[1]; j++) if (m[i][j] == t) { curSize = 0; floodFill(i, j, '*', '*'); max = Math.max(max, curSize); } out.append(max + "\n"); in.readLine(); } System.out.print(out); }
e40caf28-73ec-4c65-b44d-87039c206ea6
0
@Basic @Column(name = "CTR_FORMA_PAGO") public String getCtrFormaPago() { return ctrFormaPago; }
2974a2a5-8676-4891-9e7c-8909a45e2279
4
public static int canCompleteCircuit(int[] gas, int[] cost) { assert gas.length == cost.length; int len = gas.length; for (int i = 0; i < len; i++) { int tank = 0; int start = i; boolean done = true; int step = start; for (int j = 0; j < len; j++) { tank = tank + gas[step] - cost[step]; if (tank < 0) {done = false; break;} step = (step + 1) % len; } if (done) { return start; } } return -1; }
269d15a1-bc6f-4dae-adfe-a609753cea24
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(EditQuestionFIB.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(EditQuestionFIB.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(EditQuestionFIB.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(EditQuestionFIB.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new EditQuestionFIB().setVisible(true); } }); }
152a17af-08b2-4675-9e0f-756b4b9535f3
0
public static void main(String[] args) { new House(); }
34f86f88-981c-4c2b-b703-51c81cafb5ad
3
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("sellhead")) { if (sender instanceof Player) { Player player = (Player) sender; ItemStack item = player.getItemInHand(); if (item.getType() == Material.SKULL_ITEM) { FileConfiguration fileConfig = new YamlConfiguration(); FileManager.loadFile(FileManager.Config, fileConfig); double price = fileConfig.getDouble("Head Price"); MinecraftRPDonation.econ.bankDeposit(player.getName(), price); /** * Remove item */ item.setAmount(item.getAmount() - 1); player.setItemInHand(item); DecimalFormat df = new DecimalFormat("0.00"); player.sendMessage(ChatColor.BLUE + "[MinecraftRP] You got $" + df.format(price) + " for selling the head!"); }else{ player.sendMessage(ChatColor.RED + "[MinecraftRP] You must have a head in your hand!"); } } } return false; }
2f5514d6-470a-4c30-9e03-4b9f58d4a5bb
2
private boolean jj_3R_81() { if (jj_scan_token(END)) return true; if (jj_scan_token(CLASS)) return true; return false; }
11f25985-90e2-4f37-991e-b6f28644dac6
3
private void byWidth(BinaryTree[] mas, int counter, int counterMas) { System.out.print(mas[counter].getValue() + " "); if (mas[counter].left != null) { counterMas++; mas[counterMas] = mas[counter].left; } if (mas[counter].right != null) { counterMas++; mas[counterMas] = mas[counter].right; } counter++; if (counter < amount) byWidth(mas, counter, counterMas); }
40ceb4ff-b702-4a0b-8d45-8a3f3477947c
5
public Person getPrevPerson(final Person person) { if (person != null) { logger.debug("(getPrevPerson) Looking for Person with ID < " + person.getId()); for (int i = personStorage.entrySet().size() - 1; i >= 0; i--) { @SuppressWarnings("unchecked") final Map.Entry<Long, Person> map = (Entry<Long, Person>) personStorage.entrySet().toArray()[i]; if (person.getId() == null || map.getKey() < person.getId()) { // ohne id wird die letzte Person zurückgeliefert final Person prevPerson = map.getValue(); if (prevPerson != null) { logger.debug("getPrevPerson returns: " + prevPerson.getVorname() + " " + prevPerson.getNachname()); } else { logger.debug("getPrevPerson could not find a Person - so null will be returned"); } return prevPerson; } } } logger.debug("getPrevPerson was called with no reference Person - so null will be returend"); return null; }