method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
7b09313f-59be-47a1-919a-71321d0afe6e
0
protected Icon getIcon() { java.net.URL url = getClass().getResource("/ICON/undo2.jpg"); return new javax.swing.ImageIcon(url); }
a7b8eba0-4f85-49db-b79d-9b0528da41b1
5
public static String convertStringToHexComma(String plain, boolean appendNullSigns) { if(plain == null || plain.trim().length() == 0) return plain; StringBuffer strBuf = new StringBuffer(); for(int x = 0; x != plain.length(); x++) { if(x > 0) strBuf.append(","); strBuf.append(Integer.toHexString(plain.charAt(x))); if(appendNullSigns) strBuf.append(",00"); //this is needed, dunno why by the multi and expand string entries, but not for the binary } return strBuf.toString(); }
c6c9c5e5-812f-4e54-aab3-54106e2e896a
8
public String toString(){ StringBuffer sb = new StringBuffer(); switch(type){ case TYPE_VALUE: sb.append("VALUE(").append(value).append(")"); break; case TYPE_LEFT_BRACE: sb.append("LEFT BRACE({)"); break; case TYPE_RIGHT_BRACE: sb.append("RIGHT BRACE(})"); break; case TYPE_LEFT_SQUARE: sb.append("LEFT SQUARE([)"); break; case TYPE_RIGHT_SQUARE: sb.append("RIGHT SQUARE(])"); break; case TYPE_COMMA: sb.append("COMMA(,)"); break; case TYPE_COLON: sb.append("COLON(:)"); break; case TYPE_EOF: sb.append("END OF FILE"); break; } return sb.toString(); }
4f62c6d2-afa2-4f66-b92c-7fb2390d2ff7
9
@Override public int read() throws IOException { // Read buffer empty: read and decode a new base64-encoded 4-byte group if(bytesLeft==0) { int read; int nbRead = 0; while(nbRead<4) { read = in.read(); // EOF reached if(read==-1) { if(nbRead%4 != 0) { // Base64 encoded data must come in a multiple of 4 bytes, throw an IOException if the underlying stream ended prematurely throw new IOException("InputStream did not end on a multiple of 4 bytes"); } if(nbRead==0) return -1; else // nbRead==4 break; } decodeBuffer[nbRead] = decodingTable[read]; // Discard any character that's not a base64 character, without throwing an IOException. // In particular, '\r' and '\n' characters that are usually found in email attachments are simply ignored. if(decodeBuffer[nbRead]==-1 && read!=paddingChar) { continue; } nbRead++; } // Decode byte 0 readBuffer[bytesLeft++] = ((decodeBuffer[0]<<2)&0xFC | ((decodeBuffer[1]>>4)&0x03)); // Test if the character is not a padding character if(decodeBuffer[2]!=-1) { // Decode byte 1 readBuffer[bytesLeft++] = (decodeBuffer[1]<<4)&0xF0 | ((decodeBuffer[2]>>2)&0x0F); // Test if the character is a padding character if(decodeBuffer[3]!=-1) // Decode byte 2 readBuffer[bytesLeft++] = ((decodeBuffer[2]<<6)&0xC0) | (decodeBuffer[3]&0x3F); } readOffset = 0; } bytesLeft--; return readBuffer[readOffset++]; }
6f977b25-616f-4f60-b404-6c6a7ef95b44
4
boolean matchesLetter() { if (isEmpty()) return false; char c = input[pos]; return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); }
a5277a44-86ec-47aa-9fd1-593c008f65dc
6
public void disablePlugin(CommandSender sender, String[] args) { if (args.length == 1) { sender.sendMessage(pre + red + specifyPlugin); return; } if ("all".equalsIgnoreCase(args[1]) || "*".equalsIgnoreCase(args[1])) { for (Plugin pl : Bukkit.getPluginManager().getPlugins()) { Bukkit.getPluginManager().disablePlugin(pl); } sender.sendMessage(pre + red + "All plugins disabled!"); return; } String pl = consolidateArgs(args); if (getPlugin(pl) == null) { sender.sendMessage(pre + red + pluginNotFound); return; } if (!getPlugin(pl).isEnabled()) { sender.sendMessage(pre + red + "Plugin already disabled!"); return; } Plugin targetPlugin = getPlugin(pl); Bukkit.getPluginManager().disablePlugin(targetPlugin); sender.sendMessage(pre + red + targetPlugin.getName() + " Disabled!"); }
c4de796f-2870-467d-86d8-11a6e26b0045
5
public JSONObject increment(String key) throws JSONException { Object value = this.opt(key); if (value == null) { this.put(key, 1); } else if (value instanceof Integer) { this.put(key, (Integer) value + 1); } else if (value instanceof Long) { this.put(key, (Long) value + 1); } else if (value instanceof Double) { this.put(key, (Double) value + 1); } else if (value instanceof Float) { this.put(key, (Float) value + 1); } else { throw new JSONException("Unable to increment [" + quote(key) + "]."); } return this; }
2a8fe53b-a4ee-428c-86d5-20e58652c82d
2
public String toString(){ String out=""; out+="name = "+name+"\n"; out+="host = "+host+"\n"; out+="minAbsolute = "; if(minAbsolute==null){ } else{ out+=minAbsolute; } out+="\n"; out+="maxAbsolute = "; if(maxAbsolute==null){ } else{ out+=maxAbsolute; } out+="\n"; out+="minRelativeToNowInDays = "+String.valueOf(minRelativeToNowInMinutes)+"\n"; out+="maxRelativeToNowInDays = "+String.valueOf(maxRelativeToNowInMinutes)+"\n"; out+="state = "+state+"\n"; out+="compositeName = "+compositeName+"\n"; out+="user = "+user+"\n"; out+="pass = "+pass+"\n"; return out; }
98c088ad-5ee7-41e6-814e-ca0617aadb10
4
@Override public void putAll(Grid<? extends V> grid) { if (grid == null) { throw new IllegalArgumentException("Grid must nor be null"); } for (Cell<? extends V> cell : grid.cells()) { put(cell.getRow(), cell.getColumn(), cell.getValue()); } }
f8199c91-5084-4b0d-83cb-1f03b7fd7aba
7
@Test public void testSendDataToServer() { System.out.println("sendDataToServer"); try { Server s = ServerImpl.initNewServer(5251); Client c = ClientImpl.initNewClient(5253); try { c.sendDataToServer(null); fail("Should have failed because of no server info set."); } catch (ConnectionException ex) { assertEquals(ConnectionExceptionCause.CONNECTION_ERROR, ex.getExceptionCause()); } try { c.registerToServer(GlobalConstants.IP_LOOPBACK, 5251); } catch (ConnectionException ex) { fail("Registration failed - " + ex); } s.stopService(); try { synchronized (this) { this.wait(1000); } c.sendDataToServer(null); fail("Should have failed because server is offline."); } catch (ConnectionException ex) { assertEquals(ConnectionExceptionCause.CONNECTION_ERROR, ex.getExceptionCause()); } catch (InterruptedException ex) { fail("Waiting has been interrupted - " + ex); } s = ServerImpl.initNewServer(); try { c.registerToServer(GlobalConstants.IP_LOOPBACK); } catch (ConnectionException ex) { fail("Registration failed - " + ex); } try { assertNotNull(c.sendDataToServer("a")); } catch (ConnectionException ex) { fail("Could not reach server - " + ex); } c.stopService(); s.stopService(); } catch (IOException ex) { fail("Failed to initialize client - " + ex); } }
815f0421-2dd5-4c41-974c-3bbe6b287f7c
5
protected void exportDone(JComponent c, Transferable data, int action) { //Only do this if cutting, not copying if (action != MOVE) { return; } //Make sure there is a valid selection if ((p0 != null) && (p1 != null) && (p0.getOffset() != p1.getOffset())) { try { //Do the cutting JTextComponent tc = (JTextComponent)c; tc.getDocument().remove(p0.getOffset(), p1.getOffset() - p0.getOffset()); } catch (BadLocationException ble) { ble.printStackTrace(); } } }
da398e5e-e29d-491d-b7f7-2955014d8c9d
0
public static void main(String[] args) throws Exception { InetAddress address = InetAddress.getLocalHost(); System.out.println(address); address = InetAddress.getByName("www.baidu.com"); System.out.println(address); }
212528f7-84ac-4c93-b5dc-4ceb5d8973b5
9
@Override public boolean MoveLeft() { undodata.addLast(dataClone()); undoscore.addLast(scoreClone()); initFlag(); win = false; noMoreMoves = false; boolean flag = true; int count = 0; while (flag == true) { flag = false; for(int i=0; i<N; i++) { for(int j=1; j<N; j++) { if (data[i][j] == 0) continue; else if (data[i][j-1] == 0) { data[i][j-1]=data[i][j]; data[i][j]=0; flag = true; count++; } else if ((data[i][j-1] == data[i][j]) && (dataflag[i][j-1] == true) && (dataflag[i][j] == true)) { score=score+data[i][j]*2; data[i][j-1]=data[i][j]*2; dataflag[i][j-1]=false; data[i][j]=0; checkWin(data[i][j-1]); flag = true; count++; } } } } if (count !=0) { addBrick(); checkLoose(); setChanged(); notifyObservers(); return true; } else{ data=undodata.removeLast(); score=undoscore.removeLast(); setChanged(); notifyObservers(); return false; } }
a883ef1b-b251-4416-bff5-75f5731a5e4f
4
public void registerCommands(final Set<Command> commands) { for (final Command c : commands) { if (c.getCommandText().equals("help")) { helpCommands.put(null, (HelpCommand) c); if (c.getCommandText().startsWith("help ")) helpCommands.put(c.getCommandText().replaceFirst("help ", ""), (HelpCommand) c); } else { commandMap.put(c.getCommandText(), c); } } if (helpCommands.get(null) == null) { throw new RuntimeException("Missing help command"); } }
2f8ec895-479b-4a00-aa5d-94f5c29522c7
9
public String sample_frequency_string() { switch (h_sample_frequency) { case THIRTYTWO: if (h_version == MPEG1) return "32 kHz"; else if (h_version == MPEG2_LSF) return "16 kHz"; else // SZD return "8 kHz"; case FOURTYFOUR_POINT_ONE: if (h_version == MPEG1) return "44.1 kHz"; else if (h_version == MPEG2_LSF) return "22.05 kHz"; else // SZD return "11.025 kHz"; case FOURTYEIGHT: if (h_version == MPEG1) return "48 kHz"; else if (h_version == MPEG2_LSF) return "24 kHz"; else // SZD return "12 kHz"; } return(null); }
58fd4903-e51d-42f9-a008-e641cc9e1b3d
7
@Override public final boolean perform(AbstractComponent performer) throws IllegalAccessException { if (!isPerformable()) { throw new IllegalAccessException("Can't perform an abstract action"); } if (isCompleted()) { // stop performing if completed return true; } if (!initialized) { if (!preActionTask(performer)) { setState(STATE.INTERRUPTED); return false; } initialized = true; } setState(STATE.ONGOING); if (internalPerform(performer)) { setState(STATE.COMPLETED); postActionTask(performer); return true; } if (getDurationSeconds() > 0) { // if duration was set for this action. decrement. super.decrementDurationTime(); if (getDurationSeconds() == 0) { // if time elapsed, set state to completed setState(STATE.COMPLETED); postActionTask(performer); return true; } } return false; }
b1ea2225-27c7-40fc-b178-22b66f508253
2
@Override public int hashCode() { int hash = 3; hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 89 * hash + (this.password != null ? this.password.hashCode() : 0); hash = 89 * hash + Arrays.deepHashCode(this.groups); return hash; }
b5a29994-cfc2-4057-bcec-01b84c744085
5
@Override public String remove(Object keyObject) { String key = (String) keyObject; Map.Entry<String,String> toRemove = null; for (Map.Entry<String, String> e : entries) { if (key == null) { if (e.getKey() == null) { toRemove = e; break; } } else if (key.equalsIgnoreCase(e.getKey())) { toRemove = e; break; } } if(toRemove != null) { entries.remove(toRemove); return toRemove.getValue(); } return null; }
a33a7fcb-cfe5-4b59-ac53-14e6b8d82437
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; }
37346275-a324-4c18-af35-43169d01890e
1
public WallGridFactory(Grid grid) { if (grid == null) throw new IllegalArgumentException("Grid can't be null!"); this.grid = grid; }
3385c0cb-c30b-440d-8280-8e81aec6e4ba
1
@Override public void insertFilter(int index, PropertyFilter filter) throws IndexOutOfBoundsException { if (filter != null) { filters.add(index, filter); } else { throw new IllegalArgumentException("Provided PropertyFilter was null."); } }
daf875b4-8b41-4b58-bfe5-381230ff792c
0
public void addEdge(Vertex start, Vertex end) { adjacencyList.get(indexOf(start)).insertLast(end); }
0d7460cd-1014-48d2-afa4-ffcc78bbe508
6
@EventHandler public void WolfWeakness(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.Weakness.DodgeChance") / 100; final double ChanceOfHappening = random.nextDouble(); if (ChanceOfHappening >= randomChance) { dodged = true; } if (plugin.getWolfConfig().getBoolean("Wolf.Weakness.Enabled", true) && damager instanceof Wolf && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) { Player player = (Player) e; player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, plugin.getWolfConfig().getInt("Wolf.Weakness.Time"), plugin.getWolfConfig().getInt("Wolf.Weakness.Power"))); } }
1c26fd43-4167-46b3-9936-f60c72052251
7
@Override public Success<Expression> parse(String s, int p) { StringBuilder sb = new StringBuilder(); // Read in digits until there are none left. while (Character.isDigit(s.charAt(p))) sb.append(s.charAt(p++)); // If we didn't find any digits, this ain't an int. if (sb.length() == 0) return null; // See if this has a long literal suffix. boolean isLong = s.charAt(p) == 'l' || s.charAt(p) == 'L'; if (isLong) ++p; if (isLong) try { long n = Long.parseLong(sb.toString()); return new Success<Expression>(new LiteralLong(n), p); } catch (NumberFormatException e) { throw new NiftyException("Literal Long '%s' is too large.", sb); } try { int n = Integer.parseInt(sb.toString()); return new Success<Expression>(new LiteralInt(n), p); } catch (NumberFormatException e) { throw new NiftyException("Literal Int '%s' is too large.", sb); } }
02adfa3e-c4d0-4d33-932c-e27020a1cf34
3
public int willRLookback( int optInTimePeriod ) { if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) ) optInTimePeriod = 14; else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) ) return -1; return (optInTimePeriod-1); }
d4eb758e-66d4-42d6-a273-47bc201d6fac
0
public void setQuantity(Integer quantity) { this.quantity = quantity; }
56bdf472-480e-427e-b404-29b588c161b3
2
public List<Interval> getIntervals() { List<Interval> result=new ArrayList<>(); if(treeSet.isEmpty()){ return result; } Node worker=treeSet.first(); while (worker!=null){ Interval interval=new Interval(worker.value,worker.seqNext.value); result.add(interval); worker=worker.seqNext.next; } return result; }
10719bb6-3aff-4056-bdc6-400473f9d755
4
private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 423, 144); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); textField_Integer = new JTextField(); textField_Integer.setBounds(110, 41, 99, 21); frame.getContentPane().add(textField_Integer); textField_Integer.setColumns(10); textField_ID = new JTextField(); textField_ID.setColumns(10); textField_ID.setBounds(284, 41, 54, 21); frame.getContentPane().add(textField_ID); JButton btnConvertInt2ID = new JButton("=>"); btnConvertInt2ID.setBounds(220, 25, 54, 23); frame.getContentPane().add(btnConvertInt2ID); JButton btnConvertID2Int = new JButton("<="); btnConvertID2Int.setBounds(220, 58, 54, 23); frame.getContentPane().add(btnConvertID2Int); JLabel lblObjectid = new JLabel("ObjectIDInteger"); lblObjectid.setBounds(10, 44, 90, 15); frame.getContentPane().add(lblObjectid); JLabel lblObjectid_1 = new JLabel("ObjectID"); lblObjectid_1.setBounds(348, 44, 54, 15); frame.getContentPane().add(lblObjectid_1); btnConvertInt2ID.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String objectIntegerString = textField_Integer.getText(); if (objectIntegerString.equals("")) return; try{ int objectInteger = Integer.parseInt(objectIntegerString); String objectID = Util.int2id(objectInteger); textField_ID.setText(objectID); } catch (NumberFormatException nfe){ nfe.printStackTrace(); } } }); btnConvertID2Int.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String objectIDString = textField_ID.getText(); if (objectIDString.equals("")) return; if (objectIDString.length()==4){ objectIDString="["+objectIDString+"]"; textField_ID.setText(objectIDString); } int objectInteger = Util.id2int(objectIDString); textField_Integer.setText(objectInteger+""); } }); }
281ca22d-4444-402d-a041-0382e8b9e4d6
1
@Override public void clear() { for (int i = 0; i < size; i++) { data[i] = null; } size = 0; }
106007b4-9220-4513-8a6c-41e8276e62a9
1
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed imgIndicator--; jButton2.setEnabled(true); jButton4.setEnabled(true); if (imgIndicator == 0) { jButton1.setEnabled(false); jButton3.setEnabled(false); } StringBuilder buildSomething = new StringBuilder(); buildSomething.append("<html>"); buildSomething.append("<img src=\"").append(ChatBox.imgList.get(imgIndicator)).append("\" height=\"630\" width=\"510\">"); buildSomething.append("</html>"); jTextPane1.setText(buildSomething.toString()); jTextField1.setText(ChatBox.imgList.get(imgIndicator)); }//GEN-LAST:event_jButton3ActionPerformed
46c9095d-7f84-4998-a87c-99e27621bf70
3
public void saveConfig() { File folder = getDataFolder(); if (!folder.exists()) { folder.mkdir(); } File config = new File(folder, "config.cfg"); if (!config.exists()) { try { config.createNewFile(); Console.log("Created config.cfg!"); FileWriter fw = new FileWriter(config); BufferedWriter out = new BufferedWriter(fw); out.write("Width: 800" + "\n"); out.write("Height: 600" + "\n"); out.close(); Console.log("Saved config.cfg!"); } catch (IOException e) { e.printStackTrace(); } } }
76ff3fc2-fe5b-4ef5-b85c-b951f9a56afc
2
public Ranking(boolean needsAnswer){ items = new HashMap<Integer, String>(); hasAnswer = needsAnswer; prompt = InputHandler.getString("Enter the prompt for your Multiple Choice question:"); int numChoices = InputHandler.getInt("Enter the number of items: "); for (int i=1; i<=numChoices; i++){ String item = InputHandler.getString("Enter item #"+i+":"); if (hasAnswer){ setCorrectAnswer(item); }else{ items.put(i, item); } } }
6c1df74d-2910-4625-bd7a-adb8fd236a92
6
public void dispose() { if (tabs != null) { for (int i = 0; i < tabs.length; i++) { GraphicsTab tab = tabs[i]; tab.dispose(); } } tabs = null; if (resources != null) { for (int i = 0; i < resources.size(); i++) { if (resources.get(i) instanceof Resource) { resources.get(i).dispose(); } } } resources = null; if (backMenu != null) { backMenu.dispose(); backMenu = null; } }
23e2dc18-e1c6-480d-9dca-582d6846b385
8
private static void sort(Node[] src, Node[] dest, int low, int high) { int length = high - low; if (length < 7) { for (int i = low + 1; i < high; i++) for (int j = i, k = i - 1; j > low && (dest[k].weight > dest[j].weight); --j, --k) { Node t = dest[j]; dest[j] = dest[k]; dest[k] = t; } return; } int mid = (low + high) >>> 1; sort(dest, src, low, mid); sort(dest, src, mid, high); for (int i = low, p = low, q = mid; i < high; i++) { if (q >= high || p < mid && (src[p].weight <= src[q].weight)) dest[i] = src[p++]; else dest[i] = src[q++]; } }
a2cdd2f8-1025-4a76-9361-350b4a08fb40
7
protected String getDataType() { int offset = getOffsetInDataHeaderForDataName(); int maxLength = getDataNameMaxLength(); int nameLength = 0; // skip first 0 while ( (0 != dataHeader[offset + nameLength]) && (nameLength < maxLength) ) nameLength++; if (nameLength >= maxLength) return null; int typeLength = nameLength + 1; while ( (0 != dataHeader[offset + typeLength]) && (typeLength < maxLength) ) typeLength++; if (typeLength > maxLength) return null; if ((offset + nameLength + 1) == typeLength) return null; return new String(dataHeader, offset + nameLength + 1, typeLength - (offset + nameLength + 1)); }
b2b60960-7aa6-43c8-8278-02b49cf86997
8
public boolean simpleAddBlock(Polyominos p) { int hauteur=p.getHauteur(); int largeur= p.getLargeur(); // boucle de parcour du tableau for (int ligne = 0; ligne <= taille; ligne++) { for (int col = 0; col <= taille; col++) { // si il y a de la place pour pose en largeur et en hauteur if (((ligne + hauteur) <= taille) && ((col + largeur) <= taille)) { // on verifie si polyo est posable if (isPosable(p, ligne, col)) { // on pose le polyominos for (int lignP = 0; lignP < p.getHauteur(); lignP++) { for (int colP = 0; colP < p.getLargeur(); colP++) { plateau[(lignP + ligne)][(colP + col)] += p.polyominos[lignP][colP]; // si la valeur de la case du polyominos est // different de 0, on pose la couleur if (p.polyominos[lignP][colP] != 0) tabCoul[(lignP + ligne)][(colP + col)] = p .getCouleur() + "_" + p.getName() + p.nbBloc; } } // le polyominos est pose p.pose=true; //on renseigne le point d'origine de la pose (le point x,y de la "boite" du polyominos) p.ptOrigin=ligne+"_"+col; return true; } } } } // si nous arrivons ici, c'est que le polyominos n'as pas plus etre pose return false; }
5b6b67d0-bad7-49d2-848c-53129958accb
6
@Override public void actionPerformed(ActionEvent e) { Color color = display.getBackground(); int red = color.getRed(); int green = color.getGreen(); int blue = color.getBlue(); if (e.getActionCommand().equals("red")) { if (red == 0) { red = 255; } else { red = 0; } } if (e.getActionCommand().equals("green")) { if (green == 0) { green = 255; } else { green = 0; } } if (e.getActionCommand().equals("blue")) { if (blue == 0) { blue = 255; } else { blue = 0; } } Color setCol = new Color(red, green, blue); display.setBackground(setCol); }
7956d8cb-746f-481f-aa02-81b390483769
4
@Override protected void printScriptContents() { int nrOfClusters = clusters.size(); for (int i = 0; i < nrOfClusters; i++) { String rgbColourSpec = getRgbColourSpec(i); List<Integer> timeSeriesIndexes = clusters.get(i).getTimeSeriesIndexes(); int nrOfElementsInCluster = timeSeriesIndexes.size(); for (int j = 0; j < nrOfElementsInCluster; j++) { // Indexing is 1-based and we skip the time column int index = timeSeriesIndexes.get(j) + 2; if (isFirstLine(i, j)) { writer.println(getTimeSerieLine(rgbColourSpec, index, 0)); } else if (isLastLine(i, nrOfClusters, j, nrOfElementsInCluster)) { writer.println(getTimeSerieLine(rgbColourSpec, index, 2)); } else { writer.println(getTimeSerieLine(rgbColourSpec, index, 1)); } } } }
af95dc2d-9572-4319-9136-7b7b90a43893
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(Athentification.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Athentification.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Athentification.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Athentification.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 Athentification().setVisible(true); } }); }
75dff927-0b99-41e6-80c5-1661ed691f49
8
public boolean isOuter() { if (classType instanceof ClassInterfacesType) { ClassInfo clazz = ((ClassInterfacesType) classType).getClassInfo(); ClassAnalyzer ana = methodAnalyzer.getClassAnalyzer(); while (true) { if (clazz == ana.getClazz()) return true; if (ana.getParent() == null) break; if (ana.getParent() instanceof MethodAnalyzer && (Options.options & Options.OPTION_ANON) != 0) ana = ((MethodAnalyzer) ana.getParent()).getClassAnalyzer(); else if (ana.getParent() instanceof ClassAnalyzer && (Options.options & Options.OPTION_INNER) != 0) ana = (ClassAnalyzer) ana.getParent(); else throw new alterrs.jode.AssertError("Unknown parent: " + ana + ": " + ana.getParent()); } } return false; }
9dcfd728-ff7e-4c8b-b286-547d2429e25b
9
@Override protected ArrayList<PossibleTile> getLazyTiles(Board b) { King clone = this.clone(); clone.canCastle = false; ArrayList<PossibleTile> possibleTiles = new ArrayList<PossibleTile>(); ArrayList<PossibleTile> superLazyTile = new ArrayList<PossibleTile>(); superLazyTile.add(new PossibleTile(clone.getX() - 1, clone.getY() - 1, clone)); superLazyTile.add(new PossibleTile(clone.getX() , clone.getY() - 1, clone)); superLazyTile.add(new PossibleTile(clone.getX() + 1, clone.getY() - 1, clone)); superLazyTile.add(new PossibleTile(clone.getX() + 1, clone.getY() , clone)); superLazyTile.add(new PossibleTile(clone.getX() + 1, clone.getY() + 1, clone)); superLazyTile.add(new PossibleTile(clone.getX() , clone.getY() + 1, clone)); superLazyTile.add(new PossibleTile(clone.getX() - 1, clone.getY() + 1, clone)); superLazyTile.add(new PossibleTile(clone.getX() - 1, clone.getY() , clone)); for(PossibleTile pt : superLazyTile) { decideToAddTile(b, possibleTiles, pt); } for (Piece p : b.getPieces()) { if (p instanceof Rook && p.isWhite == this.isWhite) { Rook r = (Rook) p; if (r.canCastle()) { if ( this.getX() < r.getX() && this.canCastleRight(b) ) { possibleTiles.add(new PossibleTile(r.getX(), r.getY(), this)); } else if ( this.getX() > r.getX() && this.canCastleLeft(b) ) { possibleTiles.add(new PossibleTile(r.getX(), r.getY(), this)); } } } } return possibleTiles; }
b50da52f-00e0-456c-8148-eff82ec11bff
9
@Transactional @Override public String delete(Long objectId, Class clazz) { SimpleEntity object = (SimpleEntity) sessionFactory.getCurrentSession().get(clazz, objectId); //usuwam powiązania dla produktów, które odnoszą się do usuwanego typu if(clazz.equals(Type.class) && ((Type) object).getProducts().size() > 0) { Iterator iterator = ((Type) object).getProducts().iterator(); while(iterator.hasNext()) { Product product = ((Product) iterator.next()); product.setType(null); sessionFactory.getCurrentSession().update(product); } } //usuwam powiązania dla typów, które odnoszą się do usuwanej sekcji if(clazz.equals(Section.class) && ((Section) object).getTypes().size() > 0) { Iterator iterator = ((Section) object).getTypes().iterator(); while(iterator.hasNext()) { Type type = ((Type) iterator.next()); type.setSection(null); sessionFactory.getCurrentSession().update(type); } } //usuwam powiązania dla sekcji, które odnoszą się do usuwanej kategorii if(clazz.equals(Category.class) && ((Category) object).getSections().size() > 0) { Iterator iterator = ((Category) object).getSections().iterator(); while(iterator.hasNext()) { Section section = ((Section) iterator.next()); section.setCategory(null); sessionFactory.getCurrentSession().update(section); } } sessionFactory.getCurrentSession().delete(object); return "Usunieto"; }
3aeacda6-f2c8-434d-9010-64dc503dbbeb
7
@Test public void testJoin() { Runnable r1 = new Runnable(){ @Override public void run() { assertTrue(!r1Completed && !r2Completed); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } r1Completed = true; assertTrue(r1Completed); } }; final Thread t1 = new Thread(r1); t1.setName("thread1"); Runnable r2 = new Runnable(){ @Override public void run() { try { t1.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } r2Completed = true; assertTrue(r1Completed && r2Completed); } }; Thread t2 = new Thread(r2); t2.setName("thread2"); t2.start(); t1.start(); while(!r1Completed && !r2Completed){ System.out.println("waiting for r1 and r2 to complete"); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
6723a343-f591-4c81-879a-08f31f17d69f
9
public void createGameTab() { JPanel drawimagepanel; JLabel downfacelabel; JPanel drawbuttonslabel; JLabel laydownlabel; JPanel discardbuttonlabel; Icon upfaceicon; gametab = new JPanel(); gametab.setPreferredSize(new Dimension(1100,800)); gametab.setLayout(new GridLayout(5,1)); drawimagepanel = new JPanel(); if (rummydiscardpile.isEmpty()) { Card newcard = rummystockpile.draw(); if (newcard==null) { System.out.println("Game Over"); System.exit(1); } rummydiscardpile.addCard(newcard); } upfaceicon = this.rummydiscardpile.getTopOfDeck().getFace(); downfacelabel = new JLabel(this.DOWNFACEICON); upfacelabel = new JLabel(upfaceicon); drawimagepanel.add(downfacelabel); drawimagepanel.add(upfacelabel); gametab.add(drawimagepanel); drawbuttonslabel = new JPanel(); drawbuttonslabel.setLayout(new FlowLayout()); discardpile = new JButton("Discard Pile"); discardpile.addActionListener( new ActionListener() { // anonymous inner class /** * annonymous class action listener for the discard pile button. when pressed, takes top card off discard pile * and puts it in players hand. removes it from discardpile. reveals next card or if discard is empty, * takes the top card off the deck */ public void actionPerformed( ActionEvent event ) { //add card from theDiscardPile to theHand player.getHand().add(rummydiscardpile.draw()); if (rummydiscardpile.isEmpty()) { Card newcard = rummystockpile.draw(); if (newcard==null) { System.out.println("Game Over"); System.exit(1); } rummydiscardpile.addCard(newcard); } //update the image on the up_card of the discardPile upfacelabel.setIcon(rummydiscardpile.getTopOfDeck().getFace()); redrawHandImagePanel(); //updates the players hand display laydown.setEnabled(true); discard.setEnabled(true); stockpile.setEnabled(false); discardpile.setEnabled(false); return; } } // end anonymous inner class ); // end call to addActionListener stockpile = new JButton("The Deck"); stockpile.addActionListener( new ActionListener() { // anonymous inner class /** * annonymous inner class for the deck button action listener. Takes a card off the top of the deck and * puts it in the players hand. Updates the myhand display */ public void actionPerformed( ActionEvent event ) { //add card from theDeck to theHand Card newcard = rummystockpile.draw(); if (newcard==null) { System.out.println("Game Over"); System.exit(1); } player.getHand().add(newcard); redrawHandImagePanel(); //updates the players hand display laydown.setEnabled(true); discard.setEnabled(true); stockpile.setEnabled(false); discardpile.setEnabled(false); return; } } // end anonymous inner class ); // end call to addActionListener drawbuttonslabel.add(stockpile); drawbuttonslabel.add(discardpile); gametab.add(drawbuttonslabel); laydownimagepanel = new JPanel(); laydownimagepanel.setLayout(new FlowLayout()); laydownlabel = new JLabel("Laydown Zone"); laydownimagepanel.add(laydownlabel); gametab.add(laydownimagepanel); handimagepanel = new JPanel(); handimagepanel.setLayout(new FlowLayout()); for (Card c : player.getHand()) { this.handimagepanel.add(c); } gametab.add(handimagepanel); discardbuttonlabel = new JPanel(); discardbuttonlabel.setLayout(new FlowLayout()); laydown = new JButton("Laydown"); laydown.addActionListener( new ActionListener() { // anonymous inner class /** * When laydown is pressed, the AI will evaluate whether any of the players cards in chosenCards * can be laid down (this version does not check for proper lay down. It just lays down the * cards chosen. If yes, card will be added to theLaydownPile and removed from theHand. arrayPos will be * updated in the hand and the players card display will be updated as well as the laydown display */ public void actionPerformed( ActionEvent event ) { for(int i=0; i < theselectedcards.size(); i++) { player.getHand().get(player.getHand().indexOf(theselectedcards.get(i))); laydownimagepanel.add(theselectedcards.get(i)); } theselectedcards.removeAll(theselectedcards); //all done with chosen cards redrawHandImagePanel(); //update the players hand display redrawLaydownImagePanel(); //update the laydown display return; } } // end anonymous inner class ); // end call to addActionListener laydown.setEnabled(false); //initally, the button is turned off discard = new JButton("Discard"); discard.addActionListener( new ActionListener() { // anonymous inner class /** * When discard is pressed, the selected card will be removed from the hand and placed in the * discard pile. The discard pile will be updated, the arrayPos of each card in the hand will * be updated and the players hand display will be updated. */ public void actionPerformed( ActionEvent event ) { if(player.getHand().size() == 1) { handimagepanel.removeAll(); upfacelabel.setIcon(player.getHand().get(0).getFace()); JOptionPane.showMessageDialog(RummyGUI.this, "You only have one card left\n" + "You have won this hand!","Good Job!",JOptionPane.PLAIN_MESSAGE); // System.exit(NORMAL); //newGame(); } if(player.getHand().size() == 0) { upfacelabel.setIcon(RummyGUI.DOWNFACEICON); JOptionPane.showMessageDialog(RummyGUI.this, "You only have one card left\n" + "You have won this hand!","Good Job!",JOptionPane.PLAIN_MESSAGE); //System.exit(NORMAL); //newGame(); } rummydiscardpile.getDeck().add(theselectedcards.get(0)); //add first chosenCard to discPile player.getHand().remove(theselectedcards.get(0)); //remove chosenCard from theHand theselectedcards.removeAll(theselectedcards); //remove all of the cards in chosenCards //update the image on the up_card of the discardPile upfacelabel.setIcon(rummydiscardpile.getTopOfDeck().getFace()); redrawHandImagePanel(); //update myhand display laydown.setEnabled(false); //discard and laydown buttons disabled after discard discard.setEnabled(false); stockpile.setEnabled(true); //pick up buttons enabled discardpile.setEnabled(true); return; } } // end anonymous inner class ); // end call to addActionListener discard.setEnabled(false); //initially the button is turned off discardbuttonlabel.add(discard); discardbuttonlabel.add(laydown); gametab.add(discardbuttonlabel); }
445742f5-2047-4120-ae06-bad24764c6f5
8
private int calculateTeachersLectureWindowForIIIAndIV() { int penaltyPoints = 0; List<LinkedHashMap> teachersAllDay = getAllDaysTeacherTimeTable(); for (LinkedHashMap<String, LinkedHashMap> daysTimeTable : teachersAllDay) { Collection<String> teacherNames = daysTimeTable.keySet(); for (String teacherName : teacherNames) { LinkedHashMap<String, String> teachersTimeTableForTheDay = daysTimeTable.get(teacherName); Collection<String> lectureNumbers = teachersTimeTableForTheDay.keySet(); int lectureNumbersSize = lectureNumbers.size(); for (String lectureNumber : lectureNumbers) { String groupNameToSplit = teachersTimeTableForTheDay.get(lectureNumber); String[] splittedGroupNames = groupNameToSplit.split(":"); String groupName = splittedGroupNames[1].trim(); if (StringUtils.equals(groupName, EMPTY_GROUP)) { if (studentsMockData.getTeachersFromIIIAndIV().containsKey(teacherName)) { boolean isNotLastLectures = true; for (int lectNum = Integer.valueOf(lectureNumber); lectNum <= lectureNumbersSize; lectNum++) { String grpNam = teachersTimeTableForTheDay.get(String.valueOf(lectNum)).split(":")[1].trim(); if (StringUtils.equals(grpNam, EMPTY_GROUP)) { isNotLastLectures = false; } else { isNotLastLectures = true; break; } } if (isNotLastLectures) { penaltyPoints += PenaltyPoints.LECTURE_WINDOW_FOR_TEACHER_III_IV.penaltyPoints(); } } } } } } return penaltyPoints; }
9b08d0ea-db64-48b0-b212-35f70db7fce6
0
public String getSourceType() { return SOURCE_TYPE; }
ee38b9ef-ee8f-4c5d-84ad-293fe1481d35
6
public boolean equals(Object other) { try { if(other == null) return false; if(!(other instanceof KundeDTO)) return false; KundeDTO o = (KundeDTO)other; if (o.getNr() != this.getNr()) return false; if (!o.getName().equals(this.getName())) return false; if(!o.getAddress().equals(this.getAddress())) return false; return true; } catch (RemoteException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return false; }
126ea31a-4eb4-46cc-8258-0551ec8909cf
6
@EventHandler public void SpiderSlow(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.getSpiderConfig().getDouble("Spider.Slow.DodgeChance") / 100; final double ChanceOfHappening = random.nextDouble(); if (ChanceOfHappening >= randomChance) { dodged = true; } if (plugin.getSpiderConfig().getBoolean("Spider.Slow.Enabled", true) && damager instanceof Spider && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) { Player player = (Player) e; player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, plugin.getSpiderConfig().getInt("Spider.Slow.Time"), plugin.getSpiderConfig().getInt("Spider.Slow.Power"))); } }
710f7b76-078b-48c6-b848-1cea2bfc4684
8
public synchronized void bestowCurses(MOB mob) { norecurse=true; try { if(numCurses()>0) { mob.location().show(this,mob,CMMsg.MSG_OK_VISUAL,L("You feel the wrath of <S-NAME> in <T-NAME>.")); if(mob.charStats().getCurrentClass().baseClass().equals("Cleric") ||(CMSecurity.isASysOp(mob))) { for(int b=0;b<numCurses();b++) { final Ability Curse=fetchCurse(b); if(Curse!=null) bestowCurse(mob,Curse); } } else { final int randNum=CMLib.dice().roll(1,numCurses(),-1); final Ability Curse=fetchCurse(randNum); if((Curse!=null)&&(!fetchBlessingCleric(randNum))) bestowCurse(mob,Curse); } } } catch(final Exception e) { Log.errOut("StdDeity",e); } norecurse=false; }
7c985355-4c7d-4c9b-88ad-5ac62fe02dad
6
public void parseFromJsonFile(File json) { try { String s = readFile(json); if(s.trim().length()!=0) { JSONObject jsonO = new JSONObject(s); if(jsonO.has("title")) { name = jsonO.getString("title"); } if(jsonO.has("id")) { id = jsonO.getString("id"); } if(jsonO.has("version")) { version = jsonO.getString("version"); } if(jsonO.has("vendor")) { author = jsonO.getString("vendor"); } } } catch(Exception e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }
cfebc747-b03a-4225-a5ae-23ba79588f49
3
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final ZState other = (ZState) obj; if (!Objects.equals(this.id, other.id)) { return false; } return true; }
8056a105-eeef-47ac-a502-d9f413ebe8d7
7
public void parseParams(String[] args) { if (args == null || args.length == 0) return; for (String s : args) { // split on "=" int splitIndex = s.indexOf('='); if (splitIndex < 0) throw new IllegalArgumentException( "Parameter '" + s + "' is ill-formed. It should be of the form 'param=value'"); String param = s.substring(0, splitIndex); String value = s.substring(splitIndex + 1, s.length()); // strip off quotes around the outside if (value.length() > 2 && value.startsWith("\"") && value.endsWith("\"")) value = value.substring(1, value.length()-1); setProperty(param, value); } }
e2f4b645-d2de-49b5-b272-7a900a69e9e3
1
@Override public void display(String[] playersName) { JButton confirmButton = createButton(250, 400, "Confirm"); addListeners(confirmButton); panel.add(confirmButton); createVoteList(180, 30); panel.add(voteList); int x = 80, y = 70; for (String player : playersName) { AbstractButton button = new JRadioButton(player); customizeButton(x, y, player, button); voteList.add(button); y += 50; } panel.repaint(); }
23fdc709-cccc-4623-8539-bdc2f070847f
7
public Boolean balance(privAVLNode x) { if(checkBalance(x) == true) return true; int test0 = 0; int test1 = 0; if(x.getChild(0) != null) test0 = x.getChild(0).getHeight() + 1; if(x.getChild(1) != null) test1 = x.getChild(1).getHeight() + 1; int hld1; if(test0 > test1) hld1 = 0; else hld1 = 1; test0 = 0; test1 = 0; if(x.getChild(hld1).getChild(hld1) != null) test0 = x.getChild(hld1).getChild(hld1).getHeight() +1; if(x.getChild(hld1).getChild((hld1+1)%2) != null) test1 = x.getChild(hld1).getChild((hld1+1)%2).getHeight()+1; if(test0 > test1) singleRotation(x,hld1); else doubleRotation(x,hld1); return false; }
0c93ea26-e896-43c7-9af0-8d2b4a80da81
7
@Override public Object getValueAt(int r, int c) { TableElement te = _data.get( _filter.get(r) ); switch(c) { case 0: return te.getUniqueID(); case 1: return te.getCoords()[0]; case 2: return te.getCoords()[1]; case 3: return te.getPlateInfo()[0]; case 4: return te.getPlateInfo()[1]; case 5: return te.getPlateInfo()[2]; case 6: return te.getMatches(); default: return "Error"; } }
41b74c79-1515-4f07-89e1-d611f95aa388
7
public int divide(int dividend, int divisor) { boolean positive = true; if((dividend>0&&divisor<0)||(dividend<0&&divisor>0)) positive = false; long did,dis; did = dividend>=0?(long)dividend:-(long)dividend; dis = divisor>=0?(long)divisor:-(long)divisor; int result = generateDivide(did,dis); return positive? result:-result; }
57dbb761-6638-4989-827d-6965f780e2cc
6
public static void main(String[] args) throws UnknownHostException, InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, IllegalArgumentException, InvocationTargetException{ List<TaoItem> tiList = new ArrayList<TaoItem>(); Mongo mongo = new Mongo(); for(String dbName : mongo.getDatabaseNames()){ System.out.println(dbName); } DB db = mongo.getDB("test"); DBCollection test = db.getCollection("test"); DBCursor cursor = test.find(); while(cursor.hasNext()){ DBObject dbo = cursor.next(); TaoItem ti = MongoConverter.dbobject2Bean(TaoItem.class, dbo); tiList.add(ti); } System.out.println("-----------tiList start---------"); for(TaoItem ti:tiList){ System.out.println(ti.toJSONObject().toString()); } System.out.println("-----------tiList end---------"); String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; List<String> testList = new ArrayList<String>(); Random random = new Random(); for(int i=0;i<10;i++){ int length = random.nextInt(10); StringBuffer sb = new StringBuffer(length); for(int k=0;k<length;k++){ int ind = random.nextInt(base.length()); sb.append(base.charAt(ind)); } testList.add(sb.toString()); } if(!tiList.isEmpty()){ System.out.println(); TaoItem ti = tiList.get(0); ti.setTestList(testList.toArray(new String[testList.size()])); DBObject dbo = MongoConverter.bean2DBObject(ti); DBCollection dbc = db.getCollection("testCol"); dbc.insert(dbo); System.out.println("dbo: "+dbo); TaoItem testTi = new TaoItem(); System.out.println(MongoConverter.bean2DBObject(testTi).get("_id")); TaoItem testBean = MongoConverter.dbobject2Bean(TaoItem.class, dbo); System.out.println("bean: "+testBean.toJSONObject().toString()); dbo =dbc.findOne(); System.out.println("from dbo: "+dbo); testBean = MongoConverter.dbobject2Bean(TaoItem.class, dbo); System.out.println("from bean: "+testBean.toJSONObject().toString()); } QueryBuilder qb = QueryBuilder.start("nick").is("robot627").and("count").lessThan(5).and("count").greaterThanEquals(10); mongo.close(); }
c0810087-fcbc-4c31-a4fe-447d9b14b8a9
8
protected String escapeString(final String csvElement) { if( csvElement.isEmpty() ) { return ""; } currentColumn.delete(0, currentColumn.length()); // reusing builder object final int delimiter = preference.getDelimiterChar(); final char quote = (char) preference.getQuoteChar(); final char space = ' '; final String eolSymbols = preference.getEndOfLineSymbols(); final boolean surroundingSpacesNeedQuotes = preference.isSurroundingSpacesNeedQuotes(); final int lastCharIndex = csvElement.length() - 1; // elements with leading/trailing spaces require surrounding quotes if surroundingSpacesNeedQuotes is enabled boolean needForEscape = surroundingSpacesNeedQuotes && (csvElement.charAt(0) == space || csvElement.charAt(lastCharIndex) == space); for( int i = 0; i <= lastCharIndex; i++ ) { final char c = csvElement.charAt(i); if( c == delimiter ) { needForEscape = true; currentColumn.append(c); } else if( c == quote ) { needForEscape = true; currentColumn.append(quote); currentColumn.append(quote); } else if( c == '\n' ) { needForEscape = true; currentColumn.append(eolSymbols); lineNumber++; } else { currentColumn.append(c); } } // if element contains special characters, escape the // whole element with surrounding quotes if( needForEscape ) { currentColumn.insert(0, quote).append(quote); } return currentColumn.toString(); }
c9934d03-3844-4f25-a5fb-998a7f8441f6
1
void send(ConduitMessage msg) { try { msg.send(mClientOutput); } catch (Exception exception) { shutdown(); } }
427ee3a0-2e2f-4eb7-8634-4b0386c74e0c
1
protected Duration restReduced() { Duration gap = lastWeekRest(); if (gap.isShorterThan(Rest.NORMAL.getValue())) { return null; } return Utils.safeMinus(Rest.REDUCED.getValue(), intervals.lastGap()); }
b9d56b96-c809-4fd5-9f55-4b5110f4c9d4
0
protected TableModel createModel(Transition transition) { final MooreTransition t = (MooreTransition) transition; return new AbstractTableModel() { String s[] = new String[] {t.getLabel()}; public Object getValueAt(int r, int c) {return s[c];} public void setValueAt(Object o, int r, int c) {s[c] = (String) o;} public boolean isCellEditable(int r, int c) {return true;} public int getRowCount() {return 1;} public int getColumnCount() {return 1;} public String getColumnName(int c) {return NAME;} }; }
44240659-76ac-43dc-a813-6a0f39378152
3
public Region get(int x,int z){ int i = 0; while(i < regions.size()){ if(regions.get(i).getX()==x&&regions.get(i).getZ()==z)return regions.get(i); i++; } return null; }
11b3ad4e-cd90-4c5e-8df0-313d56038d70
8
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { String parm = (commands.size() > 1) ? CMParms.combine(commands,1) : ""; if((!mob.isAttributeSet(MOB.Attrib.AUTOGOLD) && (parm.length()==0))||(parm.equalsIgnoreCase("ON"))) { mob.setAttribute(MOB.Attrib.AUTOGOLD,true); mob.tell(L("Autogold has been turned on.")); } else if((mob.isAttributeSet(MOB.Attrib.AUTOGOLD) && (parm.length()==0))||(parm.equalsIgnoreCase("OFF"))) { mob.setAttribute(MOB.Attrib.AUTOGOLD,false); mob.tell(L("Autogold has been turned off.")); } else if(parm.length() > 0) { mob.tell(L("Illegal @x1 argument: '@x2'. Try ON or OFF, or nothing to toggle.",getAccessWords()[0],parm)); } return false; }
d9aaa53b-5659-4c97-930c-55e6cde50ba9
8
public int candy(int[] ratings) { int n = ratings.length; if(n==0) return 0; if(n==1) return 1; int[] candys = new int[n]; if(ratings[0]<=ratings[1]) candys[0] = 1; if(ratings[n-1]<=ratings[n-2]) candys[n-1] = 1; for(int i=1; i<n;i++){ if(ratings[i]>ratings[i-1]) candys[i] = candys[i-1]+1; else candys[i] = 1; } for(int i=n-2; i>=0; i--){ if(ratings[i]>ratings[i+1]) candys[i] = max(candys[i+1]+1, candys[i]); else candys[i] = 1; } return sum(candys); }
fe07121f-8585-4ed6-8b49-a10f5ac743b4
7
private boolean bruteForceSolver(int index) { boolean solvable = false; NakedCandidates candidate = nakeds.get(index); for (int i=0; i < candidate.values.size() && !solvable; i++) { if (!board.duplicateEntryColumn(candidate.y, candidate.values.get(i)) && !board.duplicateEntryRow(candidate.x, candidate.values.get(i)) && !board.duplicateEntrySection(candidate.x, candidate.y, candidate.values.get(i))) { board.setValue(candidate.x, candidate.y, candidate.values.get(i)); solvable = (index < nakeds.size()-1 ? bruteForceSolver(index+1) : board.isSolved()); } } if (!solvable) { board.setValue(candidate.x, candidate.y, new String("*")); } return solvable; }
9df9650d-2bfc-4916-b438-caecb258c651
1
public String getEntitySystemId(String ename) { Object entity[] = (Object[]) entityInfo.get(ename); if (entity == null) { return null; } else { return (String) entity[2]; } }
2e98d75f-1c22-4a82-a00d-b279d425d198
7
private static void moveChars(int len){ String str = "abcdefg"; char[] sa = str.toCharArray(); char s; if(len > 0){ //拆为两部分,分别反转,然后再整体反转,表现为左移 for (int i = 0; i < len >> 1; i++ ) { s = sa[i]; sa[i] = sa[len -i - 1]; sa[len - i - 1] = s; } for(int i = 0; i < (sa.length - len) >> 1; i++ ) { s = sa[len + i]; sa[len + i] = sa[sa.length - i - 1]; sa[sa.length - i - 1] = s; } for(int i = 0; i < sa.length >> 1; i++ ) { s = sa[i]; sa[i] = sa[sa.length - i - 1]; sa[sa.length - i - 1] = s; } }else{ //拆为两部分,整体反转,然后再分别反转,表现为右移 len = Math.abs(len); for(int i = 0; i < sa.length >> 1; i++ ) { s = sa[i]; sa[i] = sa[sa.length - i - 1]; sa[sa.length - i - 1] = s; } for (int i = 0; i < len >> 1; i++ ) { s = sa[i]; sa[i] = sa[len -i - 1]; sa[len - i - 1] = s; } for(int i = 0; i < (sa.length - len) >> 1; i++ ) { s = sa[len + i]; sa[len + i] = sa[sa.length - i - 1]; sa[sa.length - i - 1] = s; } } System.out.println(new String(sa)); }
781ef9f2-c216-425c-a3a2-977914cdfdbc
2
public void run(){ try { while(true){ rcv(); } } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
45a0219e-9a8f-40af-9fd1-ed10884e2bd7
0
public MouseHandler()//Check again later { cX = Game.fieldWidth + Game.xOff; cY = Game.fieldWidth + Game.yOff; }
f6164590-5d0b-462d-8924-dc8a9a43d465
4
public void getChunkByOff(long off) { //TODO int[] rpos = new int[vsize.length]; long toff = off; for (int i = vsize.length -1 ; i >=0 ; i--) { rpos[i] =(int)toff % vsize[i]; toff /= vsize[i]; } int cnum = 0; int ichunk = 0; for (int i = 0 ; i < vsize.length ; i++) { cnum = cnum *(( vsize[i] / (this.chunkStep[i] )+ (vsize[i] % this.chunkStep[i] == 0 ? 0 : 1))) + rpos[i] / this.chunkStep[i]; this.start[i] = rpos[i] - rpos[i] % this.chunkStep[i]; } int []csize = this.getChunkSize(); for(int i = 0; i < csize.length; i++) { ichunk = rpos[i] % csize[i] + ichunk * csize[i]; } this.chunkNum = cnum; this.inChunk = ichunk; }
9775a8b1-f03a-4574-9b0b-e3d3240984f5
1
public URL getURL() throws NotFoundException { URL url = classPool.find(getName()); if (url == null) throw new NotFoundException(getName()); else return url; }
b61f1c31-c667-423f-9f58-3af3d2313573
5
@Override protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { DatabaseManager manager=DatabaseManager.getManager(); try { Room room = manager.getRoomDao().queryForId( Integer.parseInt(request.getParameter(ID))); String title=request.getParameter(Room.TITLE); String capacity=request.getParameter(Room.CAPACITY); if(!MyServlet.isEmpty(title)){ room.setTitle(title); } if(!MyServlet.isEmpty(capacity)){ room.setCapacity(Integer.parseInt(capacity)); } ServletResult.sendResult(response, manager.getRoomDao().update(room)==1 ? ServletResult.SUCCESS : ServletResult.ERROR); } catch (NumberFormatException e) { e.printStackTrace(); ServletResult.sendResult(response, ServletResult.BAD_NUMBER_FORMAT); } catch (SQLException e) { e.printStackTrace(); ServletResult.sendResult(response, ServletResult.ERROR); } }
0ae8bdd9-03d4-4a6c-bf8d-de0d3ca10035
6
private boolean versionCheck(String title) { if(type != UpdateType.NO_VERSION_CHECK) { String version = plugin.getDescription().getVersion(); if(title.split(" v").length == 2) { String remoteVersion = title.split(" v")[1].split(" ")[0]; // Get the newest file's version number int remVer = -1,curVer=0; try { remVer = calVer(remoteVersion); curVer = calVer(version); } catch(NumberFormatException nfe) { remVer=-1; } if(hasTag(version)||version.equalsIgnoreCase(remoteVersion)||curVer>=remVer) { // We already have the latest version, or this build is tagged for no-update result = Updater.UpdateResult.NO_UPDATE; return false; } } else { // The file's name did not contain the string 'vVersion' plugin.getLogger().warning("The author of this plugin (" + plugin.getDescription().getAuthors().get(0) + ") has misconfigured their Auto Update system"); plugin.getLogger().warning("Files uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0"); plugin.getLogger().warning("Please notify the author of this error."); result = Updater.UpdateResult.FAIL_NOVERSION; return false; } } return true; }
f8a0eb24-72a9-4d01-a41c-1ca99962d934
5
public void move(Direction dir) { if(dir == null) return; if(dir.equals(Direction.North)) { y--; last = Direction.North; visited.add(new Location(x , y)); } else if(dir.equals(Direction.East)) { x++; last = Direction.East; visited.add(new Location(x , y)); } else if(dir.equals(Direction.South)) { y++; last = Direction.South; visited.add(new Location(x , y)); } else if(dir.equals(Direction.West)) { x--; last = Direction.West; visited.add(new Location(x , y)); } }
e8884a7a-1470-4b1f-bba6-3eb2f9ba20ad
9
private void rectangleSelectHandler(Page currentPage, Point mouseLocation) { // detect L->R or R->L if (currentPage != null && currentPage.isInitiated()) { // get page text PageText pageText = currentPage.getViewText(); if (pageText != null) { // clear the currently selected state, ignore highlighted. currentPage.getViewText().clearSelected(); // get page transform, same for all calculations AffineTransform pageTransform = currentPage.getPageTransform( Page.BOUNDARY_CROPBOX, documentViewModel.getViewRotation(), documentViewModel.getViewZoom()); Rectangle2D pageRectToDraw = convertRectangleToPageSpace(rectToDraw, pageTransform); ArrayList<LineText> pageLines = pageText.getPageLines(); for (LineText pageLine : pageLines) { // check for containment, if so break into words. if (pageLine.intersects(pageRectToDraw)) { pageLine.setHasSelected(true); ArrayList<WordText> lineWords = pageLine.getWords(); for (WordText word : lineWords) { if (word.intersects(pageRectToDraw)) { word.setHasHighlight(true); ArrayList<GlyphText> glyphs = word.getGlyphs(); for (GlyphText glyph : glyphs) { if (glyph.intersects(pageRectToDraw)) { glyph.setSelected(true); pageViewComponent.repaint(); } } } } } } } } }
095e9c89-8033-4aa3-b4c9-6b3ad2e8d781
8
@Override public void execute() { if (Game.getClientState() != Game.INDEX_MAP_LOADED) { AIOsmelter.stop = 1000; } if (Game.getClientState() == Game.INDEX_MAP_LOADED && AIOsmelter.stop == 1000) { AIOsmelter.stop = 50; } if (AIOsmelter.client != Bot.client()) { WidgetCache.purge(); Bot.context().getEventManager().addListener(this); AIOsmelter.client = Bot.client(); } if (Walking.getEnergy() == 100 && !Walking.isRunEnabled()) { Walking.setRun(true); } if (Widgets.get(205).getChild(1).isOnScreen()) { Walking.walk(Constants.EDGEVILLE_ESCAPE_TILE); } if (Widgets.get(640, 30).isOnScreen()) { Widgets.get(640, 30).click(true); } }
63915021-cd5f-4855-8310-92215042d06c
9
private void spinner_x2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinner_x2StateChanged if(hitbox_index_selected!=-1 || click_target_flag) { click_target_flag=true; if(hitbox_index_selected!=-1) { int i=0; for(Node hitboxes_node=current_frame.getFirstChild();hitboxes_node!=null;hitboxes_node=hitboxes_node.getNextSibling())//Hitbox loop { if(hitboxes_node.getNodeName().equals("Hitboxes")) { if(((Element)hitboxes_node).getAttribute("variable").equals(hitbox_color_selected)) { for(Node hitbox=hitboxes_node.getFirstChild();hitbox!=null;hitbox=hitbox.getNextSibling())//Red Hitboxes loop { if(hitbox.getNodeName().equals("Hitbox")) { if(i==hitbox_index_selected) ((Element)hitbox).setAttribute("x2", ""+spinner_x2.getValue()); i++; } } } } } updateHitboxes(current_frame); } }else { JOptionPane.showMessageDialog(null, "Select a hitbox first.", "Be careful", JOptionPane.INFORMATION_MESSAGE); } }//GEN-LAST:event_spinner_x2StateChanged
a43738d4-ae69-44b1-8683-ad8cae714ca0
0
public HeroSlot() { // create slot with all basic at first hero = CharacterFactory.create().buyCharacter(Constants.CHARACTER_DEFAULT); weaponSlot = new WeaponSlots(); headArmorSlot = new HeadArmorSlots(); bodyArmorSlot = new BodyArmorSlots(); }
53b02544-f426-4692-be0f-7b9a4001beb0
0
public int GetAverageNumberOfPersons() { return averageNumberOfPersons; }
084f1df5-ed41-488f-9a7a-1cf9d04f4f3c
2
@Override public void write(Writer writer) throws IOException { writer.write('['); Iterator<JSONValue> it = values.iterator(); while (it.hasNext()) { it.next().write(writer); if (it.hasNext()) { writer.write(", "); } } writer.write(']'); }
c9f310fe-088b-448f-8df5-5e16d8f83ee1
7
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof OpenBitSet)) return false; OpenBitSet a; OpenBitSet b = (OpenBitSet)o; // make a the larger set. if (b.wlen > this.wlen) { a = b; b=this; } else { a=this; } // check for any set bits out of the range of b for (int i=a.wlen-1; i>=b.wlen; i--) { if (a.bits[i]!=0) return false; } for (int i=b.wlen-1; i>=0; i--) { if (a.bits[i] != b.bits[i]) return false; } return true; }
d73ecaf1-5f5f-4756-b37a-9949f70ecb45
2
private int ROMSize() { if (addressMax <= 24576) return 24576; // The amount needed is less than/equal to 24K, return 24K int size = 24576; // Start off w/ 24KB addressMax -= 24576; // Remove 24KB from the overall size while (addressMax > 0) { addressMax -= 8192; // Iterate through subtracting 8KB at a time size += 8192; // Add 8KB to the ROM size } return size; // Return the size of the ROM }
77d3297e-9fec-43a6-92dc-131004e518fe
2
public static Performance createNew(Connection con, int userID, int phrase) { Performance perf = null; try { PreparedStatement ps = con.prepareStatement( "INSERT INTO " + tableInfo.tableName + " (UserID, Phrase, Success, RevSuccess, LastSuccess, RevLastSuccess , LastFail, RevLastFail) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS); ps.setInt(1, userID); ps.setInt(2, phrase); ps.setInt(3, 0); ps.setInt(4, 0); ps.setTimestamp(5, null); ps.setTimestamp(6, null); ps.setTimestamp(7, null); ps.setTimestamp(8, null); ps.executeUpdate(); ResultSet rs = ps.getGeneratedKeys(); rs.next(); perf = new Performance(con, rs.getString(1)); ps.close(); } catch(SQLException sqle) { if (sqle.getSQLState().equals("42X05")) // table does not exist { DBObject.createTable(con, tableInfo); return Performance.createNew(con, userID, phrase); } } return perf; }
fed80146-aae8-4d8a-935e-70a5f247645b
2
public Point[] simplifiedCurve(){ if(!this.simplifyDone){ if(!this.tolerenceEntered){ throw new IllegalArgumentException("No tolerance has been entered"); } else{ this.douglasPeucker(); } } return this.simplifiedPoints; }
5cfa5b6e-ffb9-4947-9870-dea1b28e2f4c
0
public void setjTextAreaBilan(JTextArea jTextAreaBilan) { this.jTextAreaBilan = jTextAreaBilan; }
86799eda-bcaf-4ff5-a1e1-f1464645be17
1
public void test_append_nullParser() { try { DateTimeFormatterBuilder bld2 = new DateTimeFormatterBuilder(); bld2.append((DateTimeParser) null); fail(); } catch (IllegalArgumentException ex) { // expected } }
b7dff91e-bd24-4fd6-bcdd-d02ed1d93b15
8
protected static Level getLog4jLevel(final int level) { switch(level) { case SyslogConstants.LEVEL_DEBUG: return Level.DEBUG; case SyslogConstants.LEVEL_INFO: return Level.INFO; case SyslogConstants.LEVEL_NOTICE: return Level.INFO; case SyslogConstants.LEVEL_WARN: return Level.WARN; case SyslogConstants.LEVEL_ERROR: return Level.ERROR; case SyslogConstants.LEVEL_CRITICAL: return Level.ERROR; case SyslogConstants.LEVEL_ALERT: return Level.ERROR; case SyslogConstants.LEVEL_EMERGENCY: return Level.FATAL; default: return Level.WARN; } }
02cd3a92-f360-4d1b-b0c0-764735aac33e
1
private boolean isMyTurn() { return myColor.isPresent() && myColor.get() == turnOfColor; }
7642e96b-e736-4f4c-9d11-eb5152462824
0
public void setK(float k) { this.k = k; }
0e313d2c-d820-4cc8-b992-10a8604f499f
1
public boolean posnEquals(Point p1, Point p2) { return p1.x == p2.x && p1.y == p2.y; }
8fd99d9b-d6df-4260-a974-aecf67082a7c
5
public void addGtfsData(List<Object> data){ if(fields==null || data==null) return; if(fields.size()!=data.size()) return; CoordSystemPointConversion conversion = new CoordSystemPointConversion("PROJCS[\"Albers Conical Equal Area [Florida Geographic Data Library]\"," + "GEOGCS[\"GCS_North_American_1983_HARN\"," + "DATUM[\"D_North_American_1983_HARN\"," + "SPHEROID[\"GRS_1980\",6378137.0,298.257222101]]," + "PRIMEM[\"Greenwich\",0.0]," + "UNIT[\"Degree\",0.0174532925199433]]," + "PROJECTION[\"Albers\"]," + "PARAMETER[\"False_Easting\",400000.0]," + "PARAMETER[\"False_Northing\",0.0]," + "PARAMETER[\"Central_Meridian\",-84.0]," + "PARAMETER[\"Standard_Parallel_1\",24.0]," + "PARAMETER[\"Standard_Parallel_2\",31.5]," + "PARAMETER[\"Central_Parallel\",24.0]," + "UNIT[\"Meter\",1.0]]"); double wgsLatLon[] = new double[2]; String id = (String)data.get(fields.indexOf("shape_id")); wgsLatLon[0] = Double.parseDouble((String)data.get(fields.indexOf("shape_pt_lon"))); wgsLatLon[1] = Double.parseDouble((String)data.get(fields.indexOf("shape_pt_lat"))); double projLatLon[] = new double[2]; projLatLon = conversion.getConversionOf(wgsLatLon); // Get correct set of points ArrayList<SDEPoint> points; if(allPoints==null || !shapeIds.keySet().contains(id)){ points = new ArrayList<SDEPoint>(); shapeIds.put(id, allPoints.size()); allIds.add(id); allPoints.add(points); } else { points = allPoints.get(shapeIds.get(id)); } points.add(new SDEPoint(projLatLon[0], projLatLon[1])); }
a8fc2517-b43c-4ec0-bc1d-691113824702
3
public Matrix4f InitIdentity() { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) if (i == j) matrix[i][j] = 1; else matrix[i][j] = 0; return this; }
d219cbdb-2f05-4684-ad7a-9af566db4d73
0
public String getId() { return id; }
fd317279-bcaa-4c67-a7f0-cf7a83375e3e
4
protected int getMaxSizeX(final JComponent[] components) { int max = 0; for (final JComponent component : components) { final Dimension dimension = component.getMaximumSize(); if (dimension != null) { if ((dimension.width > max) && (dimension.width != Integer.MAX_VALUE)) { max = dimension.width; } } } return max; }
ae0ebfdd-9f73-4ea9-8526-ec1c23a440f1
3
public void acquirePowerUp(PowerUp powerUp) { // remove it from the map map.removeSprite(powerUp); if (powerUp instanceof PowerUp.Star) { // do something here, like give the player points score += 50; municiones += 1; soundManager.play(prizeSound); } else if (powerUp instanceof PowerUp.Music) { // change the music soundManager.play(prizeSound); toggleDrumPlayback(); } else if (powerUp instanceof PowerUp.Goal) { // advance to next map soundManager.play(prizeSound, new EchoFilter(2000, .7f), false); municiones = 3; map = resourceManager.loadNextMap(); renderer.setBackground( resourceManager.loadImage("background"+resourceManager.getCurrentMap()+".jpg")); } }
344c5e1e-4aa3-415a-8a18-08e7bcdff71a
3
public EdgeReorderer(ArrayList<Edge> origEdges, Class criterion) { if (criterion != Vertex.class && criterion != Site.class) { throw new Error("Edges: criterion must be Vertex or Site"); } _edges = new ArrayList(); _edgeOrientations = new ArrayList(); if (origEdges.size() > 0) { _edges = reorderEdges(origEdges, criterion); } }
3bf6ec34-7ad7-41dc-9e14-68532842468f
1
public void testGetPeriodConverter() { PeriodConverter c = ConverterManager.getInstance().getPeriodConverter(new Period(1, 2, 3, 4, 5, 6, 7, 8)); assertEquals(ReadablePeriod.class, c.getSupportedType()); c = ConverterManager.getInstance().getPeriodConverter(new Duration(123L)); assertEquals(ReadableDuration.class, c.getSupportedType()); c = ConverterManager.getInstance().getPeriodConverter(new Interval(0L, 1000L)); assertEquals(ReadableInterval.class, c.getSupportedType()); c = ConverterManager.getInstance().getPeriodConverter(""); assertEquals(String.class, c.getSupportedType()); c = ConverterManager.getInstance().getPeriodConverter(null); assertEquals(null, c.getSupportedType()); try { ConverterManager.getInstance().getPeriodConverter(Boolean.TRUE); fail(); } catch (IllegalArgumentException ex) {} }
974de659-d140-4fa5-85a0-470f2af06fab
5
public AnimState getCurrentState() { AnimState ret = new AnimState(); for (AnimMultipleLine line : lines) { AnimState state = line.getCurrentState(); if (line.myPos) ret.pos = state.pos; if (line.myColor) ret.color = state.color; if (line.myAngle) ret.angle = state.angle; if (line.myScale) { ret.scaleH = state.scaleH; ret.scaleV = state.scaleV; } } return ret; }
c61e17c0-079d-4d21-b805-70bc9d0724c5
0
public ServerConnectionHandler(Socket sock, DtoExtractor dtoExtractor) { this.localSock = sock; this.dtoExtractor = dtoExtractor; }
9076571c-7d3b-472f-b2da-532edf07affe
6
public byte[] getEraseSequence(int eraseFunc) { byte[] sequence = null; switch (eraseFunc) { case TerminalIO.EEOL: sequence = new byte[3]; sequence[0] = ESC; sequence[1] = LSB; sequence[2] = LE; break; case TerminalIO.EBOL: sequence = new byte[4]; sequence[0] = ESC; sequence[1] = LSB; sequence[2] = 49; // Ascii Code of 1 sequence[3] = LE; break; case TerminalIO.EEL: sequence = new byte[4]; sequence[0] = ESC; sequence[1] = LSB; sequence[2] = 50; // Ascii Code 2 sequence[3] = LE; break; case TerminalIO.EEOS: sequence = new byte[3]; sequence[0] = ESC; sequence[1] = LSB; sequence[2] = SE; break; case TerminalIO.EBOS: sequence = new byte[4]; sequence[0] = ESC; sequence[1] = LSB; sequence[2] = 49; // Ascii Code of 1 sequence[3] = SE; break; case TerminalIO.EES: sequence = new byte[4]; sequence[0] = ESC; sequence[1] = LSB; sequence[2] = 50; // Ascii Code of 2 sequence[3] = SE; break; default: break; } return sequence; }// getEraseSequence