method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
1353b124-e837-41e8-a8df-f2b9d7863ca7
0
public byte[] getJ() { return j; }
4125e564-8f61-442d-bcd1-15a9635c3920
5
private int setLessThanUnsigned(int first, int second) { for(int i = 31; i >= 0; i--) { boolean bitOfFiirst = BinaryManiplator.getBitByIndex(first, i); boolean bitOfSecond = BinaryManiplator.getBitByIndex(second, i); if(!bitOfFiirst && bitOfSecond) return 1; if(bitOfFiirst && !bitOfSecond) return ...
b76208f8-824a-498a-bbbe-52a242116860
6
public int minimumPrice(int[] dread, int[] price) { int ans_coins = 0; long total_dread = 0; int n = dread.length; for(int i = 0;i < n;i++){ if(total_dread < dread[i]){ total_dread += dread[i]; ans_coins += price[i]; }else{ long a_dread = total_dread; a_dread += dread[i]; int a_coins =...
c2ae9072-0583-4747-af70-847c7ffe46c9
5
public Boolean checkBust(){ int check = getHandCount(); if (check<=21) bust=false; else if ((check>21)&&(!acechecked)&&(ace)) { checkAces(); hand.get(aceindex).changeAce(); acechecked = true; checkBust(); } else if(check>21) bust=true; return bust; }
be1b2ea5-b9fc-43f2-b9b1-2d21272d4a76
5
private void calcularSensibilidad(double valorActivacion, double error, int numeroEntradasIniciales){ //Derivada de la funcion de activacion y(1-y) double derivadaAdaline = valorActivacion * (1-valorActivacion); this.sensibilidadAdaline = -2 * derivadaAdaline * error; //System.out.println("S[" + this.getNume...
4b742175-3d54-4170-b98f-5843caa08974
1
public void mouseEntered(MouseEvent evt) { if (evt.getSource()==close){ mousein = 1; } }
d66e7ddf-bd36-4228-94ff-faaa964bcba7
3
@Override public int getVendidosTotal() { try{ conn = ConnectionFactory.getConnection(); String sql = "SELECT COUNT(id) AS vendidos FROM ingresso WHERE idcompra IS NOT NULL"; ps = conn.prepareStatement(sql); rs = ps.executeQuery(); if (rs.next())...
076e82d2-32c5-4697-af7e-c34c8cd53408
0
public String getAddress() { return addressText.getText(); }
2cb659a4-0b50-48c7-b130-daf9071575de
5
@Override public void update(int mouseX, int mouseY, boolean pressed) { super.update(mouseX, mouseY, pressed); if(this.btnBack.wasClicked()) Game.instance.setCurrentGui(this.parent); if(this.btnNext.wasClicked() && this.page < 4) this.page++; if(this.btnPrev.wasClicked() && this.page > 0) this.page-...
e2766778-5805-4934-86d3-4600fbeefee7
2
private void putRequest(HttpExchange he) throws IOException { try { InputStreamReader isr = new InputStreamReader(he.getRequestBody(), "UTF-8"); BufferedReader br = new BufferedReader(isr); String jsonInput = br.readLine(); String path = he.getRequestURI().getPa...
ae034f0c-c870-45fe-a1ec-4a75e66e20d4
8
public void drawFlipped(Bitmap image, int xPos, int yPos, int xo, int yo, int w , int h, int trans){ for(int y = 0; y < h; y++){ int yPix = y+yPos; if(yPix < 0 || yPix >= height)continue; for(int x = 0; x < w; x++){ int xPix = x+xPos; if(xPix < 0 || xPix >= width)continue; int src = image.pi...
d8983bc5-2954-419b-b6b0-8db5d5423fb6
1
public synchronized void addPastGame(GameResults pastGame) { GameResults[] temp = new GameResults[pastGames.length]; for(int i=0;i<pastGames.length-1;i++){ temp[i+1] = pastGames[i]; } temp[0]=pastGame; pastGames = temp; }
b4e1d245-f537-45eb-abb9-e5a093fcdff5
6
public void move(long delta) { // since the move tells us how much time has passed // by we can use it to drive the animation, however // its the not the prettiest solution lastFrameChange += delta; // if we need to change the frame, update the frame number // and flip over the sprite in use ...
e75c2725-e8e3-4d94-a639-72e2c2c9fa0b
5
public void getStats() { Iterator sentenceIterator = sentenceMap.entrySet().iterator(); Iterator wordsIterator; while(sentenceIterator.hasNext()) { Map.Entry sentencePair = (Map.Entry) sentenceIterator.next(); Sentence sentence = (Sentence) sentencePair.getValue(); ...
99b51d3b-801e-43c4-92e2-7afd528d54ea
4
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (active(request)) //if there is an active user { if (request.getRequestURI().equals(request.getContextPath() + "/profile")) //if there is no string after profile/ { //current user, ...
ae8c83ce-ce34-494f-9b5b-db5e4aac21cb
1
public static boolean isUsersReady(){ boolean result; if (user_list.size() == ready_users.size()){ result = true; } else { result = false; } return result; }
a7d3ccb0-af48-4ac0-83ae-414621f827f2
2
private static void debugMode(String s, boolean ln) { if (debug) { if (ln) { System.out.println(s); } else { System.out.print(s); } } }
116432dd-8cee-4e25-91c0-ec7510ce46cf
8
private ITrackDescriptor getTrackDescByRow(int selectedRowIndex, JTable table) { String song = ((DefaultTableModel) table.getModel()).getValueAt(selectedRowIndex, 0).toString(); String artist = ((DefaultTableModel) table.getModel()).getValueAt(selectedRowIndex, 1).toString(); String album = ((De...
94b7d839-5885-44a0-bc50-b6600f8bd0a5
4
@Override public int compareTo(WorkUnit object) { if (this.projectId == object.getProjectId() && this.workLoad == object.getWorkLoad() && this.workerId == object.getWorkerId()) return 0; if (this.workLoad > object.getWorkLoad()) return 1; return -1; }
adcb46f7-9e3a-4874-b733-080a2f729d45
5
private void damage(int dmg) { dmg = dmg > 999 ? 999 : dmg < 0 ? 0 : dmg; hp -= dmg; if(hp <= 0){ kill(); } dmgLen = dmg < 10 ? 1 : dmg < 100 ? 2 : 3; n[0] = dmg % 10; dmg -= n[0]; n[1] = (dmg % 100) / 10; dmg -= n[1] * 10; ...
e1d34d04-6c15-4ac7-bdfc-1546197ec6e6
9
public void prepareAttributes() throws XPathException { AttributeCollection atts = getAttributeList(); String selectAtt = null; for (int a=0; a<atts.getLength(); a++) { int nc = atts.getNameCode(a); String f = getNamePool().getClarkName(nc); if (f.equals(StandardNames.MODE)) { modeAttribute ...
98de62e4-476e-4294-bf61-709100ba09a8
5
private void createContent() { // link listener Listener linkListener = new Listener() { @Override public void handleEvent(Event event) { // check if the default browse action can be called if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupp...
37a2af1d-eb3a-4fc4-b0c7-400868a5e25e
4
public List<Float> databaseMedicinePrices(String columnName) throws SQLException{ //List<String> medicineName=new ArrayList(); float amount=0; List<Float> medicinePrice=new ArrayList(); try{ databaseConnector=myConnector.getConnection(); stmnt=(Statement)...
95ffaa89-38f6-45dc-96db-8f2bfa24f673
6
public static Cons yieldListifiedVariableArguments(Cons walkedargs, StandardObject targettype, boolean wrapargsP) { if (!(walkedargs == Stella.NIL)) { { Stella_Object listifiedargs = Stella.SYM_STELLA_NIL; { ConsIterator it = walkedargs.allocateIterator(); while (it.nextP()) { ...
4919eed2-803b-461e-87a8-e88bacce0712
3
private static String listAllPrimeNumbersForGivenRange(int range) { StringBuffer primeStr = new StringBuffer(); // set all values for the array to true boolean[] primes = new boolean[range]; Arrays.fill(primes, true); // prime number must be greater than 1, therefore int is as...
ed3bafbb-7ae1-4a18-8eaf-09edbd014690
0
@Basic @Column(name = "quantity") public int getQuantity() { return quantity; }
8b20919f-a458-4bfb-9000-82c5ce4e09f5
1
public void makeRightWin(boolean myWin) { Main.rightWins = myWin; if(myWin) { mySea.gameWon = true; theirSea.gameWon = true; mySea.winner = true; theirSea.winner = false; theirSea.destroyFleet(); } else { mySea.gameWon = true; theirSea.gameWon = true; theirSea.winner = t...
34de4e4a-90bf-4501-90d7-bb7c36308ef6
1
public String getColumnName(int col) { try { return people.getColumnName(col); } catch (Exception err) { return err.toString(); } }
74f09fe6-dba6-4637-88a9-026e3816e6b4
3
public void setIncomingBranch(BasicBlock b) { assert (currentBranch >= 1 && currentBranch <= 2); if(currentBranch == 1) { assert (incomingBranch1 == null); // only set once incomingBranch1 = b; } else if (currentBranch == 2) { assert (incomingBranch2 == null);...
d98a5133-2703-4de3-9866-2f71463aebfe
2
private void notifyListeners(String msg) { for (ChatListener l : listeners) { if (!l.equals(this)) { l.messageArrived(msg); } } }
0df8046a-3e40-48d1-a4da-f79ae83744ff
4
public void NESSIEfinalize(byte[] digest) { // append a '1'-bit: buffer[bufferPos] |= 0x80 >>> (bufferBits & 7); bufferPos++; // all remaining bits on the current byte are set to zero. // pad with zero bits to complete 512N + 256 bits: if (bufferPos > 32) { while (buf...
324b10ef-21b0-45bb-90d7-a9b059bd26fd
9
public Item onItemRightClick(Level level) { Random r = new Random(); int attackx = level.player.x; int attackz = level.player.z; int hitChance = level.player.getSkill(PlayerSkill.MELEE); boolean hit = r.nextInt(100) <= hitChance; if (level.player.rot == 0) attackz++; ...
9e2ec2e1-b130-4eab-a2f9-30ac816e90d5
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...
a1a7fe4f-25d2-4b0b-a8a1-d895d04bb4d5
0
public BasicHeadArmor(){ this.name = Constants.BASIC_SWORD; this.defenseScore = 4; this.money = 0; }
3748c815-8efc-40b8-8ad3-42fcd46440f0
8
private boolean templateContainsVar(Statement listS) { if(listS != null && listS.getObject().isResource()) { ExtendedIterator<RDFNode> nodes = (listS.getObject().as(RDFList.class)).iterator(); while(nodes.hasNext()) { Resource node = (Resource) nodes.next(); if(node.hasProperty(RDF.type, SP.NamedGraph))...
3500c2ef-38fa-4d14-9e55-3c9be95f5f46
7
public boolean autoDetect() { String OS = System.getProperty("os.name"); String fileName = "skzcmd.exe"; if ( !OS.startsWith("Windows") ) { fileName = "./s2zcmd"; } boolean result=false; String line; OutputStream skzIn = null; InputStream skzOut = null; ArrayList<String> responseA...
7938b862-0238-43bb-a476-d600a5efa859
2
public void tick() { /* Quadtree tree = new Quadtree(0, new Rectangle(sizeX,sizeY)); tree.addAll(entities); for(Entity e : entities) { if(e.color != Color.RED){ Vector2D gravVect = new Vector2D(0,0); for(Entity e2 : entities) { if(e2 != e) { Vector2D gComp = new Vector2D(e.posX, e.posY, e...
49e60da4-087c-43e5-8f46-2b92f803de45
3
private Entry lvalue_id(String id, int lno) { Entry e = symtab.search(id); if( e == null) { System.err.println("undeclared variable "+ id + " on line " + lno); System.exit(1); } if( !e.isVar()) { System.err.println("const...
57c05e2a-3eb3-4a19-baf4-283bcee6e7ad
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BinaryOperatorFormula other = (BinaryOperatorFormula) obj; if (leftArgument == null) { if (other.leftArgument != null) return false; } e...
713bd471-a969-4a7e-9650-e0e337ccdffe
1
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String rd = request.getParameter("r"); try (PrintWriter out = response.getWriter()) { ...
940430cb-0f92-498a-8fc9-59fa1513bfe9
4
protected String readAsKeyVal(BufferedReader reader, String expectedKey) throws IOException { String line = reader.readLine(); while (line.isEmpty() || line.indexOf("#") == 0) { line = reader.readLine(); } if (line.indexOf("#") > 0) { line = line.substring(0, line.indexOf("#")).trim(); } int split ...
53f62500-8ec1-4f54-aa65-6e2d7df12863
5
void remove(CtMember mem) { CtMember m = this; CtMember node; while ((node = m.next) != this) { if (node == mem) { m.next = node.next; if (node == methodTail) methodTail = m; if (node...
c2b49f52-6d1d-493a-b40e-0056343b4cdd
8
public static String convertDecimaltoFraction(double input) { //TODO Zero equals one when calculating...? /* boolean negative = false; if (input < 0) { negative = true; input = 0-input; } BigDecimal decimal = new BigDecimal(Double.toString(input)); decimal = decimal.setScale(18, BigDecimal.RO...
6a33f47d-7cb9-4a25-9ca8-f355f934a6f4
9
private void writeCell(Row row, int col, Object value, FormatType formatType, Short bgColor, Font boldFont) { Cell cell; if (value == null) { return; } if (boldFont != null) { // font later System.out.println("font given, but not yet implemented"); } switch (formatType) { case TEXT: cell = ...
ed4379c5-b49e-4ddd-9060-05bf3a6474dd
8
public void actionPerformed(ActionEvent e) { if (target != null) { animatorLSF anim = this.target.getCurrentAnimator(); if (anim != null) { if (e.getSource() == closer) anim.stronger(); if (e.getSource() == opener) a...
6720de87-0697-4cda-bf5e-527fa0920940
2
public boolean allUse() { for (int i = 0; i < rows.size() - 1; i++) if (!((Boolean) rows.get(i)[4]).booleanValue()) return false; return true; }
3164a5ec-34e0-4f29-9d20-3d152df256f9
0
public void keyReleased(KeyEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
241e6cc4-4976-41f0-8b14-cd8f72521a2e
8
@GrubsCommandHandler( command = "send", desc = "Teleport named player to another user or a saved preset. ", usage = "/<command> <player> <player>|<preset name>" ) public void onSendCommand(GrubsCommandInfo cmd) { CommandSender sender = cmd.sender; String[] args = cmd.args; if (args.length == 2) { List...
aa014cff-b2b2-4b50-aa01-6f6af71871f1
2
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (!localName.equals(BuilderProperties.getString("root_element"))) { //$NON-NLS-1$ if (currentParser == null) { findDeviceParser(localName); } else { lastFieldName = localNam...
0b722912-11f7-4524-b16f-a1825b3d8bc7
4
public static void main(String[] args) { spielfeld = new Spielfeld(feldBreite, feldHoehe); ausgabe = new Ausgabe(spielfeld); ausgabe.displayMap(); ausgabe.displayWelcome(); Integer anzahlGegner = ausgabe.askPlayer(); System.out.println("Anzahl Gegner: " + anzahlGegner); Richtungen richtung = ausgabe.as...
7155c94c-637e-411c-b8fa-7373bcafacb8
3
public static void deleteDir(File dir) { if (!dir.isDirectory()) return; for (File file : dir.listFiles()) { if (file.isDirectory()) deleteDir(file); else file.delete(); } dir.delete(); }
2afcb98e-28a2-4239-9054-7aa9a9e172e2
3
public boolean allowScreenRolloverMode() { if (!allowScreenOrPrintRenderingOrInteraction()) return false; if (getFlagNoView() && !getFlagToggleNoView()) return false; return !getFlagReadOnly(); }
1ae055a8-7ae3-427b-b252-d37df009d3ea
8
public int findWeakest(){ int index=-1; for(int q=0;q<objects.size();q++) { if (objects.get(q) == this||objects.get(q).kind==kind||objects.get(q).kind==0) continue; int searchRadius = 400; //radius of whether the object will be findable boolean search ...
8583e5be-b9c8-4b5a-907e-3c24c64de0d5
7
@Override public void addAllMap(Map<? extends K, ? extends Collection<? extends V>> map) { for (Map.Entry<? extends K, ? extends Collection<? extends V>> en : map.entrySet()) { addAll(en.getKey(), en.getValue()); } }
d16db138-49f3-4112-9c84-60507a608570
6
public PluginDescriptionFile build() throws Exception { PluginDescriptionFile pdf = new PluginDescriptionFile(name, version, plugin.getClass().getName()); Field depend = pdf.getClass().getDeclaredField("depend"); Field description = pdf.getClass().getDeclaredField("description"); ...
054b5d0f-ce2d-46fc-92e8-25defa4f72ea
6
public void render(int xScroll, int yScroll, Screen screen) { screen.setOffset(xScroll, yScroll); int x0 = xScroll >> 4; // >> 4 == / 16 int x1 = (xScroll + screen.width + 16) >> 4; int y0 = yScroll >> 4; int y1 = (yScroll + screen.height + 16) >> 4; for (int y = y0; y < y1; y++) { for (int x = x0; x < ...
dbefdad3-b53a-4816-9de3-c4a8de8ee6f9
5
public void select(CircuitSelection c) { CircuitSelection old = this.selected; this.selected = c; if (old != null) { old.deselect(); } if (c != null) { c.select(); if (c instanceof Board) { this.scrollRectToVisible(((Board) c).getBounds()); } BreadBoard oldbb = this.BBselect; if (c insta...
9ab818f9-4f5f-43b0-80f0-f20a3282b32d
7
private List<DailyReport> parseDailyReportResult(String text) throws Exception { List<DailyReport> result = new ArrayList<DailyReport>(); NodeList nodes = parse(text, "Table"); for (int i = 0; i < nodes.getLength(); i++) { DailyReport dailyReport = new DailyReport(); NodeList childNodes = ((Elem...
1e71dd9e-41df-42d5-a679-f1ee01a34bdc
1
private String getDescription() { String desc = "@MongoUpdate(query=[" + this.getParsedShell().getOriginalExpression() + "],modifier=[" + this.getParsedModifierShell().getOriginalExpression() + "],upsert=[" + this.isUpsert() + "],multi=[" + this.isMulti() + "])"; if (!StringUtils.isEmpty(globalCollectionNa...
b268460d-fa9a-403a-abdb-fe709efd4d44
2
public void setNumItineraries(Integer numItineraries) { if (numItineraries < 1 || numItineraries > 10) numItineraries = 3; paramPush(NUMBER_ITINERARIES, numItineraries); this.numItineraries = numItineraries; }
9d2b5a6b-3a59-4097-bc82-39c5de0e2451
0
public void seuraa(Pelaaja pelaaja) { // -75 koska näin sijoitamme pelaajan kultaiseen leikkaukseen ;-D int xKeski = 1024 / 2 + this.getX() - 75; int yKeski = 800 / 2 + this.getY() + 75; int xDelta = pelaaja.getX() + pelaaja.getxNopeus() - xKeski; int yDelta = pelaaja.getY() + p...
aaae79c6-e2bd-437d-bffd-064d9be76978
6
public void encryptFile(File read, File write) { { InputStream in = null; OutputStream out = null; OutputStream fileOut = null; try { cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec); in = new FileInputStream(read); ...
cd14fd46-597c-4cd9-9523-3c89dced00a8
9
void execute() { final String basePackageName = getClass().getPackage().getName(); final ExecutorService executor = Executors.newCachedThreadPool(); try { for (ProblemConfig problemConfig : problemConfigs) { System.out.println(problemConfig); for (Solv...
6c54da63-a53c-4275-ad43-64c97224739d
7
public void printInfo(StateBuffer in) { if(in.size() == 0) { System.out.println("StateBuffer EMPTY!"); return; } curGb.restore(in.getStates().iterator().next()); // restore some state Util.runToNextInputFrame(); // skip to menu, ensuring mons are loaded int enemyHP = Util.getMemoryWordBE(curGb.pokemon....
c712203a-5a4c-4ba1-896e-f980ffd1c3ca
7
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { SigninForm signinForm = (SigninForm) form;// TODO Auto-generated method stub String output ="wrong"; String login = signinForm.getLogin(); String password = signinForm.getPasswor...
c302c601-ef98-4eb5-a527-575e215f5254
7
private void checkMove5 () { if (row != 7 && col != 0 && Othello.board[row+1][col-1] == null) { for (int i=row, j=col; i>=0 && j<8; i--, j++) { if (Othello.board[i][j]==player) { list[5] = new Possible(row+1, col-1, i, j); break; } else if (Othello.board[i][j] == null) break; } } }
79d1532d-ed55-419f-bb12-5950402c9998
0
public GetAccountRequest getGetAccountRequest() { return getAccountRequest; }
c49ae9c1-5403-440f-8b79-7481af221210
4
public static boolean robotContainsBeacon(Robot paramRobot) { RobotPart[] arrayOfRobotPart = paramRobot.getRobotParts(); for (int i = 0; i < arrayOfRobotPart.length; i++) { if (!(arrayOfRobotPart[i] instanceof InventoryContainer)) continue; Enumeration localEnumeration = ((InventoryConta...
b78e207e-1d8b-4df1-af5e-d89c7b9e6124
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Telecommunications)) { return false; } Telecommunications other = (Telecommunications) object; if ((this.idTele...
cdd39221-8e60-4ddd-a485-8acccf472b85
3
@Override public int compareTo(Node uusi) { int paikka = 0; while (true) { if (lapset.get(paikka).name.compareTo(uusi.name) > 0) { break; } paikka++; // Jos ollaan listan päädyssä, niin paikka on listan lopussa. if (lapset.s...
96a022d8-8f77-4876-989a-cf914b28aab7
6
public static ArrayList<InetAddress> getBroadcastAddresses() throws SocketException { ArrayList<InetAddress> broadcastAddressList = new ArrayList<InetAddress>(); ArrayList<NetworkInterface> networkInterfaceList = new ArrayList<NetworkInterface>(); Enumeration<NetworkInterface> netInterfaceEnum = NetworkInte...
f8ac7c54-3e59-4312-86b3-12690e4fa2a7
4
public String putRequest(String path, String body) { URL url; StringBuilder content = new StringBuilder(); try { url = new URL(BaseURL + path); //url = new URL("https://localhost:10433/loopback?" + path); HttpsURLConnection con = (HttpsURLConnection)url.openConnection(); String OAuth = String.f...
1243d069-dbbb-473a-8794-7da983f6c962
7
public String getFullname () { StringBuilder sb = new StringBuilder((hasTitle()?getTitle():"") + " " + (hasFirstname()?getFirstname():"") + " " + (hasSurname()?getSurname():"") + " " + (hasMaidenname()?"nee "+getMaidenname():"")); if (hasOtherNames()) { sb.append(" ("); for (int i = 0; i < otherNames.size(); ...
0ebf3a26-37b2-4529-b15b-1a3e114e61b5
9
public static ArrayList<Prenotazione> caricaPrenotazioni(String nome) { try { ArrayList<Prenotazione> prenotazioni = new ArrayList<>(); Connection conn = DriverManager.getConnection(url, user, pwd); Statement st = conn.createStatement(); if (nome.equals("admin"))...
9426ca40-4312-4404-8a01-f329cd351d80
6
@Override public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) { Point where = event.getPoint(); mViewArea = checkAndConvertToArea(where); if (mViewArea != DirectScrollPanelArea.NONE) { int which = overColumnDivider(where.x); if (mAllowColumnResize && which != -1) { size...
11f71742-ad4c-415b-8381-3cf50e2bd266
7
private static boolean isValid(int m, int d, int y) { if (m < 1 || m > 12) return false; if (d < 1 || d > DAYS[m]) return false; if (m == 2 && d == 29 && !isLeapYear(y)) return false; return true; }
d6e65f5f-f18f-409e-a1de-ea516292c93b
8
private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { String eol = System.getProperty("line.separator", "\n"); StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expe...
8678e526-f729-4c7d-a337-68f37fadf104
2
private void makeClause(String s) { Clause c = new Clause(varCount); scanner = new Scanner(s); while(scanner.hasNextInt()) { int next = scanner.nextInt(); if(next!=0) //0 signifies the end of clause {c.addVariable(new Variable(next));} } ...
24e2e65b-a1ce-47c4-9897-11e75e41271c
6
private void updateDisplayList() { synchronized (lockA) { for (Displayable disp:displayablesAddition) { // Add event handlers for (KeyboardEventHandler handle:disp.getKeyboardHandlers()) { keyboardEventHandlers.add(0, handle); } ...
7009b24b-d304-4b1e-b8d2-6afd073d980c
2
public void visit_ldc(final Instruction inst) { final Object operand = inst.operand(); if ((operand instanceof Long) || (operand instanceof Double)) { stackHeight += 2; } else { stackHeight += 1; } }
c5bf6d0b-5f09-4b8e-a1f5-b935166649a7
3
public static <T> StringBuilder print( Trie<String, T> trie ) { final String LS = System.lineSeparator(); StringBuilder out = new StringBuilder(); for (TrieNode<String, T> node : trie.nodeSetAll()) { for (int i = 0; i < node.getStart(); i++) { out.a...
2828ae5b-4d0a-4981-92a1-eae61092ca19
2
public void modificarVideo(int id, ArrayList datos) { // Cambiamos todos los datos, que se puedan cambiar, a minúsculas for(int i = 0 ; i < datos.size() ; i++) { try{datos.set(i, datos.get(i).toString().toLowerCase());} catch(Exception e){} } bibliotec...
a84fc116-95bd-49f3-b17e-edad2dbe2a4a
4
@Override public void mouseReleased(MouseEvent e) { // Catch for Solaris/Mac if they did the popup trigger. if (e.isConsumed()) { return; } textArea = (OutlinerCellRendererImpl) e.getComponent(); // Shorthand Node currentNode = textArea.node; JoeTree tree = currentNode.getTree(); ...
87f4e1d6-5ee0-4b65-97ae-9140de0ec752
4
public static void main(String[] args) { //ApplicationContext appContext = ApplicationContextProvider.getInstance().getApplicationContext(); //OutletDaoInter outletDao = (OutletDaoInter) appContext.getBean("OutletDaoBean"); //CvOutletDaoInter cvOutletDao = (CvOutletDaoInter) appContext.getBean("...
da371d59-c807-44b1-9be4-883c7060c14e
4
public void run(){ Debug.debug("Starting to accept incoming connections"); while(clientsAccepted < backlog){ try { Socket clientSocket = acceptorSocket.accept(); Debug.debug("Connect from " + clientSocket); if(!isGraphicsManager){ spawnReadHandlerThread(clientSocket); } else { spawnGraphics...
029ded4f-6942-4581-ae24-a3a29a728478
7
private Mission getDefendSettlementMission(AIUnit aiUnit, boolean relaxed) { if (DefendSettlementMission.invalidReason(aiUnit) != null) return null; final Unit unit = aiUnit.getUnit(); final Location loc = unit.getLocation(); double worstValue = 1000000.0; Colony worstColony = nu...
33219019-5ab2-4f29-a051-55abc20992a3
6
public void PersonXmlWriter(ArrayList<Speaker> speakerList) { // String to hold date String tempDate = null; // Creates a folder in the documents folder to store xml file File dir1 = new File(database + "SpeakerFile_files"); dir1.mkdir(); try { // C...
f85d40e3-3f92-482c-b9e0-88c92c6f7356
6
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (hashCode() == o.hashCode()) return true; UninhabitedPlanet that = (UninhabitedPlanet) o; if (mineralResources != null ? !mineralResources.eq...
ce436051-6c25-4bdc-a895-a0c5d67367b7
3
private String relax(Vertex currVertex, Vertex neighbor) { StringBuilder returnValue = new StringBuilder(""); // Kantengewicht der Kante zwischen dem aktuellen Knoten und seinem Nachbarn Object o = graph.getEdgeMap().get(currVertex.getId(), neighbor.getId()); if (o == null) { o = graph.getEdgeMap...
e8f91de1-969a-4c78-a94f-6ff21ac8fe8f
7
private Dimension layoutSize(Container target, boolean preferred) { synchronized (target.getTreeLock()) { // Each row must fit with the width allocated to the containter. // When the container width = 0, the preferred width of the container // has not yet been calculated so lets ask for the maximum. int ...
56ead73a-b157-42f9-a341-064ec3e3bb03
3
public boolean moveToTop(int x, int y) { for (int i = 0; i < pieces.size(); i++) { if (pieces.get(i).getX() == x && pieces.get(i).getY() == y) { pieces.add(pieces.remove(i)); return true; } } return false; }
1539225e-22d8-4e2d-a721-5a260238e56a
4
public static String getHtml(String url,String charSet){ DefaultHttpClient httpClient = getHttpClientWithoutProxy(); // DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = setHttpGet(url); String back = ""; try { HttpResponse response = httpClient...
a7ca1794-609e-4b47-a453-6593a6cf4b30
3
public static boolean isAlpha(String str) { if (str == null) { return false; } int sz = str.length(); for (int i = 0; i < sz; i++) { if (Character.isLetter(str.charAt(i)) == false) { return false; } ...
23f9e995-0f5b-46c4-bb36-a84e65fd6fbb
2
public final int DecodeDirectBits(int numTotalBits) throws IOException { int result = 0; for (int i = numTotalBits; i != 0; i--) { Range >>>= 1; int t = Code - Range >>> 31; Code -= (Range & t - 1); result = result << 1 | 1 - t; if ((Range & 0xFF000000) != 0) continu...
3fa3e07e-09a2-4ed2-a27e-a2993191c71f
1
Controller(Object compound) { if (checkCircular) { validator = new Validator(); } ca = new ComponentAccess(compound, ens); }
9d210a35-09a0-4e60-9143-da0439055b01
3
void openServerSocket(int portNumber, Runnable process) { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(portNumber); socket = serverSocket.accept(); process.run(); } catch (IOException e) { println("ServerSocket could not be open"); } finally { if (serverSocket != null) ...
2a649c0b-e6bf-4fc6-b8f1-97c7d45769bb
8
private static void SwitchStatement() { char ch = 'a'; switch (ch) { case 'a': case 'A': System.out.print(ch); break; case 'b': case 'B': System.out.print(ch); break; case 'c': case 'C': System.out.print(ch); break; case 'd': case 'D': System.out.print(ch); } }
b1b65b6d-41ab-4612-8d0d-be4d2e595a82
8
@Override public boolean parseInput(String line, List<Object> result) throws IllegalArgumentException { if (result == null) { throw new IllegalArgumentException("param result must not be null."); } if (!result.isEmpty()) { throw new IllegalArgumentException("param result must be empty"); } if (line ...
e21540ff-c7e2-46f2-9ac1-d0a4d6370a93
7
public String identifyWinner(int quizId) { Iterator<Result> resultIterator= resultList.iterator(); String resultString ="the winner(s) "; List<Result> selectedQuizResult=null; int nextPlayerId=0; String playerName =""; int topScore=0; int score=0; int previousPlayerId =0; System.out.println("finali...
04d17b75-9797-4722-8c2f-f9488615e950
0
@Test public void testDirFromString() { System.out.println("dirFromString"); String name = "HERE"; Sense.senseDir expResult = Sense.senseDir.HERE; Sense.senseDir result = Sense.dirFromString(name); assertEquals(expResult, result); name = "AHEAD"; expR...