method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
5078c536-3f90-4065-9c60-4fe19e579f34
5
@Override public boolean check() { // use super.check() to check the executor, then to check the distributor. if ( super.check() ) { try { this.distributor = Class.forName(this.dis); } catch (ClassNotFoundException e) { System.out.println("InnerNode " + this.name + " : " + " Distributor " + this.dis ...
d6cdfe3b-bf14-4f23-a804-8b74f90c5153
0
public static void main(String[] args) throws IOException, ClassNotFoundException { FileOutputStream fos = new FileOutputStream("/tmp/fooobject.data"); ObjectOutputStream os = new ObjectOutputStream(fos); FooObject foo = new FooObject("foo1", 10, 12, new FooObject("test", 1, 2, null)); os.writeObject(foo)...
505f80a4-9fbc-4b12-b7ba-78f088f72f4f
4
public static void editRate(Rate r){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try{ conn.setAutoCommit(false); PreparedStatement s...
5f838048-b346-4923-9c59-fe8ce197b51e
7
private static void testCpus(int cpuCount, char[] ram) { DCPU[] cpus = new DCPU[cpuCount]; for (int i = 0; i < cpuCount; i++) { cpus[i] = new DCPU(); for (int j = 0; j < 65536; j++) { cpus[i].ram[j] = ram[j]; } } long ops = 0L; int hz = khz * 1000; int cyclesPerFrame =...
dcff6b5a-0f48-428b-af61-b38b7441e408
4
public static void splitPivotLast(int low, int high) { int i = low; for (int j = low; j < high; j++) { countLast++; if (result[j] < result[high]) { exchange(j, i); i++; } } exchange(high, i); if (low < i - 1) ...
9fb215d6-8c1e-49a3-abd1-4feeef84900a
3
public void checkConsistent() { super.checkConsistent(); if (subBlocks[0].jump != null || subBlocks[0] instanceof SequentialBlock || jump != null) throw new jode.AssertError("Inconsistency"); }
224a4d14-6702-48e0-b2f4-a59243a258ff
7
public void setRecursiveNotDirty() { super.setRecursiveNotDirty(); this.isTargetHrefDirty = false; if(this.create!=null && this.create.isDirty()) { this.create.setRecursiveNotDirty(); } if(this.delete!=null && this.delete.isDirty()) { t...
72aaf2ff-4608-4a22-a560-ee28423a7009
4
@Override public boolean equals(Object o) { if (o == null) { return false; } if (!(o instanceof Vector3)) { return false; } Vector3 other = (Vector3)o; return (this.x == other.x && this.y == other.y && this.z == other.z); ...
08f8f8a3-0289-468e-8e70-c177798dd4bd
2
@Override public void run() { FileProxy proxy = AppWindow.findFileProxy(mFile); if (proxy != null) { PrintCommand.print(proxy.getPrintProxy()); } else if (System.currentTimeMillis() - mStart < TimeUnit.MILLISECONDS.convert(2, TimeUnit.MINUTES)) { EventQueue.invokeLater(this); } }
cdf052fc-51f7-4a7d-8776-afef72a0a0c6
8
private Response requestHelper(String requestUrl, String requestBody) { Response response = backdoorRequest(requestUrl); if(response != null && response.getValue() != null) { try { response.value = JsonParser.parse((String)response.getValue()); return response; } catch(JsonParseException e) ...
b8651d07-e977-4cef-a6a3-529297a2f7de
0
@Override public String toString(){ return "\nRECARGO "+super.toString(); }
73b2835e-2626-4709-b4d9-c4ab2b2498c9
4
public List<VariableAppearance> getAppearances(ParsingContext context) { List<VariableAppearance> result = new ArrayList<VariableAppearance>(); for (PatternGroupStructure pattern : patterns) { Matcher matcher = pattern.getPattern().matcher(context.getContent()); while (matcher.find()) { String variableNam...
a5c1490e-80c8-478b-9620-a04aa7d43bae
2
public void thaw() { Configuration[] configs = configurations.getSelected(); if (configs.length == 0) { JOptionPane.showMessageDialog(configurations, NO_CONFIGURATION_ERROR, NO_CONFIGURATION_ERROR_TITLE, JOptionPane.ERROR_MESSAGE); return; } for (int i = 0; i < configs.length; i++) { configur...
c0f6d14f-9ccd-43af-9197-7494c24ac6f9
6
public void drawTile(int xi,int yi,int tileid) { if (background == null) return; // determine position within bg int x = el.moduloFloor(xi+1,el.viewnrtilesx+3) * el.scaledtilex; int y = el.moduloFloor(yi+1,el.viewnrtilesy+3) * el.scaledtiley; // draw if (bgg==null) bgg = background.getGraphics(); Integer ...
8a2972cb-1580-413e-b5a6-94033356e257
5
private boolean sudoku(char[][] board, int pos) { int n = board.length; if(pos == n*n) return true; int x = pos/n; int y = pos%n; if(board[x][y] == '.'){ for(char c= '1'; c <= '9'; c++){ board[x][y] = c; if(isValidSudoku(bo...
27260e29-f642-4d5d-9b0c-6879902596cc
5
short[] findY2(short t1Index, short t2Index, short t3Index, short t4Index){ short stopBefore = mod(t1Index - 1); short pathT4Index = path[t4Index]; short start = mod(t3Index + 2); int numLoops = Math.min(mod(stopBefore - start), LIMIT); if(numLoops == 0){ return null; } short t5Index = mod(start + r...
f55c1e8e-14a3-4fa6-808a-37ce27250ca4
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); addActionListener(this); }
49dae984-4c71-4271-946a-f787ea3245fd
2
public static void zmq_ctx_set (Ctx ctx_, int option_, int optval_) { if (ctx_ == null || !ctx_.check_tag ()) { throw new IllegalStateException(); } ctx_.set (option_, optval_); }
da2a6ffc-6243-4e84-89d6-3e76cd2aef4a
9
private void initier_table() { Vector<String> contraintes = new Vector(); for(int i=1;i<fields.size();i++) contraintes.add(fields.get(i).getText().replaceAll(" ", "")); jPanel2.removeAll(); tables = new Vector(); btn_tables = new Vector(); ...
b487c301-cb9f-4875-b345-9dfd6d438af1
3
public StochasticKMeansPredictor(List<Instance> instances) { num_clusters = 3; if (CommandLineUtilities.hasArg("num_clusters")) { num_clusters = CommandLineUtilities.getOptionValueAsInt("num_clusters"); } // init clusters for (int i = 0 ; i < num_clusters ; i++) { clusters.add(new Cluster(instance...
dfba9e18-4071-4f10-bd20-3584996f10b1
3
public boolean isSelectedNumberCandidate(int x, int y) { return game[y][x] == 0 && isPossibleX(game, y, selectedNumber) && isPossibleY(game, x, selectedNumber) && isPossibleBlock(game, x, y, selectedNumber); }
d2790d47-ccb1-49e0-91b4-06e316c64de7
3
@Override public void actionPerformed(GuiButton button) { if(button.id == 0) { GameStatistics.lives--; MapGenerator gen = new MapGeneratorSimple(); Remote2D.guiList.pop(); Remote2D.guiList.push(new GuiLoadMap(gen, 40, 40, 1337)); } else if(button.id == 1) { while(!(Remote2D.guiList.peek() insta...
5bc86d2f-0cbb-4ea2-8979-464e156d8ec9
4
public String readDword(Key key, String valueName) throws RegistryErrorException { if(key == null) throw new NullPointerException("Registry key cannot be null"); if(valueName == null) throw new NullPointerException("Valuename cannot be null, because the default value is always a STRING! If you wan...
2f411fc2-ea00-406e-937d-0daffc939c45
3
public double distanceFromLine(double testAngle) { if (leftDist <= 0 && rightDist <= 0) return 0; double x1 = leftDist * Math.cos(leftAngle); double y1 = leftDist * Math.sin(leftAngle); double x2 = rightDist * Math.cos(rightAngle); double y2 = right...
b83e3354-2d4f-4624-a05c-f09242ebec5a
3
Client() throws IOException { String s; System.out.println(getCurrentTime() + "::" +"Starting Client .."); clientSocket = new Socket("localhost", 38000); serverIn=new DataInputStream(clientSocket.getInputStream()); serverOut=new DataOutputStream(clientSocket.getOutputStream()); /*--------Reading file from T...
2fc9614f-3410-4212-906b-b64e54ba1112
2
private void bubbleUp(int pos) { int last = heap[pos]; Integer parentPos = parent(pos); if(parentPos != null) { if(heap[parentPos] < last) { swap(pos, parentPos); bubbleUp(parentPos); } } }
14de6d35-d85f-496a-b8ed-1c582123950c
1
public void zetJokerIn(Timer timer) throws LogicException { int jokers = getMaxJokers(timer); if (jokers <= 0) throw new LogicException("Jokers zijn op!"); jokersGebruikt++; timer.addJoker(); }
10fe24f7-3641-48f7-804a-2760117be177
8
private void stepEntities(Graphics2D graphics) { Iterator<Entity> it = entities.iterator(); while (it.hasNext()) { Entity entity = it.next(); if (paused || quitRequested) { entity.draw(graphics); continue; } entity.step(); ...
22c89711-5747-4d69-b934-eb038e2fac4a
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Effect other = (Effect) obj; if (Float.floatToIntBits(effectDuration) != Float .floatToIntBits(other.effectDuration)) return false; if (...
b013b68d-ba4a-4957-834f-44704fb58bf2
0
public Items getNext() { return next; }
74ecec00-349d-4568-8f54-36dc72f4e2e0
9
Node<Move, GS> selectChild() { if (unexpanded() || terminated()) { // Leaf node or node of a terminated state, nothing to select. return null; } if (gameState.currentPlayer() == GameState.PLAYER_CHANCE_NODE) { assert chanceNodeChildren != null; return chanceNodeChildren.get(); } else { if (visitC...
37542193-bdf2-4b98-b168-2a3904fd5f0b
2
private void fillLevel() { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { walkways[i][j] = false; } } }
a40af235-acde-4d75-88aa-b29e27552bf5
4
@Test public void TestSort() { MyList<Integer> list = new MyList<Integer>(); list.add(5); list.add(3); list.add(8); list.add(13); list.add(8); list.mergeSort(); Boolean res = (list.get(1) == 3 && list.get(2) == 5 && list.get(3) == 8 && list.get(4) == 8...
04f2bcbe-8f31-4725-9588-4234c43fd244
5
public void modeAuto(Loan loan) { if (user.isAllowedToBorrow(loan, this.getStockController())) { if (CalendarController.checkCalendars(loan.getStart(), loan.getEnd())) { if (this.getStockController().isAvailable(loan) && CalendarControll...
373c0b49-f256-44b4-96ca-b77f598779be
2
private static Outline createTestPanel(boolean wrapped) { Outline outline = new Outline(); OutlineModel model = outline.getModel(); outline.setDynamicRowHeight(wrapped); Column column = new Column(0, "Testy Goop", new TextCell(SwingConstants.LEFT, wrapped)); //$NON-NLS-1$ model.addColumn(column); for (int i...
a12cf3db-7d36-4cf5-80ba-069df301e60e
1
public RangeType(ReferenceType bottomType, ReferenceType topType) { super(TC_RANGE); if (bottomType == tNull) throw new alterrs.jode.AssertError("bottom is NULL"); this.bottomType = bottomType; this.topType = topType; }
0668226b-dea9-49fc-be40-84493517d05b
6
public int maximumGap_bucket(int[] num) { if (num.length < 2) return 0; int max = findMinMax(num, 1); int min = findMinMax(num, -1); int buckets = num.length - 1; double step = (max - min + 0.0) / buckets; // bucketize Map<Integer, List<Integer>> bucketMinMax =...
604712a4-11b3-431f-8d12-3c01610cf096
7
public Insanity[] check(CacheEntry... cacheEntries) { if (null == cacheEntries || 0 == cacheEntries.length) return new Insanity[0]; if (null != ramCalc) { for (int i = 0; i < cacheEntries.length; i++) { cacheEntries[i].estimateSize(ramCalc); } } // the indirect mapping lets ...
fcbe5dca-9942-4612-886e-f55c7038c299
6
public final static String date(long millis) { long secs = millis / 1000; long mins = secs / 60; long hours = mins / 60; long days = hours / 24; final long years = days / 365; long year = 1970 + years; days -= getDays(year); if (days < 0) { if (isLeap(--year)) { days += 366; } else { days ...
5c8f2239-ef17-45ba-8df7-c4f137ae67c6
0
@Override public void destroy() { synchronized (this) { doDestroy(); } }
9d3998ab-da5e-4395-aaf8-2ce3ad42d3a7
6
public void paivita(Object uusi, int rivi, int sarake) { Henkilo henkilo = henkilot.get(rivi); if (sarake == 0) henkilo.setId(((Integer) uusi).intValue()); else if (sarake == 1) henkilo.setEtunimi((String) uusi); else if (sarake == 2) henkilo.setSukunimi((String) uusi); else if (...
c037340b-6bd8-4ba0-a15e-09e439c06c66
2
public Column getColumnWithID(int id) { int count = getColumnCount(); for (int i = 0; i < count; i++) { Column column = getColumnAtIndex(i); if (column.getID() == id) { return column; } } return null; }
54249bd6-f862-4647-9293-91779e33ddec
7
private String findChromosomeName( BPTreeNode thisNode, int chromID){ String chromKey = null; // mark unfound condition as an empty string // search down the tree recursively starting with the root node if(thisNode.isLeaf()) { int nLeaves = thisNode.getItemCount(); ...
e97fcda4-ab8d-4d1b-bff6-613db6b6f87b
8
private void mergePhrasemes(List<Homonym> result, List<List<Phraseme>> phrasemes) { for (Homonym homonym : result) { //System.out.println(homonym.getOrig()); for (List<Phraseme> phs: phrasemes) { if (phs != null) { if (homonym.getOrig().equals(phs.get(...
c20dc595-95ea-4cd8-aadf-83799ed5ff1b
0
@Basic @Column(name = "POP_TERMINAL") public String getPopTerminal() { return popTerminal; }
bc83672e-c906-4526-a58f-4647569d4f65
2
public static void listarVenta(HashMap<Integer, Ventas> tablaVentas) { int codigoCliente; int codigoMusica; int codigoVenta; if (tablaVentas.isEmpty()) // No hay ventas en el sistema { System.out.println("No hay ventas en el registro."); } else { Set<Entry<Integer,Ventas>> s = tablaVentas.ent...
31f9858b-00c5-4ea4-9798-d30ac0ea74bc
5
public List<T> find(T start, T goal, StopDemander stop) { Node<T> startNode = new Node<T>(start, null); if (start.equals(goal)) { return startNode.getPathElements(); } List<Node<T>> queue = new LinkedList<Node<T>>(); Set<T> visited = new HashSet<T>(); queue.add(startNode); visited.add(start); whil...
d2d5bb1d-98ab-4323-9fb8-6c0a3996a1ad
1
public boolean equals(Object object) { Pair pair = (Pair) object; return from.equals(pair.from) && to.equals(pair.to); }
53a194f7-9bd9-4332-b962-26cb91a1db24
7
public static String toProperCase(String s) { if (s.isEmpty()) return ""; String[] unimportant = new String[] { "a", "an", "and", "but", "is", "are", "for", "nor", "of", "or", "so", "the", "to", "yet" }; String[] split = s.split("\\s+"); String result = ""; for (int i = 0; i < split.length; i++) { S...
4d1db22b-3454-4a66-9d88-7eec593acd30
3
@Override public void paintComponent(final Graphics g) { // Check if we have a running game super.paintComponent(g); g.setColor(this.getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); if (this.model != null) { // Draw all tiles by going over them x-wise and y-wise. for (int i = 0; i < this....
1a70060d-0115-41be-ad30-32765d89e68b
9
private void initTools() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setPreferredSize(new Dimension(30, 28)); toolBar.add(new JLabel("Mode ")); final JComboBox<EditorMode> modeBox = new JComboBox<EditorMode>(); modeBox.addItem(EditorMode.GUI); modeBox.addItem(EditorMode.NO...
2a8d8dbc-88be-492c-8791-6d60944047ba
5
public static void addToTable(Item item,int quantity) throws NullPointerException { if (item.getQuantity() >= quantity) { total = (getTotal() + item.getPrice() * quantity); item.changeQuantity(-quantity); modifyItem(item); int datalength = (tableData == null ? 0 : tableData.length); Object[][] temp = new O...
e8cc4e24-b247-4c5f-bee3-90f40d371292
2
private static void secondStrategy() { Semaphore MReading = new Semaphore(1); Semaphore MWriting = new Semaphore(1); Semaphore MPrio = new Semaphore(1); int counter = 0; Random r = new Random(); while(true) { if(r.nextDouble() > 0.5) new Lecteur(MReading,MWriting, counter).run(); else n...
3e2b9f29-b50a-464c-9529-efe08d0904d3
1
private Iterable<Position<T>> positions() throws InvalidPositionException, BoundaryViolationException, EmptyTreeException { ArrayList<Position<T>> ps = new ArrayList<Position<T>>(); if (size != 0) { preOrderPositions(root(), ps); // inOrderPositions(root(), ps); // postOrderPositions(root(), ps); } ...
331b2ed8-7740-40ba-a14e-9ec2cc85cc0a
1
public synchronized void samplesUpload(List<JSONObject> samples, String callBackUrl) { try { JSONObject data = new JSONObject(); data.put(Constants.SAMPLES, new JSONArray(samples)); getJson(Methods.POST, callBackUrl, data); } catch (JSONException e) { BmLo...
3afacdbf-18df-439b-92bd-c2e438352012
5
public void removeEdge(Collection<Edge> e_list){ NodeFunction f;// = e.getSource(); NodeVariable x;// = e.getDest(); FunctionEvaluator fe;// = f.getFunction(); HashMap<NodeFunction, LinkedList<NodeVariable>> f_xs = new HashMap<NodeFunction, LinkedList<NodeVariable>>(); H...
47f89818-49cb-4432-a1bd-8f80eb669059
7
public void notifySpritePaletteChanged() { if (paletteRegion != null) { paletteRegion.resetPalette(); } for (int i = 0; i < patternTableRegions.length; i++) { if (patternTableRegions[i] != null) { patternTableRegions[i].updatePatternTable(); } ...
bc714973-b2a3-4722-9070-a0cdb354d082
6
public static int loadShaderPair(String vertexShaderLocation, String fragmentShaderLocation) { int shaderProgram = glCreateProgram(); int vertexShader = glCreateShader(GL_VERTEX_SHADER); int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); StringBuilder vertexShaderSource = new StringBuilder(); StringBuil...
82819f7b-af22-4bf5-9b5f-17192abc6159
8
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int caso = 1; for(String line; (line = in.readLine())!=null; caso++){ StringTokenizer st = new StringTokenizer(line); N = Integer.parse...
0da3db9c-bfbc-4f40-a979-9809a3d2ac41
0
public CtrlComptesRendus getCtrlCR() { return ctrlCR; }
21b2736f-4491-43b3-ab3c-e45d4df4585c
4
@SuppressWarnings("unchecked") private void mondayCheckActionPerformed(java.awt.event.ActionEvent evt) { if(this.dayChecks[1].isSelected()) { this.numSelected++; if(this.firstSelection) { stretch(); } th...
b482283a-41c1-43cf-9219-78bb070a6217
1
public static PrototypeManager getManager() { if (pm == null) { pm = new PrototypeManager(); } return pm; }
23108368-59dc-4edd-8d5c-1034a3a7f303
5
public Method findMethod(String prefix, String methodName, Class<?> ... paramType) { if(methodName == null || methodName.isEmpty()) return null; methodName = createMethodName(prefix, methodName); try { return getInspectedClass().getDeclaredMethod(methodName, paramType); } catch (SecurityException e) { ...
b6c2549d-9666-47da-9149-b1c4dabccec8
6
public ChestKitsConfiguration(Configuration config, Logger log) { kits = new HashMap<String, ChestKitsKit>(); List<String> listOfKits = config.getStringList("kits"); if (listOfKits != null) { for (String kitName : listOfKits) { log.info("Loading kit " + kitName); List<?> items = config.getList("kitite...
552c86a0-a479-492a-9007-4856b4467ae2
9
public Operation sendUnconnectedOperation(final Operation operation) throws ConnectionException, TimeoutException { try { if (OperationType.isADisconnectedOperation(operation.getOperationType())) { createSocket(); MessageUtils.sendOperation(sock, operation); int retry = 0; Operation response; s...
85139be8-45c5-49e6-b064-780442f53833
9
public static Map<String, String> simpleCommandLineParser(String[] args) { Map<String, String> map = new HashMap<String, String>(); for (int i = 0; i <= args.length; i++) { String key = (i > 0 ? args[i-1] : null); String value = (i < args.length ? args[i] : null); if (key == null || key.starts...
9b570837-1d19-4b6d-b0d4-4c9d7cddc845
9
private void RemoveArestas() { LinkedList<Aresta> arestasPesoMinimo = new LinkedList<Aresta>(); ArrayList<Aresta> arestasAGM = (ArrayList<Aresta>) grafoDePalavrasAGM.Arestas(); Aresta[] arestasGrafoAGM = new Aresta[arestasAGM.size()]; for (int i = 0; i < arestasGrafoAGM.length; i++) arestasGrafoAGM[i] = ...
4055a368-6d0a-4f94-b336-36a1158b43c7
5
@Override public void addWord(String word) { if (Math.random() <= Math.pow(2., -h)) { MyString str = new MyString(word); Integer i = sample.get(str); if (i == null) sample.put(str, 1); else sample.put(str, 1 + i.intValue()); sumK++; } if(sumK == Math.pow(2., b)){ h++; Random...
9871c788-038e-4f5e-829e-c2f6ffe16c8d
9
@org.junit.Test public void multipleDragons() { Logic game1 = new Logic(10, 1, 1); char[][] maze=game1.getMaze(); int count=0; for(int i=0; i<10; i++) { for(int j=0; j<10; j++) { if(maze[i][j]=='D') count++; } } assertSame(count, 1); Logic game2 = new Logic(40, 2, 1); maze=game2.getM...
ac005d8d-9f72-4a4a-950f-779bbd9429c0
6
public Gap insertGapAt(int pos, int length, boolean exclusive) throws BadBytecode { /** * cursorPos indicates the next bytecode whichever exclusive is * true or false. */ Gap gap = new Gap(); if (length <= 0) { gap.position = pos; ga...
bedeb1b0-dea9-4b26-b6f5-761e66ef0dcb
7
@Override public void tableChanged(TableModelEvent arg0) { if(ignoreNext) { ignoreNext = false; return; } //System.out.println(""+arg0.getColumn()+" "+arg0.getFirstRow()+" "+arg0.getLastRow()+" "+arg0.getType()); int col = arg0.getColumn(); int row = arg0.getFirstRow(); int regvalue = 0; try ...
a7b353f2-36a1-46aa-97cf-4ffad575e412
7
public static void onIntentFinished(Activity sourceActivity, int requestCode, int resultCode, Intent data, String devPayload) { InAppPurchaseExtension.logToAS("Intent finished"); sourceActivity.finish(); sourceActivity = null; if(requestCode == BUY_REQUEST_CODE) { if(resultCode == Activity.RESULT_CAN...
7d2102ac-ffc0-4446-870f-952621556b88
5
public void put_branch(String roll, BasicDBObject document, DB_Init db_table, ArrayList<String> branchArray, ArrayList<String> rollStartArray, ArrayList<String> rollEndArray) { String first_char = roll.substring(0, 1); System.out.println("Outside branch insertion module "); for (int i = 0; i < branchArray.s...
32bbbd95-93ea-447c-b0df-614aeb80a62b
2
public synchronized void waitForNextDealConfirmation() { dealLatch = new CountDownLatch(1); KeyEventDispatcher dispatcher = new KeyEventDispatcher() { // Anonymous class invoked from EDT public boolean dispatchKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent....
1c9ce441-8454-4ecf-aec7-c2994b4d8d7c
2
public String getLyrics(String artistName, String songName) throws UnexpectedDataException { String lyrics = ""; // TODO: Sanitize string try { URI xmlURI = new URI("http", "lyrics.wikia.com", "/api.php", "artist="+ artistName +"&song="+ songName +"&fmt=xml", null); InputStream xmlStream = this.getIn...
092393a4-93bd-4d4a-8c51-021282115bf0
0
public void setPort(int port) { clientPort = port; }
2c3b7a14-de9c-4a39-a016-be15dfe54289
4
public static boolean deleteFolderContents(File folder) { File[] files = folder.listFiles(); for (File file : files) { if (file.isFile()) { if (!file.delete()) { return false; } } else { if (!deleteFolder(file)) { return false; } } } return true; }
7fa5278c-f524-4c27-839d-8d7b049b7294
3
public boolean equals(Object that) { if (!(that instanceof MockMessage)) return false; String thatMessage = ((MockMessage) that).getMessage(); if (this.message == null) return thatMessage == null; return (this.message == thatMessage) || this.message.equals(thatMessage); }
760a5a89-4ab4-4a75-84d6-fea36ec5569e
4
private boolean dadosValidos() { return !StringHelper.estaNulaOuVazia(txtCnpj.getText()) && !StringHelper.estaNulaOuVazia(txtEndereco.getText()) && !StringHelper.estaNulaOuVazia(txtNomeresponsavel.getText()) && !StringHelper.estaNulaOuVazia(txtRazaosocial.getText(...
0b59da52-39d8-498b-a210-5d47a31e90ed
2
public Node getFirstNodeAtPosition(int x, int y) { Enumeration<Node> nodeEnumer = Runtime.nodes.getSortedNodeEnumeration(false); while(nodeEnumer.hasMoreElements()){ Node node = nodeEnumer.nextElement(); if(node.isInside(x, y, pt)) { return node; } } return null; }
923a58af-d50f-4266-8a90-8c5c199e4d1e
0
public TrackedPeer(Torrent torrent, String ip, int port, ByteBuffer peerId) { super(ip, port, peerId); this.torrent = torrent; // Instanciated peers start in the UNKNOWN state. this.state = PeerState.UNKNOWN; this.lastAnnounce = null; }
41a7a7b2-a0d3-41b4-8a1e-b800a29d354c
8
boolean printHeaders(File targ, PrintStream ps) throws IOException { boolean ret = false; int rCode = 0; if (!targ.exists() || targ.getName().indexOf("..")>0) { rCode = HTTP_NOT_FOUND; ps.print("HTTP/1.0 " + HTTP_NOT_FOUND + " Not Found"); ps.write(EOL); ...
7822c00a-cc4f-458f-b655-29f33069bbd5
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...
16e7ea7f-bf5a-4590-95e0-76633f24cb89
6
public void startGUI() { /* 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 htt...
64c46acb-538c-479e-9e7a-0c9a600fce67
7
public void checkCherries(ArrayList<EntityCherry> ch){ for(int i = 0; i < ch.size(); i++){ EntityCherry c = ch.get(i); if(sliding){ if( c.getx() > x && c.getx() < x + (cwidth / 2) && c.gety() > y - height / 2 && c.gety() < y + height / 2 ){ c.hit(1); } } if(int...
67688423-9ea8-43ba-9506-0d20be627a80
5
public void run() { String csvFile = "USData.csv"; BufferedReader br = null; String line = ""; String cvsSplitBy = ","; int count = 0; try { br = new BufferedReader(new FileReader(csvFile)); //reads file line by line while ((line = br.readLine()) != nul...
c82c58eb-f97d-4089-be47-878d2bac2191
5
public List<String> calculateMotifEnumeration() { List<String> kMers; List<String> resultList = new ArrayList<String>(); kMers = getAllKMers(); for (String s : kMers) { List<String> mismatchList = createMismatches(s); for (String string : mismatchList) { ...
1221216c-68a2-48bd-ac94-d882fbf9f005
8
private ArrayList<Integer> straightLinePostProcessing(ArrayList<Integer> corners, double[] distApart) { ArrayList<Integer> filteredCorners = new ArrayList<Integer>(corners); boolean allLines = false; while (!allLines) { allLines = true; for (int i = 1; i < filteredCorn...
51a45069-15d8-4518-a598-0a36093c7b0b
2
public boolean setValue(String key, String value) { for(int i = 0; i < MAX_PROPS; i++) { if(keys_[i].equals(UNDEFINED)) { keys_[i] = key; values_[i] = value; return true; } } return false; }
1346c0a8-b80c-4b6b-b760-b904394e9683
1
private boolean jj_3_31() { if (jj_3R_48()) return true; return false; }
fcc2ddff-a529-4b54-b246-b267c90e9b65
5
public static List<Pregunta> buscaTemaGlobal(int numPreguntas) { /* * Habría que hacer una consulta aleatoria que sólo devuelva n líneas */ List<Pregunta> c = null; if (openConexion() != null) { try { String qry = "SELECT * FROM preguntas"; ...
ffe94591-3b53-42e6-9740-ca6be02fb6a1
6
private void kingLeftPossibleMove(Piece piece, Position position) { int x1 = position.getPositionX(); int y1 = position.getPositionY(); if((x1 >= 1 && y1 >= 0) && (x1 < maxWidth && y1 < maxHeight)) { if(board.getChessBoardSquare(x1-1, y1).getPiece().getPieceType() != board.getBlankPiece().getPieceType())...
481daf1e-a7c3-4180-9509-da0bf95710a0
7
public 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."); ...
b1602cb6-f484-487a-b0fc-88fead3ef318
2
@Override public String call() throws Exception { StringBuffer sb = new StringBuffer(); for (int i = 0; i < 10; i++) { sb.append(para); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } return sb.toString(); }
3ba72f18-f5b5-4b5d-8679-da0603d85fe8
6
protected void handleCommand(Player sender, String[] names) { Zone zone = executor.plugin.getSelectedZone(sender); if (zone == null) { sender.sendMessage("[InvisibleWalls] Please select an zone first. (Use: /iw select <zoneId>)"); return; } StringBuilder str = new StringBuilder(); for (String s : ...
ed78edc6-3281-4ae7-a6c7-d88986888d6f
7
@Override public int compareTo(VectorTimeStamp ts) { boolean beforeFlag = false; boolean afterFlag = false; // For vector time stamp, we need to compare corresponding value one by one for(Entry<String, AtomicInteger> e : localTS.entrySet()) { int local = e.getValue().get...
a1ceed78-b1de-4862-aa78-0026331aa83c
7
private synchronized void receiveAd(Sim_event ev) { if (super.reportWriter_ != null) { super.write("receive router ad from, " + GridSim.getEntityName(ev.get_src()) ); } // what to do when an ad is received FloodAdPack ad = (FloodAdPack)ev.get_...
9e02e5b9-535c-4b9c-9211-c3e20acb9297
1
public List<Object> getContent() { if (content == null) { content = new ArrayList<Object>(); } return this.content; }
09173a07-172b-40e9-a348-549ab03f88b8
5
private boolean conditionL0(String value, int index) { if (index == value.length() - 3 && contains(value, index - 1, 4, "ILLO", "ILLA", "ALLE")) { return true; } else if ((contains(value, index - 1, 2, "AS", "OS") || contains(value, value.length() - 1, 1, "A...
c2b4b975-ba0c-4640-8789-520ba4372c65
4
public void undo() { if (prevSpeed == CeilingFan.HIGH) { ceilingFan.high(); } if (prevSpeed == CeilingFan.MEDIUM) { ceilingFan.medium(); } if (prevSpeed == CeilingFan.LOW) { ceilingFan.low(); } if (prevSpeed == CeilingFan.OFF) {...