method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
254a9aef-4cb9-4221-9b29-befc5cd9e2b6
8
public int compare(Static o1, Static o2) { if(tiledata != null && o1.getX() == o2.getX() && o1.getY() == o2.getY() && o1.getZ() == o2.getZ()){ ItemData t1 = tiledata.getItem(o1.getId()); ItemData t2 = tiledata.getItem(o2.getId()); if(t1 == null && t2 == null) return 0; int t1b = (t1.getFlags().conta...
bead55a1-e4bb-411b-8e26-3b8d03b03b9c
8
public void loadElementTable(String filename) { Workbook elementBook = null; try { elementBook = Workbook.getWorkbook(new File(filename)); } catch (Exception e) { System.err.println(e); } if(elementBook == null) { System.err.println("load element table file failed!"); System.e...
389738b5-c635-4b5a-887b-38d48881ce2b
5
public boolean editFileContent(String filePath, String fileName, String content) { filePath = realPath + "\\" + filePath; BufferedReader reader = null; BufferedWriter writer = null; File file = new File(filePath, fileName); // if no exited, then create one if (!file.exists()) { try { // getParentFile...
218cbae3-3c10-4e7f-8df5-ed324e7c2d14
8
public void deplacer(String direction, int nombreDeDeplacement) { // Contrôle si le véhicule va bien dans le bon sens, puis le déplace dans la bonne direction, et du nombre de cases indiqué en paramètre if(direction.charAt(0) == 'U' && this.direction == "verticale"){ imageVehicule.slowMoveVertical (nombreDeD...
de255741-2c43-4c3b-8942-d17a6e344031
8
void generateRandomNet(BayesNet bayesNet, Instances instances) { int nNodes = instances.numAttributes(); // clear network for (int iNode = 0; iNode < nNodes; iNode++) { ParentSet parentSet = bayesNet.getParentSet(iNode); while (parentSet.getNrOfParents() > 0) { parentSet.deleteLastParent(instances); ...
c71dc7bc-9880-4319-8971-fbb5ba56c6b7
1
@Override public void startUp(GameTime gameTime) { for (IHudItem hudItem : hudItemQueue) { hudItem.startUp(gameTime); } }
3c5f0698-dafb-4bc2-9180-2a1ce9e47c1a
5
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (qName.equals("usageFlags")) { response.setUsageFlags(getInt()); } else if (qName.equals("deployFlags")) { response.setDeployFlags(getInt()); } else if (qName.equals("allowCorporationMembers")) { respon...
2cd77743-3a5d-4f81-bce7-211b4ad2f279
1
@Override public Class<?> getColumnClass(int columnIndex) { return data[0][columnIndex].getClass(); }
575a3265-904b-4834-946e-4c9ae5be9eb9
9
public int getSampleRate () { switch (h_sample_frequency) { case THIRTYTWO: if (h_version == MPEG1) return 32000; else if (h_version == MPEG2_LSF) return 16000; else // SZD return 8000; case FOURTYFOUR_POINT_ONE: if (h_version == MPEG1) return 44100; else if (h_version == MPEG2_...
4190ab84-4f58-4333-8a1b-96663b8dd034
6
public boolean remove(E x) { if (super.isEmpty()) { return false; } else if (super.contains(x)) { if (maxElement.compareTo(x) == 0) { super.remove(x); if (super.isEmpty()) { maxElement = null; } else { Iterator<E> itr = super.iterator(); maxElement = itr.next(); while (itr...
491888d0-1526-41ae-833e-65fc6c2dc010
3
public void mergeSort() { // check if there is only 1 element return if (a.length == 1) return; // otherwise create two new arrays int[] left = new int[a.length / 2]; for (int i = 0; i < left.length; i++) left[i] = a[i]; int[] right = new int[a.length - left.length]; for (int i ...
cb211a31-afd2-431d-88aa-e811ff84bd16
6
protected void createSubbands() { int i; if (mode == Header.SINGLE_CHANNEL) for (i = 0; i < num_subbands; ++i) subbands[i] = new SubbandLayer2(i); else if (mode == Header.JOINT_STEREO) { for (i = 0; i < header.intensity_stereo_bound(); ++i) subbands[i] = new SubbandLayer2S...
2afd1550-1a35-4371-88d9-674a9b70e8a8
2
@Override public void close() { try { if (this.connection != null) this.connection.close(); } catch (Exception e) { this.writeError("Failed to close database connection: " + e.getMessage(), true); } }
fc7d423d-9632-4e93-8023-8434ca9a574a
9
public static void checkVote(final Player player, final String auth) { if (player.getTemporaryAttributtes().get("CheckingVote") != null) return; if(Utils.invalidAuthId(auth)) { player.getDialogueManager().startDialogue("SimpleMessage", "The authentication id you specified couldn't be found in our database,",...
8101c1a2-8f9d-4ed1-a018-bc499add2805
5
private void startMenu() { while (menuRunning) { Graphics2D g = (Graphics2D) strategy.getDrawGraphics(); g.setColor(Color.black); g.fillRect(0, 0, Global.xRes, Global.yRes); button = new ButtonEntity(this, "sprites/hud/newbutton.jpg", new Coords(Global.xRes / 2 - 50, G...
8be4234b-affe-4eb4-abfa-f74c9a289cf0
2
public void makeConnection() { try { if ( weh != null ) weh.close(); weh = new WebsocketExtended(); weh.connect(); } catch ( Throwable e ) { e.printStackTrace(); } }
1aa2bb3b-8b6c-4297-8add-bc38bb31d439
7
public void update(Input input, int delta) { // Move down if(input.isKeyPressed(Settings.menu_down)) { this.selected += 1; if(this.selected >= this.items.size()) { this.selected = 0; } } // Move up if(input.isKeyPressed(Settings.menu_up)) { this.selected -= 1; if(this.selected < ...
3de6835d-266f-48d2-b4bd-1c4e74d58d92
1
public void tick() { die(); if (live <= 0) { snake.removeEntity(this); } }
5b0aab42-5b00-4714-9a2f-477095e5b0a5
1
public void printCells(){ for(ProcessedCell cell : cells){ System.out.println(cell); } }
0704aa80-3877-4534-81ac-4d983442b012
3
@Override public void ParseIn(Connection Main, Server Environment) { Room Room = Environment.RoomManager.GetRoom(Main.Data.CurrentRoom); if(Room == null) { return; } int itemid = Main.DecodeInt(); if(!Main.Data.SongInInventory.containsKey(itemid)) ...
7c266db7-f580-4243-aeaa-d8c65474490b
6
public EcTextField(String text,int x, int y,int width,int height){ //super(text); this.setText(text); setBounds(x,y,width,height); try { font = Font.createFont(Font.TRUETYPE_FONT, this.getClass().getResourceAsStream("/font/LucidaSansRegular.ttf")); } catch (FontFormat...
ee84dd2b-4718-4db4-a0c4-ad7a4ad7a771
0
public String getUsername() { return username; }
48ca16f2-cb2c-4797-9b82-364eb8ec3e9a
9
public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); Aplicacao aplicacao; try { aplicacao = em.getReference(Aplicaca...
ed67066d-e1b8-4926-9bd8-692be6b75250
2
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/usuario/list.jsp"); try { UsuarioDao oUsuarioDao = new UsuarioDao(oContexto.getEn...
70a4145b-3922-4de3-a311-e762fd272523
7
public static int damerauDist(int color1, int color2) { String compOne = color1+""; String compTwo = color2+""; int res = -1; int INF = compOne.length() + compTwo.length(); int[][] matrix = new int[compOne.length()+1][compTwo.length()+1]; for (int i = 0; i < compOne...
00998c40-6505-4621-aa93-6d04861c7ef3
3
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((kineticLaw == null) ? 0 : kineticLaw.hashCode()); result = prime * result + Arrays.hashCode(listOfProducts); result = prime * result + Arrays...
f443a7d6-3f47-4bce-9645-aac7d0aa9285
8
public void setSize(int width, int height) { if (width < 0 || height < 0 || width > RASTER_MAX_WIDTH || height > RASTER_MAX_HEIGHT) { // Invalid width or height. throw new ExceptionInvalidParam(); } else if (width == 0 || height == 0) { // An empty image was specified...
e3cafa85-70d9-4dde-9433-8671be949c94
6
public int solution(int[] elements) { int length = elements.length; //check if array contains only one elements if (length == 1) { return length; } //check if array contains no elements if (elements == null || length == 0) { return length; } int localSum = 0; int globalN = 0; int localN ...
4667feb6-b301-46d4-a2cc-136991818770
1
@Override public boolean pass() { if (numPassages > 0) { --numPassages; return true; } else { return false; } }
603f1511-2e4b-4aea-b6d0-177e98c324ed
5
private Object[][] createRowData(Integer nbrVars) { int lines = (int) Math.pow(2, nbrVars.intValue()); Object[][] data = new Object[lines][nbrVars.intValue() + 2]; for (int i = 0; i < lines; i++) { for (int j = 0; j < nbrVars.intValue() + 2; j++) { if (j == 0) data[i][j] = i; else { if (j == ...
f4b2ab21-f112-47ba-9eec-026cd26e40b4
5
public static void calculateErrorArrays(){ //output error for(int outNode = 0; outNode < numOutputs; outNode++){ double sum = 0; for(int node = 0; node < hidOut.length; node++){ sum += (hiddenOutput[node] * hidOut[node][outNode]); } outputError[outNode] = derivitiveActivationFunction(sum) * (lastOut...
77a40d6c-2d27-4c08-a0ab-23e83d4ab41b
9
private void HandleCommand(String line, BufferedImage image) { try { StringTokenizer commands = new StringTokenizer(line); String command = commands.nextToken(); if (command.equals("common")) { mLineHeight = Integer.parseInt(commands.nextToken().substring(11)); } else if (command.equa...
3e6b59ee-dd16-403c-9609-f015db0df94c
1
public void assignFarmToBatiment(List<Batiment> batiments){ /* this.setBatiments(batiments); for (Batiment b : batiments){ b.setFarm(this); */ for(Batiment batiment:batiments){ batiment.setFarm(this); this.setBatiments(batiments); } }
243aa3a5-0333-422c-8453-a00255380af7
6
public int calcFreeSeats(HashMap<Integer, Integer[]> passengerByStation, List<Object[]> allStationsByTrain, Station stationFrom, Station stationTo, Train train) { log.debug("Start method \"calcFreeSeats\""); int occupiedSeats = 0; int maxOccupied = -1; boolean calcMax = false; fo...
93c869e6-fa39-4c90-bbc6-c24eaba7c294
7
public List findRecords(String sqlString, boolean closeConnection) throws SQLException, Exception { Statement stmt = null; ResultSet rs = null; ResultSetMetaData metaData = null; final List list = new ArrayList(); Map record = null; // do this in an excpetion...
9c5bc6e2-2117-4768-92b7-19b3360fe28f
2
public void test_18_DnaCoder_score_rand() { int numTests = 10; int minLen = 10; System.err.println("DnaCoder.score test:"); DnaCoder dnaCoder = DnaCoder.get(); DnaSubsequenceComparator<DnaSequence> comparator = new DnaSubsequenceComparator<DnaSequence>(true); Random rand = new Random(20100812); for( int...
1733379a-9ad4-4aab-a363-b744b9df4469
4
private static boolean deleteDir(File dir) { try { logger.info("IN DELETEDIR"); if (dir.isDirectory()) { String[] children = dir.list(); for (int i=0; i<children.length; i++) { boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; } } } } ...
e26566ee-8f45-414d-8a21-0c0bf00cc414
5
static void fetch (int pc) { if(pc<2000){ String corrector = ""; String instruction1 = Integer.toBinaryString(mem[pc]); String instruction2 = Integer.toBinaryString(mem[pc+1]); if(instruction1.length() < 8) { for(int i=0; i<8-instruction1.length(); i++) { corrector= corrector+0; } } ...
d77e6848-6cec-4f6e-94c2-efccd379847c
8
public void insertNode(int index, DoublyLinkedListNode<T> newNode) { //Check for out of bounds insertion. if (index > size) { return; } if (size == 0) { // Deal with special case of the first node. startNode = newNode; } else if (index == 0) { // Deal with special case of in...
3b4818e6-8ac7-42a4-ac30-cdcd36dbad2a
6
public void loadAdmin(Node node) { Administrator ad = new Administrator(); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node cNode = childNodes.item(i); if (cNode instanceof Element) { String content = cNode.getLastChild().getTextContent().trim(); sw...
3eb5b002-f2db-4652-88cb-1a3e086f6d1b
8
private List<Node> findChildren(Node node, int depth) { List<Node> result = null; List<Node> traversed = new LinkedList<Node>(); traversed.add(node); int count = 0; while (!traversed.isEmpty() && (count < depth)) { Node tmp = traversed.remove(0); coun...
b5aa1968-34a0-461b-9e93-5079e9b5dfb0
5
public int findConversation (ArrayList<String> contacts) { // index que l'on retourne int index = -1; // variable qui sert d'index pendant qu'on parcourt le tableau int i = -1; // variable qui test chaque conversation boolean checked; for (Panel_Conversation conversation : conversations) { ...
1fa0b32d-0a83-49ec-a9b3-fa27d5b4a079
9
public static void main(String[] args) throws IOException { ICsvBeanReader beanReader = null; try { beanReader = new CsvBeanReader(new FileReader( "D:\\Download\\all_india_PO_list_without_APS_offices_ver2.csv"), CsvPreference.STANDARD_PREFERENCE); // the header elements are used to map the values to the...
ab8c4727-73b4-4239-8346-e360f88b90ab
0
public int getScaledWidth() { return WIDTH; }
987359f8-d8ab-4602-96bc-7d7fbf443dc8
8
@Override public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (!f.hasTag(REGEXP_TAG)) { return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); switch (i...
9532ff7d-cc8a-4dd4-bd70-5b6e90f9ad01
2
private void updateGameResult(Boolean amIWinner) { view.setLastGameChoices(useCase.getMyLastChoice(), useCase.getOpponentLastChoice()); if(null == amIWinner) view.evenGame(); else if(amIWinner) view.winGame(); else view.lostGame(); }
4a46bd04-460d-49dd-a25b-4a0ad370a69f
1
public String toString() { StringBuilder sb = new StringBuilder(); for (byte[] b : list) sb.append(new String(b) + "\n"); return sb.toString(); }
3c077922-47b6-4e76-8e35-53e51a514a83
0
public static void setCaption(String c) { caption.setText(c); }
a16f1d30-a177-451c-86f2-34bd1fa45eb0
3
@Override public void Execute(CommandSender cs, String[] args){ try { if(!FCReborn.getPlugin().getChatters().containsKey(cs.getName())){ cs.sendMessage(ChatColor.RED + "[FCReborn] You aren't attached to anyone!"); return; } StringBuilder cmd = new StringBuilder(); for(String s: args){ cmd.a...
713b5daa-5fb4-447f-8dcc-6798711ebabc
1
protected boolean hasSomebodyWon() { return player1.win() || player2.win(); }
78072850-9ed5-4e47-8b6a-ea499e697521
9
public Image resizeImage(int intX, int intY) { if (isFile()) { if (intX >= 0 && intY >= 0) { File flTmp = new File(strFile); if (flTmp.canRead() && flTmp.isFile() && flTmp.exists()) { Image imgOrig; ...
cc8254eb-647c-4829-8aba-cdd5263dcb38
0
public static void main(String[] args) throws InterruptedException, MalformedURLException { String urlArg = args[0]; url = new URL(urlArg); SpringApplication.run(Application.class, args); Thread.sleep(600000); }
f441c7d7-fe6a-4682-9389-af505642ce48
2
private String read_file(final File file) throws Exception { BufferedReader r = null; final StringBuffer sb = new StringBuffer(); try { r = new BufferedReader(new FileReader(file)); String line = null; while ((line = r.readLine()) != null) sb.append(line).append("\n"); } finally { if (r != null) r.close...
5b1f6b04-eb82-494c-b1b3-3ee17fd63c20
3
@Override public void run() { while (true) { System.out.println("MediaDownloderThreadを起動します"); MediaDownloderComponent mediaDownloderComponent = new MediaDownloderComponent(); if (mediaDownloderComponent.isDownloadList()) { mediaDownloderComponent.download(); } try { sleep(SLEEP_TIME); ...
dc08e82b-c964-43df-ac1f-f2a19912ef8f
4
public static Gleitpunktzahl invSqrt(Gleitpunktzahl x) { /* TODO: hier den "fast inverse square root" Algorithmus implementieren */ if (x.vorzeichen || x.isInfinite() || x.isNaN() || x.isNull()) return Gleitpunktzahl.getNaN(); int y = gleitpunktzahlToIEEE(x).toInt()/2; y = FastMath.MAGIC_NUMBER - y; return...
ec422495-bb24-495f-8f30-f6dc781b3183
9
boolean isAdherentBorder(TextStyle style) { if (this == style) return true; if (style == null) return false; if (borderStyle != style.borderStyle) return false; if (borderColor != null) { if (!borderColor.equals(style.borderColor)) return false; } else { if (style.borderColor != null) r...
0b23d0ba-9655-4889-8cf3-5788cfb676d9
9
public void testConcurrentJoining() throws Exception { for(int i=0; i < NUM; i++) { threads[i]=new MyThread(channels[i], i+1, barrier); threads[i].start(); } barrier.await(); // causes all threads to call Channel.connect() System.out.println("*** Starting the con...
3bd929f5-bd93-42e8-bb74-b9f7550bc367
8
protected PartitionKeyTrace getPartitionKeyTrace(Object target, MethodSignature signature) { // inspect cached traces first PartitionKeyTrace trace = traces.get(signature.getMethod().toString()); if (trace == null) { Method method = getTargetMethod(target, signature); if (method != null) { An...
9585c1c3-0475-4968-9f58-2baa65824197
0
public void setW(String s){ w = s; }
53fce6e1-b870-443c-b150-5e26a10c14ea
7
@Override public int hashCode() { int result = font != null ? font.hashCode() : 0; result = 31 * result + (verticalAlign != null ? verticalAlign.hashCode() : 0); result = 31 * result + (align != null ? align.hashCode() : 0); result = 31 * result + (fgColor != null ? fgColor.hashCode(...
e9b33d6f-9324-4509-be66-a24dfe3e25ed
2
static void p1(int pos, int maxUsed) { if (pos == k) { System.out.println(Arrays.toString(a)); } else { for(int i = maxUsed+1; i <= n; i++) { a[pos] = i; p1(pos+1,i); } } }
1ded8e1d-60a4-45da-9c60-119999d70512
1
public RadioButton add(String lbl, Coord c) { RadioButton rb = new RadioButton(c, parent, lbl); btns.add(rb); map.put(lbl, rb); rmap.put(rb, lbl); if(checked == null) checked = rb; return(rb); }
f1e62097-485a-4490-be9c-5ec0d2f9fa3a
0
public String getName() { return name; }
521e5d82-b319-4c7b-9758-10e929ac47db
8
public static void main(String[] args) { EvolvingGlobalProblemSetInitialisation starter = new EvolvingGlobalProblemSetInitialisation(); starter.initLanguage(new char[] { '0', '1' }, 10, "(0|101|11(01)*(1|00)1|(100|11(01)*(1|00)0)(1|0(01)*(1|00)0)*0(01)*(1|00)1)*"); int solutionFoundCounter = 0; int noSolutionF...
58ae0321-016a-4df4-b7cc-e70fcabbb9e2
0
public AnimFrame(Image image, long endTime) { this.image = image; this.endTime = endTime; }
634d0912-b646-4c0f-ad4c-0ea11879fd84
3
public String toString() { String str = ""; if (this.type == TypeC.YELLOW) str += "Yellow"; else if (this.type == TypeC.GREEN) str += "Green"; else if (this.type == TypeC.RED) str += "Red"; else str += "Blue"; return str; }
bb0dd821-98ba-4114-abb8-f8be2e2f175a
9
public static EQdata loadCSV(File f) { ArrayList<EQcamper> sc = new ArrayList<>(); ArrayList<String> requirements = new ArrayList<>(); try { Scanner m = new Scanner(f); String titleLine = m.nextLine(); titleLine = titleLine.substring(titleLine.indexOf(",")+1); //gets rid of the Scout Name collum title...
cc0aaac9-4e47-4256-8e12-de7cf9bcd87d
8
public void moveCharacter(int x, int y, int lastKeyPressed) { try { this.retractWeapon(lastKeyPressed); this.retractWeapon(KeyEvent.VK_D); this.retractWeapon(KeyEvent.VK_A); Point newLocation = new Point((int) getCharacterLocation().getX() + x, (int) getCharacterLocation().getY() + y); GridSpace g...
af2df6c4-cf34-4c91-9df0-a9e4377cb426
4
public void setPassword(String password, boolean hashed){ if(password != null && this.password != null){ if(this.password.equals(password)) return; } if(hashed == true){ this.password = password; }else{ this.password = this.hash(password); } ...
61b763ef-5218-4124-a920-7aabfb711932
5
public void fillOrder(String orderNum) { //Called when a customer checks out //Query the Orders table System.out.println("Filling order: " + orderNum); String queryOrders = "SELECT o.stock_number, o.quantity FROM Orders o WHERE o.order_number = '" + orderNum + "'"; Statement stm = null; try { s...
63f07486-5dc0-4014-bd57-24a4c6b2b3ab
5
@Test public void testSetQueueTimeoutError() { LOGGER.log(Level.INFO, "----- STARTING TEST testSetQueueTimeoutError -----"); String client_hash = ""; String client_hash2 = ""; try { server2.setUseMessageQueues(true); } catch (TimeoutException e) { exce...
9499ff2e-baea-4390-9186-70674f8285c2
1
public void drawTop(Graphics g) { for (int i=0; i < edges.size(); i++) { edges.get(i).drawTop(g); } }
0a4cfb40-bf67-4b86-ae99-3464dd655c26
2
public void readConfig(String file) { try { FileReader configRead; configRead = new FileReader(file); Scanner scan = new Scanner(configRead); while (scan.hasNext()) { bluHeadX = scan.nextInt(); bluHeadY = scan.nextInt(); magHeadX = scan.nextInt(); magHeadY = scan.nextInt(); blaHeadX = ...
bb0c7229-ab11-4b44-a3f8-27a88b3ce7a7
0
public void setSuppliercode(int suppliercode) { this.suppliercode = suppliercode; }
6d4ab6ab-fec0-4e55-94d1-e12de6353c34
2
public void run() { try { // Join the group and listen for messages. groupInterface.joinGroup(group); while (polling) { // get a responses! byte[] buf = new byte[1024]; DatagramPacket packet = new DatagramPacket(buf, buf.length); groupInterface.receive(packet); String ...
caea21a0-253a-4bdc-ac0f-061dd5ce8a2b
2
private int getNumIterations() { int numIterations; if (population.getGenerationNumber() > 20) { numIterations = population.getGenerationNumber() * AppProperties.coefMultiplEpoch() * 2; } else { numIterations = population.getGenerationNumber() * AppProperties.coefMultiplE...
b31bf965-59c6-4918-b86f-80f97ea6c766
0
public String getAndroidJar() { return androidJar; }
f99556ae-73c7-41e9-bfa9-d36a52c6d00e
2
protected void move() { if (target!= null && m.checkEnemy(target) == true) { //System.out.println(target); turnTowards(target.getX(), target.getY()); move(speed) ; }//IllegalActor here making it turn when its not there (DID JAMES ADDD THIS?) el...
b3878cc1-f9c9-480f-97a7-ffb1ee716355
3
public AttendanceResponseList getAttendanceResponseList(int aiMaxSize, String asLastModified) { String lsParam = ""; if (aiMaxSize > 0) { lsParam += "&max_size=" + Integer.toString(aiMaxSize); } if (UtilityMethods.isValidString(asLastModified)) { lsParam += "&last...
99a49bc6-8f9e-4fa6-8bdb-5f5c2f8a9539
1
public JSONObject xml2Json(InputStreamReader xmlSrc) throws IOException, JSONException { char[] buf = new char[1024 * 64]; int cnt = -1; StringBuilder optStr = new StringBuilder(1024 * 1024 * 25); while((cnt = xmlSrc.read(buf)) > 0) { optStr.append(buf, 0, cnt); } String jsonStr = optStr.toString(); ...
7b038d90-d598-4afe-b56a-6ed937e177c8
7
protected int indexToInsert(GameComponent<?> component) { int lowerIndex = 0; int higherIndex = this.getComponentCount() - 1; int searchedZ = component.getZ(); if(this.getComponents().isEmpty() || searchedZ < this.getZFromComponentAt(lowerIndex)) { return 0; } if(searchedZ >= this.getZFromComponentAt(h...
fb929e3a-0042-40eb-a0f1-f19ab1e09e90
4
private Connection(String ip) throws UnknownHostException { try { socket = new DatagramSocket(0); } catch (java.net.BindException e) { // try // { // socket = new DatagramSocket(1003); // } // catch (java.net.BindException ex) // { // ex.printStackTrace(); // } // catch (SocketExcept...
9ff332ff-a2ae-4f26-bb46-53246bece2f4
8
protected boolean prereqs(MOB mob, boolean quiet) { if(mob.isInCombat()&&(mob.rangeToTarget()>0)) { if(!quiet) mob.tell(L("You are too far away to perform a called strike!")); return false; } final Item w=mob.fetchWieldedItem(); if((w==null)||(!(w instanceof Weapon))) { if(!quiet) mob.tell(...
4965fe8d-8ee8-4b83-adeb-0da45fbdef07
3
private void handleP1selection(ActionEvent e) { for (int i = 0; i < fighters.length; i++) { JButton button = view.getP1Array()[i]; if (view.getSelection()[i] == 1) view.setSelection(i, 0); if (button.equals(e.getSource())) { System.out.println("P1 button " + i); view.setSelection(i, 1); } ...
84a9dd43-6ed4-4a3e-83e8-71c0091dddf8
4
public int get(int key){ if(map.containsKey(key)){ Node n = map.get(key); if(n.pre != null){ if(list.last == n) list.last = n.pre; n.pre.next = n.next; if(n.next != null) n.next.pre = n.pre; n....
d87ec2c9-4197-41c2-8efd-62f920a43a67
0
@PersistenceContext public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; }
f14127aa-7aa1-49d7-aa91-a000534cb3e5
2
public static boolean isBorderTimerRunning() { if (borderTask == -1) return false; return (plugin.getServer().getScheduler().isQueued(borderTask) || plugin .getServer().getScheduler().isCurrentlyRunning(borderTask)); }
5a2dc063-bfe5-436d-ae49-36f033137243
7
public int countPrimes(int n) { if (n <= 1) { return 0; } boolean[] isPrime = new boolean[n]; for (int i = 2; i < n; i++) { isPrime[i] = true; } for (int i = 2; i * i < n; i++) { if (!isPrime[i]) { continue; } for (int j = i * i; j < n; j += i) { isPrime[j] = false; } } int cou...
a4027a4f-585b-4c43-8bf1-d43ba32505ee
8
public List<Value> getValueSpace() { List<Value> values = new ArrayList<Value>(); if(firstNumber instanceof MyPower) { double start = ((MyPower)firstNumber).getExponent(), e = ((MyPower)end).getExponent(), next = ((MyPower)nextNumber).getExponent(), iterations = (e - start) / (next - start) ...
66b4ef9a-07da-43b2-ab1a-90ecabc075ef
3
public static int countIncludedString(CharSequence charseq, String str){ if(charseq == null || str == null){ System.out.println("�L��Ȓl���͂��Ă�������"); } String testedStr = charseq.toString(); int count = 0; while(testedStr.contains(str)){ count++; int index = testedStr.indexOf(str); tested...
5d984afa-0bb5-4d44-92da-af35f718dd03
7
private void updateLayout() { if (panelTop != null) mainPanel.remove(panelTop); if (panelBot != null) mainPanel.remove(panelBot); switch (type) { case conjugation: panelTop = new AddConjugPanel(frameDictionary.getLanguage1()); panelBot = new AddConjugPanel(frameDictionary.getLanguage2()); bre...
2a35ab2f-f232-43d0-aa81-5e042f71b35b
6
protected UINode selectionAt(Vec2D mousePos) { if (super.selectionAt(mousePos) == null) return null ; if (selectMode == MODE_BOUNDS) { return this ; } if (selectMode == MODE_RADIUS) { final float radius = Math.max(bounds.xdim(), bounds.ydim()) / 2 ; return (bounds.centre().pointDist(mo...
3ff1d3cf-4059-4f05-9aa1-9382d7a7d318
7
public static String getLastName(String fullName) { if (fullName.contains(",")) {// assuming lastName first then firstName maybe as initial or with middle name // initial return fullName.substring(0, fullName.indexOf(",")); } else if (!fullName.contains(".") && fullName.contains(" ")) {// ...
c91cd9e6-6589-46e1-9e84-ec59f3ad82c3
0
public Production[] getProductions() { return productions; }
2a388850-3689-4e76-bf00-0d91b587fc37
6
public void setValue(Object self, Object value) { if (isBoolean && value instanceof Number) { value = ((Number) value).longValue() > 0 ? Boolean.TRUE : Boolean.FALSE; } try { if (writeMethod != null) { writeMethod.invoke(self, new Object[]{value}); ...
d3f6934d-afb3-4853-9152-d78d39835c2e
0
public Class(String className){ this.className = className; }
8325412f-393a-4e8f-b289-033c3370d364
6
public static void crossover(Deck[] result, int position, Deck[] source, float[] perf, float total){ Deck a = selectOne(source, perf, total); Deck b = selectOne(source, perf, total); if(Math.random() < Zegana.crossoverChance){ //We want to interchange the substring posa1:posa2 (inclusive) in a //with the...
80d09619-11c8-4ff5-b46c-bca67d11d455
4
public void dumpTable(final String table, final PrintStream inOut, final String newline) { (new SQLStatementProcessor<Void>("SELECT * FROM " + table) { Void process( PreparedStatement s ) throws SQLException { ResultSet rs = s.executeQuery(); ResultSetMetaData md = rs.getMetaData(); for( int i=...
263c8940-fb09-4de9-bd6d-2d06ea207cab
1
static void initOptions() throws FileNotFoundException, IOException{ opt = new Option(); //setSkin(opt.getSkin()); skin = opt.getSkin(); downloadPath = opt.getDownloadPath(); if (!new File(downloadPath).exists()) new File(downloadPath).mkdir(); maxDownloads= opt.getMaxDownloads(); exec = Executors.new...
6306a204-dd79-4825-98c7-c3ccf013bbb8
2
private void setupBackground(int utilitiesWidth, int slideHeight, int bookLayout) { background = new JLabel(); try{ if(bookLayout == 2){ backgroundImage = ImageIO.read(new File("resources/buttons2/UtilitiesBackground.png")); } else { backgroundImage = ImageIO.read(new File("resources/buttons/...