method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
0badab96-aa83-4a3d-ba05-ce47fb2f1617
8
private void move() { if (x < 0) { x = Board.M_WIDTH - 1; direction = LEFT; moveLeft(); } else if (x > Board.M_WIDTH - 1) { x = 0; direction = RIGHT; moveRight(); } else { if (board.getLabyrinth().isIntersection(x, y)) { direction = newDir(); } if (blue) { direction = getPacmanOppositeDirection(board.getPacman()); } switch (direction) { case LEFT: moveLeft(); break; case RIGHT: moveRight(); break; case UP: moveUp(); break; case DOWN: moveDown(); break; } } }
57d087b1-5347-4993-9a88-f148becccc27
2
public void ModifyItem() { System.out.println(this.itemID); Items itemlist = new Items(); itemlist.init(); for (Item item : itemlist.getItemList()) { if (item.itemID.equals(this.itemID)) { System.out.println("itemFound"); this.itemName = item.itemName; this.itemDescription = item.itemDescription; this.itemPrice = item.itemPrice; this.itemURL = item.itemURL; } } }
61cc3835-b9c6-46c2-95e7-1d60f0d1bee2
7
public void testConstructor_int_int_int() throws Throwable { DateMidnight test = new DateMidnight(2002, 6, 9); assertEquals(ISOChronology.getInstance(), test.getChronology()); assertEquals(LONDON, test.getZone()); assertEquals(TEST_TIME_NOW_LONDON, test.getMillis()); assertEquals(2002, test.getYear()); assertEquals(6, test.getMonthOfYear()); assertEquals(9, test.getDayOfMonth()); try { new DateMidnight(Integer.MIN_VALUE, 6, 9); fail(); } catch (IllegalArgumentException ex) {} try { new DateMidnight(Integer.MAX_VALUE, 6, 9); fail(); } catch (IllegalArgumentException ex) {} try { new DateMidnight(2002, 0, 9); fail(); } catch (IllegalArgumentException ex) {} try { new DateMidnight(2002, 13, 9); fail(); } catch (IllegalArgumentException ex) {} try { new DateMidnight(2002, 6, 0); fail(); } catch (IllegalArgumentException ex) {} try { new DateMidnight(2002, 6, 31); fail(); } catch (IllegalArgumentException ex) {} new DateMidnight(2002, 7, 31); try { new DateMidnight(2002, 7, 32); fail(); } catch (IllegalArgumentException ex) {} }
617b4b91-cf6a-4386-8d31-116b4461c547
4
private static void bubbleSort(int[] arr) { if(arr.length < 2) return; int right;//每次冒泡那个最大元素落在这个索引位置上 for(int i=0; i<arr.length-1; i++){//需要进行n-1次冒泡 right = arr.length - 1 - i; for(int j=0; j<right; j++){ if(arr[j] > arr[j+1]){ //swap arr[j] and arr[j+1] int temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } }
3bad45a0-6cbb-433f-9e17-0df88699e073
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(SaisieFrais.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(SaisieFrais.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(SaisieFrais.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(SaisieFrais.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the dialog */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { SaisieFrais dialog = new SaisieFrais(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); }
fc529eaf-7eb9-457c-b41f-ec6565ffff0e
1
public static void main(String[] args) { for (int i = 1; i <= 20; ++i) System.out.println(new Count_and_Say().countAndSay(i)); // System.out.println(new Count_and_Say().countAndSay(10)); }
671c483c-d96e-4954-9644-29bfe55d4f9f
7
public static String setRankString(int x) { if(x!=1&&x!=11&&x!=12&&x!=13) { return Integer.toString(x); } if(x==11) { return JACK; } if(x==12) { return QUEEN; } if(x==13) { return KING; } return ACE; }
8e57d1c2-894a-46a1-bb69-48e6a7780aa0
1
public ModelCRLV getModelCrlv(ModelCRLV crlv, String action){ ModelIPVA ipva = new ModelIPVA(); if(action.equals("editar")) ipva.setIdIpva(crlv.getIpva().getIdIpva()); crlv.setVia(Integer.parseInt(txtVia.getText())); crlv.setCodRenavam(txtCodRenavam.getText()); crlv.setRntrc(txtRntrc.getText()); crlv.setExercicio(txtExercicio.getText()); crlv.setNome(txtNome.getText()); crlv.setCpfCnpj(txtCpfCnpj.getText()); crlv.setPlaca(txtPlaca.getText()); crlv.setUfPlaca(txtUfPlaca.getText()); crlv.setPlacaAnt(txtPlacaAnt.getText()); crlv.setUfPlacaAnt(txtUfPlacaAnt.getText()); crlv.setChassi(txtChassi.getText()); crlv.setEspecieTipo(txtEspecie.getText()); crlv.setCombustivel(txtCombustivel.getText()); crlv.setMarca(txtMarca.getText()); crlv.setModelo(txtModelo.getText()); crlv.setAnoFab(Integer.parseInt(txtAnoFab.getText())); crlv.setAnoMod(Integer.parseInt(txtAnoMod.getText())); crlv.setCap(txtCap.getText()); crlv.setPot(txtPot.getText()); crlv.setCil(txtCil.getText()); crlv.setCategoria(txtCategoria.getText()); crlv.setCor(txtCor.getText()); ipva.setCotaUnica(txtCotaUnica.getText()); ipva.setFaixaIpva(txtFaixaIpva.getText().toString()); ipva.setVencCotaUnica(txtVencCotaUnica.getText().toString()); ipva.setParcelamentoCotas(txtParcelamentoCotas.getText().toString()); ipva.setVencPrimeiraCota(txtParcela1.getText().toString()); ipva.setVencSegundaCota(txtParcela2.getText().toString()); ipva.setVencTerceiraCota(txtParcela3.getText().toString()); crlv.setIpva(ipva); /*crlv.getIpva().setFaixaIpva(txtFaixaIpva.getText()); crlv.getIpva().setCotaUnica(txtCotaUnica.getText()); crlv.getIpva().setVencCotaUnica(txtVencCotaUnica.getText()); crlv.getIpva().setParcelamentoCotas(txtParcelamentoCotas.getText()); crlv.getIpva().setVencPrimeiraCota(txtParcela1.getText()); crlv.getIpva().setVencSegundaCota(txtParcela2.getText()); crlv.getIpva().setVencTerceiraCota(txtParcela3.getText()); crlv.setPremioTarifario(txtPremioTarifario.getText());*/ crlv.setIof(txtIof.getText()); crlv.setPremioTotal(txtPremioTotal.getText()); crlv.setDataPag(txtDataPagamento.getText()); crlv.setObservacoes(txtObservacoes.getText()); crlv.setLocal(txtLocal.getText()); crlv.setData(txtData.getText()); System.out.println(txtCotaUnica.getText().toString()); return crlv; }
2d4f6032-1b4e-468f-9e92-bd20b95dcbb3
3
protected void skipAttributes(DataInputStream input) throws IOException { int count = input.readUnsignedShort(); for (int i = 0; i < count; i++) { input.readUnsignedShort(); // the name index long length = input.readInt(); while (length > 0) { long skipped = input.skip(length); if (skipped == 0) throw new EOFException("Can't skip. EOF?"); length -= skipped; } } }
2c799957-cfee-46a7-9419-b77c04b26d1e
4
public String[] getSets0(){ String[] sets =null; try{ sets = textField.getText().split(","); if(textField_1.getText().length()<1) return null; int x = Integer.valueOf(nbrVarComboBox.getSelectedItem().toString()); x = (int) Math.pow(2, x); for(String s : sets){ int set = Integer.valueOf(s); if (!(set <x))return null; } } catch(Exception e){} return sets; }
64bd6a3e-7101-4ff9-8c29-2f08935bdb80
8
public void run(){ gameStart=0; new Tile(); windowrunning = true; running = true; level = new Level(); image = createVolatileImage(width,height); //Run the application until the user tells it to close while(windowrunning){ if(gameStart==1){ startTime = System.currentTimeMillis(); gameStart++; } if(running) currentTime = System.currentTimeMillis(); update();//go to update() render();//renders the grid after checking conditions and changing tile images //If you hit a bomb, end the game if(hitBomb){ Level.revealBombs(Level.grid); update(); render(); Level.endGame(false); hitBomb=false; } //If you win, end the game if(gamewon){ update(); render(); stopTime = System.currentTimeMillis(); Level.endGame(true); gamewon=false; } //Close the window if(gtfo){ windowrunning=false; j.setVisible(false); j.dispose(); } //Wait a bit so as not to render more than necessary try{ Thread.sleep(15); } catch(Exception e){ e.printStackTrace(); } } //Close the window when the application has been told to stop running if(gtfo){ windowrunning=false; j.setVisible(false); j.dispose(); } }
dbc7f278-d624-4fa2-9475-bb2a5cf9c8ce
0
public SubCategory(String naam, int datatype, float weight) { this.naam = naam; this.datatype = datatype; this.weight = weight; this.periods = new ArrayList<Period>(); }
b2c83c5b-d884-4ef1-9c3a-7c5cf232956f
4
public double removeMin() { if ( _heap.size() == 0 ) return -1.0; else _size--; //store root value for return at end of fxn double retVal = peekMin(); //store val about to be swapped into root double foo = _heap.get( _heap.size() - 1); //swap last (rightmost, deepest) leaf with root swap( 0, _heap.size() - 1 ); //lop off last leaf _heap.remove( _heap.size() - 1); // walk the now-out-of-place root node down the tree... int pos = 0; int minChildPos; while( pos < _heap.size() ) { //choose child w/ min value, or check for child minChildPos = minChildPos(pos); //if no children, then i've walked far enough if ( minChildPos == -1 ) break; //if i am less than my least child, then i've walked far enough else if ( foo <= _heap.get(minChildPos) ) break; //if i am > least child, swap with that child else { swap( pos, minChildPos ); pos = minChildPos; } } //return removed value return retVal; }//O(logn)
0fc02af5-8b5e-40e7-aef1-4b026c13ff54
2
@Override public Account getObject(int row, int col) { if(col == 0 || col == 1) { return (Account)getValueAt(row, 0); }else { return (Account)getValueAt(row, 3); } }
15ad829e-3f92-440e-ada0-3620370a2a80
1
public static String stripBlanks(final String string) { //// Preconditons if (string == null) throw new InvalidParameterException("string cannot be null"); return stripTrailing(stripLeading(string, ' '), ' '); }
4d50c473-0b20-4faa-9959-27ead2980c7e
9
private void cftbsub(int n, float[] a, int offa, int[] ip, int nw, float[] w) { if (n > 8) { if (n > 32) { cftb1st(n, a, offa, w, nw - (n >> 2)); if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (n > ConcurrencyUtils.getThreadsBeginN_1D_FFT_2Threads())) { cftrec4_th(n, a, offa, nw, w); } else if (n > 512) { cftrec4(n, a, offa, nw, w); } else if (n > 128) { cftleaf(n, 1, a, offa, nw, w); } else { cftfx41(n, a, offa, nw, w); } bitrv2conj(n, ip, a, offa); } else if (n == 32) { cftf161(a, offa, w, nw - 8); bitrv216neg(a, offa); } else { cftf081(a, offa, w, 0); bitrv208neg(a, offa); } } else if (n == 8) { cftb040(a, offa); } else if (n == 4) { cftx020(a, offa); } }
959eeb63-29e9-42d9-9e75-46975a3f4354
6
public DFA(Collection<State> states, Collection<Transition> transitions, Collection<State> acceptables, State start) { Set<State> statesSet = new HashSet<State>(states); Set<Transition> transitionsSet = new HashSet<Transition>(transitions); this.acceptables = new HashSet<State>(acceptables); for (State state : statesSet) { HashMap<String, Transition> map = new HashMap<String, Transition>(); allInOne.put(state, map); } Logger.log(statesSet.size()); for (State state : statesSet) { HashMap<String, Transition> map = allInOne.get(state); for (Transition tran : transitionsSet) { if (tran == null) throw new IllegalArgumentException(); if (tran.getOrigin() != state) continue; String key = tran.getKey(); if (key == null) throw new IllegalArgumentException("null key in transition"); map.put(key, tran); } Logger.log(map.size()); } this.start = start; current = start; }
53651da8-428b-4441-9859-4e0cd592b712
9
private void readLuminance() { int type = sourceImage.getType(); if (type == BufferedImage.TYPE_INT_RGB || type == BufferedImage.TYPE_INT_ARGB) { int[] pixels = (int[]) sourceImage.getData().getDataElements(0, 0, width, height, null); for (int i = 0; i < picsize; i++) { int p = pixels[i]; int r = (p & 0xff0000) >> 16; int g = (p & 0xff00) >> 8; int b = p & 0xff; data[i] = luminance(r, g, b); } } else if (type == BufferedImage.TYPE_BYTE_GRAY) { byte[] pixels = (byte[]) sourceImage.getData().getDataElements(0, 0, width, height, null); for (int i = 0; i < picsize; i++) { data[i] = (pixels[i] & 0xff); } } else if (type == BufferedImage.TYPE_USHORT_GRAY) { short[] pixels = (short[]) sourceImage.getData().getDataElements(0, 0, width, height, null); for (int i = 0; i < picsize; i++) { data[i] = (pixels[i] & 0xffff) / 256; } } else if (type == BufferedImage.TYPE_3BYTE_BGR) { byte[] pixels = (byte[]) sourceImage.getData().getDataElements(0, 0, width, height, null); int offset = 0; for (int i = 0; i < picsize; i++) { int b = pixels[offset++] & 0xff; int g = pixels[offset++] & 0xff; int r = pixels[offset++] & 0xff; data[i] = luminance(r, g, b); } } else { throw new IllegalArgumentException("Unsupported image type: " + type); } }
b3ef176c-0309-43ba-a5ba-7384b6263da6
4
private static Point[][] get8PlayersPositions() { int maxPlayers = 8; Point[][] pos = new Point[8][128]; for(int i = 0; i < maxPlayers;i++ ){ pos [0][i] = new Point(0,2*i); } for(int i = 0; i < maxPlayers/2;i++ ){ pos [1][i] = new Point(2 ,1+4*i); } for(int i = 0; i < maxPlayers/4;i++ ){ pos [2][i] = new Point(4 ,3+8*i); } for(int i = 0; i < maxPlayers/8;i++ ){ pos [3][i] = new Point(6 ,7+16*i); } return pos; }
997f294c-563e-4ec3-93c2-bacde511c56c
2
public void withdraw(int value) { if(value < 0) { IllegalArgumentException ex = new IllegalArgumentException( "You can't withdraw a negative number of dollars!"); log.throwing(getClass().getSimpleName(), "withdraw(int)", ex); throw ex; } else if(value > money) { IllegalArgumentException ex = new IllegalArgumentException( "You don't have enough money to withdraw " + value + " dollars!"); log.throwing(getClass().getSimpleName(), "withdraw(int)", ex); throw ex; } else { notifyPropertyChangeListeners(money, money - value); money -= value; } }
cd6d1817-6deb-44d9-9afc-2046a10c2660
1
public void method() { try { BufferedWriter w = new BufferedWriter(new PrintWriter("texto.txt")); BufferedReader r = new BufferedReader(new FileReader("text.txt")); } catch (IOException e) { } }
e9f0c9a1-2517-441a-8d9c-db56090a3770
9
@SuppressWarnings("rawtypes") @Override public void onEvent(Event e) { // TODO Auto-generated method stub String[] args = {""}; if(e instanceof PrivateMessageEvent) { PrivateMessageEvent event = (PrivateMessageEvent) e; args = Colors.removeFormattingAndColors(event.getMessage()).split(" "); String prefix = config.get("CommandPrefix"); if(args.length == 2) { if(args[0].equalsIgnoreCase(prefix + config.get("ChangeNickCommand"))) { setNick(args[1]); } else if(args[0].equalsIgnoreCase(prefix + config.get("IdentifyCommand"))) { identify(args[1]); } else if(args[0].equalsIgnoreCase(prefix + config.get("ChangeServerCommand"))) { connect(args[1]); } else if(args[0].equalsIgnoreCase(prefix + config.get("JoinChannelCommand"))) { joinChannel(args[1]); } else if(args[0].equalsIgnoreCase(prefix + config.get("PartChannelCommand"))) { partChannel(args[1]); } } else if(args.length == 3) { if(args[0].equalsIgnoreCase(prefix + config.get("PartChannelCommand"))) { partChannel(args[1], args[2]); } } } }
f769aefb-abab-4b0c-8653-3e624bb2de91
8
private static Object[] processValues(Field field, Selection selection) { FieldType type = TypeUtil.getFieldType(field.getType()); switch (type) { case INTEGER: return processIntegerValues(selection); case DOUBLE: return processDoubleValues(selection); case LONG: return processLongValues(selection); case DATE: return processDateValues(selection); case LOCALE: return processLocaleValues(selection); case TIMEZONE: return processTimeZoneValues(selection); case UUID: return processUUIDValues(selection); case STRING: return selection.values(); } throw new UnsupportedOperationException("@Selection of type: " + field.getType().getSimpleName() + " is not currently supported"); }
e9b1d3bc-e666-4826-81df-42c9575be08a
6
@Override public int hashCode() { int result = popProveedorId != null ? popProveedorId.hashCode() : 0; result = 31 * result + (popNitProveedor != null ? popNitProveedor.hashCode() : 0); result = 31 * result + (popNombreProveedor != null ? popNombreProveedor.hashCode() : 0); result = 31 * result + (popUsuario != null ? popUsuario.hashCode() : 0); result = 31 * result + (popTerminal != null ? popTerminal.hashCode() : 0); result = 31 * result + (popFecmod != null ? popFecmod.hashCode() : 0); return result; }
494dd31b-065c-4e9a-9dfc-0ed4fa1b7ed9
4
public void create(Engine engine, String name, String mapLocation) { //engine.addWorld(this); if(cubes == null) cubes = new ArrayList<Cube>(); try { BufferedImage image = ImageIO.read(new File(mapLocation)); height = new float[image.getWidth()][image.getHeight()]; width = image.getWidth()*0.25f; length = image.getHeight()*0.25f; for(int x=0;x<image.getWidth();x++) for(int y=0;y<image.getHeight();y++) height[x][y] = (new Color(image.getRGB(x, y)).getRed())/255f; } catch (IOException e) { e.printStackTrace(); } }
fbda596a-a8a9-4841-a201-7b071554d434
0
void without(Gizmo g) { g = new Gizmo(); // OK -- g not final g.spin(); }
0fa574da-fb07-49a8-b51a-75b16db4e6b7
3
@Override public double percentile(double percentile) { if (N == 0) return Double.NaN; // Number of values in the quartile double indexing = N * percentile; // If indexing has digits the index array contains only the number // indexing + 1. On the other hand, if indexing is an even number (it // has no decimals), index array contains two numbers: indexing and // indexing + 1 int index[] = (indexing % 1 == 0) ? new int[] { (int) indexing, (int) indexing + 1 } : new int[] { (int) indexing + 1 }; double sum = 0.0; for (int i : index) sum += getValue(i).doubleValue(); return sum / index.length; }
ab0ed43b-91b5-47e0-9673-f313f4f290b0
2
public static void main(String... args) { /* * Loads the file client.properties from the classpath. * It is located within the directory src/main/resources. */ Config config = new Config("client"); /* * Retrieve the String value associated with the 'download.dir' key * and print the absolute path of the directory. */ String downloadPath = config.getString("download.dir"); File downloadDir = new File(downloadPath); System.out.println("Download directory: " + downloadDir.getAbsoluteFile()); /* * Retrieve host and port of the proxy component to connect to. * Note that port is an Integer and parsed automatically. * If it does not contain a parsable integer, a NumberFormatException is thrown. */ String proxyHost = config.getString("proxy.host"); int proxyPort = config.getInt("proxy.tcp.port"); System.out.printf("Client connects to Proxy at '%s:%d'%n", proxyHost, proxyPort); System.out.println(TestUtils.repeat('=', 80)); /* * Furthermore, if the file is invalid i.e., a value is not defined, a MissingResourceException is thrown. */ String key = "undefined"; try { System.out.printf("%s = %s%n", key, config.getString(key)); } catch (MissingResourceException e) { System.out.printf("Key '%s' is not defined. Thus a MissingResourceException was thrown.%n", key); } /* * The same is true for a file, which is not located within the classpath. */ try { new Config("abc"); } catch (Exception e) { System.out.printf(e.getClass().getSimpleName() + ": " + e.getMessage()); } }
a053a5ee-608e-4084-9d39-344abc66a478
9
@Test public void testEndUserApi() throws JFKException{ // create the dummy object DummyClass dummy = new DummyClass(); // now get the function IFunctionBuilder builder = JFK.getFunctionBuilder(); IFunction function = builder.bindFunction( dummy, "hello" ); // execute the function String result = (String) function.executeCall( null ); // test the result if( ! dummy.resultString.equals(result) ) fail("Function invocation does not result!"); // now get another function IFunction function2 = builder.bindFunction(dummy, "double" ); if( function.equals(function2) ) fail("Two functions should not be equale with different names!"); Double d1 = new Double(10.5); Double d2 = (Double) function2.executeCall( new Object[]{ d1 } ); if( (d1.doubleValue() * 2) != (d2.doubleValue() ) ) fail("Return value is not the same! (" + d1.doubleValue() + " vs " + d2.doubleValue() + ")"); // test arity try{ function2 = builder.bindFunction(dummy, "string2"); function2.executeCall(null); }catch(JFKException e){ e.printStackTrace(); } // another function int value = 10; IFunction function3 = builder.bindFunction(dummy, "string"); if( function3.equals(function2) || function3.equals(function) ) fail("A function that should not be the same of a previous one!"); result = (String) function3.executeCall( new Object[]{ value } ); if( ! result.equals( dummy.resultString + value ) ) fail("Result value for string composition is wrong!"); // test arity try{ function3 = builder.bindFunction(dummy, "string2"); function3.executeCall(new Object[]{ value }); fail("Method call bad arity check passed!"); }catch(JFKException e){ e.printStackTrace(); } // test function parameters try{ function3 = builder.bindFunction(dummy, "string2"); function3.executeCall(new Object[]{ new String("A"), new String("B") }); fail("Method call parameter check passed!"); }catch(JFKException e){ e.printStackTrace(); } }
d051a7d6-3567-4d62-a2de-45f43b59f06c
2
public int dropHeight(Piece piece, int x) { int high = 10000; int result = 0; int temp; int i; int[] skirt = piece.getSkirt(); for (i = x; i < x + piece.getWidth(); i++) { temp = skirt[i - x] - getColumnHeight(i); if (temp < high) { high = temp; result = i; } } return getColumnHeight(result) - skirt[result - x]; }
7425f344-74f5-499b-a688-752fc4895d96
4
public void run() { try { boolean done = false; while (!done) { File file = queue.take(); if (file == FileEnumerationTask.DUMMY) { queue.put(file); done = true; } else search(file); } } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { } }
bb3d8763-3103-4218-a22b-42e1106079bf
3
public int[] getCurrentLayout() { String[] face = {"F", "R", "B", "L", "U", "D"}; Color[] colors = {color_red, color_green, color_orange, color_blue, color_yellow, color_white}; int[] layout = new int[6]; //Gets layout of grids on screen for(int i=0;i<6;i++) { //Loop for each face for(int n=0;n<6;n++) { //Loop for each color if(rubiks.compareColor(face[i]+":2:2", colors[front[0][n]])) { layout[i] = n; } } } return layout; }
d8403cd5-66bb-40c2-9a8c-8764b4c55b59
4
final public void run() { connectionEstablished(); // The message from the server Object msg; // Loop waiting for data try { while (!readyToStop) { // Get data from Server and send it to the handler // The thread waits indefinitely at the following // statement until something is received from the server msg = input.readObject(); // Concrete subclasses do what they want with the // msg by implementing the following method handleMessageFromServer(msg); } } catch (Exception exception) { if (!readyToStop) { try { closeAll(); } catch (Exception ex) { } connectionException(exception); } } finally { clientReader = null; } }
85e819d8-648a-4b92-8b01-a231866c4995
7
public void accept(final ClassVisitor cv) { FieldVisitor fv = cv.visitField(access, name, desc, signature, value); if (fv == null) { return; } int i, n; n = visibleAnnotations == null ? 0 : visibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = visibleAnnotations.get(i); an.accept(fv.visitAnnotation(an.desc, true)); } n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = invisibleAnnotations.get(i); an.accept(fv.visitAnnotation(an.desc, false)); } n = attrs == null ? 0 : attrs.size(); for (i = 0; i < n; ++i) { fv.visitAttribute(attrs.get(i)); } fv.visitEnd(); }
de5ea07d-964a-460c-9f08-e95c6953ef7c
0
@Test public void runTestRegisterGlobal1() throws IOException { InfoflowResults res = analyzeAPKFile("Callbacks_RegisterGlobal1.apk"); Assert.assertNotNull(res); Assert.assertEquals(1, res.size()); }
dc494d02-c9eb-4b19-a5da-a8e60796e3b1
1
public static WeaponType getWeaponType(String name) { if (weaponTypes.containsKey(name)) { return (WeaponType) weaponTypes.get(name); } return null; }
989de16a-5d4f-4215-9cb2-9bb1059dbef3
7
public static void main(String[] args){ while ( jogo.SearchPacdot(jogo.pacmaze) == true && !(jogo.SamePosition())) { jogo.DisplayPacworld(); Scanner in = new Scanner(System.in); System.out.println("Faz jogada: "); char tecla = in.nextLine().charAt(0); int x = 0; int y = 0; switch (tecla) { case 'w': x = -1; y = 0; break; case 's': x = 1; y = 0; break; case 'a': x = 0; y = -1; break; case 'd': x = 0; y = 1; break; } jogo.MoveGhost(); jogo.MovePacman(x, y); } jogo.DisplayPacworld(); if ( jogo.SamePosition() ){ System.out.println("Perdeste!"); } }
a47e1878-352f-4ce2-a1b0-8b632fe8763f
6
private Types.ACTIONS microbial(StateObservation stateObs, int maxdepth, StateHeuristic heuristic, int iterations) { double[] maxScores = new double[stateObs.getAvailableActions().size()]; for (int i = 0; i < maxScores.length; i++) { maxScores[i] = Double.NEGATIVE_INFINITY; } outerloop: for (int i = 0; i < iterations; i++) { for (Types.ACTIONS action : stateObs.getAvailableActions()) { StateObservation stCopy = stateObs.copy(); stCopy.advance(action); double score = 0; try { score = microbial_tournament(genome[r_action_mapping.get(action)], stCopy, heuristic) + randomGenerator.nextDouble()*0.00001; } catch (TimeoutException e) { break outerloop; } try { int int_act = this.r_action_mapping.get(action); if (score > maxScores[int_act]) { maxScores[int_act] = score; } }catch (Exception e){} } } Types.ACTIONS maxAction = this.action_mapping.get(Utils.argmax(maxScores)); return maxAction; }
ef42e31e-17b1-4072-8006-f72e0c08f742
6
public void retractWeapon(int lastKeyPressed) { try { int dir = 1; Point charLoc = new Point(this.getCharacterLocation()); if (!(grid.get(charLoc).returnCharacter().getWeapon() instanceof RangedWeapon)) { if (lastKeyPressed == KeyEvent.VK_A || lastKeyPressed == KeyEvent.VK_LEFT) { dir = -1; } else if (lastKeyPressed == KeyEvent.VK_D || lastKeyPressed == KeyEvent.VK_RIGHT) { dir = 1; } Point side = new Point((int) (getCharacterLocation().getX() + dir), (int) getCharacterLocation().getY()); Point secondSide = new Point((int) (getCharacterLocation().getX() + dir + dir), (int) getCharacterLocation().getY()); GridSpace target = grid.get(side); GridSpace target2 = grid.get(secondSide); target.remove(grid.get(charLoc).returnCharacter().getWeapon()); target.sortArrayOfThings(); target2.remove(grid.get(charLoc).returnCharacter().getWeapon()); target2.sortArrayOfThings(); } } catch (NullPointerException e) { System.out.println("Caught retractWeapon null pointer error."); } }
1d51c277-2c70-4b83-b3b8-5db92018c197
0
@Override public String getName() { return NAME; }
cf086ec8-08fa-4df0-b98c-4f64fe03fc93
2
public PickUpAction(Grid grid, Item item) { if (grid == null) throw new IllegalArgumentException("The given grid is invalid!"); if (item == null) throw new IllegalArgumentException("The given item is invalid!"); this.grid = grid; this.item = item; }
1740c063-e0fc-473f-a911-bdde7751ecb6
0
public void setVisited(boolean b) { this.visited = b; }
f89d1f81-c436-4f93-817f-27e92fff5a7c
4
public void keyReleased(KeyEvent ev) { if(ev.getKeyCode() == KeyEvent.VK_LEFT) { if(index != 1) index--; } if(ev.getKeyCode() == KeyEvent.VK_RIGHT) { index++; index = index % 1325; if(index == 0) index++; } comic = getComic(index); frame.setTitle("XKCD - " + Integer.toString(index)); title.setText(comic.getTitle()); image.setIcon(new ImageIcon(comic.getImgFilename())); frame.repaint(); }
755e4c7b-7974-45de-bd64-24f42756fa33
5
private void subledger2(ArrayList<ArrayList> arrayL) { String query3; System.out.println("sub2size"+arrayL.size()); for(int i=0; i<arrayL.size(); i++){ arrayTemp=arrayL.get(i); if(arrayTemp.get(0).matches("reg")){ /*query3 = "insert into subledger_reg(ordtlid, loanid, loandtlid, mon_premium_prev, mon_interest_prev, premium_pay, interest_pay) " + "values('"+ordtlid+"', '"+arrayTemp.get(1)+"', '"+arrayTemp.get(2)+"', '"+arrayTemp.get(3)+"', '"+arrayTemp.get(4)+"', '"+arrayTemp.get(5)+"', '"+arrayTemp.get(6)+"')"; paramDB.accessLoopDatabase(query3);*/ query3= "update loan_dtl set mon_premium_bal=mon_premium_bal-"+arrayTemp.get(5)+", mon_interest_bal=mon_interest_bal-"+arrayTemp.get(6)+ " where loandtlid="+arrayTemp.get(2); paramDB.accessLoopDatabase(query3); } else if(arrayTemp.get(0).matches("ed")){ /*query3 = "insert into subledger_educ(ordtlid, loanid, loandtlid, mon_premium_prev, mon_interest_prev, premium_pay, interest_pay) " + "values('"+ordtlid+"', '"+arrayTemp.get(1)+"', '"+arrayTemp.get(2)+"', '"+arrayTemp.get(3)+"', '"+arrayTemp.get(4)+"', '"+arrayTemp.get(5)+"', '"+arrayTemp.get(6)+"')"; paramDB.accessLoopDatabase(query3);*/ query3= "update loan_dtl set mon_premium_bal=mon_premium_bal-"+arrayTemp.get(5)+", mon_interest_bal=mon_interest_bal-"+arrayTemp.get(6)+ " where loandtlid="+arrayTemp.get(2); paramDB.accessLoopDatabase(query3); } else if(arrayTemp.get(0).matches("cal")){ System.out.println("2size"+arrayTemp.size()); /*query3 = "insert into subledger_cal (ordtlid, loanid, loandtlid, mon_premium_prev, mon_interest_prev, premium_pay, interest_pay) " + "values('"+ordtlid+"', '"+arrayTemp.get(1)+"', '"+arrayTemp.get(2)+"', '"+arrayTemp.get(3)+"', '"+arrayTemp.get(4)+"', '"+arrayTemp.get(5)+"', '"+arrayTemp.get(6)+"')"; paramDB.accessLoopDatabase(query3); */ query3= "update loan_dtl set mon_premium_bal=mon_premium_bal-"+arrayTemp.get(5)+", mon_interest_bal=mon_interest_bal-"+arrayTemp.get(6)+ " where loandtlid="+arrayTemp.get(2); paramDB.accessLoopDatabase(query3); System.out.println("in calinsert"+ordtlid+" "+arrayTemp.get(1)+" "+arrayTemp.get(2)+" "+arrayTemp.get(3)+" "+arrayTemp.get(4)+" "+arrayTemp.get(5)+" "+arrayTemp.get(6)); } else if(arrayTemp.get(0).matches("em")){ /*query3 = "insert into subledger_emer(ordtlid, loanid, loandtlid, mon_premium_prev, mon_interest_prev, premium_pay, interest_pay) " + "values('"+ordtlid+"', '"+arrayTemp.get(1)+"', '"+arrayTemp.get(2)+"', '"+arrayTemp.get(3)+"', '"+arrayTemp.get(4)+"', '"+arrayTemp.get(5)+"', '"+arrayTemp.get(6)+"')"; paramDB.accessLoopDatabase(query3);*/ query3= "update loan_dtl set mon_premium_bal=mon_premium_bal-"+arrayTemp.get(5)+", mon_interest_bal=mon_interest_bal-"+arrayTemp.get(6)+ " where loandtlid="+arrayTemp.get(2); paramDB.accessLoopDatabase(query3); } } }
52abcd5e-f713-42f4-8b03-39183277d7ad
9
public static String toFancyTime(int minutes) { if (minutes <= 0) { return "0 minutes"; } StringBuilder time = new StringBuilder(); int days = minutes / 60 / 24; if (days > 0) { time.append(days).append(" day").append(days > 1 ? "s" : ""); } int hours = minutes / 60 % 24; if (hours > 0) { if (days > 0) { time.append(", "); } time.append(hours).append(" hour").append(hours > 1 ? "s" : ""); } minutes = minutes % 60; if (minutes > 0) { if (hours > 0) { time.append(", "); } time.append(minutes).append(" minute").append(minutes > 1 ? "s": ""); } return time.toString(); }
ddc3bdac-fda4-4650-b0c4-d759567b9c86
7
public int maxArea(int[] heights) { int maxArea = 0; int start = 0, end = heights.length - 1; while (start < end) { int startHeight = heights[start], endHeight = heights[end]; int area = Math.min(startHeight, endHeight) * (end - start); if (area > maxArea) { maxArea = area; } if (startHeight < endHeight) { while (start < end && heights[start] <= startHeight) { start ++; } } else { while (start < end && heights[end] <= endHeight) { end --; } } } return maxArea; }
5f7c1a1f-6361-4243-b3bd-cd33dd74f841
6
static final boolean method3137(boolean bool, byte i) { anInt9426++; boolean bool_0_ = Class348_Sub8.currentToolkit.isBloomSupported(); if (i != -24) return true; if (!bool_0_ == !bool) return true; if (!bool) Class348_Sub8.currentToolkit.method3710(); else if (!Class348_Sub8.currentToolkit.method3671()) bool = false; if (bool_0_ == bool) return false; BitmapTable.aClass348_Sub51_3959.method3429((byte) 74, (((Class348_Sub51) (BitmapTable .aClass348_Sub51_3959)) .aClass239_Sub12_7243), bool ? 1 : 0); Class14_Sub2.method243(37); return true; }
a090e753-d95a-4015-8fa4-06688e959ef0
9
public static int[] maxProductIncreasingSubsequence(int[] input, int length){ int[] response = new int[length]; /** * product[n][l] is responsible for keeping max products of * product[i][3] means from i = 0 ..i in input[] , maximum product of a subsequence of 3 length * till i */ int product[][] = new int[input.length][length+1]; //reconstruction is crappy as always //we will keep back pointers int [][]reconstruct = new int[input.length][length+1]; //base conditions needs to setup for(int i =0; i<input.length; i++) { // subsequence of zero length will have 0 product product[i][0] = 0; //subsequence of 1 length will have the product equals to the number itself product[i][1] = input[i]; } //for reconstruction int maxProduct = 0; int maxIndex = -1; // goes from element 0 to n.. index of the number for(int i=0; i<product.length; i++) { // length of the subsequence for(int j = 2; j<=length; j++) { // this is to compare all smaller elements for(int k =0; k<i;k++){ if(input[k]<input[i]){ int productCalculatedByJ ; //checking whether product is optimal or not if(product[k][j] < input[i] * product[k][j-1]){ productCalculatedByJ = input[i]* product[k][j-1]; } else { productCalculatedByJ = product[k][j]; } if(product[i][j] < productCalculatedByJ){ // mark the node responsible for the maximum value reconstruct[i][j] = k; //update the sum product[i][j] = productCalculatedByJ; // this is to track the largest product and the index responsible for it if(maxProduct < product[i][j]){ maxProduct = product[i][j]; maxIndex = i; } } } } } } // reconstruction logic while(length>0){ response[length-1] = input[maxIndex]; maxIndex = reconstruct[maxIndex][length--]; } return response; }
2b84c0b3-b18b-4029-9d7b-1406de93a301
7
public void save(JavaPlugin plugin) { File file = new File(plugin.getDataFolder(), FILE); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } FileOutputStream fileStream = null; ObjectOutputStream objectStream = null; try { fileStream = new FileOutputStream(file); objectStream = new ObjectOutputStream(fileStream); objectStream.writeObject(this); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fileStream != null) { fileStream.close(); } if (objectStream != null) { objectStream.close(); } } catch (IOException e) { e.printStackTrace(); } } }
9a841b0e-38ea-48e5-801c-de27b85c2cc3
5
public static Object getNewObject(FileTypes type, String name){ //TODO add name to construct? if(type.equals(FileTypes.CODEX)){ return new Codex(); } else if(type.equals(FileTypes.CODEXITEM)){ return new CodexItem(); } else if(type.equals(FileTypes.FRAMES)){ return new Frames(); } else if(type.equals(FileTypes.ITEM)){ return new Item(); } else if(type.equals(FileTypes.OBJECT)){ return new SBObject(); } return new Object(); }
96d9db9b-028f-4052-9fa5-4435ad0166be
8
public void loadSettings(ComponentManager componentManager) { // get all our loaded classes Vector<Class<?>> classes = null; try { classes = getLoadedClasses(); } catch(Exception e) { Logger.error("Unhandled exception (%s): %s!", e.getClass().getName(), e.getMessage()); e.printStackTrace(); } // copy the data List<Class<?>> classList = null; synchronized(classes) { classList = new ArrayList<Class<?>>(classes); } // loop over all our classes for(Class<?> clazz: classList) { // and register their settings try { if(clazz.getPackage() != null) { registerSettings(clazz, componentManager); } } catch(Exception e) { Logger.error("Failed to load settings for class '%s': %s", clazz.getName(), e.getMessage()); e.printStackTrace(); } } }
8375ab9f-fe68-412e-afc3-2020850656a2
8
public static void main(String[] args) { Connection conn = null; Statement stat= null; ResultSet resultSet= null; try{ /* 1.注册数据库驱动, 不同的数据库要导入不同的驱动jar包。Driver就是这个包中的类。*/ /*---这种方式有两个不好的地方: * 1)查看Driver的源码,我们会发现在 new Driver()的时候,其实已经注册了一次驱动了。这样就造成注册了两次驱动。 * 2)这样写,让程序导入了com.mysql.jdbc.Driver包,程序的可扩展性下降了。如果要使用其它的数据库就要修改程序代码了。 * * DriverManager.registerDriver(new Driver()); * * 基于以上的考量,所以最后选择使用下面的方法。 通过反射机制来加载一个,给定全路径名的类。这样只要把字符串写入配置文件中,就可以不修改源代码了。*/ Class.forName("com.mysql.jdbc.Driver"); /* 2.连接数据库 */ conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_jdbc?user=root&password=root"); /* 其它数据库的URL写法。 * * Oracle数据库的写法: "jdbc:oracle:thin:@localhost:1521:sid" * SqlServer数据库的写法:"jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=sid" */ /* 3.获取传输器对象 */ stat = conn.createStatement(); /* 4.利用传输器将sql语句传输到数据库中去执行,并返回一个结果集。 */ resultSet = stat.executeQuery("SELECT * from person"); /* 5.遍历结果集,取出数据。 */ while (resultSet.next()){ String name = resultSet.getString("name"); int age = resultSet.getInt("age"); String addr = resultSet.getString("address"); String PhoneNumber = resultSet.getString("PhoneNumber"); System.out.println(name+" "+age+" "+addr+" "+PhoneNumber); } } catch (Exception e) { e.printStackTrace(); } finally{ /* 6.关闭连接、传输对象和结果集。 */ if(resultSet!=null){ try { resultSet.close(); } catch (Exception e) { e.printStackTrace(); }finally{ /* 手动将其引用指向null,java的内存清理机制最终会对其清除 */ resultSet = null; } } if(stat!=null){ try { stat.close(); } catch (Exception e) { e.printStackTrace(); }finally{ /* 手动将其引用指向null,java的内存清理机制最终会对其清除 */ stat = null; } } if(conn!=null){ try { conn.close(); } catch (Exception e) { e.printStackTrace(); }finally{ /* 手动将其引用指向null,java的内存清理机制最终会对其清除 */ conn = null; } } } }
98dc90b9-881a-406e-b7b3-925a3d4d6925
0
public String toString(){ return bins.toString(); }
24231c1d-7627-44ba-974c-584d30d3a003
6
public void merge(int[] arr, int p, int q, int r) { int length = arr.length; int[] tempArray = new int[length]; for (int i = 0; i < length; i++) { tempArray[i] = arr[i]; } int temp = p; int i = p, j = q + 1; for (; i <= q && j <= r;) { if (tempArray[i] < tempArray[j]) { arr[temp++] = tempArray[i]; i++; } else { // System.out.println("Array indexes p :"+p+" q :"+q+" r :"+r+" i :"+i+" j :"+j); n = n + (q + 1) - i; arr[temp++] = tempArray[j]; j++; } } while (i <= q) { arr[temp++] = tempArray[i]; i++; } while (j < r) { arr[temp++] = tempArray[j]; j++; } }
dde31d0b-8a79-446f-9e81-e87fd0a80061
6
static String toXml (String s) { int m=s.length(); H.clear(); for (int i=0; i<m; i++) { char c=s.charAt(i); switch(c) { case '<' : toH("&lt;"); break; case '>' : toH("&gt;"); break; case '&' : toH("&amp;"); break; case '\'' : toH("&apos;"); break; case '\"' : toH("&quot;"); break; default : H.append(c); } } return H.toString(); }
08aa1ce1-3656-4212-a11d-e80f2c67ab66
1
@Override public int compare(String s1, String s2) { assert s1 != null && s2 != null; return String.CASE_INSENSITIVE_ORDER.compare(s1, s2); }
673952c7-0af4-455b-8835-016ca443753b
1
public void testConstructor_ObjectStringEx6() throws Throwable { try { new LocalTime("10:20:30.040+04:00"); fail(); } catch (IllegalArgumentException ex) {} }
b7f732eb-8eb6-4d98-8dda-fb236f5a2532
0
public void addNeighbour(Agent a) { neighbours.add(a); }
5de642f2-89d4-43ff-9ccc-644d3651241e
3
public void drawRolloverTooltip(Graphics g){ g.setColor(Color.WHITE); g.setFont(new Font("Arial", Font.BOLD, 20)); g.drawString("Racial Turret", 605, 305); g.setFont(new Font("Arial", Font.PLAIN, 18)); g.drawString("Cost: "+totalCost +" Gold", 605, 330); g.drawString("Range: Moderate", 605, 355); g.drawString("Damage: None", 605, 380); g.drawString("Attack Speed: Very Low", 605, 405); if(playerRace == EARTH){ g.drawString("Special: Entomb", 605, 430); } else if(playerRace == WATER){ g.drawString("Special: Slow", 605, 430); } else if(playerRace == WIND){ g.drawString("Special: Knockback", 605, 430); } else{ g.drawString("Special: Stun", 605, 430); } }
d8500add-445f-420c-8bd6-6e6c5f4f5168
8
public Update createUpdate(com.hp.hpl.jena.update.Update arq, String uri) { if(arq instanceof UpdateModify) { return createModify((UpdateModify)arq, uri); } else if(arq instanceof UpdateClear) { return createClear((UpdateClear)arq, uri); } else if(arq instanceof UpdateCreate) { return createCreate((UpdateCreate)arq, uri); } else if(arq instanceof UpdateDeleteWhere) { return createDeleteWhere((UpdateDeleteWhere)arq, uri); } else if(arq instanceof UpdateDrop) { return createDrop((UpdateDrop)arq, uri); } else if(arq instanceof UpdateLoad) { return createLoad((UpdateLoad)arq, uri); } else if(arq instanceof UpdateDataDelete) { return createDeleteData((UpdateDataDelete)arq, uri); } else if(arq instanceof UpdateDataInsert) { return createInsertData((UpdateDataInsert)arq, uri); } else { throw new IllegalArgumentException("Unsupported SPARQL Update type for " + arq); } }
0846c6d6-9b73-40f2-9349-4f187f549cb3
4
private int jjMoveStringLiteralDfa7_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(5, old0, 0L); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(6, active0, 0L); return 7; } switch(curChar) { case 110: if ((active0 & 0x2000L) != 0L) return jjStartNfaWithStates_0(7, 13, 16); break; default : break; } return jjStartNfa_0(6, active0, 0L); }
6cca8dd1-1717-4387-9c08-ae8f3a9333f4
4
public static Collection<Class<?>> internalComponents(Class<?> model) { Collection<Class<?>> comps = new ArrayList<Class<?>>(); comps.add(model); internalComponents0(comps, model); return comps; }
7c467055-0fc8-45f3-83eb-f06c6b53fbc1
9
public static QuestionPower decode(String str) throws DecodeException { QuestionPower res = null; if (str.substring(0,14).compareTo("#QuestionPower") == 0) { res = new QuestionPower(); int i = 14; if (str.charAt(i) == '<') { while (str.charAt(i) != '>') { i++; } res.setOperand(Integer.valueOf(str.substring(15, i))); i++; int beginning = i; if (str.charAt(i) == '<') { while (str.charAt(i) != '>') { i++; } ArrayList<Integer> tmp_pow = decodePowers(str.substring(beginning+1,i)); res.setPowers(tmp_pow); i++; beginning = i; if (str.charAt(i) == '<') { while (str.charAt(i) != '>') { i++; } ArrayList<Character> tmp_opt = decodeOperators(str.substring(beginning+1,i)); assert tmp_opt.size() == tmp_opt.size()+1 : "incorrect size of operators table"; res.setOperators(tmp_opt); i++; beginning = i; if (str.charAt(i) == '<') { while (str.charAt(i) != '>') { i++; } int tmp_lth = Integer.valueOf(str.substring(beginning+1,i)); assert tmp_lth < 0 : "negative length"; res.setLength(tmp_lth); i++; str = str.substring(i); Question.decode(res, str); } else { res = null; throw new DecodeException(); } } else { res = null; throw new DecodeException(); } } else { res = null; throw new DecodeException(); } } else { res =null; throw new DecodeException(); } } else { res = null; throw new DecodeException(); } return res; }
1a3d7ce5-d943-44c4-88e0-dbfbfe46d8c4
3
public double interQuartileMean_as_double() { double mean = 0.0D; switch (type) { case 1: double[] dd = this.getArray_as_double(); mean = Stat.interQuartileMean(dd); break; case 12: BigDecimal[] bd = this.getArray_as_BigDecimal(); mean = (Stat.interQuartileMean(bd)).doubleValue(); bd = null; break; case 14: throw new IllegalArgumentException("Complex interquartile mean is not supported"); default: throw new IllegalArgumentException("This type number, " + type + ", should not be possible here!!!!"); } return mean; }
3819cb6f-28d1-4973-b6ac-d350c9773ca6
8
private void GLRender() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glRotatef(xRot,1 , 0, 0); glRotatef(-yRot, 0, 1, 0); glTranslatef(-camX, -camY, -camZ); RenderFrame(); // Axis glBegin(GL_LINES); glColor3d(1, 0, 0); glVertex3f(axis[0], axis[1], axis[2]); glVertex3f(axis[3], axis[4], axis[5]); glColor3d(0, 1, 0); glVertex3f(axis[6], axis[7], axis[8]); glVertex3f(axis[9], axis[10], axis[11]); glColor3d(0, 0, 1); glVertex3f(axis[12], axis[13], axis[14]); glVertex3f(axis[15], axis[16], axis[17]); glEnd(); // Draw Planes for(int i = 0 ; i < drawvecs.length; i++){ if(needWriting[i]){ glColor4d(color[i][0], color[i][1], color[i][2], alpha[i]); if (drawvecs[i][3] == null) { glBegin(GL_LINES); for(int j = 0 ; j < 2; j++){ glVertex3d(drawvecs[i][j].getX(), drawvecs[i][j].getY(), drawvecs[i][j].getZ()); } glEnd(); } } } for(int i = 0 ; i < drawvecs.length; i++){ if(needWriting[i]){ glColor4d(color[i][0], color[i][1], color[i][2], alpha[i]); if (drawvecs[i][3] != null) { glBegin(GL_QUADS); for(int j = 0 ; j < drawvecs[i].length; j++){ glVertex3d(drawvecs[i][j].getX(), drawvecs[i][j].getY(), drawvecs[i][j].getZ()); } glEnd(); } } } }
c2a35e5f-ddb3-4bc0-80e4-c0d564a25fa2
5
public int findCombinationsCount(int sum, int vals[]) { if (sum < 0) { return 0; } if (vals == null || vals.length == 0) { return 0; } int dp[] = new int[sum + 1]; dp[0] = 1; for (int i = 0; i < vals.length; ++i) { for (int j = vals[i]; j <= sum; ++j) { dp[j] =dp[j] + dp[j - vals[i]]; } } return dp[sum]; }
3329e847-7d07-43a4-b59f-982e90a125b5
5
@Override public void update(Observable o, Object arg) { if (arg != null && arg instanceof String && ((String) arg).contains("VS")) // View settings updates { if (activeGroup != null) m_container.remove(activeGroup); if (ViewPreferences.getInstance().getCenterView() == CenterView.TASK) { activeGroup = taskButtonGroup; m_container.add(activeGroup, BorderLayout.EAST); } else { activeGroup = calendarButtonGroup; m_container.add(activeGroup, BorderLayout.EAST); } m_container.validate(); // force to recalculate size of active ButtonGroup } else // application settings update { ApplicationSettings a = ApplicationSettings.getInstance(); weekView.setText(a.getLocalizedMessage("vtb.wv")); listView.setText(a.getLocalizedMessage("vtb.lv")); taskView.setText(a.getLocalizedMessage("vtb.tv")); addItem.setText(a.getLocalizedMessage("menu.add.calitem")); addCalendar.setText(a.getLocalizedMessage("menu.add.calendar")); importCalendar.setText(a.getLocalizedMessage("menu.imp.calendar")); addTask.setText(a.getLocalizedMessage("menu.add.task")); addTasklist.setText(a.getLocalizedMessage("menu.add.tasklist")); importTasklist.setText(a.getLocalizedMessage("menu.imp.tasklist")); } }
11532bcf-e1a6-488b-bba0-717181c6e9cd
6
public void changeMark() { if (this.markState == MarkState.unmarked) { this.markState = MarkState.flagged; try { Image icon = ImageIO.read(getClass().getResource("flagged.gif")); this.setIcon(new ImageIcon(icon)); } catch (IOException ex) { } } else if (this.markState == MarkState.flagged) { this.markState = MarkState.questioned; try { Image icon = ImageIO.read(getClass().getResource("questioned.gif")); this.setIcon(new ImageIcon(icon)); } catch (IOException ex) { } } else if (this.markState == MarkState.questioned) { this.markState = MarkState.unmarked; try { Image icon = ImageIO.read(getClass().getResource("unmarked.gif")); this.setIcon(new ImageIcon(icon)); } catch (IOException ex) { } } }
ef76199a-64d6-4275-b30c-97ed3c0b5a13
5
public boolean canBuyDevCard(int playerIndex) { Player player = serverModel.getPlayers().get(playerIndex); if (playingCommandsPreconditions(playerIndex) && player.getOre() > 0 && player.getWheat() > 0 && player.getSheep() > 0 && serverModel.getDeck().getTotalDevCardCount() > 0) { return true; } else { return false; } }
7d02c3ff-458a-44b3-b295-77c7f5f3ae31
1
public void startPoint(String name) { if (this.goalMap.containsKey(name)) { Calculator cal = (Calculator) this.goalMap.get(name); cal.setStartTime(Calendar.getInstance().getTimeInMillis()); } else { this.goalMap.put(name, new Calculator(name)); } }
1da7e543-3f52-46da-b79c-cee57d9d6b4e
0
public static void main(String[] args) { new ViewHandler(); }
40f60333-be9e-4dcd-bfea-c2b051160e2e
1
public void incRegister() { this.speicherzelle++; if(this.speicherzelle == 256) { this.speicherzelle = 0; // Überlauf } }
d62f8eca-1225-4d4d-9d5a-c9d63b3a1d5b
1
public void rewindNbytes(int N) { int bits = (N << 3); totbit -= bits; buf_byte_idx -= bits; if (buf_byte_idx<0) buf_byte_idx += BUFSIZE; }
952a831b-cdab-414c-915d-47f0e031dc92
2
public void terminateSimulation () { org.omg.CORBA.portable.InputStream $in = null; try { org.omg.CORBA.portable.OutputStream $out = _request ("terminateSimulation", false); $in = _invoke ($out); return; } catch (org.omg.CORBA.portable.ApplicationException $ex) { $in = $ex.getInputStream (); String _id = $ex.getId (); throw new org.omg.CORBA.MARSHAL (_id); } catch (org.omg.CORBA.portable.RemarshalException $rm) { terminateSimulation ( ); } finally { _releaseReply ($in); } } // terminateSimulation
4e5d5d35-871b-47b9-a814-799edaa0f628
4
private void loadFileNumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadFileNumActionPerformed try { String newLine = "\\n"; String sourceContents; /*/Code to read from file File inputFile = new File(inputFileName); FileInputStream in = new FileInputStream(inputFile); byte bt[] = new byte[(int)inputFile.length()]; in.read(bt); String sourceContents = new String(bt); in.close();*/ sourceContents = jTextPaneSource.getText(); if(sourceContents.isEmpty()){ JOptionPane.showMessageDialog(rootPane, "Please Load the File with out Line Numbers First"); return; } jTextPaneSource.setText(""); DefaultStyledDocument sourceDoc = (DefaultStyledDocument) jTextPaneSource.getDocument(); //line numbers sourceContents = "1 " + sourceContents; StringBuffer sourceBuffer = new StringBuffer(sourceContents); //find offsets Pattern pCPName = Pattern.compile(newLine, Pattern.MULTILINE); Matcher cpMatcher = pCPName.matcher(sourceBuffer); ArrayList offEnd = new ArrayList(); int count = 0; while (cpMatcher.find()) { offEnd.add(cpMatcher.end()); } //Insert line num int endLineVal = offEnd.size() - 1; count = offEnd.size() + 1; for (int i = endLineVal; i >= 0; --i) { String insertString = count + " "; int endOff = Integer.parseInt(offEnd.get(i).toString()); sourceBuffer.insert(endOff, insertString); --count; } String sourceContentsLines = new String(sourceBuffer); //Clear text area jTextPaneSource.setText(""); //Display text read from file sourceDoc.insertString(0, sourceContentsLines, null); //jTextPaneSource.setText(sourceContents); jTextPaneSource.setCaretPosition(0); } catch (BadLocationException ex) { jTextPaneSource.setText(""); JOptionPane.showMessageDialog(jScrollPaneText, "Error: " + ex, "Applet Error", JOptionPane.ERROR_MESSAGE); } }//GEN-LAST:event_loadFileNumActionPerformed
72d8e77f-ef70-4a9a-ad0b-3da5f93e4e72
5
public boolean add(Item input) { if (isFull()) return false; if (input == null) return false; for (int h = 0; h < height; h++) { for (int w = 0; w < width; w++) { if (inventory[h][w] == null) { inventory[h][w] = input; return true; } } } return false; }
4fce7c29-9804-41bc-9f68-31af504eb1e7
6
public void run() { try { CookieManager.setDefault(Client.cookieManager); //boolean authbool = messenger.authenticate("Lukew4lker", pwInput); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //System.out.print("Enter String"); System.out.println("Enter Username"); System.out.println(); String username = br.readLine(); System.out.println("Enter Password"); System.out.println(); String p = br.readLine(); //Console console = System.console(); boolean authbool = poller.messenger.authenticate(username, p.toCharArray()); System.in.mark(0); (new Thread(new InputChat())).start(); System.out.println(authbool); messenger.channel = 8613406; //client.channel= 3; parser pars = new parser(); /* The following three lines of code are are how you recreate * the SortedMap made by the parser, see parser.java. */ SortedMap[] b = (pars.parser(messenger.poll())); SortedMap Userlist = new TreeMap(b[0]); SortedMap Messagelist = new TreeMap(b[1]); LinkedList c = new LinkedList(Messagelist.values()); Iterator I = c.iterator(); String[] objects = new String[4]; while (I.hasNext()) { objects = (String[]) (Object[]) I.next(); System.out.println("[" + objects[1] + "] " + objects[2] + ": " + objects[3]); } //Review to figure out how to read messages from SortedMap. //System.out.println("Entryset: " + Messagelist.keySet()); //String[] objects = (String[]) (Object[]) (Messagelist.get(Messagelist.lastKey())); //System.out.println("[" + objects[1] + "] " + objects[2] + ": " + objects[3]); //Put console link here. System.gc(); while (true) { /* * * * */ b = (pars.parser(messenger.poll())); Userlist.clear(); Messagelist.clear(); Userlist = b[0]; Messagelist = b[1]; try { objects = (String[]) Messagelist.get(Messagelist.lastKey()); System.out.println("[" + objects[1] + "] " + objects[2] + ": " + objects[3]); } catch (NoSuchElementException ex) { } } } catch (MalformedURLException ex) { Logger.getLogger(poller.class.getName()).log(Level.SEVERE, null, ex); } catch (JSONException ex) { Logger.getLogger(poller.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(poller.class.getName()).log(Level.SEVERE, null, ex); } }
5a015a4b-7784-4b99-8376-228dccc1067d
2
private static long sumOfPred(int i, int j){ long sum = 0; if (i>0){ sum+=routes[i-1][j]; } if (j>0){ sum+=routes[i][j-1]; } return sum; }
69dffc77-8cce-40b0-8805-4c709fcb350a
3
public void handleClick(int x, int y) { for(int i = 0; i < Sidebar.MAX_ELEMS; i++) { if((elements[i] != null) && (y >= (elementPos[i]))) { elements[i].handleClick((int)(x - Sidebar.xPos_), (int)(y - elementPos[i])); return; } } }
29705115-bef5-46f0-a65d-f97b9857cd33
0
@Override public String getNationality() { return super.getNationality(); }
4860562e-3351-442b-9a5e-974a84703179
8
public static void checkloginstatus(String num, String downloadpath){ try{ HWND targetwindow=User32.FindWindow("ZocMainWindow", "COM"+num+" [evaluation mode]");//find the ZOC window with specific port number by its class and name HWND edit=User32.FindWindowEx(targetwindow, new HWND(0),"ZocTerminalArea", null);// find the input terminal sub-window of the ZOC main window. User32.SendMessage(edit, new UINT(0x102), new WPARAM(10), new LPARAM(1)); // simulate a press on "enter" Thread.sleep(200);//wait for response, the time may change print(edit,"/usr/lib/leeonl/sensors/led_off.sh"); Thread.sleep(500); print(edit,"/usr/lib/leeonl/sensors/led_green.sh"); Thread.sleep(500); print(edit,"sz /usr/lib/leeonl/sensors/reset_detec1.txt"); Thread.sleep(2000); }catch (Exception ex){ ex.printStackTrace(); } File outputfile = new File(downloadpath+"\\login_status.txt"); File downloadfile = new File(downloadpath+"\\reset_detec1.txt"); if (downloadfile.exists()){ System.out.println("Log in Succeed!"); downloadfile.delete(); if (outputfile.exists()){ outputfile.delete(); } } else { if (!outputfile.exists()){ try { outputfile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } ArrayList<String> content = new ArrayList<String>(); try{ BufferedReader br = new BufferedReader(new FileReader(outputfile)); String line=""; while((line=br.readLine())!=null){ content.add(line); } br.close(); if (content.size()<2){ BufferedWriter bw = new BufferedWriter(new FileWriter(outputfile,true)); bw.write("1\r\n"); bw.flush(); bw.close(); System.out.println("Log in Failed. Try again!"); } else { System.out.println("Log in Fail for 3 times!"); } }catch (Exception ex){ ex.printStackTrace(); } } }
be033db8-49a1-48d0-973b-35cacd7e1c50
7
private Object getValue(Object item) { Object value = null; if(item != null) { if(item instanceof JTextField) { value = ((JTextField) item).getText(); } else if(item instanceof JSpinner) { value = ((JSpinner) item).getValue(); } else if(item instanceof JTextArea) { value = ((JTextArea) item).getText(); } else if(item instanceof JCheckBox) { value = ((JCheckBox) item).isSelected(); } else if(item instanceof JRadioButton) { value = ((JRadioButton) item).isSelected(); } if(value == null) { System.err.println("Null value! Element = " + item); } } return value; }
787cd5a6-f823-45c4-af7c-eac2f313804e
4
public void printXProportion(String xProportionFile, ArrayList<_Doc> docList) { System.out.println("x proportion for parent doc"); try { PrintWriter pw = new PrintWriter(new File(xProportionFile)); for (_Doc d : docList) { if (d instanceof _ParentDoc) { for (_ChildDoc doc : ((_ParentDoc) d).m_childDocs) { _ChildDoc4BaseWithPhi cDoc = (_ChildDoc4BaseWithPhi) doc; pw.print(d.getName() + "\t"); pw.print(cDoc.getName() + "\t"); pw.print(cDoc.m_xProportion[0] + "\t"); pw.print(cDoc.m_xProportion[1]); pw.println(); } } } pw.flush(); pw.close(); } catch (Exception e) { e.printStackTrace(); } }
6c3f3b1d-ec3b-4f6c-a0f7-e9574b77f6a1
6
public void actionPerformed(ActionEvent ae) { if ("pump".equals(ae.getActionCommand())){ chart.pump = ((JCheckBox)ae.getSource()).isSelected(); if (chart.pump){ optInc.setEnabled(true); optDec.setEnabled(true); } else{ optInc.setEnabled(false); optDec.setEnabled(false); } } else if ("inc".equals(ae.getActionCommand())) chart.pump_increase = true; else if ("dec".equals(ae.getActionCommand())) chart.pump_increase = false; else if ("up".equals(ae.getActionCommand())) chart.sa_dir = BaseTableContainer.UP; else if ("down".equals(ae.getActionCommand())) chart.sa_dir = BaseTableContainer.DOWN; }
9ee8a5f2-f855-4c0a-b59a-eb08b9876b8d
7
public boolean checkConnection(TagSet tagSet, int tag1, int tag2, int len1, int len2, int typeOfTag2) { String tag1Name = tagSet.getTagName(tag1); String tag2Name = tagSet.getTagName(tag2); if ((tag1Name.startsWith("nc") || tag1Name.charAt(0) == 'f') && tag2Name.charAt(0) == 'n') { if (tag2Name.startsWith("nq")) { return false; } else if (len1 < 4 || len2 < 2) { return false; } } // System.err.println(tag1Name + "\t" + tag2Name + ": " + connectionTable[tag1][tag2] + " " + tagSet.checkTagType(nextTagType, tag2)); return connectionTable[tag1][tag2] && tagSet.checkTagType(typeOfTag2, tag2); }
91483ea0-5ae8-405b-b703-a9b2b32c1642
9
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if(!(affected instanceof MOB)) return; final MOB mob=(MOB)affected; if((mob.location()!=null) &&(mob.location().domainType()!=Room.DOMAIN_OUTDOORS_JUNGLE) &&(mob.location().domainType()!=Room.DOMAIN_OUTDOORS_SWAMP) &&(mob.location().domainType()!=Room.DOMAIN_OUTDOORS_WOODS)) { unInvoke(); mob.recoverPhyStats(); } if((msg.source()==affected) &&(msg.sourceMajor(CMMsg.MASK_MALICIOUS)) &&(msg.source().isInCombat()) &&(msg.source().rangeToTarget()<=0)) { unInvoke(); mob.recoverPhyStats(); } return; }
75ad5465-a66b-465b-92f1-8ca6ebcd5c98
7
public void drawString(int column, int row, String string, ScreenCharacterStyle... styles) { if(column >= areaSize.getColumns() || row >= areaSize.getRows() || string == null) return; string = TabBehaviour.ALIGN_TO_COLUMN_4.replaceTabs(string, column + topLeft.getColumn()); if(string.length() + column > areaSize.getColumns()) string = string.substring(0, areaSize.getColumns() - column); EnumSet<ScreenCharacterStyle> stylesSet = EnumSet.noneOf(ScreenCharacterStyle.class); if(styles != null && styles.length != 0) stylesSet = EnumSet.copyOf(Arrays.asList(styles)); if(currentlyBold) stylesSet.add(ScreenCharacterStyle.Bold); screen.putString(column + topLeft.getColumn(), row + topLeft.getRow(), string, foregroundColor, backgroundColor, stylesSet); }
cf59e8ed-0686-442d-bcd1-ab48da6b9261
1
@Override Integer redactEntity(Criteria criteria, AbstractDao dao) throws DaoException { Integer idOrder = (Integer) criteria.getParam(DAO_ID_ORDER); if (idOrder != null) { return updateOrder(criteria, dao); } else { return createOrder(criteria, dao); } }
027ecf33-3ec7-4ea7-a1dc-ca77355e5089
2
public synchronized void reset() { for(int i = 0; i < receivedPackets.length; i++) receivedPackets[i] = null; receivedPacketHistoryInt = 0; lastReceivedPacketIndex = -1; lastReceivedPacketSequenceNumber = Packet.SEQUENCE_NUMBER_NOT_APPLICABLE; for(int i = 0; i < sentPackets.length; i++) sentPackets[i] = null; lastSentPacketIndex = -1; lastSentPacketSequenceNumber = Packet.SEQUENCE_NUMBER_NOT_APPLICABLE; lastSentPacketCheckedForDelivery = Packet.SEQUENCE_NUMBER_NOT_APPLICABLE; }
ef8474cd-50e7-463e-bd07-788d0d1d00cd
0
public CheckResultMessage check34(int day) { return checkReport.check34(day); }
f9383bc6-3cdf-4b5a-a821-ca313301e170
7
public void commandAction(Command c, Displayable d) { if (d == remotedeviceui && c.getLabel().equals("Search")) { startInquiry(discoveryMode, serviceUUIDs); } else if (d == remotedeviceui && c.getLabel().equals("Back")) { callback.commandAction(BACK, remotedeviceui); } else if (d == remotedeviceui && c.getLabel().equals("Select")) { // get selected device selectedDevice = remotedeviceui.getSelectedIndex(); RemoteDevice remoteDevice = (RemoteDevice) devices.elementAt(selectedDevice); // remove all existing record first services.removeAllElements(); try { agent.searchServices(null, serviceUUIDs, remoteDevice, new Listener()); // tell callback device selected display.callSerially(new Worker(ID_DEVICE_SELECTED)); } catch (BluetoothStateException ex) { ex.printStackTrace(); } } }
76c44a5c-3635-42d4-991e-02feecc5144c
6
public static void startupStellaIn() { { Object old$Module$000 = Stella.$MODULE$.get(); Object old$Context$000 = Stella.$CONTEXT$.get(); try { Native.setSpecial(Stella.$MODULE$, Stella.$STELLA_MODULE$); Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get()))); if (Stella.currentStartupTimePhaseP(2)) { Stella.KWD_PUBLIC_SLOTS = ((Keyword)(GeneralizedSymbol.internRigidSymbolWrtModule("PUBLIC-SLOTS", null, 2))); Stella.KWD_SLOTS = ((Keyword)(GeneralizedSymbol.internRigidSymbolWrtModule("SLOTS", null, 2))); Stella.KWD_PUBLIC_METHODS = ((Keyword)(GeneralizedSymbol.internRigidSymbolWrtModule("PUBLIC-METHODS", null, 2))); Stella.KWD_METHODS = ((Keyword)(GeneralizedSymbol.internRigidSymbolWrtModule("METHODS", null, 2))); Stella.SYM_STELLA_SETTER = ((Symbol)(GeneralizedSymbol.internRigidSymbolWrtModule("SETTER", null, 0))); Stella.KWD_SETTERp = ((Keyword)(GeneralizedSymbol.internRigidSymbolWrtModule("SETTER?", null, 2))); Stella.SYM_STELLA_DEFAULT_OPTION_HANDLER = ((Symbol)(GeneralizedSymbol.internRigidSymbolWrtModule("DEFAULT-OPTION-HANDLER", null, 0))); Stella.SYM_STELLA_STARTUP_STELLA_IN = ((Symbol)(GeneralizedSymbol.internRigidSymbolWrtModule("STARTUP-STELLA-IN", null, 0))); } if (Stella.currentStartupTimePhaseP(4)) { Stella.$UNSUPPORTED_EXTERNAL_SLOT_OPTIONS$ = List.list(Cons.cons(Stella.KWD_ALLOCATION, Cons.cons(Stella.KWD_INITIALLY, Cons.cons(Stella.KWD_CONTEXT_SENSITIVEp, Cons.cons(Stella.KWD_HARDWIREDp, Stella.NIL))))); } if (Stella.currentStartupTimePhaseP(6)) { Stella.finalizeClasses(); } if (Stella.currentStartupTimePhaseP(7)) { Stella.defineFunctionObject("PERMANENTIFY-FORM", "(DEFUN (PERMANENTIFY-FORM OBJECT) ((FORM OBJECT)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella_Object", "permanentifyForm", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object")}), null); Stella.defineFunctionObject("TRANSIENTIFY-FORM", "(DEFUN (TRANSIENTIFY-FORM OBJECT) ((FORM OBJECT)) :GLOBALLY-INLINE? TRUE :PUBLIC? TRUE (RETURN (COPY-CONS-TREE FORM)))", Native.find_java_method("edu.isi.stella.Stella_Object", "transientifyForm", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object")}), null); Stella.defineFunctionObject("STRINGIFY-IN-MODULE", "(DEFUN (STRINGIFY-IN-MODULE STRING) ((TREE OBJECT) (MODULE MODULE)) :DOCUMENTATION \"Stringify a parse `tree' relative to `module', or\n`*module*' if no module is specified.\" :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella_Object", "stringifyInModule", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Module")}), null); Stella.defineFunctionObject("UNSTRINGIFY-IN-MODULE", "(DEFUN (UNSTRINGIFY-IN-MODULE OBJECT) ((STRING STRING) (MODULE MODULE)) :DOCUMENTATION \"Unstringify relative to `module', or `*MODULE*' if no\nmodule is specified.\" :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella", "unstringifyInModule", new java.lang.Class [] {Native.find_java_class("java.lang.String"), Native.find_java_class("edu.isi.stella.Module")}), null); Stella.defineFunctionObject("UNSTRINGIFY-STELLA-SOURCE", "(DEFUN (UNSTRINGIFY-STELLA-SOURCE OBJECT) ((SOURCE STRING) (MODULE MODULE)) :DOCUMENTATION \"Unstringify a STELLA `source' string relative to `module',\nor `*MODULE*' if no module is specified. This function allocates transient\nobjects as opposed to `unstringify-in-module' or the regular `unstringify'.\" :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella", "unstringifyStellaSource", new java.lang.Class [] {Native.find_java_class("java.lang.String"), Native.find_java_class("edu.isi.stella.Module")}), null); Stella.defineFunctionObject("COLLECT-FEATURE-LIST", "(DEFUN (COLLECT-FEATURE-LIST (LIST OF GENERALIZED-SYMBOL)) ((TREE OBJECT)))", Native.find_java_method("edu.isi.stella.Stella_Object", "collectFeatureList", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object")}), null); Stella.defineFunctionObject("COLLECT-KEY-VALUE-LIST", "(DEFUN (COLLECT-KEY-VALUE-LIST (KEY-VALUE-LIST OF GENERALIZED-SYMBOL OBJECT)) ((TREE OBJECT)))", Native.find_java_method("edu.isi.stella.Stella_Object", "collectKeyValueList", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object")}), null); Stella.defineFunctionObject("DEFINE-INLINE-METHOD", "(DEFUN (DEFINE-INLINE-METHOD METHOD-SLOT) ((NAME SYMBOL) (PARAMETERSANDBODY CONS)))", Native.find_java_method("edu.isi.stella.Symbol", "defineInlineMethod", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Symbol"), Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("HELP-DEFINE-CLASS-FROM-PARSE-TREE", "(DEFUN (HELP-DEFINE-CLASS-FROM-PARSE-TREE CLASS) ((PARSETREE CONS) (STRINGIFIEDSOURCE STRING)))", Native.find_java_method("edu.isi.stella.Cons", "helpDefineClassFromParseTree", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("DEFINE-STORAGE-SLOT-FROM-PARSE-TREE", "(DEFUN (DEFINE-STORAGE-SLOT-FROM-PARSE-TREE STORAGE-SLOT) ((SLOTDEF CONS) (OWNER TYPE)))", Native.find_java_method("edu.isi.stella.Cons", "defineStorageSlotFromParseTree", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("edu.isi.stella.Surrogate")}), null); Stella.defineFunctionObject("RECORD-SLOT-HOME-MODULE", "(DEFUN (RECORD-SLOT-HOME-MODULE MODULE) ((SELF SLOT)))", Native.find_java_method("edu.isi.stella.Slot", "recordSlotHomeModule", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Slot")}), null); Stella.defineFunctionObject("EXPLICITLY-QUALIFIED-NAME?", "(DEFUN (EXPLICITLY-QUALIFIED-NAME? BOOLEAN) ((NAME GENERALIZED-SYMBOL) (DEFINITIONMODULE MODULE)))", Native.find_java_method("edu.isi.stella.GeneralizedSymbol", "explicitlyQualifiedNameP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.GeneralizedSymbol"), Native.find_java_class("edu.isi.stella.Module")}), null); Stella.defineFunctionObject("GET-IDENTICAL-CLASS", "(DEFUN (GET-IDENTICAL-CLASS CLASS) ((CLASSNAME STRING) (STRINGIFIEDSOURCE STRING)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella", "getIdenticalClass", new java.lang.Class [] {Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("DEFINE-CLASS-FROM-PARSE-TREE", "(DEFUN (DEFINE-CLASS-FROM-PARSE-TREE CLASS) ((PARSETREE CONS)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Cons", "defineClassFromParseTree", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("DEFINE-CLASS-FROM-STRINGIFIED-SOURCE", "(DEFUN (DEFINE-CLASS-FROM-STRINGIFIED-SOURCE CLASS) ((CLASSNAME STRING) (STRINGIFIEDSOURCE STRING)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella", "defineClassFromStringifiedSource", new java.lang.Class [] {Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("EXTRACT-OPTIONS", "(DEFUN (EXTRACT-OPTIONS CONS) ((TREE CONS) (OPTIONSTABLE KEY-VALUE-LIST)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Cons", "extractOptions", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("edu.isi.stella.KeyValueList")}), null); Stella.defineFunctionObject("DESTRUCTURE-DEFMETHOD-TREE", "(DEFUN (DESTRUCTURE-DEFMETHOD-TREE OBJECT CONS CONS) ((METHOD-TREE CONS) (OPTIONS-TABLE KEY-VALUE-LIST)) :PUBLIC? TRUE :DOCUMENTATION \"Return three parse trees representing the name,\nparameters, and code body of the parse tree `method-tree'. Fill\n`options-table' with a dictionary of method options.\nStorage note: Options are treated specially because the other return\nvalues are subtrees of `method-tree', while `options-table' is a newly-created\ncons tree. Note also, the parameter and body trees are destructively\nremoved from `method-tree'.\")", Native.find_java_method("edu.isi.stella.Cons", "destructureDefmethodTree", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("edu.isi.stella.KeyValueList"), Native.find_java_class("[Ljava.lang.Object;")}), null); Stella.defineFunctionObject("YIELD-SETTER-METHOD-NAME", "(DEFUN (YIELD-SETTER-METHOD-NAME SYMBOL) ((METHODNAME SYMBOL)))", Native.find_java_method("edu.isi.stella.Symbol", "yieldSetterMethodName", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Symbol")}), null); Stella.defineFunctionObject("DESTRUCTURE-METHOD-NAME-TREE", "(DEFUN (DESTRUCTURE-METHOD-NAME-TREE SYMBOL CONS) ((NAMETREE OBJECT)))", Native.find_java_method("edu.isi.stella.Stella_Object", "destructureMethodNameTree", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("[Ljava.lang.Object;")}), null); Stella.defineFunctionObject("IN-PLACE-NORMALIZE-METHOD-OPTIONS", "(DEFUN IN-PLACE-NORMALIZE-METHOD-OPTIONS ((METHODOPTIONS KEYWORD-KEY-VALUE-LIST) (METHODNAME SYMBOL)))", Native.find_java_method("edu.isi.stella.KeywordKeyValueList", "inPlaceNormalizeMethodOptions", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.KeywordKeyValueList"), Native.find_java_class("edu.isi.stella.Symbol")}), null); Stella.defineFunctionObject("GET-FUNCTION-WITH-IDENTICAL-SIGNATURE", "(DEFUN (GET-FUNCTION-WITH-IDENTICAL-SIGNATURE METHOD-SLOT) ((NAME SYMBOL) (STRINGIFIEDSOURCE STRING)))", Native.find_java_method("edu.isi.stella.Symbol", "getFunctionWithIdenticalSignature", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Symbol"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("GET-METHOD-WITH-IDENTICAL-SIGNATURE", "(DEFUN (GET-METHOD-WITH-IDENTICAL-SIGNATURE METHOD-SLOT) ((NAME SYMBOL) (PARAMETERSTREE CONS) (STRINGIFIEDSOURCE STRING)))", Native.find_java_method("edu.isi.stella.Symbol", "getMethodWithIdenticalSignature", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Symbol"), Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("HELP-DEFINE-METHOD-FROM-PARSE-TREE", "(DEFUN (HELP-DEFINE-METHOD-FROM-PARSE-TREE METHOD-SLOT BOOLEAN) ((INPUTTREE CONS) (STRINGIFIEDSOURCE STRING)))", Native.find_java_method("edu.isi.stella.Cons", "helpDefineMethodFromParseTree", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("java.lang.String"), Native.find_java_class("[Ljava.lang.Object;")}), null); Stella.defineFunctionObject("DEFINE-METHOD-FROM-PARSE-TREE", "(DEFUN (DEFINE-METHOD-FROM-PARSE-TREE METHOD-SLOT) ((PARSETREE CONS)))", Native.find_java_method("edu.isi.stella.Cons", "defineMethodFromParseTree", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("STRINGIFY-METHOD-SIGNATURE", "(DEFUN (STRINGIFY-METHOD-SIGNATURE STRING) ((PARSETREE CONS)))", Native.find_java_method("edu.isi.stella.Cons", "stringifyMethodSignature", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("STRINGIFY-METHOD-BODY?", "(DEFUN (STRINGIFY-METHOD-BODY? BOOLEAN) ((METHOD METHOD-SLOT)))", Native.find_java_method("edu.isi.stella.MethodSlot", "stringifyMethodBodyP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.MethodSlot")}), null); Stella.defineFunctionObject("DEFINE-METHOD-FROM-STRINGIFIED-SOURCE", "(DEFUN (DEFINE-METHOD-FROM-STRINGIFIED-SOURCE METHOD-SLOT) ((METHODNAME STRING) (CLASSNAME STRING) (STRINGIFIEDSOURCE STRING)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella", "defineMethodFromStringifiedSource", new java.lang.Class [] {Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("DEFINE-METHOD-OBJECT", "(DEFUN DEFINE-METHOD-OBJECT ((DEFINITION STRING) (CODE METHOD-CODE) (WRAPPERCODE METHOD-CODE)))", Native.find_java_method("edu.isi.stella.Stella", "defineMethodObject", new java.lang.Class [] {Native.find_java_class("java.lang.String"), Native.find_java_class("java.lang.reflect.Method"), Native.find_java_class("java.lang.reflect.Method")}), null); Stella.defineFunctionObject("DEFINE-EXTERNAL-SLOT-FROM-PARSE-TREE", "(DEFUN (DEFINE-EXTERNAL-SLOT-FROM-PARSE-TREE STORAGE-SLOT) ((PARSETREE CONS)))", Native.find_java_method("edu.isi.stella.Cons", "defineExternalSlotFromParseTree", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons")}), null); Stella.defineFunctionObject("DEFINE-EXTERNAL-SLOT-FROM-STRINGIFIED-SOURCE", "(DEFUN (DEFINE-EXTERNAL-SLOT-FROM-STRINGIFIED-SOURCE STORAGE-SLOT) ((STRINGIFIEDSOURCE STRING)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella", "defineExternalSlotFromStringifiedSource", new java.lang.Class [] {Native.find_java_class("java.lang.String")}), null); Stella.defineFunctionObject("LOOKUP-SLOT-FROM-OPTION-KEYWORD", "(DEFUN (LOOKUP-SLOT-FROM-OPTION-KEYWORD STORAGE-SLOT) ((OWNER TYPE) (KEYWORD KEYWORD)))", Native.find_java_method("edu.isi.stella.Surrogate", "lookupSlotFromOptionKeyword", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Surrogate"), Native.find_java_class("edu.isi.stella.Keyword")}), null); Stella.defineFunctionObject("LOOKUP-OPTION-HANDLER", "(DEFUN (LOOKUP-OPTION-HANDLER METHOD-SLOT) ((SLOT STORAGE-SLOT)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.StorageSlot", "lookupOptionHandler", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.StorageSlot")}), null); Stella.defineFunctionObject("RUN-OPTION-HANDLER?", "(DEFUN (RUN-OPTION-HANDLER? BOOLEAN) ((OBJECT OBJECT) (OPTION KEYWORD) (VALUETREE OBJECT)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella.Stella_Object", "runOptionHandlerP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Keyword"), Native.find_java_class("edu.isi.stella.Stella_Object")}), null); Stella.defineFunctionObject("DEFAULT-OPTION-HANDLER", "(DEFUN DEFAULT-OPTION-HANDLER ((SELF OBJECT) (SLOT STORAGE-SLOT) (TREE OBJECT)))", Native.find_java_method("edu.isi.stella.Stella_Object", "defaultOptionHandler", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.StorageSlot"), Native.find_java_class("edu.isi.stella.Stella_Object")}), null); Stella.defineFunctionObject("STARTUP-STELLA-IN", "(DEFUN STARTUP-STELLA-IN () :PUBLIC? TRUE)", Native.find_java_method("edu.isi.stella._StartupStellaIn", "startupStellaIn", new java.lang.Class [] {}), null); { MethodSlot function = Symbol.lookupFunction(Stella.SYM_STELLA_STARTUP_STELLA_IN); KeyValueList.setDynamicSlotValue(function.dynamicSlots, Stella.SYM_STELLA_METHOD_STARTUP_CLASSNAME, StringWrapper.wrapString("_StartupStellaIn"), Stella.NULL_STRING_WRAPPER); } } if (Stella.currentStartupTimePhaseP(8)) { Stella.finalizeSlots(); Stella.cleanupUnfinalizedClasses(); } if (Stella.currentStartupTimePhaseP(9)) { Stella_Object.inModule(((StringWrapper)(Stella_Object.copyConsTree(StringWrapper.wrapString("/STELLA"))))); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *REDEFINE-IDENTICAL-CLASSES?* BOOLEAN FALSE :DOCUMENTATION \"If `true', always redefine classes, even if an\n identical class exists\")"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *UNSUPPORTED-EXTERNAL-SLOT-OPTIONS* (LIST OF KEYWORD) (LIST :ALLOCATION :INITIALLY :CONTEXT-SENSITIVE? :HARDWIRED?))"); Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *DEFAULT-OPTION-HANDLER* METHOD-SLOT NULL)"); Stella.$DEFAULT_OPTION_HANDLER$ = Symbol.lookupFunction(Stella.SYM_STELLA_DEFAULT_OPTION_HANDLER); } } finally { Stella.$CONTEXT$.set(old$Context$000); Stella.$MODULE$.set(old$Module$000); } } }
8190e4ef-eeef-484f-b488-e1ff81dd8363
9
public void getBalances( SimpleDate asOfWhen, boolean force ) { // if we're up to date, there is nothing to do if (upToDate && !force) return; // reset all summary amounts to zero initBal = 0; totCredits = 0; totBudget = 0; totDebits = 0; finalBal = 0; // if we have no ledger entries, nothing to do if (firstElement == null) return; // if no date has been specified, use 1/1 if (asOfWhen == null) { asOfWhen = new SimpleDate( firstElement.entry.date.year, 1, 1 ); } // walk the entire ledger // accumulating each amount against proper balance for ( LedgerL thisElement = firstElement; thisElement != null; thisElement=thisElement.nextElement ) { if (thisElement.ignore) continue; if ( thisElement.entry.date.before(asOfWhen) ) { initBal += thisElement.entry.amount; } else if (thisElement.entry.amount < 0) { totDebits += thisElement.entry.amount; } else { if (thisElement.entry.description.equals( BUDGET_DESCRIPTION )) totBudget += thisElement.entry.amount; else totCredits += thisElement.entry.amount; } finalBal += thisElement.entry.amount; } upToDate = true; }
233e03b0-70d6-43dd-a97f-7a77eda3bef5
1
@Override public void execute() { if (this.from.distanceBetweenFile(this.to) == 2) { // King moves right (file difference is positive) this.rookFrom = board.getField('h', this.from.rank); this.rookTo = board.getField('e', this.from.rank); // Rook moves left } else { this.rookFrom = board.getField('a', this.from.rank); this.rookTo = board.getField('c', this.from.rank); // Rook moves right } this.rook = this.rookFrom.getPiece(); this.from.removePiece(this.piece); this.to.addPiece(this.piece); this.rookFrom.removePiece(this.rook); this.rookTo.addPiece(this.rook); this.piece.increaseMoveCount(); this.rook.increaseMoveCount(); }
21533f6a-357f-4fad-a3db-abff2679e0f5
4
private String toString(double number) { String result=""; if (Double.toString(number).equals("NaN")||Double.toString(number).equals("Infinity")) { result="Error"; }else{ result=Double.toString(number); //if it's an integer, remove ".0" if (result.substring(result.length()-2,result.length()).equals(".0")) { result=result.substring(0,result.length()-2); } //get rid of negative zero if (result.equals("-0")) { result="0"; } } return result; }
0a058c0d-faa8-4637-b44e-030c3f893e57
4
public int _createKey(int key, String subkey) throws RegistryErrorException { try { int result[] = (int[])createKey.invoke(null, new Object[] {new Integer(key), getString(subkey)}); if(result[ERROR_CODE] == ERROR_SUCCESS) return result[NATIVE_HANDLE]; else return -1; } catch (InvocationTargetException ex) { throw new RegistryErrorException(ex.getMessage()); } catch (IllegalArgumentException ex) { throw new RegistryErrorException(ex.getMessage()); } catch (IllegalAccessException ex) { throw new RegistryErrorException(ex.getMessage()); } }
b6ecdbb0-c10b-45ec-a1fc-18fba57c915d
4
@Override public void paintComponent(Graphics g) { super.paintComponent(g); int bx = (camera.getX() < 0) ? 0 : (int) camera.getX(); int by = (camera.getY() < 0) ? 0 : (int) camera.getY(); int ox = -1 * (bx - (int) camera.getX()); int oy = -1 * (by - (int) camera.getY()); drawMap(g); drawGameObjects(g); for (Player p : players) { p.draw(g); } g.clipRect(0, 0, getWidth(), getHeight()); g.drawImage(uiHealth, 0, 0, 221, 81, null); g.drawImage(healthBar, 83, 17, 26 * player.getHealth(), 12, null); if (!isAlive) { timer.stop(); g.setColor(Color.red); g.setFont(new Font("Sherif", 1, 50)); g.drawString("YOU DIED!", getWidth() / 2 - 50, getHeight() / 2); g.drawString("Time survived : " + time, getWidth() / 2 - 46, getHeight() / 2 + 50); } }
8e0dd808-2143-4bd0-8b1c-06a0c4aa272e
9
public List<GeneratedImage> buildCreatedFiles() throws IOException, InterruptedException { boolean error = false; final List<GeneratedImage> result = new ArrayList<GeneratedImage>(); for (File f : dir.listFiles()) { if (error) { continue; } if (f.isFile() == false) { continue; } if (fileToProcess(f.getName()) == false) { continue; } final FileWatcher watcher = modifieds.get(f); if (watcher == null || watcher.hasChanged()) { final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f, option.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption()); final Set<File> files = new HashSet<File>(sourceFileReader.getIncludedFiles()); files.add(f); for (GeneratedImage g : sourceFileReader.getGeneratedImages()) { result.add(g); if (OptionFlags.getInstance().isFailOnError() && g.isError()) { error = true; } } modifieds.put(f, new FileWatcher(files)); } } Collections.sort(result); return Collections.unmodifiableList(result); }
4e2b4b60-76bb-4eba-add4-b439d245fac5
0
public Status getStatus() { return status; }
0bb984ec-dca9-4f60-9dc0-c7881b405d85
5
public static void createPDFExcel(String path, String[] content, int row, Boolean rotate) { if (content == null) { return; } try { File myFile = new File(path); if (!myFile.exists()) { myFile.createNewFile(); } Document document = new Document(rotate == true ? PageSize.A4 : PageSize.A4.rotate());// 创建word文档,并设置纸张的大小 PdfWriter.getInstance(document, new FileOutputStream(path)); document.open(); document.setMargins(3.5f * 28.5f, 1.5f * 28.5f, 3.17f * 28.5f, 3.17f * 28.5f); // 下面是解决中文的问题 BaseFont bf = BaseFont.createFont("c:\\windows\\fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font nobold = FontFactory.getFont("Arial", 22, Font.NORMAL); Font bold = FontFactory.getFont("Arial", 22, Font.BOLD); Font zn = new Font(bf); PdfPTable table = new PdfPTable(row);// 大小必须刚刚好,缺一个单元整行都没了 for (int i = 0; i < content.length; i++) { PdfPCell cell = new PdfPCell(); cell.addElement(new Paragraph(content[i], zn)); table.addCell(cell); } document.add(table); document.close(); } catch (Exception e) { e.printStackTrace(); } }