method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
d01dee42-a61d-4eda-905f-2b9336b48d57
6
public static List<CDDFeature> reloadFeatures(CyNetwork network, CyIdentifiable id) { if (!CyUtils.checkColumn(network.getDefaultNodeTable(), CDD_FEATURE, List.class, String.class)) return null; List<String> features = network.getRow(id).getList(CDD_FEATURE, String.class); List<String> chainFeatures = network.getRow(id).getList(PDB_CHAIN_FEATURES, String.class); List<String> types = network.getRow(id).getList(CDD_FEATURE_TYPE, String.class); List<String> sites = network.getRow(id).getList(CDD_FEATURE_SITE, String.class); if (features == null || features.size() != chainFeatures.size() || features.size() != types.size() || features.size() != sites.size()) return null; List<CDDFeature> cddFeatures = new ArrayList<CDDFeature>(); for (int i = 0; i < features.size(); i++) { CDDFeature hit = new CDDFeature(chainFeatures.get(i), features.get(i), types.get(i), sites.get(i)); cddFeatures.add(hit); } return cddFeatures; }
55aa6fea-55d6-4b52-98bb-a955cd8d36c1
6
@Override public void run() { if (D) Log.i(TAG, "BEGIN TimeoutThread (remaining time="+mTime+")"); setName("TimeoutThread (time="+mTime+")"); while (true) { try { Thread.sleep(mTime); break; } catch (InterruptedException e) { if (D) Log.i(TAG, "TimeoutThread reseted, starting over again"); } } if (listener != null) listener.onTimeExpired(); if (D) Log.i(TAG, "END TimeoutThread"); }
3b0bdc67-9b8d-47ae-9420-5adf8903acc7
7
@Override public void mousePressed(MouseEvent e) { for (int i = 0; i < sliders.size() && !active; i++) { TButton slider = sliders.get(i); if (slider.contains(e.getPoint())) { active = true; activeSlider = slider; } } if (active) { int i = getIndexOfSlider(activeSlider); if (isVertical) { dragStartedAt = e.getY() - activeSlider.getYI(); if (showValue) activeSlider.setLabel("" + getValue(i), false); } else { dragStartedAt = e.getX() - activeSlider.getXI(); if (showValue) activeSlider.setLabel("" + getValue(i), false); } } }
667948d8-7221-4f64-94ec-aa8ff3490631
5
public static int[] eliminateRedundantLinks(int[] links) { // final int tag = Integer.MIN_VALUE; // int last = 0; int ctr = 0; // if (links.length > 0) { ctr += LINK_SIZE; } // // first make redundant links invalid. // for (int i = LINK_SIZE; i < links.length; i += LINK_SIZE) { if (equal(links, i, last)) { // // links equal, eliminate link. // links[i] = tag; } else { last = i; ctr += LINK_SIZE; } } // // collect non-null links // int[] result = new int[ctr]; int idx = 0; for (int i = 0; i < links.length; i += LINK_SIZE) { if (links[i] != tag) { copy(links, i, result, idx); idx += LINK_SIZE; } } return result; }
7070f187-bb8a-42e5-b759-2752f108f5d0
2
public void loadImage(){ int returnVal = fc.showOpenDialog(Paintimator.this); BufferedImage[] img = new BufferedImage[1]; if (returnVal == JFileChooser.APPROVE_OPTION) { try { img[0] = ImageIO.read(fc.getSelectedFile()); layeredPanel.importImgToPane(img[0]); } catch (IOException e1) { JOptionPane.showMessageDialog(new JPanel(), "Image could not be loaded.", "Image error", JOptionPane.ERROR_MESSAGE); } } }
65f58af9-603e-47f1-bcf8-72d1f06fbacc
1
public boolean accept(File f){ return f.getName().endsWith(".gif") || f.isDirectory(); }
99385b13-f233-4f1c-95e7-42dc0322dbb6
9
private void btn_aceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_aceptarActionPerformed if (lab_modo.getText().equals("Alta")){ if (camposCompletos()){ ocultar_Msj(); insertar(); menuDisponible(true); modoConsulta(); updateTabla(); } else{ mostrar_Msj_Error("Por favor, complete todos los campos solicitados"); } } else{ if (lab_modo.getText().equals("Baja")){ if (!field_codigo.getText().equals("")){ if(!existe(Integer.parseInt(field_codigo.getText()))){ mostrar_Msj_Error("Ingrese un codigo que se encuentre registrado en el sistema"); field_codigo.requestFocus(); } else{ ocultar_Msj(); eliminar(); menuDisponible(true); modoConsulta(); vaciarCampos(); updateTabla(); } } else{ mostrar_Msj_Error("Por favor, complete todos los campos solicitados"); } } else{ if (lab_modo.getText().equals("Modificación")){ if (!field_codigo.getText().equals("")){ if(!existe(Integer.parseInt(field_codigo.getText()))){ mostrar_Msj_Error("Ingrese un codigo que se encuentre registrado en el sistema"); field_codigo.requestFocus(); } else{ if (camposCompletos()){ ocultar_Msj(); modificar(); menuDisponible(true); modoConsulta(); updateTabla(); } else{ mostrar_Msj_Error("Por favor, complete todos los campos solicitados"); } } } else{ mostrar_Msj_Error("Por favor, complete todos los campos solicitados"); } } } } }//GEN-LAST:event_btn_aceptarActionPerformed
858e0123-6048-4a04-a9cf-c0b9d6b6b12c
0
@Override public void setLoginTimeout(int arg0) throws SQLException { }
7a50ab00-5847-496c-8a2b-af8fc03ad267
9
@SuppressWarnings("rawtypes") public synchronized boolean clearWorldReference(String worldName) { if (regionfiles == null) { plugin.getLogger().warning("Exception while removing world reference for '" + worldName + "'!"); return false; } if (rafField == null) { plugin.getLogger().warning("Exception while removing world reference for '" + worldName + "'!"); return false; } ArrayList<Object> removedKeys = new ArrayList<Object>(); worldName = worldName.replaceAll("/", "|"); int Cleared = 0; try { for (Object o : regionfiles.entrySet()) { Map.Entry e = (Map.Entry) o; File f = (File) e.getKey(); String f_string = f.toString().replace("\\", "|"); f_string = f_string.substring(2, f_string.length()); if (f_string.startsWith(worldName)) { RegionFile file = (RegionFile) e.getValue(); try { RandomAccessFile raf = (RandomAccessFile) rafField.get(file); if(raf != null && raf.length() != 0){ raf.close(); } removedKeys.add(f); Cleared += 1; } catch (Exception ex) { ex.printStackTrace(); } } } } catch (Exception ex) { plugin.getLogger().warning("Exception while removing world reference for '" + worldName + "'!"); ex.printStackTrace(); } for (Object key : removedKeys) regionfiles.remove(key); return true; }
bf8a1d23-3f42-4301-9fe5-f199d607bab9
4
static String hashMD5(String s) throws ApiDataException { MessageDigest algorithm = null; try { algorithm = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException nsae) { throw new ApiDataException("Cannot find MD5 digest algorithm"); } byte[] defaultBytes = new byte[s.length()]; for (int i = 0; i < s.length(); i++) { defaultBytes[i] = (byte) (0xFF & s.charAt(i)); } algorithm.reset(); algorithm.update(defaultBytes); byte messageDigest[] = algorithm.digest(); StringBuilder hexString = new StringBuilder(); for (int i = 0; i < messageDigest.length; i++) { String hex = Integer.toHexString(0xFF & messageDigest[i]); if (hex.length() == 1) { hexString.append('0'); } hexString.append(hex); } return hexString.toString(); }
0be00366-8b55-43b1-a3a4-ace0f4d83e75
1
public void registerAll(Collection<RegisteredListener> listeners) { for (RegisteredListener listener : listeners) { register(listener); } }
05debba0-e43f-4d77-915d-063c22a44522
8
public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[27]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 22; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } } } } for (int i = 0; i < 27; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.add(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = jj_expentries.get(i); } return new ParseException(token, exptokseq, tokenImage); }
eac182eb-5ae2-4d44-b466-0bb727a9ab79
2
public void fire(){ final int dX = 3,dY = 3; if( lastDir==DirKey.Up || lastDir==DirKey.Down ){ bullets.add(new Bullet(id,this.getCenter().x - dX, this.getCenter().y, lastDir)); } else{ bullets.add(new Bullet(id,this.getCenter().x, this.getCenter().y - dY, lastDir)); } }
12d8db56-ddf1-4bba-a73b-77a797702bb1
4
public static void main(String[] args) { double score1, score2, score3; // Using three scores and an average double averageScore; Scanner keyboard = new Scanner(System.in); //Creates scanner object so program will accept input System.out.print("\n"); // Only for formatting, puts an extra line between the command line prompt and the start of the program System.out.print("What is the first test score: "); score1 = keyboard.nextFloat(); System.out.print("What is the second test score: "); score2 = keyboard.nextFloat(); System.out.print("What is the third test score: "); score3 = keyboard.nextFloat(); System.out.print("\n"); // Same as the first, only for aesthetics averageScore = ((score1 + score2 + score3)/3); //Calculations DecimalFormat formatter = new DecimalFormat("#0.00"); //Creates DecimalFormat object that makes output numbers stop after 2 decimal places System.out.println("Your average score is a(n) " + formatter.format(averageScore) + "%"); // Applies DecimalFormat object to my variable if(averageScore < 60) System.out.println("That is a(n) F."); else if(averageScore < 70) System.out.println("That is a(n) D."); else if(averageScore < 80) System.out.println("That is a(n) C."); //Using the If-ElseIf-Else loop lets me tell user different outputs depending on input else if(averageScore < 90) System.out.println("That is a(n) B."); else System.out.println("That is an(n) A. Great Job!!"); //Since I only have 1 class in this file, I shouldn't need System.exit() ... hopefully }
c0d9eb42-e2a2-42fa-956d-ae135512c502
0
public TasonLuontiTest() { }
b0ed7fd9-3ce3-49c8-b216-92fd21e2a29d
2
public EditorRuler(mxGraphComponent graphComponent, int orientation) { this.orientation = orientation; this.graphComponent = graphComponent; updateIncrementAndUnits(); graphComponent.getGraph().getView().addListener( mxEvent.SCALE, repaintHandler); graphComponent.getGraph().getView().addListener( mxEvent.TRANSLATE, repaintHandler); graphComponent.getGraph().getView().addListener( mxEvent.SCALE_AND_TRANSLATE, repaintHandler); graphComponent.getGraphControl().addMouseMotionListener(this); DropTarget dropTarget = graphComponent.getDropTarget(); try { if (dropTarget != null) { dropTarget.addDropTargetListener(this); } } catch (TooManyListenersException tmle) { // should not happen... swing drop target is multicast } setBorder(BorderFactory.createLineBorder(Color.black)); }
b45b6d90-afe7-4990-aa65-ef40a52178c6
2
public static int loadTexture(String path) { int tex = 0; BufferedImage img = null; try { img = ImageIO.read(Main.class.getResourceAsStream(path)); } catch (Exception e) { System.out.print(e.toString()); return 0; } int[] pix = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth()); ByteBuffer bb = BufferUtils.createByteBuffer((img.getWidth() * img.getHeight()) * 4); for (int i = 0; i < pix.length; i++) { byte alpha = (byte) ((pix[i] >> 24) & 0xFF); byte red = (byte) ((pix[i] >> 16) & 0xFF); byte green = (byte) ((pix[i] >> 8) & 0xFF); byte blue = (byte) ((pix[i]) & 0xFF); bb.put(red); bb.put(green); bb.put(blue); bb.put(alpha); } bb.flip(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, img.getWidth(), img.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, bb); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); return tex; }
f75b8516-c3e8-46e2-a6ad-4e90e999a44c
6
protected boolean inserirElemento(int x) { NoB elem = busca(raiz,x); NoB novaPagina; NoB temp; if (elem == null) { //caso seja o primeiro elemento inserido novaPagina = new NoB(x, null, null, null); raiz = new NoB(1, null, novaPagina, null); novaPagina.anterior = raiz; return(true); } else {//nao e o primeiro if (elem.chave == x) return false;//elemento ja existe na arvore else { novaPagina = new NoB(x, null, null, null); if (elem.chave < x) { //decide se irá inserir antes ou depois do nó retornado elem.proximo = novaPagina; novaPagina.anterior = elem; } else { temp = elem.anterior; temp.proximo = novaPagina; novaPagina.proximo = elem; elem.anterior = novaPagina; novaPagina.anterior = temp; } while (novaPagina != null && novaPagina.pagina != elem) { //em busca do cabecalho elem = novaPagina; novaPagina = novaPagina.anterior; } elem.chave = elem.chave + 1; //atualizacao do cabecalho if (elem.chave > MAX_CHAVES - 1) { cisaoArvoreB(elem); //caso estoure a página } return(true); } } }
4a37477f-62f2-4971-a3bd-2cf36f022fe1
2
public Symbol lookup(String name) throws SymbolNotFoundError { if (table.containsKey(name)) { return table.get(name); } if (parent != null) { return parent.lookup(name); } throw new SymbolNotFoundError(name); }
7e06768a-728c-4848-aeb2-652d28c61fb5
5
Expr phiRelatedFind(Expr a) { final ArrayList stack = new ArrayList(); while (a != null) { Object p = phiRelated.get(a); if ((p == a) || (p == null)) { // Path compression. final Iterator iter = stack.iterator(); while (iter.hasNext()) { p = iter.next(); if (p != a) { phiRelated.put(p, a); } } return a; } stack.add(a); a = (Expr) p; } return null; }
a022365b-3aca-4133-9888-016a879434c8
0
public void dragg(Excel start, Excel finish) { }
9f0cdd04-14fb-4f8e-b371-12614fead811
9
public Object getValueAt(int row, int col) { File f = uploads.get(row).getF(); String uploadName = uploads.get(row).uploadName; int pos = uploadName.lastIndexOf("."); if (pos != -1) uploadName = uploadName.substring(0, uploadName .lastIndexOf(".")); if (col == 0) { if (uploads.get(row).getF().isDirectory()) return folderIcon; if (uploads.get(row).getF().isFile()) return fileIcon; } if (col == 1) { return uploads.get(row).getF().getName(); } if (col == 2) { return uploads.get(row).getF().getPath(); } if (col == 3) return transSize(CaculateFileSize(uploads.get(row).getF())); if (col == 4) return uploadName; if (col == 5) return delIcon; return null; }
bae81cbe-59a3-48a7-8e75-000e15aac6c3
9
private boolean doList(ICommand cmd) throws Exception { if (cmd.getSubCommand().equals(CmdConstants.SubCmdNames.CLASS) || cmd.getSubCommand().matches(CmdConstants.SubCmdNames.INTERFACE)) { long id = IdManager.getInstance().accessIdWithKey(cmd.getFlagValue(CmdConstants.Flags.OBJECT)); System.out.println(isc.listObject(id)); return true; } if (cmd.getSubCommand().equals(CmdConstants.SubCmdNames.DESIGN)) { System.out.println(isc.listDesign()); return true; } if (cmd.getSubCommand().equals(CmdConstants.SubCmdNames.CACHE)) { // get ID long id = Long.parseLong(cmd.getFlagValue(CmdConstants.Flags.ID)); String type = cmd.getFlagValue(CmdConstants.Flags.TYPE); if (type == null) { System.out.println("Please specify a type"); return false; } String listable = ""; switch (type.toUpperCase()) { case "METHOD": listable = isc.listCachedMethod(id); break; case "VARIABLE": case "INSTANCE": listable = isc.listCachedVariable(id); break; case "MODIFIER": listable = isc.listCachedModifierSet(id); break; default: System.out.println("Unknown type given"); return false; } System.out.println(listable); return true; } else return false; }
120a8266-3d2a-47a9-bde8-619f6d8ebcde
4
private Govt switchGov(int i) { switch (i) { case 0: return Govt.PROT; case 1: return Govt.DEMO; case 2: return Govt.DICT; case 3: return Govt.AUTH; } return null; }
ee25c29b-0504-41fd-bd68-e48676765173
1
protected void distributeFileChangeEvent(FileChangeEvent event) { Iterator it = fileListeners.iterator(); while (it.hasNext()) { FileChangeListener listener = (FileChangeListener) it.next(); listener.fileChanged(event); } }
62d367c9-62fe-4939-ac29-cc2915d5a1e0
4
private void parseAdditionalPropertiesFile(File pPropertiesFile) throws ExManifestBuilder { Logger.logDebug("Reading additional properties file " + pPropertiesFile.getName()); ManifestParser lParser = new ManifestParser(pPropertiesFile); try { lParser.parse(); } catch(Throwable th){ throw new ExManifestBuilder("Failed to read additional properties file", th); } for(ManifestEntry lEntry : lParser.getManifestEntryList()){ if(lEntry.isAugmentation()){ if(!"".equals(lEntry.getLoaderName())){ throw new ExManifestBuilder("Error in entry for " + lEntry.getFilePath() + ". Loader names cannot be specified in the additional properties file"); } mAddtionalPropertiesMap.put(lEntry.getFilePath(), lEntry); } else { throw new ExManifestBuilder("Only augmentation entries can be specified in the additional properties file"); } } }
c82e9956-c9e7-4141-b613-4bf3d79a07de
3
private Map<String, Long> retrieveFilePathMap(VDK1FileInfo vdkFileInfo) { Map<String, Long> filePathMap = new HashMap<String, Long>(); long currentOffset = vdkFileInfo.getSize() + VDK1FilePattern.getRootLength() + VDK1FilePattern.getFileListHeaderLength(); long endOfFileList = vdkFileInfo.getSize() + VDK1FilePattern.getRootLength() + vdkFileInfo.getFileListPartLength(); try { VDKRandomAccessFile raf = new VDKRandomAccessFile(vdkFilePath, "r"); while(currentOffset < endOfFileList) { //System.out.println(raf.readUnsignedInt(currentOffset, VDK1FilePattern.FILE_OFFSET) + ": " + raf.readString(currentOffset, VDK1FilePattern.FILE_PATH)); filePathMap.put( raf.readString(currentOffset, VDK1FilePattern.FILE_PATH), raf.readUnsignedInt(currentOffset, VDK1FilePattern.FILE_OFFSET) ); currentOffset += VDK1FilePattern.getPathNameBlockLength(); } raf.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return filePathMap; }
e3689b8e-495e-4c91-b291-58512db754a2
2
public Digraph reverse() { Digraph R = new Digraph(V); for (int v = 0; v < V; v++) { for (int w : adj(v)) { R.addEdge(w, v); } } return R; }
55d38cf3-ac0e-459f-969f-4846951349f1
3
public void freeResult(ResultSet result) { try { if (result != null) { result.close(); result = null; } if (m_statement != null) { Connection connection = m_statement.getConnection(); m_statement.close(); connection.close(); m_statement = null; connection = null; } } catch(SQLException e) { e.printStackTrace(); } }
943883b9-5b83-4bd9-a4e9-5c3782842f02
6
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed int targetLayer; try{ //throws NumberFormatException if not a Number. targetLayer = Integer.parseInt(whichLayerTextField.getText())-1; //throws NullPointerException if Network has not been initialized. if (targetLayer < myNetwork.getLayerCount() && targetLayer >= 0 && myNetwork.howManyInLayer(targetLayer)>0){ int whereTo; //We never shrink the column size so we can just remove the NeuronButton and add a label to the end of the row whereTo = gridPanelLayout.getColumns()*targetLayer-1 + myNetwork.howManyInLayer(targetLayer); gridPanel.remove(whereTo); whereTo = gridPanelLayout.getColumns()*targetLayer-1 + gridPanelLayout.getColumns(); gridPanel.add(new JLabel(""),whereTo); gridPanel.setVisible(false); gridPanel.setVisible(true); myNetwork.removeNeuron(targetLayer); } else { if(myNetwork.howManyInLayer(targetLayer)==0){ JOptionPane.showMessageDialog(this, "There are no Neurons to remove!"); } else{ JOptionPane.showMessageDialog(this, "The layer can only be between 1 and " + (myNetwork.getLayerCount())); } } //NeuronButton geladen = (NeuronButton) gridPanel.getComponent(4); //geladen.setEnabled(false); } catch (NumberFormatException e){ JOptionPane.showMessageDialog(this, whichLayerTextField.getText() + " is not a valid layer"); } catch(NullPointerException e){ JOptionPane.showMessageDialog(this, "Please setup a Network first."); } }//GEN-LAST:event_removeButtonActionPerformed
ba08f492-601a-41fb-a3dc-f66ecf14a341
1
private static void makeSureFilesExist(String makeFileWithName) { File newFile = new File(makeFileWithName); try { newFile.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
aea97617-de9e-4ac6-b10b-e6135f5361db
1
@Override public void add(Users element) { //Добавляем запись в список getList().add(element); //2 способ добавления новой записи try { PreparedStatement statement = getConnection().prepareStatement(insertQuery); //Устанавливаем параметры statement.setString(1, element.getUserName()); statement.setString(2, element.getUserPsw()); statement.setInt(3, element.getUserState()); statement.setInt(4, element.getUserTypeId()); //Выполняем добавление записи statement.executeUpdate(); } catch(SQLException exc){ System.out.println("Ошибка при изменении таблицы"); } }
19c854c2-1500-40fa-943d-9a12d6712258
4
public static void moviesToFile(String infilename, String outfilename) { File file = new File(outfilename); List<Movie> list = readData(infilename); FileWriter fw = null; try { fw = new FileWriter(file); for (Movie m : list) { fw.append(m.toString()); } fw.flush(); } catch (IOException e) { e.printStackTrace(); } finally { if (fw != null) { try { fw.close(); } catch (IOException e) { e.printStackTrace(); } } } }
a58f3e08-4733-4585-a7c4-f82b6e5022c5
2
@Override public int hashCode() { int hash = 7; hash = 31 * hash + (this.id != null ? this.id.hashCode() : 0); hash = 31 * hash + (this.seq != null ? this.seq.hashCode() : 0); return hash; }
68ad593b-3528-439c-8928-76176a0b3354
2
private static void firstStrategy() { Semaphore MReading = new Semaphore(1); Semaphore MWriting = new Semaphore(1); int counter = 0; Random r = new Random(); while(true) { if(r.nextDouble() > 0.5) { Lecteur l = new Lecteur(MReading,MWriting,counter); l.run(); counter = l.counter; } else new Redacteur(MWriting).run(); System.out.println("----->Counter : " + counter); } }
e05643cc-ae33-4c2d-a57c-611fda902ae5
0
public void setGroupName(String gName){ this.groupName = gName; }
50d828bf-e2c7-4405-b64d-5fa9296f2590
3
private void botonAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAceptarActionPerformed int fila = tabla.getSelectedRow(); int columna = tabla.getSelectedColumn(); if(fila == -1 || columna == -1){ JOptionPane.showMessageDialog(this, "Debe seleccionar una colección"); }else{ if(tabla.getValueAt(fila,columna) == ""){ JOptionPane.showMessageDialog(this, "Debe seleccionar una colección"); }else{ Ejecutable.getControl().getGui().getIdColeccion().setText((String)tabla.getValueAt(fila,0)); Ejecutable.getControl().getGui().setVisible(true); this.dispose(); } } }//GEN-LAST:event_botonAceptarActionPerformed
1c837a06-9a58-4523-aa35-34e6f70effc8
4
public void fireSubLWorkerStartedEvent(SubLWorkerEvent event) { if (event.getEventType() != SubLWorkerEvent.STARTING_EVENT_TYPE) { throw new RuntimeException("Got bad event type; " + event.getEventType().getName()); } setId(event.getId()); synchronized(listeners) { Object[] curListeners = listeners.getListenerList(); for (int i = curListeners.length-2; i >= 0; i -= 2) { if (curListeners[i] == listenerClass) { try { ((SubLWorkerListener)curListeners[i+1]).notifySubLWorkerStarted(event); } catch (Exception e) { Logger.getLogger(this.getClass().toString()).log(Level.WARNING, e.getMessage(), e); } } } } }
a361797e-198e-4124-b061-c9f13fa50081
1
public long[] nextLongs(int n) throws IOException { long[] res = new long[n]; for (int i = 0; i < n; ++i) { res[i] = nextLong(); } return res; }
b969dd12-314b-415a-b359-b43db0cd21b5
5
@SuppressWarnings("serial") public javax.swing.table.DefaultTableModel readModelScores(){ @SuppressWarnings("unused") String id; String name; Integer score; javax.swing.table.DefaultTableModel model = new javax.swing.table.DefaultTableModel(){ @Override public Class<?> getColumnClass(int columnIndex) { switch (columnIndex){ case 0: return String.class; case 1: return Integer.class; default: return String.class; } } }; model.addColumn("User"); model.addColumn("Score"); try{ Scanner usersFile = new Scanner(new FileReader("users.txt")); while(usersFile.hasNext()){ Vector<Object> usr = new Vector<Object>(); id = usersFile.next(); name = usersFile.next(); score = Integer.parseInt( usersFile.next() ); usr.add(name); usr.add(score); model.addRow(usr); } usersFile.close(); }catch (IOException e){ e.getStackTrace(); } return model; }
76b992c2-4e57-43a2-9abd-17dfba49b037
1
private boolean jj_2_32(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_32(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(31, xla); } }
3f474250-6e74-46a4-bfe9-27872a1ec245
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Connection)) { return false; } Connection other = (Connection) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; }
c2abe1f4-4d79-4e2d-a755-0ab6f4c96189
1
private void displayLast() { try { refresh(ekd.last()); } catch (NoEmailKontaktFoundException e) { refresh(null); e.printStackTrace(); } }
0fe8e249-4b39-4116-b992-16a30a643fa7
4
@Override public void nodeCreated(ZVNode newNode) { boolean updateView = false; if (nodes != null) { for (int i = 0; i < nodes.length; i++) { if ((nodes[i] == newNode)) { updateView = true; } } } if (updateView) { updateView(); } }
09346cb2-3363-4ad2-ac62-765acd4cfd2e
9
public static double cos(double x) { int quadrant = 0; /* Take absolute value of the input */ double xa = x; if (x < 0) { xa = -xa; } if (xa != xa || xa == Double.POSITIVE_INFINITY) { return Double.NaN; } /* Perform any argument reduction */ double xb = 0; if (xa > 3294198.0) { // PI * (2**20) // Argument too big for CodyWaite reduction. Must use // PayneHanek. double reduceResults[] = new double[3]; reducePayneHanek(xa, reduceResults); quadrant = ((int) reduceResults[0]) & 3; xa = reduceResults[1]; xb = reduceResults[2]; } else if (xa > 1.5707963267948966) { final CodyWaite cw = new CodyWaite(xa); quadrant = cw.getK() & 3; xa = cw.getRemA(); xb = cw.getRemB(); } //if (negative) // quadrant = (quadrant + 2) % 4; switch (quadrant) { case 0: return cosQ(xa, xb); case 1: return -sinQ(xa, xb); case 2: return -cosQ(xa, xb); case 3: return sinQ(xa, xb); default: return Double.NaN; } }
3ebd2715-3b2a-47a4-80c8-f728214e6534
1
public void visit_monitorexit(final Instruction inst) { stackHeight -= 1; if (stackHeight < minStackHeight) { minStackHeight = stackHeight; } }
be37cdb4-3c01-4059-b4e5-ddadb2ce54f2
7
private byte[] calculateGeneralEncryptionKey( byte[] userPassword, byte[] firstDocIdValue, int keyBitLength, int revision, byte[] oValue, int pValue, boolean encryptMetadata) throws GeneralSecurityException { // Algorithm 3.2: Computing an encryption key // Step 1: Pad or truncate the password string to exactly 32 bytes... final byte[] paddedPassword = padPassword(userPassword); // Step 2: Initialize the MD5 hash function and pass the result of step // 1 as input to this function. MessageDigest md5 = createMD5Digest(); md5.reset(); md5.update(paddedPassword); // Step 3: Pass the value of the encryption dictionary’s O entry to the // MD5 hash function. (Algorithm 3.3 shows how the O value is computed.) md5.update(oValue); // Step 4: Treat the value of the P entry as an unsigned 4-byte integer // and pass these bytes to the MD5 hash function, low-order byte first md5.update((byte) (pValue & 0xFF)); md5.update((byte) ((pValue >> 8) & 0xFF)); md5.update((byte) ((pValue >> 16) & 0xFF)); md5.update((byte) (pValue >> 24)); // Step 5: Pass the first element of the file’s file identifier array // (the value of the ID entry in the document’s trailer dictionary; see // Table 3.13 on page 97) to the MD5 hash function. (See implementation // note 26 in Appendix H.) if (firstDocIdValue != null) { md5.update(firstDocIdValue); } // Step 6: (Revision 4 or greater) If document metadata is not being // encrypted, pass 4 bytes with the value 0xFFFFFFFF to the MD5 hash // function if (revision >= 4 && !encryptMetadata) { for (int i = 0; i < 4; ++i) { md5.update((byte) 0xFF); } } // Step 7: finish the hash byte[] hash = md5.digest(); final int keyLen = revision == 2 ? 5 : (keyBitLength / 8); final byte[] key = new byte[keyLen]; // Step 8: (Revision 3 or greater) Do the following 50 times: Take the // output from the previous MD5 hash and pass the first n bytes of the // output as input into a new MD5 hash, where n is the number of bytes // of the encryption key as defined by the value of the encryption // dictionary’s Length entry if (revision >= 3) { for (int i = 0; i < 50; ++i) { md5.update(hash, 0, key.length); digestTo(md5, hash); } } // Set the encryption key to the first n bytes of the output from the // final MD5 hash, where n is always 5 for revision 2 but, for revision // 3 or greater, depends on the value of the encryption dictionary’s // Length entry. System.arraycopy(hash, 0, key, 0, key.length); return key; }
1a8f109e-2682-4719-9ef9-64fc2582ee6b
0
public void addTimer(The5zigModTimer timer) { timers.add(timer); }
dde91ef6-0ca7-4a6d-991f-1282d51fde5f
1
public boolean distance(int y, int x, int[][] image){ int red = (image[y][x] >> 16) & 0xff; int blue = (image[y][x] >> 8) & 0xff; int green = (image[y][x]) & 0xff; double dfb = Math.sqrt(Math.pow(red - 0, 2) + Math.pow(green - 0, 2) + Math.pow(blue - 0, 2)); double dfw = Math.sqrt(Math.pow(red - 255, 2) + Math.pow(green - 255, 2) + Math.pow(blue - 255, 2)); if(dfb > dfw){ return false; } else{ return true; } }
8e00b983-96f2-4524-be98-33830407d099
4
public void tsumo(String win, int hou, int han) { Player winner = players[position(win)]; finalizeriichi(winner); int value = handvalue(hou, han); if (players[dealer] == winner) value = 2 * value; for (int i = 0; i < players.length; i++) { if (i == dealer) take(winner, players[i], 2 * value + 100 * bonus,false); else take(winner, players[i], value + 100 * bonus,false); } if (players[dealer] == winner) bonus++; else { bonus = 0; nexthand(); } update(); printnextround(); }
1a48c6ec-7225-4d4f-bf71-af2e0ba74aa7
8
@Override public void run(int interfaceId, int componentId) { switch(stage) { case -1: stage = 0; sendOptionsDialogue(SEND_DEFAULT_OPTIONS_TITLE, "No - toys are for kids.", "Let's have a look, then.", "Ohh, goody-goody - toys!", "Why do you sell most rune armour but not platebodies?"); break; case 0: switch(componentId) { case 1: stage = -2; sendPlayerDialogue(9827, "No - toys are for kids."); break; case 2: ShopsHandler.openShop(player, 12); end(); break; case 3: stage = 1; sendPlayerDialogue(9827, "Ohh, goody-goody - toys!"); break; case 4: stage = 2; sendPlayerDialogue(9827, "Why do you sell most rune armour but not platebodies?"); break; default: end(); break; } break; case 1: ShopsHandler.openShop(player, 12); end(); break; case 2: stage = -2; sendNPCDialogue(npcId, 9827, "Oh, you have to complete a special quest in order to wear", "rune platebodies. You should talk to the guild master", "downstairs about that."); break; default: end(); break; } }
fec48723-9ff7-43a4-877d-e6e8a6e559dc
4
public static void replaceFlower(OneFlower o) { Random random = new Random(); int x = random.nextInt(12); int y = random.nextInt(12); if ((x == o.x && y == o.y) || (x == o.fx && y == o.fy)) { replaceFlower(o); return; } o.fx = x; o.fy = y; o.msFlower = System.currentTimeMillis(); }
953354e1-3370-4c8c-9ef4-16278c5386af
5
public void go() { while ( !isOver() ) { attack(); //Attacks happen first try { //wait Thread.sleep(500); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } showHp(); //HP is shown if ( isOver() ) {break;}; //Game over if player dies/monsters die try { Thread.sleep(500); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } bPrompt(); //Ask player for their next move try { Thread.sleep(500); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } enemyGo(); //Enemies attack } }
be88ba67-4cca-4639-bafe-6219ef23442d
8
@Override public void run() { try { report ("download job started", 1); if (!forceDownload) if (page.loadFromCache()) report("read from cache", 1); else report("cache reading failed", 1); if (page.updateFromNet(this) || forceDownload) { page.saveToCache(); report("download finished", 1); //note: this iterator does not require locking because of CopyOnWriteArrayList implementation for (AbstractPage child: page.childPages) jobMaster.submit(new UpdatePageJob(child, jobMaster, forceDownload)); } else { report("up to date", 1); // even if all children are "up to date" too, still need to run the jobs - for the grand-children and etc. // since cache checks are cheap, better err on a cautious side. for (AbstractPage child: page.childPages) jobMaster.submit(new GetPageJob(child, jobMaster)); } //saving pre-check for faster visual; CheckSavingJob checkJob = new CheckSavingJob(page, jobMaster, false); checkJob.run(); } catch (ProblemsReadingDocumentException e) { report("download failed", 1); // TODO: incur more error handling, job resubmitting and such } catch (InterruptedException e) { } }
06fba072-79a8-4e27-b906-aabecebc6d1c
3
public List<String> getUsersHavingStatus(String sellerName, String status, String serviceName) { List<String> usersWithStatus = new ArrayList<String>(); HashMap<String, String> usersService = this.matchingUsers .get(serviceName); String userName; String currentStatus; Set<String> userNames = usersService.keySet(); Iterator<String> userNamesIt = userNames.iterator(); while (userNamesIt.hasNext()) { userName = userNamesIt.next(); currentStatus = usersService.get(userName); if (!userName.equals(sellerName) && currentStatus.equals(status)) { usersWithStatus.add(userName); } } return usersWithStatus; }
db9d500f-9531-4c7e-8c8f-1754426f1c8d
2
private void calculateEnabledState(JoeTree tree) { if (tree.getComponentFocus() == OutlineLayoutManager.ICON) { setEnabled(true); } else { if (tree.getCursorPosition() == tree.getCursorMarkPosition()) { setEnabled(false); } else { setEnabled(true); } } }
74700a27-e1bb-4ae2-ae93-f3cbf80fe2cf
1
public static void main(String[] args) { try{ Collection c = new ArrayList(); Cardinality("hello", null); System.out.println(total); } catch(Exception e){ System.out.println("0"); } }
bfa5650d-dead-4cfd-962a-1b974966cfcc
8
public static String decrypt(String code,BigInteger n, BigInteger d) { String t=new String(""); String binary[]=new String[1000000],msg1=new String(""); BigInteger decry[]=new BigInteger[1000000]; BigInteger encry[]=new BigInteger[1000000]; int j=-1; for(int i=0;i<code.length();i++) {if(i%4==0) {j++;binary[j]="";} t=Long.toBinaryString((long)(code.charAt(i))); for(int k=t.length();k<8;k++) t="0"+t; binary[j]=binary[j]+t; } // System.out.println("j is"+j); for(int i=0;i<=j;i++) { int a=5; if(binary[i].equals("")) break; //System.out.println("Binary is::"+binary[i]); BigInteger t1=new BigInteger(binary[i],10); encry[i]=toDecimal(t1); decry[i]=encry[i].modPow(d,n); //System.out.println("hee hee"+encry[i]+"\t\t"+decry[i]); binary[i]=Long.toBinaryString(decry[i].longValue()); for(int pp=binary[i].length();pp<32;pp++) binary[i]="0"+binary[i]; //System.out.println("Binary is:"+binary[i]); for(int k=0;k<25;k+=8) { if(binary[i].substring(k,k+8).equals("00000000")) continue; msg1+=(char)Integer.parseInt(binary[i].substring(k, k+8),2); } //System.out.println("whoosh::::"+msg); } return msg1; }
e5dc2bca-bf81-4841-959e-cd820242a506
7
protected final void appendLabelAndStereotype(IEntity entity, final StringBuilder sb, boolean classes) { final Stereotype stereotype = getStereotype(entity); final String stereo = entity.getStereotype() == null ? null : entity.getStereotype().getLabel(); if (isThereLabel(stereotype)) { sb.append("<BR ALIGN=\"LEFT\"/>"); for (String st : stereotype.getLabels()) { sb.append(manageHtmlIB(st, classes ? FontParam.CLASS_STEREOTYPE : FontParam.OBJECT_STEREOTYPE, stereo)); sb.append("<BR/>"); } } String display = StringUtils.getMergedLines(entity.getDisplay2()); final boolean italic = entity.getType() == EntityType.ABSTRACT_CLASS || entity.getType() == EntityType.INTERFACE; if (italic) { display = "<i>" + display; } sb.append(manageHtmlIB(display, classes ? FontParam.CLASS : FontParam.OBJECT, stereo)); }
c0727234-b53f-47db-ba38-dd670a12ebe5
5
public static String[] parse(String line) { boolean insideQuote = false; ArrayList<String> result = new ArrayList<String>(); int quoteCount = 0; StringBuilder sb = new StringBuilder(); for(int i = 0; i < line.length(); i++) { char c = line.charAt(i); if(c == QUOTE) { insideQuote = !insideQuote; quoteCount++; } if(c == COMMA && !insideQuote) { String value = sb.toString(); value = unQuoteUnEscape(value); result.add(value); sb = new StringBuilder(); continue; } sb.append(c); } result.add(sb.toString()); // Validate if (quoteCount % 2 != 0) { return new String[0]; } return result.toArray(new String[result.size()]); }
d31c4c35-712f-4884-8117-5729dce584d1
3
public synchronized void broadcastChatEventToClients(ChatEvent chatEvent) { ObjectOutputStream currentObjectOutputStream; for (ClientConnection clientConnection : clientConnections) { if (!clientConnection.getUser().getUsername().equals(chatEvent.getFrom().getUsername())) { currentObjectOutputStream = clientConnection.getObjectOutputStream(); try { currentObjectOutputStream.reset(); currentObjectOutputStream.writeObject(chatEvent); } catch (IOException e) { e.printStackTrace(); } } } }
e4998dfd-7921-4dc6-8ba2-63a6163bcf2b
3
public BufferedImage getCaptchaImage(String captchaStr, int width, int height) { BufferedImage retBufImage = null; Graphics graphicsLine = null; Graphics captchaImg = null; BufferedImage bufferImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); try { graphicsLine = bufferImg.getGraphics(); graphicsLine.setColor(new Color(Integer.parseInt("c0c0c0", 16))); graphicsLine.fillRect(0, 0, width, width); graphicsLine .setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 30)); graphicsLine.setColor(Color.GRAY); drawRandomLine(graphicsLine, 16); drawMessage(graphicsLine, captchaStr); ImageProducer source = bufferImg.getSource(); ImageProducer producer = new FilteredImageSource(source, this); Image filteredImg = Toolkit.getDefaultToolkit().createImage( producer); retBufImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); captchaImg = retBufImage.getGraphics(); captchaImg.drawImage(filteredImg, 0, 0, null); } catch (RuntimeException e) { e.printStackTrace(); throw new RuntimeException(e); } finally { if (graphicsLine != null) graphicsLine.dispose(); if (captchaImg != null) captchaImg.dispose(); } return retBufImage; }
6a7d8ed4-efa2-47bf-badc-1a39b06e9843
6
public synchronized void mouseReleased(MouseEvent me) { xm = me.getX(); ym = me.getY(); onScreen = xm >= 0 && ym >= 0 && xm < canvas.getWidth() && ym < canvas.getHeight(); if (me.getButton() == MouseEvent.BUTTON1) mb0 = false; if (me.getButton() == MouseEvent.BUTTON3) mb1 = false; if (me.getButton() == MouseEvent.BUTTON2) mb2 = false; }
1842c4ee-7824-4713-a7c1-4ba5d40ebaf4
5
public static void addEmployee() { //todo: verify someone cannot enter a duplicate username. File f = new File("Employee.txt"); String choice = "y"; try { PrintWriter pw = new PrintWriter(new FileOutputStream(f, true)); while (choice.equalsIgnoreCase("y")) { System.out.print("Please enter the username you would like to add: "); String username = sc.nextLine().toUpperCase(); System.out.print("Please enter the password you would like to add: "); char[] password = sc.nextLine().toCharArray(); System.out.print("What is the access level? E for Employee or M for Manager "); String levelEntered = sc.nextLine(); String employeeLevel = null; boolean successful = false; while (!successful) { switch (levelEntered.toUpperCase()) { case "E": employeeLevel = e; successful = true; break; case "M": employeeLevel = m; successful = true; break; default: System.out.print("Please enter a valid access level. Employee or Manager "); levelEntered = sc.nextLine(); successful = false; } } em = new Employee(username, password, employeeLevel); //String choice = "y"; pw.write(em.getAccessLevel() + "\t"); pw.write(em.getUsername() + "\t"); pw.write(String.valueOf(em.getPassword()) + "\n"); System.out.print("Would you like to add another user? Y or N "); choice = sc.nextLine(); pw.close(); } } catch (FileNotFoundException e1) { e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
4375a8d2-4623-42a6-abbc-dd510d639e11
9
public void addOrInsert(T o) { int i = 0; boolean found = false; boolean empty = false; while (i < list.size() && !found && !empty) { if (o instanceof Yeast) { Yeast y = (Yeast) list.get(i); Yeast y2 = (Yeast) o; found = y.getName().equalsIgnoreCase(y2.getName()); // empty = y.getName().equals(""); } else if (o instanceof Fermentable) { Fermentable f = (Fermentable) list.get(i); Fermentable f2 = (Fermentable) o; found = f.getName().equalsIgnoreCase(f2.getName()); // empty = f.getName().equals(""); } else if (o instanceof Hop) { Hop h = (Hop) list.get(i); Hop h2 = (Hop) o; found = h.getName().equalsIgnoreCase(h2.getName()); // empty = h.getName().equals(""); } else if (o instanceof Style) { Style s = (Style) list.get(i); Style s2 = (Style) o; found = s.getName().equalsIgnoreCase(s2.getName()); // empty = s.getName().equals(""); } else if (o instanceof String) { String q = (String) list.get(i); String q2 = (String) o; found = q.equalsIgnoreCase(q2); empty = q.equals(""); } i++; } // if it's not found, add it to the list & select it, // otherwise, set the found index to the selected index if (!found) { Debug.print("removing dupe " + o.toString()); list.add(o); selected = o; } else { selected = list.get(i-1); } }
a338a018-35a3-481b-bb48-73b70e1ac0bf
6
@Override public int move(State state) { while (!mousePressed()) { // Wait for a mouse click } double x = mouseX(); double y = mouseY(); int r = (int)round((0.95 - y) / 0.1); int c = (int)round((x - 0.15) / 0.1); int result = PASS; if (r >= 0 && r < WIDTH && c >= 0 && c < WIDTH) { result = r * WIDTH + c; } while (mousePressed()) { // Wait for mouse release } return result; }
c6b41806-004e-4554-a5aa-d0790a6b301d
6
public void handleRecord(Record record){ log("[PrintAdapter] Record:"); if(record == null){ log(" null"); } else{ for(Property<?> property : record.getAllProperties()){ if(property == null){ log(" [null]"); } else{ if((printableFields == null) || printableFields.containsKey(property.getName())){ log(" [" + property.getName() + "=" + property.getValue() + "]"); } } } } super.handleRecord(record); }
1fedeb86-efde-414d-87c1-f9f7709acddb
4
public void useGravity(BlackHole bh) { calculateGravity(bh); if (x + r < bh.getX() + bh.getWidth() / 2) { vx += gravity; } if (x + r > bh.getX() + bh.getWidth() / 2) { vx -= gravity; } if (y + r < bh.getY() + bh.getHeight() / 2) { vy += gravity; } if (y + r > bh.getY() + bh.getHeight() / 2) { vy -= gravity; } }
3dd2ffc5-3b35-4feb-8192-30b78b29cd03
7
protected void validateField() throws Exception { // do some type checking here if (m_fieldDefs != null) { Attribute a = getFieldDef(m_fieldName); if (a == null) { throw new Exception("[FieldRef] Can't find field " + m_fieldName + " in the supplied field definitions"); } if ((m_opType == FieldMetaInfo.Optype.CATEGORICAL || m_opType == FieldMetaInfo.Optype.ORDINAL) && a.isNumeric()) { throw new IllegalArgumentException("[FieldRef] Optype is categorical/ordinal but matching " + "parameter in the field definitions is not!"); } if (m_opType == FieldMetaInfo.Optype.CONTINUOUS && a.isNominal()) { throw new IllegalArgumentException("[FieldRef] Optype is continuous but matching " + "parameter in the field definitions is not!"); } } }
b1c03f99-6e5f-4cda-a054-8a5942800c92
0
public OthelloBoardBinary board(){ return board; }
f0dbdae7-32fd-4bb0-8197-46b0d8315276
7
public void func_71852_a(World par1World, int par2, int par3, int par4, int par5, int par6) { boolean flag = (par6 & 4) == 4; boolean flag1 = (par6 & 8) == 8; if (flag || flag1) { func_72143_a(par1World, par2, par3, par4, 0, par6, false, -1, 0); } if (flag1) { par1World.notifyBlocksOfNeighborChange(par2, par3, par4, blockID); int i = par6 & 3; if (i == 3) { par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, blockID); } else if (i == 1) { par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, blockID); } else if (i == 0) { par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, blockID); } else if (i == 2) { par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, blockID); } } super.func_71852_a(par1World, par2, par3, par4, par5, par6); }
262ec0ff-6487-43f1-bc35-3199e4cab780
9
public static boolean sameSentence(Integer word1, Integer word2, String line) { String[] words = splitAndMaskWordsAroundNotLeavePunctuation(line); Integer start = word1 < word2 ? word1: word2; Integer end = word1 < word2 ? word2: word1; for (int i=start; i < end; i++) { if (words[i].contains(".") || words[i].contains("?") || words[i].contains("!") || words[i].contains(",") || words[i].contains(";") || words[i].contains(":")) return false; } return true; }
a569b794-f544-4460-af11-4bfb2c7e7796
2
private static void saveSettings(){ SettingsModel.setUserName(nameField.getText()); SettingsModel.setFullscreen(fullscreen.isSelected()); Locale [] l = model.save.SettingsModel.getAllLocales(); for(int a=0; a<l.length; a++){ if (l[a].getDisplayLanguage(l[a]).equalsIgnoreCase(language.getSelectedItem().toString())){ SettingsModel.setLocale(l[a]); } } SettingsModel.save(); }
8cd3919f-b713-4b15-97ce-af91810389c8
6
public String get(int n) { if (capitalword_) return null; int len = grams_.length(); if (n < 1 || n > 3 || len < n) return null; if (n == 1) { char ch = grams_.charAt(len - 1); if (ch == ' ') return null; return Character.toString(ch); } else { return grams_.substring(len - n, len); } }
0fbcd733-d64d-4546-8f5f-2ade9a9d8157
4
public boolean add(Item it) { if (it == null) { return false; } for (Item i : items) { if (i.getClass().isInstance(it)) { i.add(it.amount()); return true; } } if (items.size() + 1 < maxitems) { items.add(it); return true; } return false; }
0b138c5d-4aef-4179-b4f5-b29075ab03fc
6
private void changeStat(Button b, boolean plus) { if (plus && (valuables > 0)) { for (String s : plusButtonMap.keySet()) { if (plusButtonMap.get(s).equals(b)) { supplyMap.put(s, supplyMap.get(s) + buyAmtMap.get(s)); valuables -= supplyCost; supplyTextboxMap.get(s).setText(s + ": " + supplyMap.get(s) + "\nCost: " + supplyCost); } } } else { for (String s : minusButtonMap.keySet()) { if (minusButtonMap.get(s).equals(b)) { supplyMap.put(s, supplyMap.get(s) - buyAmtMap.get(s)); valuables += supplyCost; supplyTextboxMap.get(s).setText(s + ": " + supplyMap.get(s) + "\nCost: " + supplyCost); } } } }
36c0aea8-0594-4f1b-b4e2-aa63cbe4ed8a
2
static String java_home() { String jh = System.getProperty("jh"); if (jh != null) { return jh; } jh = System.getenv("JAVA_HOME"); if (jh != null) { return jh; } return System.getProperty("java.home"); }
1ca62bd5-5c75-4599-9258-9f8a5f5d1de8
4
@Override public void run() { if (ctx.skillingInterface.getCategory().equalsIgnoreCase("heat ingots")) { ctx.skillingInterface.start(); Condition.wait(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return !ctx.backpack.select().id(MakeSword.HEATED_INGOTS).isEmpty(); } }); } else { for (GameObject furnace : ctx.objects.select().id(FURNACE).nearest().first()) { if (ctx.camera.prepare(furnace) && furnace.interact("Smelt", "Furnace")) { Condition.wait(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return ctx.skillingInterface.opened(); } }); } } } }
43c607a2-59c1-4134-a943-3f80eb404297
0
public double getIntelligence() { return intelligence; }
7232c99e-ff63-49dc-a88f-0522283860fe
6
private boolean hasVariable(AlgebraicParticle a){ if(a instanceof Variable) return true; else if(a instanceof AlgebraicCollection){ AlgebraicCollection c = (AlgebraicCollection) a; for(int i = 0; i < c.length(); i++){ if(hasVariable(c.get(i))) return true; } return false; } else if(a instanceof Fraction){ Fraction f = (Fraction) a; return hasVariable(f.getTop()) || hasVariable(f.getBottom()); } else return false; }
a71dc8ff-f90a-4e24-b95c-d80331dc2d17
6
public void run(String[] args) throws Exception { if (args.length == 1) { Logger.log("Uso: " + getTemplate()); } else { String[] apdu = null; if (args.length == 2) { apdu = StringUtil.tokenize(args[1]); } else { apdu = new String[1]; apdu[0] = args[1]; } String commandApdu = Numbers.clearAPDUFormat(apdu[0]); if (Numbers.isHex(commandApdu)) { if (PCSCManager.getCard() != null && PCSCManager.getTerminal() != null) { if (apdu.length == 2) { PCSCManager.sendAPDU(apdu[0], apdu[1]); } else { PCSCManager.sendAPDU(commandApdu); } } else { Logger.log("Cartao inteligente nao conectado"); } } } }
cc30de98-71eb-43b4-b7d4-4c87ff734dcd
9
public String nextToken() throws JSONException { char c; char q; StringBuffer sb = new StringBuffer(); do { c = next(); } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; for (;;) { c = next(); if (c < ' ') { throw syntaxError("Unterminated string."); } if (c == q) { return sb.toString(); } sb.append(c); } } for (;;) { if (c == 0 || Character.isWhitespace(c)) { return sb.toString(); } sb.append(c); c = next(); } }
b3981c9b-ad99-40fe-b706-142385f8b0d9
9
public void prettyPrint(int ident, boolean putLeft, TreeSet<Integer> verticalLines, String repr) { if (right != null) if (putLeft) { right.prettyPrint(ident + 1, true, verticalLines, repr + "0"); } else { TreeSet<Integer> leftVerticalLines = new TreeSet<Integer>(verticalLines); leftVerticalLines.add(ident - 1); right.prettyPrint(ident + 1, true, leftVerticalLines, repr + "0"); } for (int i = 0; i < ident - 1; ++i) { if (verticalLines.contains(i)) { System.out.print("| "); } else { System.out.print(" "); } } if (ident >= 1) { System.out.print((putLeft ? "," : "'") + "---"); } System.out.println(number + "-" + weight + " " + (symbol != 0?symbol + " '" + repr + "'":"")); if (left != null) if (putLeft) { TreeSet<Integer> rightVerticalLines = new TreeSet<Integer>(verticalLines); rightVerticalLines.addAll(verticalLines); rightVerticalLines.add(ident - 1); left.prettyPrint(ident + 1, false, rightVerticalLines, repr + "1"); } else { left.prettyPrint(ident + 1, false, verticalLines, repr + "1"); } }
cfb527f5-b8ec-4fcd-bfd5-59b60b8e9dde
0
public Dimension getMaximumSize(JComponent c) { return getPreferredSize(c); }
6eea3a4b-abe7-43b5-b425-3b81ba6480c1
7
public Collection<SystemObject> getAllObjects( final Collection<ConfigurationArea> configurationAreas, final Collection<SystemObjectType> systemObjectTypes, ObjectTimeSpecification objectTimeSpecification) { // Liste, die alle ermittelten Objekte enthält final Collection<SystemObject> objects = new ArrayList<SystemObject>(); // alle Konfigurationsbereiche, die zu berücksichtigen sind, ermitteln final List<ConfigurationArea> areas; if(configurationAreas == null) { areas = new ArrayList<ConfigurationArea>(); ConfigurationAreaFile[] areaFiles = getConfigurationFileManager().getConfigurationAreas(); for(ConfigurationAreaFile areaFile : areaFiles) { ConfigurationArea area = (ConfigurationArea)getObject(areaFile.getConfigurationAreaInfo().getPid()); // nicht aktive Bereiche werden ignoriert if(area != null) { areas.add(area); } } } else { areas = new ArrayList<ConfigurationArea>(configurationAreas); } // alle Objekt-Typen, die zu betrachten sind, ermitteln - also auch die Typen, die die angegebenen Typen erweitern final Set<SystemObjectType> relevantObjectTypes = new HashSet<SystemObjectType>(); if(systemObjectTypes == null) { // es wurde keine Einschränkung der Typen gegeben -> alle Typen ermitteln // die Typen eines TypTyp-Objekts ermittelt man mit getElements()! relevantObjectTypes.add(getTypeTypeObject()); final List<SystemObject> typeTypeElements = getTypeTypeObject().getElements(); for(SystemObject typeTypeElement : typeTypeElements) { relevantObjectTypes.add((SystemObjectType)typeTypeElement); } } else { // die Typen eines Typ-Objekts werden über die Sub-Types ermittelt. for(SystemObjectType objectType : systemObjectTypes) { relevantObjectTypes.add(objectType); relevantObjectTypes.addAll(getAllSubTypes(objectType)); } } // Ermittlung der direkten Objekte der angegebenen Typen for(ConfigurationArea configurationArea : areas) { Collection<SystemObject> directObjects = configurationArea.getDirectObjects(relevantObjectTypes, objectTimeSpecification); objects.addAll(directObjects); } return objects; }
d45fd21b-1eda-41a0-909a-d0dc931a7eaf
0
public IntDataType createIntDataType() { return new IntDataType(); }
187d0119-0264-4028-a08b-8416f40cbb05
2
public void newGeneration(){ List<Chromo<T>> freshPop = new ArrayList<Chromo<T>>(size); freshPop.addAll(getElite()); while (freshPop.size() < size){ Chromo<T> offspring1 = rouletteSelection(); Chromo<T> offspring2 = rouletteSelection(); crossOver(offspring1, offspring2); freshPop.add(mutateGenes.apply(rand, offspring1)); if (freshPop.size() == size) break; freshPop.add(mutateGenes.apply(rand, offspring2)); } this.individuals = freshPop; setFitnessValues(); this.generation_num++; }
9849806a-ebab-46b6-8996-fc9349cc2e76
7
public List<Boolean> getBooleanList(String path) { List<?> list = getList(path); if (list == null) { return new ArrayList<Boolean>(0); } List<Boolean> result = new ArrayList<Boolean>(); for (Object object : list) { if (object instanceof Boolean) { result.add((Boolean) object); } else if (object instanceof String) { if (Boolean.TRUE.toString().equals(object)) { result.add(true); } else if (Boolean.FALSE.toString().equals(object)) { result.add(false); } } } return result; }
d0ce59fd-4665-4d53-a060-4d2ce3141689
9
@Override public boolean tick(Tickable ticking, int tickID) { if(!super.tick(ticking,tickID)) return false; if(!(affected instanceof MOB)) return true; final MOB M=(MOB)affected; if(M.location()!=null) { if((!M.getWorshipCharID().equals(godName)) &&(godName.length()>0)) { final Deity D=CMLib.map().getDeity(godName); if(M.getWorshipCharID().length()>0) { final Deity D2=CMLib.map().getDeity(M.getWorshipCharID()); if(D2!=null) { final CMMsg msg2=CMClass.getMsg(M,D2,this,CMMsg.MSG_REBUKE,null); if(M.location().okMessage(M,msg2)) M.location().send(M,msg2); } } final CMMsg msg2=CMClass.getMsg(M,D,this,CMMsg.MSG_SERVE,null); if(M.location().okMessage(M,msg2)) { M.location().send(M,msg2); M.setWorshipCharID(godName); } } } return true; }
0bd06228-2ba0-441a-9702-55dfaf0717e7
1
public KmeansCommand(CommandParameter par) { if(par == null) throw new NullPointerException("KmeansCommand has a null CommandParameter"); this.par= par; }
0d1d0580-6076-4b57-91e9-5ecabe40dd93
1
public static void main(String[] args) { GUI.init(); //Menus.MainMenu(); // Sleep to let the GUI build try { Thread.sleep(1000); } catch (InterruptedException e) {} intro(); }
4c706d4b-f371-40aa-a749-5e04d916e27e
0
private String readInput() throws IOException { return this.keyboard.readLine(); }
05fcc489-5ac1-4fd1-b031-93ee87dd7101
1
public void pause(String soundName) { Sound sound = sounds.get(soundName); if (sound != null) { sound.pause(); } }
e8115309-fc57-4d63-b9cf-5f84194b9469
7
public static Cons kifTwoArgumentForallToStellaForall(Cons tree, Cons declarations) { { Stella_Object sentence = Logic.kifSentenceToUntypedStellaSentence(tree.rest.rest.value); if (Stella_Object.safePrimaryType(sentence) == Logic.SGT_STELLA_CONS) { { Cons sentence000 = ((Cons)(sentence)); { GeneralizedSymbol testValue000 = ((GeneralizedSymbol)(sentence000.value)); if (testValue000 == Logic.SYM_STELLA_AND) { { Cons foralls = Stella.NIL; { Stella_Object conjunct = null; Cons iter000 = sentence000.rest; for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) { conjunct = iter000.value; foralls = Cons.cons(Cons.list$(Cons.cons(Logic.SYM_STELLA_FORALL, Cons.cons(Stella_Object.copyConsTree(tree.rest.value), Cons.cons(Cons.cons(conjunct, Stella.NIL), Stella.NIL)))), foralls); } } return (((Cons)(Logic.kifSentenceToUntypedStellaSentence(Cons.cons(Logic.SYM_STELLA_AND, foralls.concatenate(Stella.NIL, Stella.NIL)))))); } } else if (testValue000 == Logic.SYM_STELLA_OR) { { Stella_Object antecedent = Logic.kifInvertSentence(sentence000.rest.value); Stella_Object consequent = sentence000.rest.rest.value; return (Cons.list$(Cons.cons(Logic.SYM_STELLA_FORALL, Cons.cons(declarations, Cons.cons(Cons.cons(antecedent, Cons.cons(consequent, Stella.NIL)), Stella.NIL))))); } } else if (testValue000 == Logic.SYM_STELLA_FORALL) { { Stella_Object v = null; Cons iter001 = declarations; for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) { v = iter001.value; sentence000.secondSetter(Cons.cons(v, ((Cons)(sentence000.rest.value)))); } } return (sentence000); } else if (testValue000 == Logic.SYM_LOGIC_ABOUT) { return (Cons.list$(Cons.cons(Logic.SYM_LOGIC_ABOUT, Cons.cons(Logic.kifSentenceToUntypedStellaSentence(Cons.list$(Cons.cons(Logic.SYM_STELLA_FORALL, Cons.cons(declarations, Cons.cons(Cons.cons(sentence000.rest.value, Stella.NIL), Stella.NIL))))), Cons.cons(sentence000.rest.rest.concatenate(Stella.NIL, Stella.NIL), Stella.NIL))))); } else { } } } } else { } return (Cons.list$(Cons.cons(Logic.SYM_STELLA_FORALL, Cons.cons(declarations, Cons.cons(Cons.list$(Cons.cons(Logic.SYM_STELLA_TRUE, Cons.cons(sentence, Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL))))); } }
31501b05-3daf-4bfd-8bfa-58a66c07275d
7
public ShowGoSaveFileChooser(MainWindow mainWindow){ this.mainWindow = mainWindow; fc = new JFileChooser(new File(System.getProperty("user.dir"))) { private static final long serialVersionUID = 1L; @Override public void approveSelection() { File f = getSelectedFile(); if (!f.getName().endsWith(".showgo")) { f = new File(f.getParentFile(), f.getName() + ".showgo"); } if (f.exists() && getDialogType() == SAVE_DIALOG) { int result = JOptionPane.showConfirmDialog(this, "Die Datei \"" + f.getName() + "\" existiert bereits. Überschreiben?", "Datei existiert bereits", JOptionPane.YES_NO_CANCEL_OPTION); switch (result) { case JOptionPane.YES_OPTION: super.approveSelection(); return; case JOptionPane.NO_OPTION: return; case JOptionPane.CLOSED_OPTION: return; case JOptionPane.CANCEL_OPTION: cancelSelection(); return; } } super.approveSelection(); } }; fc.setDialogType(JFileChooser.SAVE_DIALOG); fc.setAcceptAllFileFilterUsed(false); fc.setSelectedFile(new File("Mein Theater")); FileFilter filter = new FileNameExtensionFilter("ShowGo-Datei", "showgo"); fc.addChoosableFileFilter(filter); }
688406af-4669-4c65-90a8-964907323d41
4
@Override public List<Cible> getCibles() throws BadResponseException { List<Cible> cibles = new ArrayList<Cible>(); JsonRepresentation representation = null; // R�cup�ration de la liste des messages Representation repr = serv.getResource("intervention/" + interId + "/cible", null); try { representation = new JsonRepresentation(repr); JSONArray ar = representation.getJsonArray(); for (int i = 0; i < ar.length(); i++) { cibles.add(new Cible(ar.getJSONObject(i))); } } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (InvalidJSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return cibles; }
8ed9793b-79ab-4339-b332-f080556a99e3
8
@Override public void update(GameContainer gc, int delta) { if(gc.getInput().isKeyDown(Input.KEY_W) && position.getY() > 0) { position.setY(position.getY() - (delta * MOVEMENT_MULTIPLIER)); } if(gc.getInput().isKeyDown(Input.KEY_A) && position.getX() > 0) { currentAnimation = birdLeft; position.setX(position.getX() - (delta * MOVEMENT_MULTIPLIER)); } if(gc.getInput().isKeyDown(Input.KEY_D) && position.getX() < 740) { //800 - width currentAnimation = birdRight; position.setX(position.getX() + (delta * MOVEMENT_MULTIPLIER)); } if(gc.getInput().isKeyDown(Input.KEY_S) && position.getY() < 560) { //600 - height position.setY(position.getY() + (delta * MOVEMENT_MULTIPLIER)); } /* disable gravity if(position.getY() < 560) { position.setY(position.getY() + (delta * MOVEMENT_MULTIPLIER)); //gravity }*/ }
5a2e9378-94e2-4f41-b853-c265da13ecf9
8
public static int Action(Client joueur) { int tempDette = 0; int choiceInt = -1; boolean wrong = true; boolean quit = true; do { System.out.println("Que voulez vous faire?" + "\n pour dormir tapez 1" + "\n pour appeler le room service tapez 2" + "\n pour partir tapez 3"); do { String choice = keyboard.nextLine(); try { choiceInt = Integer.parseInt(choice); if (choiceInt != 1 && choiceInt != 2 && choiceInt != 3) { throw new Exception("not 1, 2 or 3"); } wrong = false; } catch (Exception e) { System.out.println("Mauvaise valeur inseree"); } } while (wrong); switch (choiceInt) { case 1: dormir(joueur); break; case 2: tempDette += RoomService(joueur); break; default: quit = false; break; } } while (quit); return tempDette; }
82ca0648-c486-49b6-b2ee-755a8b05d718
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } Event other = (Event) obj; if (extendsProp == null) { if (other.extendsProp != null) { return false; } } else if (!extendsProp.equals(other.extendsProp)) { return false; } if (properties == null) { if (other.properties != null) { return false; } } else if (!properties.equals(other.properties)) { return false; } return true; }
e23af0ec-010d-46e2-9b89-349abb73ff5c
5
private void setBorder() { for (int i=TOP_AND_LEFT_BORDER_SIZE-1; i< SIZE_OF_MATRIX; i+=2) { for (int k=TOP_AND_LEFT_BORDER_SIZE-1; k< SIZE_OF_MATRIX; k++) { matrix[i][k] = BORDER_MATERIAL; } for (int k=TOP_AND_LEFT_BORDER_SIZE; k< SIZE_OF_MATRIX; k++) { matrix[k][i] = BORDER_MATERIAL; } } char topCoord = FIRST_TOP_COORD; for (int i=TOP_AND_LEFT_BORDER_SIZE; i< SIZE_OF_MATRIX; i+=2) { matrix[0][i] = topCoord; topCoord++; } char leftCoord = FIRST_LEFT_COORD; for (int i=TOP_AND_LEFT_BORDER_SIZE; i< SIZE_OF_MATRIX; i+=2) { matrix[i][0] = leftCoord; leftCoord++; } }