method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
1435efcb-9777-45b7-a634-fa72e1671cf3
0
@Override @MethodInfo(author = "Pankaj", comments = "Main method", date = "Nov 17 2012", revision = 1) public String toString() { return "Overriden toString method"; }
3693fe91-4fb2-4efd-b4ab-c06e298fd77c
9
@Override public boolean takeControl() { double distance = Sputnik.opp.getPose().distanceTo(new Point(0, 0)); Thread.yield(); // System.out.println("distance: " + distance); if (Localizing.cornerCount != 2) { return false; } if (Sputnik.robotMap.getHeading() == 0 || Sputnik.robotMap.getHeading() ==...
458aad3c-8a4f-41bf-8575-e496556a17cf
4
private void applyBackgrounds(Human actor) { Background root = vocation ; if (birth == null) { final Batch <Float> weights = new Batch <Float> () ; for (Background v : Background.OPEN_CLASSES) { weights.add(ratePromotion(root, actor)) ; } birth = (Background) Rand.pickFrom( ...
661236b3-bc38-4aa3-bbb4-495ac8241748
1
private void createMenuOptions() { String gameFontName = Configuration.GUI.Fonts.BUTTON_FONT; // Load all of the game graphics from the GUI congfiguration GameGraphic normalGraphic = GameAssetManager.getInstance().getObject(GameGraphic.class, Configuration.GUI.Graphics.GRAPHIC_BUTTON_NORMAL); GameGraphic hoverG...
13693249-ce33-435d-b515-5c431997c4ff
8
private Object getMenu(Object component, Object part, boolean forward, boolean popup) { Object previous = null; for (int i = 0; i < 2; i++) { // 0: next to last, 1: first to previous for (Object item = (i == 0) ? get(part, ":next") : get(popup ? get(component, "menu") : component, ":comp"); (i == 0...
585e7304-79a1-424b-a03f-5da9db4ef7f6
4
@Test public void testEmptyArray() { Conversions.debug = debug; double[] arr = Conversions.convert("{}", double[].class); Assert.assertTrue(arr != null && arr.length == 0); arr = Conversions.convert(" { } ", double[].class); Assert.assertTrue(arr != null && arr.length == 0); ...
b8d8f2c0-9c6d-459e-879c-1ad15f91ae2d
6
public void run() { try { InetAddress ipAddress = clientSocket.getInetAddress(); String remoteIP = ipAddress.getHostAddress(); player.setIPAddress(remoteIP); if (!(player.getIPAddress().equals(null))) { System.out.println("Player IP is: " + player.getIPAddress()); } OutputStream register...
d17b7736-d301-4739-ac97-8967c82b60a2
3
public static String encodeFromFile( String filename ) { String encodedData = null; Base64.InputStream bis = null; try { // Set up some useful variables java.io.File file = new java.io.File( filename ); byte[] buffer = new byte[ Math.max((int)(file...
01a673b1-9a0e-40cb-82b6-f99199cab73c
7
public static String cppUnpointerizeNativeType(String nativetype) { { int length = nativetype.length(); { int i = Stella.NULL_INTEGER; int iter000 = 1; int upperBound000 = length; boolean unboundedP000 = upperBound000 == Stella.NULL_INTEGER; loop000 : for (;unboundedP000 || ...
a064c104-86d6-4c2d-b7ff-4f9f1e78435a
4
public NewVariableEditor() { setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setTitle("Create new variable"); setBounds(100, 100, 450, 235); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); con...
8732501b-bed2-4062-986a-3df1a4325a0b
6
public CodeMap42 set(final int index, final int value) { int[][] map2; if ((index >>> 16) != 0) { if (map == null) map = new int[MAX_INDEX][][][]; final int i0 = index >>> 24; int[][][] map1 = map[i0]; if (map1 == null) map[i0] = map1 = new int[MAX_INDEX][][]; final int i1 = (index >>> 16)...
00adb2cf-597a-4336-b8d2-53d6d707c4c4
4
@EventHandler public void onInventoryClose( InventoryCloseEvent e ){ Player p = (Player) e.getPlayer(); if( p.getInventory().getChestplate() != null ){ if (String.valueOf(p.getInventory().getChestplate().getItemMeta().getLore()).contains("Life Touch III")) { p.setHealthSc...
97b6f539-75a6-4d73-a2ad-57b5ff0d4dbc
9
private void merge(T[] arValues, int left, int middle, int right) { // int nrTimes = (right - left) + 1; // int leftMoves = left; T leftValue = null; // int middleMoves = middle + 1; T middleValue = null; Vector<T> arTemp = new Vector<T>(nrTimes); for (int i = 0; i < nrTimes; i...
1483eab3-91a2-4b3f-83a1-8ab41de6964c
5
public boolean hasChanged() { if(parent != null && parent.hasChanged()) return true; if(!pos.equals(oldPos)) return true; if(!rot.equals(oldRot)) return true; if(!scale.equals(oldScale)) return true; return false; }
c30ae8ba-43c8-44a9-97a6-3891f02f4b02
6
public Move makeMove() { Move move; //Keep looping and getting moves 'till we get a valid move while (true) { move = getMove(); System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); //If we're trying to move from positions that are actually in the board if (!(move.getA().isOutOfBounds() || move....
b861bd59-dc1e-4200-9bf9-082860c17558
6
public static boolean isValid(JsonNode track) { LOG.debug("Checking validity of track : \n" + track); boolean result = false; if (track == null) LOG.warn("Track is invalid: null."); else if (!track.hasNonNull(ARTIST)) LOG.warn("Track is invalid: no artist attribute."); else if (!track.get(ARTIST).has(TE...
d3821ca7-0c88-407f-ab59-31c4a4608178
2
public void addIload(int n) { if (n < 4) addOpcode(26 + n); // iload_<n> else if (n < 0x100) { addOpcode(ILOAD); // iload add(n); } else { addOpcode(WIDE); addOpcode(ILOAD); addIndex(n); } ...
2caa8a86-4896-4813-9097-0b343979bfd0
7
public NodeInfoDialog(GUI p, Node n){ super(p, "Edit Node "+n.ID, true); GuiHelper.setWindowIcon(this); parent = p; node = n; node.highlight(true); this.setLayout(new BorderLayout()); JPanel nodeSelAndPosition = new JPanel(); nodeSelAndPosition.setLayout(new BorderLayout()); JPanel nodeSel...
58c84e3a-6438-4af4-a645-ac209d9ec3c6
3
public void addRulesInTable() { try { RulesManager.getInstance().loadRules(MainClass.RULES_DIR); } catch (Exception ex) { Logger.getLogger(NBFrame.class.getName()).log(Level.SEVERE, null, ex); return; } DefaultTableModel model = (DefaultTableModel) ta...
58691845-bde7-46cc-8302-5e1f6afd5607
2
public int sum (List<Integer> a){ if (a.size() > 0) { int sum = 0; for (Integer i : a) { sum += i; } return sum; } return 0; }
c1d2e87a-dc3f-4d9f-9c2d-e67ca65de167
8
@Override public void keyReleased(KeyEvent event) { int key = event.getKeyCode(); if(key == KeyEvent.VK_UP){ if(screen.checkRotate(current, currentCol, currentRow, orientation)) { screen.removePiece(current, currentCol, currentRow, orientation); orientation = (orientation+1)%4; screen.addPiece(curre...
01853c69-895c-4ef5-b3a9-2473dca94bf2
3
public static void IfCheatMessage() { for (int i = 0; i < playerInventory.length; i++) { Item playerInventoryVariable = playerInventory[i]; if (playerInventoryVariable != null) { if (playerInventory[i].getId() == 5) { System.out .println(" How to Become Immortal"); Sys...
635966d5-ada7-449d-9ad6-935d7aa21c1c
5
@Override public void tick(PlayField field) { // super.tick(field); xVel = xVel + xAcc / 10.F; x += xVel; if (x < width / 2) { x = width / 2; } if (x > Game.WIDTH - width / 2) { x = Game.WIDTH - width / 2; } y += yVel; xVel = xVel / friction; yVel = yVel / friction; if (x <= 0 || x >= Game....
1751e6a3-0d88-449c-9ce9-cabfe66c18e3
7
public double calcMoment(String whichMoment){ Stack<Point> blob_copy = new Stack<Point>(); blob_copy.addAll(blob); double moment = 0; // NOTE: This code will only work with Java SE 7. Strings in // switch statements were not supported in JDK<=6, apparently....
48b37552-73ea-4cf7-bac2-214aaae4ec96
1
private String calc(String input) { //Person 2 put your implementation here StringBuilder sb = new StringBuilder(); for (int i = 0; i < input.length(); i++) { int num = Math.abs(rand.nextInt()%input.length()); sb.append(input.charAt(num)); } retu...
2e5d018c-9a8a-4faf-991e-c1a22e7513e0
2
public void StartCallTime() { callTimeTask = new TimerTask() { @SuppressWarnings("deprecation") public void run() { second++; if(second==60) {minute++;second=0;} if(minute==60) {hour++;minute=0;} time.setHours(hour); ...
4ccacb33-51c3-4fdd-a8dc-a8765a6cd536
7
public void createLifeForm(int x, int y, LifeForms lifeForm) { //System.out.println("Creating " + lifeForm.name()); boolean[][] pattern = PATTERNS[lifeForm.ordinal()]; int patternHeight = pattern.length, patternWidth = pattern[0].length; for (int i = 0; i < patternHeight; i++) { if ...
6abf1cbd-97ac-46d4-8fc6-b663b4641ab2
7
public int generateTreshold(){ Collections.sort(valuesFaces); int[] treshold = new int[2]; int countDownToUp = 0; int countUpToDown = 0; for(int i = 0; i < valuesFaces.size(); i++){ if(valuesFaces.get(i).face){ countDownToUp++; } else { if(i > 0){ treshold[0] = (valuesFaces.get(i).value - v...
23e3e472-e9c4-4d08-a86b-54c424e4e556
2
public GeneratorWebClient() { isRunning = false; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 800, 600); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JPanel p...
3645b886-143e-40f2-ac3d-40ef41b34faf
0
public void setAppPackageName(String appPackageName) { this.appPackageName = appPackageName; }
3fc4b214-4649-4ee9-b700-d40e553b312f
1
private Node<T> setToNext(Node<T> node, T item) { if (node.next != null) { setToNext(node.next, item); } Node<T> nextNode = new Node<T>(null, item); node.next = nextNode; return nextNode; }
234e43e1-42bc-4209-9767-99731225d60c
5
@Override public Set<int[]> threshold(int thresh) throws IllegalStateException { if(!isDone) throw new IllegalStateException("accumulate() must be called before threshold(int)"); Set<int[]> circles = new HashSet<int[]>(); for(int r = 0; r < acc.length; ++r) { for(int x = 0; x < acc[r].length; ++x) { for(i...
454f1d2d-9cdc-4d39-b3a9-b7f435a9cf97
8
private int valorMax( Partida partida, EstatPartida estat_partida, int alfa, int beta, EstatCasella estat_casella, int profunditat, int profunditat_maxima, EstatCasella fitxa_jugador ) { Tauler tauler = partida.getTauler(); if ( profunditat == profunditat_maxima || estat_partida == EstatPart...
3f918c4a-c085-499e-ad43-4e9280e0425f
2
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/mensaje.jsp"); HiloBean oHiloBean = new HiloBean(); HiloDao oHiloDao = new HiloDao(oC...
1a69140c-c87e-47a0-ba32-40acfbb5f8fc
8
public String execute() throws CitysearchException { log.info("Start review action"); reviewRequest.setAdUnitName(CommonConstants.AD_UNIT_NAME_REVIEW); if (reviewRequest.getAdUnitSize() == null || reviewRequest.getAdUnitSize().trim().length() == 0) { reviewRequest.setAdUnitSize(CommonConstants.MANTLE_AD_SI...
75af09a6-0b1d-4b5f-8d42-05346156a6cf
5
public void refresh() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { content.removeAllChildren(); Enumeration<TreePath> paths = tree.getExpandedDescendants(tree.getPathForRow(0)); for(DialogCategory category : editor.controller.categories.values()){ DefaultMutableT...
49c5b714-9c65-475a-bfa6-71235f5ed039
2
public static String[] removeDuplicateStrings(String[] array) { if (isEmpty(array)) { return array; } Set<String> set = new TreeSet<String>(); for (String element : array) { set.add(element); } return toStringArray(set); }
59e07572-6044-457a-b4fe-2cedcae473e3
1
void doRun() throws InterruptedException { ExecutorService threadPool = Executors.newFixedThreadPool(THREAD_NUM); for (int i = 0; i < THREAD_NUM; i++) { Node n = new Node(threadPool); threadPool.submit(n); } }
3dba7fc1-674f-4c99-ac13-8616f2fc9e3a
6
public Node search(Problem problem, State initialState) { // Make a node with the initial problem state Node firstNode= new Node(initialState); // Insert node into the frontier data structure List<Node> frontier= new ArrayList<Node>(); frontier.add(firstNode); // (Variables needed later on) List<Node> su...
da60cc26-e9ca-44d4-9649-75b1e23e1f8c
2
public void visitNewMultiArrayExpr(final NewMultiArrayExpr expr) { print("new " + expr.elementType()); if (expr.dimensions() != null) { for (int i = 0; i < expr.dimensions().length; i++) { print("[" + expr.dimensions()[i] + "]"); } } }
d28573c5-3949-4d46-b0d1-2d211e0ed388
1
public boolean maximumHuntersReached() { if (world.getHunterList().size()<=10) return false; else return true; }
1874875f-bde6-4436-a226-c2e145b6c4af
4
@Override public void build(String dictName) { BufferedReader reader = null; StringBuffer stringBuffer = null; String string = null; try { reader = new BufferedReader(new FileReader(new File(dictName))); string = reader.readLine(); while (string != null) { stringBuffer = new StringBuffer(string); ...
8fc7bd9c-b036-4957-82fe-dee8490adcd2
6
public synchronized int setTemplateDirectory(File dir) { if (dir!=null && dir.isDirectory()) { this.directory = dir; File[] files = dir.listFiles(new XMLFileFilter()); int newCount = files==null ? 0 : files.length; int oldCount = templates.size(); List temp = new ArrayList(oldCount+newCount); te...
59e39069-ac8d-4682-927d-8d653b409351
5
public void addBlocks(int b) { debug("Adding " + b + " blocks to the game"); if (reset) { debug("Blocks not added, middle of reset"); return; } int bS; int rS; int c = 0; for (int i = 0; i < b; i++) { bS = this.getBlueScoreFromB...
703ec9f7-1aac-4684-bcea-22b67f9dd427
5
public void calcAdjacencies() { adjMtx = new HashMap<Integer, LinkedList<Integer>>(); for(int i = 0; i < NUMBEROFSPACES; i++) { LinkedList<Integer> temp = new LinkedList<Integer>(); if(i > 3) { temp.add(i - 4); } if(i % 4 != 0) { temp.add(i - 1); } if(i % 4 != 3) { temp.add(i + 1); ...
1dc6c4f1-9b86-438a-b62c-4c7a08373771
2
public void imprimir(Object[][] h) { for (int i = 0; i < h.length; i++) { for (int j = 0; j < h[0].length; j++) { System.out.print(h[i][j] + " "); } System.out.println(""); } }
fa3c02d0-f463-4855-80b1-c9e066eb530d
2
public void affiche(){ if(this.catalogue.size() < 1) System.out.println("Aucune questions..."); else{ for(int i=0; i < this.catalogue.size(); i++){ System.out.print("["+i+"] => "); this.catalogue.get(i).affiche()...
08388e8b-a17c-450c-b686-ca065510256d
1
@SuppressWarnings({ "rawtypes", "unchecked" }) public JList getFontSizeList() { if (fontSizeList == null) { fontSizeList = new JList(this.fontSizeStrings); fontSizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fontSizeList.addListSelectionListener( ...
026c2423-5998-4b6c-aaed-95e2d7f05c54
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ServicePK other = (ServicePK) obj; if (client == null) { if (other.client != null) return false; } else if (!client.equals(other.client)...
54f73dd5-03b1-456e-bf68-6cba4fadcbc1
5
public static int[] getShortestEdge(int[][] nabomatrise, ArrayList<Integer> noder) { int[] shortest = new int[] {-1, INF}; for (int fra = 0; fra < noder.size() ;fra++ ) { for (int til = 0; til < nabomatrise.length; til++) { int w = nabomatrise[noder.get(fra)][til]; if(w != INF && w < shortest[1] && !node...
b045da91-84df-4935-ad3c-269b062a63a1
8
public void putAll( Map<? extends Byte, ? extends Integer> map ) { Iterator<? extends Entry<? extends Byte,? extends Integer>> it = map.entrySet().iterator(); for ( int i = map.size(); i-- > 0; ) { Entry<? extends Byte,? extends Integer> e = it.next(); this.put( e.get...
91416b3b-5d9e-46f5-9271-98baec8d1b08
1
public static Connection connection(Server server, String dbName) { Connection result = null; try { result = DriverManager.getConnection(server.getUrl(dbName), server.getUser(), server.getPassword()); logger.debug(result); } catch (SQLException e) { logger.error("Error in get connection fo...
6b212e97-e62b-46d8-b135-5edaabcaa9a2
1
public static int randomized_partiton(int[] array, int start, int end){ Random r = new Random(); int a = r.nextInt(end); while(a < start){ a = r.nextInt(end); } exchange(array,a,end); return partition(array,start,end); }
9cc5710e-1d45-4df6-9856-45ac25a5c0cf
7
public static boolean joinGuild(String[] args, CommandSender s){ //Various checks if(Util.isBannedFromGuilds(s) == true){ //Checking if they are banned from the guilds system s.sendMessage(ChatColor.RED + "You are currently banned from interacting with the Guilds system. Talk to your server admin if you be...
7d3d6348-af4e-4ad8-b2ab-9975437d6d4f
0
public String getText() { return text; }
d90358ca-3eb4-47e2-8790-a8def13c3828
6
public void setString() { // An input window asking for a string String txt = JOptionPane.showInputDialog("Ange en text med bokstäver, siffror och tecken"); // An array of Array7x7 object to hold characters. // The size of the array must be at least 5. if (txt.length() < 4) { txtArray = new Array7x7[5]; ...
2264b689-4254-4d57-a744-2e9344e47eee
1
public String toString() { if (instance == null) return "new " + type; else return instance.toString(); }
405ec273-c002-46f9-a1a9-8e8e89a5c003
4
public boolean getButton(int which, int id){ switch(which){ case 1: return leftDriveJoy.getRawButton(id); case 2: return rightDriveJoy.getRawButton(id); case 3: return leftJoy.getRawButton(id); case 4: ...
76821b0c-6d61-4e27-9847-a62a3ab9d867
4
private void handleProcessClear(){ for(int i:processesMap.keySet()){ if((processesMap.get(i).getStatus() == Status.FINISHED.toString()) || (processesMap.get(i).getStatus() == Status.FAILED.toString())){ Message msg = new Message(Message.msgType.COMMAND); ...
bfc05b9d-471c-4254-a976-11211c85593b
0
public void lastStep(Context ctx) { ctx.setState(new FirstState()); }
0703d7dd-d28e-4f34-bc53-8f62310aa3e2
8
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if(!(myHost instanceof MOB)) return super.okMessage(myHost,msg); final MOB myChar=(MOB)myHost; if((msg.amISource(myChar)) &&(msg.sourceMinor()==CMMsg.TYP_CAST_SPELL) &&(!CMLib.flags().isGood(myChar)) &&((msg.tool()==null)...
4fd4819f-eef1-4914-8469-51eddb525efe
7
@Override public void actionPerformed(ActionEvent e) { if (e == null || e.getSource() == clearButton) { currState = game.getInitialState(); currState.rollDice(); } else if (!game.isTerminal(currState)) { if (e.getSource() == pro...
39893b17-ed44-4d9c-b19e-4ebdfbdd9213
6
public static TreeSet<IdInt> topListInt(String baseFilename, int numVertices, final int topN) throws IOException{ final TreeSet<IdInt> topList = new TreeSet<IdInt>(new Comparator<IdInt>() { public int compare(IdInt a, IdInt b) { if (a.vertexId == b.vertexId) return 0; ...
76dfda67-bad7-4c40-9597-ef18eaae14e0
1
private void resize(int n) { Type[] newArray = (Type[]) new Object[n]; for (int i = 0; i < size; i++) { newArray[i] = stack[i]; } stack = newArray; }
c8a08cb9-bf23-4af1-b259-833584595274
9
public boolean isBlocked(Location l, boolean playersBlock){ if (playersBlock) { //Return true if occupied by any player for (Player player : players) { if (l.equals(player.getLocation())) return true; } } //Return true if the location is beyond the edge of the map if(l.getX() >= MAX_X ||...
9553e0cb-6f47-4f78-a3f7-31831ea88e44
5
public static String changeExtension(String fileName, String extension, boolean gzipped) { extension = (extension.startsWith(".")) ? extension : String.format( "%s%s", ".", extension); String rgxOne = "^(.+?)(?=((\\.tar)?\\.gz)$)"; String rgxTwo = "^(.+?)(?=\\.(.*)$)"; Matcher m = Pattern.compile(rgxOne...
2a65096d-f0e1-4b0e-879b-cc9779fc5fbc
7
void TryToCookFood(Order o) { print("Doing TryToCookFood"); log.add(new LoggedEvent("Doing TryToCookFood")); int foodAmount = mRole.mItemInventory.get(Item.stringToEnum(o.choice)); if(foodAmount <= 0) { o.waiter.msgOutOfFood(o.table, o.choice); orders.remove(o); return; } mRole.decreaseInventory(It...
2f27f9be-740d-4aa9-84b7-67284872f88e
4
private void start() { TcpCon con = new TcpCon(); if((login.getText().trim().length()==0)||passwd.getText().trim().length()==0) { login.setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.red)); passwd.setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.red)); } else { ...
7f8ca8f5-55d6-4708-9ab4-d4f3b7ccd2aa
0
public void setName(String name) { this.name = name; }
f85f0f28-5c98-444f-a963-2b94d3736bba
5
public void sort(int[] array) { int length = array.length, gap = length; boolean swapped = false; while (gap > 1 || swapped) { gap = (int)((double)gap / SHRINK_FACTOR); if (gap < 0) gap = 1; swapped = false; for (int i = 0; (gap + i) < length; i++) ...
ddba1b53-fc27-4908-b541-8fd34e5aace3
7
public void highlightLine(final int lineNum) { final Highlighter high = getHighlighter(); final Document d = getDocument(); int line = 0; int posStart = 0; int pos = 0; int lineTermLength = 0; try { while ( line < lineNum ) { posStart = pos; lineTermLength = 0; // Find the end of a...
9c1fa063-ecfe-4309-9e3f-d5f308af972b
3
private boolean AT3x04PilotToneHunt (double spectrum[]) { int a,pbin; // Look if a particular bin in startCarrierList1 also exists in startCarrierList2 and startCarrierList3 for (a=startCarrierList1.size()-1;a>=0;a--) { pbin=startCarrierList1.get(a).getBinFFT(); if (checkBinExists(startCarrierList2,pbin)==t...
732e85ac-4e4f-4526-bf09-7405a2fcab3b
1
private void writeIntAMF0(List<Byte> ret, int val) { ret.add((byte)0x00); byte[] temp = new byte[8]; ByteBuffer.wrap(temp).putDouble((double)val); for (byte b : temp) ret.add(b); }
9aa6319d-8714-44d1-8600-ad0aed3ab132
5
@Override public int getPartition(Text key, DoubleWritable value, int numberOfPartitions) { String newSchemaStr = conf.get(SystemConf .getNewSchemaForConfSetString()); if (null == newSchemaStr || "".equals(newSchemaStr)) { try { ...
53fec754-fd9d-4c3c-822c-dc243e533dcc
5
private void addButtons() { JPanel buttonHolder = new JPanel(); buttonHolder.setLayout(new BoxLayout(buttonHolder, BoxLayout.X_AXIS)); JButton process = new JButton("Create map"); final Gui gui = this; process.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) ...
7a0688c6-a82b-4628-85e5-0926e1486fb9
4
public Currency[] search(String token){ ArrayList<Currency> list = new ArrayList<>(); for (Currency currency : this){ if (currency.getCode().equalsIgnoreCase(token)) list.add(currency); else if (currency.getSymbol().equalsIgnoreCase(token)) list.ad...
7b2b2d33-e32f-4c15-b5ab-2d6d5ae1ea67
2
public RainFall(String record, BufferedWriter out, String fn) { try { String[] fields = record.split(","); //System.out.println(record); _stationId = fields[1]; _year = "" + Integer.parseInt(fields[2]); _month = "" + Integer.parseInt(fields[3]); _day = "" + Integer.parseInt(fields[4]); ...
2452d59e-580c-4bf7-a697-0992403cfbeb
8
public MainFrame(final String title) throws IOException { super(title); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel csvPanel = new JPanel();//new FlowLayout()); csvPanel....
84f92d78-50a3-4988-972f-ee6adfd6ac44
8
@Test public void complicatedTest() throws Exception { for (int i = 1; i <= 20; i++) { heap.enqueue(i); } for (int i = 1; i <= 20; i++) { //heap should be 1 ... 20 assertIntWithObject(i, heap.dequeue()); } for (int i = 1; i <= 20; i++) { he...
e354563e-3f5a-44b2-b6d1-b7fc507487eb
8
@Override public AudienceVotingResult vote(List<Answer> allAnswers, List<Answer> possibleAnswers, QuestionDifficulty difficulty) { int answersCount = possibleAnswers.size(); if (answersCount != 2 && answersCount != 4) { throw new RuntimeException("Unable to vote for " + possibleAnswers.s...
416ec568-b6d8-49ce-80e3-948195f9a15f
2
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String actionCh = request.getParameter("Change"); String actionDel = request.getParameter("Delete"); if(actionCh != null) { RequestDispatcher view = request.getRequestDispatcher("ChangeRec.js...
6320aca0-5df1-475f-8784-17d32b07d40e
4
int guess(String solution) { int count = 0; count++; int a = getA(solution, "1234"); if (a == 4) { return count; } int b = getB(solution, "1234"); reduce("1234", a, b); for (int i = 0; i < validSet.length; i++) { if (!validSet[i...
53e4031d-1f02-4d05-a1b3-ed8e5c1c9848
6
public int compareTo(Object o) { if (o instanceof ArgPosition) { ArgPosition other = (ArgPosition) o; int i = 0; while (this.path.size() > i && other.path.size() > i) { final int result = this.path.get(i).compareTo(other.path.get(i)); if (result != 0) { return result; ...
4ca205dd-5786-42de-a19f-60da78c8762e
3
private static Character createCharacter(String type, Scanner console) { if(type.toLowerCase().startsWith("war")) { Warrior character = new Warrior(); return character; } else if(type.toLowerCase().startsWith("mag")) { Mage character = new Mage(); return character; } else if(type.toLowerCase().startsW...
ca4d55cc-868d-4eba-9ffd-7740df019f91
9
public void checkBananas(ArrayList<EntityBanana> ba){ for(int i = 0; i < ba.size(); i++){ EntityBanana b = ba.get(i); if(flying){ if( b.getx() > x && b.getx() < x + (cwidth / 2) && b.gety() > y - height / 2 && b.gety() < y + height / 2 ){ b.hit(1); } } if(intersect...
71f6b7a9-2bf6-4d68-9e0a-a270d4d60f0d
2
public static byte[] toByte(String str){ if(str != null){ try { return str.getBytes(UTF8); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; } } return null; }
f784f8bc-c77b-4c40-8e02-36fcf8f05674
8
public void processEvent(Event event) { try { if (event.getType() == EventType.CLASS_OPEN || event.getType() == EventType.CLASS_REPARSE) { this.cf = event.getClassFile(); } if (event.getType() == EventType.CLASS_PARSE_ERROR) { this.tree.setModel(new DefaultT...
54581995-aa87-48c3-b26f-50b8a1304511
8
public void updateReduceOutputPerMap(String jobID, String taskID, int mapId, int[] stat) { Boolean retry = false; int backoff = 1000; String domainName; if ( taskID.hashCode()<0 ) domainName = dbManagerDomain + (-taskID.hashCode())%Global.numSDBDomain; else domainName = dbManagerDomain + (taskID.hash...
89449d7d-559a-48ec-9613-ae7e4a47d1cf
0
@Test public void findHandFromCardSet_whenFourJacks_returnsFourOfaKind() { Hand hand = findHandFromCardSet(quadsJacksWithTenKicker()); assertEquals(HandRank.FourOfAKind, hand.handRank); assertEquals(Rank.Jack, hand.ranks.get(0)); assertEquals(Rank.Ten, hand.ranks.get(1)); }
7af6bb18-9e13-4c87-98e5-51c9c012c06c
3
private void playVote() { Vector<Integer> hasNotVoted = votes2.notVoted(2); for (Integer player : hasNotVoted) { if (!players2.isDead(player)) { players2.kill(player); bot.sendMessage(gameChan, getFromFile("NOT-VOTED", players2.get(player), NARRATION)); sendNotice(players2.get(player), getFromFile("...
d5992a12-d2c1-46ab-8713-0337bbe895f9
4
public OverwriteDialog(final JFrame parent) { super(parent, "", true); bundle = Application.getResourceBundle(); this.setTitle(bundle.getString("overwrite_title")); // Closing the window is equal to pressing the No-Button WindowListener windowListener = (new WindowAdapter() { @Overr...
886377c4-ca9c-467d-9591-29ec6084a8a7
4
private void experiment() { //wait for all the entities to register super.gridSimHold(50.0); int location; File f1 = null; File f2 = null; //1. create new files try { f1 = new File("file1", 5); f2 = new File("file2", 1); } catch (P...
9835ffe1-d3fc-44d1-9126-6ef60353f4d2
9
public static String buildOutputCalendar(Calendar calendar) { String res = " " + calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) + " " + calendar.get(Calendar.YEAR) + '\n' + (argsAnalizer.getIsWeekNumber() ? " " : "") + "Mo Tu We Th Fr Sa Su" + '\n'...
6a1901a6-b4ac-46fc-9898-fc83a011c171
3
@Override public void caseAProgramas(AProgramas node) { inAProgramas(node); if(node.getIdentificador() != null) { node.getIdentificador().apply(this); } { List<PDeclaracao> copy = new ArrayList<PDeclaracao>(node.getDeclaracao()); for(PD...
6da7001b-6509-4904-87e1-3564dd257f53
2
public void dbConnect(String db_connect_string, String db_userid, String db_password) { try { Class.forName("net.sourceforge.jtds.jdbc.Driver"); Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password); System.out.printl...
3c33a6fc-f047-4431-a470-e70c0e19d82a
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Townshipbusiness)) { return false; } Townshipbusiness other = (Townshipbusiness) object; if ((this.townshipBusi...
2e7afbcf-c97f-4c7e-9996-c57d8df950d6
4
private void outputHelper() throws IOException { miscInfo = new PrintWriter(new FileWriter(JPEGFileName.replace(".JPG", "_miscInfo.txt"))); outline = new PrintWriter(new FileWriter(JPEGFileName.replace(".JPG", "_outline.txt"))); controlPoints = new PrintWriter(new FileWriter(JPEGFileName.rep...
1218b430-b313-4bae-8b9d-d8b8f894e42c
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...
e64eafa6-67d2-4f9b-8e15-55cf93388d3b
6
public static HashMap<String, HashMap<String, Integer>> getMap(String filePath) throws Exception { HashMap<String, HashMap<String, Integer>> map = new HashMap<String, HashMap<String,Integer>>(); BufferedReader reader = filePath.toLowerCase().endsWith("gz") ? new BufferedReader(new InputStreamReader( ...
716195ef-b10c-43a7-89ba-312e50a17a59
9
@Override public void unInvoke() { final Physical affected=super.affected; // undo the affects of this spell if(affected==null) return; if(canBeUninvoked()) { if((invoker()!=null) &&((targetM == null)||(!CMLib.flags().isInTheGame(targetM, true))||(targetM.location()!=invoker().location()))) inv...