method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
46e25a93-fe27-4cc5-8b6e-889b4a8ff1cb
2
public void runEngineQueue() { Engine[] tempStorage = new Engine[engineQueue.size()]; engineQueue.toArray(tempStorage); for (Engine eng : tempStorage) { try { registerEngine(eng); } catch (EngineException ex) { System.out.println(ex.getMessage()); } } }
74c877bd-eb20-4d3f-b674-52d922cf2ead
8
private static int decode4to3( byte[] source, int srcOffset, byte[] destination, int destOffset, int options) { // Lots of error checking and exception throwing if (source == null) { throw new NullPointerException("Source array was null."); } // end if ...
6835b2d3-a944-4cf7-ac1f-d89dd939f35c
3
private boolean setFocusIfNeeded(Configuration current, boolean foundFocused) { Configuration parentConfig = current.getParent(); if (parentConfig == null) return foundFocused; if (parentConfig.getFocused()) { current.setFocused(true); if (!foundFocused) { configurations.setFocused(current); cur...
e63fb51d-7ab3-435e-9eed-1d2499e206fe
2
public void wheelUp() { if(Panel.contains(Main.mse)&&Page<Pages) { Page++; } }
52e41626-89af-44a2-b328-75a110dbef10
7
@Override public void run() { if (!automatedProcessesStop.get(metadataId)) try { logger.info("Sheduled automated thumb choice N°" + numberOfTries + " on " + maxNumberOfTries + " for metadata " + metadataId + " : try number " + numberOfTries); if (askForMetadataIcons) logge...
b238e3fc-923f-4fba-bb54-93bba9e08374
9
private static void runAnalysis(final BufferedReader gcLogReader, final PrintWriter pauseWriter, final PrintWriter percentWriter, final Date monitoringStartTimestamp) throws IOException, ParseException { Date currentDateTime = null; double totalTime = 0; d...
2e3f3727-4d3f-4751-a566-f8f7b674d88e
5
public List<StudentInfo> getStudent(ClassInfo cls) { List<CourseEnrollment> erlList = getCourseEnrollment(cls); StudentManager studentManager = StudentManager.getInstance(); List<StudentInfo> allStd = studentManager.getStudent(); List<StudentInfo> clsStd = new ArrayList<StudentInfo>(); if ((allStd != null) &&...
74f4eaad-b03c-4f54-9a92-f46063fd65b9
4
@Override public Map<String, Boolean> getPermissionsForPlayer(Player player) { // We try to do handle the maps by reference // as long as possible, to avoid creating // new maps over and over Map<String, Boolean> result = null; // If we had to make a copy of the result map ...
36ebc8b5-b0eb-4809-8b4d-17fbbd9741e8
7
public void run() { try { running = true; while (!stop) { Thread.sleep(60000); if (!stop) { try { env.checkpoint(null); } catch (DatabaseException ex) { throw new Error(ex); } } } } catch (InterruptedException ex) { if (stop) { ...
a12e54e9-2c0a-4525-a108-7330efae2d45
2
public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("Graph")){ //draw a graph// String name = nameField.getText(); NameSurferEntry entry = dataFile.findEntry(name); graph.addEntry(entry); graph.update(); }else if(e.getActionCommand().equals("Clear")){ //clear the canvas// ...
cee0cf7b-e18a-405f-8e61-1b2845e915a7
4
@Override public boolean execute(final String sender, final String message, final IRCChannel channel) { int size = 25; if (message.length() > 6) { if (this.validNumber(message.substring(6))) { size = Integer.parseInt(message.substring(6)); } ...
da73c478-d3bb-4414-90fd-8dac1ef84bbc
0
public void createNewProduct(Product newProduct) { this.em.persist(newProduct); }
945adec5-7011-4353-b769-511115c21860
2
public void addAttributeNotEmpty(String name, String value) throws XMLStreamException { if (value != null && value.length() > 0) { mWriter.writeAttribute(name, value); } }
735a6293-098c-4746-a7b2-546aca9e8049
1
@Override public void draw() { for(GraphicalElement poly : childPolygons) { poly.draw(); } CompositeClient.addOutput("element finished"); }
b3c82df0-7873-4336-9fdb-f99b8e5043e6
5
private boolean unregisterCommand(CommandSender sender, String[] args) { if (!xPermissions.has(sender, "xauth.admin.unregister")) { plugin.getMsgHndlr().sendMessage("admin.permission", sender); return true; } else if (args.length < 2) { plugin.getMsgHndlr().sendMessage("admin.unregister.usage", sender); ...
16d7f734-563b-4c26-9d7b-db7b5b682448
0
public void setjButtonClose(JButton jButtonClose) { this.jButtonClose = jButtonClose; }
ccca5416-0e80-4e9f-a7f0-9514e215ee60
0
public String getPrueba() { return prueba; }
8b7ed91f-1c62-41fd-a573-12860c01b092
8
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } Card card = (Card) obj; if (isBet() || card.isBet()) { return card.getColor() == this.getColor() && card.getType() == this...
8f090a00-a488-492f-bde0-34db88cd429e
2
public Object[] getArray(String key) { if (get(key) instanceof TypedObject && getTO(key).type.equals("flex.messaging.io.ArrayCollection")) return (Object[])getTO(key).get("array"); else return (Object[])get(key); }
8b56ad5e-5c7f-4747-8334-b3720177c821
8
public void set(String in, int index) { switch(index) { case 1: serviceCode = in; break; case 2: memberNum = in; break; case 3: providerNum = in; break; case 4: currentTime = in; break; case 5: dateOfService = in; break; case 6: comments = in; break; case 7: fee = ...
23513f26-05b6-4cde-86bd-fd5ba4dff2b7
6
private void massConversionsMenu() throws InterruptedException { System.out.println(); println("Choose a conversion or enter any integer to go back: "); println("0: Grams to milligrams"); println("1: Milligrams to grams"); println("2: Grams to kilograms"); println("3: Kilograms to grams"); ...
69087348-d9fe-4c1f-b3f6-df669ef7da17
6
public String next() { StringBuilder b = new StringBuilder(); while (true) { b.append(line.charAt(idx)); if (idx + 1 >= line.length() || Character.isWhitespace(line.charAt(idx+1))) { break; } idx++; } while (true) { if (idx + 1 >= line.length() || !Character.isWhitespace(line.charAt(idx+1)...
17d6fcbe-512c-4b42-9a15-007cae9e41e5
4
public SplitMatch(String pattern, String matchStr, char delimiter) { if (pattern == null || matchStr == null) { throw new IllegalArgumentException( "Pattern and String must not be null"); } this.pattern = pattern; this.matchStr = matchStr; ptnLen...
e3e471f8-fe98-496e-932f-b17304de01b0
8
public Direction clockwise(){ if (this.equals(NORTH)){ return NORTHEAST; } else if (this.equals(NORTHEAST)){ return EAST; } else if (this.equals(EAST)){ return SOUTHEAST; } else if (this.equals(SOUTHEAST)){ return SOUTH; } else if (this.equals(SOUTH)){ return SOUTHWEST;...
3d3e13d4-caec-45e7-8625-7ca8b9bc45e6
8
@SuppressWarnings("deprecation") public void processLoginRequest(OMMSolicitedItemEvent event) { OMMMsg msg = event.getMsg(); Token token = event.getRequestToken(); byte msgType = msg.getMsgType(); System.out.println(_instanceName + " Received Login " + OMMMsg.MsgType.toString(ms...
b137ea04-422c-466f-981d-40cfd88f3399
1
public int getRelativeWindDirection(){ int dir = this.absoluteWindDirection - this.heading; if(dir < 0) dir = 360 + dir; return dir; }
9df31f7a-ed17-4ffa-9796-b9b0451086c6
1
private static int fastfloor(double x) { int xi = (int) x; return x < xi ? xi - 1 : xi; }
af1e0537-2f33-4de8-b498-f821d5d74f84
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; AnagramWord other = (AnagramWord) obj; if (characterMap == null) { if (other.characterMap != null) return false; } else if (!characterMa...
9f6ff029-31ba-4e42-a517-1df7c3e95671
8
private SparseVectorN extractWordGrams(StringTokenizer tokenizer) { SparseVectorN x = new SparseVectorN(); assert (ngrams > 0); String t = null; String l = null; String ll = null; String lll; for (;tokenizer.hasMoreTokens();) { // Circu...
ac8c541c-a6fa-449e-8665-e2f96ea9ad6a
5
public void mouseDragged(MouseEvent e) { DonkeyGUI donkeyGui = DonkeyGUI.getInstance(guiBuilder); MaskPanel mask = guiBuilder.getMaskPanel(); ImageLabel source = (ImageLabel) e.getSource(); imageX = e.getX(); imageY = e.getY(); source.setLocation(imageX + source.getX() - source.getWidth() / 2, imageY + sour...
ae71573d-73e8-44e1-9787-eb36202dbca6
5
public static void main(String[] args) { Scanner s = new Scanner(System.in); int i; boolean isPrime = true; System.out.println("Please enter a number (integer)."); System.out.println("Enter '0' to exit the program."); String str = s.nextLine(); ...
820d5d38-abc6-4e1b-a8d9-28adb8c275b8
3
private synchronized void processEvent(Sim_event ev) { double now = GridSim.clock(); if(ev.get_src() == myId_) { // time to update the schedule, finish jobs // finish reservations, start jobs if (ev.get_tag() == UPT_SCHEDULE) { if(now > lastSchedUpt) { updateSchedule(); ...
6541f711-3ae7-40e4-9503-690e645b5dfe
7
private boolean checkImpactWall() { boolean hasBouncedOffWall = false; // If ball is touching the ground and // if energy is pointing down (It's positive) if((ballY >= (PHEIGHT-10)) && (yEnergy > 0)) { lives--; if(yEnergy >= minEnergyAtImpact) { yEnergy = ((yEnergy * 0.80f) - 80) * -1; hasBouncedO...
de0ec698-ecf8-4db6-89c1-bdc46bdb2ab2
2
public JSONObject append(String key, Object value) throws JSONException { testValidity(value); Object object = this.opt(key); if (object == null) { this.put(key, new JSONArray().put(value)); } else if (object instanceof JSONArray) { this.put(key, ((JSONArray)objec...
bdb6edc4-c772-4dff-b57c-891a62faf74c
9
private int jjMoveStringLiteralDfa7_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(5, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(6, active0); return 7; } switch(curChar) { case 110: ...
8445e8cc-3722-4eae-b6f3-ebe680613175
1
private boolean jj_2_36(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_36(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(35, xla); } }
2fdfa6b9-65e5-43d7-8556-625076a4487c
1
private void deleteFromPlaylist() { try { int songid; int id; showPlaylists(); System.out.println("Enter id of playlist to delete song from: "); id = Keyboard.readInt(); getAllByPlaylist(); System.out.println("Enter id of song...
ca9e91a7-8343-4889-81df-36d945f5f9bd
9
public Configuration addClass(Class<?> entityClass) throws Exception { int idCount = 0; Entity entity = entityClass.getAnnotation(Entity.class); if (entity == null) throw new Exception("A classe " + entityClass + " não é uma entidade válida, pois não possui a anotação @Entity"); Field[] fields = entit...
a9a5ca80-7b96-4b83-9612-2fc965cf9f61
9
public static void main(String[] args) { final Integer[] array = new Integer[2000000]; final Random random = new Random(); for (int i = 0; i < array.length; ++i) { array[i] = random.nextInt(100); } final Map<String, Sorter> sorters = new LinkedHashMap<String, Sorter>(); sorters.put("Array...
3db2c6a3-304c-412a-b83f-b53b54092e73
4
private void createFileMenu(Menu menuBar) { //File menu. MenuItem item = new MenuItem(menuBar, SWT.CASCADE); item.setText(resAddressBook.getString("File_menu_title")); Menu menu = new Menu(shell, SWT.DROP_DOWN); item.setMenu(menu); /** * Adds a listener to handle enabling and disabling * some items in the E...
80dad77d-1552-4dd2-bc8c-4553b567bf7e
7
@Override public int smarts(Algebra algebra) { Fraction frac = (Fraction) algebra; if(frac.isSimplified()) return 0; //if the bottom is 1 or -1 we can simplify for sure else if(frac.getBottom().equals(Number.ONE) || frac.getBottom().equals(Number.NEGATIVE_ONE)) return 7; else if(!frac.getTop().sign() || !fra...
4653e761-61ce-4fd0-ac9f-fa9d6d730a20
1
private void onPause() { if (!downloadsTable.getSelectionModel().isSelectionEmpty()) { int id = downloadsTable.convertRowIndexToModel(downloadsTable.getSelectedRow()); Integer gid = (Integer) downloadsTable.getModel().getValueAt(id, 0); downloadManager.pauseDownload(gid); ...
9de29e8a-3cf5-40a3-bbd6-fcc6f28bcf67
5
@Override public void keyPressed(KeyEvent arg0) { int keyCode = arg0.getKeyCode(); switch( keyCode ) { case KeyEvent.VK_ESCAPE: Fullscreen.this.dispose(); break; case KeyEvent.VK_UP: next(); break; case KeyEvent.VK_DOWN: back();...
bf76d8af-26bd-40c7-b5df-0c8defe43573
3
public LoggerStatus log(InputStream xliff, String filename,LoggerJena loggerJena) { LoggerStatus results = new LoggerStatus(); try { // Parse the xliff into an XML DOM DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(t...
6dc488a9-3cb2-4a88-b291-aa50aa611cb7
9
public void viewImage() { try { printCommandSeparator(); String infile = inputfiletxt.getText(); if (infile.toLowerCase().endsWith(".bmp")) { BmpImage img = new BmpImage(infile); bcifViewer.main(img, (new File(infile)).getName()); } else if (infile.toLowerCase().matches(".*\\.bcif[0-9]*")) { if (str...
7332ad13-baae-4ffb-b307-2528b6b0a6c5
2
public Date execute() throws IOException, ParseException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); boolean gotCorrect = false; while(!gotCorrect){ try{ System.out.println("Introduzca una fecha (dd-mm-yyyy)"); String...
5370eb1c-351b-476d-b724-0f2c584a159b
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 : ...
8a11006f-5b4e-4376-8f4e-954a0d2cba23
9
private boolean saveUser(ArrayList<Machine> machines) { String firstName = firstNameField.getText(); String lastName = lastNameField.getText(); String cwid = userIDField.getText(); String email = emailField.getText(); String department = departField.getText(); SystemAdministrator admin = ((SystemAdministra...
dfebf1a9-8d27-4556-ae2b-a9d4e54efd79
0
public void mouseClicked(MouseEvent e) { }
5cd65b30-59f8-4762-9be1-4e5a7a49d052
0
public static void main(String args[]){ Driver d=new Driver(true); d.htmlContent("prod"); }
9052e1dd-b69f-4872-b8b4-db716b9dd684
3
private int setStatus(){ if(status.equals("Offline")){ statusID = 0; return statusID; } if(status.equals("Available")){ statusID = 1; return statusID; } if(status.equals("Maintenance")){ statusID = 2; return statusID; } statusID = 3; return statusID; }
34449329-3037-401b-a95e-17ea20512d8e
1
public static boolean chequearActualizacion(String textoJSON) { boolean resultado = false; JSONParser parser = new JSONParser(); try { Object objeto = parser.parse(textoJSON); JSONObject objetoJSON = (JSONObject) objeto; resultado = objetoJSON.containsKey(CANTFILAS); } catch (ParseException e) { e.p...
3606e42c-7043-4fbd-b98b-c986214be9d1
5
private void init() { setFont(APP_FONT); addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if(SwingUtilities.isLeftMouseButton(evt) && evt.getClickCount() == 2 && mouseDoubleClick != null) { int index = locationToIndex(evt.getPoint()); if(index == -1) { ...
e554a6c7-86e5-4b62-b8cd-27453f07740e
7
@Override public int hashCode() { int hash = 5; hash = 97 * hash + ( ( this.id != null ) ? this.id.hashCode() : 0 ); hash = 97 * hash + ( ( this.title != null ) ? this.title.hashCode() : 0 ); hash = 97 * hash + ( ( this...
a87d4768-84bc-4c0e-8673-9f63eb1f178b
1
public String getDefaultName() { if (elementType instanceof ArrayType) return elementType.getDefaultName(); return pluralize(elementType.getDefaultName()); }
8c076ca0-a304-4aaf-8c04-e1d779916aff
6
public ArrayList<Ticket> createTicketArrayListByWorker(int workerId) { ArrayList<Ticket> result = new ArrayList<Ticket>(); ResultSet rs = null; PreparedStatement statement = null; try { statement = conn.prepareStatement("select * from Tickets where WorkerID_FK=?"); statement.setInt(1, workerId); ...
8dfc30a1-1c5f-4efb-aa9a-1095bad7afc6
8
public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] var1, int var2, int var3, int var4, int var5) { if(var1 == null || var1.length < var4 * var5) { var1 = new BiomeGenBase[var4 * var5]; } this.temperature = this.field_4194_e.func_4112_a(this.temperature, (double)var2, (double)var3, v...
c8149043-67c4-4571-a927-eb4c99912778
9
public static void main(String[] args) { Scanner input = new Scanner(System.in); int cpu_number; int your_number; String continuation = "Y"; int correct = 0; int gameplays = 1; int[] cpu_numbers = new int[100]; int[] your_numbers = new int[100]; System.out.println("Welcome to the Guess the Dice Ga...
85ed5609-0847-4dfb-aac5-0be561506db9
2
private void KDistanceFromRootRec(BTPosition<T> current, int k) { if (current == null) return; if (k == 0) { System.out.println("find one at " + current.element()); } else { KDistanceFromRootRec(current.getLeft(), k - 1);// note: can't use // --k here, it will // affect the...
450952c7-7fc6-4d10-b60b-b903b5227f2e
9
private void doOutputCommand(Command command, HackSimulator simulator) throws ControllerException, VariableException { if (output == null) throw new ControllerException("No output file specified"); StringBuffer line = new StringBuffer("|"); for (int i = 0; i < varList.length; i++) ...
0f100c17-2e8d-4ee2-ad14-789a6aaa304d
9
private Node parseFactor(final Node parent) throws SyntaxException, IOException { if (scanner.getCurrentToken().isType(TokenType.IDENTIFIER)) { return IdentifierNode.newInstance(parent, scanner.getCurrentToken().getValue()); } if (scanner.getCurrentToken().isType(TokenType.LITERAL))...
dbb34a59-5b86-41c3-b25e-8d5cf21aeb31
1
private double exptGreaterThan(double b) { double sum=0,interval=(bowSize*12-b)/1000,val=b; for (int i = 0; i <1000; i++) { sum+=phi(val, mu, sigma)*val*interval; val+=interval; } return sum/(1-probLessThan(b)); }
9ded3346-1825-44d1-a132-60a213089b56
1
public static void main(String[] args) throws NumberFormatException, IOException { InputStream inputStream = Googlers.class.getResourceAsStream("B-large-practice.in"); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader br = new BufferedReader(inputStreamReader); int numCase...
b0d719ac-0c3e-4f2f-a81f-07ae44c9353f
5
public ImageType classify() { List<String> frameAsJPEG = getImagesFromVideo(); Map<ImageType, Integer> maxImageTypeForFrames = new HashMap<ImageType, Integer>(); ImageClassification imageClassifier = ImageClassification.getInstance(); for(String filePath : frameAsJPEG) { Path jpegImagePath = Paths.get(filePa...
d702c14e-badd-47ad-bf63-9e7ab11fd5ec
8
private ArrayList<Word> getWords(Square square) { ArrayList<Word> words = new ArrayList<Word>(); Word word = new Word(); Word verticalWord; int x = square.getX(); while(x < Board.SIZE - 1 && this.board[x][square.getY()].getTile() != null) { if((verticalWord = getVeticalWord(this.board[x][square.ge...
10f0a0b0-97cb-41b5-ac69-8e94c1f805a8
6
@Override public void actionPerformed(ActionEvent e) { final String source = e.getActionCommand(); switch (source) { case "Easy": App.getField().setDifficulty(0); break; case "Medium": App.getField().setDifficulty(1); ...
99dbebe1-35f1-4915-b261-e695a943a3bd
0
public void setAddress(String address) { this.address = address; }
dd084c47-265b-4e57-add8-abc5e1e77793
4
@Override public VoiceStatus[] getVoiceStatus() { VoiceStatus[] all; if (theSynths.size() == 1) all = theSynths.get(0).getVoiceStatus(); else { all = new VoiceStatus[0]; for (Synthesizer s : theSynths) { VoiceStatus[] temp = s.getVoiceStatu...
649c871a-46e9-49bf-94e0-067f018a50f6
8
public void process(JCas arg0, ResultSpecification arg1) throws AnnotatorProcessException { System.out.println("Analysis engine 1"); String docText = arg0.getDocumentText(); String[] lines=docText.split("\n"); //Add LingPipe annotation //Line commented for release //File modelFile = new File("src/main/...
566e9e55-d5df-4211-9d74-32c953f3e98c
8
public void convert(CharChunk cc, ByteChunk bc) throws IOException { if ((bb == null) || (bb.array() != bc.getBuffer())) { // Create a new byte buffer if anything changed bb = ByteBuffer.wrap(bc.getBuffer(), bc.getEnd(), bc.getBuffer().length - bc.getEnd()); ...
fd42f621-c6de-4762-a7ea-f813fc884a6b
0
public void setVis_matricule(String vis_matricule) { this.vis_matricule = vis_matricule; }
c287f626-7b93-4fba-921a-ffc9326e73b2
4
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Alustetaan muuuttujat ja oliot sek� vastaan otetaan muuttujille arvot formilta String poistettavaID = request.getParameter("ID"); TuoteFormBean tuoteForm = null; try { tuoteFor...
fd35258c-9358-4cf4-8f01-a57e41a690a0
3
public static List<ColumnMetaData> getColumnMetaData(final String key, final MetaData columnMD) { if (key == null || key.equals(FPConstants.DETAIL_ID) || key.equals(FPConstants.COL_IDX)) { return columnMD.getColumnsNames(); } return columnMD.getListColumnsForRecord(key); }
8b707138-6ac7-49cb-9cbe-5650fac9231e
4
* @return Returns true if the label of the given cell is movable. */ public boolean isLabelMovable(Object cell) { return !isCellLocked(cell) && ((model.isEdge(cell) && isEdgeLabelsMovable()) || (model .isVertex(cell) && isVertexLabelsMovable())); }
51fac715-d5ac-4ae9-a924-6cd2a05048c8
6
public void loginUser(String user, String pass) { int cond=0; if (user.equals("") || pass.equals("")){ System.out.println("No Ha ingresado Usuario y/o contraseña..."); //cond=1; //return false; resultado = false; } else { ...
d0dd6bc7-8dd4-48b1-9814-f6b77230f03b
0
public static void main(String[] args) { MNA mna = new MNA(); MNA.A mnaa = mna.new A(); MNA.A.B mnaab = mnaa.new B(); mnaab.h(); }
0b2354ee-ceff-46d2-9816-37f97d53a694
6
public static int downloadInstalledLibraries(String jsonMarker, File librariesDir, IMonitor monitor, List<JsonNode> libraries, int progress, List<String> grabbed, List<String> bad) { for (JsonNode library : libraries) { String libName = library.getStringValue("name"); monitor.setNote(Str...
db31571b-e48a-45b7-aca9-9a1c926da27e
5
@Override public String findById(int id) { String type = null; try { connection = getConnection(); ptmt = connection.prepareStatement("SELECT id FROM Task WHERE type=?;"); ptmt.setInt(1, id); resultSet = ptmt.executeQuery(); resultSet.next(...
789de01a-c851-41cf-9a05-e8e8acce800e
3
private void clearResource(Hashtable resource){ if (resource != null){ Set keys = resource.keySet(); Object value; for (Object key : keys){ value = resource.get(key); if (value instanceof Reference){ library.removeObject((Re...
a7887028-605c-4e4c-a7e5-039c07339176
6
public void addResource(int amount, Resource res) { String r = res.toString(); if (amount <= 0) { System.out.println("Cannot add negative resources"); return; } if (r.equals("Metal")) { Metal += amount; return; }if (r.equals("Wood")) { Wood += amount; return; }if (r.equals("Food")) { Fo...
3ddae8b8-e74b-4cea-9659-125d4d0cfea1
4
@Override public void render (float delta) { badguy.setGoal(missile.getBody().getPosition()); badguy.update(delta); missile.update(delta); String newLine = System.lineSeparator(); if(countdown.isDone()){ System.out.println("You didn't manage to destroy the enemy ship, " + newLine + " they fled and de...
2c982d02-27b1-4a95-be49-a974471a7a85
2
public void grow(double dw, double dh) { if (x1 <= x2) { x1 -= dw; x2 += dw; } else { x1 += dw; x2 -= dw; } if (y1 <= y2) { y1 -= dh; y2 += dh; } else { ...
bbbdaa43-8110-479d-a5ae-d4412aefef6e
5
public void render(Entity parent, Graphics g, int delta) { if (this.shown) { // if the text is dynamic, move the text at its y location (decrement by speed) if (this.dynamic) { this.speed -= 0.05f; this.y -= this.speed; if (this.speed <= 0) this.shown = false; // if the speed equals to ...
0c5b01c7-9b59-4bf8-b018-99e73ec96ad5
5
public static boolean shouldBuild() { // ========================================================= // Begin EASY-WAY int factories = TerranFactory.getNumberOfUnitsCompleted(); int vultures = TerranVulture.getNumberOfUnits(); if (vultures < TerranVulture.CRITICALLY_FEW_VULTURES && !TerranVulture.DISABLE_VULT...
4469b5c0-ffdc-457e-b46c-64f4449b1082
2
public Item getItem(int itemSlot) { if(itemSlot > 5 || itemSlot < 0) return null; Item item = inv[itemSlot]; return item; }
530d2d25-188c-4883-b375-f3b557e5945d
2
public void setAutopaint(boolean autopaint) { if (this.autopaint == autopaint) return; this.autopaint = autopaint; if (autopaint) forceRedraw(); }
0e388535-00e7-4977-87fd-657439a00c06
4
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException { try { resp.setContentType("text/plain"); PrintWriter out = resp.getWriter(); out.println("*** ApacheDS RootDSE ***\n"); DirContext ctx = new InitialDirContext(this.createEnv()); SearchControls ctls =...
5f5a5681-db63-4e27-9668-029eb7f52ecc
2
public Collection implementors(final Type type) { final TypeNode node = getImplementsNode(type); if (node != null) { final List list = new ArrayList(implementsGraph.preds(node)); final ListIterator iter = list.listIterator(); while (iter.hasNext()) { final TypeNode v = (TypeNode) iter.next(); it...
6ef3cdec-4f31-45f3-8601-400b2ea982bc
9
private int updateCellCount(int current, int count) { if(count == 0) { if(current == 1) { return -1; } if(current == 2) { return 1; } } else { if(count < 0) { if(current == 1) { return count-1; } if(current == 2) { ...
815411a8-de46-4050-9947-b5ace5e2681f
3
public OrderSet<? super PROJECTION> removeLast() { if(orders.size() > 1) { return new OrderSet<PROJECTION>(orders.subList(0, orders.size()-1)); } else { return new OrderSet<PROJECTION>(new ArrayList<Order<? super PROJECTION>>()); } }
63f5fb38-99d0-402a-9138-b63a0b587f49
7
private static boolean isValidScheme(final String scheme) { final int length = scheme.length(); if (length < 1) { return false; } char c = scheme.charAt(0); if (!Character.isLetter(c)) { return false; } for (int i = 1; i < length; i++) { ...
efe3d976-6004-41f0-92b2-8cd4171968e0
0
public void setFossil(String value) { this.fossil = value; }
227d49d4-47bb-4e8c-a7bf-c8633405f9e5
1
@Override public boolean equals(Object obj) { if (obj instanceof Link) { return this.getLinkID() == ((Link) obj).getLinkID(); } return false; }
e79dbd4f-c53a-44f9-86fe-b5dedb2d3877
9
private int countNeighbours(int line, int row) { int count = 0; for(int lineOffset=-1; lineOffset <=1; lineOffset++) { int lineIndex = line+lineOffset; if(lineIndex <0 || lineIndex >= states.length) continue; for(int rowOffset=-1; rowOffset <=1; rowOffset++) { if(lineOffset==0 && rowOffset==0) ...
3449f9a4-d6bb-456c-a927-e4701bd261ca
6
private void computeWeightedShortestPath(Vertex origin) { // priority queue to store paths that need to be visited PriorityQueue pq = new PriorityQueue(PriorityQueue.PRIORITY_ASCENDING); // number of vertices visited int visited; // current shortest path Path shortestPath; // Vertex in current s...
1590f124-5ca8-4e82-b85d-c15104817cfe
9
public static void server(int port) throws IOException, InterruptedException{ ServerSocket server = new ServerSocket(port); Socket socket; while (true){ socket = server.accept(); System.out.println(socket.getRemoteSocketAddress().toString() + " connected...
7c2724a2-7189-4cc7-aeb4-ad90f17fee3a
3
@Override public boolean isDuplicate(Question obj) { for (Question q : questions) { if (q.equals(obj)) { return true; } } if (questions.size() >= limit) { questions.remove(0); } questions.add(obj); return false; ...
5cf8ce43-9ebe-48c7-9b48-1e882ca915fd
8
public void computeChoice (int ART_MODE) { double top, bottom; if (ART_MODE == FUZZYART) { // System.out.println("Phase code T computationation FUZZYART"); for (int j=0; j<numCode; j++) { activityF2[j] = 0; top = 0; bottom = alpha; for (int k...
0577a637-8b03-4876-8193-c683208fc342
0
public void drawVillage(Graphics2D gI) { gI.drawImage(village.draw((int)(getX()-village.getX()+village.getRelativeChunkCenter().getX()), (int)(getY()-village.getY()+village.getRelativeChunkCenter().getY())), 0, 0, Chunk.getPixelLength(), Chunk.getPixelLength(), null); }
7449541a-875e-4f33-bcbf-448ab54b2edb
7
public void setSpecificTrainerImages() { if(name.equals("James")) { for(int i=0; i<4; i++) { URL url=Trainer.class.getResource("Sprites/OverworldNPCs/prof"+i+".png"); trainerStand[i]=Toolkit.getDefaultToolkit().getImage(url); } } else if(name.equals("Jimmy")||name.equals("Jac...