method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
cb151fbf-06d6-400d-a77b-4544ed39f095
2
public double[] standardizedPersonStandardDeviations(){ if(!this.dataPreprocessed)this.preprocessData(); if(!this.variancesCalculated)this.meansAndVariances(); return this.standardizedPersonStandardDeviations; }
b98be113-ca1a-40a2-a0f4-61fdc99f816f
6
public int binarySearch(int value, int[] array, int lowIndex, int highIndex) { if (value == 0) return -1; runCount++; if (lowIndex == highIndex) { if (value == array[lowIndex]) return lowIndex; else return -1; } int midIndex = (lowIndex + highIndex) / 2; // System.out.println("Looking in ...
6e9870c5-1854-4f60-a924-034cee219261
5
public void setScoreboardFormat(String scoreboardText, String scoreboardScoreType) { if(scoreboardText == null || scoreboardScoreType == null) throw new NullPointerException(); if(!scoreboardScoreType.matches("(?i)d|h|m|s|ms")) throw new IllegalArgumentException(); String oldText = this.scoreboardText; sc...
731725a3-ca8a-487a-93ae-58b976894a0b
3
private JsonObject getFreesoundAPISoundInstanceFromId() { // sets headers Header[] headers = { new BasicHeader("Content-type", "application/json") }; // sets Freesound API Sound Instance url String tempUrl = "http://www.freesound.org/apiv2/sounds/" + id + "/?token=" + apiKey; // executes GET request ...
5ff7ef59-72b8-425f-b2de-f081528b33ad
5
public void Login() { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String username = userTextField.getText(); char[] password = passwordField.getPassword(); String passwordString = new String(password); try { answer = Switch.switchMethod("logIn", username, passwordString); } catch (Excepti...
66fb67c1-624c-4b3b-9d42-bf7a80c029f1
6
private static StringBuilder normalizeHex(StringBuilder hex, int step) { // strip and white space int length = hex.length(); for (int i = 0; i < length; i++) { if (isNoneHexChar(hex.charAt(i))) { hex.deleteCharAt(i); length--; i--; ...
0054bcd7-6aa5-4dc2-b3b8-d92f906346bb
1
public Boolean isOnline() { long time = System.currentTimeMillis(); if(time-lastSignal > Constants.NOT_ALIVE_INTERVAL*1000) { return false; } else { return true; } }
b5e0a7e6-08bf-4ed3-9db5-6125f4ecb2bd
3
@Override public int compareTo(final Lap o) { int ret; if (this.getId() == null) { ret = 1; } else if (o == null || o.getId() == null) { ret = -1; } else { ret = this.getId().compareTo(o.getId()); } return ret; }
b7a0b671-c24b-4281-9535-afaab857a0e6
1
public boolean onMouseUp(int mX, int mY, int button) { if(button == 0) { screenClicked = false; } return false; }
7657dee6-14b3-4601-9114-f7c36fea7a34
6
public void restore() { String[] split = _backupouts.split(","); _outs = new BoardObject.type[split.length]; for(int j=0; j<split.length; j++) { for (BoardObject.type c: BoardObject.cardtypes) { if (split[j].equalsIgnoreCase(c.toString())) { _outs[j] = c; } } } String[] split2 = _backupi...
5e4965d8-1167-40d6-97d2-b333543d091c
2
public static int countColumns(String file) { try { // Open a file and read one line BufferedReader reader = new BufferedReader(new FileReader(file)); String line = reader.readLine(); reader.close(); // Nothing to read? if (line == null) return 0; // Count fields String fields[] = line.split...
75601142-eda5-4cad-81ae-94b2441f99b2
7
public String reverse1(String str) { char chars[] = str.toCharArray(); int forward = 0; int backward = chars.length - 1; boolean forwardReady = false; boolean backwardReady = false; while (forward < backward) { if (forwardReady && backwardReady) { ...
44dc6a01-ecac-4219-ab09-51ebaeffa004
7
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
40b4b114-49ca-4407-a714-223cfff51665
8
public XMLTable() throws XPathExpressionException, SAXException, IOException, ParserConfigurationException{ FileInputStream file = new FileInputStream(new File(xml)); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); ...
f951bb3b-430b-4a08-b2a5-29fa50bb04b0
8
public static void main(String[] args) { MyGraph g = new MyGraph(); g.addNode(1); g.addNode(999); g.addNode(12); g.addNode(13); g.addNode(2); g.addEdge(1, 999); g.addEdge(12, 999); g.addEdge(999, 2); g.addEdge(999, 999); // introduce cycle g.addEdge(999, 1); if(g.hasNode(999)...
ecc70679-c079-43e2-9aab-ad8110d85f5d
8
public static void main(String[] args) { if (args.length < 2) { System.out.println("Please specify the type of lock (B or C) and test (count or print) as command line arguments."); return; } if (args[0].equals("B")) { Test.set_lock(new LockB(THREADS)); } else if (args[0].equals("C")) { Tes...
c0d72911-a18d-4550-a213-79420d8df235
5
private void preprocessDataThree(){ // Check row and column lengths this.numberOfRows = this.values.length; this.numberOfColumns = this.values[0].length; for(int i=1; i<this.numberOfRows; i++){ if(this.values[i].length!=this.numberOfColumns)throw new IllegalArgumentExcept...
0ab58e28-aaf5-46ae-af1e-a9c627b31c31
3
public void checkForDeath(Tile tile) { if (tile.hasUnit()) { Unit unit = tile.getUnit(); if (unit.getCurrentHealth() <= 0) { getCurrentPlayer().getUnits().remove(unit); if (getCurrentPlayer().getUnits().isEmpty()) { getCurrentPlayer().setDefeated(true); //EXTRA: Change this to check for rout b...
0f72c463-5705-48ad-8975-ddbe6caf7c49
9
public T removeMin() { T response = (T)store[1]; //insert the last entry to the root if heap does not only contains root if(tail!=1){ store[1] = store[tail]; } //nullify the tail node since its copied to the root store[tail] = null...
951cb604-3183-4c99-a6f7-48c6fb8c15d7
7
public static void renderLine(int x, int y, int length, boolean horizontal, boolean doubled) { glEnable(GL_BLEND); bindTexture("/graphics/textures/ui/gui.png"); int height = (doubled) ? 17 : 12; int width = length; int lineLength = (doubled) ? 73 : 74; // if (!horizontal) // { // width = height; //...
307d1349-bd3c-466b-8831-dbbe91cef753
2
public boolean mousedown(Coord c, int button) { if(folded) { return super.mousedown(c, button); } parent.setfocus(this); raise(); if (button == 1) { ui.grabmouse(this); doff = c; } return super.mousedown(c, button); }
95c6d599-4fdd-4800-9960-c171d28d1515
9
public Vector<Integer> outdoorChoices(Room R) { final Vector<Integer> choices=new Vector<Integer>(); if(R==null) return choices; for(int d=Directions.NUM_DIRECTIONS()-1;d>=0;d--) { final Room room=R.getRoomInDir(d); final Exit exit=R.getExitInDir(d); final Exit opExit=R.getReverseExit(d); if((ro...
48875bb4-f602-4793-82c2-7b949190a168
0
public String getLastName() { return lastName; }
936f725d-f4da-40ee-b940-7802b6ac2cbc
7
public final void decorators() throws RecognitionException { try { // Python.g:86:11: ( ( decorator )+ ) // Python.g:86:13: ( decorator )+ { // Python.g:86:13: ( decorator )+ int cnt5=0; loop5: while (true) { int alt5=2; int LA5_0 = input.LA(1); if ( (LA5_0==AT) ) { alt5=1; }...
5db67a2c-7be9-4338-b5b5-c8b1265816ca
6
public static void main(String[] args) { logger.setLevel(Level.SEVERE); ConsoleHandler handler = new ConsoleHandler(); handler.setLevel(Level.SEVERE); logger.addHandler(handler); if (args.length == 0) { logger.warning("Invalid arguments count."); return; ...
e47c56e8-2d9d-4ec7-97b9-496382823f1e
3
private void setButtonsWidthAndHeight() { Dimension newSize = new Dimension(0, 0); Dimension currentSize = new Dimension(0, 0); // Get the size of each button and preserve the widest for (int x = 0; x < keys.length; x++) { currentSize = theButtons[x].getPreferredSize(); if (currentSize.width > newSize.wi...
98463ec5-3100-482e-befa-8808a124bf3d
4
public void update( ArrayList<PhysicObject> objectList, float delta ) { if ( objectList == null ) return; for ( PhysicObject object : objectList ) physics( object, delta ); for ( int i = 0; i < objectList.size(); i++ ) { for ( int j = i + 1; j < objectList.size(); j++ ) intersect( objectList.get( ...
a00b2dfc-3f69-4a0b-b4eb-adc9ceeb878d
8
public static void main(String[] args) { // Initialize notProcessedNodes with all nodes for (int i = 0; i < GRAPH_SIZE; i++) { if (NODE != i) { notProcessedNodes.add(i); } } // Initialize distances with very big values Arrays.fill(distance...
583bc9e8-5272-4a2d-92ed-eebbe6fc94a2
5
public int getLastLightChange(int x, int y) { if(chunkID < 0) { x = 15-x; } if(x < 0 || x >= blocks.length || y < 0 || y >= blocks[0].length) return 0; return lightChanges[x][y]; }
1bf43264-1162-499c-a73a-38420d5d3b2e
2
public void recieveInput(int mouseX, int mouseY){ mouseY = Standards.W_HEIGHT - mouseY; if (isInPanesSelector(mouseX, mouseY)){ if (Mouse.isButtonDown(0)){ Boot.getGUIHandler().changeActivePane(findPane(mouseX, mouseY)); } } }
0370fc70-d89c-4a6b-995e-12aa6538432d
9
public boolean isMatch_2d_method(String s, String p) { int m=s.length(), n=p.length(); boolean[][] dp = new boolean[m+1][n+1]; dp[0][0] = true; for (int i=1; i<=m; i++) { dp[i][0] = false; } // preprocess * for(int j=1; j<=n; j++) { if(p.charAt(j-1)=='*'){ dp[0][j] = true; } else { break;...
42902afc-cc3c-463a-9c2d-61114214e6e5
6
@Override public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case 0: return teachers.get(rowIndex).getIdTeacher(); case 1: return teachers.get(rowIndex).getName(); case 2: return teachers.get(r...
817de1e2-4c31-4174-937b-99e31105ef5f
4
private double testPriorityQueuePoll(int[] inserts) { System.out.println("Testing PriorityQueue with " + inserts.length + " polls"); long[] times = new long[20]; long startTime; long endTime; for (int i = 0; i < 20; i++) { priorityQueue = new PriorityQueue(); ...
68e12935-38cd-4ed9-a833-f93d5e340341
5
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(args.length < 4) { return this.showHelp(sender); } if(Validate.isPlayer(sender)) { UPlayer player = plugin.getPlayerManager().getUPlayer(sender.getName()); ...
c65fb5c5-4ddd-4410-b272-ca687ecaa5c7
6
public static void maxHeaplify(int[] array, int index, int size){ int left, right, temp; int big = index; while(true){ left = 2 * index + 1; right = 2 * index + 2; if(left < size && array[left] > array[index]) big = left; if(right < size && array[right] > array[big]) big = right; if(big == ...
f3023b71-79e0-456d-b19c-5bffcad39fca
2
public Element get(String name) { for(Element e : elements) if(e.getName().equals(name)) return e; return null; }
37f592f3-3ef7-4d49-97ae-ec238257f2bd
2
private Integer createDirection(Criteria criteria, AbstractDao dao) throws DaoException { Integer idDescription = dao.createNewDescription(criteria).get(0); criteria.remuveParam(DAO_ID_DESCRIPTION); criteria.addParam(DAO_ID_DESCRIPTION, idDescription); List<Integer> res = dao.createNewD...
c4f79670-6d74-43a9-93f2-0a88a218c207
1
private double getAngle(Edge edge) { double x1 = edge.getFromNode().getxCoord(); double y1 = edge.getFromNode().getyCoord(); double x2 = edge.getToNode().getxCoord(); double y2 = edge.getToNode().getyCoord(); double xDiff = x2 - x1; double yDiff = y2 - y1; double angle = -Math.atan2(yDiff, xDiff); if ...
c9b378ec-b573-4771-a28f-b696567e40ca
2
@Override public Balance createNewChild(TreeMap<String, String> properties) { Balance balance = new Balance(accounts); balance.setName(properties.get(NAME)); balance.setLeftName(properties.get(Balances.LEFTNAME)); balance.setRightName(properties.get(Balances.RIGHTNAME)); bala...
827e3072-dd8d-48b5-bdeb-db67d988d78c
9
public String activate(Participant p, LifeEventType lifeEventType, HtmlColor backcolor) { if (lastDelay != null) { return "You cannot Activate/Deactivate just after a ..."; } if (lifeEventType == LifeEventType.CREATE) { pendingCreate = new LifeEvent(p, lifeEventType, backcolor); return null; } if (la...
b3072923-bfe1-44a1-8b47-8cc6b8662074
0
public void onMouseClick(int x, int y, int button) { }
f36e57fa-95f8-4348-9287-e76a3948803e
9
public IDResult joinGame (String gameName, String playerName) { try { if(gameName == null) { return new IDResult("illegal game name"); } if((!_gameManager.isGameExists()) || !(_gameManager.isGameSameName(gameName))) ...
35b0edca-dd29-4420-8f77-4f0df36739fd
9
public static int genomeIdFromJsonArray(JSONArray organizedJson, String name){ int len = organizedJson.length(); int i,j,k,l; int id = -1; boolean ok = false; for(i = 0; i < len && !ok; i++) { JSONArray groups = organizedJson.getJSONObject(i).getJSONArray("groups"); int leng = groups.length(); for...
5c3661d9-b0ef-48c3-8de5-1ec8a98922ab
7
static final void method135(boolean flag, String s) { if (Class43.aClass142_Sub17Array730 == null) { return; } if (flag) { return; } int i = 0; long l = NodeCache.nameToLong(s); if (l == 0L) { return; } for (; ~C...
e0a37d8a-4b60-41aa-9d3d-36220f0170f3
3
public void remove(int val) { Node current = head; while (current.next != null) { Node tempNext = current.next; if (tempNext.value == val) { if (tempNext.next == null) current.next = null; else current.next = tempNext.next; return; } } }
2b4b4553-3648-4bcf-96d2-d3e0dc57e98b
5
public void setSourccePreview() { InputStream is; try { BufferedImage src = ImageIO.read(new File(sourcePath)); if (src.getWidth() >= 150 || src.getHeight() >= 150) { BufferedImage prevIMG = new BufferedImage(150, 150, src.getType()); for (int i =...
8a70c560-e532-4cca-a850-aa90fd05ac5f
4
@Override public void open() { switch (this.getState()) { case LIFTCLOSE: this.setState(LiftState.LIFTOPEN); break; case LIFTOPEN: case LIFTRUNNING: case LIFTSTOP: break; } }
072b17f0-7315-4043-96c3-4ead4dfd6a06
1
public PageScraper(URL url, String[] words, String[] args) throws IOException, BadLocationException { HTMLDocument doc = scrap(url); page.setUrl(url.toString()); for (String arg : args) { executeArg(arg, words, doc); } }
37343739-05f3-4fc5-9d58-e025611a40a0
9
public void processWeatherStationConfiguration() throws ConfigurationException { weatherStations.clear(); for (int i = 1; i < Integer.MAX_VALUE; i++) { final String weatherStationValue = "weatherstation" + i; final String weatherStationName = config.getProperty(weatherStationValue + "_name"); ...
8aee796c-415f-4c90-a855-b638a219dae6
4
@Override public void addComponent(Component component, LayoutParameter... layoutParameters) { Set<LayoutParameter> asSet = new HashSet<LayoutParameter>(Arrays.asList(layoutParameters)); if(asSet.contains(MAXIMIZES_HORIZONTALLY) && asSet.contains(GROWS_HORIZONTALLY)) throw new IllegalArg...
e459d8a1-479c-4d9f-9b38-2dcde318f6f5
4
private void performElimination(Instruction i) throws Exception { // if i is dead, but hasn't already been eliminated if(i.isDeadCode() && !i.isDeleted()) { i.delete(deleteFor); for(Value v : i.getArguments()) { v.removeUse(i); // v may now be dead...
d7ed5f7e-9b06-44c7-81e1-5352e9505b97
5
public static final void PetCommand(final SeekableLittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) { final byte petIndex = chr.getPetIndex(slea.readInt()); if (petIndex == -1) { return; } MaplePet pet = chr.getPet(petIndex); slea.skip(5); final byte command = slea.readByte(); final...
d73b81a4-2165-4429-bb49-f87760caa1d2
3
public static void sort (int[] array) { for (int i = 0; i < array.length -1; i++) { for (int j = i + 1; j < array.length; j++) { if (array[i] > array[j]) { array[i] ^= array[j]; array[j] ^= array[i]; array[i] ^= array[j...
cf17f8d8-a4a2-4c74-81f1-f871b6634d76
8
@Override public void updurgency(HWindow wnd, int level) { if ((wnd == awnd) && !folded) level = -1; if (level == -1) { if (wnd.urgent == 0) return; wnd.urgent = 0; } else { if (wnd.urgent >= level) return; ...
5c7fed9a-f6a5-4b1a-9193-a990a8cb3662
4
public void generate(EnumGenerationType paramGenType) { Random genRdm = new Random(); switch (paramGenType) { case coinStruct: genBox.generate(theWorld, new EntityCoin(1), Display.getWidth() + 30, Display.getHeight()); break; case cashStru...
7f16b893-742b-44c2-b02b-e6a3e074f037
6
private BufferedImage[] cutMobSheet() { BufferedImage mobSpriteSheet = null; try { mobSpriteSheet = ImageIO.read(new File( "Images/CondensedOverworldSprites.png")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } BufferedImage spriteSheet = null; try { ...
1ff243ed-a22b-4ddb-972a-ae124239c91f
8
public ComprarJuego2() { initComponents(); setLocationRelativeTo(null); c_perfiles.getEditor().getEditorComponent().addKeyListener(new KeyAdapter(){ @Override public void keyReleased(KeyEvent evt){ String cadenaEscrita=c_perfiles.getEditor()....
5cfef06c-580b-4244-a9fd-16d87f9a509e
6
public Set<Man> spawnMen(int amount, int speed) { int amountPerSquare = (amount / amountOfFloorTiles) < 1 ? 1 : amount / amountOfFloorTiles; Set<Man> men = new HashSet<Man>(); int x = orig_x; int y = orig_y; for(int r = 0; r < tiles.length; r++) { for(int c = 0; c < tiles[r].length; c++) { ...
6eb1c431-4631-486a-ad90-80a466378a71
4
@Override public void deserialize(Buffer buf) { position = buf.readUShort(); if (position < 0 || position > 65535) throw new RuntimeException("Forbidden value on position = " + position + ", it doesn't respect the following condition : position < 0 || position > 65535"); total = ...
78548648-bd90-4695-8aa7-ab745eaf4da4
6
public static <T extends Comparable<T>, E> Node<T,E> search(T value, Node<T,E> node){ if(node == null) return null; if(node.getValue().compareTo(value) < 0 && node.getRightNode() != null){ return search(value, node.getRightNode()); }else if(node.getValue().compareTo(value) > 0 && node.getLeftN...
df66671c-9f5b-4544-aee3-ce3ed6051ac5
8
public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); HashMap<Integer, HashMap<Integer, Integer>> g = new HashMap<Integer, HashMap<Integer, Integer>>(); int[][] dist = new int[n + 1][n + 1]; for (int i = 0; i <= n; i++) { g.put(i, new Ha...
65c92808-3b92-4ce3-a67b-88bd0ba64672
1
public static void main(String[] args) { String key = "QWERTY"; LinkedList<Character> word = new LinkedList<>(); for (int i = 0; i < 3; i++) { word.append(key.charAt(i)); } System.out.println(word.toString()); // Setting up the conditions Node<Character> temp = new Node<Character>(null, null); No...
f216ff88-411d-43ec-a3dd-c7d8089d41e4
6
public String addResourceNode(String resource_id) { String node_id = null; int count = 0; try { while((node_id == null) && (count != retryCount)) { if(count > 0) { //System.out.println("ADDNODE RETRY : regi...
6dec9729-39d3-4782-8e05-ea252c4bff84
3
public ResultSet retry(String query) { // boolean passed = false; Statement statement = null; ResultSet result = null; // while (!passed) { try { statement = connection.createStatement(); result = statement.executeQuery(query); // passed = true; return result; } catch (SQLException ex) { if ...
61b628d2-41ae-4ae0-96fa-6149fce0081d
1
public ArrayList<Network> moleculeArrToNetworkArr(ArrayList<Molecule> molecules){ ArrayList<Network> networks = new ArrayList<Network>(); for(int i=0; i<molecules.size(); i++){ networks.add(retrieve(molecules.get(i))); } return networks; }
6841fbc9-3274-4b2b-97c3-d62ca0c334dc
4
@Override public void insert(int i, int j, double value) { for (Element e : elems) { accessCount += 1; // durchsuchen des elements if (e.getI() == i && e.getJ() == j) { elems.remove(e); break; } } if (Double.compare(value, 0.0) != 0) { // only non zero values need to // be added e...
f3c58049-38c8-4df2-a1a5-437f34c24580
2
public ClassLoader getClassLoader() { URL[] urls = getUrls(); System.out.println(Arrays.toString(urls)); ClassLoader parent = Thread.currentThread().getContextClassLoader(); if (parent == null) { parent = ClassPath.class.getClassLoader(); } if (parent == null)...
ca19cfe2-3a83-4e9c-9027-95a17b9fa659
7
private Dimension computeSize(Container target) { synchronized (target.getTreeLock()) { int hgap = getHgap(); int vgap = getVgap(); int w = target.getWidth(); // Let this behave like a regular FlowLayout (single row) // if the container hasn't ...
a4140674-7bcb-447a-9df3-1acb52b2210a
5
static void tick(int delta) { if (Mouse.isButtonDown(0)) { if (dragging) { // mouseDrag: dragHere = mouseToSphere(); // new ending position quatHere = new Quaternion( dragStart.dot (dragHere), // angle between position vectors dragStart.cross(dragHere) // normal of position vectors...
3049817e-57b2-45da-9289-dfda51833ef0
6
public synchronized void regenerate() { Iterator<Map.Entry<ChunkSQL, ArrayList<LocationSQL>>> it = this.possibleLocations.entrySet().iterator(); HashMap<String, Integer> properties; while(it.hasNext()) { //TODO: Implement HIGHEST_BLOCK Map.Entry<ChunkSQL, ArrayList<LocationSQL>> set = it.next(); //ChunkSQL...
feb5ced5-2baa-4e51-8ccd-9579f8345f01
4
public static float getFloat() { float x = 0.0F; while (true) { String str = readRealString(); if (str == null) { errorMessage("Floating point number not found.", "Real number in the range " + (-Float.MAX_VALUE) + " to " + Float.MAX_VALUE); } ...
d59930f1-d538-4aad-91d8-91af0726c24a
1
public State usingId(Id id) { if (this.id != null) { throw new IllegalStateException("Id already assigned!"); } this.id = id; return this; }
fde2830e-fb17-4471-943b-e986b3911904
7
private void addDetailsToListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addDetailsToListButtonActionPerformed //SYG hardcoded crime. skift snarligt int resTypeID = 0; if (dropDownRes.getSelectedItem().equalsIgnoreCase("Lille Stang")) { resTypeID ...
e38fa28d-cb50-4b0d-8415-04c2be6542b7
6
public boolean getBoolean(String key) throws JSONException { Object object = this.get(key); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String)object).equalsIgnoreCase("false"))) { return false; } else if (object.equals(Boolean.T...
f772cb94-bcb2-4351-bcca-ff1544210f04
7
public static void main(String[] args) throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for (String line; (line = in.readLine())!= null; ) { StringBuilder sb = new StringBuilder(); boolean isCapsLock = true; for (int i = 0; i < line.length() && isCapsLock; i++) {...
b52a778f-b38e-408e-b93c-6ea15cec8262
8
@Test public void test3() { xmlReader.setContentHandler(new DefaultHandler() { List<Book> books = new ArrayList<>(); private String currentQName; private Book currentBook; @Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { cu...
362bf521-3ba3-4f25-a908-8ae9dcd0b274
9
private void splitIntoQuadrants(int startx, int endx, int starty, int endy) { int halfLength = Math.abs(starty - endy) / 2; for (int i = startx + halfLength; i < endx; i++) for (int j = starty + halfLength; j < endy; j++) board[i][j] += "4"; for (int i = startx + ha...
04a00eb4-d6b0-488c-94de-137ef566e53b
0
@Override public String getName() { return this.name; }
60292f3d-8ae3-440f-9fb6-8cf530380db1
8
public final List<Double> generateValueAxisMarkPositions(double minData, double maxData, int segmentsNumber) { List<Double> result = new ArrayList<Double>(); double step = calculateValueAxisStepInDataScale(minData, maxData); double dataDistance = getDataDistance(maxData, minData); double...
f6d15edf-457d-4dff-b7c8-98354b8b6195
9
public static boolean portAvailable(int port) { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(port); serverSocket.setReuseAddress(true); } catch(IOException e) { // do nothing return false; } finally { if (null != serverSocket && !serverSocket.isClosed()) { try { ...
81390823-ac90-4eab-aa08-235be678eb19
9
public static void main(String[] args) { //comment out one of the next two lines depending on whether environmental variables or a credentials file is being used // AmazonEC2 ec2 = new AmazonEC2Client(new BasicAWSCredentials(System.getenv("AWS_ACCESS_KEY"), System.getenv("AWS_SECRET_KEY"))); AmazonEC2 ec2 = new A...
8fa86c28-720d-4b39-ad28-269fb89d1cdd
7
private Connect parseConnect ( ) { Connect connect = new Connect(); boolean isAfterConnect = false; for(int i = 0; i < container.length; i++) { if ("connect".equals ( container[i] )) { isAfterConnect = true; continue; ...
057b6f1e-445f-484e-a717-83df65697b86
1
public List findAll() { log.debug("finding all Problem instances"); try { String queryString = "from Problem"; Query queryObject = getSession().createQuery(queryString); return queryObject.list(); } catch (RuntimeException re) { log.error("find all failed", re); throw re; } }
2da48723-47e8-4cc2-af6b-33ea00b76e6e
7
public static boolean checkDate(String date){ // M M / D D / Y Y Y Y - H H : M M : S S // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 if (date.length() != 19){ return false; } if (date.charAt(2) != '/'){ return false; } if (date.charAt(5) != '/'){ return false; } if ...
ad4fbc98-cc91-4bd2-826a-6b5d1e3a5bf7
5
@Override public Ticket in(Car car, List<Park> parkList) { int no = -1; double num = -1d; for(int i = 0; i < parkList.size(); i ++) { Park park = parkList.get(i); if(park.isFull()) { continue; } double _rate = Math.round((float)park.getEmptyNu...
52b26ecc-83f2-44cb-a8bd-d02e1ce884c9
4
public void ecriturePGM(String nomFichier){ try{ String fichier = nomFichier+".pgm"; String test = ""; BufferedWriter file = new BufferedWriter(new FileWriter(fichier)); file.write("P2"); file.newLine(); file.write("#")...
2350dba3-de5d-464b-bd19-075a3092ff0f
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HtmlCommentToken other = (HtmlCommentToken) obj; if (COMMENT == null) { if (other.COMMENT != null) return false; } else if (!COMMENT.equ...
41196a41-8ba8-4c2a-8689-a18c9385cbc4
5
public void run(){ while(true){ this.cal = new GregorianCalendar(); stunde = cal.get(Calendar.HOUR_OF_DAY); minute = cal.get(Calendar.MINUTE); sekunde = cal.get(Calendar.SECOND); if (stunde < 10){ zeit="0"+stunde+":"; } else{ zeit=""+stunde+":"; } ...
4d218308-991f-49bb-978f-76b9d1746634
0
public ArrayList viewCheckout() { ArrayList al = new ArrayList(); al = shsmb.viewMyBookingCheckout(); return al; }
71f1da7e-8b9e-44f4-abf5-7bf603eeaae4
8
public boolean isTransition(String ref, String alt) { if (ref.equals("A") && alt.equals("G")) return true; if (ref.equals("G") && alt.equals("A")) return true; if (ref.equals("C") && alt.equals("T")) return true; if (ref.equals("T") && alt.equals("C")) return true; return false; }
181c5e68-4541-4fb7-a084-cc897d6e7bdf
5
@Override public Object getParam(String name) { String sname = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); try { Method m = getClass().getMethod(sname); return m.invoke(this); } catch (NoSuchMethodException e) { return null;...
120a0414-69e9-4983-af12-f20d2f2bed1a
6
public ArrayList<ArrayList> allMovesDefending(){ ArrayList<ArrayList> a=new ArrayList<ArrayList>(); for(int i=0;i<pMovesDefending().size();i++){ a.add(pMovesDefending().get(i)); } for(int i=0;i<nMovesDefending().size();i++){ a.add(nMovesDefending().get(i)); } for(int i=0;i<bMovesDefending().size();i++...
10aace31-7746-4ce0-a421-6e9f5299be85
4
private void drawInterface(Graphics g) { // Draw a basic 10 X 20 grid for (int i = 0; i < 10; i++) for (int j = 0; j < 20; j++) g.drawRect(i*32, j*32, 32, 32); g.drawString("Next piece:", 383, 16); g.setColor(Color.BLACK); g.drawRect(343, 32, 128, 128); for (int i = 0; i < 4; i++) for (int j = 0;...
22cf9a76-554c-458c-8595-68580d61300b
7
static void dradf2(int ido, int l1, float[] cc, float[] ch, float[] wa1, int index){ int i, k; float ti2, tr2; int t0, t1, t2, t3, t4, t5, t6; t1=0; t0=(t2=l1*ido); t3=ido<<1; for(k=0; k<l1; k++){ ch[t1<<1]=cc[t1]+cc[t2]; ch[(t1<<1)+t3-1]=cc[t1]-cc[t2]; t1+=ido; ...
55c058fc-e000-47ad-bab3-4d6cec3889dd
6
private void startElement(XMLStreamReader reader) throws DAOException { switch (reader.getLocalName()) { case TagConstants.ARTIFICIAL_FLOWER_TAG: int id = getID(reader.getAttributeValue(null, TagConstants.ID_ATTRIBUTE)); currentFlower = new ArtificialFlower(id); ...
da44a214-1112-4757-a4d6-f825743d4bc5
8
public static boolean writeUserSelectedFile() { if (fileDialog == null) fileDialog = new JFileChooser(); fileDialog.setDialogTitle("Select File for Output"); File selectedFile; while (true) { int option = fileDialog.showSaveDialog(null); if (option != JFileChooser.APPR...
c7d38c20-dc57-402d-9f64-a44995febd3c
9
public void invert(int invDir){ int lown = -1; int highn = -1; for(int i=0; i < highnote-lownote+1; i++){ if(keyon[i] == true){ lown = i; break; } } if(lown >= 0){ for(int i=highnote-lownote; i>lown; i--){ if(keyon[i] == true){ highn = i; break; } } } if(highn >= 0){ ...
d9f5c4a2-eb0e-44ac-8706-cd0bffa2ad93
8
public static void main(String[] arg) { Socket capture = null; InputStream is = null; OutputStream os = null; try { capture = new Socket("www.baidu.com", 80); os = capture.getOutputStream(); String commandStr = "GET / HTTP/1.0"; String ente...
61d90fe7-e345-4dc6-becc-a7d71c290916
8
@Override public void caseAAvalieExpLogicaDefinicaoComando(AAvalieExpLogicaDefinicaoComando node) { inAAvalieExpLogicaDefinicaoComando(node); if(node.getPontoVirgula() != null) { node.getPontoVirgula().apply(this); } if(node.getFimAvalie() != null) { ...
b0195046-efcd-4af9-89c1-2b7ef51904a7
7
public Socket connect(String host, int port) throws ProxyConnectionException { setPrimaryConnectionPort(port); InetSocketAddress isa = null; try { isa = new InetSocketAddress(InetAddress.getByName(host), port); } catch (IOException ioe) { throw new P...