method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
5e601928-cb4e-46aa-af22-339d1efb6023
0
public void closeWindow() { window = null; }
fefdf3e1-63c9-41f7-924f-a78014e02ecb
6
public static void sortStudentsPromotion() { if (FileReadService.sList.isEmpty()) { System.out.println("There is no Student !"); } else if (FileReadService.pList.isEmpty()) { System.out.println("There is no Promotion !"); } else { System.out .println("Do you want to sort in an Ascending Order (0)...
423d1c00-a6ba-46d7-a6ba-21c5b78b9f93
5
public JsonElement next() throws JsonParseException { if (!hasNext()) { throw new NoSuchElementException(); } try { return Streams.parse(parser); } catch (StackOverflowError e) { throw new JsonParseException("Failed parsing JSON source to Json", e); } catch (OutOfMemoryError e...
fb47000c-0a05-40f6-8053-8a7e870758fa
6
private static int alphaBeta(Configuration conf, int alpha, int beta,byte depth,byte max){ if ((conf.whoWin() != 0) || (depth >= max)){ return evaluation(conf); } else{ int meilleur = Integer.MIN_VALUE; for (Configuration fconf : listeFils(conf)) { int suiv=-alphaBeta(fconf, -beta, -alpha, (byte) (de...
b392c813-f227-43cc-bda3-a34218f39dd8
2
@Override public void onSignIn( String name ) { ServerToUser service = currentClient.newService( ServerToUser.class ); if (userMap.containsKey( name )) { System.out.println( "SERVER: sign-in attempt failed for " + name + ", user already signed in" ); service.onSig...
d278b5d4-b80c-43a7-8683-728465492381
6
public static void main(String[] args) { if (args[0].equals("--mutate")) { //java -jar <your jar> --mutate <n> <input file> try { Reader inStreamReader = new InputStreamReader(new FileInputStream(new File(args[2]))); Program program = ParserFactory.getParser().parse(...
d7746aad-94c0-481c-98a1-1838ebc562d4
9
private void generateCellValue(int rowIndex, int colIndex) { if (!(field[rowIndex][colIndex].getCellType() == CellType.Bomb)) { int roundBombsCount = 0; for (int i = rowIndex - 1; i <= rowIndex + 1; i++) { if (i >= 0 && i < height) { for (int j = colIn...
e5cf6d5c-201f-47e9-9273-c99ff15ce7e6
8
public void DumpAPIUsageData( AbstractApi api, String outFile ) { try { FileWriter fw = new FileWriter(outFile); for( PackageElem pack : api.Packages ) { for( ClassElem klass : pack.Classes ) { for( Integer id : klass.AnswerIds ) { fw.write( join( new String[]{"class", pack.Nam...
81b63182-5fde-4881-a2f2-63cc29cad49c
5
public boolean isActive(Vector2 cursor){ if(cursor.x>=objs.length) cursor.x = 0; if(cursor.x<0) cursor.x = objs.length; if(cursor.y>=objs[(int) cursor.x].length) cursor.y = 0; if(cursor.y<0) cursor.y = objs[(int) cursor.x].length; if(objs[(int) cursor.x][(int)cursor.y]==null) return false; return objs[(...
4b9be46b-ffa0-4577-8bf6-ac3f0f52b517
2
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); if (this.bbKey == null){ Properties props = new Properties(); try{ // properties file should be put here (not included in repo) props.load(g...
c15d4e82-a17b-41b8-b1c7-e259e3e89dbb
7
@Path("/formulario") public void formulario(Pedido pedido, List<Item> i){ if(pedido.getCliente() == null) { validator.add(new ValidationMessage("Vampo Obrigatório", "pedido.cliente")); } validator.onErrorUsePageOf(this).cadastra(); if (pedido != null && pedido.getCliente() != "") { if (i != null) { ...
88379fcd-6dae-4625-91cf-a7371bccf131
9
public void visitLiteral(JCLiteral tree) { try { switch (tree.typetag) { case TypeTags.INT: print(tree.value.toString()); break; case TypeTags.LONG: print(tree.value + "L"); break; ...
688f5c1a-58cb-4641-9843-0303e314a07d
4
public static boolean isVersionEqualToo(String isThis, String equalToThis){ int A[] = parseVersion(isThis); int B[] = parseVersion(equalToThis); if(A[0] == B[0]){ if(A[1] == B[1]){ if(A[2] == B[2]){ if(A[3] == B[3]){ return true; } return false; } return false; } return f...
da8071fb-4e40-4d8b-a325-84eb9b71d4bc
7
@Ignore @Test public void kingRookAndBishop() { Map<String, Integer> figureQuantityMap = new HashMap<>(); figureQuantityMap.put(KING.toString(), 2); figureQuantityMap.put(ROOK.toString(), 2); figureQuantityMap.put(BISHOP.toString(), 2); int dimension = 7; assertT...
ff0f6369-ca4b-4aa8-a673-f5a5a21777b4
9
public static void main(String args[]){ Twitter twitter = TwitterFactory.getSingleton(); try{ BufferedReader br= new BufferedReader(new FileReader("ftw")); File fw=new File("twDataCounts"); FileOutputStream fos=new FileOutputStream(fw,true); OutputStreamWriter osw=new OutputStreamWriter(fos); Writer...
80292ca0-27c2-42ea-98fa-bd0b7ded9940
9
public static void unzipFile(String zipFileName) throws Exception { try { File f = new File(zipFileName); ZipFile zipFile = new ZipFile(zipFileName); if((!f.exists()) && (f.length() <= 0)) { throw new Exception("要解压的文件不存在!"); } String strPath, gbkPath, strtemp; File tempF...
899a0c20-3886-4d3d-9e43-042e49e4a81d
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); addActionListener(this); }
5220ae64-5f9e-4528-9005-8b178feaad64
9
public void handlePacket(int id, PacketReader read) { if (id == 2) { int sub = read.readInt(); if (sub == 1) { RaspIDE.instance.newSippetnNET(read.readString(), read.readString()); } else if (sub == 2) { RaspIDE.instance.getSnippet(read.readString()).setCode( read.readString()); } } ...
eb9d5dca-2ce6-49de-8750-dc1b5896fd73
1
private static String byteToHex(final byte[] hash) { Formatter formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", b); } String result = formatter.toString(); formatter.close(); return result; }
3a3eac9c-59de-4a0d-be22-af96aa2451af
1
public PopUp(BufferedImage image, String title) { // format title if too long if(title.length() > (TITLE_LENGTH+3)) title = "..." + title.substring(title.length()-TITLE_LENGTH); // create frame JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(WindowConstants....
67d84ad3-e608-429f-bed7-915c94f21ace
3
private void addToSymbolTable(String label,int address) { boolean error = false; for(SymbolAddress e:symTab) { if(e.label.equals(label)) error=true; } if(error) { System.out.println("!---------- ERROR: Label already exists -----...
78a34613-fc56-4bac-b775-259d818e165c
0
public void setAddress(String address) { this.address = address; setDirty(); }
b7eed3fa-d248-41f8-8f0a-f74ac792533c
4
public SimpleRunCPE(String args[]) throws Exception { mStartTime = System.currentTimeMillis(); // check command line args if (args.length < 1) { printUsageMessage(); System.exit(1); } // parse CPE descriptor System.out.println("Parsing CPE Descriptor"); CpeDescription cpeDesc =...
4444b963-063d-4f3c-a536-b3a36e560ea8
8
private void adjustStartingTime(int timeUnit, int timeUnitCount) { calendar.setTime(new Date(rrdGraph.im.start * 1000L)); switch (timeUnit) { case SECOND: calendar.add(Calendar.SECOND, -(calendar.get(Calendar.SECOND) % timeUnitCount)); break; case MINUTE: ...
e4a91571-5ff7-438e-8d2c-454aa193613b
2
private int getMafiaCount() { int count = 0; for (Player player : players.getPlayers()) { if (player.getRole().equals(Role.Mafia.toString())) count++; } return count; }
d2d4470d-3840-48b8-8c54-8798d85f9473
2
public Board(int columns, int inrows) { cols = columns; rows = inrows; board = new Point[cols][rows]; columnHeight = new int[cols]; movesMade = new int[cols*rows]; moveCounter = -1; /* Set columnHeight to zero and initialise all points to EMPTY. */ for(int x=0; x<cols;x++) { columnHeight[x]=0...
5cac1d34-5f76-4432-ab68-213deddc2d09
8
public void giveHoobItem(CommandSender sender, String playerName, String item, String[] args) { Player target = null; target = findPlayer(playerName); String dis = ""; if (target != null) { switch(item) { case "1": giveBookOne(target); break; case "Shelf1": giveShelfOne(target); ...
c966229e-d575-4af4-a1bd-37998571fd0c
6
public static Map<Integer, List<Double>> serviceAttackES(Map<Server, Set<Application>> connections, int runs, int deadlyServicesAmount) { Map<Integer, List<Double>> result = new HashMap<>(); double robustnessMax = getAliveServers(connections).size() * Simulator.getInstance().getApplicationPoolSize(); ...
88cd9728-f41e-441d-9983-c5f216479310
8
private static void addBeerToSearchIndex(Beer beer) { Document.Builder docBuilder = Document.newBuilder(); /*** Id ***/ Long beerId = beer.getId(); docBuilder.addField(Field.newBuilder().setName("id").setText(Long.toString(beerId))); /*** Name ***/ String beerName = beer.getBeerName(...
177d74f5-5228-4ea9-8315-441b593d3f04
9
public boolean isInterleave(String s1, String s2, String s3){ if(s1.length() + s2.length() != s3.length()) return false; boolean[][] matched = new boolean[s1.length() + 1][s2.length() + 1]; matched[0][0] = true; for(int i1 = 1; i1 <= s1.length(); i1++){ if(s3.charAt(i1-1) == ...
addc0da1-7838-41c7-b851-1445dd1571d5
6
final void method3930(byte i) { ((NativeToolkit) this).aClass101_Sub2Array8131 = new Class101_Sub2[((NativeToolkit) this).anInt8090]; anInterface18Array8098 = new Interface18[((NativeToolkit) this).anInt8090]; ((NativeToolkit) this).aClass229Array8086 = new Class229[((NativeToolkit) this).anInt8090]; ((Na...
5f770d7d-0134-40d2-94ec-03c01d2069bb
5
@Override protected ByteBuffer onAllocate(int size, AtomicBoolean cache) { // For any size thats greater then the max or less then the minimum // buffer sizes just create a HeapByteBuffer. if (size > maxSize || size < minSize) { try { return ByteBuffer.allocate(size); } catch (OutOfMemoryError e) ...
28a0ac78-61f6-4232-bbb3-507f5b585844
4
@SuppressWarnings("resource") public static void filerdr() throws IOException{ if (!fnames.exists()){fnames.createNewFile();} BufferedReader rfile = new BufferedReader(new FileReader(fnames)); String nme=null; while (rfile.ready()){ nme=rfile.readLine(); if (nme!=null && !nme.isEmpty())...
322c582e-37e2-4219-818d-4ef9fff06393
2
public byte[] listReader(ArrayList<Packet> buffer, byte[] target) { byte[] targetMac = new byte[6]; //Object[] packets = buffer.toArray(); //for(int i = 0; i < packets.length; i++) { //} Iterator<Packet> it = buffer.iterator(); ARPPacket p = (ARPPacket) it.next(); while(it.hasNext()) { ...
bd2c2224-9c74-44c6-a6cf-10dcbca6724a
2
public void suljeEdellinenKortti(){ if (ui.getNakyvaKortti().equals("ajastin")){ ui.suljeAjastinmaatti(); } else if (ui.getNakyvaKortti().equals("kertain")){ ui.suljeKertausmaatti(); } }
c941cc2d-9e72-4f41-8d93-5bea328dbad4
9
public static int[] heapSort(int[] array) { // build heap for (int i=1;i<array.length;i++) { int currentIndex = i; int parentIndex = (i-1) / 2; while((array[parentIndex]<array[currentIndex])) { int t=array[parentIndex]; array[parentIndex] = array[currentIndex]; array[currentIndex] = t; ...
4ddce57e-4661-4a25-82c3-e851b52f72a0
3
@Override public void actionPerformed(ActionEvent e) { if ( callback == null ) return; Iterator<JRadioButton> it = buttonList.keySet().iterator(); while ( it.hasNext() ) { JRadioButton thisButton = it.next(); if ( thisButton.isSelected() ) { callback.connectToClient(buttonList.get(thisButton...
b590bd37-b736-4f90-bdc9-f1d64f9ff8d4
4
public void testFloatlargeArrayArraycopy() { float[] data = new float[]{1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 10.10f}; int startPos = 2; int length = 8; LargeArray.setMaxSizeOf32bitArray(1073741824); FloatLargeArray a = new FloatLargeArray(data); Float...
12b8f5f7-fd21-419c-943b-b0a50c4cbe7b
7
public byte[] decrypt(byte[] textEncrypted, String key){ byte[] decrypted = null; try{ //keygenerator.init(bits); // 192 and bits bits may not be available byte[] keyPadded = new byte[bits / 8]; for(int i = 0; i < bits / 8 && i < key.length(); i++){ keyPadded[i] = (byte)key.charAt(i); } /*...
cad1d05d-aa2c-4db3-a34e-531b8a6b8a4a
6
public static int dehexchar(char c) { if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'F') { return c - ('A' - 10); } if (c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; }
f443fe84-3d05-43cb-8d58-10cc33d015cc
9
public void loadGame(Stage stage) { // If there are save files if(Save.get().getSaves() != null && Theater.saveFile.matches("New")) { switch(titleMenu.select()) { case(-1): break; // Load a selected save file default: Theater.saveFile = titleMenu.getText().get(titleMenu.getSelected()).getLine();...
2d1fc881-6e7f-4e58-a642-d3929cedaab9
3
public void tick() { if (timerSpawnEnemy.isTimeleft() && mobsStack.size() > 0) game.addMob(mobsStack.remove(0)); for (DirectionPoint dp : directionPoints) dp.tick(); endpoint.tick(); }
fc3595cc-8dca-47b6-9b34-c43f7c3566ac
1
public void catchException(final Label start, final Label end, final Type exception) { if (exception == null) { mv.visitTryCatchBlock(start, end, mark(), null); } else { mv.visitTryCatchBlock(start, end, mark(), exception.getInternalName()); } }
972f6a3e-98c0-48da-8dab-25559e26086b
9
private String getChart(String request) { int index = request.indexOf("#"); String user; String project; user = request.substring(0, index); project = request.substring(index + 1); System.out.println("Requested user= " + user + ", project= " + project); int userId = 0, projectId = 0, hoursPerWeek = 0; ...
48dff0f3-13cb-4775-8243-2b49dbc1d357
9
private void shutdownImpl() { // Shut down read/write threads, if necessary if (Thread.activeCount() > 1) { L.i("shutdown(): Shutting down read/write threads"); Thread[] threads = new Thread[Thread.activeCount()]; Thread.enumerate(threads); for (Thread thr...
f38659d0-da98-4982-8227-efe3791392cd
6
public static double getDamageModPierce(WeaponMaterial type) { switch (type) { case COPPER: return 0.75; case BRONZE: return 1; case SILVER: return 0.25; case IRON: return 1; case STEEL: ...
706000dc-7c92-4975-80e2-20b8e5dd2945
8
@Override public ApiResponse insertValues(TableProperties tableProperties) throws IllegalArgumentException, LengthTableException, SQLException { if(connexion == null && path == null) return ApiResponse.MYAPI_NOT_INITIALISE; Statement stat = null; if (connect == null || connect.isClosed()) return ApiRe...
47ca0177-e374-49ba-bdda-104ae95798d1
9
private static INFO __INFO (String _info){ if (_info==null) return null; INFO info_container = new INFO(); boolean hasAudio; boolean common; String thesequence = _info.substring( _info.indexOf("/EntL")+5, _info.length()-1); hasAudio = thesequence.endsWith("X"); if (hasAudio) thesequence= th...
1293a6d2-bfea-42ea-a0e1-fd758b93a794
6
public void removeCategory(Category t) { try { String filepath = System.getProperty("user.home") + "/.TODO-group9/savedata.xml"; DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(fil...
7ab7f1b8-a508-41f4-9eaa-8b050e640406
0
private final void setNick(String nick) { _nick = nick; }
d32f2cf4-e20a-45b6-aae2-3178aa5ee7d2
0
public byte[] getAll() { return Arrays.copyOf(buf,index); }
dabda4e1-4611-4672-892e-9a14ec4580e6
5
private void updateVillainMissiles1() { ArrayList<VillainMissile1> deadVillainMissiles = new ArrayList<VillainMissile1>(); for(int i = 0; i < villainMissiles1.size(); i++) { VillainMissile1 v = villainMissiles1.get(i); v.move(); if(CollisionDetector.isColliding(v, sc)) { if(!sc.isShieldActive()) ...
7b8100d9-0e97-48a2-9a18-0eda67ec7ad8
8
public boolean canGoSwim(float posX, float posY) { if(!noclip) for(int x1 = 0;x1<w;x1++) { for(int y1 = 0;y1<h;y1++) { int gridX = (int) ((x1+posX)/Block.BLOCK_WIDTH); if(gridX < -1) gridX -= 1; int g...
93425edd-2efb-4c57-bea3-b7423c08b464
2
private void obtainSource() { xml = new File("ports.xml"); if (xml.exists()) populateTable(); else { xml = new File("service-names-port-numbers.xml"); if (!xml.exists()) downloadNewPorts(); populateTable(); saveXMLFile(data); } }
85fc1b7f-9080-4ecf-91e5-7d567b399e0d
1
public PathCreator(){ roomCounter=0; initializeArray(); while(roomCounter<maxRooms){ int x = roomChooser(); createRoom(x); } createDoors(); printStuff(); }
eb573456-7101-4703-8d9a-fc2beaea2392
8
protected Document createDefaultModel() { return new PlainDocument() { public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (permit != null) { char[] source = str.toCharArray(); char[] result = new char[source.length]; int j = 0; for (int i = ...
ef6a7af1-da37-4d4f-8e12-c7f99e5b742b
7
@Override public W<DeltaTriple<Delta,Delta,Delta>> delta(DC obj) { if(obj instanceof Triple) { Triple that=(Triple)obj; if(this.r.instanceOf(that.r) && this.s.instanceOf(that.s) && this.t.instanceOf(that.t)) { W wr=this.r.delta(that.r); W ws=this.s.delta(that.s); W wt=this.t.delta(th...
41755934-29af-49b4-9169-cd8222f470db
3
public boolean equals(Object object) { if (object == this) { return true; } if ((!(object instanceof CycSymbol)) || (object == null)) { return false; } return ((CycSymbol) object).toFullStringForced().equals(toFullStringForced()); }
62c423d2-cc48-43b8-8de7-9a79b07a0c15
0
public void setPrpIdElemento(Integer prpIdElemento) { this.prpIdElemento = prpIdElemento; }
b1e0dc00-da4d-43d4-86c8-0af2954a621f
7
@Override public void mouseClicked(MouseEvent e) { Component clicked = e.getComponent(); if (clicked.isEnabled()) { if (clicked.equals(this.play)) { if (loadInstrument()) { setRunningState(true); ...
0c70dd56-7985-4571-8f5a-b2a9afbfee4b
3
public void schrijf() throws DbException{ PrintWriter schrijver; try{ schrijver = new PrintWriter(handler.getBestand()); }catch(FileNotFoundException e){ throw new DbException("file not available"); } ArrayList<Product> producten = handler.getWinkel().getProducten(); for(Product product: producten)...
e5556317-0dea-4ef3-9f98-b5b9b696dedd
7
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 ht...
9da0ab86-8847-41b9-87cb-1ef383fc5fb1
0
@Test public void findHandFromCardSet_whenThreeSevensAndAceKingExist_returnsTripSevenswithAKKickers() { Hand hand = findHandFromCardSet(threeSevensAndAceKing()); assertEquals(HandRank.ThreeOfAKind, hand.handRank); assertEquals(Rank.Three, hand.ranks.get(0)); assertEquals(Rank.Ace, hand.ranks.get(1)); assertE...
ca097277-7618-4d22-9247-a1a7ae7235b4
1
private void loadPreferences() { prefs = Gdx.app.getPreferences(Constants.APP); // Coloca los valores por defecto (para la primera ejecución) if (!prefs.contains("sound")) prefs.putBoolean("sound", true); }
ea90be9f-8a7c-41b5-93fb-e902ed10ceab
6
public boolean gameIsOver() { boolean foundWhiteKing = false; boolean foundBlackKing = false; for (int rank = 0; rank < this.board.length; rank++) { for (int file = 0; file < this.board[rank].length; file++) { if (this.board[rank][file] == Board.whiteKing) { foundWhiteKing = true; } else if (this....
51087430-a7a7-475f-ba1a-f7108941cf9f
0
public JComboBox getjComboBoxChercher() { return jComboBoxChercher; }
f7aab680-1663-435d-b6a4-284f65dab554
7
private void loadPathCaseGraph() { boolean done = false; if (configuration == null) done = true; else if (service == null) { String WebServiceURL = (String) configuration.get("WebServiceUrl"); if (WebServiceURL != null && !WebServiceURL.equals("")) conne...
664bc9c5-0e77-42dc-a9cb-dc656fdbafb8
0
public String getFind(int i) { return (String) this.finds.get(i); }
93fbe850-0068-493b-a75c-cdbf3ee934ac
4
@Override public void run() { try { System.out.println("starting mining"); Process p = Runtime.getRuntime().exec(MINECMD); p.waitFor(); BufferedReader input = new BufferedReader(new InputStreamReader(p .getInputStream())); String line; while ((line = input.readLine()) != null) { System.out...
08e0628e-0759-48a3-bf4f-6b9ae82250f0
5
public void dispose() { for (int i = 0; i < resources.size(); i++) { Object obj = resources.get(i); if (obj != null && obj instanceof Resource) ((Resource) obj).dispose(); } resources = new ArrayList<Object>(); if (menu1 != null) { menu1.dispose(); menu1 = null; } if (menu2 != null) { menu2.dispos...
340176e3-0587-494b-acb5-312c9bd3120d
3
@Override public void updateFromDTO(final EntityDTO dto) { super.updateFromDTO(dto); PlayerDTO pDTO = (PlayerDTO) dto; this.speed = pDTO.getSpeed(); this.colorID = pDTO.getColorID(); this.engineLeft = pDTO.isEngineLeft(); this.engineRight = pDTO.isEngineRight(); this.engineMain = pDTO.isEngineMain(); ...
d467b2af-25c9-49bf-a5d4-152c0b66f11c
4
public boolean openFile(String path, long fileLength) { File outputFile = new File(path); if (outputFile.exists()) { Log.i(LOG_TAG, "Deleting existing file " + path); outputFile.delete(); } try { outputFile.createNewFile(); } catch (IOException e) { Log.e(LOG_TAG, ...
fe8cf3f1-5746-4aa2-b216-af0f98eb7c2d
0
public String getName() { return this.name; }
abb63577-db11-4bbc-b458-804c05b8f2d3
1
public static String charArrayToString(char[] charArray) { StringBuilder string = new StringBuilder(); for(int i = 0; i < charArray.length; i++) { string.append(charArray[i]); } return string.toString(); }
1b627a7b-d671-4ee7-af08-f4fadb65c6cd
0
public void setPanel(Panel p) { this.panel = p; }
c80f0368-b751-4227-a51d-61af8c398f29
1
public double[][] getPotentialProfile() { double[] x = new double[intervals.size()]; double[] y = new double[x.length]; for (int i = 0; i < y.length; i++) { x[i] = intervals.get(i).getX(); y[i] = intervals.get(i).getY(); } return new double[][]{x, y}; ...
abfa5ac7-e011-4446-a06d-f824177b85b0
3
private void actionOk( ) { try { int m = Matrix.getNumOfRows(matrix); int n = Matrix.getNumOfColumns(matrix); for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) matrix[i][j] = Double.parseDouble(matrixTF[i][j].getText()); } catch( NumberFormatException exc ) { return; } state = State.OKAY; s...
6524d4ad-dd0e-4178-a4fa-aa077e81d77c
2
@Test public void assignCoordinatesAssignsCoordinates() { String[] s = {"0 0 0 0", "0 0 0 0", "0 0 0 0", "0 0 0 0"}; DynamicArray<String> d = new DynamicArray(); for (int i = 0; i < s.length; i++) { d.insert(s[i]);...
87444f63-8718-4ce3-8d51-a32bd200947e
6
private static Container findComponentWithBorder(JComponent panel, Class<?> aClass) { for (int n = 0; n < panel.getComponentCount(); n++) { if (panel.getComponent(n) instanceof JComponent) { JComponent comp = (JComponent) panel.getComponent(n); if ((comp.getBorder() ...
5dfe5652-0f62-4ac9-9539-91cc6091261a
0
public int getIconHeight() { return STATE_RADIUS * 2; }
c73c9d5c-97a7-45f8-83d7-32e3b3ec47ee
5
private void setRect(double minLat, double minLng, double maxLat, double maxLng) { if (!(minLat < maxLat)) { throw new IllegalArgumentException("GeoBounds is not valid - minLat must be less that maxLat."); } if (!(minLng < maxLng)) { if (minLng > 0 && minLng < 180 && maxLng < 0) { rects = new Re...
7fa416f7-52cc-46f2-b398-747d2a3b12fa
1
Key[] resize(Key[] a, int n) { Key[] b = (Key[]) new Comparable[n]; System.arraycopy(a, 0, b, 0, (a.length < b.length) ? a.length : b.length); return b; }
d8fa23af-04b8-4696-abbf-126f52e6fb6a
4
public boolean importData(TransferSupport support) { if (!canImport(support)) { return false; } Transferable transferable = support.getTransferable(); String line; try { line = (String) transferable.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { return false; } ...
d1ff1e95-ca96-4c7b-bec3-dc64ab657d3d
2
public void save(int chunkX, int chunkY) throws IOException{ String path = Standards.WORLD_SAVE_LOCATION + "/" + chunkX + "x" + chunkY + ".cnk"; FileOutputStream out = new FileOutputStream(path); for (int x = 0; x < Standards.CHUNK_SIZE; x++){ for (int y = 0; y < Standards.CHUNK_SIZE; y++){ //contents[x][...
ad9f2f76-b9ea-4c6e-aa62-6a37ca4cb729
6
private void buildSegments() { PathIterator iterator = path.getPathIterator( null, 1 ); double[] coords = new double[6]; List<Point2D> segments = new ArrayList<>(); Point2D previous = null; while( !iterator.isDone() ) { int type = iterator.currentSegment( coords ); if( type == PathIterator.SEG_MOVETO |...
617cc88d-cac2-428d-891e-3a49d40dc088
6
@Override public List<SkillRating> employeeSkills(String employeeId) { String sql = SELECT_EMPLOYEE_SKILLS + employeeId + "' AND givenBy ='" + employeeId + "'"; List<SkillRating> skills = new ArrayList<SkillRating>(); Connection connection = new DbConnection().getConnection(); ResultSet resultSet = null; ...
49b33359-b676-4669-a496-20b24046ebca
4
public static Object[] performFrizzBuzz(String[] actualList) { String outputList[]= new String[actualList.length]; Arrays.fill(outputList, ""); for (int i = 0; i <actualList.length ; i++) { boolean flag = false; if((Integer.parseInt(actualList[i])%3==0)){ ...
6200ed61-4419-42e2-ad7e-f9bae0301cee
9
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person = (Person) o; if (age != person.age) return false; if (dateOfBirth != null ? !dateOfBirth.equals(person.dateOfBirth) : person.dat...
fc7a098c-24c2-4982-8b8a-3a4ce5021872
5
public void onClose(int round){ boolean stop = false; synchronized (syncIncr) { if (!shouldIncrease || round == super.getNumberOfRounds()) { stop = true; } else { shouldIncrease = false; double increase = ((super.getMaxPrice() - super.getMinPrice()) / (super.getNumberOfRounds() - 1)); s...
5824d4c4-02bd-48bd-ab61-f7428bc4e55c
6
public void accept(final MethodVisitor mv) { switch (type) { case Opcodes.F_NEW: case Opcodes.F_FULL: mv.visitFrame(type, local.size(), asArray(local), stack.size(), asArray(st...
239e142f-aadc-4852-a68a-e4b3f6e9754e
4
public void checkInteractions() { synchronized (playerPawns) { //Code that checks for AI, player, interactions if (playerPawns.isEmpty()) { return; } PlayerPawn previousPlayer = playerPawns.get(0); for (PlayerPawn v : playerPawns) { ...
ecebef1a-7914-4d7b-8b5c-3602ce3aeae6
2
public boolean isGreater(int i, int j) { assert i > 0 && j > 0; if (this.array[i - 1].compareTo(this.array[j - 1]) > 0) { return true; } else return false; }
01daf18a-87e0-485d-b574-bea77947181e
6
protected String chooseCaseHandler(int routine, RequestType reqType) { Method[] methods = this.getClass().getDeclaredMethods(); // Цикл по всем методам текущего класса for (Method curMethod : methods) { CaseHandler anno = curMethod.getAnnotation(CaseHandler.class); // В...
dcc73c01-54bc-47e6-8c7e-6ef4b0294df8
9
public void putObjects(String bucket, String destination, List<String> listFiles) throws Exception { if(destination.trim().equalsIgnoreCase("/")){ destination=""; } if(destination.startsWith("/")){ destination = destination.substring(destination.indexOf("/")+1); } i...
636c51a7-aa0d-4868-a975-750e5c96edfb
4
private boolean isWithinDensityDomain( float x , float y){ if(x < (float)densityDomain[0] || x > (float)densityDomain[1]) return false; if(y < (float)densityDomain[0] || y > (float)densityDomain[1]) return false; return true; } // end method isWithinDensityDomain( float x , float y)
9e1c4be5-faa9-4ad5-9411-4f63e41bf536
1
public int unpin() { pin_cnt = (pin_cnt <= 0) ? 0 : pin_cnt - 1; return(pin_cnt); } // end unpin()
f85ee045-e896-445f-95c9-9b702ce349c0
4
private void test() { EmailImpl mail = new EmailImpl(); mail.setText("hello world"); mail.addAddress(new EmailAddress("macrozone@gmail.com")); mail.setSendTime(new Date().getTime()+20000l); try { getApp().getMessagingService().addMessage(mail); } catch (AddressValidatorException e) { // TODO Auto-gene...
9134d692-3dc9-468e-83d2-7b05fc8b18f3
6
private static String[] splitBySpaces(String expr) { LinkedList<String> words = new LinkedList<String>(); int start = -1; // -1 si pas dans un mot for (int cursor = 0; cursor < expr.length(); cursor++) { if (start != -1 && Character.isWhitespace(expr.charAt(curs...
85f2f759-6669-41e7-af9d-800b69a56314
9
@Override public void teach(MOB teacher, MOB student) { super.teach(teacher, student); if((student!=null)&&(student.fetchAbility(ID())!=null)) { final CharClass C=student.charStats().getCurrentClass(); if(CMLib.ableMapper().getQualifyingLevel(C.ID(), false, ID())>=0) return; final boolean crafting ...
eee81488-8672-4288-a651-b64be9edce9e
7
private Element diplomacy(Element element) { Player player = getFreeColClient().getMyPlayer(); DiplomacyMessage message = new DiplomacyMessage(getGame(), element); Unit unit = message.getUnit(); if (unit == null) { logger.warning("Unit omitted from diplomacy message."); ...