method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
4e8a30e7-248a-4106-98b4-d692c23e3a6e
1
public static String keyToLocatedString(String key) { String ret = null; try { ret = locale.getString(key); } catch (Exception e) { ret = key; } return ret; }
2433a976-4a4f-4edd-b75d-f9f22d77d65a
7
public double[] instanceToSchema(Instance inst, MiningSchema miningSchema) throws Exception { Instances miningSchemaI = miningSchema.getMiningSchemaAsInstances(); // allocate enough space for both mining schema fields and any derived fields double[] result = new doub...
57ef92b0-c19f-4750-8f7d-0afea6b3a71a
4
public static Level genWorldRandom(int cols, int rows, TexturePack tp) { /** Brick density. */ final double pBrick = 0.8; /** Probability of a light in the bg. */ final double pLight = 0.02; Level level = new Level(cols, rows, tp); for (int row = 0; row < rows; r...
4179398f-9271-4ffa-980e-56ee1dc6182a
3
public static void count_occurences(Integer[] v, Integer k) { boolean started = false; int counter = 0; for (int value : v) { if(value == k) { counter++; started = true; } else if(started) { System.out.println(counter); ...
e9ae6878-cf37-4852-a7eb-5a9cc4ebf605
8
public void setConnections() { System.out.println("Cog - Connecting cog nets"); // ======================== roomnet inhibits 'seenroom' in factnet /* for (int i = 0; i < RoomNet.getSize(); i++) { if (RoomNet.neurons[i].isInhibitory()) { int toNeuron = (i%40)+760; RoomNet.neurons[i].addConnection(Fa...
7e52be84-98ec-4c13-9f4d-764ee2a17201
5
public void SetPrices(int posState, int numSymbols, int[] prices, int st) { final int a0 = SevenZip.Compression.RangeCoder.Encoder .GetPrice0(_choice[0]); final int a1 = SevenZip.Compression.RangeCoder.Encoder .GetPrice1(_choice[0]); fi...
05a608af-64ed-4626-8bc6-19411e68b218
3
public void run() { try { String response; udpClient = new DatagramSocket(); udpServer = new DatagramSocket(PORT); udpPackage = new DatagramPacket(new byte[123], 123); /* Warte auf eingfehenden Nachrichten */ ...
4dcb6965-5535-42b0-836e-7ee1d6445967
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GcUsage gcUsage = (GcUsage) o; if (gcCount != gcUsage.gcCount) return false; if (gcTime != gcUsage.gcTime) return false; return true; ...
f10fcf22-1d9c-4515-bd7c-58260dc0efe7
6
public void paintComponent(Graphics g) { g.setColor(Color.BLACK); g.fillRect(0, 0, board.length * 30, getHeight()); for (int i = 0; i < board.length; i++) { for (int j = 0; j < board.length; j++) { if (board[i][j] == PLAYER) g.drawImage(imgPlayer, i * 30, j * 30, null...
8fa06c9b-bd54-4e47-b80e-dec73ba6220a
9
public void saveAsApplet() { Frame frame = JOptionPane.getFrameForComponent(this); fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.addChoosableFileFilter(FileFilterFactory.getFilter("html")); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); String s = Modeler.getInternationalText("SavePageAsHTM...
60436edc-cffd-46fa-8c64-3f6d7d465f59
8
public void takeShot(int x,int y) { this.setShots(); if (Battleship.getPlayers(Battleship.getEnemy()).getHitOrMiss(x,y)) { this.setHits(); if (!Battleship.getPlayers(Battleship.getEnemy()).isSunk(x,y)) { Battleship.getPlayers(Battleship.getEnemy()).setBboard(x,y,Color.orange); if ((this.getU...
81a5ce24-e5d7-4d38-bc3b-512fce5e4b3f
1
public int findPlayersFruitId(Player p){ int fruitId = -1; if(FruitManager.getInstance().getFruitByPlayer(p) == null){ return fruitId; } fruitId = FruitManager.getInstance().getFruitByPlayer(p).getId(); return fruitId; }
519b2f74-02f5-42ac-9c5d-a1daa92b562e
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...
c60239be-a559-4aa1-8b4e-58e91a64d729
6
public Match getNext(){ try { // read size of match int r = 0; byte[] b = new byte[4]; r = in.read(b); if(r == -1) { return null; } ByteBuffer bb = ByteBuffer.wrap(b); int...
e18bd636-b7d6-4155-8679-068d5b591355
1
public static int getMessageHeight(String message, Font font, Graphics2D g){ g.setFont(font); if(message.length() == 0) return 0; TextLayout tl = new TextLayout(message, font, g.getFontRenderContext()); return(int)tl.getBounds().getHeight(); }
b8c0e93c-8294-4755-944b-ca57dfa3bbc0
6
static public String numberToString(Number n) throws JSONException { if (n == null) { throw new JSONException("Null pointer"); } testValidity(n); // Shave off trailing zeros and decimal point, if possible. String s = n.toString(); if (s.indexOf('.') > 0 ...
67c4d6af-23b2-4a65-a7c6-dce215861f40
4
public void dispose() { for (Object cachedFile : cachedFiles) { String fileName = (String) cachedFile; try { boolean success = (new File(fileName)).delete(); if (!success && logger.isLoggable(Level.FINE)) { logger.fine("Error deleting c...
b81f08db-8739-4d10-867c-cd075b9114c7
6
public Particle(int _x, int _y, int _dx, int _dy, int _life, int _imageType, int _r, int _g, int _b){ this.x = _x; this.y = _y; this.dx = _dx; this.dy = _dy; this.life = _life; c = new Color(_r, _g, _b); if(_imageType == 0) { try{ image = new Image("Content/ImageFiles/diamond.png"); }catch(Sl...
ab500327-c48e-4263-bf66-f27036628afb
6
public static int[] runFourCard (int [] c, long dead) { int res[] = new int[Valuation.NUM_RANKINGS]; for (int i=0; i<52; i++) if (((one<<i)&dead) == 0) for (int j=i+1; j<52; j++) if (((one<<j)&dead) == 0) for (int k=j+1; k<52; k++) if (((one<<k)&dead) == 0) { c[4] = i; c...
2342c4ac-13b4-4c97-b2a6-1930f78073e6
9
@Override public void run() throws NullPointerException{ //public void execution(){ while(!dis.readyQueue.Is_Queue_Empty() || !dis.blockQueue.Is_Queue_Empty()){ //Is both Ready and Block queues empty //instructionCount =10; //@Pravi: this won't be needed, as we are assigning a value ...
8f1f1186-89af-4d16-a9f4-806480c4a4ff
7
private static void write(SootClass sClass, int output_format) { OutputStream streamOut = null; try { String filename = SourceLocator.v().getFileNameFor(sClass, output_format); if (output_format == Options.output_format_class) streamOut = new JasminOutputStream(new FileOutputStream(filename)); else ...
88f5cb38-10c9-42d1-af1c-145dd86bf259
0
public ConnectionInfo getConnectionInfo() { return connectionInfo; }
8eda8b91-47c5-4fad-a332-34f483c79394
5
private void notifyAtListner(final Subscriber<?, ?> listener, final Envelop data) { executor.execute(new Runnable() { @Override public void run() { final Filter f = listener.getFilter(); if (f.getManagedType() == null || data.getContentTyp...
4bb3d533-96cc-4a68-8994-f386d148c271
3
public void sub(int[] S, int start){ for(int i = start; i < len; ++i){ if(i > start && S[i] == S[i-1]) continue; seq.add(S[i]); res.add(new ArrayList<Integer>(seq)); sub(S, i+1); seq.remove(seq.size() - 1); } }
407aa98e-d520-4fbc-b71a-5cf9a0418aca
5
@Test public void testSetSocketTimeout() { LOGGER.log(Level.INFO, "----- STARTING TEST testSetSocketTimeout -----"); String client_hash = ""; String client_hash2 = ""; String client_hash3 = ""; try { client_hash = server2.addSocket("127.0.0.1", port); } ca...
4286762e-18f1-49f0-8681-7d7f96a3737a
8
static int knapsackV(int[] p,int[] v,int maxV){ if (maxV <= 0 || p == null || v == null || p.length != v.length){ return 0; } int size = p.length; if (size == 1){ if (v[0] <= maxV){ return p[0]; } else { return 0; ...
fde81ace-6047-47d2-9b67-a441bc76adfa
9
public boolean testScore(String startScore) { //sees if string is valid score String tempNumStr = ""; Integer firstInt = 0; Integer secondInt = 0; Double tempScore = 0.0; if(startScore == "0") { return true; }else { char[] aCharArray = startScore.toCharArray(); //turns input into array so it can be it...
131b180e-8bdb-4efb-a7e0-8c5188741fcd
8
public static void writeFileUTF8(File file, StringBuffer str){ if(!file.exists()){ try { if (file.createNewFile()){ BufferedWriter bw = null; try { bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file...
cda534e1-2a33-43e7-920d-a65d57e06961
8
public static void main(String[] args) { if(args.length < 3) { System.err.println("Not enough arguments!"); System.err.println(getHelp()); System.exit(0); } try { float a = (float) Float.valueOf(args[1]); float b = (float) Float.valueOf(args[2]); if(a < 0 || b < 0) { System.err...
54900ca8-7c97-454d-b185-5db169e2d7a0
2
public boolean isOptOut() { synchronized (optOutLock) { try { // Reload the metrics file configuration.load(CONFIG_FILE); } catch (IOException ex) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); return ...
e21155f1-4b18-4893-a890-b407931320f8
0
public static ArrayList<Excel> scale(int coeff, ArrayList<Excel> toScale) { return Scalign.scale(coeff, toScale); }
02675388-9f82-45c5-9ec5-8e06d21900c6
4
public ArrayList<Entity> retrieveSideWarps(){ ArrayList<Entity> warps = new ArrayList<>(); MapProperties prop = tileMap.getProperties(); Warp w; if(prop.get("next")!=null){ w = main.findWarp(ID, 1); w.setOffset(-4*Vars.TILE_SIZE, this.groundLevel); warps.add(w); // adds a trigger to show the title ...
1df42ab5-84d0-4e3f-bfe4-e1216de54f85
7
public void insert(String column[], String value[], String type[]) { if(conn!=null){ try { stmt = conn.createStatement(); String query = "insert into " + table_name + " ("; for(int i=0;i<column.length;i++){ query +=...
884a2523-f7e3-48bb-a227-d3c572d59322
3
public void updatePlayerDisplayName(Player p) { String confPath = "players." + p.getName(); String title = fastTitles.getConfig().getString(confPath); if (title == null || title.equalsIgnoreCase("none")) { p.setDisplayName(p.getName()); } else { String titleFormat = getTitle(title); if (titleFormat != ...
bad2a741-7766-4018-8f32-f8327815e249
3
@Override public void cleanup() { super.cleanup(); client.removeMessageListener(this); if(!stateSwitch && client != null && client.isConnected()) { client.close(); } }
e2b9d4fb-317f-4efb-acff-fa270f099e0b
0
public int GetEmptyTrips() { return emptyTrips; }
8e5103b9-00f2-43bf-98a1-4e15374b6cba
4
public static void main(String[] args) { Scanner consoleScanner = new Scanner(System.in); while (true) { System.out.print("Would you like to do: [1] convert celsius to fahrenheit, [2] convert fahrenheit to celsius, [3] quit: "); int input = 0; input = consoleScanner.n...
07bf58f8-7f1f-4a82-b756-9fa7888448b1
4
public void chooseImage() { // get the entity from the map that is on either side of this. if one is a // wall then we turn the graphic to a "-" if neither then we leave it as a // "|" if (getGameMap().isSceneryAtPoint(getX(), getY() + 1)) { if (getGameMap().getSceneryAtPoint(getX(), getY() + 1) i...
f185581d-f811-4f86-be2e-07b0a53141dd
7
public SimpleFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); setTitle("Forest:"); setLocation(400, 200); Container con = getContentPane(); con.setLayout(new FlowLayout()); button1 = new JButton("Create"); button2 = new JButton("Read"); button3 = new JButton("Update"); button4 = new JButton("Delete")...
9bd1bf58-ce5b-4316-b3d5-5aece8ab0622
0
public byte[] toByteArray() { return stream.toByteArray(); }
cc8074c4-ec10-4774-afd0-2bf70c5534f5
1
public void testConstructor_invalidObject_DateTimeZone() throws Throwable { try { new DateMidnight(new Object(), PARIS); fail(); } catch (IllegalArgumentException ex) {} }
61d41f30-ce08-474a-81ee-aff67b15ed19
5
private static final void method714(int i) { Widget class46 = AbstractFontRasterizer.getWidget(i); if (class46 != null) { int i_520_ = i >>> 16; Widget[] class46s = Class369_Sub2.aClass46ArrayArray8584[i_520_]; if (class46s == null) { Widget[] class46s_521_ = Class348_Sub40_Sub33.aClass46ArrayA...
13cc657c-eba9-42bb-b94c-385e98835a09
3
* @return The amount */ public int getComboAmount(int c) { if (c == SimpleCreature.COMBO_ONE) { return SimpleCreature.COMBO_ONE_AMOUNT; } if (c == SimpleCreature.COMBO_TWO) { return SimpleCreature.COMBO_TWO_AMOUNT; } if (c == SimpleCreature.COMBO_THREE) { return SimpleCreature.COMBO_TWO_AMO...
a0a47023-4f81-4a96-81c3-5306dbfb036d
9
public void doSspcCdf(int first, int last, int date) throws CDFException{ float scint_temp = 0, dpu_temp = 0; int numOfRecs = last - first; float[][] sspc_rebin = new float[numOfRecs][256], sspc_error = new float[numOfRecs][256]; float[] old_edges, std_edg...
d8b1db98-edd5-4fcd-bd39-c7caa5ae2b31
0
@Override public boolean setDefault(boolean def) { return (defaultGroup = def); }
1991a9bf-9254-4fc0-b176-8cabd6022bbe
0
@Override public Set<String> getGroups() throws DataLoadFailedException { return getList("groups", "name"); }
2f0bc326-7c32-480a-b5bb-8fea5f3ad4f9
7
private void fallIfPossible(World par1World, int par2, int par3, int par4) { if (BlockSand.canFallBelow(par1World, par2, par3 - 1, par4) && par3 >= 0) { byte var8 = 32; if (!BlockSand.fallInstantly && par1World.checkChunksExist(par2 - var8, par3 - var8, par4 - var8, par2 + v...
18d1b3b1-106b-41cf-b70d-a12b5b12a2a3
9
static void quickSortStringArray(String array[], int lo0, int hi0) { int lo = lo0 ; int hi = hi0 ; String mid = null ; if ( hi0 > lo0 ) { mid = array[(lo0+hi0)/2] ; while (lo <= hi) { while ((lo < hi0) && (array[lo].compareTo(mid) < 0)) ...
e1141a96-8611-46d2-b866-af7a219d5203
9
public static void checkEvolutions() { for(int i=0; i<userNumOfPokemon; i++) { if(user[i].status!=Pokemon.Status.FNT&&Mechanics.participatedInBattle[i]&&(user[i].evolve(user[i])!=user[i].species||user[i].evolve(user[i],JokemonDriver.trainerIdNumber)!=user[i].species)) { ynWin=new YesNoWindow(); ynWin...
572e13b7-637f-45ca-a914-f979c311b3cc
1
protected void type(By locator, String text) { if (text != null) { driver.findElement(locator).clear(); driver.findElement(locator).sendKeys(text); } }
ba46fa8d-eb87-42f7-aadc-92c5d9ba6a81
4
private void getNextTetromino() { // Get next tetromino and generate new one Iterator<Tetromino> it = next.iterator(); if (it.hasNext()) { tetromino = next.pop(); next.add(bag.draw()); } else { tetromino = bag.draw(); } // Notify liste...
acc6f36b-5d9c-49d8-b383-8cbe0f20b30a
2
public static void main(String[] args) throws IOException { String filename = "fairyface"; BufferedImage img = ImageIO.read(new File(filename + ".png")); int height = img.getHeight(); int width = img.getWidth(); int k = 1; int horz = 2; int vert = 4; int hSize = height / horz; int wSize = width / vert...
43e3830e-0306-422b-99f4-d77ab7520b50
8
private static void printKMax(int[] items, int k) { Deque<Integer> que = new ArrayDeque<Integer>(k); for (int i = 0; i < k; i++) { // Remove index of items smaller than current item in the array while (!que.isEmpty() && items[i] >= items[que.peekLast()]) { que.po...
3e27d511-1c6b-438b-8dd1-4372231597da
5
@Override public Pos WhereSet(Bord bord,Pos clickPos) { Pos retPos = null; ArrayList<Point> handList = new ArrayList<Point>(); // おけるところすべてを取得してループをまわす ArrayList<Pos> canSetList = bord.getCanSetList(getMyColor()); for (Pos pos : canSetList) { Bord vrBord = bord.clone(); // 一度石を置く vrBord.DoSet(pos...
cd306ec9-c206-410a-82b4-dbe5e92de269
6
@Override public boolean equals(Object obj) { if (this == obj) return true; else if (obj == null) return false; else if (getClass() != obj.getClass()) return false; else { Num other = (Num) obj; if (x == null && other.x != null) return false; else if (!x.equals(other.x)) return false;...
7270b5a2-12c9-4c25-909d-e6557c366072
3
public final boolean operator(Screen r) { if (id != r.id) return false; if (!dimensions.equals(r.dimensions)) return false; if (flags != r.flags) return false; return true; }
bbc0bf16-359c-4bd7-bcd9-18f02e7281bc
1
public void setDepth(int depth) { this.depth = depth; for (Node n : children.values()) { n.setDepth(depth + 1); } }
ede0088f-0973-49cf-87a3-2908b9b8f36b
4
public static void main(String[] args) { try { f(0); f(1); } catch(Exception e) { e.printStackTrace(); } finally { System.out.println("Finally: f(1)"); } try { f(2); } catch(Exception e) { e.printStac...
2fcb140c-6eba-4091-8572-fdbb0ff33c57
9
public static void main(String[] args) throws IOException { boolean running = true; while (running) { System.out.println("0.\tQuit"); System.out.println("1.\tCustom packet"); System.out.println("2.\tIdent packet"); System.out.println("3.\tRequest flavors packet"); System.out.println("4.\tRequest to...
a36c9eaa-eaba-44b9-831c-246f7942c511
6
public void makeDeclaration(Set done) { super.makeDeclaration(done); if (isConstructor() && !isStatic() && (Options.options & Options.OPTION_ANON) != 0) { ClassInfo clazz = getClassInfo(); InnerClassInfo outer = getOuterClassInfo(clazz); ClassAnalyzer clazzAna = methodAnalyzer.getClassAnalyzer(clazz);...
cd97caa0-323d-4301-9370-081369c0a217
3
@Override public void keyEnterPressed() { if (!Game.RELEASE) { if (shouldRender) { if (consoleText.isEmpty()) { opening = false; closing = true; } else { hudManager.processConsoleCommand(consoleText); ...
c50a6225-2dea-403e-80a1-badf163a0387
9
public MultiPointerServer() throws IOException, AWTException { thisPtr = this; loadConfig(CONFIG_FILE); /* try { localAddr = InetAddress.getLocalHost(); if (localAddr.isLoopbackAddress()) { localAddr = LinuxInetAddress.getLocalHost(); } mLocalHostName = localAddr.getHostName(); mLocalH...
52a8e611-63cd-4109-b4c6-c8f324944b75
2
@Override public boolean activate() { return (Bank.isOpen() && !Widgets.get(13, 0).isOnScreen() && Settings.usingHerb ); }
70040d1d-bc85-40c9-8259-05f1c37169fb
2
public void removePerson(P p) { GameData g = GameData.getCurrentGame(); if (p instanceof Contestant) g.removeContestant((Contestant) p); else if (p instanceof User) g.removeUser((User) p); fireTableDataChanged(); }
2b97cc94-a2ca-4e85-968e-46d7fe27f388
0
public Map<String, Long> getStatistics() { throw new RuntimeException("not implemented"); }
3569e3a7-ca57-4f95-b34a-e16e46f09672
4
private void reply(IrcMessage rawmessage, String message) { if(rawmessage.getType() == MessageTypes.CHANMSG) { try{ rawmessage.getClient().PrivMsg(rawmessage.getChannel(), message, false); } catch(Exception e){} return; } else if(rawmessage.getType...
3d0ff398-819c-47b0-8615-3b20b0e5616b
9
public void Weights(){ for(int i=0; i<inputNodes.length; i++) for(int j=0; j<inputNodes[i].brnO.length; j++){ // System.out.print(inputNodes[i].brnO[j].getWeight()+"\t"); inputNodes[i].brnO[j].updateWeight(alfa); // System.out.print(inputNodes[i].brnO[j].getWeight()+"\n"); } //System.out.print("\n")...
b13c0cd0-b387-4120-bae3-c8701d3d1d3f
1
@Override public boolean removeWatcher(WatchKey watchKey) throws IOException { boolean isWatcherRemoved = JNotify.removeWatch((Integer) ((JNotifyWatchKey) watchKey).getWatchKey()); if (isWatcherRemoved) { LOG.info(StringUtil.concatenateStrings("Watcher: ", watchKey.toString(), " was successfully unregistered.")...
273be15e-9cad-4ba0-88ff-9c10c5866a1b
1
public static TennisGame getInstance(){ if(instancia == null){ instancia = new TennisGame(); } return instancia; }
675bb9d0-33fc-493b-954a-d131c840f02a
8
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Timing that = (Timing) o; if (Double.compare(that.ioResponseTime, ioResponseTime) != 0) return false; if (Double.compare(that.worstReadeTime, w...
57db3989-6f02-49ea-895c-3a74ad81ac24
0
@Override public void testAssumptionFailure(Failure failure) { setCurrentFailure(failure); logger.warn("END Testcase '{}' '{}' BLOCKED because '{}'.", new Object[] {getId(failure.getDescription()), failure.getTestHeader(), failure.getMessage(), }); }
77c1688a-495b-4ea1-a0b2-4fb35c103c0c
8
static final public void expressao_relacional() throws ParseException { trace_call("expressao_relacional"); try { adicao(); label_7: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMPARACAO: case DIFERENTE: case MAIOR_QUE: case MENOR_QUE: ...
e0313f1a-a257-4964-966f-0832932266b1
3
void disposeAccessibles() { if (accessibles != null) { for (int i = 0; i < accessibles.length; i++) { if (accessibles[i] != null) { accessibles[i].dispose(); } } accessibles = null; } }
f48145e2-30e9-43a5-a06d-6f2a751a2fd7
0
public String[] getSomeStrArray() { return someStrArray; }
877786c8-8934-4c98-a103-77fa04571458
4
private static boolean isPermutate(int i, int j){ int[] a = new int[10]; int[] b = new int[10]; String si = Integer.toString(i); String sj = Integer.toString(j); for(char ii : si.toCharArray()){ a[Integer.parseInt(""+ii)]++; } for(char jj : sj.toCharArray()){ b[Integer.parseInt(""+jj)]++; } ...
0a564b41-d53e-4c80-b813-96962592e342
8
public static void run(URL warUrl, boolean consoleMode, String[] args) throws Exception { if (args.length == 0 || isHelp(args)) { BootstrapCommon.printUsage(WebappBootstrapMain.class, "usage-webapp.txt"); System.exit(-1); } Options options = createOptions(); Parser parser = new GnuPa...
4d862a0a-ec6b-47cf-a09e-43f8e5329f94
8
public int[][] generateMatrix(int n) { int[][] matrix = new int[n][n]; int startx = 0; int starty = 0; int endx = n - 1; int endy = n - 1; int num = 1; while (startx <= endx && starty <= endy) { for (int i = starty; i <= endy; i++) { matrix[startx][i] = num; num++; } for (int i = startx +...
e64e737d-9bfa-47a3-aa7d-881058fc5d1c
4
private void removeAllComponents(Container container){ if(container.getComponentCount() != 0){ for (Component component : container.getComponents()) { if(component instanceof Container){ Container childContainer = (Container) component; if(childContainer.getComponentCount() != 0){ removeAllComponents...
cb16ba90-967d-41e7-a035-9fd789bd9d75
3
public int calcFatorInc(Personagem personagem){ int valor = 0; switch (personagem.getClasse()){ case 1: valor = (int) (personagem.getQuantidadeVida() * 0.1); break; case 2: valor = (int) (personagem.getQuantidadeVida() * 0.4); ...
e38b0622-14a5-4f77-8438-61387230d9c7
7
public static void main(String[] args) { final String graphite_path = "/home/inescid/graphite/"; final String sniper_path = "/home/inescid/sniper-5.3/"; final String test_folder_path = "/home/inescid/Desktop/autotests/"; if(args.length == 0 || args.length > 6){ System.out.println("use --help option to obta...
c8599ae2-ad49-4e30-b530-db0f7e9a5cab
2
private void appendToBuffer(StringBuffer buf, String text, int depth, boolean appendLineEnd) { for (int i = 0; i < depth; i++) { buf.append(CHAR_TAB); } buf.append(text); if (appendLineEnd) { buf.append(CHAR_NEWLINE); } }
e6610a82-d21e-4116-bb3d-de9849da857c
9
public String getConfigPath(String filename) { if (isApplet()) return null; File jgamedir; try { jgamedir = new File(System.getProperty("user.home"), ".jgame"); } catch (Exception e) { // probably AccessControlException of unsigned webstart return null; } if (!jgamedir.exists()) { // try to crea...
ac1b7cfe-ee0d-4268-acdb-9d8921aa224d
7
@Override public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); switch (action) { case "Start": boolean validInput = true; String userFisrtName = tfUserName.getText(); String userLastName = tfUserLastName.getText(); if (userFisrtName.equals("") || userLastName.equals(""))...
efa8df46-e7b6-4a21-b44e-d0c84b152db5
0
public static Image getFaceDownCardImage() { String curDir = System.getProperty("user.dir"); String pathName = curDir + "/classic_cards/"; Image pic = Toolkit.getDefaultToolkit().getImage(pathName + cardImageFileNames[cardImageFileNames.length - 1]); return pic; }
8b97de8f-a095-40e5-a6ac-9b2aa589929b
0
@Override public Object getValue() { return this.nativeValue; }
8685428b-a9f7-4746-803c-6673e8719cb2
4
@Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_D) { MainChar.setRPress(false); } if (e.getKeyCode() == KeyEvent.VK_A) { MainChar.setLPress(false); } if (e.getKeyCode() == KeyEvent.VK_S) { MainChar.setDPress(false); } if (e.getKeyCode() == KeyEvent.VK_W) { Ma...
4e0e2f60-eb1a-4dfe-9244-bcfb06541b32
4
@Override public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); if (action.equals(">>>>")) { verplaatsOpdrachtNaarRechts(); } else if (action.equals("<<<<")) { verwijderOpdrachtVanToegevoegdeOpdrachten(); } else if (action.equals("^^^^")) { verplaatsOpdrachtNaarBoven...
9842b9ea-76fd-44e1-858b-af5f9120196e
5
public static void setIntLE(final byte[] array, final int index, final int value, final int size) { switch (size) { case 0: return; case 1: Bytes.setInt1(array, index, value); break; case 2: Bytes.setInt2LE(array, index, value); break; case 3: Bytes.setInt3LE(array, index, value); ...
e6910f92-36f0-48ab-ae11-94751c170c3c
5
private static int[] stringToArray_4(String s) { int[] ret = null; if ((s != null) && !s.equals("")) { String[] tmp = s.split(SkinConstants.SPLIT2); if (tmp.length == 4) { ret = new int[4]; try { for (int i = 0; i < tmp.lengt...
c28d67f1-cc87-4f71-bdd8-33cb034f6d63
1
private boolean headerAlreadySent(Map<String, String> header, String name) { boolean alreadySent = false; for (String headerName : header.keySet()) { alreadySent |= headerName.equalsIgnoreCase(name); } return alreadySent; }
72c436cd-85b0-49ce-9169-7178e418e0b2
4
public void tick(long delta) { // FOLLOW CAM //------------ // // Seems to only work correct in 1920 * 1080 resolution // Probably to do with scaling... // // Work on this later! (tired, 23.55 now...) // //------------ if(game.her...
58470678-21e2-4cd9-b24d-ee54929d7eaa
6
public static Method findMethod(Class<?> clazz, String method, Class<?>... parameters) { for (Method m : clazz.getDeclaredMethods()) if (m.getName().equals(method) && Arrays.equals(m.getParameterTypes(), parameters)) return m; if (clazz.getSuperclass() != null) re...
963949e6-bc25-4cfa-aaeb-59e8b0d98a7e
8
public static void main(String[] args){ try { Object obj = Class.forName(args[0]).newInstance(); String[] temp = new String[args.length-1]; for(int i=1 ; i<args.length ; i++){ temp[i-1] = args[i]; } CommandLineParser.parseCommandLine(temp,obj); for(Method method : obj.get...
8c8e1132-b304-4ddb-83d6-59d6689693a4
7
@Override public boolean tick(Tickable ticking, int tickID) { if(!super.tick(ticking,tickID)) return false; else if((affected!=null)&&(affected instanceof Room)&&(invoker!=null)) { final Room room=(Room)affected; for(int i=0;i<room.numInhabitants();i++) { final MOB inhab=room.fetchInhabitant(i...
58a2b5d7-3ffb-4ff5-82a7-277506fff754
7
public ChordBoardAPPView(SingleFrameApplication app) { super(app); initComponents(); // status bar initialization - message timeout, idle icon and busy animation, etc ResourceMap resourceMap = getResourceMap(); int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeo...
70260392-0f61-436e-a0d7-4a5bdfe216da
7
public void testDuringAddIndexes() throws Exception { Directory dir1 = new MockRAMDirectory(); final IndexWriter writer = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED); writer.setInfoStream(infoStream); writer.setMergeF...
3c18abf3-3383-42a2-ae94-db03eb0915cf
6
public static boolean isPrime(int n) { if (n <= 3) { return n >= 2; } else if (n % 2 == 0 || n % 3 == 0) { return false; } else { for (int i = 5; i < (Math.sqrt(n) + 1); i += 6) { if (n % i == 0 || n % (i + 2) == 0) { return...
565c9c16-0a54-47fc-aca9-4357c4a9409e
9
public Queue<String> kamikazeXMLUnit (){ try { path = new File(".").getCanonicalPath(); FileInputStream file = new FileInputStream(new File(path + "/xml/papabicho.xml")); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); ...
7c77d249-51b8-4fea-9b8f-0ef3c9c31b3d
5
@Override public boolean userIsAuthorizedForService(String user, Service service) { log.info("Checking user {}'s authorization for service {}", user, service); try { log.debug("Setting the statement parameters"); int index = params.indexOf("user"); if (index > -1) statement.setString(index + 1,...
256b46fe-7ba1-4d90-be39-34d5dfb8c2f8
7
public static void main(String[] args) { System.out.println("Welcome to CHATBOT"); String question; boolean askAQuestion = true; Scanner keyboard = new Scanner(System.in); Bot bot = new Bot(); do { System.out .println("Tell Chatbox something (enter Goodbye to leave): "); question = keyboard.nextL...