method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
16fb8950-6bb2-455f-9ad6-01426efdaa70
4
private boolean isOptimal(double[] b, double[] c) { double[] x = primal(); double[] y = dual(); double value = value(); // check that value = cx = yb double value1 = 0.0; for (int j = 0; j < x.length; j++) value1 += c[j] * x[j]; double value2 = 0.0; ...
7cfeaf11-67b7-42f3-a6ec-1379fac2e104
5
public static void validate(List<Long> pointToValidate, List<Long> startPoint, List<Long> endPoint) throws SizeNotEqualException, InvalidPointException { int size = pointToValidate.size(); if (size != startPoint.size()) { throw new SizeNotEqualExce...
ea00ef8c-2751-4a17-a469-dc6b0b1ab4c3
9
protected final java.lang.Object iterateReader(XMLStreamReader toReader, java.lang.Object toObject, XMLFormatType toFormatType) { java.lang.Object loReturn = null; try { while(toReader.hasNext()) { switch(toReader.getEventType()) { ...
f293ee64-8fc9-4918-a00e-74037098165a
8
public static void main( String[] args ) throws NoSuchFieldException, SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException { String stringer = "this is a String called str...
2fb5225f-b51d-4dde-9186-7e651f0a895a
1
public void setCodigo(String codigo) { this.codigo = codigo.isEmpty() ? "sem código" : codigo; }
bcd6d959-9372-49ad-a06d-4b02cdc2a9e3
4
public void run(){ try { buff = new byte[Optiums.BUFF_SIZE]; recordFile = new FileOutputStream(new File(Optiums.FILE_RECORD_NAME + "." + Optiums.FILE_TYPE.toString().toLowerCase())); outpuStream = new OutputStream() { private byte l = 0; ...
a625504b-c458-466c-8806-1738ca5c0888
7
@SuppressWarnings("unchecked") public void registerListener( EventListener listener, Plugin plugin ) { List< Method > methods = new ArrayList< Method >(); Collections.addAll( methods, listener.getClass().getMethods() ); for( Method method : methods ) { EventHandler handler = method.getAnnotation( Eve...
a98e0482-b0d4-4c86-a371-c5e993f0d82f
5
public void DFS(int a,int b){ Stack<Node> s= new Stack<Node>(); ArrayList<Integer> visited= new ArrayList<Integer>(); Node src=new Node(a); Node dest= new Node(b); s.push(src); while(!s.empty()){ Node tmp=s.pop(); if(!visited.contains(new Integer(tmp.getData()))){ System.out.println(tmp.getData())...
0c1c4117-bb51-4800-9140-5ef172fb006c
5
private final void sendObjectPlacement(final MapleCharacter c) { if (c == null) { return; } for (final MapleMapObject o : getAllMonster()) { updateMonsterController((MapleMonster) o); } for (final MapleMapObject o : getMapObjectsInRange(c.getPosition(), Ga...
c6c67830-fda2-4c1e-9909-c56201dc917b
7
public void criaUSER(Usuario user) throws SQLException { Connection conexao = null; PreparedStatement comando = null; try { conexao = BancoDadosUtil.getConnection(); if ("Diretor".equals(user.getTipo())) { comando = conexao.prepareStatement(SQL_INSERT_D...
80ebbb46-b8e8-42ac-ad0f-e18681ffd944
6
private void findNextElement() { try { if(parser.getElement() != null && parser.getElement().hasChildren()) parser.down(); while(true) { parser.next(); if(parser.getElement() != null) { foundNext = true; return; } else { if(parser.getDept...
22fed56f-dcf4-4bcd-93dc-31330604f464
8
public void initialize(final ClientDavInterface connection) throws Exception { DataModel dataModel = connection.getDataModel(); ConfigurationAuthority configurationAuthority = null; if(_kv != null && _kv.length() != 0) { try { long id = Long.parseLong(_kv); SystemObject object = dataModel.getObject(id)...
446195cf-ec14-4616-bd04-e64c7c898ff4
5
private void handleFailed() { uncompletedCount = 0; completedCount = 0; for (OnDemandData onDemandData = (OnDemandData) requested.peekLast(); onDemandData != null; onDemandData = (OnDemandData) requested .reverseGetNext()) if (onDemandData.incomplete) uncompletedCount++; else completedCount++; ...
fd681fab-4477-412b-ac38-069899d3e6ba
7
public void log( Level level, String trace, String msg ) { // Forward the call the the default logger super.log( level, trace, msg ); // Then add the event to the HTTPD statistics if( level.equals(Level.SEVERE) ) { this.getHandler().getRuntimeStatistics().reportSevere(); } else if( level.equal...
6af9f1d0-4cde-43e1-84c9-f1a4b27a6fb5
4
public static void saveFile(String file, String data, boolean append) throws IOException { BufferedWriter bw = null; OutputStreamWriter osw = null; File f = new File(file); FileOutputStream fos = new FileOutputStream(f, append); try { // write UTF8 BOM mark if file is empty ...
2e570732-1eb0-45d3-8845-0aea11e87068
3
@Override public double getTip() { double tip = 0.00; // always initialize local variables switch(serviceQuality) { case GOOD: tip = baseTipPerBag * bagCount * (1 + goodRate); break; case FAIR: tip = baseTipPerBag * bagCount * ...
2982205b-77e5-4382-8351-1fb7a0a71b2e
2
public Collection<String> getClassificacao(String cod_competicao) { try { Collection<String> col = new ArrayList<String>(); Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery("select Jogador.nome,equipa.cod_equipa as Equipa,golo from Jogador,Marcadores,Eq...
9d65be22-8d04-49a1-bdb8-baa44972032d
4
public static final void setPrintStream(PrintStream stream) { if (!Debug.DEV_MODE) { if (stream == null) { stream = System.out; } if (OUT != stream && OUT != System.out) { OUT.close(); } OUT = stream; } }
c98d6f87-8496-47ca-a4be-9aeec1121c09
7
public static void recCall(int num) { LinkedList<Integer> queue = new LinkedList<Integer>(); queue.add(num); queue.add(-1); Hashtable<Integer, ArrayList<Integer>> memo = new Hashtable<Integer, ArrayList<Integer>>(); boolean firstPlayerTurn = true; while (!queue.isEmpty()) { Integer currNum = queue.poll...
b36d5f03-8c20-4f22-af43-c54fec1f7332
1
public void wdgmsg(Widget sender, String msg, Object... args) { if (sender == cbtn) { clbk.result(false); close(); return; } super.wdgmsg(sender, msg, args); }
b502ba06-a0c3-4caa-90ab-468badad089d
4
public final Action[] createDefaultFontFaceActions() { String[] families = GraphicsEnvironment.getLocalGraphicsEnvironment() .getAvailableFontFamilyNames(); Map fontFamilyRange = Collections.synchronizedMap(new HashMap()); Action a = null; for (int i = 0; i < families.length; i++) { if (f...
877686ae-49d7-4a40-b4a9-8cd0f39f0311
7
public String[] getOptions() { Vector<String> result; result = new Vector<String>(); result.add("-mean-prec"); result.add("" + getMeanPrec()); result.add("-stddev-prec"); result.add("" + getStdDevPrec()); result.add("-col-name-width"); result.add("" + getColNameWidth(...
83b5dd7b-fcd6-4137-bcb5-a5797158f186
8
private static float getUnitFactor(String unit) { //byte scale if(unit.equals("KB")) return 1/1024; if(unit.equals("MB")) return 1; if(unit.equals("GB")) return 1024; if(unit.equals("TB")) return 1024 * 1024 ; //freq scale if(unit.equals("Hz")) return 1; if(unit.equals("KHz")) ret...
0b375c55-fe56-48fe-9198-939196ac3b97
6
public static int[] selectionSort(int[] array, boolean ascendingOrder) { if (array != null && array.length > 1) { int lengthLessOne = array.length - 1; int minValue; int minIndex; for (int i = 0; i < lengthLessOne; i++) { minValue = array[i]; minIndex = i; for (int j = i + 1; j < array.len...
e5aa0288-8846-4e54-acc1-12e8c888635e
3
@Override public V merge( final K key, final V value, final BiFunction<? super V, ? super V, ? extends V> remappingFunction) { throw new UnsupportedOperationException(); }
351a6196-9e6a-44cf-8c51-e73e11b3b03f
8
public void renderPlayer(int xp, int yp, Sprite sprite) { xp -= xOffset; yp -= yOffset; for(int y = 0; y < 32; y++) { int ya = y + yp; for(int x = 0; x < 32; x++) { int xa = x + xp; if(xa < -32 || xa >= width || ya < 0 || ya >= height) break; if(xa < 0) xa = 0; int col = sprite.pixels[...
47cb63b1-8922-47fe-b9cf-6607179346c2
8
public static Map<String, CyIdentifiable> getPDBChains(String queryString, Map<String, CyIdentifiable>reverseMap, Map<CyIdentifiable, List<PDBStructure>>chainMap) ...
352b0854-8a8a-4424-8fac-85c45b955578
3
@Test public void testDrawWorld() { Cell[][] cells = new Cell[][]{ {Cell.LIVING, Cell.DEAD}, {Cell.DEAD, Cell.LIVING}, }; Integer numberOfLivingCells = 0; Integer numberOfDeadCells = 0; for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { if (cells[i][j] == Cel...
877b9221-b6f3-4428-bf76-e3c9e95184d6
1
public void cmpl(final Type type) { mv.visitInsn(type == Type.FLOAT_TYPE ? Opcodes.FCMPL : Opcodes.DCMPL); }
2d10756c-cab3-45a6-9326-af28a22d1e71
2
@Override public boolean takePoints(String name, int points) { if(getPoints(name)<points){ return false; } try { PointsAPI.modifyPointsToPlayer(name, points, Type.RemovePoints); } catch (Exception e) { return false; } return true; }
4f0c9065-d55f-449e-ab18-1ac487818ce7
3
public List<Element> getNodes(String xpath) { try { XPathFactory xpathfactory = XPathFactory.newInstance(); XPath xPath = xpathfactory.newXPath(); XPathExpression expr = xPath.compile(xpath); Object result = expr.evaluate(domNode, XPathConstants.NODESE...
a5086eee-a2b2-4cfa-9732-45ccc1bfaa53
0
public String getName() { return name; }
18094c3a-46ec-43b4-b8c0-a989a5765645
1
private void LoadContent() { try { URL moonLanderMenuImgUrl = this.getClass().getResource("/raceresources/resources/images/stardust.png"); moonLanderMenuImg = ImageIO.read(moonLanderMenuImgUrl); } catch (IOException ex) { Logger.getLogger(Framework.class.getName()).lo...
0a8d8571-6e9b-48a1-be93-3f8587e4eecd
6
@Override public void run() { while(!stop && !hasStopped()) { redirectStdin(); redirectStdout(); try { for(String s : getEvents()) { EventHandler.handle(new Event(s)); } } catch (Exception e) { e.printStackTrace(); } try { sleep(100); } catch(InterruptedException e) {} } // If the server ...
3115bd55-e520-4d30-8c32-080bcc3276f6
2
public static Date[] getColumnDateValues(CSTable t, String columnName) { int col = columnIndex(t, columnName); if (col == -1) { throw new IllegalArgumentException("No such column: " + columnName); } Conversions.Params p = new Conversions.Params(); p.add(String.class,...
0edd2449-a870-4bfc-a8d2-3b550088c6db
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://down...
6cde54a7-26a1-44d2-95cc-4278d547f0c9
9
private void iniciaRodada() { criaPecas(); int n = distribuiPecas(); pontaDir = pontaEsq = n; int i = prim; vez = i % 4; turno = 0; while (vencedor == 5) { vez = i % 4; for (int j = 0; j < jogadores.length; j++) { jogadores[...
681f668f-8759-4e8a-88b7-7f894f2059f6
0
private void ok() { this.styleName = (File) styles.getSelectedItem(); this.shouldProceed = true; hide(); }
6fcc4791-0384-4244-ab36-32000e7a29e9
2
public Item removeFirst() { if (isEmpty()) throw new java.util.NoSuchElementException(); else if (size() == 1) { Item item = first.item; first = null; last = null; size--; return item; } Item item = first.item; ...
0193bac0-aa4e-4a7b-9db4-d72a8fdc9816
1
public SoundData(IAudioDevice device, String fileName) throws IOException { this.device = device; this.id = 0; try { this.id = loadAudio(device, fileName); } catch (UnsupportedAudioFileException e) { throw new IOException(e); } }
6b385194-8019-44a0-86d4-bf189ab6680a
8
private static boolean collapseIfIf(IfNode rtnode) { if (rtnode.edgetypes.get(0) == 0) { IfNode ifbranch = rtnode.succs.get(0); if (ifbranch.succs.size() == 2) { // if-if branch if (ifbranch.succs.get(1).value == rtnode.succs.get(1).value) { IfStatement ifparent = (IfStateme...
4f75255b-1aaa-463c-be52-bfe8a3608c4f
1
public void deleteClientInfo(String t_name) { ClientInfo temp = this.find(t_name); if (temp != null) client_list.remove(temp); }
ea7f12a1-02d6-4ece-8ac8-c4678e19e2ea
8
@Override public void mouseClicked(int button, int x, int y, int clickcount) { Client.debug("clicked in a window x:" + x + " y:" + y ); boolean found = false; for (GUIObject obj : objects.values()) { if (!obj.isInput()) continue; if ( x >= obj.getRealX() && x < obj.getRealX()+obj.getRealWidth() ) {...
8021e3aa-6168-46e4-b7f5-9d4a4c8ab7e2
9
protected void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed if(JOptionPane.showConfirmDialog(rootPane, "Você tem certeza que deseja Salvar ?")== 0){ if(txtNome.getText().isEmpty()){ JOptionPane.showMessageDialog(rootPane, "O cam...
be1ed625-5f41-49c5-9bbd-10b071190890
0
public void setId(String id) { this.id = id; setDirty(); }
820ee708-069f-43ce-ab32-0eb543e63b6e
1
public JavaFileManagerClassLoader(JavaFileManager fileManager, final ClassLoader parent) { super(parent); if (fileManager == null) { throw new NullPointerException("fileManager"); } this.fileManager = fileManager; }
4bc9fd10-a134-41c9-973c-53727616d568
4
public void keyPressed(KeyEvent e) { int i = targetList.getSelectedIndex(); switch (e.getKeyCode()) { case KeyEvent.VK_UP: i = targetList.getSelectedIndex() - 1; if (i < 0) { i...
7fa3ebd6-27b3-4d30-8cb5-6be4f5a37ba4
6
private static void findPairIntersections() { for (Pair p1 : values) { Card[] c1 = p1.cards; int i1 = p1.ordinal; for (Pair p2 : values) { int i2 = p1.ordinal; Card[] c2 = p2.cards; intersectsPair[i1][i2] = false; if(c1[0] == c2[0]) intersectsPair[i1][i2] = true; if(c1[0] == c2[1]) inters...
58660590-5c18-4791-aed1-02bba728a90f
0
public void updatePacketTime(int packetTime) { lastPacketTime = packetTime; }
60b320b5-3001-4bb4-8a75-c45224fcdc54
4
public Component getTreeCellRendererComponent( JTree tree,Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { // Allow the original renderer to set up the label Component c = super.getTreeCellRendererComponent( tree, value, sele...
96e406d4-759b-4cff-a0ca-d121f88342fb
6
public static int spawn_in_out_err(String command, String infile, String outfile, String errfile) { Process p; try { p = Runtime.getRuntime().exec(command); } catch (IOException e) { return -1; } try { if (infile != null) { (new Xfer(new FileInputStream(infile), p.getOutputStream())).start(); ...
10887e19-4aba-4bdd-acf5-2ad35d4a67e9
4
public void rotate(int[][] matrix) { int length = matrix.length; int[][] array = new int[length][length]; for(int i =0;i < length;i++){ for(int j =0;j<length;j++){ array[j][length-1-i] = matrix[i][j] ; } } for(int i =0;i < length;i++){ ...
0fdf4f28-32dd-4397-9719-ecfa984fee23
0
@Override public String toString() { return this.def + "@" + this.key; }
89148799-8785-427c-8c9c-16596745141c
3
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); List<User> list = DB.getAll(); for(User user : list){ if(user.getUsername().equals(u...
dc889507-e6e3-41c8-a91f-5b5f5fa60150
2
private TeamMember findPlayer(String name, String number, TeamMember defaultReturn) { TeamMember playerToFind = new Player(name, "Team", number, "age"); for (Player player : players) { if (player.equals(playerToFind)){ return player; } } return def...
b7fc17c1-0994-4dae-87cf-bced0df0faf6
9
public static final void main(String[] args) throws Exception { if(args.length < 1 || args.length > 2) { System.err.println("usage: Ping host [count]"); System.exit(1); } final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2); try{ final InetAddress add...
1b58a3a7-1b39-42d7-bb58-806a27cba529
7
static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double)o).isInfinite() || ((Double)o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); ...
99e6092c-bd1f-47b4-804e-acf042d3c92b
0
public void testLastDay() { Date date = new Date(); Date r = DateUtils.getLastDayOfTheMonth(date); System.out.println(r); }
7b93ac44-7224-4720-a44b-212ac10b3dd5
6
void setExampleWidgetForeground () { if (colorAndFontTable == null) return; // user cannot change color/font on this tab Control [] controls = getExampleControls (); if (!instance.startup) { for (int i = 0; i < controls.length; i++) { controls[i].setForeground (foregroundColor); } } /* Set the foreg...
722f2adc-623b-4394-babb-0c6644fdd476
3
public void loadConfig() { localeFileName = config.getString("locale.filename"); iInterval = config.getInt("interval"); iQuota = config.getInt("quota"); iBreakMax = config.getInt("block-break.max"); iBreakMult = config.getInt("block-break.multiplier"); iPlaceMax = config.getInt("block-place.max"); iPla...
cab378c4-731d-490f-98fa-f99526f90155
2
public boolean equals(final Object obj) { return (obj instanceof NameAndType) && ((NameAndType) obj).name.equals(name) && ((NameAndType) obj).type.equals(type); }
5f0718d5-e63a-46a8-9280-416007feb8d1
7
public Boolean estocarNovos(List<Estoque> estoques) { Boolean sucesso = false; if (estoques != null) { Connection connection = conexao.getConnection(); try { String valorDoComandoUm = comandos.get("estocarNovos" + 1); String valorDoComandoDois = co...
2bb9a5b4-078f-4bff-9c37-09304b430e2f
1
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setText((value == null) ? "" : value.toString()); return this; }
8a5d58d2-35c5-4639-b447-3887efc937b8
9
@Override public void setValueAt(Object value, final int row, final int col) { final String key = this.propNames.get(row); final WidgetProperty p = this.dataMap.get(key); p.setValue(value); Object o; if ((this.selectedComponents != null) && !this.selectedComponents.isEmpty()) { o = this.selectedCompon...
ebd491db-15f7-4774-8ddb-4b1072d4084d
2
public void testGetIntervalConverter() { IntervalConverter c = ConverterManager.getInstance().getIntervalConverter(new Interval(0L, 1000L)); assertEquals(ReadableInterval.class, c.getSupportedType()); c = ConverterManager.getInstance().getIntervalConverter(""); assertEquals(Stri...
fcd6f006-5dc4-4936-a3ae-077a3cf33e79
3
public void move() { if (isFalling) { dy = dy+gravity; y += dy; } else { y -= dy; dy = dy+antiGravity; } if (dy < 0.01f) { isFalling = true; dy = 0.02f; } if (y < 0) { isFalling = true; dy = 0.02f; move(); } }
9af181c6-7143-477b-83b7-c7d5fb4f83ee
9
@Override public NfcMessage write(NfcMessage input) throws IOException { if (!isEnabled()) { if (Config.DEBUG) Log.d(TAG, "could not write message, reader is not enabled"); eventHandler.handleMessage(NfcEvent.FATAL_ERROR, NFCTRANSCEIVER_NOT_CONNECTED); return new NfcMessage(Type.ERROR).sequenceNumbe...
188ff6de-cc2d-4cd3-a57e-46fab69ae3c4
8
public synchronized void sortBy(int dim) { if((dim<1)||(dim>dimensions)) throw new java.lang.IndexOutOfBoundsException(); dim--; if(stuff!=null) { final TreeSet<Object> sorted=new TreeSet<Object>(); Object O=null; for (final Object[] name : stuff) { O=(name)[dim]; if(!sorted.contains(O))...
f2c01ab3-0627-4c35-97f5-c779b5f58229
7
public void place(int x, int y) { if (this instanceof RockTower &&player.getGold()>=600) { player.addTower(new RockTower(player, player.getTowers().size(), x, y)); player.pay(600); } else if (this instanceof SpikyTower&&player.getGold()>=1000) { player.addTower(new SpikyTower(player, player.getTowers().siz...
90ef2be2-9b46-4e70-9c21-64313abbcb48
1
public int evaluate (AbstractPlay play, Player cpu, int largestCapture) { int evaluation = evaluateRecursively(play, cpu); if (play.eatNumber() < largestCapture) evaluation--; return evaluation; }
694207e1-77f8-48bd-8c7c-2b7c0d4895c9
4
private boolean precisaAutenticar(String url) { return !url.contains("index.xhtml") && !url.contains("institucional.xhtml") && !url.contains("area-do-cliente.xhtml") && !url.contains("contato.xhtml") && !url.contains("javax.faces.resources"); }
751f2fc2-3ac9-4f0b-8396-10f958fa6829
7
@Override public void run(int interfaceId, int componentId) { if (stage == -1) { stage = 0; sendEntityDialogue( SEND_2_TEXT_CHAT, new String[] { NPCDefinitions.getNPCDefinitions(npcId).name, "You have already learned the first thing needed to", "succeed in this world talking to o...
d13b6b8a-6999-45a4-a59c-20eacf7bcd38
6
public static OS getPlatform() { String osName = System.getProperty("os.name").toLowerCase(); if (osName.contains("win")) { return OS.windows; } if (osName.contains("mac")) { return OS.macos; } if (osName.contains("solaris")) { return OS.solaris; } if (osName...
31ed4572-2dab-4101-a5d2-4ec705b520fe
5
public Export(RSInterface main) { if (main == null) { JOptionPane.showMessageDialog(null, "This is not a valid interface!"); return; } this.main = main; setChildren(); if (layers != null && !layers.isEmpty()) { setSubChildren(); } if (subchildren != null && !subchildren.isEmpty()) { setSubSubC...
28a1d1fe-2757-455d-b885-6eb16d97a0fe
0
public void actionPerformed(ActionEvent e) { JComponent c = (JComponent) environment.getActive(); PrintUtilities.printComponent(c); }
ed2b15fa-7b4f-4962-818a-9f56c567c4fb
8
public static Vector2f rectCollide(Vector2f oldPos, Vector2f newPos, Vector2f size1, Vector2f pos2, Vector2f size2) { Vector2f result = new Vector2f(1,1); if(!(newPos.getX() + size1.getX() < pos2.getX() || newPos.getX() - size1.getX() > pos2.getX() + (size2.getX() * size2.getX()) || oldPos.getY() + size1...
36435afd-fce2-4f6b-8569-386cd9e336a1
2
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanelBusca = new javax.swing.JPanel(); jScrollPane4 = new javax.swing.JScrollPane(); tbProjetos = new javax.swing.JTable(); t...
8620d951-3aa5-438e-9a8a-cec6be08815c
7
public void stateChanged(ChangeEvent e) { if (model.getLightSource() == null) return; Object o = e.getSource(); if (o instanceof JSlider) { JSlider source = (JSlider) o; if (!source.getValueIsAdjusting()) { model.setLightSourceInterval((int) ((200 + (source.getMaximum() - source.getValue()) * 20) / m...
1dd30560-f683-4481-b2ca-8bc9816eb459
6
public void dbData(int uName) { try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { System.out.println("Where is your MySQL JDBC Driver?"); e.printStackTrace(); } if (uName >= 0) { PreparedStatement ps = null...
089cb618-5ecb-40dd-8ed8-5a479d9c379f
9
public String getConfigPath(String filename) { if (eng.isApplet()) return null; File jgamedir; try { jgamedir = new File(System.getProperty("user.home"), ".jgame"); } catch (Exception e) { // probably AccessControlException of unsigned webstart return null; } if (!jgamedir.exists()) { // try to ...
e2833ab8-0d87-43d9-95ab-8df6c82c547c
7
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://down...
a6fb2437-b2ba-4efb-b6e1-2b6419d9bbfb
9
private String[] splitString(String ipFormula) throws ScriptSyntaxException { LinkedList<String> tokens = new LinkedList<String>(); int braces=0;//level of braces //considering that there is always only one space int posBegin=0; int posEnd=0; while (posEnd<ipFormula.length()){ if (isSpace(ipFormula...
b740c121-b4ae-4348-b04e-fd503e84d754
3
public static FlacMetadataBlock create(InputStream inp) throws IOException { int typeI = inp.read(); if(typeI == -1) { throw new IllegalArgumentException(); } byte type = IOUtils.fromInt(typeI); byte[] l = new byte[3]; IOUtils.readFully(inp, l); int length = (in...
5008e4b2-a3bd-4636-9dcb-a7b5ebad7a5d
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://down...
6ba28740-7ee6-4d2d-bda6-6eb2b73e9463
1
public final JSONObject optJSONObject(int index) { Object o = opt(index); return o instanceof JSONObject ? (JSONObject)o : null; }
02d0d22c-7482-4dc5-b69e-abeb57597eac
2
private boolean first_round_strategy() { if (bowlId < chooseLimit) { maxScoreSoFar = Math.max( maxScoreSoFar, get_bowl_score(bowl) ); System.out.println("Not reached chooseLimit yet, updated maxScoreSoFar = " + maxScoreSoFar); return false; } else { if (ge...
de1870db-b651-4ca4-97e1-edd1f9a0ce29
0
@Override public int eatNumber() { return 0; }
d328919e-31af-43e4-9652-a0db056072bd
0
public Game() { Level level = new SpawnLevel(this); currentScreen = new GameScreen(this, level); mouse = new Mouse(this); addMouseListener(mouse); keyboard = new Keyboard(this); addKeyListener(keyboard); player = new Player(level, 30, 100); }
85297320-a14b-4d0a-b67f-d90b033b4d00
2
public double visibleBias(int index) { if(index < 0 || index >= m) throw new RuntimeException("given m=" + m + ", illegal value for index: " + index); return _visibleBias[index]; }
1149f6d0-1e40-48cb-a0ed-de63733a1aa6
2
@Override public int compareTo(Entity o) { if (id > o.id) { return 1; } if (id < o.id) { return -1; } return 0; }
26500a8d-642e-4833-b9fb-2c6f30ec5754
1
@Transactional public Journal getOrCreateJournal(String name, Date date) { Journal journal = journalsDao.getByName(name); if (journal != null) { Date startDate = dateService.getStartOfDay(date); Date endDate = dateService.getNextDay(date); journal.setTasks(tasksDa...
38c36820-43ff-40f5-a806-3d696d40c0e1
9
private void refreshStatistics(ArrayList<T[]> gens) { double max, min, avg, current; avg = max = min = problem.costFunction(gens.get(0)); for (int i = 1; i < gens.size(); ++i) { current = problem.costFunction(gens.get(i)); if (max < current) { max = curr...
d0a58fba-483a-4ec8-ac6b-af8199e19543
3
@Override public void draw(Graphics g) { g.setColor(Color.WHITE); g.setFont(new Font("Tahoma", Font.PLAIN, FONT_SIZE - FONT_SIZE/4)); switch (type) { case 0: g.drawString("T", x, y); break; case 1: g.drawString("+", x, ...
36efd515-bbcf-41ae-8ea4-d2314af0a2a3
5
private int indOfOutP( char op, String equ ){ int PDepth = 0; for (int i = 0; i < equ.length(); i++){ if (equ.charAt(i) == '(') PDepth++; else if (equ.charAt(i) == ')') PDepth--; else if (PDepth == 0){ if (equ.charAt(i) == op) return i; } } return -1; }
e85e8c0a-e180-4b8d-9827-e420eeecdb16
8
public String typeConveter(byte val) { String rString = "?"; switch(val) { case STRING: rString = "String"; break; case HIT_TEST: rString = "Hit Test"; break; case SHIP: rString = "Ship"; break; case SHIPKILLED: rString = "Ship Killed"; break; case SH...
bd5357b3-bef1-41b5-a770-08d21f87f15c
8
protected static int getNPrime(int n) { if (n == 1) return FIRST_PRIME; if (n == 2) return SECOND_PRIME; int prime = SECOND_PRIME; int count = 2; for (int i : primesByOrder.keySet()) { if (n > i) { count = i; prime = primesByOrder.get(...
90cb1b56-9793-4c0b-b04c-79d86172cc6b
0
public int getNewPosition() { return this.newPosition; }
33be7ce0-d846-487c-8d18-9b31cbd85b5e
3
public Evaluator(String expression){ Stack<Expression> expressionStack = new Stack<Expression>(); for (String token : expression.split(" ")){ if (token.equals("+")) { Expression subExpression = new Plus(expressionStack.pop(), expressionStack.pop()); expressionStack.push(subExpression); } else if (toke...
5e2a6383-c14d-45cf-890c-13793bc55015
4
private String serverRecievedSendFrame(SendFrame msg){ String reply= ""; if (msg.getMessage().equals("stats\n")) Statistics.getStatisticsObject().getStats(); else if (msg.getMessage().equals("stop\n")) _cH.stopServer(); else if (msg.getMessage().equals("clients online\n")) reply= _users.getListOfAllUse...
c2c12b24-bd4f-48ea-990c-0231c924a31d
4
protected boolean canEnter(Tile t) { if (t == init || t == destination) return true ; return t.habitat().pathClear && ( t.owner() == null || t.owner().owningType() < priority ) ; }