method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
4012b41b-5fcd-4cd3-a849-2b54369d4576
4
private void drawGrid(Graphics g){ for(int i=scale.getOriginY(); i<=500; i+=scale.getScale()){ g.drawLine(0, i, 500, i); } for(int i=scale.getOriginY(); i>=0; i-=scale.getScale()){ g.drawLine(0, i, 500, i); } for(int i=scale.getOriginX(); i<=500; i+=s...
7a913157-e433-4aba-a71f-845242de45bd
2
public static double limit(final double min, final double value, final double max) { return value > max ? max : value < min ? min : value; }
c838fa7d-a180-46e4-83cb-ad7b324180d4
7
public void deathAni() { switch (aniNum) { case 0: sprt = imgD1.getImage(); if(Game.tickCount2 == game.DELAY){ aniNum = 1; } break; case 1: sprt = imgD2.getImage(); if(Game.tickCount2 == game.DELAY){ aniNum = 2; } break; case 2: sprt = imgD5.getImage(); if...
4565b7c7-7c88-42c7-b4ce-1920da38b53b
6
public void run() { long beforeTime, afterTime, timeDiff, sleepTime; long overSleepTime = 0L, excess = 0L; int noDelays = 0; beforeTime = System.currentTimeMillis(); running = true; while (running) { gameUpdate(); // actualizar los elementos del juego gameRender(); // pintar los elementos a u...
0810faf7-ddc5-47ac-a1d9-298d6e34485a
9
public void buyFarm(){ if(Gold<10) { MF.writeNarra("You don't have enough gold!"); return; } if(MF.M.grid[NS-1][EW]<4) MF.M.setBlock(NS-1,EW,4); else if(MF.M.grid[NS+1][EW]<4) MF.M.setBlock(NS+1,EW,4); else if(MF.M.grid[NS][EW-1]<4) MF.M.setBlock(NS...
dde5a6d2-bdfe-4bac-8784-c5a3d063cae1
7
@Override public Object getValueAt(int rowIndex, int columnIndex) { if (columnIndex < 0 || columnIndex >= COL_NAMES.length || rowIndex < 0 || rowIndex >= list.size()) { return null; } if (columnIndex == 0) { return list.get(rowIndex).getType(); } if (columnIndex == 1) { return list.get(rowInd...
fd2d367e-00fc-4040-99d3-072900536689
7
public void addTransition(Transition trans) { if (!getTransitionClass().isInstance(trans) || trans == null) { throw (new IncompatibleTransitionException()); } if (transitions.contains(trans)) return; if(trans.getToState() == null || trans.getFromState() == null) return; transitions.add(trans); ...
8380ab3e-3872-4b72-9e4c-84e6734e558a
4
public static void main(String args[]) { try { // BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); BufferedReader in; if (args.length > 0) { in = new BufferedReader(new FileReader(args[0])); } else { in = new BufferedReader(new InputStreamReader(System.in)); } StringT...
22ca9bab-ceed-429f-8256-ed98fa040ac9
2
public void initProperties() { File dir = new File(Main.SETTINGS_DIRECTORY); File file = new File(Main.USER_PROPS); FileInputStream stream; if (!dir.exists()) dir.mkdir(); try { FileOutputStream fos = new FileOutputStream(new File( Main.USER_PROPS)); props.setProperty("X", "400"); props.se...
31d0b24f-4eda-47b8-ac56-c55cd86c93fb
2
public static ArrayList<String>[] createList() { ArrayList[] strListArray = new ArrayList[10]; for (int i = 0; i < 10; i++) { strListArray[i] = new ArrayList<String>( ); for ( int j = 0; j < 10; j++ ) { strListArray[i].add( i + " - " + j )...
eea7fb68-488d-476a-b6d1-dc81198bb96e
0
public static CoffeeMakerAPI get() { return globalCoffeeMaker; }
29c9630e-c1f6-4a66-bab2-eb49279a4d9f
9
protected void appendHandle(final Handle h) { buf.append('\n').append(tab3); int tag = h.getTag(); buf.append("// handle kind 0x").append(Integer.toHexString(tag)) .append(" : "); switch (tag) { case Opcodes.H_GETFIELD: buf.append("GETFIELD"); ...
8770c048-be75-4408-9867-4e0cbb8b7683
4
public boolean has_out() { // If one part of the message was already written we can definitely // write the rest of the message. if (more) return true; while (active > 0) { // Check whether a pipe has room for another message. if (pipes.get(curren...
4d34b339-87b9-4771-8445-ceb8a0c9e0e3
4
public JSONObject toJSONObject(JSONArray names) throws JSONException { if (names == null || names.length() == 0 || this.length() == 0) { return null; } JSONObject jo = new JSONObject(); for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this....
d187913c-3759-4757-89e1-b64241493447
3
public static void run() { while (running) { try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } // repaint calls update pane.repaint(); if(Ecosystem.getBlue().size() + Ecosystem.getRed().size() +Ecosystem.getYellow().size() +Ecosyst...
e1ee8d9c-baea-47e4-a451-e42ad5122cb6
3
private void assertRowPopulation(int row, boolean populated) { for (Cell cell : testee.getBoardCells()) { if (cell.row == row) assertTrue("row " + row + " not populated: " + populatedCells(), populated ? cell.isPopulated() : !cell.isPopulated()); } }
3ba8e05e-c2bd-491f-89a8-d9d9e7a241cf
5
public Iterable<String> processInput(String input, boolean skipHeader) throws IOException { final BufferedReader br = new BufferedReader(new FileReader(input)); if (skipHeader) { br.readLine(); } return new Iterable<String>() { @Override public Itera...
180f3f08-9d45-4ad2-8d69-7746855016eb
2
public void visitSCStmt(final SCStmt stmt) { if (stmt.array == from) { stmt.array = (Expr) to; ((Expr) to).setParent(stmt); } else if (stmt.index == from) { stmt.index = (Expr) to; ((Expr) to).setParent(stmt); } else { stmt.visitChildren(this); } }
669aae3c-3400-4bd3-9ac3-0f49bf2f129c
3
public List<Location> getLocationList() { List<Location> a = new ArrayList<Location>(); Location b; for (int i = 0; i < 999999; i++) { b = fcw.getLocation(field + "." + i); if (b != null) a.add(b); else { breakCounter++; if (breakCounter > BREAK_COUNTER_LIMIT) return a;...
7fb5dc05-ee15-43f4-80a0-f7d272e08806
2
public void redo(){ // EDebug.print("I am mucking with that data structure."); if (myBackDeck.size() == 0) return; // EDebug.print("Back deck is not empty."); // myDeck.push((Automaton)myMaster.clone()); //push on head if (myMaster instanceof TuringMachine) TuringMachi...
22ba2021-2af3-4c26-88d6-22dde64c35f3
6
buttonHoverEffect(final JPanel k, final String name) { super(); this.setText(name); this.setName(name); final Color z = this.getForeground(); this.setMaximumSize(new Dimension(200, 100)); this.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR)); this.setOpaque(false); this.addMouseListener(new...
70b85c5e-eb15-45c5-870f-8a10f9f481ab
2
public void sendDeadline(){ JSONObject o = new JSONObject(); try { o.put("message", "endturn"); sendMessage(o); } catch (JSONException e){} catch (IOException e){ Debug.error("Error writing to '" + username + "': " + e.getMessage()); } }
2bb06464-2ba1-4b39-b93b-bf173df974be
6
public void addWeapon(Weapon weapon) { this.weapon = weapon; if (weapon instanceof RangedWeapon && !(weapon instanceof Magic)) { if (!rangedStore.contains(weapon)) { this.rangedStore.add((RangedWeapon) weapon); return; } } else if (weapon instanceof Magic) { if (!magicStore.contains(weapon)) { ...
3fa998ca-dcd1-4e84-99aa-d8879067a762
9
private void finishText() { if (currentText != null) { String strValue = currentText.toString(); if (currentTextObject != null) { if (DefaultXmlNames.ELEMENT_Unicode.equals(insideElement)) { currentTextObject.setText(strValue); } else if (DefaultXmlNames.ELEMENT_PlainText.equals(insideElem...
b5fbaed6-e506-4760-ba06-64dd16bcd515
2
public void testPropertySetMinute() { TimeOfDay test = new TimeOfDay(10, 20, 30, 40); TimeOfDay copy = test.minuteOfHour().setCopy(12); check(test, 10, 20, 30, 40); check(copy, 10, 12, 30, 40); try { test.minuteOfHour().setCopy(60); fail(); ...
af9db9d1-0b99-4001-a881-d4d52791c73e
6
private boolean validMove(Move move) { if(completedMoves.contains(move)){ return false; } boolean noMoveAtIndex = false; boolean indexesAreOk = move.getRow() >= 0 || move.getRow() < getRowSize(); indexesAreOk = indexesAreOk && move.getColumn() >= 0 || move.getColumn() < getColumnSiz...
34578755-3f7c-4779-a16d-122c65154c4d
3
public int getPlacesForDiningSchedule(Calendar cal, DiningHall dh) { Iterator<Booking> iter; iter = bookings.iterator(); int places = 0; while (iter.hasNext()) { Booking booking = iter.next(); if ((booking.getDate().compareTo(cal) == 0) && (booking.getDiningHall().equals(dh))) { places++; } ...
c2ee21b7-9055-4cb1-a03e-c2fcf6e5168d
7
public static byte[] objToBytes(Object o) { if (o instanceof String) { String str = (String) o; return str.getBytes(); } else if (o instanceof Long) { Long l = (Long) o; return l.toString().getBytes(); } else if (o instanceof Integer) { Integer l = (Integer) o; return l.toStr...
2c22b273-4e53-4610-bab2-a3175ee5f427
4
Font lookupFont(char text[], int start, int limit, int style) { /* Try using an already known base font; the first font in usedFonts list is the one set with setDefaultFont() */ Iterator<Font> iterator = usedFonts.iterator(); while (iterator.hasNext()) { /* Only use the font if it ca...
90506c7a-c80e-443e-91b9-348e1aad86c2
7
public void init(List<CubePiece> cubePieceList) { if(cubePieceList.size() != 6) throw new IllegalArgumentException("A cube has to have 6 faces"); // Init map for each cube piece // In other words each piece knows which other piece they fit into cubePieces = cubePieceList...
eb809c98-68d8-4773-b040-7ac82d56c49c
8
public static int getNumOfQuadrangles(GraphModel graph) { int quadrangles = 0; for (Vertex i : graph) for (Vertex j : AlgorithmUtils.getNeighbors(graph, i)) for (Vertex k : AlgorithmUtils.getNeighbors(graph, j)) for (Vertex l : AlgorithmUtils.getNeighbors(...
a5286bb9-9be8-429b-97d7-e964fd9a2343
5
private List<String> getSublist(String[] args, boolean server, org.bukkit.command.Command cmd) { List<String> list = new ArrayList<String>(); String[] argC = args.clone(); List<Command> subs = manager.matchCommands(cmd.getName(), server); List<String> direct; for(int i = args.length; i > -1; i--){ direct =...
9d82b82d-4444-41b9-bff4-d4556f3a242c
9
static void exportPage(StorageImpl db, XMLExporter exporter, int pageId, int type, int height) throws java.io.IOException { Page pg = db.getPage(pageId); try { int i, n = getnItems(pg); if (--height != 0) { if (type == ClassDescriptor.tpString || type =...
e25e561e-5881-444f-8560-d9b42302c91b
1
public synchronized void start() { if (running) return; running = true; thread = new Thread(this); thread.start(); }
dbf1f915-bf1f-42cc-9092-6cb49d9b0fdc
0
public static void main(String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Service1 s = new Service1(); // メソッド名と引数の型を指定してMethodを取得。 Method m = s.getClass().getDeclaredMethod("doIt", String.class); // メソッド呼び出し @...
ae6c3ef2-eac3-44bf-9741-05e2e928d877
5
private void initComponents() { formatLabel = new JLabel("How should your track info be displayed:"); formatArea = new JTextArea(config.getFormat()); formatLighter = new DefaultHighlighter(); // TODO allow configuration of this color formatPainter = new DefaultHighlighter.DefaultHighlightPainter(new Color(200...
fc5dbe4a-815c-4909-b716-5cc3547fde18
0
@XmlTransient public Collection<Entradas> getEntradasCollection() { return entradasCollection; }
2585e40a-ff7f-438c-8e37-da4780b26d24
9
public static void decode(Question decodedQuestion, String encodedQuestion) throws DecodeException { if (encodedQuestion.charAt(0) == '<') { int i = 1; while (encodedQuestion.charAt(i) != '>') { i++; } if (i > 1) { decodedQuestion.s...
1542fb60-8652-4914-ba20-dda150258ea8
7
private void setChoices(String csvFile){ BufferedReader CSVFile; try { InputStream is = this.getClass().getResourceAsStream(csvFile); CSVFile = new BufferedReader(new InputStreamReader(is)); String dataRow = CSVFile.readLine(); dataRow = CSVFile.readLine(); int key; String choiceStr; int effec...
1c887197-1184-4700-80cf-4d43f2e02210
2
@Override protected void paintComponent(Graphics gc) { super.paintComponent(gc); if (mHint != null && getText().length() == 0) { Rectangle bounds = getBounds(); bounds.x = 0; bounds.y = 0; gc.setColor(Color.GRAY); TextDrawing.draw(gc, bounds, mHint, SwingConstants.CENTER, SwingConstants.CENTER); }...
74e9bf03-920a-4297-bcd3-f4770a0c1587
7
private void receive(Buffer buf) { int cursor; int lastBufLength = lastRxBuf.length(); //keep processing packet header/body as long as we have enough bytes to read it in full for (cursor = 0; cursor - lastBufLength + rxLen <= buf.length(); ) { byte[] message; if (cursor - lastBufLength >= 0) { //last...
e6f90a89-8649-4c92-a375-2917cb6b9507
5
public JPanel createPanelSignup(String email, String password) { //Some settings int nb = 3; String labelcolor = "#E43B01"; //Create panel JPanel pan = new JPanel(); BmgLabel label = new BmgLabel("Veuillez renseigner les informations suivantes afin de créer votre compte...
3e358ded-e5b0-40b3-a31b-055ef46969db
1
public StageManager(GamePanel gamePanel, int startStage) { this.gamePanel = gamePanel; setStatge(startStage, null); try { loadingScreen = ImageIO.read(getClass().getResourceAsStream("/graphics/loading/DummyLoading.png")); } catch (IOException e) { e.printStackTrace(); } SoundManager.init("GameData/sou...
49240823-2a0e-4281-8cbe-9596aa81ad79
4
@Override public void paint(Graphics g1) { Graphics2D g = (Graphics2D) g1; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Rectangle[] rects = buildHeaders(); g.setColor(TEXT_COLOR); String topLine = Script.getName() + " by Strikeskids"; String botLine = (Universal....
65282dbe-d582-43f5-9e36-31979c3997cd
6
@Override public void update() { for (TimerTask task : new ArrayList<TimerTask>(tasks)) { if (task.getElapsed() < 0) { cancel(task); } else { task.elapse(); if (task.getPeriod() <= 0 && task.getElapsed() == task.getDelay()) { ...
f324cbb3-d6d3-432b-9d45-3228be37030e
0
public void setNombre(String nombre) { this.nombre = nombre; }
3d884df7-542d-46b8-b468-2d6d2380de15
1
public void addSmartSeconds() { if (secondsRemaining > 10) secondsRemaining += 2; else secondsRemaining += 3; g.getForm().setTimerTime("Seconds left: " + String.valueOf(secondsRemaining)); }
59614180-69d1-49d5-978f-e06f02ef93a7
9
public static int[] dijsktra(int[][] weight, int start) { int n = weight.length; String[] path = new String[n]; // From Start to others' path int[] shortPaht = new int[n]; // From Start to others' short path length boolean[] isVisted = new boolean[n]; for (int i = 0; i < path.length; i++) { path[i] = new ...
ab036b9d-aa4b-46f0-a485-9b2674240d25
2
public PreparedStatement getPreparedStatement(final String sql) throws SQLException { // Thread.dumpStack(); if (operationMode == mode.DEVELOPMENT && showQuery) System.err.println("Qu: " + sql); // Create the statement PreparedStatement ps = locDB.prepareStatement(sql); return...
31f4bba9-8e93-4501-a1ca-978469fc25a5
3
public void printCds() { // Alle CDs ausgeben (alle Datensätze außer null-Datensätze) int i = 0; for (String[] cd: this.cds) { if (cd[0] != null && cd[1] != null) System.out.printf("%3d %25s %25s\n", i, cd[0], cd[1]); i++; } System.out.println(); }
177ee95b-2ba5-4fe6-b1ef-0de37f64a5d5
9
public void run(){ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); try{ String textQuery = in.readLine(); while( !textQuery.equals("exit") ){ QueryResult result; if( textQuery.contains("!") || textQuery.contains("AND") || textQuery.contains("OR") ){ ...
90449beb-57ea-4dd3-bd1e-5dcc463821f2
4
public boolean isOnBorder(int x, int y) { if(x == 0 || y == 0 || x == (getXSize() - 1) || y == (getYSize() - 1)) { return true; } return false; }
f623a465-7da4-487b-91ec-af4f05a61949
7
public void updateGUIBasedOnNumOfCells(int numOfCells) { if(numOfCells < 8) { this.jSpinner9.setVisible(false); this.jSpinner17.setVisible(false); this.jLabel9.setVisible(false); }else { this.jSpinner9.setVisible(true); this...
a0851ec3-d4da-4c4b-9d45-674ef559a36e
5
private void insertarDatos() { principal.mes[principal.mesActual].setIrpf(IRPF); principal.mes[principal.mesActual].setcComunes(dCcomunes); principal.mes[principal.mesActual].setTotalDevengado(tDevengado); principal.mes[principal.mesActual].setTotalDeducir(tDeducir); principal.me...
424efc21-3faf-4c39-aa0d-0c70c1da1eee
1
public void toggle() { if(this.open){ this.closeConsole(); } else { this.openConsole(); } }
30d85696-5c01-4b16-86bc-511cbb77e5e7
6
@Override public Point2D calculatePosition(Point2D pos, double speed) { if (isBackWard) { } PathIterator p = fCurve.getPathIterator(null); FlatteningPathIterator f = new FlatteningPathIterator(p, reduceCarSpeed(speed)); while (!f.isDone()) { float[] pts = new float[6]; switch (f.currentSegment(pt...
555db42c-44f2-4d85-bcb2-07e79e215f7c
5
public void render(Graphics g) { // increment during a second to calculate FPS this.frames++; // set font g.setFont(Resources.normalFont); // if we are in game if (!Param.isTitleScreen() && !Param.isEndScreen()) { g.setColor(Resources.levelColor[world.getID()][0]); g.fillRect(0, 0, dimension.wid...
e4bc65ed-256d-41a7-9489-38bc86badd5b
5
public void createSimulationFile(int gpioNum, String path) { if (gpioNum <= maxGpioPins) { for (int i = 0; i <= maxGpioPins - 1; i++) { //Create the Gpio "Pins" (the Pins are only dirs like under linux) File gpioPin = new File(path + "/gpio" + i); i...
e967b018-3d0f-42a7-b4eb-45ce1637f4a6
4
@Override public List<CategoriaDespesa> readByCriteria(Map<String, Object> criteria, Connection conn) throws Exception { List<CategoriaDespesa> lista = new ArrayList<CategoriaDespesa>(); String sql = "SELECT * from ccategoria_despesa WHERE 1=1"; //criterio por nome String criterionN...
2ede1153-f387-4b6c-aaed-d9efa4cf756e
8
public static boolean[] getNextCombination(boolean current[]) { /*Example: series of executions: * 11000 10100 10010 10001 01100 01010 01001 00110 00101 00011 */ //we know that we are going to readjust at least 1 element: int numToReadjust = 1; boolean foundSpaceToFill = fal...
302818f4-8739-4912-bb22-652058d52782
4
@Override public boolean equals(Object obj) { if (obj == null || getClass() != obj.getClass()) return false; final Number other = (Number) obj; if (this.numerator != other.numerator) return false; if (this.denominator != other.denominator) return false; ...
99e228d3-9339-45ca-a328-73fa9191352e
7
private void process_status(Request req, Response res) throws Exception { Parameters params = req.getParameters(); if (params == null) { process_error(TYPESYNTAX, SMESPAR, res); return; } String jvmRoute = null; String load = null; Enumeration<String> names = params.getParameterNames(); while (names...
bc3190fa-6bbb-4d0c-afa7-341404bac510
5
private static boolean[] primeBoolArray(int limit) { boolean[] nums = new boolean[limit]; for (int i = 2; i < nums.length; i++) nums[i] = true; int nextPrime = 2; while (nextPrime < nums.length / 2) { int i = nextPrime; for (; i < nums.length; i += nextPrime) nums[i] = false; nums[nextPrime] = t...
a01e007f-6ff0-47e6-9c87-2fa5e35f6549
8
public void setParameter(String paramname, int a){ if(paramname == "Mat"){ mat = a;} if(paramname == "MirrX"){hoodx = a; if(mirror){setLocation(hoodx, hoody);}} if(paramname == "MirrY"){hoody = a;if(mirror){setLocation(hoodx, hoody);}} if(paramname == "InMode"){inmode = a; if(a == 2){ages = false; fades = f...
798618fd-f9ef-4b61-910f-53c268f4b75d
4
@Test public void testHistorgram() { final short[][] image = new short[10][10]; assertEquals(100, problems2.histogram(image)[0]); for (short i = 0; i < image.length; i++) { for (short j = 0; j < image[0].length; j++) { image[i][j] = (short) (i * image[0].length +...
b08cbf41-c650-4d5a-8b58-6fbef4f87ad5
4
public Boolean Parse(Document doc) { try { Element docElement=doc.getDocumentElement(); NodeList nList= docElement.getElementsByTagName("API"); if(nList!=null && nList.getLength()>0) { for(int index=0;index<nList.getLength();index++) { API apiInfo=GetApiInfo(nList.item(index)); ap...
022d46dd-2e61-48bc-9f2d-657b0ab3c103
5
public SmashClientHost(Socket socket, SmashServer instance){ this.setSocket(socket); client = this; server = instance; try { out = new DataOutputStream(socket.getOutputStream()); in = new DataInputStream(socket.getInputStream()); bufferSize = socket.getReceiveBufferSize(); } catch (IOException e) { ...
c9917bf0-7bd1-4a0d-8e03-f2013c3e7378
7
public List<Member> getFieldsToDisplay() { if (blocDisplayProxy != null) { return blocDisplayProxy.getFieldsToDisplay(); } final List<Member> result = new ArrayList<Member>(); for (String s : rawBody) { if (isMethod(s) == true) { continue; } if (s.length() == 0 && result.size() == 0) { conti...
c2183fa7-eccb-45b4-9046-e8f25d17bc88
6
public static void main(String[] args) { World w = new World(); // create some deer int numDeer = 20; for (int i = 0; i < numDeer; i++) { new Deer(w); } // create some wolves int numWolves = 5; for (int i = 0; i < numWolves; i++) { new Wolf(w); } ...
7cce915c-68f4-4698-8dba-e09162929435
4
private double getDegrees(RaceTrack track) { this.tangent = track.getTangent(time%1); double degrees = acos(this.tangent.normalized().dot(Robot.normal)); degrees = toDegrees(degrees+PI); for(;degrees < 0;)degrees += 360; degrees %= 360; if(time%1 < 0.25 || time%1 > 0....
aeb314a4-3c68-4c52-aca2-54d7bda42b45
0
public BooleanValidator() {}
3e98cdb1-2525-423f-9aa7-f3441d4dbf96
6
public void LoadData() { //name of csv files with data // exported by hand from static data dump String BlueprintCSV = "blueprints.csv"; String MaterialCSV = "materials.csv"; // place where csv are String folder = "data/"; // material vector List<Material...
e1f2f675-df1d-4254-bcc1-2e6debab66a5
9
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { directionCode=-1; String where=CMParms.combine(commands,0); if(!where.equals("NOWHERE")) { if(where.length()==0) { final Vector<Integer> directions=new Vector<Integer>(); for(int d...
96518bd9-3e56-42e0-9110-7f4021b0b0b5
2
public static Receipt getByNumber(final String token, final Long number) { JSONArray fetchByNumber = null; try { fetchByNumber = fetchByNumber(token, object, number); } catch (IOException e) { e.printStackTrace(); } List<Receipt> formatOutputs = formatOutputs(fetchByNumber); if (formatOutputs.size() >...
838ed343-5fee-4e9e-95e3-82411c3f2bdb
3
public List<Book> getBookListFromData(String bookRecordString){ ArrayList<Book> books= new ArrayList<Book>(); //Create an array of Strings for each record. This is done by splitting the //bookRecordString by "/n" as each record is in a new line String[] recordArray = bookRecordString.split("\n"); /...
8a9a2e6e-7449-46ef-9641-0a152921b2d8
6
protected double merge(Polygon p1, Polygon p2) { double x = 0; double y = 0; double total = 0; Polyline upper = p1.lowerHead; Polyline lower = p2.upperHead; while (lower != null && upper != null) { double d = offset(x, y, lower.dx, lower.dy, upper.dx, upper.dy); y += d; total += d; if (x +...
edfde343-c7db-427f-b86c-fadc376cd109
0
private void setupItems() { String sql = "SELECT * FROM Suppliers ORDER BY SupplierCode"; List<Suppliers> items = getPersist().readList(Suppliers.class, sql); setItems(FXCollections.observableArrayList(items)); }
634528a0-d3c3-454c-af2e-8a47b66d9c5d
7
public void dragEnter(DropTargetEvent event) { if (event.detail == DND.DROP_DEFAULT) { if ((event.operations & DND.DROP_COPY) != 0) { event.detail = DND.DROP_COPY; } else if ((event.operations & DND.DROP_MOVE) != 0) { event.detail = DND.DROP_MOVE; } else { event.detail = DND.DROP_NONE; ...
16894b32-a33e-4383-a5ad-26e48683f11c
9
@Override public Card PlayAHand(Card topCard, Deck d) { log.entering("Play a hand", name); boolean done = false; boolean tried = false; int pos = 0; Card toPlay = null; log.fine("Trying to decide"); int state = Decide(topCard); if (state == 1...
02a61a13-318e-4e76-9961-177521a45241
5
private static void initialiseItems(Items items){ for (Shoes s : items.getShoes()) { s.getItemset().calcBonus(); s.calcBonus(); } for (Pants s : items.getPants()) { s.getItemset().calcBonus(); s.calcBonus(); } for (Gloves s : items.getGloves()) { s.getItemset().calcBonus(); s.calcBonus(); ...
f587d95f-e8d0-4475-9cde-7d7cd8851e06
0
public static void main( String[] args ) { System.out.println( "Hello World!" ); }
5ecef3e6-beda-4c09-ae49-5bf1c0ffd24d
6
public TileColor getFace(Side side) { if (side.equals(Side.front)) return frontFace; else if (side.equals(Side.back)) return frontFace.getOpposite(); else if (side.equals(Side.up)) return topFace; else if (side.equals(Side.down)) return topFace.getOpposite(); else if (side.equals(Side.left)) re...
9b76d022-f0b9-47a2-bf70-fd6e69ebd260
4
static Object getRegisteredObject (Connection connection, int objectID) { ObjectSpace[] instances = ObjectSpace.instances; for (int i = 0, n = instances.length; i < n; i++) { ObjectSpace objectSpace = instances[i]; // Check if the connection is in this ObjectSpace. Connection[] connections = objectSpace.co...
8a74d1e0-6eca-49ee-baaf-244b23518140
8
public boolean intersects(final S1Interval y) { if (isEmpty() || y.isEmpty()) { return false; } if (isInverted()) { // Every non-empty inverted interval contains Pi. return y.isInverted() || y.lo() <= hi() || y.hi() >= lo(); } else { if (y.isInverted()) { return y.lo() <=...
e802e46b-965a-46cf-8af1-b7446bb27d89
6
public void updateShares() { this.makeCategoryDirs(); for (Server server : servers.values()) { if(!server.isEnabled()) { continue; } try { server.refreshFiles(); server.saveChanges(); server.log("Saved " + server.toUpdate.size() + " changes."); } catch (Throwable t) { t.printStackTr...
17b42f15-0dcd-4cc2-8ea0-db0c44d31d3c
9
@GET @Path("/{repoName}/{fileName}") @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response getFile( @PathParam("repoName") String repoName, @PathParam("fileName") String fileName, @Context HttpServletRequest request) { if (StringUtils.isEmpty(rep...
5379ac53-4221-4151-8694-eacd1c9d0d95
0
private void initialize() { setLayout(new BorderLayout()); JScrollPane scroll = new JScrollPane(table); setLayout(new BorderLayout()); add(scroll,BorderLayout.CENTER); setVisible(true); }
634a16cb-301d-43e3-9254-9fb9ce4ed3af
0
public void setPwd(String pwd) { this.pwd = pwd; }
0c9fa878-7391-4e86-9d2e-947f191e4330
6
@Override public void start() { world = new World(); for(int i = 0; i < world.sizeX; i++) { for(int j = 0; j < world.sizeY; j++) { if(i == 0 || i == world.sizeX - 1 || j == 0 || j == world.sizeY - 1) { world.setTile(i, j, Tile.color); } } } //TODO: change back to colorPlayer world.setTileA...
4a20a388-38e3-4b88-aded-c20258c974e7
4
private String readURL(String url) { URL myuri; try { myuri = new URL(url); } catch (MalformedURLException e) {e.printStackTrace();return null;} BufferedReader in; try { in = new BufferedReader( new InputStreamReader( myuri.openStream())); } catch (IOException e) { e.printStack...
5ae92bca-5d32-4378-a082-7bea0736fafa
9
@Override public void run() { Random r = new Random(); boolean isSimulating = false; producer = new EventProducer(typeName, _clazz); //System.out.println("generating events..."); int i = 1; try { if (sporadic) { Thread.sleep(r.nextInt((int...
6eae6edc-9195-41c3-a485-eadb1f4ca546
1
private String helpCommandReturn(AreaLineManager gardenLineManager) { StringBuilder content = new StringBuilder(); content.append(gardenLineManager.getPropertiesLoader().loadProperty(Constants.MAIN_AVAILABLE_COMMANDS)); for (String availableCommand : gardenLineManager.getCommands().keySet()) { content.append("...
876030eb-800b-4ae1-91b6-15ab53d1251a
9
public int bitrate(int i){ if(i>=links) return (-1); if(!seekable&&i!=0) return (bitrate(0)); if(i<0){ long bits=0; for(int j=0; j<links; j++){ bits+=(offsets[j+1]-dataoffsets[j])*8; } return ((int)Math.rint(bits/time_total(-1))); } else{ if(seekable...
42098de1-386f-49e6-9d4f-7b94363c5a56
0
public String getDescription(){ return ".bmp"; }
111ad594-0de3-41bd-be5e-fdc23e59f247
0
public String getDescription() { return "JFLAP 4 File"; }
8b7c4015-1aae-4516-8d1c-a74716a2841f
7
public void calculateBoundingBox(){ int S32_NUM_VERTS = parent_surface.S32_NUM_VERTS; for(int i = 0; i < S32_NUM_VERTS; i++){ float[] xyz = xyz_normals[i].F32_3_XYZ; if( bb_minXYZ[0] > xyz[0]) bb_minXYZ[0] = xyz[0]; if( bb_minXYZ[1] > xyz[1]) bb_minXYZ[1] = xyz[1]; if( bb_minXYZ[2] > xyz...
b5c40f42-b8fb-45e5-a891-8eae0659374b
1
public static GameManager getInstance(){ if(instance == null){ instance = new GameManager(); } return instance; }
45ed8e56-e426-41d5-8a42-a0d803eb62b1
5
@Override public void mouseMoved(MouseEvent e) { int x = e.getX(); int y = e.getY(); if (x >= this.x && y >= this.y && x <= this.x + this.width && y <= this.y + this.height) setState(ButtonState.HOVER); else if(currentState == ButtonState.HOVER) setState(ButtonState.NORMAL); }
b02010f7-2b9e-4310-b0fd-72f5c14286d2
9
private void cftfsub(int n, double[] a, int offa, int[] ip, int nw, double[] w) { if (n > 8) { if (n > 32) { cftf1st(n, a, offa, w, nw - (n >> 2)); if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (n > ConcurrencyUtils.getThreadsBeginN_1D_FFT_2Threads())) { ...
3b293f90-1f4d-40cb-9325-70cb7d40f635
5
public void sort2(List<Integer> list) { if (list.size() < 2) return; int count = 0; for (int end = list.size(); end > 0; --end) { boolean swapped = false; for (int idx = 0; idx < end - 1; ++idx) { int left = list.get(idx); int ...