method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
2a635875-6fd5-48f0-b409-7a694310f678
9
public static int getKthSmallestElementInTwoSortedArrays(int[] array1, int[] array2, int k) { if(k > array1.length + array2.length) { throw new IllegalArgumentException("k is too large"); } int index1 = 0, index2 = 0; //Advance pointers until 'k' exhausted or we reach end of an array while (k != 1 &&...
feb53840-38cc-462b-8e58-186cc67e267f
6
public void registrarCambio(int indice1, int indice2) { String url = "jdbc:derby://localhost:1527/PDPIVP"; String selectdatos="SELECT * FROM EstructuraTabu"; int updated=0; int id=0; int tabu=0; try{ Class.forName("org.apache.derby.jdbc.ClientDriver"); //catch SQLException Connec...
5a6708a0-7a0d-401e-9de9-d5061c0b19fd
5
public TruthTablePanel(final Controller controller) { super(controller.program.getFrame()); setBounds(100, 100, 450, 465); this.setVisible(true); this.setIconImage(Program.programIcon); this.setTitle(Tools.getLocalizedString("TRUTH_TABLE.ShortDescription")); getContentPane().setLayout(new BorderLayout()); ...
a2839f53-57b2-4ae9-b30c-4d417dc3b93d
3
public static void main(String[] args) { String greetings = "Hello!!!"; String description = "I am written into a file"; BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(new File("output.txt"))); writer.write(greetings); writer.newLine(); writer.write(description); ...
1bd278f2-e278-40d7-957a-96db50292632
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://download.oracle.com/j...
91fd9f65-38db-4f71-b4da-438dfd41af23
0
@Override public Map<String, Object> getOptions() { return getOptions(null); }
f2a509c8-c546-4b11-af06-e5d6edfb5b80
1
public static void save() { DataFile dF = new DataFile(); try { File f = new File(Main.loc + "Options.cfg"); f.createNewFile(); FileOutputStream fileoutputstream = new FileOutputStream(f); dF.setProperty("mSounds", Main.options.mSounds + ""); dF.setProperty("sS", Main.options.sS); dF.setProper...
1e54fa3f-b3f0-4c0d-9265-1ea4f9e86a24
0
void moveDFA() { AutomatonDraggerPane dp = new AutomatonDraggerPane(dfa); split.setRightComponent(dp); }
f5371ed7-6f86-455e-84ed-d134f83c3c74
0
public DataHolderImporter(DataHolder s, DataHolder t) { source = s; target = t; }
3e104f23-6ebb-4e18-8c66-70169aacb7f0
7
public static void main(String[] args) { //make sure we're passed the correct arguments if(args.length != 1) { System.out.println("Incorrect number of arguments - given " + args.length); System.out.println("Correct usage: java SsatSolver <ssat file>"); System.out.print("Given : '"); for(String s : ar...
9bb4016e-85f7-4332-aaeb-455252ee3a85
5
@Override public void execute(JobExecutionContext jec) throws JobExecutionException { Bar[] bars = getBar(); List<BigDecimal> close = Arrays.asList(bars).stream().map(c -> c.getClose()).collect(Collectors.toList()); List<BigDecimal> high = Arrays.asList(bars).stream().map(c -> c.getHigh())....
7fe64e16-e38b-42a0-b8fe-02595db67665
0
public final int getQuerycount() { return querycount; }
f33cb613-004c-4726-9df9-1732e2ed9961
7
public void fillSuggestions() { history.add(Change.marker()); for (Cell cell : all()) { for (int n = 1; n <= size*size; n++) { if (!cell.poss().contains(n)) { history.add(new Change(cell.row, cell.column, n, Change.POSS_REM, fal...
268d49a6-016d-47c7-ac35-55352494aac2
4
public static void stub() { System.out.println("STUB TESTING\n\n\n"); // add 6(max number) of contestants try { // cont ID,first name,last name, tribe Contestant c1 = new Contestant(); c1.setID("i1"); Contestant c2 = new Contestant(); c2.setID("i2"); Contestant c3 = new Contestant(); c3.set...
e0ce562a-053a-4784-9c71-7a118da3dd47
0
@Test public void runTestLoop2() throws IOException { InfoflowResults res = analyzeAPKFile("GeneralJava_Loop2.apk"); Assert.assertEquals(1, res.size()); }
a236e888-0d91-4a1c-961b-c58578233f31
7
public int rangeMaxHit() { int rangeLevel = c.playerLevel[4]; double modifier = 1.0; double wtf = c.specDamage; int itemUsed = c.usingBow ? c.lastArrowUsed : c.lastWeaponUsed; if (c.prayerActive[3]) modifier += 0.05; else if (c.prayerActive[11]) modifier += 0.10; else if (c.prayerActive[19]) modi...
af8f1bed-5cac-4743-8124-f8e477d49db2
2
public static Storage getInstance() { if (uniqueInstance == null) { synchronized (Storage.class) { if (uniqueInstance == null) { uniqueInstance = new Storage(); } } } return uniqueInstance; }
ccc318c2-efc7-4575-a9db-54daa4d99852
8
public ArrayList<ArrayList<Integer>> fourSum(int[] num, int target) { ArrayList<ArrayList<Integer>> rst = new ArrayList<ArrayList<Integer>>(); Arrays.sort(num); ArrayList<Element> list = new ArrayList<Element>(); int i =0; int j =0; while (i<num.length - 2) { j = i + 1; while (j < num.l...
29ce1f36-7939-4322-8897-cfd128e3d8a7
7
public static int computeWordDistance(String s, String t) { int n = s.length(); int m = t.length(); int[][] d = new int[n + 1][ m + 1]; if (n == 0) return m; if (m == 0) return n; for (int i = 0; i <= n; d[i][ 0] = i++) { } for (int j = 0; j <= m; d[0][ j] = j...
5ff76f7f-edf0-40b0-872a-9239d12fc141
8
private boolean r_verb() { int among_var; int v_1; // (, line 136 // [, line 137 ket = cursor; // substring, line 137 among_var = find_among_b(a_4, 46); if (among_var == 0) ...
a7c9274f-9b46-4375-ba4f-6d48b6d4a1a5
2
private void drawSprite(Graphics2D g, Animation am) { if (showBox) { } // draw if (facingRight) { g.drawImage(animation.getImage(), (int) ((x) - (width / 2)), (int) ((y) - (height / 2)), null); } else { g.drawImage(animation.getImage(), (int) ((x) - (width / 2)) + width, (int) ((y) - ...
51ade206-2a9d-4161-b3c8-08b05aa4b9cb
4
public void start() { ServerSocket socket = null; try { socket = new ServerSocket(port); } catch (IOException e) { System.out.println("Could not listen on port " + port + "\n"); System.exit(-1); } while(true) { RealClient client1 = ...
fde7cce3-3ae9-49da-a6b4-2183f75c3c5f
2
public void deleteFollowing(String userEmail, String friendEmail) { initConnection(); String preparedString = null; PreparedStatement preparedQuery = null; try { //Prepare Statement preparedString = "DELETE FROM friends WHERE email = ? AND friend = ?;"; preparedQuery = (PreparedStatement) conne...
0d9a3955-5a8c-4cad-a1ad-ea3b1eea802a
8
@Override public boolean equals(Object obj) { System.out.println("ParkingSpace.equals() called"); if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ParkingSpace other = (ParkingSpace) obj; if (id != other.id) return false; if (lab...
f3856a22-7b78-4663-8ae0-9c8a2c9e903e
2
static double[][] transpose(double[][] A){ double[][] B = new double[A[0].length][A.length]; for(int i = 0; i < A.length; i++){ for(int j = 0; j < A[i].length; j++){ B[j][i] = A[i][j]; } } return B; }
7af7194d-81b4-4278-9e2a-73949ff990cd
3
public static String getExtension(String ext){ if(ext.equals("project file")){ return "agmproj"; } else if(ext.equals("data file")){ return "agmdata"; } else if(ext.equals("settings file")){ return "agmset"; } return ""; ...
401f5e7f-b85a-4908-8758-69752579c731
5
@Override public boolean arePointsNear(int x1, int y1, int x2, int y2) { int dx = Math.abs(x1 - x2); int dy = Math.abs(y1 - y2); if (dx * dy == 0 && (dx == 1 || dy == 1)) { return true; } if (dx > 1 || dy > 1) { return false; } //Top-Left & Bot...
33319b1b-28a3-437a-8a8e-231d9ed6e336
0
public static int defaultSCOSCPort() { return DEFAULT_SC_OSC_PORT; }
a3bf3f4c-d3a7-4075-ace3-841e71578d68
8
private void mainKeyPress(KeyEvent e){ currentMessage=""; if(currentScreenIndex==1){ int id = e.getID(); if(id==KeyEvent.KEY_RELEASED){ int keyCode=e.getKeyCode(); switch (keyCode){ case(KeyEvent.VK_UP): player1.move('8'); player1.endPlayerTurn(); return; case(KeyEvent...
d26f8e27-1951-48ec-b52f-77e2883b82ab
0
public ClientListener(The5zigMod plugin) { this.plugin = plugin; }
f80e5aed-d679-4a81-a1ba-00a0efad0fb5
0
public void publishNews(News news) { news.setAuthor(this); news.setTimestamp(new Date()); newspaper.addNews(news); }
ebfb590e-467c-41bc-80c6-ccfe88dac59f
5
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { MediaElement media = (MediaElement) medias[table.convertRowIndexToModel(row)]; isSelected = isSelected && (table.hasFocus() || Utils.isContextMenuDisplayed(media)...
d1cb40ec-1751-41f8-8133-6fce1278b9b0
0
public void add(Ball b) { balls.add(b); }
7d70367e-e899-47f2-a000-b0df402b9699
1
private void init(Socket clientSocket, Map<String, ClientData> records) { this.records = records; this.clientSocket = clientSocket; try { // this.input = new BufferedReader(new InputStreamReader(this.clientSocket.getInputStream())); input = new ObjectInputStream(this.clientSocket.getInputStream()); output...
ce57a1d0-d513-48bc-b1d9-1b020b1a4240
5
public static <T extends BaseWindow> String getNextUntitledWindowName(Class<T> windowClass, String baseTitle, BaseWindow exclude) { List<T> windows = getWindows(windowClass); int value = 0; String title; boolean again; do { again = false; title = baseTitle; if (++value > 1) { title += " " + valu...
ca014be7-867a-40dc-a241-f1563cd8bb89
1
private boolean jj_2_70(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_70(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(69, xla); } }
0e31add1-d6cb-4f3a-a87e-5f82b2dd74a0
8
private void processGridletSubmission(Sim_event ev) { if (trace_flag) { System.out.println(super.get_name() + ": received an SUBMIT_GRIDLET event. Clock: " + GridSim.clock()); } /*********** We have to submit: - the gridlet whose id c...
54e5b3a8-864b-40bf-a431-5f40a1d04e30
0
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "RSAKeyValue") public JAXBElement<RSAKeyValueType> createRSAKeyValue(RSAKeyValueType value) { return new JAXBElement<RSAKeyValueType>(_RSAKeyValue_QNAME, RSAKeyValueType.class, null, value); }
3bc2a487-3e10-4e21-a55a-38cd4f310c89
5
public static void updateMap() { for (int x=0;x<map.xAmt();x++) { for (int y=0;y<map.yAmt();y++) { if (Square.getSquare(x,y).isFree()) { map.value[x][y]=20; } else map.valu...
7f3d24ff-614b-4deb-9b59-3f43c10c50e4
4
public double getValueAs(String to){ double fromBase = 0; double toBase = 0; Converter[] u; // don't do any work if we're converting to ourselves if (to == unit || type == abrv) return value; if (type == "vol") u = volUnits; else if (type == "pressure") u = pressureUnits; else // assume weigh...
97c6e8ee-5c1d-415c-a887-cf30c4bfa599
1
private void givePenalityForLingeringOnSpawntile(AIConnection currentPlayer){ if(currentPlayer.position == currentPlayer.spawnTile){ Debug.warn("Player " + currentPlayer.username + " stayed on spawn too long"); currentPlayer.givePenality(10); } }
5fcc421f-838a-4c18-be59-4b5a767f5cf9
3
public boolean comprobar(String correo, String pass){ ResultSet resultado = cnx.execConsulta("SELECT idUsuario, nombre, contrasenia, nick, correo, telefono,edad, idModulo FROM Usuario WHERE correo = '"+correo+"' AND contrasenia = '"+pass+"' "); try{ if(resultado != null){ if(resultado.next()){ enSesion ...
cca6367a-1284-4e00-92b9-817984010140
0
public Timing (Modele _model){ model = _model; }
d794b4fc-d09f-4dbd-90f1-e9e9cc9dac0d
6
public void writeType(Class c) { // A big ol' case statement -- what's polymorphism mean, again? // I really wish I could extend the base classes! // use the appropriate flags to tell SuperCollider what kind of // thing it is looking at if (Integer.class.equals(c)) { stream.write('i'); } else if (java....
14939466-5435-4b12-a728-2a96e03b4526
5
public Ponto verificaZBuffer(Ponto p, int x, int y){ Ponto retorno = null; if(x >= this.zBuffer.length || y >= this.zBuffer[0].length || x < 0 || y < 0){ return null; } if(p.getZ() < this.zBuffer[x][y]){ this.zBuffer[x][y] = p.getZ(); retorno = p; } return retorno; }
8a14f2cb-39df-4b22-817e-ee6f4b8ecf84
9
public static void main(String[] args) { IComponentsData db = new DB(); //need to do initial load before doing anything else. If you don't you'll get an //error message stating such db.initialLoad("LAMS"); System.out.println("All appointments"); List<Object> objs = db.getData("...
f3c13ff6-3559-472e-a847-2397d7024868
4
public void setTransparency(int red, int green, int blue) { for (int index = 0; index < myPixels.length; index++){ if (((myPixels[index] >> 16) & 255) == red && ((myPixels[index] >> 8) & 255) == green && (myPixels[index] & 255) == blue) { myPixels[index] = 0; } } }
58a4fe38-ef58-403c-8161-d0211c428974
5
public int run (CommandManager manager, Object... args) { String source = ""; String dest = ""; if(args != null && args.length > 1){ source = (String)args[0]; dest = (String)args[1]; } else //Take input { Scanner kb = new Scanner(System.in); //Prompt the user as it pertains to System.out.pr...
23b266b1-1718-4ad5-92ad-ac9b04baebaa
0
private void preReques() { System.out.println("pre request !"); }
d028c682-b5ef-476f-a952-1d062767d542
3
public int greatestProduct(String sNum) { int numLen = sNum.length(); int greatestProduct = 0; int current = 0; //store current number for comparison for (int i = 0; i < numLen - 4; i++) { current = getProduct(sNum, i); if (greatestProduct == 0) { greatestProduct = current; } else if (curren...
1afb8c4c-63c1-4f87-a63d-aefefe16edde
4
public Highscore() throws DataException { try { file = new File(getClass().getResource("/resource/Highscores.xml").toURI()); } catch (URISyntaxException e1) { throw new DataException("Het highscorebestand kan niet worden gevonden."); } try { doc = new Builder().build(file); } catch (ValidityExceptio...
bbf75676-af63-45c3-8bc1-0e3e074608ef
1
private void compute_pcm_samples2(Obuffer buffer) { final float[] vp = actual_v; //int inc = v_inc; final float[] tmpOut = _tmpOut; int dvp =0; // fat chance of having this loop unroll for( int i=0; i<32; i++) { final float[] dp = d16[i]; float pcm_sample; pcm_sample = (float)(((vp[2 + ...
83ac19bd-59c7-4148-98a9-66379ed21c32
3
public void serverLogic(ServerUI server) { if (server.thread != null && !server.thread.isRunning()) { if (!server.startServer.getText().equals("Lunch server")) { server.startServer.setText("Lunch server"); server.startServer.setEnabled(true); } } }
ee74b4a0-0a92-4423-b95c-70c1d0b8f7a9
5
public boolean isComplexIDOrNeg() { return ((PrimitiveOperator) op).isComplexIDOfLeft() || ((PrimitiveOperator) op).isComplexIDOfRight() || ((PrimitiveOperator) op).isComplexIDOfMiddle() || ((PrimitiveOperator) op).isComplexNotOfLeft() || ((PrimitiveOperator) op).isComplexNotOfRigh...
e10a6741-09a7-44b3-9faa-1bd7538659b9
7
public static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double)o).isInfinite() || ((Double)o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); ...
ec0faa9f-8a11-48da-9c17-ddc6ef24123c
8
public void setImages() { if (waitImage == null) { File imageFile = new File(Structure.baseDir + "StasisTower.png"); try { waitImage = ImageIO.read(imageFile); } catch (IOException e) { e.printStackTrace(); } } if (attackImage == null) { File imageFile = new File(Structure.baseDir + ...
537d9030-6dc7-4715-b428-5e6c875cbb8b
9
public static void main(String[] args) { double[] weight = {0.05, 0.4, 0.08, 0.04, 0.1, 0.1, 0.23}; int numNode = weight.length; double[][] matrix = new double[numNode][numNode]; for (int s = 0; s < numNode; s++){ for (int i = 0; i < numNode - s; i++){ double[] temp = new double[s+1]; ...
45034425-39c8-4872-a836-73272ec86bba
3
@SuppressWarnings("unchecked") public static <T> T readObject(String path) { ObjectInputStream ois = null; try { ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(path))); return (T) ois.readObject(); } catch (Exception e) { CommonUtils.throwRuntimeExceptionAndPrint(e); } finally...
43e466f9-a6bf-455f-b6c0-6ecd4bed6853
2
private static int getTeamId(Statement statement, String teamName) throws SQLException { int id = -1; ResultSet resultSet = statement.executeQuery("select id from " + Settings.DB_TABLE_TEAM + " where name like '" + teamName + "' limit 1"); // SQL injection ? if (resultSet.next()) { id = result...
8b60d653-571e-41a9-9cc9-c84b16e31273
8
public static void main(String[] args) { Scanner in = new Scanner(System.in); while (true) { int n = in.nextInt(); if (n == 0) break; BigInteger N = new BigInteger(""+n); BigInteger current = new BigInteger(""+n); if (n == 90) current = new BigInteger("1111111110"); if (n == 180) cu...
9e0c7662-390f-4396-a4e4-b63029d4c1e1
0
public CtrlVisiteurs(VueVisiteurs vue, VueAbstrait vueA){ super(vueA); this.vue = vue; this.vue.setControleur(this); // Gérer la persistance em = EntityManagerFactorySingleton.getInstance().createEntityManager(); em.getTransaction().begin(); //pr...
2d50975f-e140-4844-a84f-6d0365148155
1
public long[] nextLongs(int n) throws IOException { long[] res = new long[n]; for (int i = 0; i < n; ++i) { res[i] = nextLong(); } return res; }
39d6f8a5-79e9-447b-9591-a9938a74de00
3
public int maxFlow(int src, int dest) { int flow = 0; int[] dist = new int[V]; while (dinicBfs(src, dest, dist)) { int[] ptr = new int[V]; while (true) { int df = dinicDfs(ptr, dist, dest, src, Integer.MAX_VALUE); if (df == 0) break; flow += df; } } return flow; }
b49ed783-b9fc-48e8-b2e9-02363481eba7
2
public SyncDownloadTableModel() { for (final FolderConfig folderConfig : GuiUtils.syncConfig.getConfigs()) { for (final SongConfig songConfig : folderConfig.getSongs()) { data.add(Pair.createPair(songConfig.isSyncOn(), songConfig.getSongUrl())); } } }
b630fcd3-3c5b-4dc8-934e-f35cb39eda16
6
@Override public void handleMessages(Inbox inbox) { while(inbox.hasNext()) { Message m = inbox.next(); if(m instanceof MarkMessage) { if(parent == null || !inbox.getSender().equals(parent)) { continue;// don't consider mark messages sent by children } this.setColor(Color.RED); // forward t...
7ac9a72c-0739-43c3-95df-e477264dd0e6
4
public void checkBulletCollision() { for(int i = 0; i<bullets.size(); i++){ Sprite collisionSprite = getSpriteCollision(bullets.get(i)); if(collisionSprite instanceof Grub || collisionSprite instanceof Fly){ Creature badguy = (Creature)collisionSprite; ...
032ed958-243d-465f-979e-7313bba40089
6
public boolean moveItem(XYLocation initialLocation,XYLocation finalLocation) { if (!testLocation(initialLocation) || !testLocation(finalLocation) || board[initialLocation.getXCoOrdinate()][initialLocation.getYCoOrdinate()] ==null) return false; if (board[initialLocation.getXCoOrdinate()][initialLocation.g...
78117fc3-22fe-498e-ad3b-1fea26bc0be7
3
public boolean jsFunction_waitDrop(int timeout) { deprecated(); int curr = 0; if(timeout == 0) timeout = 10000; while(JSBotUtils.isDragging()) { if(curr > timeout) return false; Sleep(25); curr += 25; } return true; }
f9cc42f6-42e7-4567-b5b2-4146cda0e515
3
static private Map<String, Set<CoreMetaData> > getTaGrpMetaInfoMap() { if (taFuncMap==null) getAllFuncs(); Map<String, Set<CoreMetaData> > result = new TreeMap<String, Set<CoreMetaData> >(); for (String func : taFuncMap.keySet()) { CoreMetaData mi = taFuncMap.get(func); S...
72377b75-e205-474f-868d-95e8e1ce8661
3
@Override public void step() { //Only baseCooldown if we're below the rate, otherwise the ship hasn't tried to shoot if (cooldownTimer <= 0 && shootRequested) this.shoot(); if (cooldownTimer > 0) cooldownTimer--; super.step(); }
ce2dbffa-040f-4a82-8eaa-2251535383d3
9
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { logger.info("preHandle()"); // Session management /*for (Cookie cookie : request.getCookies()) { logger.info("name of Cookie from request is: "+ cookie.getName()); logger.info...
2630d4f4-aafb-49fb-9154-7bcd0e4653b4
5
public Dimension getMinimumSize() { int height = 0; int width = 0; // // Use the size set by the application // if (isPreferredSizeSet()) return super.getPreferredSize(); // // Leave room for the component border // Border bor...
1d5c4362-a939-49a7-949f-2a43e759ebcd
0
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jButton4ActionPerformed
b8c37040-5438-4ac0-908e-f1a9466da135
8
@Override public void setImages() { if (waitImage == null) { File imageFile = new File(Structure.baseDir + "PlasmaCannon.png"); try { waitImage = ImageIO.read(imageFile); } catch (IOException e) { e.printStackTrace(); } } if (attackImage == null) { File imageFile = new File(Structure.base...
6f8dd835-782e-47a0-a35f-a8a0531ac0ae
5
private boolean parseItems(Document doc) { NodeList nodes = doc.getElementsByTagName(XmlTag.ITEM_SECTION.toString()); if(nodes.getLength() == 0) return false; //ITEM_SECTION not found NodeList items = ((Element)nodes.item(0)).getElementsByTagName(XmlTag.ITEM.toString()); for(int item_num = 0; item_num < items....
1df3d839-2377-4ddb-94d8-2eb99c79066c
8
static long LCA(int p, int q) { int tmp, log, i; // if p is situated on a higher level than q then we swap them if (L[p] < L[q]) { tmp = p; p = q; q = tmp; } // we compute the value of [log(L[p)] for (log = 1; 1 << log <= L[p]; log++) ; log--; long max = 0; // we find the ancestor of n...
0b982311-44d1-4cd4-8773-58a995b33eec
0
@Override public ArrayList<String> getQuestAnswer() { return null; }
6ba2ab79-fda1-40d9-8991-f182b1b76568
2
public boolean contains(StructuredBlock child) { while (child != this && child != null) child = child.outer; return (child == this); }
d340ee0b-9335-4571-8157-28f140c8cd65
4
public String row(int i) throws Exception { int h = this.block.height(); // Sanity check if ((i < 0) || (i >= h)) { throw new Exception("Invalid row " + i); } // if the row is invalid if (this.block.width() > this.width) { throw new Exception("New TextBlock width...
72abf332-cc7d-46dc-a278-fc2450215bd5
3
private void writeRun (final int value, int runLength) { final int blockLength = this.blockLength; final byte[] block = this.block; this.blockValuesPresent[value] = true; this.crc.updateCRC (value, runLength); final byte byteValue = (byte)value; switch (runLength) { case 1: block[blockLength] = by...
042771e7-be55-44f5-98c3-365bb6f03a06
8
public Chest() { super(ResourceManager.getImage("chest")); this.items = new ArrayList<>(); for (int i = 0; i < new Random().nextInt(5); i++) { items.add(new GoldPickup()); } if (new Random().nextBoolean()) { int amo = (new Random().nextDouble() > 0.8 ? 2 :...
8a342511-0261-4d92-9425-5d5933294adb
4
public boolean containsDouble(final List<Card> cardList, final List<Card> containsList) { List<Card> mutableCards = new ArrayList<Card>(cardList); List<Card> doubleList = new ArrayList<Card>(containsList); doubleList.addAll(containsList); ListIterator<Card> cardIterator = doubleList.listIterator(); ...
a726dc01-68f5-401f-88fb-cb6b36c2a608
5
public static int addToDB(String Firstname, String LastName, String PhoneNumber) throws SQLException, IOException { int isTrue = 0; PreparedStatement prStAddToDB = null; String query = "INSERT INTO `mobilephone` VALUES (?, ?, ?, null)"; Connection conn = DBConnection.getConnection(); try { conn.setAuto...
43069e00-5dc5-4d69-bf6a-5c9c24e1ac8d
1
public CNRLink setNetName(String s) { if (s != null) netname = s; return this; }
91ed0818-db35-4ca0-8b63-94e626ed80fc
5
public MediaWiki.CurrentUser getCurrentUser() throws IOException, MediaWiki.MediaWikiException { final Map<String, String> getParams = paramValuesToMap("action", "query", "format", "xml", "meta", "userinfo", "uiprop", "hasmsg|groups|rights|blockinfo|editcount"); final String url = createApiGetUrl(getParams); net...
c2bec448-2592-4467-a89c-7085589ef475
0
private ParticipantJsonConverter() { }
bd8afe35-df50-4fb3-a02b-b93931f4b004
5
private boolean spaceInCheck(Board b, PossibleTile pt) { for (Piece p : b.getPieces()) { if(p.isWhite() != this.isWhite() && !(p instanceof King)) { for(PossibleTile ppt : p.getLazyTiles(b)) { if (checkSameSpace(pt, ppt)) { return true; } } } } return false; }
f345e439-74bd-4a61-ae03-7fab293389b1
4
@Test public void kingRookAndKnight() { Map<String, Integer> figureQuantityMap = new HashMap<>(); figureQuantityMap.put(KING.toString(), 2); figureQuantityMap.put(ROOK.toString(), 2); figureQuantityMap.put(KNIGHT.toString(), 2); int dimension = 5; assertThat("all ele...
d99dab83-9195-4daf-ba8f-c923cb314644
3
public Tournament loadTournament(long tournamentId) throws EntityNotFoundException /* loaded tournament will be persisted by default * */ { if (tournamentId != 0L) { // logger.debug("Trying to load Tournament {}", tournamentId ); try { ...
1c6ec0fd-77f0-4f09-af58-ebde441eaa24
9
protected Node createNode(Document document, String title, GraphLayoutCache cache, int inset) throws ParserConfigurationException { // Collects basic geometric details Rectangle2D bounds = GraphLayoutCache.getBounds(cache.getAllViews()); double dx = bounds.getX() - inset; double dy = bounds.getY() - inse...
cc938593-2626-46fe-bc24-21b652359343
1
public void updateDisplay() { this.wasAccepted = false; this.stock = null; this.lstStocks.setListData(this.stocks.toArray()); this.txfDate.setText(Service.dateToString(new Date(System .currentTimeMillis()))); if (this.requiresStock) { this.btnOk.setEnabled(false); } else this.btnOk.setEnabled(true)...
b78fc2b8-7e97-4bc4-8c73-b7970380b055
1
public long getLong( String name ){ XAttribute attribute = getAttribute( name ); if( attribute == null ) throw new XException( "no attribute known with name: " + name ); return attribute.getLong(); }
8c8e720d-6c8e-4c2e-ae5f-015f1e440665
3
public static String toString(JSONObject o) throws JSONException { boolean b = false; Iterator keys = o.keys(); String s; StringBuffer sb = new StringBuffer(); while (keys.hasNext()) { s = keys.next().toString(); if (!o.isNull(s)) { ...
68dd34d5-28b6-4f8b-9dbc-7670891bfbfb
5
public static synchronized int addUser(String roomName, User user) { for (GameRoom room : briscaGames) { // if(room==null)continue; if (room.getName().equals(roomName)) { for (Player player : room.getPlayers()) { if (player == null) continue; if (player.getUser().getUsername() .equals...
106d4898-0a6a-449a-b7e1-91975464a2e8
6
@SuppressWarnings( "unchecked" ) public UmlDiagramData toData( DefaultUmlDiagram diagram ) { UmlDiagramData diagramData = new UmlDiagramData(); diagramData.setNextUnqiueId( diagram.currentUniqueId() ); for( DefaultItem<?> item : diagram.getDefaultItems() ) { DataConverter<?, ?, DefaultItem<Item>> converter =...
73feae15-add8-4992-80df-c298b52c5db9
0
public ButtonCellEditor(JCheckBox checkBox) { super(checkBox); button = new JButton(); button.setOpaque(true); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireEditingStopped(); } } ); rendererButt...
d7d8b2b8-0bf0-4183-852b-54b2fc1cfed3
2
@Override public BigDecimal calculate(Expression expression) { BigDecimal leftOperand = expression.getLeftValue(); BigDecimal rightOperand = expression.getRightValue(); if(leftOperand == null || rightOperand == null){ return null; } BigDecimal result = leftOperand.add(rightOperand); return resul...
485a6b06-d2ee-4db0-a23b-77764efa3569
7
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { String serviceOrderIdParam = request.getParamet...
288db9f6-e20a-49d2-b773-3cbe90dda7ab
5
public void InsertPWD(PwdItem encpwd) { if (this.connection == null || encpwd == null) { return; } try { int maxkey = 0; Statement stmt = null; stmt = this.connection.createStatement(); //find the max id ResultSet rs = stm...
f54c2be4-7194-49fe-8108-6c5eb11f225f
4
private void drawPieces(int imageWidth, int imageHeight, Graphics g) { for(int y = 0; y < boardSize; y++) { for(int x = 0; x < boardSize; x++) { Piece piece = controller.getPieceFromBoard(x, y); String pieceName = piece.getPieceName(); ...