method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
90ea6568-af83-407c-8a1e-10eb6f2ab873
3
public V valAt(Class c) { V val = lookup.valAt(c); if (val == null) { val = checkBaseClasses(c); } if (val == null) { val = checkBaseInterfaces(c); } if (val == null) { val = lookup.valAt((Class) Object.class); } return...
c1695f7c-a074-471b-98f5-98d88a05a446
2
public FastqBuilder withQuality(final String quality) { if( quality == null ) { throw new IllegalArgumentException("quality must not be null"); } if( this.quality == null ) { this.quality = new StringBuilder(quality.length()); } this.quality.replace(0, this.quality.length(), quality); return this; }
b0eea7a8-1fa3-4063-9193-fbc78682523d
2
protected void die() { super.die(); int count = random.nextInt(2) + 1; for (int i = 0; i < count; i++) { level.add(new ItemEntity(new ResourceItem(Resource.slime), x + random.nextInt(11) - 5, y + random.nextInt(11) - 5)); } if (level.player != null) { level.player.score += 25*lvl; } }
2ff5fb18-0e82-4392-a80b-07e4738d3088
1
public final void initUI() { JMenuBar menubar = new JMenuBar(); JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); JMenu view = new JMenu("View"); view.setMnemonic(KeyEvent.VK_V); JCheckBoxMenuItem sbar = new JCheckBoxMenuItem("Show StatuBar"); sbar.setState(true); sbar.addActionListe...
fff14fc9-7f91-4ff4-863d-721c5718b7a3
5
public static void divideString(String str){ char[] carr = str.toCharArray(); int len = carr.length; for( int i=0; i< len-1; i++){ char chari = carr[i]; char nextc = carr[i+1]; if( isDigit( chari)){ stack.push( char2int(chari) ); }else if(isOp(chari)){ Op op = new Op(); op.left = stack.pee...
e1e45e20-3aaf-4c96-ab43-2e4858ea76a7
0
@Override public PermissionType getType() { return PermissionType.ENTITY; }
62715f6f-1f07-4c34-8f85-41cef92237fa
8
public static void main(String[] args) { try{ File directory = new File("/Users/bhaveshkumar/mygit/java-class-enumerator/folder"); System.out.println("Test class location: " ); List<Class<?>> classes = ClassEnumeratorFindAll.processDirectory(directory); System.out.println("Number of classes found in direct...
985ff321-6bf0-4245-8a17-c3b10157d2c4
6
private void attackPlaceAbove(int position, char[] boardElements, int dimension) { if (isPossibleToPlaceOnPreviousLine(positionAboveRight(position, dimension)) && isPositionInRangeOnTheRight(position, dimension) && isBoardElementEmpty(boardElements[positionAboveRight(position, di...
5e9962c0-d3a5-4cc2-9e1f-171f773579da
5
@Override public int loop() { if (stop) { shutdown(); } if (validate() && !wait) { final Node stateNode = scriptTree.state(); if (stateNode != null) { scriptTree.set(stateNode); final Node setNode = scriptTree.get(); if (setNode != null) { getContainer().submit(setNode); setNode.jo...
a8cab8f0-4561-4ed4-ba83-84346814d792
2
public void setKeyFrameTo(String name) { for (KeyFrame k : keys) { if (k.equalsIgnoreCase(name)) { currentKey = k; break; } } }
26703532-22fc-40e4-85f3-b318ceb2bcc7
2
private static void fourthStrategy() { Semaphore MReading = new Semaphore(1); Semaphore MWriting = new Semaphore(1); Semaphore MPrio = new Semaphore(1); Semaphore MPrioW = new Semaphore(1); Semaphore MPrioR = new Semaphore(1); int RCounter = 0; int WCounter = 0; Random r = new Random(); while(true...
6789d32f-2dea-4600-908c-e1e340f5a5d9
4
void select_imagesource_file_dialog() { String fname = null; JFileChooser chooser = new JFileChooser(image_dir); chooser.setDialogTitle("Open Image File"); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); if (f.exists()) { fname = f.toString(); ...
2104027f-d13b-4078-a5e0-92f28299ab3a
1
public void draw(Graphics g) { for (int i=0; i < edges.size(); i++) { edges.get(i).draw(g); } }
1a9d5d0a-c848-467e-b23c-e2d56adb370f
4
public static long getJailExpire(String playerName){ long expire = 0; if(isJailed(playerName)){ try { SQL_STATEMENT = SQL_CONNECTION.createStatement(); SQL_RESULTSET = SQL_STATEMENT.executeQuery("SELECT * FROM jails WHERE username='" + playerName + "'"); // This loop checks all bans ...
3fed0592-de53-4d72-8d1f-b06cc08c66bc
5
public void findScalarProduct() throws IOException { int totalInputs = Integer.parseInt(fileReader.nextLine()); int input=1; List<Integer> arrayOne; List<Integer> arrayTwo; while(fileReader.hasNext()){ int totalNumberOfElements = Integer.parseInt(fileReader.nextLine(...
09f9b38d-f19d-4d2f-8991-353ec8de344f
2
public byte[] Int32ToByte4(Integer value) { byte[] result = new byte[4]; /*** forward algorithm [123][0][0][0] ***/ byte i = 0, j = 0; while(true) { result[j] = (byte)((value >> (i*8)) & 0xff); if (j == 3) break; j++; i++; } return result; /*** inverse algorithm ...
3f419884-e991-4589-83d4-5f62c8977f41
6
private void subtraction(int countryCode, int numberToMinus){ if(IPCTrackerKeys.DEBUG_STATUS){ logger.log(CLASS_NAME, "DEBUG: Minus"); } switch(countryCode){ case IPCTrackerKeys.CountryCodes.SU: logger.log(CLASS_NAME, "Subtracting: \"" + numberToMinus + "\" from SU"); int currentTotalSU = Integer...
998887c2-c5ba-4496-b802-205139494298
3
public void deleteElement(String value) throws NotExist{ ListElement previous = head; ListElement current = head.next(); if (previous.getValue().equals(value)) { head = head.next(); count--; } else { while (current != tail.next()) { if ...
9a5f6995-24aa-4833-99a4-0c80ba69eab6
0
public String getRegip() { return this.regip; }
962240fa-b821-482b-9a7d-d643c2cdda17
9
public void setQueue1(FloatQueue t) throws MismatchException { if (t == null) throw new NullPointerException("the arg cannot be null"); if (q2 != null) { if (t.getLength() != q2.getLength()) throw new MismatchException("queue 1 and 2 have different lengths!"); if (t.getPointer() != q2.getPointer()) ...
918d3b20-3b50-483a-99ff-187ce6f5fa3d
5
public ArrayList<ArrayList<ArrayList<String>>> erstelleBlockelementListRegular( ArrayList<Umlaufplan> umlaufplanliste, Fahrplan fahrplan) { ArrayList<ArrayList<ArrayList<String>>> ListPlaeneGesamt = new ArrayList<ArrayList<ArrayList<String>>>(); int zaehler = 0; ArrayList<Blockelement> blockelementlist = new...
ece457ec-fff7-4688-94bd-fff8bbca79f7
8
public static void render(Graphics g){ Graphics2D g2d = (Graphics2D) g; if (screen == 0) { g2d.setColor(Color.WHITE); g2d.setFont(new Font("Serif", Font.BOLD, 96)); g.drawString("Jomapat", Jomapat.game.getWidth() / 2 - 170, 100); g2d.setFont(new Font("Serif", Font.BOLD, 36)); g2d.drawString(selecti...
49f99877-1989-4125-b7e2-98b7802ae82a
0
public void setBlogContent(String blogContent) { this.blogContent = blogContent; }
96d30735-589c-4094-8b5d-a2def7541f4b
2
private static Properties Configure() { Properties prop = new Properties(); InputStream in = null; try { in = new FileInputStream(getDefaultConfigPath() + "jmpd.properties"); prop.load(in); } catch (FileNotFoundException e) { System.out.println("[INFO...
55533bcf-30e8-408b-9136-6b93a61defa3
9
public void mate(Chromosome father, Chromosome offspring1, Chromosome offspring2) { int geneLength = getGenes().length; int cutpoint1 = (int) (Math.random() * (geneLength - getGeneticAlgorithm() .getCutLength())); int cutpoint2 = cutpoint1 + getGeneticAlgorithm().getCutLength(); Set<Double> taken1 = ne...
53f2789c-f370-4553-a332-4cabca51f750
0
public void setPersons(Set<Person> persons) { this.persons = persons; }
d6b72bae-08b0-4062-b199-b7dda4cf3048
1
public List<ArrayOfKeyValueOfstringanyType.KeyValueOfstringanyType> getKeyValueOfstringanyType() { if (keyValueOfstringanyType == null) { keyValueOfstringanyType = new ArrayList<ArrayOfKeyValueOfstringanyType.KeyValueOfstringanyType>(); } return this.keyValueOfstringanyType; }
ac32eb40-f10e-4b4d-b0cf-f4e7a3ecd454
4
public void generate(Land[][] world, int heightScale) { // seed for the world seed = (float) (System.nanoTime()/10000000); this.world = world; // grid of results for the noise algorithm functionResults = new float[(int) (world.length/xFreq)+4][(int) (world[0].length/zFreq)+4]; // adding 4 to create buffer ...
d1de4057-429f-436a-a55b-54b25e57b726
9
public Object[] getEdgesBetween(Object cell1, Object cell2, boolean directed) { if (graphLayoutCache != null && graphLayoutCache.isPartial() && edgePromotion) { Set cells1 = getHiddenChildren(cell1); Set cells2 = getHiddenChildren(cell2); // Optimise for the standard case of no child cells if (c...
278fc1f4-bfc7-45f9-850a-2afbcd21a14c
8
public Void visitExecutableStatements(ExecutableStatementsContext ctx) { if (ctx.children == null) return null; int loc = 1; for (ParseTree child : ctx.children) { if (child instanceof ExecutableStatementContext) { visitExecutableStatement((ExecutableStatementContext) child); if (ctx....
419bcade-c8a2-42b6-be10-20757cdc11db
3
@Override public LoggerPanel getLoggerPanel(int defaultID, String supplierName) { final Vector<ChoiceItem> data = new Vector<ChoiceItem>(items.size()); for (Entry<Integer, BarItem> item : items.entrySet()) { ChoiceItem toAdd = new ChoiceItem(); toAdd.id = item.getKey(); toAdd.item = item.getValue(); ...
537a3917-99c3-476f-9e5e-379f1696cfc3
0
public Teacher(DelayQueue<Student> students,ExecutorService exec) { super(); this.students = students; this.exec = exec; }
6b94d44a-a695-431f-a52a-bc5fec0f719b
1
@Override public void grabbed(EventMouse eventMouse) { texPos = sliderTexture.getBobGrabbed(); float posDifference = eventMouse.getPosition().getX() - getPosition().getX() - getScale().getX()/2; if (posDifference != 0) setPosition(getPosition().add(new Vector3f(posDifference,0,0...
83112210-22b1-48aa-b5de-3a4d61d17fcf
9
public static void main(final String[] args) throws Exception { int i = 0; int flags = ClassReader.SKIP_DEBUG; boolean ok = true; if (args.length < 1 || args.length > 2) { ok = false; } if (ok && "-debug".equals(args[0])) { i = 1; flag...
c076c6e4-c7b2-455c-8ab9-c139024aa516
0
public JPanel getjPanelTitre() { return jPanelTitre; }
b4c12325-49af-424a-84a6-66bba1e48aec
8
public void setValue(Object value) { // // Return an empty string if the value is null // if (value == null) { setText(new String()); return; } // // We must have a Number // if (!(value instanceof Number)) thr...
11c5f4d3-4280-4cfb-a0e0-a7a8bbd78c6d
4
private int getNum(String text) throws NumberFormatException { int res = 0; if(text.startsWith("+=")) res = Integer.parseInt(text.substring(2)); else if(text.startsWith("-=")) res = Integer.parseInt(text.substring(2)) * -1; else if(text.equals("++")) r...
c6ad0b5c-e3c4-4478-909d-d45fb144a66e
2
private int getTeleporterCoverage() { int nrSquaresTeleport = 0; for (Element e : grid.getElementsOnGrid()) if (e instanceof Teleporter) nrSquaresTeleport++; return (nrSquaresTeleport * 100 / grid.gridSize()); }
0b35aa03-3d4c-42d5-a048-b07699e98a2c
3
public static boolean hasHeadTag(String eadfile) throws FileNotFoundException, XMLStreamException, FactoryConfigurationError{ boolean result = false; FileInputStream fileInputStreamEAD = new FileInputStream(eadfile); XMLEventReader xmlEventReaderEAD = XMLInputFactory.newInstance() .createXMLEventReader(fi...
cf9cd2ab-ddfc-4379-b72a-877f4d46020a
3
@Override public void addProductToCart(UserModel user, int productId, int quantity) throws WebshopAppException { if (isValidUser(user, "ADD_PRODUCT_TO_SHOPPING_CART") && isPositiveQuantity(quantity, "ADD_PRODUCT_TO_SHOPPING_CART")) { try (Connection conn = getConnection()) { int db_quantity = getPro...
44613f58-71ce-4811-82f8-1a48585acb68
4
@Override public void run() { try { while (true){ if (!UserList.messages_list.isEmpty()){ System.out.println(UserList.messages_list.size()); String message = UserList.messages_list.get(0).replace("\n", ";;"); GUI.println("Sending message"); for(User value : UserList.user_list.values...
b30cca28-bbc4-46d6-a5af-1aa840778713
2
public static FloatBuffer createFilppedBuffer(Matrix4f value) { FloatBuffer buffer = createFloatBuffer(4 * 4); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j ++) { buffer.put(value.get(i, j)); } } buffer.flip(); ...
49dcfbe9-28f5-4c47-a2ad-aaa9bc0c5fea
1
public void add( V val,K key, W address){ if (root == null) { root = new BinaryNode<K,V,W>(val,key,address,null,null); } else{ root.insert(val,key,address); } }
cd475117-265b-4016-8e4f-eb495fe0d1c7
2
public void setHover (boolean visible) { if (champion != null) { if (visible) championIcon.setIcon (HOVER); else championIcon.setIcon (null); } }
4c7a395d-de6f-4497-83c6-f0db8b3f1c2b
5
public void setEndTime(int hr, int min) { if (hr < 24 && hr >= 0) { if (hr > this.tStart[0]) { this.tEnd[0] = hr; } else { this.tEnd[0] = tStart[0] + 1; } } if (min < 60 && min >= 0) { this.tEnd[1] = min; } ...
8bb1ab86-a464-48c3-86e1-826e4b622c8c
3
@Override public void caseASeExplogSenaoComando(ASeExplogSenaoComando node) { inASeExplogSenaoComando(node); { List<PComando> copy = new ArrayList<PComando>(node.getSenaoF()); Collections.reverse(copy); for(PComando e : copy) { e.ap...
23f53509-91f9-4606-bf70-711936306a3e
4
public Object getValueAt(int row, int col) { if(null == data) return null; if(col>=columnNames.length || col<0 || row<0) return null; return data[row][col]; }
e376d2b8-0a52-485f-9d20-3de8ed87b1f6
2
public boolean isValidType() { return ifaces.length == 0 || (clazz == null && ifaces.length == 1); }
380f24c9-1b0f-482c-ae71-8a590566425d
8
@Override public void init() { /* 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://download.o...
722305c9-07de-4b6f-b2cf-59b7cc49af60
2
@RequestMapping(value = "/saveEmployee", method = RequestMethod.POST) public String saveCustomer(@ModelAttribute("employee") Employee employee, BindingResult result) { if (employee.getEmployeeId() == null) { GenericDAO<Worktype> worktypesDAO = getWorktypesDAO(); ...
0b6d1bed-2e98-46c6-bc7c-35bd604dfd50
7
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final Physical target=getAnyTarget(mob,commands,givenTarget,Wearable.FILTER_ANY); if((target==null)||(target.fetchEffect(ID())!=null)) return false; if(!super.invoke(mob,commands,givenTarget,au...
a37eb364-9532-4328-9549-055027d9eb9a
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); Outliner.menuBar.helpMenu = this; }
06c5a841-ea51-40a5-bb9e-73663b8d5e13
8
protected String parseHeader(String input) { String[] lines = input.split("\r?\n", -1); StringBuilder result = new StringBuilder(); boolean readingHeader = true; boolean foundHeader = false; for (int i = 0; (i < lines.length) && (readingHeader); i++) { String line = ...
b4b5cbdf-dadf-4884-9acf-24d93153eb24
1
private void sendMessage(JButton confirmButton) { if (status.equals(GameStatus.NIGHT)) controller.sendMessage(new MafiaVotedOutVillagerMessage(votedOutPlayer)); else controller.sendMessage(new VillagerVotedOutMafiaMessage(votedOutPlayer)); disableVoteButtons(confirmButton); }
707235fe-20e6-4d94-bac4-b4c882e36038
5
@Override public void update(PositionChangedObservable observable) { if(observable != this) { if(observable.getPositions().contains(position)) { addHoveringElement(observable); if(getLifetime() > 0) observable.accept(new CollideWithPowerFailureVisitor()); } else if(hoveringElements.remove(observab...
d9af10a2-5a02-4d76-9f91-9584b6e6ee72
4
public void init(int mode, byte[] key, byte[] iv) throws Exception{ String pad="NoPadding"; // if(padding) pad="PKCS5Padding"; byte[] tmp; if(iv.length>ivsize){ tmp=new byte[ivsize]; System.arraycopy(iv, 0, tmp, 0, tmp.length); iv=tmp; } if(key.length>bsize){ tmp=new b...
5bc8d691-db34-4983-b8e3-4f70c8047704
1
public QueryUserByIdentityNumberResponse queryUserByIdentityNumber(QueryUserByIdentityNumberRequest request) throws GongmingConnectionException, GongmingApplicationException { URL path = _getPath(QUERY_USER_BY_IDENTITY_NUMBER); QueryUserByIdentityNumberResponse response = _GET(path, request, QueryUserByI...
9bbe469c-4d6c-4ddf-a31f-cbf475b39d94
1
public Class[] getParameterClasses() throws ClassNotFoundException { Class[] paramClasses = new Class[parameterTypes.length]; for (int i = paramClasses.length; --i >= 0;) paramClasses[i] = parameterTypes[i].getTypeClass(); return paramClasses; }
d49f4343-96ee-4cff-aced-5b659aa96cf1
2
public void mergeGenKill(Collection gen, SlotSet kill) { grow(gen.size()); big_loop: for (Iterator i = gen.iterator(); i.hasNext();) { LocalInfo li2 = (LocalInfo) i.next(); if (!kill.containsSlot(li2.getSlot())) add(li2.getLocalInfo()); } }
5699dc6c-5458-400c-b451-cc9538851242
0
@Override public void documentAdded(DocumentRepositoryEvent e) {}
788a67b6-591a-42e2-acdd-a4f6790bc482
2
public Map<Integer, CatalogItem> GrabItemsByPage(int ID) { Map<Integer, CatalogItem> Itemz = new HashMap<Integer, CatalogItem>(); for(CatalogItem Item : Items.values()) { if (Item.Page == ID) { Itemz.put(new Integer(Item.ID), Item); } } return Itemz; }
a92eb488-a57f-44fd-815b-fa21502fff4e
1
public PokeFont() { super(font); File f = new File("res/Font/PokemonFont.ttf"); FileInputStream in; try { in = new FileInputStream(f); dFont = Font.createFont(Font.TRUETYPE_FONT, in); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } font = setSize(20); }
10d0d7de-013e-4ff0-a5e8-b134b7f8ce17
3
public static void saveAllPlayers(boolean clearOfflinePlayers){ Iterator<Entry<String, PlayerData>> i = data.entrySet().iterator(); while(i.hasNext()){ Entry<String, PlayerData> e = i.next(); e.getValue().saveData(); if(clearOfflinePlayers){ Player p = Bukkit.getPlayerExact(e.getKey()); if(!p.isOnl...
eb2360c7-8e42-47fd-97f9-7ca52c3bd31b
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...
a9d3f6fe-8efd-4a14-a2c9-ef42d251ae24
4
public void addToPosition(int place, int value) { ListElement current = new ListElement(value); int nextCount = count + 1; if (place == first) { addToStart(value); } else if (place == nextCount) { addToEnd(value); } else if (place < nextCount) { ...
2936a21c-894d-4e53-8025-4ff73e57cfda
6
public static boolean isGreaterThan(Date inDate, Date dateToCompare){ if(inDate.getYear() > dateToCompare.getYear()){ return true; }else if(inDate.getYear() < dateToCompare.getYear()){ return false; }else{ if(inDate.getMonth() > dateToCompare.getMonth...
040fe654-0e31-4f6f-aa0e-0d543f2f57e1
6
public String toBizHawkString() { StringBuilder str = new StringBuilder(); // UDLRBAZSLRudlr xxx, yyy str.append("|.|...."); // UDRL str.append(b ? "B" : "."); // B str.append(a ? "A" : "."); // A str.append(z ? "Z" : "."); // Z str.append(".."); // Start , L str.append(r ? "R" : "."); // R str.append...
fa6ea2e9-d785-4a24-98fd-4c80bd6abf5f
7
@Override public List<Point> findWay(Node<Point> start, Node<Point> goal, ListGraph<Point> graph) { this.closedList = new LinkedList<Node<Point>>(); this.openList = new LinkedList<Node<Point>>(); Node<Point> current = start; // ADD IT TO OPEN LIST openList.add(current); ...
cd471594-cc08-409a-b50f-27d1abddc416
1
static void test(Fraction f1, Fraction f2, String msg){ if (! f1.equals(f2)) System.out.println(msg); }
90d0a578-a53e-4ce1-9ed2-709ae83398d0
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...
de138b45-cfdf-49c4-8200-88b07f564974
6
public static Properties load(String [] paths, String fileName) { Properties properties = null; File propertiesFile = null; try { String path = null; for(int i=0; i<paths.length; i++) { path = paths[i] + File.separator + fileName; propertiesFile = new File(path); if(prope...
6b93d070-3e39-4f0d-ba15-d1cc209c9bba
6
private static void browse(String url) throws ClassNotFoundException, IllegalAccessException, IllegalArgumentException, InterruptedException, InvocationTargetException, IOException, NoSuchMethodException { String osName = System.getProperty("os.name", ""); if (osName.startsWith("...
71b2f398-0395-4e15-8cd7-5be8cea1899f
4
public boolean addNoClaimChunk(String chunk) { if(this.noclaim.contains(chunk)) return false; if(this.chunkIsOwned(chunk)) { if(this.owners.containsKey(chunk)) { String owner = this.owners.remove(chunk); Player p = Bukkit.getPlayer(owne...
53e234f6-632f-41b3-b4fa-dc009b39a8b7
3
@Override public int compareTo( VoteItem o ) { if ( o instanceof VoteItem ) { VoteItem otherVoteItem = (VoteItem) o; if ( this.getScore() < otherVoteItem.getScore() ) { return 1; } else if ( this.getScore() > otherVoteItem.getScore() ) { return -1; } else { ...
a059d43a-2d50-4559-a3dc-e5cc3b04d61e
8
public static void finalizeObjectAxioms(Stella_Object self) { { Object old$Termsourcebeingparsed$000 = Logic.$TERMSOURCEBEINGPARSED$.get(); Object old$LogicDialect$000 = Logic.$LOGIC_DIALECT$.get(); try { Native.setSpecial(Logic.$TERMSOURCEBEINGPARSED$, null); Native.setSpecial(Logic.$L...
2dfb5210-7f9f-4512-8d72-373da4d2861c
7
public static void main(String[] args){ // abstractPathname = "MyTextFile.txt"; abstractPathname = "C:"; file = new File(abstractPathname); // file.createNewFile(); if(file.exists()){ System.out.println("File or Directory exists."); if(file.isFile()){ System.out.println("This is file."); if(file.c...
2d82d8e4-f227-424f-8753-c3ba78091a45
2
public static long toLong(byte ... b) { int mask = 0xff; int temp = 0; long res = 0; int byteslen = b.length; if (byteslen > 8) { return Long.valueOf(0L); } for (int i = 0; i < byteslen; i++) { res <<= 8; temp = b[i] & mask; res |= temp; } return res; }
fdbc7d0e-cdcc-410c-a6e6-780403fcdabe
4
public static void main (String[] args) throws IOException, ClassNotFoundException, IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException { String jarFilePath = "WordCount.jar"; JarFile jarFile = new JarFile(jarFilePath); Enumeration<JarEnt...
857e0c57-a3aa-49ec-a622-b696485f9f1d
7
public void compute3KindCategoryPoints(Dice[] roll) { if(this.ones >= 3 || this.twos >= 3 || this.threes >= 3 || this.fours >= 3 || this.fives >= 3 || this.sixes >= 3) { for(int i=0; i<5; i++) { scoreArray[THREEKIND_INDEX] += roll[i].face; } } else { scoreArray[THREEKIND_INDEX] = 0; } }
058c6d1d-822f-401b-9966-b79c690d02cb
3
public boolean isPoweredOn(String vmName) throws Exception { String vmSearch = doGet(apiLink + Utils.VMS_QUERY_SUFFIX); Document doc = RestClient.stringToXmlDocument(vmSearch); NodeList list = doc.getElementsByTagName(Constants.VM_RECORD); String vmRef = new String(); for(int i=0; i < list.getLength(); i++...
d2f1280d-f6af-4154-9f44-aed3ecdd35bb
9
public boolean step() { // get relevant rule int c = grid[pos_x][pos_y]; Rule r = rules.getRule(state, c); if (r == null) { System.out.println("No rule for state " + state + ", colour " + c + "!"); System.exit(-1); } //Change the colour and state...
6c30811f-753b-4654-b416-6ccac057367b
3
private static int getRepresentation(final String s) { if ("code".equals(s)) { return BYTECODE; } else if ("xml".equals(s)) { return MULTI_XML; } else if ("singlexml".equals(s)) { return SINGLE_XML; } return 0; }
2229feab-db37-4a32-9678-94ffc4f0882b
3
public void collideWithPlayer(final PlayerEntity player, final int delta) { boolean playerToLeft = player.pos.x - pos.x - SIZE / 2 < 0; Vector2d target = pos.copy(); if (playerToLeft) target.add(0.03 * delta, 0); else target.add(-0.03 * delta, 0); boolean isValide = World.getInstance().isValidPos(targ...
1a446b1e-5b93-4ee6-90e7-5eace7cc0265
7
public Strike(HtmlMidNode parent, HtmlAttributeToken[] attrs){ super(parent, attrs); for(HtmlAttributeToken attr:attrs){ String v = attr.getAttrValue(); switch(attr.getAttrName()){ case "class": clazz = Class.parse(this, v); break; case "dir": dir = Dir.parse(this, v); break; ...
14194efa-e6f3-49bb-af84-bf4f0c8e36bd
4
public boolean verifyConnection(){ try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); this.connect=DriverManager.getConnection("jdbc:mysql:"+this.link,this.username, this.passwd); this.statement=this.connect.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ...
7dbb3bd6-c45b-4b4b-879b-9aace93aeb0f
9
@Override public final int index() { final int key = this._key_; final BEXFileLoader owner = this._owner_; switch (BEXLoader._typeOf_(key)) { case BEX_VOID_TYPE: return -1; case BEX_ATTR_NODE: { final IAMArray array = owner._attrParentRef_; if (array.length() == 0) return -1; fina...
3601d4b2-8a46-4e84-a52c-ca819110bcab
2
private TowerView getTowerView(Tower t) { for (TowerView tv : towers) { if (tv.getTower().equals(t)) { return tv; } } //if it's not already in the list create a new and add it TowerView tv = new TowerView(t); towers.add(tv); return tv; }
982097bb-f41e-4f5b-b3e7-85ebf22cedf2
3
public void open() { if (this.state != CellState.CLOSED) return; if (hasMine()) { explodeMine(); } else { this.state = CellState.OPENED; notifyObservers("Opened"); if (countNeighborsWithMines() == 0) openNeighbors(); } }
403128d0-92dd-4850-a9e9-416c821ce2da
0
public int Decksize(){ return size; }
9b0fed89-302a-47eb-b4d5-727ad84138cb
0
public void setZipCode(String zipCode) { this.zipCode.set(zipCode); }
37ee726a-d261-467e-a637-0b30408178dc
9
private void handleMenuInput() { if (this.upHelper.state()) { this.activeMenu.up(); } else if (this.downHelper.state()) { this.activeMenu.down(); } else if (this.enterHelper.state()) { if (this.activeMenu instanceof BattleActionMenu) { BattleActionMenu.Action action = (BattleActionMenu.Action) this.a...
d1a9fe9c-8852-4552-83cd-fe2cc6a6963c
0
@Override public boolean pollControls() { Main.KEYBOARD_LISTENER.recordPollСontrols(KEYS, keyStates); return !Display.isCloseRequested(); }
228f9139-ceb8-46aa-92bc-0d35cf9b6a11
7
public int getMedianOfTwoArrays(int[] a1, int[] a2, int start1, int end1, int start2, int end2) { int length = end1 - start1 + 1; if (length == 0) return -1; if (length == 1) return (a1[0] + a2[0]) / 2; if (length == 2) return (Math.max(a1[start1 + 0], a2[start2 + 0]) + Math.min(a1[start1 + 1], a2[star...
395b057f-0a13-4255-a13f-f60d4011f2f9
9
private Method findStaticGetter(Class<?> theClass, String propertyName) { Method[] methods = theClass.getMethods(); for (Method method : methods) { int modifiers = method.getModifiers(); if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) { String m...
4259b8a4-abe1-4ba7-b97f-dff7ab0ffd7b
6
public boolean mousedown(Coord c, int button) { if (folded) { //recalcSize(this.sz); return super.mousedown(c, button); } parent.setfocus(this); raise(); Resource h = bhit(c); if (button == 1) { if (h != null) { pressed ...
ccf2ebc3-0856-40e6-a294-e7630b69f721
4
private void setUpWeapons() { for (int i = 0; i < 25; i++) { weapons.add("Weapons" + File.separator + "dagger.properties"); } for (int i = 0; i < 15; i++) { weapons.add("Weapons" + File.separator + "shortsword.properties"); } for (int i = 0; i < 10; i++) { weapons.add("Weapons" + F...
07911d57-f405-40b2-a9ee-68ef433c2dd4
6
public synchronized void jvnUnLock() throws JvnException { System.out.println("unlock STATE : "+STATE+" waitforread : "+wait_for_read+" waitforwrite : "+wait_for_write+" "+System.currentTimeMillis()); if(STATE == STATE_ENUM.R){ if(wait_for_write){ wait_for_write = false; STATE = STATE_ENUM.NL; th...
4c37cc88-bbf4-4115-9bc8-606523bd6070
4
private static void initKeywordMergeMap() { Iterator p = map.keySet().iterator(); while( p.hasNext() ) { final String key = ( String )p.next(); if( key.indexOf( ' ' ) > -1 ) { final String[] array = key.split( "\\s+" ); final String firstKeyword = array[ 0 ]; if( firstKeyword.length() > maxMergedKeywordLengt...
fa3d9d8d-8886-4a21-938c-f589848f3883
5
public void busquedaOrdenada(T dato){ if(dato instanceof Integer ){ Nodo<T> nodoQ = this.inicio; while(nodoQ != null && (Integer)nodoQ.getInfo() < (Integer) dato){ nodoQ = nodoQ.getLiga(); } if(nodoQ == null ||(Integer) nodoQ.getInfo() > (Integer)dato){ System.out.println("El elemento no se e...
8f57b9b6-1f29-4adb-b298-2e6d93f71bc5
0
@Override public void init(List<String> argumentList) { }