method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
13acacb2-e472-4f13-8bab-1fe1a25fab04
2
protected void updateLocation(double elapsedTime) { //oldPosition = position; currentForce = locMan.calculate(elapsedTime); // Update the applied forces. currentForce = currentForce.plus(locMan.calculateGravity(elapsedTime)); double forceReduction = 1; // makes orbits more graceful this.currentForce = current...
1730b811-e75d-47c8-b1b3-6e10dd767398
7
public boolean gameOver() { int cHerobrine = 0, cTotal = 0; for (int i = 0; i < instance.BoardSize; ++i) { for (int j = 0; j < instance.BoardSize; ++j) { if (instance.Board[i][j].getCard() != null) { ++cTotal; if (instance.Board[i][j].getCard().getID() == Card.HEROBRINE) { ++cHerobrine; ...
32f5dbe0-cae2-4c71-860b-fd187aea23be
4
@Override public void init() { super.init(); dyHeight = ByteTools.readShort( getByteAt( 0 ), getByteAt( 1 ) );// Height // in // 1/20 // point grbit = ByteTools.readShort( getByteAt( 2 ), getByteAt( 3 ) );// attributes icv = ByteTools.readShort( getByteAt( 4 ), getByteAt( 5 ) );// index // to // col...
48e28c52-d04f-4c36-9ae1-b0c381030b49
9
@Override public MoveWithPP getMove(int slot) { MoveWithPP result = null; if (slot == MOVE_ONE) { result = move1; } else if (slot == MOVE_TWO) { result = move2; } else if (slot == MOVE_THREE) { result = move3; } else if (slot == MOVE_FOUR) { result = move4; } else if (slot == SWITCH_ONE) { r...
4411cdc7-ed06-4679-be7d-eb524692eb27
7
private static void genData(String... args) throws Exception { if (args.length == 0 || args.length == 1 || args.length == 3) { File uniDir = (args.length < 3 ? Constants.uniDir : new File(args[0])); File triDir = (args.length < 3 ? Constants.triDir : new File(args[1])); ...
0a302519-e486-4075-803e-668932459097
5
private void postPlugin(boolean isPing) throws IOException { // Server software specific section PluginDescriptionFile description = plugin.getDescription(); String pluginName = description.getName(); boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enab...
9b16153d-1317-49e4-b7d0-1b02b46fd2f3
8
private void fetchRrdData() throws IOException { long tEndFixed = (tEnd == 0) ? Util.getTime() : tEnd; for (int i = 0; i < defSources.length; i++) { if (!defSources[i].isLoaded()) { // not fetched yet Set<String> dsNames = new HashSet<String>(); ...
f38cbda1-defe-4283-b1eb-72bc547a7e46
8
public void Show() { JButton btnAlta = new JButton("Alta"); hayUnaVentanaAbierta = false; //action listener Alta btnAlta.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if(!hayUnaVentanaAbierta){ try { hayUnaVentanaAbierta = true; ventanaAltaM...
8cd14d40-4da8-4c97-8797-f28d199a5ce1
6
public AnalyzeResult<T> solve() { List<RuleConstraint<T>> original = new ArrayList<RuleConstraint<T>>(this.rules.size()); for (RuleConstraint<T> rule : this.rules) { original.add(rule.copy()); } List<RuleConstraint<T>> inProgress = new ArrayList<RuleConstraint<T>>(this.rules.size()); for (RuleConstraint...
4d53f8b6-cff0-4453-aacd-083b14701a2c
9
public void animateToSize(int x, int y) { int currentX = getWidth(); int currentY = getHeight(); int dx = x - currentX; int dy = y - currentY; int ppsX = dx / 20; int ppsY = dy / 20; int i = currentX; int j = currentY; for (int c = 0; c < 20; c ++) { i += ppsX; j += ppsY; if (x !...
3dfe278d-2567-41fa-91bd-a5c4045992a8
2
private void checkRange(int value, int min, int max) throws BoardException,ExitException{ if (value < min|value > max) { throw new BoardException("Input a value between " + min + " and " + max + "."); } else if(value == -1){ throw new ExitException(PLAYING); } ...
1b0519f0-caa4-4521-bd67-04dd8b0a0593
1
public BitInputStream(InputStream in) { if (in == null) throw new NullPointerException("Argument is null"); input = in; numBitsRemaining = 0; isEndOfStream = false; }
c5acb60d-cea7-412c-962b-976f2fe130ac
8
private void updateRankings() { if (lastRBRanking > 0) { if (rbRankings != null) { rbRankings.clear(); } if (rbRankingsByName != null) { rbRankingsByName.clear(); } } Connection con = DatabaseConnection.getConnection...
13d9a123-a6f6-4021-8de0-edd48281f99e
0
public void setStatus(byte status) { this.status = status; }
3ed8439e-7317-4738-8254-d0fad1d919d5
2
public static double[] consumptionMemory(Memory memory, UsageMemory usageMemory) { double f1 = (usageMemory.getEstimatedMilliseconds() / 1000.0) * (usageMemory.getUtilization() * memory.getWorkConsumption() + (1 - usageMemory.getUtilization()) * memory.getIdleConsumption()); double f2 = (usageMemory.getSize().getMe...
c1698d78-8182-4ca1-aaa6-3218ddc9afa1
8
public boolean canMoveLeft(){ int emptyColumsFromLeft=0, j, i; // check for field boundaries on the right side for(i=0;i<(t.getySize()-1);i++){ if(!t.columnIsEmpty(i)){ break; } emptyColumsFromLeft++; } if((t.getPosX()+emptyColumsFromLeft)<=0){ return false; } // check for other blocks...
825272d2-0930-4738-ad79-05e3948fe0fe
8
private Object handleEventFact(Object tos, String tagName, String tagNameUpper) { if ((tos instanceof Person && EventFact.PERSONAL_EVENT_FACT_TAGS.contains(tagNameUpper)) || (tos instanceof Family && EventFact.FAMILY_EVENT_FACT_TAGS.contains(tagNameUpper)) || (tos instanceof EventFact && "CAUS...
94d6335f-786a-42fe-8acd-7314c05af5d4
2
public void insertDates() throws ParseException { // http://docs.oracle.com/javase/tutorial/essential/io/file.strHtml // http://docs.oracle.com/javase/tutorial/java/data/manipstrings.strHtml // Path file = Paths.get("/home/mark/0-prj/bible/bookchap-v3.csv"); Charset charset = Cha...
65a47dd7-a165-4f84-af33-a250ab644c05
9
public Model method209(int j, int k, boolean flag) { Model model; if(flag) model = method206(anInt255, anInt256); else model = method206(anInt233, mediaID); if(model == null) return null; if(k == -1 && j == -1 && model.anIntArray1640 == null) return model; Model model_1 = new Model(true, Class36...
05fed377-be57-4f8e-a7e3-baa7f32679f9
3
void solve2() { NHL nhl = new NHL(in); int[] totals = new int[30]; for (Match m : nhl.matches) { totals[m.score.total]++; } for (int i = 0; i < totals.length; i++) { if (totals[i] != 0) { out.println(i + " -> " + totals[i] ...
9ca6bd7c-0b77-4c8c-a78e-f6345027170a
6
public String[][] cardAssignment() { Set<String> tempCards = new HashSet<String>(); Set<String> threeYes = new HashSet<String>(); String aYes = cardAssignmentHelper(); tempCards.add(aYes); threeYes.add(aYes); String bYes = cardAssignmentHelper(); while (tempCards.contains(bYes)) { bYes = cardAssignment...
142c6264-9fe4-40e8-bacc-d2cbbfd85185
5
@Override public Calendar plan(ArrayList<Calendar> calendars, TaskList tasklist, String calendarName) throws PlanningException { ZonedDateTime last = tasklist.getLastDeadline(); ZonedDateTime now = ZonedDateTime.now(); Calendar merged = PlanningUtil.mergeCalendars(ApplicationSettings.getInstance().getLocalizedM...
c31637d9-d5b3-4326-b7c2-c2f971f83242
1
public CompositeConcreteFlyweight factory(String data) { int len = data.length(); CompositeConcreteFlyweight ccfw = new CompositeConcreteFlyweight(); for (int i = 0; i < len; i++) { ccfw.add(String.valueOf(data.charAt(i)), this.innerFactory(String.valueOf(data.charAt(i)))); } return ccfw; }
eaa9f844-f82c-406f-a5ba-79775b131744
0
public int getCapacity()//Accessor method { return data.length; }
708e8c3e-38e7-4c83-82b5-eae76b45573f
7
public static double analyseTextForLanguageSet( HashMap<Integer, HashMap<Character, Integer>> languageFreqMap, HashMap<Character, Integer> charCountMap) { double expectedCount = 0; double tempSum = 0; double currentSum = Integer.MAX_VALUE; // iterate through the map created of character instances found ...
632d21ba-7db8-488d-9bfd-e870e9b8aae7
5
public void selectPiece(int x,int y){ if(x>0&&x<canvas_width&&y>0&&y<canvas_height){ current_square_x = x/grid_size; current_square_y = (y/grid_size_y)-2; if(board.getBoardArray()[current_square_y][current_square_x].getOccupied()!=null){ selected = board.getBoardArray()[current_square_y][current_square_x].g...
8aeafb3b-5fe2-4cca-952e-7e1ff39fe4ab
9
public void clipSourceDest(CPRect srcRect, CPRect dstRect) { dstRect.right = dstRect.left + srcRect.getWidth(); dstRect.bottom = dstRect.top + srcRect.getHeight(); if (isEmpty() || dstRect.left >= right || dstRect.top >= bottom || dstRect.right <= left || dstRect.bottom <= top) { srcRect.makeEmpty(); d...
ca4ac91c-d040-4c71-8dac-7dc2bed34e41
0
public void onTrackLimitationNotice(int numberOfLimitedStatuses) { //System.out.println("Got track limitation notice:" + numberOfLimitedStatuses); }
abb6ade0-f262-4488-a008-6153368acb71
0
@Override public void actionPerformed(ActionEvent e) { expandEverything((OutlinerDocument) Outliner.documents.getMostRecentDocumentTouched()); }
1651e90d-d596-4df9-8b81-6899532c3544
9
public Path prepareDataSet() throws IOException { // Get hadoop file system configuration. FileSystem fs = FileSystem.get(this.conf); // Check if a single file was referenced, otherwise our implementation can't handle it. if (!fs.exists(this.path)) throw new IOException(Coefficient.EOL + "You have to specify t...
16482af0-0159-49cb-87a5-1818ad68bdf4
5
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerCommandPreprocess( final PlayerCommandPreprocessEvent event) { if (MonsterIRC.getHookManager().getTownyChatHook() != null) { final Player player = event.getPlayer(); final String split[] = event.getMessage...
b11bf510-fbe9-4913-9925-ff38839f6878
2
private void collectAllMasses() { for (Assembly a : getModel().getAssemblies()) { for (Mass m : a.getMasses()) { myMassesToAssembly.put(m, a); } } }
68361f5a-4ca6-4abc-a5a3-eaf2e7d51a94
8
private void readAlterations(String path, DataModel dataModel) { try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse(new File(path)); // normalize text representation ...
046ff50b-1d86-4dfa-a0b8-45f5762ebed2
0
@Override public void restoreTemporaryToCurrent() {tmp = cur;}
3c7c81ea-a588-4f12-943d-b76069b6469c
2
public static ArrayList<String> parseStringList(String string){ ArrayList<String> result = new ArrayList<String>(); if(string!=null){ String[] aliasesStrings = string.split("\\Q | \\E"); for(String s : aliasesStrings){ result.add(s); } } ...
1cdc2d2c-2e17-42e5-a4aa-20248820ef67
6
public static double determinant(Matrix matrix) { double sum = 0.0; int columns = matrix.getColumnDimension(); int rows = matrix.getRowDimension(); if (columns == 1) { return matrix.get(0, 0); } for (int i = 0; i < columns; ++i) { Matrix smaller = ...
6f7cdfcd-2795-4d0f-8b11-3063d0b46f3b
6
@EventHandler public void WitchFastDigging(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getWitchConfig().getDouble("Witch.FastDi...
1326346e-a493-45c2-bed6-d84359b6c781
5
final void reset() { anInt2660++; if (!isPaused) { synchronized (this) { isPaused = true; this.notifyAll(); } if (request != null) { while (request.state == 0) Class286_Sub5.method2161((byte) 105, 1L); if (request.state == 1) { try { ((Thread) request.returnObj).join(); } c...
f2857dff-70d2-40e0-9409-8e1e72939389
3
public void caretUpdate(CaretEvent e) { if (e.getSource() instanceof JTextPane) { final JTextPane tp = (JTextPane) e.getSource(); Runnable r = new Runnable() { public void run() { for (int i = 0; i < sFontStyleNames.length; i++) { String buttonName = sFontStyleNames[i]; JTog...
10751d15-2763-4400-a557-a468e20fb237
9
@Override void update() { super.update(); angle = Math.atan2((Player.y + (Player.SIZE / 2)) - (y + (SIZE / 2)), (Player.x + (Player.SIZE / 2)) - (x + (SIZE / 2))); x += Math.cos(angle) * speed; y += Math.sin(angle) * speed; if (!remove && Player.x + Player.SIZE > x &...
532cf58d-0d64-4964-8d4c-142e5bd8fbbf
8
public void run() { paintLS = new LiveSystem(level, panelWidth, panelHeight); physicsLS = new LiveSystem(paintLS); frame.getContentPane().add(actP); frame.getContentPane().validate(); frame.getContentPane().repaint(); actP.requestFocusInWindow(); ...
7062685c-c5ae-4c12-aaf3-4c8f35f2dc47
5
public void UpdatePlayerShop() { for (int i = 1; i < PlayerHandler.maxPlayers; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].IsShopping == true && PlayerHandler.players[i].MyShopID == MyShopID && i != playerId) { PlayerHandler.players[i].UpdateShop = true; } } } }
8e9a0148-3917-45e2-9663-99a3490def92
8
public void moveRight() { setDirection(90); for (TetrisBug tb : blocks){ tb.setDirection(90); } if (rotationPos==0){ if (blocks.get(1).canMove() && canMove()) { blocks.get(1).move(); move(); blocks.get(0).move(); blocks.get(2).move(); } } if (rotationPos == 1){ if (...
8bd0813c-c088-428d-883f-f96affdda9ca
6
public void loop() { game.init(); long timer = System.currentTimeMillis(); long before = System.nanoTime(); double elapsed = 0; double nanoSeconds = 1000000000.0 / 60.0; int ticks = 0; int frames = 0; while(running) { if (Display.isCloseRequested()) stop(); Display.update(); widt...
c9785714-2eac-4561-b54d-f5f292ed62fb
3
@Override public Iterator<Position<T>> iterator() { Iterable<Position<T>> ps = null; try { ps = positions(); } catch (InvalidPositionException e) { e.printStackTrace(); } catch (BoundaryViolationException e) { e.printStackTrace(); } catch (EmptyTreeException e) { e.printStackTrace(); } return...
fbc3d7b2-4545-4d4c-855c-25a28e385084
0
public SampleDao getDao() { return dao; }
ab2677ec-e3a0-405e-8eca-dea4d3f22806
2
private boolean jj_3R_58() { if (jj_3R_88()) return true; if (jj_3R_75()) return true; return false; }
4e09eb2d-8793-466d-9aa9-107def41c3f9
6
public void loadProposals() { this.proposals.clear(); ProposalModel proposalModel = new ProposalModel(); String selectedStatus = statusComboBox.getSelectedItem().toString(); String statusQuery = ""; if (selectedStatus.equalsIgnoreCase("active")) { statusQuery = ", ex...
4c0311db-3be2-4578-a79d-18f7062a6e60
7
public static IConversionWorker getConversionWorker(String mimeType, List<String> outputMimeTypeList, File incomingFile, File OutputDir, int limit, Conversion conversion, String realPath) { System.out.println(realPath); System.out.println(mimeType); System.out.println(outputMimeTypeList.get(0)); if (MimeT...
40319313-a0d8-4bde-815b-29424a19e7fd
9
public void keyPressed(KeyEvent keyEvent) { char pressedKey = keyEvent.getKeyChar(); int pressedKeyVal = keyEvent.getKeyCode(); if (pressedKey == 'd' || pressedKey == 'D' || pressedKeyVal == KeyEvent.VK_RIGHT) chell.setXVelocity(PLAYER_MOVE); if (pressedKey == 'a' || pressedKey == 'A' || pressed...
b9355ea8-30fa-4746-9faa-81db716cbe5d
6
@Override //Auto Generated public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; State other = (State) obj; if (rows[0] != other.rows[0]) return false; if (rows[1] != other.rows[1]) return false; if...
092c7dde-c4ef-45c1-a951-b02eb091de16
0
@Test public void testRankOutOfRange() { int key = 10; int result = BinarySearch.rank(N, key); assertEquals(BinarySearch.KEY_NOT_FOUND, result); }
f43f3df1-c088-4734-8ec9-39d5be422400
4
public static void Look() { CountItems(Rooms.currentRoom); if(ItemCount != 1) { GUI.log("There are "+ItemCount+" objects in this room."); } else { GUI.log("There is 1 object in this room."); } if(ItemCount != 0) { for(int i=0; i<Items.roomItems[Rooms.currentRoom-1].length; i++) { if(Items.room...
2e86f32c-42c4-43cf-984c-4e77e8ed5cf5
5
private void showPage(URL pageUrl, boolean addToList) { try { // Get URL of page currently being displayed. URL currentUrl = displayEditorPane.getPage(); // Load and display specified page. displayEditorPane.setPage(pageUrl); //displayEditorPane.setPage("http://192.168.1.90/h...
9ad3de91-f502-4a25-90e2-742509cec67b
0
public static void main(String[] args) { InputBox ib=new InputBox(null, null, "input"); }
cc4a9205-cc11-4d1d-82a6-2ba8aba5ecc4
7
private void collectMails() { int count; String line; sendToMailbox("STAT "); String[] request = readFromMailbox().split(" "); if (request[0].startsWith("+OK") && request[1] != null) { count = Integer.parseInt(request[1]); line = ""; } else { ...
291e0038-b8fb-4253-b095-ab770c10f55c
4
public void progress() throws NotExistException { ListElement currentRobot = this.robotPlace.getHead(); List banList = new List(); int amount = this.robotPlace.listAmount(); while (currentRobot != null) { if (!banList.exist(currentRobot.getId())) { int startPl...
9c691548-a1a8-4f51-80fe-593e777cfa6c
4
public void removeCellSwitch(int x, int y) { for (int i = 0; i < switchGates.length; i++) { if (switchGates[i] == null) continue; for (int j = 0; j < switchGates[i].getSwitchSize(); j++) { if (switchGates[i].getNearSwitch(x, y)) { switchGates[i].removeNearSwitch(x, y); } } } }
c24e09da-2192-46dc-a31a-155ad3caa09a
4
@Override public void actionPerformed(ActionEvent e) { Object click = e.getSource(); if (click == GuiMainWindow.playersOnline) { new PlayersOnline(); } else if (click == GuiMainWindow.topPlayers) { new TopPlayers(); } else if (click == GuiMainWindow.exit) { System.exit(0); } else if (click == GuiMa...
a46af0c7-e9cb-45ec-acff-ead60a2e7551
0
private void verDatos(){ idLabel1.setText(Integer.toString(cliente.getIdCliente())); nombre1.setText(cliente.getNombre()); apellidos1.setText(cliente.getApellidos()); apodo1.setText(cliente.getApodo()); especial1.setSelected(cliente.isEspecial()); nombre1.disable(); ...
d4c9637a-7b1e-45b2-9e34-9d881c512717
1
public Integer find(String key){ if (root == null) { return null; } return Find(key,root); }
e848a653-07f8-4b5d-b569-9c3c10e6fbb5
2
public static boolean search(int[] A, int value, int index) { for(int i = 0; i< A.length; i++) { if(value == A[i]) { return true; } } return false; }
1ada7363-f682-4ca1-b3e2-e2d1be6f15cf
2
public MonitorAction produceStatsListForName(String name) throws Exception { init(); List<StatView> list = produceListOfViews(db.getStatsFor(name)); StatView latestOne = new StatView(db.obtainLatestStat(name)); if (list.size() == 0 || list.get(0).compareTo(latestOne) != 0) li...
34e1ff79-ddc3-4e05-b495-faad2350b00e
7
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
ac107fb4-9ee8-4ab7-bd5f-be1cc5ae6199
3
public static float getFloatNumber(FloatingPoint floatingPoint) { if (floatingPoint == null) { return 0.0f; } float value = 0.0f; if (floatingPoint.getDevide() >= Lexer.FLOATING_POINT_DEVICE_OFFSET) { if (floatingPoint.getValue() < 0) { value = (-(float) floatingPoint.getValue()) + (float) flo...
57333bb9-43e0-4784-83f3-9979749b8305
3
public OpenGLDisplay(int width, int height, String title) { glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err)); if (glfwInit() != GL_TRUE) { throw new IllegalStateException("Unable to initialize GLFW"); } glfwDefaultWindowHints(); glfwWindowHint(GLFW_VISIBLE, GL_FALSE); glfwWindowHint...
a88a9ad5-f2b7-46b0-9b13-f0036d58f22f
1
private boolean jj_3_39() { if (jj_3R_58()) return true; return false; }
f81cc3c6-2a20-47c2-a1b4-5d8c04c9123f
9
private static final void method1786(int ai[], int ai1[], int ai2[], byte abyte0[], int i, int j, int k) { int l = 0; for (int i1 = i; i1 <= j; i1++) { for (int l2 = 0; l2 < k; l2++) { if (abyte0[l2] == i1) { ai2[l] = l2; l++; } } } for (int j1 = 0; j1 < 23; j1++) { ai1[j1] = 0; }...
81b55468-e661-4a6b-91a3-b32caa5f8345
9
public Object clone() { Usersinfo cloned = new Usersinfo(); if (this.identification != null) cloned.setIdentification(new String(this.identification)); if (this.sipuri != null) cloned.setSipuri(new String(this.sipuri)); if (this.state != null) cl...
09b6efd3-49c2-447b-bc91-6445aaf8a4bf
5
public static void main(String[] args) { String dataFile = DEFAULT_DATA_FILE; int trainingExamples = DEFAULT_TRAINING_EXAMPLES; for(int i = 0; i + 1 < args.length; i += 2) { if(args[i].equals("-f")) { dataFile = args[i + 1]; } else if(args[i].equals("-e")) { trainingExample...
bf59ad09-fd65-40fc-bdd1-fd1915667d68
1
public void run() { /*================================================================== * THE GAMELOOP THREAD *===================================================================*/ //================================================================== initGame(); isRunning = true; //ProcessThread ...
f9ccab09-cb9b-4cd0-84fb-94ccf6c0d9cb
7
private final boolean cons(int i) { switch (b[i]) { case 'a': case 'e': case 'i': case 'o': case 'u': return false; case 'y': return (i==0) ? true : !cons(i-1); default: return true; } }
7dfe64ca-ae36-4c88-827a-958b93fdaa3b
4
public void move(Rectangle2D bounds) { x += dx; y += dy; if (x < bounds.getMinX()) { x = bounds.getMinX(); dx = -dx; } if (x + XSIZE >= bounds.getMaxX()) { x = bounds.getMaxX() - XSIZE; dx = -dx; } if (y < bounds.getMinY()) ...
dd54c6a0-07d5-441a-b556-2443b3e822df
4
public boolean saveIpbUser(String user) throws ClassNotFoundException, SQLException { sqlClass(); sqlCon(); if (!customField.isEmpty()) { query = "SELECT member_id FROM " + tablePref + "pfields_content WHERE field_" + customField + " ='" + user + "'"; ResultSet rs = SELECT(query); if (rs.nex...
d2224fb2-5578-48e1-8e13-5c37ba1c7567
2
public Forum getForum(String forumId) { for (int i = 0; i < forums.size(); i++) if (forums.get(i).getId().equals(forumId)) return forums.get(i); return null; }
0ecea97f-c646-4f53-bfc9-52ecd19a34e5
7
public static<T> T executeInPrepareStmt(QueryCallBack<T> cb) { T result = null; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = ConnectionUtil.getConnection().prepareStatement(cb.getSql()); result = cb.doInCallback(pstmt); rs = cb.g...
a2ad3aa3-2dca-461b-a6d9-a5e7fd6c059f
3
public int climbStairs(int n) { if (n == 1) return 1; if (n == 2) return 2; int a = 1; int b = 2; int c = a + b; for (int i = 3; i < n; i++) { a = b; b = c; c = a + b; } return c; }
95bf49c3-9d20-4ec2-ba24-dd677b5b9cc5
7
public void init() { JRootPane rootPane = createRootPane(); // load properties defaultPropsURL = getResource("freemind.properties"); try { // load properties defaultProps = new Properties(); InputStream in = defaultPropsURL.openStream(); de...
7cb1d19c-551e-4e45-b746-9130cb1bc3b6
7
private boolean isValidInvocation(Method method, Object[] arguments) { // all listener methods are valid if (listenerMethodName == null) { return true; } // method's name matches if (listenerMethodName.equals(method.getName())) { // no arguments in call a...
b40c1abf-baf5-4400-a8ad-8390af73ff47
4
public void deleteRegion(final Region region, final boolean immediate) { final BufferedYamlConfiguration config = this.configuration.get((region.isDefault() ? null : region.world)); String path = region.name; if (region.isDefault()) if (region.world == null) { path =...
d6c7fa79-d7d0-4cc0-92a3-c1b6ae8e1493
0
@MyDocumented("javadoc use") public void document() { System.out.println("My Document !!"); }
089ad115-7584-41cd-a257-5bb2fd87201e
2
@Override protected void process() { super.process(); Actor actor = ai.getActor(); Player player = registry.getPlayerManager().getPlayerById(target); if(actor == null || player == null) { return; } Point p = player.getCenterPoint...
58b1eba0-a563-4177-a3ec-2952afdc9b9c
6
public void fly() { synchronized (enemy_Launcher) { boolean status = enemy_Launcher.isHidden(); if (status) { // if missile is hidden set him as unhidden enemy_Launcher.setHidden(false); } // if missile alive and launcher is alive if (this.isAlive && enemy_Launcher.alive()) { War.theLogger.log...
1c7ad4fe-2037-4e20-a6fb-238e8b7c0d7c
3
public void create(Booking booking) throws DuplicateInstanceException, MaxCapacityException, NotValidDateException { if (!existsBooking(booking)) { checkCapacity(booking); try { if (SchoolCalendar.isNotHoliday(booking.getDate())) { bookings.add(booking); } else { throw new NotValidDateExcep...
56af22ad-2ff8-4438-8741-1b289b782f49
8
private static void primitiveIO(Environment e, boolean trace) { final LWord a = new LWord(LWord.Type.Name, "argument1"); final Scanner in = new Scanner(System.in); if (trace) { e.addTracer(new Tracer() { public void begin() { System.out.println("tracer: begin."); } public void end() { System.out.p...
ea07f4f2-b848-492e-a663-6a593e4a5040
5
public boolean cast (Sorcerer sorcerer, Trigger trigger, Event event) { PlayerInteractEvent interactEvent = (PlayerInteractEvent) event; interactEvent.setCancelled(true); if (trigger.isBlockTriggered()) { Location target = interactEvent.getClickedBlock...
326a9b24-7487-4739-80b5-988d222a158c
3
private void printLab() { for (Node2[] row : nodeNetwork) { for (Node2 node : row) { System.out.print("Node: (" + node.getX() + "," + node.getY() + ") Children:"); for (Node2 child : node.getChildren()) System.out.print(" (" + child.getX() + "," + child.getY() + ")"); System.out.println(); } } }
d129be4f-254b-439a-8a8f-17512695344f
0
@Id @GenericGenerator(name = "generator", strategy = "increment") @GeneratedValue(generator = "generator") @Column(name = "sale_id") public int getSaleId() { return saleId; }
53deb369-b65f-4df0-9042-9dd296616d2c
8
private int obtenerCuadrante(int x, int y) { int retorno=0; if(x<=2) { if(y<=2) { retorno=1; } else if(y<=5) { retorno=2; } else { retorno=3; ...
649ae28f-1890-4fb9-938a-5ff33f565709
0
public void right(int velocity) { controls.right(velocity); }
06b5a27e-ff16-444d-9696-6fefe4836fc3
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; SearchResult other = (SearchResult) obj; if (keyword == null) { if (other.keyword != null) return false; } else if (!keyword.equals(othe...
539c980d-f21e-4882-baf8-eb253ad7d352
7
public String calculateMargin() throws MonkeyTalkFailure { Application app=new ConnectClass().connect(); String results=null; try { app.tabBar().select("Markets"); app.button("Search").tap(); app.input("_searchField").enterText(cfdMarket, "enter", new Mods.Builder().thinktime(5000).build()); app.la...
654f6a06-bdf1-4d30-b767-7cd1f265e84f
4
@Override public void run() { for(int i = 0; i < 20; i++) { queue.add(new PrioritizedTask(rand.nextInt(10))); Thread.yield(); } try { for (int i = 0; i < 10; i++) { TimeUnit.MILLISECONDS.sleep(250); queue.add(new P...
4b5772bb-7ad1-4444-8f5d-d67781296181
0
TreeNode(int x) { val = x; }
5ab74573-ee8b-4fd4-a29d-bb92bd5d93ca
4
public void userKeyInteraction(int keyCode ) { // Key typed includes specials, -ve // Char is ASCII value switch ( keyCode ) // Character is { case -KeyEvent.VK_LEFT: // Left Arrow break; case -KeyEvent.VK_RIGHT: // Right arrow break; case -K...
9156c48c-4004-4540-a996-1375a25b5a6d
2
private long binFlippedDiskOf(long binPosition){ long binFlippedData = binIsBlack; if(isBattingFirstTurn){ binFlippedData = (binIsBlack | binPosition); } else if( (binIsBlack & binPosition) != 0 ){ binFlippedData = binIsBlack - binPosition; } retu...
be249ec9-cf2f-4f93-b291-036ff5f3729c
2
public Order getOrderById(int id,ArrayList<Order> list){ for(int i = 0; i < list.size(); i++){ if( list.get(i).getId() == id ){ return list.get(i); } } return null; }
01f9e9e6-fb92-4102-a8b1-04600a028294
6
public static IndexSearcher wrapUnderlyingReader(final IndexSearcher s, final int edge) throws IOException { IndexReader r = s.getIndexReader(); // we can't put deleted docs before the nested reader, because // it will throw off the docIds IndexReader[] readers = new IndexReader[] { edge < ...
67f7e76f-9c69-4428-b379-d12fc3777109
6
private Instruction makeCall(Identifier name, ArrayList<Value> args) throws Exception { if(name.equals(inputNum)) { if(args.size() != 0) { throw new Exception("Incorrect number of arguments for builtin function"); } return new Read(); } ...
bda1ba01-ce1c-4b0c-9f0f-cb7df55af9cc
5
private void populateList(List<ProtectionEntry> entries, List<ProtectionEntry> candidates, ConnectionWrapper cw) throws SQLException { List<ProtectionEntry> nuCandidates = new ArrayList<ProtectionEntry>(); for (ProtectionEntry pe : candidates) { List<ProtectionEntry> tmp = listAllDependentEntries(pe, cw); ...