method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
83a7376a-8943-499f-acbd-3b9664c12539
8
@Override public Object esegui() throws ExtraTokenException, OperazioneNonValidaException, ParentesiParsingException, OperandoMissingException, ParsingException, OperatoreMissingException { VarRepository variabili = VarRepository.getInstance(); ArrayList<Token> lineaCodiceProvvisoria = (ArrayList<Token>)lineaCodice.clone(); for(int j=0;j<lineaCodiceProvvisoria.size();j++) if(lineaCodiceProvvisoria.get(j).ritornaTipoToken().equals(Tok.VARIABILE)) { String nome = (String)lineaCodiceProvvisoria.get(j).ritornaValore(); Token valoreVariabile = variabili.getVariabile(nome); if(!valoreVariabile.equals(null)) lineaCodiceProvvisoria.set(j, valoreVariabile); } if(lineaCodiceProvvisoria.size()==1) if(lineaCodiceProvvisoria.get(0).ritornaTipoToken().equals(Tok.STRINGA)) { valoreVariabile = lineaCodiceProvvisoria.get(0); variabili.setVariabile(nomeVariabile, valoreVariabile); return null; } if(Condizione.isExprMatematica(lineaCodiceProvvisoria)) { ExprMatematica em = new ExprMatematica(lineaCodiceProvvisoria); valoreVariabile = em.getRisultato(); } else if(Condizione.isExprBooleana(lineaCodiceProvvisoria)) { ExprBooleana eb = new ExprBooleana(lineaCodiceProvvisoria); valoreVariabile = eb.getRisultato(); } else if(Condizione.isConfronto(lineaCodiceProvvisoria)) { Condizione cond = new Condizione(lineaCodiceProvvisoria); valoreVariabile = cond.getRisultato(); } else throw new ParsingException(); variabili.setVariabile(nomeVariabile, valoreVariabile); return null; }
becfa525-d252-4f42-911b-1ac6935db9be
0
public DialogSettings() { super(); initComponents(); }
c9859de8-9d0b-40c4-9ec8-1c2fe31556bd
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(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new MenuPrincipal().setVisible(true); } }); }
d44854d3-7474-4f54-b3b5-123a867c8f1c
2
public void editStartURL() { JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(false); int result = fc.showOpenDialog(null); if (result != JFileChooser.APPROVE_OPTION) return; URL url = null; try { url = fc.getSelectedFile().toURI().toURL(); } catch (MalformedURLException e) { JOptionPane.showMessageDialog(null, e.getMessage()); return; } rootPage.setURL(url); rootPage.setContainsNames(true); rootPage.setContainsPages(false); }
5758cb0e-4441-4380-a215-6d7154c5d0f7
5
private void timeOut() { boolean timedOutBeforeConnecting = false; boolean timedOutAfterConnecting = false; synchronized(CONNECTION_LOCK) { if(isAttemptingToConnect) { logger.fine("Connection to " + serverAddress + ":" + serverPort + " timed out"); closeConnection(); timedOutBeforeConnecting = true; } else if(isConnected) { logger.fine("Connect request to " + serverAddress + ":" + serverPort + " timed out"); disconnectQuietly(); timedOutAfterConnecting = true; } //it should be impossible for timedOut() to get called if the // ClientConnection is neither connected nor attempting to connect, // but we'll check for both separately and not assume anything } //once again, exactly one of these could be true, but we're making sure // both don't get run and not assuming one not happening implies the // other happening if(listener != null) { if(timedOutBeforeConnecting) { listener.onCouldNotConnect(ClientConnection.CONNECT_REQUEST_TIMED_OUT); } else if(timedOutAfterConnecting) { listener.onDisconnected(ClientConnection.CONNECTION_TIMED_OUT); } } }
5febf144-3077-4cb6-9e8f-6229d1981fcf
8
public static void main( String[] argv ) throws IOException { BufferedReader reader = new BufferedReader( new FileReader( ITEM_KEYWORDS ) ); System.out.println( "Scanning for keyword array size" ); int linesComplete = 0; String line = reader.readLine(); while( line != null ) { StringTokenizer t = new StringTokenizer( line ); t.nextToken(); t.nextToken(); StringTokenizer keyTok = new StringTokenizer( t.nextToken(), ";" ); String keywordId = keyTok.nextToken(); while ( keyTok.hasMoreTokens() ) { Integer count = sWordMap.get( keywordId ); if ( count != null ) { sWordMap.put( keywordId, count + 1 ); } else { sWordMap.put( keywordId, 1 ); } keywordId = keyTok.nextToken(); } linesComplete++; System.out.printf( "\rProcessed %d lines", linesComplete ); line = reader.readLine(); } LinkedList<Entry<String,Integer>> top100 = new LinkedList<Entry<String,Integer>>(); for ( Entry<String,Integer> entry : sWordMap.entrySet() ) { if ( top100.isEmpty() ) { top100.add( entry ); } else if ( top100.size() < 100 ) { addAscending( top100, entry ); } else if ( entry.getValue() > top100.get( 0 ).getValue() ) { addAscending( top100, entry ); top100.removeFirst(); } } FileWriter writer = new FileWriter( "data/topKeywords.txt" ); for ( Entry<String,Integer> entry : top100 ) { writer.write( entry.getKey() ); writer.append( "\t" ); } writer.append( "\n" ); System.out.printf( "\n%d keywords found\n", sWordMap.size() ); reader.close(); writer.close(); }
a342782d-7881-4bb8-abf4-a90ea2ee6baf
6
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { AjaxRequest ajaxRequest = AjaxRequest.action(request); Player player = ajaxRequest.getPlayer(); Field field = ajaxRequest.getField(); String status = "true"; Integer amount = 0; TransactionTemplate transactionBuilder = null; if (field instanceof Payment) { if(player.getCash() > field.getAmount()) { amount = paymentCalculator.calculateAmount(field, null); } else { amount = player.getCash(); } transactionBuilder = new PlayerToMonopolyTransaction(); transactionBuilder.transact(player, player.getMonopoly(), amount); } else if (field instanceof Property) { Integer chargeAmount = propertyCalculator.calculateAmount(field, PaymentTypeEnum.Charge); if(player.getCash() > chargeAmount){ amount = chargeAmount; } else{ amount = player.getCash(); } Player owner = ((Property) field).getOwner(); if (owner != null) { transactionBuilder = new PlayerToPlayerTransaction(); transactionBuilder.transact(player, owner, amount); } else { transactionBuilder = new PlayerToMonopolyTransaction(); transactionBuilder.transact(player, player.getMonopoly(), amount); } } if(player.getCash() == 0){ status = "end"; } player.setLocation(field.getLocation()); SessionController.changePlayerInSession(request); response.sendRedirect("game.jsp?status="+status); }
32ad2c9a-4336-408e-9ca7-0133e23740a0
3
public boolean load(String audiofile) { try { setFilename(audiofile); sample = AudioSystem.getAudioInputStream(getURL(filename)); clip.open(sample); return true; } catch (IOException e) { return false; } catch (UnsupportedAudioFileException e) { return false; } catch (LineUnavailableException e) { return false; } }
fc031e6a-af8c-47d3-a3c4-3393c7d88541
9
public void handshake() throws Exception { String raw_message = ""; String[] token = new String[3]; generateHash(); while(true) { while(incoming.ready()) { raw_message = incoming.readLine(); token = raw_message.split(":"); if(token[0].equals("hash")) { sendHandshakeMessage("hash:" + serverInfo.hashID); serverInfo.remoteHash = token[1]; } else if(token[0].equals("username")) { sendHandshakeMessage("username:" + serverInfo.username); serverInfo.remoteUsername = token[1]; } else if(token[0].equals("ipaddress")) { sendHandshakeMessage("ipaddress:" + serverConnection.getInetAddress().toString()); serverInfo.remoteIP = token[1]; } else if(token[0].equals("port")) { sendHandshakeMessage("port:" + Integer.toString(serverConnection.getLocalPort())); serverInfo.remotePort = token[1]; } else break; } if(serverInfo.remoteUsername.length() != 0 && serverInfo.remoteIP.length() != 0 && serverInfo.remoteHash.length() != 0) { break; } } }
02fff640-e28b-4698-a8cc-d0238cd8c931
9
public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[58]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 31; 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; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 58; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.add(jj_expentry); } } jj_endpos = 0; jj_rescan_token(); jj_add_error_token(0, 0); 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); }
55f4f1c0-88ab-4cd4-94e4-1af4cec44416
3
@Override public void deserialize(Buffer buf) { msgType = buf.readByte(); if (msgType < 0) throw new RuntimeException("Forbidden value on msgType = " + msgType + ", it doesn't respect the following condition : msgType < 0"); msgId = buf.readShort(); if (msgId < 0) throw new RuntimeException("Forbidden value on msgId = " + msgId + ", it doesn't respect the following condition : msgId < 0"); int limit = buf.readUShort(); parameters = new String[limit]; for (int i = 0; i < limit; i++) { parameters[i] = buf.readString(); } }
ad487df7-81a2-4a1e-af80-3d4c74f1ea8a
3
public boolean notReadyToPlay() { detectLinesAndCols(); for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) if (matrixb[i][j]) return true; return false; }
650227ab-5407-4a23-a6d6-c332bb987b8e
2
public List<E> getAll() { List<E> clients = new ArrayList<E>(); try { ResultSet rs = select.executeQuery(); while(rs.next()){ clients.add(build(rs)); } } catch(Exception ex) { ex.printStackTrace(); } return clients; }
061defbc-9809-4916-a5ff-f98468844f05
1
protected Integer calcBPB_TotSec16() { byte[] bTemp = new byte[2]; for (int i = 19;i < 21; i++) { bTemp[i-19] = imageBytes[i]; } BPB_TotSec16 = byteArrayToInt(bTemp); System.out.println(BPB_TotSec16); return BPB_TotSec16; }
3f00306f-b2b1-425f-9112-679dcf04b145
5
public void populateCritter(int numCritters, Class<? extends Critter> critterType) { populationCounters.put(critterType, new Integer(numCritters)); for (int i = 0; i < numCritters; i++) { if (population == maxPopulation) { return; } try { addCritter(critterType.newInstance()); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
f905a4a6-1014-4809-bdb0-86012a0e34f2
2
private static final long[] evaluate(long[] data) { long[] evl = new long[smp.length]; for (int i = 0; i < smp.length; i++) { evl[i] = 1L; for (long j : data) evl[i] = PF.mul(evl[i], PF.sub(smp[i],j)); } return evl; }
c0f399ce-f4e2-49ba-ab62-a66f722c6a58
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(MainJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MainJFrame().setVisible(true); } }); }
3ef5b2cc-11d3-4da9-bd9a-d69dd1ffe6c2
6
public void makeDeclaration(Set done) { super.makeDeclaration(done); if (isConstructor() && !isStatic() && (Options.options & Options.OPTION_ANON) != 0) { ClassInfo clazz = getClassInfo(); InnerClassInfo outer = getOuterClassInfo(clazz); ClassAnalyzer clazzAna = methodAnalyzer.getClassAnalyzer(clazz); if (clazzAna != null && outer != null && outer.name == null) { /* * call makeDeclaration on the anonymous class, since _we_ will * declare the anonymous class. */ clazzAna.makeDeclaration(done); } } }
09739665-546c-41a4-ba26-b03535e45276
7
protected void readChild(XMLStreamReader in) throws XMLStreamException { Game game = getGame(); if (in.getLocalName().equals(IndianSettlement.MISSIONARY_TAG_NAME)) { in.nextTag(); // advance to the Unit tag missionary = updateFreeColGameObject(in, Unit.class); in.nextTag(); // close <missionary> tag } else if (in.getLocalName().equals(Resource.getXMLElementTagName())) { Resource resource = game.getFreeColGameObject(in.getAttributeValue(null, ID_ATTRIBUTE), Resource.class); if (resource != null) { resource.readFromXML(in); } else { resource = new Resource(game, in); } tileItems.add(resource); } else if (in.getLocalName().equals(LostCityRumour.getXMLElementTagName())) { LostCityRumour lostCityRumour = game.getFreeColGameObject(in.getAttributeValue(null, ID_ATTRIBUTE), LostCityRumour.class); if (lostCityRumour != null) { lostCityRumour.readFromXML(in); } else { lostCityRumour = new LostCityRumour(game, in); } tileItems.add(lostCityRumour); } else if (in.getLocalName().equals(TileImprovement.getXMLElementTagName())) { TileImprovement ti = game.getFreeColGameObject(in.getAttributeValue(null, ID_ATTRIBUTE), TileImprovement.class); if (ti != null) { ti.readFromXML(in); } else { ti = new TileImprovement(game, in); } tileItems.add(ti); } else { logger.warning("Unknown tag: " + in.getLocalName() + " loading PlayerExploredTile"); in.nextTag(); } }
e8614467-bf1e-414b-867a-4f750f79041b
5
public static void parse(final File file, final ConfigHandler handler) throws IOException, ParseException { final String raw = IOUtils.toString(new FileInputStream(file)); final JSONArray routes = (JSONArray) JSONValue.parseWithException(raw); for (Iterator<Object> iter= routes.iterator() ; iter.hasNext() ; ) { final JSONObject route = (JSONObject)iter.next(); final String remote_addr = route.get("remote_addr").toString(); final String name = route.get("name").toString(); final int listen_on = Integer.parseInt(route.get("listen_on").toString()); final String log_dir = route.get("log_dir").toString(); final JSONArray filters = (JSONArray)route.get("filters"); Properties[] configs = new Properties[]{}; if (filters != null && filters.size() > 0) { configs = new Properties[filters.size()]; for (int i = 0; i < filters.size(); ++i) { final JSONObject filter = (JSONObject) filters.get(i); configs[i] = new Properties(); for (Object k : filter.keySet()) { configs[i].setProperty((String) k, filter.get(k).toString()); } } } handler.config(name, remote_addr, listen_on, log_dir, configs); } }
eb735a47-538e-4132-b59a-bdd1cf000b8e
2
private void updateBuyButton() { if (Inventory.money >= amount && amount > 0) buyButton.setEnabled(true); else buyButton.setEnabled(false); }
747c02fb-e4a0-421e-839b-7ab2f6a722d9
4
public boolean addStore(OfflinePlayer player,Chest chest){ if(player==null || chest==null) return false; if(isStore(chest)) return false; if(isCoffer(chest)) return false; stores.put(chest, new Store(this,player,chest)); saveStores(); return true; }
e6fe5849-1d48-4112-ae1d-966093a7d8bf
9
public void ensureContainedTablesExist(ConnectionWrapper cw) throws SQLException, SchemaPermissionException { // a list of contained classes that must be added ArrayList<Class<?>> containedClasses = new ArrayList<Class<?>>(); if (this.clazz.isArray()) { if (!ObjectTools.isDatabasePrimitive(clazz.getComponentType())) { // make sure the component type exists containedClasses.add(clazz.getComponentType()); } } else { for (int x = 0; x < this.getPropertyCount(); x++) { if (this.isReferenceType(x)) { Class<?> returnType = returnTypes.get(x); containedClasses.add(returnType); } } } for (Class<?> c : containedClasses) { adapter.getPersist().getTableManager().ensureTableExists(c, cw); } }
acf7aff0-9cd6-4bc1-8002-184b6923aade
0
public int getBoilerState() { return this.boilerState; }
dd7b201e-7d1d-4504-90a4-af42a0ab24c5
6
public List<List<Card>> getSets(List<Card> cards) { List<Card> flushSet; List<Card> pairSet1; List<Card> pairSet2; List<Card> straitSet; List<List<Card>> pairSets; List<List<Card>> sets; sets = new ArrayList<>(); pairSets = Ranking.checkPairs(cards); straitSet = Ranking.checkStrait(cards); flushSet = Ranking.checkFlush(cards); pairSet1 = pairSets.get(0); pairSet2 = pairSets.get(1); if (flushSet != null) sets.add(flushSet); if (straitSet != null) sets.add(straitSet); if (pairSet1 != null) sets.add(pairSet1); if (pairSet2 != null) sets.add(pairSet2); if (sets.size() < 4) { for (int i=0; i<4; i++) { sets.add(null); } } return sets; }
5e3d93d2-9a0c-49db-8241-d279bdbbffa2
4
public boolean accept(File file){ if (file.isDirectory()){ return true; } else { String path = file.getAbsolutePath().toLowerCase(); for (int i = 0, n = extensions.length; i < n; i++) { String extension = extensions[i]; if ((path.endsWith(extension) && (path.charAt(path.length() - extension.length() - 1)) == '.')){ return true; } } } return false; }
64a68610-ee42-4ba3-a246-4b02c2e6e9d2
5
public static Object invokeMethod(Object o, String methodName) { if (Functions.isEmpty(methodName)) return null; if (o == null) return null; Object retObj; try { Class<?> c = o.getClass(); if (c == null) return null; Method m = c.getMethod(methodName); retObj = m.invoke(o,new Object[0]); } catch (Throwable e) { return null; } return retObj; }
d0cc6540-4d61-4c33-a3cd-90cbe07152b7
8
@Override public void mouseMoved(MouseEvent e) { Point point = e.getPoint(); if (e.getSource() == _north) { if (point.x <= _borderWidth) { // Mouse located at North-West edge _north.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR)); } else if (point.x > _north.getWidth()-_borderWidth) { // Mouse located at North-East edge _north.setCursor(new Cursor(Cursor.NE_RESIZE_CURSOR)); } else { // Mouse located at North side _north.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR)); } } if (e.getSource() == _south) { if (point.x <= _borderWidth) { // Mouse located at Sounth-West edge _south.setCursor(new Cursor(Cursor.SW_RESIZE_CURSOR)); } else if (point.x > _south.getWidth()-_borderWidth) { // Mouse located at Sounth-East edge _south.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR)); } else { // Mouse located at Sounth side _south.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR)); } } if (e.getSource() == _east) { // Mouse located at East side _east.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR)); } if (e.getSource() == _west) { // Mouse located at West side _west.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR)); } }
515647ed-7492-45ec-8d96-f2c9a1ffaf07
5
public static void main(String[] args) throws InterruptedException { final Terminal rawTerminal = new TestTerminalFactory(args).createTerminal(); rawTerminal.enterPrivateMode(); int currentRow = 0; rawTerminal.moveCursor(0, 0); while(true) { Key key = rawTerminal.readInput(); if(key == null) { Thread.sleep(1); continue; } if(key.getKind() == Key.Kind.Escape) break; if(currentRow == 0) rawTerminal.clearScreen(); rawTerminal.moveCursor(0, currentRow++); putString(rawTerminal, key.toString()); if(currentRow >= rawTerminal.getTerminalSize().getRows()) currentRow = 0; } rawTerminal.exitPrivateMode(); }
56d445e3-f6d8-4e44-a0c2-2434227b6e46
5
public void update(Object target, String fieldname) { if (target != null && fieldname != null) { try { Method getter = target.getClass().getMethod( "is" + fieldname); if (getter != null) { Object current = getter.invoke(target); if (current instanceof Boolean) { setSelected(((Boolean) current).booleanValue()); } } } catch (Exception e) { // ignore } } }
a57a8bbc-3fe7-4c5f-b103-98d34c0001fb
4
public int []nextWinningMove(int token) { for(int i=0;i<3;i++) for(int j=0;j<3;j++) if(getBoardValue(i, j)==EMPTY) { board[i][j] = token; boolean win = isWin(token); board[i][j] = EMPTY; if(win) return new int[]{i,j}; } return null; }
857f4d20-38f8-406f-9ac1-4e6386e8bde5
5
public boolean deplacerPiece(Piece p, Point point) { boolean succes = false; if (Echiquier_deplacement_Utils.estAutorise(p, this, point)) { if (this.getPieceCase(point) != null) { if (this.jeuCourant == this.j1) { this.j2.mangerPieceCase(point); } else { this.j1.mangerPieceCase(point); } } if (isRoque(p, point)) { this.roque(p, point); } else { this.tabPieces[p.point.x][p.point.y] = null; p.setPoint(point); this.tabPieces[p.point.x][p.point.y] = p; p.unsetPremierDeplacement(); } succes = true; if (p.getType() == Piece_type.pion) { ((Pion) p).unsetPremierDeplacement(); } this.changerJoueur(); } return succes; }
f6a61dac-17c1-4b65-99be-793e2b44fa8e
7
public int uniquePathsWithObstacles(int[][] obstacleGrid) { int m = obstacleGrid.length; int n = obstacleGrid[0].length; int[][] A = new int[m][n]; for (int i = 0; i < m; i++) { if (obstacleGrid[i][0] == 1) break; A[i][0] = 1; } for (int i = 0; i < n; i++) { if (obstacleGrid[0][i] == 1) break; A[0][i] = 1; } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { if (obstacleGrid[i][j] == 1) continue; A[i][j] = A[i - 1][j] + A[i][j - 1]; } } return A[m - 1][n - 1]; }
0a14e388-8142-40a0-9e39-e6d807a65eb5
2
public void show() { for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) System.out.printf("%9.4f ", data[i][j]); System.out.println(); } }
642b96c0-7092-445d-a4b3-fc97bf24d9b4
3
public void use(BattleFunction iface, PokeInstance user, PokeInstance target, Move move) { if (this.target == Target.target) { target.battleStatus.resetStats(); } else { user.battleStatus.resetStats(); } if (text != null) { text = text.replace("$target", target.getName()); if (target.battleStatus.lastMove != -1) text = text.replace("$lastMove", target.getMove(target.battleStatus.lastMove).getName()); iface.print(text); } }
d74ec231-82b5-4aca-b3cf-c0e6fdb9c724
7
private static void writeAllData(String filename) throws IOException { FileWriter fw = new FileWriter(filename, false); HashMap<String, Averaging> statistic = new HashMap<String, Averaging>(); // // Write header to file // Object[] headers = keys.keySet().toArray(); java.util.Arrays.sort(headers); StringBuffer headersStr = new StringBuffer(); headersStr.append("file name"); headersStr.append(SEPARATOR_OUT); for(Object header : headers) { headersStr.append(header.toString()); headersStr.append(SEPARATOR_OUT); statistic.put(header.toString(), new Averaging()); } fw.write(headersStr.toString()); fw.write(NEW_LINE); // // Write data to file // System.out.println("Write statistic to '" +filename +"' with " +headers.length +" column"); Object[] filenames = allData.keySet().toArray(); java.util.Arrays.sort(filenames); for(Object file : filenames) { HashMap<String, String> data = allData.get(file); // write filename to file StringBuffer dataStr = new StringBuffer(); dataStr.append(file); dataStr.append(SEPARATOR_OUT); // write all values to file for(Object header : headers) { String value = data.get(header); if(value != null) { dataStr.append(value); } statistic.get(header.toString()).add(value); dataStr.append(SEPARATOR_OUT); } fw.write(dataStr.toString()); fw.write(NEW_LINE); } // write statistic // 1. average StringBuffer dataStr = new StringBuffer(); dataStr.append("Average"); dataStr.append(SEPARATOR_OUT); for(Object header : headers) { String value = statistic.get(header).toString(); dataStr.append(value); dataStr.append(SEPARATOR_OUT); } fw.write(dataStr.toString()); fw.write(NEW_LINE); // 2. diff to min dataStr = new StringBuffer(); dataStr.append("Diff to min value"); dataStr.append(SEPARATOR_OUT); for(Object header : headers) { String value = statistic.get(header).getDiffToMin(); dataStr.append(value); dataStr.append(SEPARATOR_OUT); } fw.write(dataStr.toString()); fw.write(NEW_LINE); // 3. diff to max dataStr = new StringBuffer(); dataStr.append("Diff to max value"); dataStr.append(SEPARATOR_OUT); for(Object header : headers) { String value = statistic.get(header).getDiffToMax(); dataStr.append(value); dataStr.append(SEPARATOR_OUT); } fw.write(dataStr.toString()); fw.write(NEW_LINE); // // Close file // fw.close(); }
f851037a-cfb6-47d3-8af5-2511a8887d0e
9
private char escapedStringChar(PositionTrackingPushbackReader par1PositionTrackingPushbackReader) throws IOException, InvalidSyntaxException { char c1 = (char)par1PositionTrackingPushbackReader.read(); char c; switch (c1) { case 34: c = '"'; break; case 92: c = '\\'; break; case 47: c = '/'; break; case 98: c = '\b'; break; case 102: c = '\f'; break; case 110: c = '\n'; break; case 114: c = '\r'; break; case 116: c = '\t'; break; case 117: c = (char)hexadecimalNumber(par1PositionTrackingPushbackReader); break; default: throw new InvalidSyntaxException((new StringBuilder()).append("Unrecognised escape character [").append(c1).append("].").toString(), par1PositionTrackingPushbackReader); } return c; }
ebb06401-d548-407b-995a-1dd9f0085651
1
public static void plot(int size) { PlotFrame frame = new PlotFrame("Energy", "Propagation", "Propagation"); frame.setSize(600, 600); for (int i = 0; i < size; i++) { // frame.append(0, x[i], y[i]); frame.append(0, i, i); frame.append(1, i, i * i); } frame.setConnected(true); frame.setMarkerShape(0, 0); frame.setMarkerShape(1, 0); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
d0d8d52a-e4ec-4e13-99fc-73766f23a593
3
public void set(AlumnoBean oAlumnoBean) throws Exception { try { oMysql.conexion(enumTipoConexion); oMysql.initTrans(); if (oAlumnoBean.getId() == 0) { oAlumnoBean.setId(oMysql.insertOne("alumno")); } oMysql.updateOne(oAlumnoBean.getId(), "alumno", "id_usuario", Integer.toString(oAlumnoBean.getId_usuario())); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "dni", oAlumnoBean.getDni()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "numexpediente", oAlumnoBean.getNumexpediente()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "nombre", oAlumnoBean.getNombre()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "ape1", oAlumnoBean.getApe1()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "ape2", oAlumnoBean.getApe2()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "sexo", oAlumnoBean.getSexo()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "domicilio", oAlumnoBean.getDomicilio()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "codpostal", oAlumnoBean.getCodpostal()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "poblacion", oAlumnoBean.getPoblacion()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "provincia", oAlumnoBean.getProvincia()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "telefono", oAlumnoBean.getTelefono()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "email", oAlumnoBean.getEmail()); oMysql.updateOne(oAlumnoBean.getId(), "alumno", "validado", oAlumnoBean.getValidado()); if (oAlumnoBean.getId_usuario() > 0) { oMysql.updateOne(oAlumnoBean.getId_usuario(), "usuario", "password", oAlumnoBean.getPassword()); oMysql.updateOne(oAlumnoBean.getId_usuario(), "usuario", "login", oAlumnoBean.getLogin()); } else { oMysql.setNull(oAlumnoBean.getId_usuario(), "usuario", "password"); oMysql.setNull(oAlumnoBean.getId_usuario(), "usuario", "login"); } oMysql.commitTrans(); } catch (Exception e) { oMysql.rollbackTrans(); throw new Exception("AlumnoDao.setAlumno: Error: " + e.getMessage()); } finally { oMysql.desconexion(); } }
d711a9f9-ccef-4aea-b221-add1955f2164
8
void add(Map<SearchState,SearchState> nextQueue, Node<String> node, int startIndex, double chunkScore, boolean isTokenEnd, Map<Dp,Chunk> chunking, char[] cs, int end) { if (chunkScore > mDistanceThreshold) return; SearchState state2 = new SearchState(node,startIndex,chunkScore); SearchState exState = nextQueue.get(state2); if (exState != null && exState.mScore < chunkScore) return; nextQueue.put(state2,state2); // finish match at token end by adding each cat (may be 0) if (isTokenEnd) { for (int i = 0; i < node.mEntries.length; ++i) { Chunk newChunk = ChunkFactory .createChunk(startIndex,end+1, node.mEntries[i].category().toString(), chunkScore); Dp dpNewChunk = new Dp(newChunk); Chunk oldChunk = chunking.get(dpNewChunk); if (oldChunk != null && oldChunk.score() <= chunkScore) continue; chunking.remove(dpNewChunk); chunking.put(dpNewChunk,newChunk); } } // insert for (int i = 0; i < node.mDtrChars.length; ++i) add(nextQueue,node.mDtrNodes[i],startIndex, chunkScore - mEditDistance.insertWeight(node.mDtrChars[i]), isTokenEnd,chunking,cs,end); }
7c1c7a6f-4edf-40f7-b3c2-47ca398171a7
2
@Override public void onGameEnd(int result, Object arg) { if (result == 1) { this.send("GAME-END " + result + " " + ((Player) arg).getName()); } else if (result == -1) { this.send("GAME-END " + result); } }
c95e0aed-b622-4fc8-a805-a26178889ce0
1
@Override public String getName() { String name = super.getName(); if (name == null) { return DEFAULT_NAME; } else { return name; } }
64504b3d-286f-4a26-81a2-9b3f39cf2d6c
3
public static void main(String[] args) { //String protocolName = "rmi"; String protocolName = "triple"; BasicProvider<DemoService> basicProvider = new BasicProvider<DemoService>(protocolName); basicProvider.exportService(DemoService.class); System.out.println("input 'stopServer' to stop provider service"); BufferedReader control = new BufferedReader(new InputStreamReader(System.in)); String command = null; try { while ((command = control.readLine()) != null) { if (command.equals("stopServer")) { basicProvider.unExportService(); break; } } } catch (IOException e) { e.printStackTrace(); } }
64fa00e4-8567-467a-a6af-2c02feab65be
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Permissao other = (Permissao) obj; if (grupo == null) { if (other.grupo != null) return false; } else if (!grupo.equals(other.grupo)) return false; if (menu == null) { if (other.menu != null) return false; } else if (!menu.equals(other.menu)) return false; return true; }
76841e65-d9c0-4f86-90ed-8b18e0687b4f
4
public void printPaths() { for(int i = 0; i < Game.map.height; i++) { System.out.print("["); for(int j = 0; j < Game.map.width; j++) { if(movement[j][i] > 0) { System.out.print(movement[j][i] + ",\t"); } else if(movement[j][i] == 0) { System.out.print("■■■■,\t"); } else { System.out.print("0,\t"); } } System.out.println("]"); } System.out.println(""); }
24b02209-dcca-44e0-9294-a26e7c57c8c0
4
public void mkFile(HashMap<String, SVGGraphics2D> p_recentPaintingObjects) { for (Entry<String, SVGGraphics2D> pair : p_recentPaintingObjects.entrySet()) { // Begin : How are the directory paths this SVG objects will need String objectDir = pair.getKey().substring(0, pair.getKey().lastIndexOf(File.separator)); String rootDir = objectDir.substring(0, objectDir.lastIndexOf(File.separator)); // End : How are the directory paths this SVG objects will need // Begin : if Directory does not exist create one File root = new File(rootDir); // root directory if(!root.exists()) { root.mkdir(); } File object = new File(objectDir); // directory for the specific object if(!object.exists()) { object.mkdir(); } // End : if Directory does not exist create one // Begin : Create new file and stream the SVG into try { Writer out = new OutputStreamWriter(new FileOutputStream(new File(pair.getKey())), "UTF-8"); pair.getValue().stream(out, true); //true means that svgGenerator uses CSS } catch (UnsupportedEncodingException | FileNotFoundException | SVGGraphics2DIOException e) { e.printStackTrace(); } // End : Create new file and stream the SVG into } }
13a8131f-9101-4c3b-b172-cc6d96698e12
8
@Override public long execute(AMD64Environment env, IInstruction instruction) { List<IOperand> operands = instruction.getOperands(); if (operands.size() == 2) { IOperand op1 = operands.get(0); IOperand op2 = operands.get(1); int op_width1 = env.getOperandWidth(op1); int op_width2 = env.getOperandWidth(op2); long val1; long val2; if(op1.getOperandType() == OperandType.MEMORY_EFFECITVE_ADDRESS){ val1 = env.getValue(op1, op_width2); } else { val1 = env.getValue(op1, op_width1); } if(op2.getOperandType() == OperandType.MEMORY_EFFECITVE_ADDRESS){ val2 = env.getValue(op2, op_width1); } else { val2 = env.getValue(op2, op_width2); } long diff = val1-val2; //CMP doesnt save the actual difference anywhere... it just //updates the EFLAGS register Register dummyReg = new Register(); dummyReg.setValue(diff, op_width1 - 1, 0); long returned = dummyReg.getValue(op_width1-1, 0); if (checkOverflow(val1, val2, returned)) { env.setValue(RegisterType.OF, 1); } else { env.setValue(RegisterType.OF, 0); } if (checkCarry(val1, val2, returned)) { env.setValue(RegisterType.CF, 1); } else { env.setValue(RegisterType.CF, 0); } if (returned == 0) { env.setValue(RegisterType.ZF, 1); } else { env.setValue(RegisterType.ZF, 0); } if (returned < 0) { env.setValue(RegisterType.SF, 1); } else { env.setValue(RegisterType.SF, 0); } if (ISAUtil.isEvenParity(returned)) { env.setValue(RegisterType.PF, 1); } else { env.setValue(RegisterType.PF, 0); } } return 0; }
f7a2b6e5-bc84-4f98-ae46-fcec2bde6582
4
short deinitialize() { // Before killing this thread, check if the thread is STILL alive if(!t.isAlive()) MsgAnalyzerCmnDef.WriteDebugSyslog("The worker thread in the SerialReceiver object did NOT exist......"); else { exit.set(true); MsgAnalyzerCmnDef.WriteDebugSyslog("The worker thread in the SerialReceiver object is STILL alive"); t.interrupt(); try { // wait till this thread dies t.join(2000); // System.out.println("The worker thread of receiving serial data is dead"); MsgAnalyzerCmnDef.WriteDebugSyslog("The worker thread of receving serial data is dead"); } catch (InterruptedException e) { MsgAnalyzerCmnDef.WriteDebugSyslog("The receiving serial data worker thread throws a InterruptedException..."); } catch(Exception e) { MsgAnalyzerCmnDef.WriteErrorSyslog("Error occur while waiting for death of receving serial data worker thread, due to: " + e.toString()); } } device_handle_exist = false; short ret = MsgAnalyzerCmnDef.ANALYZER_SUCCESS; // Close the serial port MsgAnalyzerCmnDef.WriteDebugSyslog("De-initialize the SerialPortWrapper object"); ret = serial_port.close_serial(); if (MsgAnalyzerCmnDef.CheckFailure(ret)) return ret; return ret; }
7cd576b9-7c01-43a6-b354-bc905664309c
2
public void draw (JEditorPane editor) { StringBuffer buf = new StringBuffer (); String name = toString (); editor.setContentType ("text/html"); buf.append ("<html>\n<head><title>"); buf.append (name); buf.append ("</title></head>\n<body><font size=+1><b>"); buf.append (name); buf.append ("</b></font><br>\n"); editor.setText (buf.toString () + "... querying for current device status ..." + "</body></html>" ); editor.repaint (); if (dev != null) { try { showDeviceInfo (buf); showClassInfo (buf); showConfigInfo (buf); } catch (IOException e) { e.printStackTrace (); } } buf.append ("</body></html>"); // the config info could be cached. // other bits involve "live" status. editor.setText (buf.toString ()); }
1994a698-02d1-4489-899a-ae95774ac12b
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } ComputerPart other = (ComputerPart) obj; if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (version == null) { if (other.version != null) { return false; } } else if (!version.equals(other.version)) { return false; } return true; }
5a9db105-1843-4b43-888b-a5e678ce9d31
1
public void clear_buffer() { for (int i = 0; i < channels; ++i) bufferp[i] = (short)i; }
10da7323-304c-44c2-9c2a-8dd8e2d28f67
6
public String nextCDATA() throws TXMLException { char c; int i; StringBuffer sb = new StringBuffer(); for(;;) { c = next(); if(end()) { throw syntaxError("Unclosed CDATA"); } sb.append(c); i = sb.length() - 3; if(i >= 0 && sb.charAt(i) == ']' && sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') { sb.setLength(i); return sb.toString(); } } }
87602c7a-f704-47fe-af64-c44385b722da
2
private static String createExecutionEnvironment(HardwareAlternative platformAlternative, String hardwareSetId, DeploymentAlternative deploymentAlternative) { String executionEnvironment = "\t\t<nestedNode xmi:type=\"uml:ExecutionEnvironment\" xmi:id=\"" + platformAlternative.getId() + "\" name=\"" + platformAlternative.getName() + "\">\n"; for (DeployedComponent deployedComponent : deploymentAlternative.getDeployedComponents()) if (deployedComponent.getHardwareSet().getId().equals(hardwareSetId)) executionEnvironment += createArtifact(deployedComponent.getComponent()); executionEnvironment += "\t\t</nestedNode>\n"; return executionEnvironment; }
9b4b3429-90e1-4389-85c2-48bdafa7524f
3
private void copyAndStrip(File sourceJar, File targetJar) throws IOException { ZipFile in = new ZipFile(sourceJar); ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(targetJar))); for(ZipEntry e : Collections.list(in.entries())) { if(e.isDirectory()) { out.putNextEntry(e); } else if(e.getName().startsWith("META-INF")) {} else { ZipEntry n = new ZipEntry(e.getName()); n.setTime(e.getTime()); out.putNextEntry(n); out.write(readEntry(in, e)); } } in.close(); out.close(); }
8b2a490b-2abe-473f-80e4-bc94bad5a3f7
0
@Override public double access(Balance balance) { return balance.getBalance(); }
006b16ad-65aa-4bc5-a1d3-d5d30e409f04
8
void deleteArrow(int col) { switch(col) { case 1: if(_arrows[4][0]!=null) { _arrows[4][0]=null; upArrowDeleted=true; } break; case 2: if(_arrows[4][1]!=null) { _arrows[4][1]=null; leftArrowDeleted=true; } break; case 3: if(_arrows[4][2]!=null) { _arrows[4][2]=null; rightArrowDeleted=true; } break; case 4: if(_arrows[4][3]!=null) { _arrows[4][3]=null; downArrowDeleted=true; } break; } }
3988376d-2530-45a5-afc3-15890893ea5f
2
private String getTeacher(List<String> teachers) { String s = ""; for(String t : teachers){ s += t + ", "; } if(s.length() > 0) { s = s.substring(0, s.length()-2); } else { s = "None"; } return s; }
89a941a7-4d93-4a55-8cd0-857bac28f528
3
private userDao() { Properties properties = new Properties(); try { properties.load(new FileInputStream("c:\\Users\\Igos\\workspace\\newsLine\\config.properties")); String dbURL = properties.getProperty("baseurl"); String user = properties.getProperty("user"); String password = properties.getProperty("pass"); try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } connection = DriverManager.getConnection(dbURL, user, password); } catch (IOException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } }
16245c1b-4883-4324-af6c-635dc8dfaedb
2
private String getListBy( String variable ) { StringBuilder sb = new StringBuilder(); if ( hasSearch ) { for ( int i = 1; i < searchList.size() + 1; i++ ) { sb.append( "\n" + TAB + TAB + "List<" + variable + "> list" + i + "= " ); sb.append( toJavaCase( variable ) + "Bo.getListBy" + toTitleCase( searchList.get( i - 1 ) ) ); sb.append( "( " + toJavaCase( variable ) + ".get" + toTitleCase( searchList.get( i - 1 ) ) ); sb.append( "() ) ; \n" ); sb.append( TAB + TAB + "assertEquals( 1 , list" + i + ".size() );\n" ); } } return sb.toString(); }
e2c7ff5b-f813-4b2a-81c7-53c87836f75f
2
@Override public void mousePressed(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { if (Main.modState == ModState.Editing) { Point clickedPoint = getClickedPoint(e); handlePointSelection(clickedPoint); } } }
0ec609ae-6796-455d-8d20-e17ff374078c
0
public void setStworz(String stworz) { this.stworz = stworz; }
8f7c61c9-c861-47a0-90d6-bc5d4a1d4174
9
public mxGraphHierarchyModel(mxHierarchicalLayout layout, Object[] vertices, List<Object> roots, Object parent, boolean ordered, boolean deterministic, boolean scanRanksFromSinks) { mxGraph graph = layout.getGraph(); this.deterministic = deterministic; this.scanRanksFromSinks = scanRanksFromSinks; this.roots = roots; this.parent = parent; if (vertices == null) { vertices = graph.getChildVertices(parent); } if (ordered) { formOrderedHierarchy(layout, vertices, parent); } else { // map of cells to internal cell needed for second run through // to setup the sink of edges correctly. Guess size by number // of edges is roughly same as number of vertices. vertexMapper = new Hashtable<Object, mxGraphHierarchyNode>( vertices.length); edgeMapper = new Hashtable<Object, mxGraphHierarchyEdge>( vertices.length); if (scanRanksFromSinks) { maxRank = 0; } else { maxRank = SOURCESCANSTARTRANK; } mxGraphHierarchyNode[] internalVertices = new mxGraphHierarchyNode[vertices.length]; createInternalCells(layout, vertices, internalVertices); // Go through edges set their sink values. Also check the // ordering if and invert edges if necessary for (int i = 0; i < vertices.length; i++) { Collection<mxGraphHierarchyEdge> edges = internalVertices[i].connectsAsSource; Iterator<mxGraphHierarchyEdge> iter = edges.iterator(); while (iter.hasNext()) { mxGraphHierarchyEdge internalEdge = iter.next(); Collection<Object> realEdges = internalEdge.edges; Iterator<Object> iter2 = realEdges.iterator(); if (iter2.hasNext()) { Object realEdge = iter2.next(); Object targetCell = graph.getView().getVisibleTerminal( realEdge, false); mxGraphHierarchyNode internalTargetCell = vertexMapper .get(targetCell); if (internalTargetCell != null && internalVertices[i] != internalTargetCell) { internalEdge.target = internalTargetCell; if (internalTargetCell.connectsAsTarget.size() == 0) { internalTargetCell.connectsAsTarget = new LinkedHashSet<mxGraphHierarchyEdge>( 4); } internalTargetCell.connectsAsTarget .add(internalEdge); } } } // Use the temp variable in the internal nodes to mark this // internal vertex as having been visited. internalVertices[i].temp[0] = 1; } } }
03e08acc-7ea1-447d-b3c4-7b2e576462d9
9
public void Process(int id){ switch(id){ case 241:ColorReasoning(0);//浅 break; case 242:ColorReasoning(1);//相等 break; case 243:ColorReasoning(2);//深 break; case 301:ActivateForceSpace(); break; case 341:DynamicForceReasoning(); break; case 401:ActivateObjectSpace(); break; case 261:GetRelationFromColorSpace(); break; case 351:GetRelationFromForceSpace(); break; case 399:GetAttribute(); break; } }
39df2d5e-ea7b-45f9-939f-f37bd603ee90
4
public void setMapValue(){ if( pointer_x >=0 && pointer_x < Constant.MAP_Array_SIZE && pointer_y < 80 && pointer_y >=0) this.array[pointer_x][pointer_y] = this.current_type ; }
5adec9a2-0677-49e1-81ea-f2fbcc2b4978
6
@Override protected void lock() { while (true) { if (!calcLocker.isWriteLocked() && calcLocker.writeLock().tryLock()) if (calcLocker.getWriteHoldCount() != 1) calcLocker.writeLock().unlock(); else if (hasAdjustment() == PRO_ADJ_PAR && ((NumberProperty) ((AbstractProperty) parentProperty)).calcLocker.isWriteLocked()) calcLocker.writeLock().unlock(); else return; } }
594ac6cd-8499-4399-a6e6-138cbbec8ac8
2
public HiddenNode(double act, NeuralNet dd, int lNo){ super(act,dd); layerNo=lNo; int hlp; if(layerNo==0) hlp = dis.getInputNo(); else hlp = dis.getHiddenLayers()[layerNo-1]; brnI = new Branch[hlp]; if(dd.getHiddenLayersNo()==layerNo+1) hlp = dis.getOutputNo(); else hlp = dis.getHiddenLayers()[layerNo+1]; brnO = new Branch[hlp]; }
3b477602-92de-4448-bb6a-ddfd028d6e58
9
public void connectHLine(String fieldType, CABot3Net retNet, CABot3Net linesNet) { int netSize =retNet.getInputSize(); int retinaOffset = getRetOffset(fieldType)*netSize; int lineOffset = getLineOffset(fieldType, "Hline")*netSize; int column; int row; int cols = retNet.getCols(); double weight=1.2; int retNeurIndex; int lineNeurIndex; //System.out.println("fieldType: "+fieldType+" Hline"); //We are going to add conections to "inputSize" number of neurons in the line net //These neurons will begin in the position determined by the lineOffset value //connections will come from neurons that are in the same row (retinotopically) for (int i = 0; i < netSize; i++){ row = i/cols; column=i%cols; if((row>5 && row<45) && (column>5 && column<cols-5)){//leave off the edges retNeurIndex=i+retinaOffset; lineNeurIndex=i+lineOffset; //System.out.println("lineNeurIndex: "+lineNeurIndex); //add central connection retNet.neurons[retNeurIndex].addConnection(linesNet.neurons[lineNeurIndex], weight); //need to check that the connections arent "falling off" the edge of the retina; column=i%retNet.getCols(); if(column>0){//retinal neuron is not right on the left edge of the vis field - add synapse retNet.neurons[retNeurIndex-1].addConnection(linesNet.neurons[lineNeurIndex], weight); } if(column>1){//retinal neuron is 2 or more cols from the left edge of the vis field - add synapse retNet.neurons[retNeurIndex-2].addConnection(linesNet.neurons[lineNeurIndex], weight); } if (column<retNet.getCols()-2){//we are not right at the RHS of the vis field retNet.neurons[retNeurIndex+2].addConnection(linesNet.neurons[lineNeurIndex], weight); } if (column<retNet.getCols()-1){//we are not right at the RHS of the vis field retNet.neurons[retNeurIndex+1].addConnection(linesNet.neurons[lineNeurIndex], weight); } rebuildHLineEnds(lineNeurIndex, 1, linesNet); } } }
a0873f58-3a51-407c-827d-833740d6123b
9
@SuppressWarnings("deprecation") @EventHandler public void onProjectileHit(ProjectileHitEvent event) { Projectile projectile = event.getEntity(); if (!(projectile instanceof Arrow)) return; Arrow arrow = (Arrow)projectile; if (!(arrow.getShooter() instanceof Player)) { return; } BlockIterator bi = new BlockIterator(arrow.getWorld(), arrow.getLocation().toVector(), arrow.getVelocity().normalize(), 0, 4); while (bi.hasNext()) { final Block hit = bi.next(); if (!(arrow.getShooter() instanceof Player)) { return; } //final Player shooter = (Player) arrow.getShooter(); if (hit.getType() == Material.GLASS || hit.getType() == Material.GLOWSTONE || hit.getType() == Material.THIN_GLASS) { this.sendBlockBreakParticles(/*(Player) arrow.getShooter(), */hit, hit.getLocation()); for (Player p : Bukkit.getOnlinePlayers()) { p.sendBlockChange(hit.getLocation(), Material.AIR, (byte) 0); } arrow.remove(); Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(HyperPVP.getJavaPlugin(), new Runnable() { @Override public void run() { for (Player p : Bukkit.getOnlinePlayers()) { p.sendBlockChange(hit.getLocation(), hit.getType(), (byte) 0); } } }, Helpers.getSecondByTick(2)); //hit.setType(Material.AIR); break; } } }
9c292bcf-53ab-42d9-9887-e70bb3515bb8
0
public void initListe() { TableModel listeModele = new AbstractTableModel() { @Override public String getColumnName(int col) { return titres[col].toString(); } public int getColumnCount() { return titres.length; } public Object getValueAt(int row, int col) { return donnees[row][col]; } public int getRowCount() { return donnees.length; } @Override public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } /* * @Override public boolean isCellEditable(int row, int column) { * return false; } */ @Override public void setValueAt(Object value, int row, int col) { donnees[row][col] = value; fireTableCellUpdated(row, col); // notifie les listeners que la // valeur a changee } // Requete: Select Nom From Liste Where getValueAt(1,tailleRes) /* * @Override public Class<?> getColumnClass(int columnIndex) { * switch (columnIndex) { case 0: case 1: return String.class; * * case 2: return Integer.class; * * case 3: return String.class; * * case 4: return Long.class; * * default: return Object.class; } } */ }; tableListe = new JTable(listeModele); tableListe.setAutoCreateRowSorter(true);// permet de trier la liste // selon les titres /* * TableColumn column = null; for (int i = 0; i < NBCOL; i++) { column = * tableListe.getColumnModel().getColumn(i); if (i == 0) { * column.setPreferredWidth(100); //Largeur premiere colonne column is * bigger } else { column.setPreferredWidth(50); } } */ // tableListe.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // //redimensionnement table impossible tableListe.getTableHeader().setBackground(new Color(227, 231, 244)); JScrollPane sp = new JScrollPane();// creation d'un scrollpane sp.setViewportView(tableListe); // sp.setBackground(new Color(227, 231, 244)); this.add(sp); }
ab1599ca-dacf-4038-bfc9-16101e387603
3
public static List<Integer> preorderTraversal(TreeNode root) { List<TreeNode> stack = new ArrayList<TreeNode>(); List<Integer> res = new ArrayList<Integer>(); TreeNode node = root; while (null != node || 0 != stack.size()) { while (null != node) { res.add(node.val); stack.add(node); node = node.left; } int size = stack.size(); node = stack.remove(size - 1); node = node.right; } return res; }
b3b5d778-9b79-4ca3-9ff3-072aee710674
4
public String getAttribute(String attribName) { if ((pdu.getPdu().equals("PSSRR")) || (pdu.getPdu().equals("PSSDR"))) { ArrayList attribs = pdu.getAttribs(); for (int i=0; i < attribs.size(); i++){ String[] attrib = (String[])attribs.get(i); if (attrib[0].equals(attribName)) return attrib[1]; } } return null; }
54d1fcd1-fb62-4713-97ae-7662b511d333
7
private void removePars() { try{ String inPars; boolean foundEndPars=false; int beginPars=0, endPars=0; while(beginPars!=-1&&endPars!=-1) { foundEndPars=false; beginPars=input.indexOf("("); endPars=beginPars; if (beginPars!=-1) { while(foundEndPars==false) { endPars++; switch(input.charAt(endPars)) { case '(': beginPars=endPars; break; case ')': foundEndPars=true; break; } } inPars=input.substring(beginPars+1,endPars); //evaluate stuff in parentheses input=input.substring(0,beginPars)+evaluate(inPars+"=")+input.substring(endPars+1,input.length()); //take care of --number resulting from -(number-biggerNumber) noMultipleNegatives(); } } }catch(Exception e) { input="NaN"; } }
4070c8f0-c428-4cad-92c3-b286fdae313e
2
private boolean jj_3R_93() { Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_16()) { jj_scanpos = xsp; break; } } return false; }
f6ab6013-2ffd-4d16-a552-28e19ed3374e
0
public Point2D getTopRight() { return new Point2D(width, y); }
2f466076-e8d7-48ac-b835-d6dfc6c5d8ef
7
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if(msg.amITarget(this)) { final MOB mob=msg.source(); switch(msg.targetMinor()) { case CMMsg.TYP_WAND_USE: if((mob.isMine(this)) &&(!amWearingAt(Wearable.IN_INVENTORY)) &&(msg.targetMessage()!=null)) { if(msg.targetMessage().toUpperCase().indexOf("SHAZAM")>=0) { if(mob.curState().adjHunger(50,mob.maxState().maxHunger(mob.baseWeight()))) mob.tell(L("You are full.")); else mob.tell(L("You feel nourished.")); } } return; default: break; } } super.executeMsg(myHost,msg); }
6758ab23-d5f6-4820-a50c-7e896a857198
7
@Override public void lock(int thread_id) { choosing_[thread_id] = true; choosing_ = choosing_; //force the other threads to see that choosing_[thread_id] has updated number_[thread_id] = max() + 1; choosing_[thread_id] = false; choosing_ = choosing_; //force the other threads to see that choosing_[thread_id] and number_[thread_id] have updated for (int i = 0; i < number_.length; i++) { //don't make the thread wait on itself if (i == thread_id) { continue; } //make sure the thread isn't choosing its ticket while (choosing_[i]) {}; //then wait for the other thread to not be waiting and/or finish in the critical section while (!((number_[i] == 0) || ((number_[thread_id] < number_[i]) || ((number_[thread_id] == number_[i]) && (thread_id < i))))) {}; } }
662333b6-c287-4b9b-a5f2-694f1ed0abca
2
@Override public int compareTo(StarSystem o) { return (this.getMass() < o.getMass()) ? -1 : (this.getMass() > o.getMass()) ? 1 : 0; }
c1e4ae81-4437-4b5b-9632-562d1113f600
3
public void mouseClicked(MouseEvent e){ //sets the string details equal to the click count. details = ("You clicked: "+ e.getClickCount()); //if the button that was pressed is equal to the //left button, middle wheel, or the right button //the string details gets this text added on depending which one is //clicked on. if(e.getButton() == MouseEvent.BUTTON1){ details += (" with left mouse button"); }else if(e.getButton() == MouseEvent.BUTTON2){ details += (" with the middle mouse button"); }else if(e.getButton() == MouseEvent.BUTTON3){ details += (" with the right mouse button"); } //sets our status bar's text to the outcome of the string details. statusbar.setText(details); }
0eeb849c-61ce-47f0-b3c0-9bbc13b02100
2
public static void win(int elapsedTime, int numMoves) { prefs.putInt("wins", prefs.getInt("wins", 0) + 1); if (getLowestMoves() > numMoves) { setLowestMoves(numMoves); } if (getBestTime() > elapsedTime) { setBestTime(elapsedTime); } }
62b7dde3-ddaa-4809-b5ec-7cdda2646047
5
@Override public void actionPerformed(ActionEvent e) { //browse button if(e.getActionCommand().equals(Strings.MENU_DATA[4])){ JFileChooser fc = new JFileChooser(); fc.setPreferredSize(new Dimension(600,600)); int returnVal = fc.showOpenDialog(Soartex_Patcher.frame); if (returnVal != JFileChooser.APPROVE_OPTION) return; File chosenFile = fc.getSelectedFile(); if(chosenFile.getAbsolutePath().endsWith(Strings.ZIP_FILES_EXT.substring(1))){ Strings.setModdedZipLocation(chosenFile.getAbsolutePath()); //show old mods if possible Thread thread = new Thread(){ public void run(){ //info for user System.out.println("\nFinding Installed Mod Table"); final JFrame frame = new JFrame("Loading"); frame.setLocationRelativeTo(Soartex_Patcher.frame); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); GridLayout g1 = new GridLayout(3,1); frame.setLayout(g1); JLabel title = new JLabel("Please Wait We Are", JLabel.CENTER); title.setForeground(Color.white); JLabel title2 = new JLabel("Finding Your List", JLabel.CENTER); title2.setForeground(Color.white); final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL); aJProgressBar.setStringPainted(false); aJProgressBar.setIndeterminate(true); frame.add(title, BorderLayout.NORTH); frame.add(title2); frame.add(aJProgressBar, BorderLayout.SOUTH); frame.setSize(200, 100); frame.setResizable(false); frame.setFocusableWindowState(true); frame.setVisible(true); Soartex_Patcher.frame.setEnabled(false); //get the old mods getOldMods(); //disable frame Soartex_Patcher.frame.setEnabled(true); frame.setVisible(false); } }; thread.start(); } else{ JOptionPane.showMessageDialog(Soartex_Patcher.frame, "Not a valid .zip", "Error", JOptionPane.ERROR_MESSAGE); System.err.println("Error: Not a valid .zip"); } } //patch button else if(e.getActionCommand().equals(Strings.MENU_DATA[5])){ Thread thread = new Thread(){ public void run(){ if(!Strings.MODDEDZIP_LOCATION.equals("")){ Patch_Controller temp= new Patch_Controller(Strings.MODDEDZIP_LOCATION); temp.run(); } else{ JOptionPane.showMessageDialog(Soartex_Patcher.frame, "Your path has not been set to a valid .zip file.", "Error", JOptionPane.ERROR_MESSAGE); System.err.println("Error: Path not Set!"); } } }; thread.start(); } }
2d5f5738-339d-45e1-b2ce-f726b3e566b3
2
@Override public String getNamespaceURI(String prefix) { String url = XMLConstants.NULL_NS_URI; if(this.map != null && this.map.containsKey(prefix)) { url = this.map.get(prefix); } return url; }
8de17610-bf59-4c9f-ac81-882483608fc6
1
public static void dolaresToEuros(){ final BufferedReader stdin=new BufferedReader (new InputStreamReader(System.in)); try{ System.out.print("Intoduce el importe en dolares => "); dolar=Double.parseDouble(stdin.readLine()); System.out.println("El valor de cambio es "+cambio+"€ => 1 $"); System.out.println(dolar +"$ son "+df.format((dolar/cambio))+"€"); }catch(Exception e){ System.out.println("Valor fuera de rango"); }finally{//se ejecuta si o si independientemente de si entra en el try y catch // try { // stdin.close(); //} catch (IOException e1) { //e1.printStackTrace(); //} } }
2689023c-8fb7-43f0-952b-40c7a339d4f2
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; TypeDeclarationNode other = (TypeDeclarationNode) obj; if (ident == null) { if (other.ident != null) return false; } else if (!ident.equals(other.ident)) return false; if (type == null) { if (other.type != null) return false; } else if (!type.equals(other.type)) return false; return true; }
33cd8710-5c65-4e68-ae5a-7510ded72687
1
private double exptLessThan(double b) { double sum=0,interval=(b-12)/1000,val=12; for (int i = 0; i <1000; i++) { sum+=phi(val, mu, sigma)*val*interval; val+=interval; } return sum/probLessThan(b); }
e9a426c3-6a2a-4809-affa-26b36fe16210
2
private JPanel prepareParamControls(JTextField posStart, JTextField posEnd, final JTextField winSize, final JTextField shiftIncr, JCheckBox useSlide) { JPanel controlField = new JPanel(), startField = new JPanel(), endField = new JPanel(), checkBoxField = new JPanel(), windowField = new JPanel(), shiftField = new JPanel(); final JPanel slideFields = new JPanel(); /* * Position based parameters */ startField.setLayout(new FlowLayout(FlowLayout.LEADING)); startField.add(new JLabel("Start Position:")); startField.add(posStart); endField.setLayout(new FlowLayout(FlowLayout.LEADING)); endField.add(new JLabel("End Position:")); endField.add(posEnd); /* * Fancy check box for making window parameters visible/invisible */ checkBoxField.setLayout(new FlowLayout(FlowLayout.LEADING)); checkBoxField.add(useSlide); useSlide.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { slideFields.setVisible(true); } else if (e.getStateChange() == ItemEvent.DESELECTED) { slideFields.setVisible(false); winSize.setText(""); shiftIncr.setText(""); } mPane.setVisible(true); } }); /* * Window Parameters */ windowField.setLayout(new FlowLayout(FlowLayout.LEADING)); windowField.add(new JLabel("Window Size")); windowField.add(winSize); shiftField.setLayout(new FlowLayout(FlowLayout.LEADING)); shiftField.add(new JLabel("Window Shift")); shiftField.add(shiftIncr); slideFields.setLayout(new BoxLayout(slideFields, BoxLayout.Y_AXIS)); slideFields.add(windowField); slideFields.add(shiftField); slideFields.setVisible(false); /* * Putting all parameter inputs together */ controlField.setLayout(new BoxLayout(controlField, BoxLayout.Y_AXIS)); controlField.add(startField); controlField.add(endField); controlField.add(checkBoxField); controlField.add(slideFields); return controlField; }
46519dd9-c98b-4c6a-ad55-024554d87430
3
public int[] getSlotItemIDs() { Vector<Integer> v = new Vector<Integer>(); for (Widget slot : getSlotWidgets()) { int i = slot.getParentId(); if (i != -1) { v.add(i); } } int[] ia = new int[v.size()]; int index = 0; for (int i : v) { ia[index] = i; index++; } return ia; }
a308c22c-ed0c-464c-9b21-d4dc24406ea7
7
@Override public void execute(CommandSender sender, String[] arg1) { if (!CommandUtil.hasPermission(sender, PERMISSION_NODES)) { sender.sendMessage(plugin.NO_PERMISSION); return; } if (arg1.length == 0) { ChatChannel cc = plugin.getChannel("Global"); ChatPlayer cp = plugin.getChatPlayer(sender.getName()); if (plugin.globalToggleable) { if (!cp.getCurrentChannel().equals(cc)) { cp.setCurrentChannel(cc); } } return; } String message = ""; for (String data : arg1) { message += data + " "; } ChatChannel cc = plugin.getChannel("Global"); ChatPlayer cp = plugin.getChatPlayer(sender.getName()); cc.sendGlobalMessage(cp, message); if (plugin.globalToggleable) { if (!cp.getCurrentChannel().equals(cc)) { cp.setCurrentChannel(cc); } } }
4699f155-3edd-4df1-a514-1cd09e62fdb3
2
public void match(Pipe pipe_) { int idx = pipes.indexOf (pipe_); // If pipe is already matching do nothing. if (idx < matching) return; // If the pipe isn't eligible, ignore it. if (idx >= eligible) return; // Mark the pipe as matching. Utils.swap( pipes, idx, matching); matching++; }
3ca338bd-ebda-4e03-9f79-64571ad0843b
6
public static void writeCommandsForU(ArrayList<String> tl){ ArrayList<String> cmds=rfa.readInputStream(GenerateInitScripts.class.getResourceAsStream("config/srcOds/CommandsForU.sh"),"UTF-8"); StringBuffer content=new StringBuffer(); for (int i = 0; i < cmds.size(); i++) { if(cmds.get(i).contains("{commands-config-generate}")){ content.append("cd /home//Pad-dbw/"+projectName+"\r\n"); content.append("./runJob.sh\r\n"); content.append("cd /home//Pad-dbw/"+projectName+"-ods\r\n"); content.append("./runJob.sh\r\n"); content.append("\r\n"); for (int j = 0; j < tl.size(); j++) { String index=((j+offset)<10?"0"+Integer.toString(j+offset):Integer.toString(j+offset)); content.append("hive -f "+index+"_create_"+tl.get(j)+".hql\r\n"); } content.append("\r\n"); for (int j = 0; j < tl.size(); j++) { String index=((j+offset)<10?"0"+Integer.toString(j+offset):Integer.toString(j+offset)); content.append("./"+index+"_src_load_"+tl.get(j)+".sh wf job "+dbconS+" "+un+" "+pwd+" "+new SimpleDateFormat("yyyyMMdd").format(new Date())+" hdfs://cnsz131083.app.paic.com.cn:9000/apps-data/hduser0401/Pad-dbw/"+projectName+"/"+new SimpleDateFormat("yyyyMMdd").format(new Date())+"/\r\n"); } content.append("\r\n"); content.append("hive -e 'use "+data_db_name+"; show partitions {table_name};' | grep 'channel="+channel+"\r\n"); content.append("hadoop fs -ls hdfs://cnsz131083.app.paic.com.cn:9000/apps-data/hduser0401/Pad-dbw/"+projectName+"/\r\n"); content.append("hadoop fs -rmr hdfs://cnsz131083.app.paic.com.cn:9000/apps-data/hduser0401/Pad-dbw/"+projectName+"/"+new SimpleDateFormat("yyyyMMdd").format(new Date())+"/\r\n"); }else content.append(cmds.get(i)+"\r\n"); } wfa.mkdirs(resetPath); wfa.overwriteFromSB(resetPath + File.separator + "CommandsForU.sh", "UTF-8", content); }
1d1aab9f-b651-4bc8-9e78-575b82d45002
0
public Integer getErrorCount() { return errorCount; }
156aaf90-54e9-41d8-8655-99d47214f754
7
public static List<Person> getAllPeople() { List<Person> people = new ArrayList<Person>(); Connection conn = null; Statement stmt = null; try { // STEP 2: Register JDBC driver Class.forName("com.mysql.jdbc.Driver"); // STEP 3: Open a connection System.out.println("Connecting to database..."); conn = DriverManager.getConnection(DB_URL, USER, PASS); // STEP 4: Execute a query System.out.println("Creating statement..."); stmt = conn.createStatement(); String sql; sql = "SELECT * FROM person"; ResultSet rs = stmt.executeQuery(sql); // STEP 5: Extract data from result set while (rs.next()) { // Retrieve by column name int id = rs.getInt("person_id"); String name = rs.getString("person_first_name") + " " + rs.getString("person_last_name"); Date birthday = rs.getDate("person_birth_date"); people.add(new Person(id, name, birthday)); } // STEP 6: Clean-up environment rs.close(); stmt.close(); conn.close(); } catch (SQLException se) { // Handle errors for JDBC se.printStackTrace(); } catch (Exception e) { // Handle errors for Class.forName e.printStackTrace(); } finally { // finally block used to close resources try { if (stmt != null) stmt.close(); } catch (SQLException se2) { }// nothing we can do try { if (conn != null) conn.close(); } catch (SQLException se) { se.printStackTrace(); }// end finally try }// end try return people; }
8853a819-7b8a-42ee-a1a8-d007e93d24fd
7
public static boolean isAdjacentTo(Board board, int player, int x, int y) { int boardSize = board.boardSize; int[][] intersections = board.intersections; return (x > 0 && intersections[x - 1][y] == player) || (x < boardSize - 1 && intersections[x + 1][y] == player) || (y > 0 && intersections[x][y - 1] == player) || (y < boardSize - 1 && intersections[x][y + 1] == player); }
af4dcf44-1950-43a2-818c-d81be00c971a
7
public int look(int bits){ int ret; int m=mask[bits]; bits+=endbit; if(endbyte+4>=storage){ if(endbyte+(bits-1)/8>=storage) return (-1); } ret=((buffer[ptr])&0xff)>>>endbit; if(bits>8){ ret|=((buffer[ptr+1])&0xff)<<(8-endbit); if(bits>16){ ret|=((buffer[ptr+2])&0xff)<<(16-endbit); if(bits>24){ ret|=((buffer[ptr+3])&0xff)<<(24-endbit); if(bits>32&&endbit!=0){ ret|=((buffer[ptr+4])&0xff)<<(32-endbit); } } } } return (m&ret); }
83f02441-6310-4ff4-ae47-e4573afa9969
5
private int getOption() { while (true) { try { System.out.print("\nEnter option: "); int option = new Scanner(System.in).nextInt(); if (option >= 1 && option <= menuItems.length || option == EXIT_OPTION) { return option; } else { System.out.println("\nERROR - Invalid option."); } } catch (InputMismatchException e) { System.out.println("ERROR - Not a number."); } } }
a0edc4d6-91bc-4783-82b0-f478735a094a
6
@Override public void start(final Stage primaryStage) throws JAXBException { primaryStage.setTitle("een"); opslag = new ObjectenOpslag(root, null); label = new Label("Welkom!!!!"); root.getChildren().add(label); rz = new Rugzak(); root.getChildren().add(rz); ab = new ActionBenodigdheden(label, opslag, rz); Button save = new Button(); save.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("----"); FileChooser fileChooser = new FileChooser(); //Show save file dialog File file = fileChooser.showSaveDialog(primaryStage); if(file != null){ opslag.save(file); } System.out.println("----"); } }); save.setText("Save"); save.setTranslateX(400); save.setTranslateY(20); root.getChildren().add(save); me = new Me(5.0, 10.0); root.getChildren().add(me.getShape()); root.getStylesheets().add("Opmaak/opmaak.css"); primaryStage.setScene(new Scene(root)); // waarom???? :( //primaryStage.getScene() rz.getTabel().setOnKeyPressed(new EventHandler<KeyEvent>(){ @Override public void handle(KeyEvent t) { if(dX.get(t.getCode()) != null){ double nx = me.getX() + dX.get(t.getCode()); double ny = me.getY() + dY.get(t.getCode()); if (!opslag.hitBuilding(nx, ny)){ me.verplaats(nx, ny); } label.setText(null); }else if(t.getCode() == KeyCode.SPACE){ Spatiebaar b = opslag.onSpatiebaarDing(me.getX(),me.getY()); if(b != null && b.hasAction()){ b.doAction(ab); } } } }); primaryStage.setWidth(800); primaryStage.setHeight(600); primaryStage.show(); }
ef941158-f5dc-4331-a55a-2c6a917c0c43
0
@Test public void itShouldNotSerializeEmptyProperties() throws Exception { TestGeoJsonObject testObject = new TestGeoJsonObject(); Assert.assertEquals("{\"type\":\"TestGeoJsonObject\"}", mapper.toJson(testObject)); }
235cabe9-f797-4b77-a1be-9f87c43e23e6
4
public boolean game_over(){ return table.is_complete() || WHITE_SCORE ==0 || BLACK_SCORE == 0 || (cpuValidMoves.size()==0 && playerValidMoves.size()==0); } // end game_over
d288c9ac-a72a-4575-a84b-ccf5d28fffe9
2
protected String queryWithWhoisServer(final String domainName, final String whoisServer) { String result = ""; try { WhoisClient whois = new WhoisClient(); whois.connect(whoisServer); result = whois.query(domainName); whois.disconnect(); } catch (SocketException e) { } catch (IOException e) { } return result; }
a7ae9f1d-ac23-41bf-a390-89996d2fb645
5
public boolean translate(Polyomino poly, int dx, int dy){ for (Point loc:poly.getTranslateLocs(dx, dy)){ if (loc.y<0 || loc.x<0 || loc.x>=fWidth || contents[loc.y][loc.x] != null) return false; } poly.translate(dx, dy); return true; }
ea065adc-82e7-445e-a79f-a13cc076e8b4
2
@Override public int getLockWriteCount(String objectType) { int result = 0; String lockStart = objectType + lockSeparate; for (int i = 0; i < writeLocks.size(); i++) { String lockName = writeLocks.get(i); if (lockName.startsWith(lockStart)) result++; } return result; }