method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
d4866ce6-2d22-49da-9a4e-d286cb116251
0
public LibrationODE(double a, double epsilon, double delta, double omega0) { this.a = a; this.epsilon = epsilon; this.delta = delta; this.omega0 = omega0; }
b43e37f1-cc31-47e9-816b-a977b1f849d0
6
@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { if(plugin.config.getBoolean("Apply.Enabled")) { Player player = event.getPlayer(); String pw = plugin.config.getString("Apply.Password"); String group = plugin.config.getString("Apply.Group"); if(!player.hasPermission("MasterPromote.member")) { String msg = plugin.messages.getString("Join").replace("&", "\247"); msg = msg.replace("<group>", group); msg = msg.replace("<password>", pw); String[] msgs = msg.split("<newline>"); for(String s : msgs) { player.sendMessage(s); } } } if(plugin.config.getBoolean("Time.Enabled")) { Player player = event.getPlayer(); if(!player.hasPermission("MasterPromote.member")) { if(!plugin.timepromote.containsKey(player.getName().toLowerCase())) { plugin.timepromote.put(player.getName().toLowerCase(), plugin.config.getLong("Time.Time")); } } } }
7b8c9590-88b5-4932-8847-ab779e84f40e
9
@SuppressWarnings("unchecked") @Override public void recoverCharStats() { baseCharStats.setClassLevel(baseCharStats.getCurrentClass(), basePhyStats().level() - baseCharStats().combinedSubLevels()); baseCharStats().copyInto(charStats); final Rideable riding = riding(); if (riding != null) riding.affectCharStats(this, charStats); final Deity deity = getMyDeity(); if (deity != null) deity.affectCharStats(this, charStats); final int num = charStats.numClasses(); for (int c = 0; c < num; c++) charStats.getMyClass(c).affectCharStats(this, charStats); charStats.getMyRace().affectCharStats(this, charStats); baseCharStats.getMyRace().agingAffects(this, baseCharStats, charStats); eachEffect(affectCharStats); eachItem(affectCharStats); if (location() != null) location().affectCharStats(this, charStats); for (final Enumeration<FData> e = factions.elements(); e.hasMoreElements();) e.nextElement().affectCharStats(this, charStats); if ((playerStats != null) && (soulMate == null) && (playerStats.getHygiene() >= PlayerStats.HYGIENE_DELIMIT)) { final int chaAdjust = (int) (playerStats.getHygiene() / PlayerStats.HYGIENE_DELIMIT); if ((charStats.getStat(CharStats.STAT_CHARISMA) / 2) > chaAdjust) charStats.setStat(CharStats.STAT_CHARISMA, charStats.getStat(CharStats.STAT_CHARISMA) - chaAdjust); else charStats.setStat(CharStats.STAT_CHARISMA, charStats.getStat(CharStats.STAT_CHARISMA) / 2); } }
d3a11d45-8115-4644-a709-d9c3e891b9d0
3
@Test public void test() { PersonnageService perso = new PersonnageImpl(); Random rand = new Random(); System.out.println("Tests de pré-condition non atteignable"); perso.init(0, 0); System.out.println("Tests de couverture des postconditions de init"); assertTrue("Le personnage est mort après init", perso.getSante() == Sante.VIVANT); assertTrue("La position du personnage est mauvaise", perso.getX()==0 && perso.getY() == 0); System.out.println("Tests de couverture des post-conditions des operators"); int x = rand.nextInt(), y = rand.nextInt(); perso.setX(x); assertTrue("Post-condition de setX non respéctées", perso.getX()==x && perso.getY()==0); perso.setY(y); assertTrue("Post-condition de setY non respéctées", perso.getX()==x && perso.getY()==y); perso.setSante(Sante.MORT); assertTrue("Post-condition de setSante non respectées",perso.getSante()==Sante.MORT); }
6ff57d4a-aa30-4cc8-b64c-5111f35c4b86
2
private static SpriteSheet getSpriteSheet(String path, float scale) { try { SpriteSheet spriteSheet; Color col = new Color(0, 0, 255); Image img = new Image(path); if (scale != 1) { img = img.getScaledCopy(scale); } img.setFilter(Image.FILTER_NEAREST); spriteSheet = new SpriteSheet(img, 8 * (int) scale, 8 * (int) scale); return spriteSheet; } catch (SlickException e) { System.out.println("Couldn't find font file..."); System.exit(0); } return null; }
ae434392-9a8c-43a3-93dc-b85599bae1a0
1
private void asetaJonoonArvollinen() throws IllegalStateException { if (seuraavaArvollinen == null) { throw new IllegalStateException(); } nykyinenJono().lisaaSeuraavaArvollinen(seuraavaArvollinen); this.seuraavaArvollinen = null; }
deee0647-cf35-4b20-872a-f6c8978ae6b1
1
public void writeToDebugFile(String value) throws IOException { if(debug) { //append text to log //text = Date + time + " || " + value FileWriter write = new FileWriter(System.getProperty("user.dir") + "/" + debugFile + ".txt", true); PrintWriter print_line = new PrintWriter(write); cal = Calendar.getInstance(); print_line.printf("%n" + sdf.format(cal.getTime()) + " || " + value); print_line.close(); } }
73974c7b-f736-48f2-85e0-29149e547459
2
public String getColumnName(int columnIndex) { switch (columnIndex) { case 0: return "Name"; case 1: return "Week Day"; } return ""; }
d5abb6e8-cfc0-4164-9b4b-ce1fc371d2c5
9
public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: java Chess input-file"); System.exit(0); } String inputFileName = args[0]; BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(inputFileName)); } catch (IOException e) { System.out.println(e); e.printStackTrace(); } String firstLine = null; try { firstLine = reader.readLine(); } catch (IOException e) { System.out.println(e); e.printStackTrace(); } String[] rcList = firstLine.split("\\s+"); BOARD_ROWS = Integer.parseInt(rcList[0]); BOARD_COLS = Integer.parseInt(rcList[1]); ChessConfig startConfig = null; String currentLine = ""; int numPieces = 0; ChessPiece[][] board = new ChessPiece[BOARD_ROWS][BOARD_COLS]; try { for (int i=0;i<BOARD_ROWS;i++) { currentLine = reader.readLine(); String[] tempList = currentLine.split("\\s+"); for (int j=0; j<Chess.BOARD_COLS;j++) { board[i][j] = makePiece(tempList[j]); if (board[i][j] != ChessPiece.EMPTY) numPieces++; } } } catch (IOException e) { System.out.println(e); e.printStackTrace(); } startConfig = new ChessConfig(board, numPieces); Chess game = new Chess(startConfig); Solver solver = new Solver(game); ArrayList<Config> path = solver.solve(); if (path == null) System.out.println("No solution."); else for (Config c : path) System.out.println("Step " + path.indexOf(c) + ":" + c + "\n"); ChessFrame gui = new ChessFrame("Solitare Chess Dylan Bannon <drb2857>", game); }
45322c84-5a61-4827-b6c0-2fd68bdbac0c
0
public String getrank() {//Accesses the Card's rank return rank; }
322b2eb1-ff91-4dbd-ba71-ca6505c788a7
4
public static Image createTransparentImageFromBitmap( byte[] bytes, int width, int height) { Display.check(); int pix[] = new int[width * height]; int index = 0; int srcPos = 0; int dstPos = 0; int[] colors = { 0x000ffffff, 0x0ffffffff, 0x0ff000000, 0x0ff000000 }; for (int y = 0; y < height; y++) { int shift = 6; for (int x = 0; x < width; x++) { pix[dstPos++] = colors[(bytes[srcPos] >> shift) & 3]; shift -= 2; if (shift < 0) { shift = 6; srcPos++; } } if (shift != 6) srcPos++; } Image ret = new Image( java.awt.Toolkit.getDefaultToolkit().createImage( new MemoryImageSource(width, height, pix, 0, width)), false, true, "createTransparentImageFromBitmap"); ret._transparent = true; return ret; }
620b1f34-aed4-4fee-8c45-c02e8adfbadd
2
public static double getDoubleParameter(String key) throws CorruptConfigurationEntryException { key = key.toLowerCase(); if(parameters.containsKey(key)) { try { return Double.parseDouble(parameters.get(key)); } catch(NumberFormatException e) { throw new CorruptConfigurationEntryException("The entry '" + key + "' in the configuration file cannot be converted to a double value."); } } else { throw new CorruptConfigurationEntryException("Missing entry in the configuration file: An entry for the key '" + key + "' is missing."); } }
571174c2-6dcb-47c6-9110-a6bfd43d770a
1
public boolean isGameOver() { return (board.numberOfPawns()==1) || (board.maxGold() >= 3); }
92bad23a-b1e3-4e98-9407-90561afb15ce
2
public User(String name) { if (name == null || name == "") throw new IllegalArgumentException(); this.name = name; }
68b3c81b-0a0d-4d7f-b5b7-91404379865c
9
public static void render(Item item){ int dialogWidth; if(item.getName().length() > item.getDescription().length()){ dialogWidth = item.getName().length() * 8 + 20; }else{ dialogWidth = item.getDescription().length() * 8 + 20; } // 20 + 12 * i (i = desc lines) int dialogHeight = 20 + 12 * (item.getDescription().length()/35 +2); int dialogX = Game.PLAYER.getCameraX() + Mouse.getX() + 15; int dialogY = Game.PLAYER.getCameraY() + Mouse.getY() - dialogHeight + 15; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(0.5f, 0.5f, 0.5f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(dialogX - 2, dialogY - 2); GL11.glVertex2f(dialogX + dialogWidth + 2, dialogY - 2); GL11.glVertex2f(dialogX + dialogWidth + 2, dialogY + dialogHeight + 2); GL11.glVertex2f(dialogX - 2, dialogY + dialogHeight + 2); GL11.glEnd(); GL11.glColor3f(0.3f, 0.3f, 0.3f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(dialogX, dialogY); GL11.glVertex2f(dialogX + dialogWidth, dialogY); GL11.glVertex2f(dialogX + dialogWidth, dialogY + dialogHeight); GL11.glVertex2f(dialogX, dialogY + dialogHeight); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); switch(item.getTier()){ case T1: Font.render(item.getName(), dialogX + 10, dialogY + dialogHeight - 16); break; case T2: Font.renderColored(item.getName(), dialogX + 10, dialogY + dialogHeight - 16, 1, 0f, 1f, 0f); break; case T3: Font.renderColored(item.getName(), dialogX + 10, dialogY + dialogHeight - 16, 1, 0f, 0f, 0.7f); break; case T4: Font.renderColored(item.getName(), dialogX + 10, dialogY + dialogHeight - 16, 1, 0.5f, 0f, 0.7f); break; case T5: Font.renderColored(item.getName(), dialogX + 10, dialogY + dialogHeight - 16, 1, 1f, 0.5f, 0.3f); break; } if(item.getRequiredLvl() > Game.PLAYER.getLvl()){ Font.renderColored("LvL: " + item.getRequiredLvl(), dialogX + 10, dialogY + dialogHeight - 26, 1, 0.5f, 0f, 0f); }else{ Font.render("LvL: " + item.getRequiredLvl(), dialogX + 10, dialogY + dialogHeight - 26); } for (int i = 0; i < (item.getDescription().length()/35) + 1; i++) { if((i+1)*35 < item.getDescription().length()){ Font.render(item.getDescription().substring(i*35, (i+1)*35), dialogX + 10, dialogY + dialogHeight - 36 - i*10); }else{ Font.render(item.getDescription().substring(i*35, item.getDescription().length()), dialogX + 10, dialogY + dialogHeight - 36 - i*10); } } }
3641a23e-c199-43c7-9531-900fb0ada726
3
@SuppressWarnings("unchecked") public String getEventsLineChart() { PreparedStatement st = null; ResultSet rs = null; JSONArray json = new JSONArray(); try { conn = dbconn.getConnection(); st = conn.prepareStatement("SELECT m.event_id, e.name, sum(m.auton_top)*6 + sum(m.auton_middle)*4 + sum(m.auton_bottom)*2 + sum(m.teleop_top)*3 + sum(m.teleop_middle)*2 + sum(m.teleop_bottom) + sum(m.teleop_pyramid)*5 + sum(m.pyramid_level)*10 as total FROM match_record_2013 m, events e WHERE team_id = ? and m.event_id = e.id GROUP BY event_id"); st.setInt(1, getSelectedTeam()); rs = st.executeQuery(); while (rs.next()) { JSONObject o = new JSONObject(); o.put("id", rs.getInt("event_id")); o.put("name", rs.getString("name")); o.put("total_points", rs.getInt("total")); json.add(o); } } catch (SQLException e) { e.printStackTrace(); } finally { try{ conn.close(); st.close(); rs.close(); }catch (SQLException e) { System.out.println("Error closing query"); } } return json.toString(); }
a1d0d548-58c7-4185-9495-4b98ee0065be
0
private void especialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_especialActionPerformed // TODO add your handling code here: }//GEN-LAST:event_especialActionPerformed
a66945db-d0da-48ff-bd31-43758d30f8c4
5
private static void generateLeafs(){ for(int i = 0 ; i < Config.labels.size() ; i++){ ArrayList<Composant> list = Config.hash.get(Config.labels.get(i)); int j = 0 ; while(j < list.size()){ Composant c = list.get(j); System.out.println("\t " + c); if(c.getList().size() == 1){ if(c.getList().get(0).equals("Leaf")){ if(Config.labels.get(i).contains("SL")){ SETNode s = new SETNode(Config.labels.get(i), c.getWeight()); leaf.add(s); addToTable(s); }else{ Node n = new Node(Config.labels.get(i), c.getWeight()); leaf.add(n); addToTable(n); } nameLeaf.add(Config.labels.get(i)); list.remove(j); }else{ j++; } }else{ //System.out.println("here"); j++; } } } }
19a8538d-2fe3-49e2-84df-ff5d69eaa1ab
3
public static void doubleWalk(int current, boolean[] visited, UndirectedGraph ug, ArrayList<Integer> doublePath){ if(visited[current]){ return; } doublePath.add(current); visited[current]=true; for(int i=0;i<ug.dist[current].length;i++){ int to=ug.dist[current][i]; if(!visited[to]){ doubleWalk(to,visited, ug, doublePath);//add going down doublePath.add(current);//add going up } } }
e84d8870-1286-4739-a18a-c5e780763275
9
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { ArrayList<CompRequest> comp = new ArrayList<CompRequest>(); ArrayList<PaidRequest> paid = new ArrayList<PaidRequest>(); ArrayList<Game> games = new ArrayList<Game>(); ArrayList<Section> section = new ArrayList<Section>(); Employee emp = (Employee) request.getSession().getAttribute("emp"); request.getSession().invalidate(); request.getSession().setAttribute("emp", emp); String message, url = "/index.jsp"; String dbURL = "jdbc:mysql://localhost:3306/itrs"; String username = "root"; String dbpassword = "sesame"; try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { } try { Connection conn = DriverManager.getConnection(dbURL, username, dbpassword); Statement s = conn.createStatement(); ResultSet r = s.executeQuery("SELECT * FROM employee NATURAL JOIN department WHERE emp_acctnum ='" + emp.getAcctNum() + "'"); if (r.next()) { emp = new Employee(); emp.setEmployee(r); emp.setLoggedIn(emp.getPassword()); message = "Employee found: " + emp.getFName() + " " + emp.getLName(); r.close(); r = null; s.close(); s = null; if (emp.getLoggedIn()) { url = "/Main.jsp"; s = conn.createStatement(); r = s.executeQuery("SELECT * FROM comprequest NATURAL JOIN department NATURAL JOIN games " + "NATURAL JOIN seating NATURAL JOIN employee " + "WHERE emp_acctnum =" + emp.getAcctNum()); while (r.next()) { CompRequest c = new CompRequest(); c.setRequest(r); comp.add(c); } r.close(); r = null; s.close(); s = null; s = conn.createStatement(); r = s.executeQuery("SELECT * FROM paidrequest NATURAL JOIN department NATURAL JOIN games " + "NATURAL JOIN seating NATURAL JOIN employee " + "WHERE emp_acctnum =" + emp.getAcctNum()); while (r.next()) { PaidRequest p = new PaidRequest(); p.setRequest(r); paid.add(p); } r.close(); r = null; s.close(); s = null; s = conn.createStatement(); r = s.executeQuery("SELECT * FROM games ORDER BY game_date"); Date date = new Date(); while (r.next()) { Game g = new Game(); g.setGame(r); if (date.compareTo(g.getGameDay()) >= 0) { g.setSoldOut(true); } games.add(g); } r.close(); r = null; s.close(); s = null; s = conn.createStatement(); r = s.executeQuery("SELECT * FROM seating ORDER BY sec_num"); while (r.next()) { Section x = new Section(); x.setSection(r); section.add(x); } request.getSession().setAttribute("games", games); request.getSession().setAttribute("sections", section); request.getSession().setAttribute("comp", comp); request.getSession().setAttribute("paid", paid); } else { message = "Invalid Password " + emp.getPassword() + " " + emp.getLoggedIn(); } } else { message = "Unknown user: " + emp.getAcctNum() + ". UserID not found."; } } catch (SQLException e) { message = "SQL Error: " + e.getMessage(); } request.setAttribute("message", message); request.getSession().setAttribute("emp", emp); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url); dispatcher.forward(request, response); } finally { out.close(); } }
0c3bf42c-1c77-49d3-a561-90ad05698ad3
4
public ArrayList<Meeting> getMeetingNotificationsByUsername(String username){ ArrayList<Meeting> meetings = new ArrayList<>(); ArrayList<MeetingInvite> meetingInvites = meetingInvites().getMeetingInvitesByUsername(username); for(MeetingInvite meetingInvite : meetingInvites){ Meeting meeting = meetings().getMeetingByID(meetingInvite.getMeetingID()); LocalDateTime lastUpdated = meeting.getLastUpdatedAsLocalDateTime(); LocalDateTime lastSeen = meetingInvite.getLastSeenAsLocalDateTime(); if(lastUpdated == null) continue; if(lastSeen == null){ meetings.add(meeting); continue; } if(meeting.getLastUpdatedAsLocalDateTime().isAfter(meetingInvite.getLastSeenAsLocalDateTime())) meetings.add(meeting); } return meetings; }
ba615e6a-d26d-4745-9b11-816d151800d6
3
public void test_constructor1() { OffsetDateTimeField field = new OffsetDateTimeField( ISOChronology.getInstance().secondOfMinute(), 3 ); assertEquals(DateTimeFieldType.secondOfMinute(), field.getType()); assertEquals(3, field.getOffset()); try { field = new OffsetDateTimeField(null, 3); fail(); } catch (IllegalArgumentException ex) {} try { field = new OffsetDateTimeField(ISOChronology.getInstance().secondOfMinute(), 0); fail(); } catch (IllegalArgumentException ex) {} try { field = new OffsetDateTimeField(UnsupportedDateTimeField.getInstance( DateTimeFieldType.secondOfMinute(), UnsupportedDurationField.getInstance(DurationFieldType.seconds())), 0); fail(); } catch (IllegalArgumentException ex) {} }
b06306ba-a27a-42fb-9668-174249e74b01
8
static int KMP(char[] p, char[] t) { int i = 0, j = 0, m = p.length, n = t.length; boolean palindrome = false, alindrome = false; while (i < n) { while (j >= 0 && t[i] != p[j]) j = b[j]; i++; j++; if (j == m) { if (i == j) palindrome = true; else if (i != n) alindrome = true; j = b[j]; } } return alindrome ? 0 : palindrome ? 1 : 2; }
3d68ec42-16d6-44ca-9375-2e7831cd1f1a
1
private final List<Integer> getIntegerList (Object[] objList) { List<Integer> list = new ArrayList<Integer>(); for (int i = 0; i < objList.length; i++) { list.add((Integer)objList[i]); } return list; }
99fa4177-efe9-4254-ba6c-0d8c99d8dfb4
2
public void get(String url) { try { URI requestUrl = URI.create(url); Map<String, List<String>> params = prepareParameters(requestUrl.getQuery()); String path = requestUrl.getPath(); if(!routes.containsKey(path)) { System.out.println("No service found for path '" + path + "'!!!"); return; } IServlet servlet = routes.get(path); PrintWriter output = new PrintWriter(System.out); System.out.println("Dispatching path '" + path + "'"); servlet.process(params, output); output.flush(); } catch (UnsupportedEncodingException e) { System.out.println("Encoding of your querystring is not supported. Expected UTF-8"); } }
d8a82888-114b-4a49-b13a-72707211f399
3
public void flipH() { for (Connector c : connectors) { if (c.getPosition() == Position.left) c.setPosition(Component.Position.right); else if (c.getPosition() == Position.right) c.setPosition(Position.left); } }
e82438a5-fd40-41b7-bc8c-7cd18c28d251
1
public List<Class<? extends Pet>> types() {return types;}
296778b7-3194-4d58-89fc-3b692a775916
0
@Override public void connectionLost(String message) { c = null; connectionSemaphore.acquireUninterruptibly(); System.out.println("[DcStation " + alias + "] Connection lost: " + message); }
241bdae7-2a40-4df6-8661-b41a3fb1dc28
0
public void setPcaSecuen(Integer pcaSecuen) { this.pcaSecuen = pcaSecuen; }
14b840c6-2517-4f6c-afeb-bf3064564113
3
private void be(String label) { if (verbose) System.out.println("(Branch? " + (acc == 0 ? "YES" : "NO") + ")"); if (acc == 0) index = branches.get(label) - 1; }
4d0c7a8a-b3a0-442d-a3e0-3ac955f2f586
0
public static void main(String[] args) { System.out.println(1 + 2); // 3 System.out.println(2 - 3); // -1 System.out.println(3 * 4); // 12 System.out.println(16 / 5); // 3 System.out.println(16 % 5); // 1 }
52e7da80-1aa8-4a4d-8215-8bd9cf194499
4
public Matrix plus(Matrix B) { Matrix A = this; if (B.M != A.M || B.N != A.N) throw new RuntimeException("Illegal matrix dimensions."); Matrix C = new Matrix(M, N); for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) C.data[i][j] = A.data[i][j] + B.data[i][j]; return C; }
7528a3ce-2e7e-4c59-8aaa-eefad9a33c2d
9
@Override public List<SearchResult<SequenceMatcher>> searchForwards(final WindowReader reader, final long fromPosition, final long toPosition) throws IOException { // Initialise: final int longestMatchEndPosition = sequences.getMaximumLength() - 1; long searchPosition = fromPosition > 0? fromPosition : 0; // While there is data to search in: Window window; while (searchPosition <= toPosition && (window = reader.getWindow(searchPosition)) != null) { // Does the sequence fit into the searchable bytes of this window? // It may not if the start position of the window is already close // to the end of the window, or the sequence is long (potentially // could be longer than any single window - but mostly won't be): final long windowStartPosition = window.getWindowPosition(); final int windowLength = window.length(); final int arrayStartPosition = reader.getWindowOffset(searchPosition); final int arrayLastPosition = windowLength - 1; if (arrayStartPosition + longestMatchEndPosition <= arrayLastPosition) { // Find the last point in the array where the sequence still fits // inside the array, or the toPosition if it is smaller. final int lastMatchingPosition = arrayLastPosition - longestMatchEndPosition; final long distanceToEnd = toPosition - windowStartPosition; final int arrayMaxPosition = distanceToEnd < lastMatchingPosition? (int) distanceToEnd : lastMatchingPosition; // Search forwards in the byte array of the window: final List<SearchResult<SequenceMatcher>> arrayResult = searchForwards(window.getArray(), arrayStartPosition, arrayMaxPosition); // Did we find a match? if (!arrayResult.isEmpty()) { final long readerOffset = searchPosition - arrayStartPosition; return SearchUtils.addPositionToResults(arrayResult, readerOffset); } // Continue the search one on from where we last looked: searchPosition += (arrayMaxPosition - arrayStartPosition + 1); // Did we pass the final toPosition? In which case, we're finished. if (searchPosition > toPosition) { return SearchUtils.noResults(); } } // From the current search position, the sequence could cross over in to // the next window, so we can't search directly in the window byte array. // We must use the reader interface on the sequence to let it match // over more bytes than this window potentially has available. // Search up to the last position in the window, or the toPosition, // whichever comes first: final long lastWindowPosition = windowStartPosition + arrayLastPosition; final long lastSearchPosition = toPosition < lastWindowPosition? toPosition : lastWindowPosition; final List<SearchResult<SequenceMatcher>> readerResult = doSearchForwards(reader, searchPosition, lastSearchPosition); // Did we find a match? if (!readerResult.isEmpty()) { return readerResult; } // Continue the search one on from where we last looked: searchPosition = lastSearchPosition + 1; } return SearchUtils.noResults(); }
b9c190a9-d23a-44f8-80aa-f706abb411ec
0
public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("[Sales:"); buffer.append(" id: "); buffer.append(id); buffer.append(" datetime: "); buffer.append(datetime); buffer.append(" total: "); buffer.append(total); buffer.append("]"); return buffer.toString(); }
1ebe5ade-c11a-471a-a3e8-64389839fe9e
7
@Nullable public Table loadTable(@NotNull String name) { if(tableCache.containsKey(name)) { return tableCache.get(name); } int ignore = 0; int attributesCount = 0; int firstPage = 0; List<Attribute> attributes = null; for(Record rec: table) { Map<SecondLevelId, Object> recAtributes = rec.getAttributes(); if(ignore != 0) { ignore -= 1; continue; } String currName = (String) recAtributes.get(NAME_ID); if(attributes != null) { attributesCount -= 1; Attribute.DataType type = integersToType(recAtributes); Attribute atr = new Attribute(currName, type); attributes.add(atr); if(attributesCount == 0) { Map<Attribute, BxTree> indexes = loadIndexes(name, attributes); Table result = new Table(bufferManager, firstPage, attributes, name, indexes); if(tableCache.size() == MAX_TABLE_CACHE_ITEMS) { tableCache.remove(tableCache.keySet().iterator().next()); } tableCache.put(name, result); return result; } continue; } if(!name .equals(currName)) { ignore = (Integer)recAtributes.get(VAL2_ID); continue; } attributes = new ArrayList<>(); attributesCount = (Integer)recAtributes.get(VAL2_ID); firstPage = (Integer)recAtributes.get(VAL1_ID); } return null; }
de2e83c5-a5a8-4a91-9532-5ce044b56c67
2
private Repository getRepositoryFork(GitHubClient gitHubClient, Repository masterRepository) throws IOException { Properties properties = ApplicationProperties.getProperties(); RepositoryService repositoryService = new RepositoryService(gitHubClient); List<SearchRepository> searchRepositories = repositoryService.searchRepositories( masterRepository.getName() + " user:" + properties.getProperty(PropertiesConstants.GITHUB_ANON_USERNAME) + " fork:only"); if (searchRepositories.isEmpty()) { logger.log(Level.INFO, "No anon fork of {0} found. Forking.", masterRepository.getName()); return forkAndWait(gitHubClient, masterRepository); } Release latestRelease = getLatestRelease(masterRepository); Repository repositoryFork = repositoryService.getRepository( properties.getProperty(PropertiesConstants.GITHUB_ANON_USERNAME), masterRepository.getName()); if (latestRelease.getPublishedAt().after(repositoryFork.getCreatedAt())) { // There's been a release on the master since we last forked, so delete and re-create logger.log(Level.INFO, "New release found since anon fork of {0} was created. Deleting and re-forking.", masterRepository.getName()); deleteAndWait(gitHubClient, repositoryFork); return forkAndWait(gitHubClient, masterRepository); } else { return repositoryFork; } }
5d41e2a5-2bd9-4346-8c34-56ec37422141
4
public ArrayList<Integer> getMostConstrainedMeeting() { HashMap<Integer, ArrayList<Integer>> slotsForMeetings = this.SlotsForMeetings; int minNumSlots = Integer.MAX_VALUE; ArrayList<Integer> meeting = new ArrayList<Integer>(); for(Integer key: slotsForMeetings.keySet()) { int numSlots = slotsForMeetings.get(key).size(); if( numSlots <= minNumSlots && !this.Assignment.containsKey(key)) { if(numSlots < minNumSlots) { meeting = new ArrayList<Integer>(); } minNumSlots = numSlots; meeting.add(key); } } return meeting; }
03b05d72-3e0f-4044-aac4-495630cd0b49
5
public AsciiImage execute(AsciiImage img) throws OperationException { AsciiImage newI = new AsciiImage(img); String[] lines = data.split("\n"); if(lines.length < img.getHeight()) { throw new OperationException("Not enough lines"); } for(int y = 0; y < lines.length; y++) { if(lines[y].length() < img.getWidth()) { throw new OperationException("Line too short"); } for(int x = 0; x < lines[y].length(); x++) { if(img.getCharset().indexOf(lines[y].charAt(x)) < 0) { throw new OperationException("Invalid character"); } newI.setPixel(x,y,lines[y].charAt(x)); } } return newI; }
a77deab1-981d-438a-a284-4e37667c1340
1
public void visiteurSuivant(){ int index = getVue().getjComboBoxVisiteur().getSelectedIndex()+1; if(index== getVue().getjComboBoxVisiteur().getItemCount())index=0; getVue().getjComboBoxVisiteur().setSelectedIndex(index); }
cb6b6300-f028-4a99-ac30-73834811ffb0
3
public Integer GetCount(Stone Color) { Integer retCnt = 0; Pos workPos = new Pos(); for (int x = Common.X_MIN_LEN; x < Common.X_MAX_LEN; x++) { workPos.setX(x); for (int y = Common.Y_MIN_LEN; y < Common.Y_MAX_LEN; y++) { workPos.setY(y); if (getColor(workPos) == Color) { retCnt++; } } } return retCnt; }
2eeaece3-5738-4f8a-b070-e78f638c9db3
1
public static String getAvailableTimeSlot(long[] aUid) { TimeSlotHelper helper = new TimeSlotHelper(DateUtil.getStartOfDay(TimeMachine.getNow() .getTime()), 5); for (long uid : aUid) { helper.removeByUser(uid); } return helper.toSentence(); }
39af9870-4d5e-43da-b96d-916c0bc83bb1
4
public void selectNextStream() { int selectedRow = table.getSelectedRow(); int numberOfStreams = controlStreams.getStreamVector().size(); //no stream is selected if(selectedRow == -1 && numberOfStreams > 0) { selectedRow = 0; } else if (selectedRow >= (numberOfStreams-1)) { selectedRow = 0; } else { selectedRow++; } try { table.getSelectionModel().setSelectionInterval(selectedRow, selectedRow); } catch (IllegalArgumentException e) { SRSOutput.getInstance().logE("Gui_TablePanel: Unable to select an row"); } }
4b1e91c6-aa44-4dfc-8fc3-ba4d43c8bc81
8
final public void AppExp() throws ParseException {/*@bgen(jjtree) AppExp */ SimpleNode jjtn000 = (SimpleNode)SimpleNode.jjtCreate(this, JJTAPPEXP); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(LEFTB); Expression(); Expression(); jj_consume_token(RIGHTB); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } }
e6ec84ea-13ad-4e49-aa3e-32d61c012cf4
0
public initiateRemoval() { this.requireLogin = true; this.addParamConstraint("id", ParamCons.INTEGER); this.addRtnCode(405, "permission denied"); }
0dc594b1-2603-431c-87c3-4e9d2586b32e
7
protected MOB getCharmer() { if(charmer!=null) return charmer; if((invoker!=null)&&(invoker!=affected)) charmer=invoker; else if((text().length()>0)&&(affected instanceof MOB)) { final Room R=((MOB)affected).location(); if(R!=null) charmer=R.fetchInhabitant(text()); } if(charmer==null) return invoker; return charmer; }
79783464-ee7c-4be7-a2ad-a8d6f8ba06e0
0
public void setPopTerminal(String popTerminal) { this.popTerminal = popTerminal; }
c25c42df-2a25-40be-958e-57af1b87f178
5
private static boolean is2Pawn(final ChessBoardEntity board, final ChessmenEntity c, final PositionEntity p) { boolean result = false; for (int y = 0; y < 9; y++) { ChessmenEntity cto = getChessmen(board, p.getX(), y); if (null != cto) { if (cto.isPlayer() && Type.Pawn == cto.getType() && !cto.isPromote()) { result = true; break; } } } return result; }
6b796a3d-93de-4cfd-ba9e-b2c2c4f3af69
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/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(ViewProduct.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ViewProduct.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ViewProduct.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ViewProduct.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ViewProduct().setVisible(true); } }); }
4543b1fb-28ac-4aeb-87e3-a133b0226fae
0
public void resume_ingress() { ++resume_ingress_count; }
61753c18-7187-4f96-9b7c-189851c3f393
7
private void resetZoomButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetZoomButtonActionPerformed diagramPanel.getScaleRatio()[0] = 1; diagramPanel.getScaleRatio()[1] = 1; diagramPanel.getScaleRatio()[0] = Math.max(0.3, getDiagramPanel().getScaleRatio()[0]); diagramPanel.getScaleRatio()[1] = Math.max(0.3, getDiagramPanel().getScaleRatio()[1]); int minX = Integer.MAX_VALUE; int minY = Integer.MAX_VALUE; int maxX = 0; int maxY = 0; Element e = null; Element e2 = null; ArrayList<Element> elements = new ArrayList<Element>(); if (this.graph instanceof PetriNet) { PetriNet pn = (PetriNet) this.graph; elements = new ArrayList<Element>(); elements.addAll(pn.getListOfArcs()); elements.addAll(pn.getListOfPlaces()); elements.addAll(pn.getListOfResources()); elements.addAll(pn.getListOfTransitions()); } if (this.graph instanceof PrecedenceGraph) { PrecedenceGraph pg = (PrecedenceGraph) this.graph; elements = new ArrayList<Element>(); elements.addAll(pg.getListOfArcs()); elements.addAll(pg.getListOfNodes()); } for (Element element : elements) { if (minX > element.getX()) { minX = element.getX(); e = element; } if (minY > element.getY()) { minY = element.getY(); e2 = element; } if (maxX < element.getX()) { maxX = element.getX(); } if (maxY < element.getY()) { maxY = element.getY(); } } int graphWidth = maxX - minX; int graphHeight = maxY - minY; int w = (int) (((this.diagramScrollPane.getWidth()/2)-(graphWidth/2))/this.getDiagramPanel().getScaleRatio()[0]); int h = (int) (((this.diagramScrollPane.getHeight()/2)-(graphHeight/2))/this.getDiagramPanel().getScaleRatio()[1]); int newX = (int) ((minX-w-50/this.getDiagramPanel().getScaleRatio()[0])*this.getDiagramPanel().getScaleRatio()[0]); int newY = (int) ((minY-h-50/this.getDiagramPanel().getScaleRatio()[0])*this.getDiagramPanel().getScaleRatio()[1]); this.diagramScrollPane.getViewport().setViewPosition(new java.awt.Point(newX,newY)); repaint(); }
63757f5d-90d6-4bcf-ae6f-d577c7e4d155
2
protected boolean isOfType(final Object object) { if (object instanceof CycList) { return parse((CycList) object, false) != null; } else if (object instanceof CycNaut) { return parse((CycNaut) object, false) != null; } else { return false; } }
054c6173-1f57-4f60-bfc1-b1f1199ab31c
7
public ListNode reverseBetween(ListNode head, int m, int n) { if(head == null || head.next == null) return head; ListNode preNode = new ListNode(0); preNode.next = head; ListNode ahead = head; ListNode current = head; for(int i=0; i<n-m; i++) ahead = ahead.next; for(int i=1; i<m; i++){ preNode = current; ahead = ahead.next; current = current.next; } boolean fromHead = false; if(current == head) fromHead = true; while(ahead != current){ ListNode tmp = ahead.next; ahead.next = current; preNode.next = current.next; current.next = tmp; current = preNode.next; } if(fromHead) return ahead; return head; }
db89c928-571c-446f-8ce5-73eaaf8906ae
5
@Override public Measurement add(Measurement m) { Connection conn = db.getConnection(); Vector<PreparedStatement> vps = new Vector<PreparedStatement>(); ResultSet rs = null; try { conn.setAutoCommit(false); int measurementId = HomeFactory.getMeasurementHome().executeInsertUpdate(vps, m); // wifi HomeFactory.getWiFiReadingVectorHome().executeUpdate(vps, m.getWiFiReadings(), measurementId); // gsm HomeFactory.getGSMReadingVectorHome().executeUpdate(vps, m.getGsmReadings(), measurementId); // bluetooth HomeFactory.getBluetoothReadingVectorHome().executeUpdate(vps, m.getBluetoothReadings(), measurementId); conn.commit(); return getById(measurementId); } catch (SQLException e) { log.log(Level.SEVERE, "add fingerprint failed: " + e.getMessage(), e); } finally { try { conn.setAutoCommit(true); if (rs != null) rs.close(); for(PreparedStatement p : vps) { if (p != null) p.close(); } } catch (SQLException es) { log.log(Level.WARNING, "failed to close statement: " + es.getMessage(), es); } } return null; }
517131a9-528d-452b-979f-a9b68332ea3e
0
public boolean getAlwaysDrawGrouting() { return alwaysDrawGrouting; }
6cc56d53-0276-4e39-ac3e-1509e6924b92
9
public Value unaryOperation(final AbstractInsnNode insn, final Value value) { int size; switch (insn.getOpcode()) { case LNEG: case DNEG: case I2L: case I2D: case L2D: case F2L: case F2D: case D2L: size = 2; break; case GETFIELD: size = Type.getType(((FieldInsnNode) insn).desc).getSize(); break; default: size = 1; } return new SourceValue(size, insn); }
bcb32bb3-db0f-4001-b482-7953ef32e36c
2
public final boolean isWalkable(final Point p) { final Point point = sanitizeCoordinates(p); if (point == null) { return false; } if (wall.contains(point)) { return false; } return true; }
aa41bedc-702e-4357-88e0-d185e29bcd9e
9
public static long S1() { // S1: No student writes more than one exam in a time slot. long numS1 = 0; for(Student s : Environment.get().students.objects()){ // TODO: this is slow, is there a better than N^2 way to check this? for(Lecture l1 : s.lectures){ if(l1.session == null) continue; for(Lecture l2 : s.lectures){ if(l2.session == null) continue; // lecture session days should not be null! assert l1.session.day != null; assert l2.session.day != null; // student attends two different lectures with exams on the same day if(l1 != l2 && l1.session.day.equals(l2.session.day)){ // lecture session times should never be null! assert l1.session.time != null; assert l2.session.time != null; if(l1.session.time <= l2.session.time){ // examlength cannot be null assert l1.examLength != null; // l1 exam overlaps with l2 exam, direct conflict if(l1.examLength + l1.session.time > l2.session.time){ numS1++; } } } } } } return numS1; }
ed930b9b-c520-455e-80f9-0ae156646d18
5
protected boolean yObstacleAhead(double time) { final int halfOfWidth = this.currentWidth / 2; for (StaticObject so : AppFrame.getFrameDesign().getStaticObjects()) { if (checkYObstacle(so, time, halfOfWidth)) { if (obstacleReaction(so)) { currentVerticalSpeed = 0; return true; } //return true; } } for (MovingObject mo : AppFrame.getFrameDesign().getMovingObjects()) { if (checkYObstacle(mo, time, halfOfWidth)) { obstacleReaction(mo); } } return false; }
61cf9638-0621-44b0-a668-8846f0516e7a
2
static private int[] permutation(int N) { int[] a = new int[N]; // insert integers 0..N-1 for (int i = 0; i < N; i++) { a[i] = i; } // shuffle for (int i = 0; i < N; i++) { int r = (int) (Math.random() * (i + 1)); // int between 0 and i int swap = a[r]; a[r] = a[i]; a[i] = swap; } return a; }
46266285-502f-44e9-8958-c127ff8eb843
7
static void scanJarForMatchingFiles(List<String> matchingFiles, File jarfile, Logger log) { try { JarFile jar = new JarFile(jarfile); Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { String name = entries.nextElement().toString(); if (name.endsWith(PACKAGE_INFO_CLASS)) { String className = name.substring(0, name.length() - DOT_CLASS.length()) .replaceAll(SLASH_REGEX, "."); if (log != null && log.isLoggable(FINEST)) { StringBuilder sb = new StringBuilder("scan found class "); sb.append(className); sb.append(" in jar "); sb.append(jarfile); log.log(FINEST, sb.toString()); } matchingFiles.add(className); } } } catch (Exception e) { if (log != null && log.isLoggable(SEVERE)) { log.log(SEVERE, "problem scanning jar for matching files", e); } } }
86295bec-3c05-470d-b5dc-5870f91d71b9
1
public Transform getTransform() { if ( parent != null ) return parent.getTransform(); return new Transform(); }
28f3236d-97b9-437d-8087-4a8967ea528b
8
public Frame11() { try{ Class.forName(JDBC_DRIVER); conn = DriverManager.getConnection(DB_URL,USER, PASS); statement = conn.createStatement(); }catch(SQLException se){ se.printStackTrace(); }catch(Exception e){ e.printStackTrace(); } setTitle("Blok E, 1 - 35"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 1123, 604); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); comboBox = new JComboBox(); comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (comboBox.getSelectedItem().equals("")){ textField.setText(""); textField_1.setText(""); textField_2.setText(""); textField_3.setText(""); textField_4.setText(""); textField_5.setText(""); isSelected = false; } else{ isSelected = true; String noRumah = (String) comboBox.getSelectedItem(); rumah = new Rumah(noRumah); String sql = "SELECT * FROM `tabel_rumah` WHERE noRumah='"+rumah.getNoRumah()+"';"; try { ResultSet rs = statement.executeQuery(sql); if (!rs.isBeforeFirst()){ System.out.println("Tabel Kosong"); } while(rs.next()){ rumah.setIDRumah(rs.getInt("idRumah")); rumah.setTipe(rs.getString("tipeRumah")); rumah.setLT(rs.getInt("LT")); rumah.LTAwal = rs.getInt("LTAwal"); rumah.setLB(rs.getInt("LB")); rumah.setHargaAwal(rs.getInt("HargaAwal")); rumah.setHargaNett(rs.getInt("HargaNett")); rumah.setIsBought(rs.getBoolean("isBought")); rumah.setIsEdited(rs.getBoolean("isEdited")); rumah.setIsLocked(rs.getBoolean("isLocked")); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } textField.setText(rumah.getTipe()); textField_1.setText(rumah.getNoRumah()); textField_3.setText(rumah.getStrLT()); textField_2.setText(rumah.getStrLB()); textField_4.setText(rumah.getStrHN()); textField_5.setText(rumah.getStrIsBought(rumah.getIsBought())); } } }); comboBox.setFont(new Font("Tahoma", Font.PLAIN, 12)); comboBox.setModel(new DefaultComboBoxModel(new String[] {"", "E-1", "E-2", "E-3", "E-4", "E-5", "E-6", "E-7", "E-8", "E-9", "E-10", "E-11", "E-12", "E-14", "E-15", "E-16", "E-17", "E-18", "E-19", "E-20", "E-21", "E-22", "E-23", "E-24", "E-25", "E-26", "E-27", "E-28", "E-29", "E-30", "E-31", "E-32", "E-33", "E-34", "E-35"})); comboBox.setBounds(332, 399, 63, 20); contentPane.add(comboBox); JPanel panel = new JPanel(); panel.setLayout(null); panel.setBorder(new LineBorder(new Color(0, 0, 0))); panel.setBounds(428, 394, 179, 158); contentPane.add(panel); JLabel label = new JLabel("Kavling"); label.setBounds(10, 11, 46, 14); panel.add(label); JLabel label_1 = new JLabel("No Rumah"); label_1.setBounds(10, 33, 55, 14); panel.add(label_1); JLabel label_2 = new JLabel("LB"); label_2.setBounds(10, 80, 55, 14); panel.add(label_2); JLabel label_3 = new JLabel("LT"); label_3.setBounds(10, 58, 46, 14); panel.add(label_3); JLabel label_4 = new JLabel("Harga"); label_4.setBounds(10, 105, 55, 14); panel.add(label_4); JLabel label_5 = new JLabel("Status"); label_5.setBounds(10, 130, 55, 14); panel.add(label_5); textField = new JTextField(); textField.setText((String) null); textField.setColumns(10); textField.setBounds(71, 8, 98, 20); panel.add(textField); textField_1 = new JTextField(); textField_1.setText((String) null); textField_1.setColumns(10); textField_1.setBounds(71, 30, 98, 20); panel.add(textField_1); textField_2 = new JTextField(); textField_2.setText((String) null); textField_2.setColumns(10); textField_2.setBounds(71, 77, 98, 20); panel.add(textField_2); textField_3 = new JTextField(); textField_3.setText((String) null); textField_3.setColumns(10); textField_3.setBounds(71, 55, 98, 20); panel.add(textField_3); textField_4 = new JTextField(); textField_4.setText((String) null); textField_4.setColumns(10); textField_4.setBounds(71, 105, 98, 20); panel.add(textField_4); textField_5 = new JTextField(); textField_5.setColumns(10); textField_5.setBounds(71, 127, 98, 20); panel.add(textField_5); JLabel lblPilihanRumah = new JLabel("Pilihan Rumah :"); lblPilihanRumah.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblPilihanRumah.setBounds(217, 401, 90, 14); contentPane.add(lblPilihanRumah); JButton btnNewButton = new JButton("Kembali ke Peta Awal"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setVisible(false); PetaAwal frame = new PetaAwal(); frame.setVisible(true); } }); btnNewButton.setBounds(656, 436, 172, 30); contentPane.add(btnNewButton); JButton btnNewButton_1 = new JButton("Masuk ke Menu Rumah"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (isSelected){ MainRumah.noRumahDariPeta = rumah.getNoRumah(); setVisible(false); MainRumah frameMain = new MainRumah(); frameMain.setVisible(true); } else if (!isSelected){ JOptionPane.showMessageDialog(null, "Rumah belum dipilih, silahkan pilih terlebih dahulu"); } } }); btnNewButton_1.setBounds(656, 395, 173, 30); contentPane.add(btnNewButton_1); JLabel lblNewLabel = new JLabel(""); lblNewLabel.setIcon(new ImageIcon(Frame11.class.getResource("/gambar/Frame 11.jpg"))); lblNewLabel.setBounds(10,33,1100, 350); contentPane.add(lblNewLabel); JLabel labelKeterangan = new JLabel("Blok E, 1 - 35"); labelKeterangan.setHorizontalAlignment(SwingConstants.CENTER); labelKeterangan.setFont(new Font("Monospaced", Font.BOLD, 20)); labelKeterangan.setBounds(10, 0, 1087, 41); contentPane.add(labelKeterangan); }
b7de0982-4166-4e66-97ff-efedebdd2b4a
8
@Override public void update() { if (attributes.get(primaryKey) == null) { throw new NullPointerException("Can't update a non inserted object"); } StringBuilder sb = new StringBuilder("UPDATE "); sb.append(tableName).append(" SET "); StringBuilder where = new StringBuilder(" WHERE "); where.append(getPrimaryKeyColumn()).append(" = ?"); List<Object> values = new ArrayList<Object>(); for (Map.Entry<String, Object> e : attributes.entrySet()) { String key = e.getKey(); Object value = e.getValue(); if (!(key.equals(primaryKey)) && !(value instanceof List) && !(value instanceof JavaRecord) && (value != null)) { sb.append(", ").append(key); sb.append(" = "); sb.append("?"); values.add(value); } } String update = sb.toString().replaceFirst(",", ""); update += where.toString(); PreparedStatement smt = database.getPreparedStatement(update); int index = 0; try { for (index = 1; index <= values.size(); index++) { SQLUtil.addParameter(smt, index, values.get(index - 1)); } SQLUtil.addParameter(smt, index, attributes.get(primaryKey)); smt.execute(); smt.close(); smt = null; } catch (SQLException ex) { throw new SQLGeneratorException(ex.getMessage(), ex); } }
2cc2b74a-6a39-405c-92a8-57adfbc8cffc
9
private void cargarSetAprendizaje(){ DefaultTableModel temp = (DefaultTableModel) this.tablaSetAprendizaje.getModel(); String csvFile = "dataset/diabetes_aprendizaje_quickpropagation.csv"; BufferedReader br = null; String line = ""; String cvsSplitBy = ","; try { double maximo0 = normalizacion.obtenerMaximo(0, csvFile); double maximo1 = normalizacion.obtenerMaximo(1, csvFile); double maximo2 = normalizacion.obtenerMaximo(2, csvFile); double maximo3 = normalizacion.obtenerMaximo(3, csvFile); double maximo4 = normalizacion.obtenerMaximo(4, csvFile); double maximo5 = normalizacion.obtenerMaximo(5, csvFile); double maximo6 = normalizacion.obtenerMaximo(6, csvFile); double maximo7 = normalizacion.obtenerMaximo(7, csvFile); double minimo0 = normalizacion.obtenerMinimo(0, csvFile); double minimo1 = normalizacion.obtenerMinimo(1, csvFile); double minimo2 = normalizacion.obtenerMinimo(2, csvFile); double minimo3 = normalizacion.obtenerMinimo(3, csvFile); double minimo4 = normalizacion.obtenerMinimo(4, csvFile); double minimo5 = normalizacion.obtenerMinimo(5, csvFile); double minimo6 = normalizacion.obtenerMinimo(6, csvFile); double minimo7 = normalizacion.obtenerMinimo(7, csvFile); br = new BufferedReader(new FileReader(csvFile)); while ((line = br.readLine()) != null) { String[] patron = line.split(cvsSplitBy); if(normalizar.equals("NO")){ Object nuevo[]= {"-1", patron[0], patron[1], patron[2], patron[3], patron[4], patron[5], patron[6], patron[7], patron[8]}; temp.addRow(nuevo); }else if(normalizar.equals("MAX")){ Object nuevo[]= { "-1", String.valueOf(Double.valueOf(patron[0])/maximo0), String.valueOf(Double.valueOf(patron[1])/maximo1), String.valueOf(Double.valueOf(patron[2])/maximo2), String.valueOf(Double.valueOf(patron[3])/maximo3), String.valueOf(Double.valueOf(patron[4])/maximo4), String.valueOf(Double.valueOf(patron[5])/maximo5), String.valueOf(Double.valueOf(patron[6])/maximo6), String.valueOf(Double.valueOf(patron[7])/maximo7), patron[8] }; temp.addRow(nuevo); }else if(normalizar.equals("MAX/MIN")){ Object nuevo[]= { "-1", String.valueOf((double)(Double.valueOf(patron[0])-minimo0)/(double)(maximo0-minimo0)), String.valueOf((double)(Double.valueOf(patron[1])-minimo1)/(double)(maximo1-minimo1)), String.valueOf((double)(Double.valueOf(patron[2])-minimo2)/(double)(maximo2-minimo2)), String.valueOf((double)(Double.valueOf(patron[3])-minimo3)/(double)(maximo3-minimo3)), String.valueOf((double)(Double.valueOf(patron[4])-minimo4)/(double)(maximo4-minimo4)), String.valueOf((double)(Double.valueOf(patron[5])-minimo5)/(double)(maximo5-minimo5)), String.valueOf((double)(Double.valueOf(patron[6])-minimo6)/(double)(maximo6-minimo6)), String.valueOf((double)(Double.valueOf(patron[7])-minimo7)/(double)(maximo7-minimo7)), patron[8] }; temp.addRow(nuevo); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (IndexOutOfBoundsException e) { System.out.println("Error accediendo al csv"); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } }
2547a0d3-9ac9-4fd7-a482-4cd0d79290fc
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/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Resultat.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Resultat.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Resultat.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Resultat.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the dialog */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { /* Resultat dialog = new Resultat(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); */ } }); }
acf35d80-9e71-4663-ab30-22027e4fea10
8
private boolean satisfyNEGATE(Variable v0, Variable v1, Trail trail) { IntDomain d0 = (IntDomain) v0.getDomain(); IntDomain d1 = (IntDomain) v1.getDomain(); if (d1.size() == 1) { // v0 = -v1 int value = -d1.value(); if (!d0.contains(value)) return false; if (d0.size() > 1) v0.updateDomain(new IntDomain(value), trail); return true; } else if (d0.size() == 1) { // v1 = -v0 int value = -d0.value(); if (!d1.contains(value)) return false; if (d1.size() > 1) v1.updateDomain(new IntDomain(value), trail); return true; } // v0 = -v1 d0 = d0.capInterval(-d1.max(), -d1.min()); if (d0.isEmpty()) return false; v0.updateDomain(d0, trail); // v1 = -v0 d1 = d1.capInterval(-d0.max(), -d0.min()); if (d1.isEmpty()) return false; v1.updateDomain(d1, trail); return true; }
a85655b5-e3bc-4469-b293-43ab34273f60
3
public JSONObject putOnce(String key, Object value) throws JSONException { if (key != null && value != null) { if (this.opt(key) != null) { throw new JSONException("Duplicate key \"" + key + "\""); } this.put(key, value); } return this; }
ebf4893e-4e8c-4684-9043-2094b0245c14
3
public JMenuItem createOpenItem() { open = new JMenuItem("Open"); open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); open.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (!(w == null)) { JPanel panel = new JPanel(); JLabel label = new JLabel("Insert password "); JPasswordField pass = new JPasswordField(15); panel.add(label); panel.add(pass); int op = JOptionPane.showConfirmDialog(null, panel, "Password", JOptionPane.OK_CANCEL_OPTION); if (op == JOptionPane.YES_OPTION) { if (pass.getText().equals(w.getPassword())) { addWalletMenu(w); open.setEnabled(false); isOpen = true; revalidate(); } else { JOptionPane.showMessageDialog(null, "Wrong Password!"); } } } else { JOptionPane.showMessageDialog(null, "Wallet not created yet !", "Error", JOptionPane.OK_OPTION); } } }); open.setEnabled(false); return open; }
12d3dabd-511a-43e9-b20c-6423cd336b59
6
public void clearship () { switch (this.dir) { case 0: { if (!this.invalid) for (j=this.y1;j<this.y2;j++) { Battleship.getPlayers(Battleship.getYou()).setBboard(this.x1,j,null); Battleship.getPlayers(Battleship.getYou()).setHitOrMiss(this.x1,j,false); Battleship.getPlayers(Battleship.getYou()).setWhatShip(this.x1,j," "); } } break; case 1: { if (!this.invalid) for (i=this.x1;i<this.x2;i++) { Battleship.getPlayers(Battleship.getYou()).setBboard(i,this.y1,null); Battleship.getPlayers(Battleship.getYou()).setHitOrMiss(i,this.y1,false); Battleship.getPlayers(Battleship.getYou()).setWhatShip(i,this.y1," "); } } break; } }
5ae4b9d2-7c5d-4324-8469-ce1623f09858
9
public static ListNode insertionSortList(ListNode head) { if (head == null || head.next == null) return head; ListNode newHead = new ListNode(head.val); ListNode pointer = head.next; // loop through each element in the list while (pointer != null) { // insert this element to the new list ListNode innerPointer = newHead; ListNode next = pointer.next; //头指针的情况 if (pointer.val <= newHead.val) { ListNode oldHead = newHead; newHead = pointer; newHead.next = oldHead; } else { while (innerPointer.next != null) { if (pointer.val > innerPointer.val && pointer.val <= innerPointer.next.val) { ListNode oldNext = innerPointer.next; innerPointer.next = pointer; pointer.next = oldNext; } innerPointer = innerPointer.next; } if (innerPointer.next == null && pointer.val > innerPointer.val) { innerPointer.next = pointer; pointer.next = null; } } // finally pointer = next; } return newHead; }
2ca37169-2b05-4f44-96fb-0cbdfffbf2d2
8
public void addPedestrian(){ int n = rand.nextInt(4); int m = rand.nextInt(2); switch(n){ case Pedestrian.GO_DOWN: if(m==0) pedestrians.add(new Pedestrian(260, 0, Pedestrian.GO_DOWN)); else pedestrians.add(new Pedestrian(412, 0, Pedestrian.GO_DOWN)); break; case Pedestrian.GO_UP: if(m==0) pedestrians.add(new Pedestrian(260, 700, Pedestrian.GO_UP)); else pedestrians.add(new Pedestrian(412, 700, Pedestrian.GO_UP)); break; case Pedestrian.GO_RIGHT: if(m==0) pedestrians.add(new Pedestrian(0, 265, Pedestrian.GO_RIGHT)); else pedestrians.add(new Pedestrian(0, 410, Pedestrian.GO_RIGHT)); break; case Pedestrian.GO_LEFT: if(m==0) pedestrians.add(new Pedestrian(700, 265, Pedestrian.GO_LEFT)); else pedestrians.add(new Pedestrian(700, 410, Pedestrian.GO_LEFT)); break; } }
d12227ef-17ec-4590-b087-c254d0df2f97
6
public void close() throws IOException { if(r != null) { r = null; ogg.close(); ogg = null; } if(w != null) { w.bufferPacket(info.write(), true); w.bufferPacket(tags.write(), false); long lastGranule = 0; for(SpeexAudioData vd : writtenPackets) { // Update the granule position as we go if(vd.getGranulePosition() >= 0 && lastGranule != vd.getGranulePosition()) { w.flush(); lastGranule = vd.getGranulePosition(); w.setGranulePosition(lastGranule); } // Write the data, flushing if needed w.bufferPacket(vd.write()); if(w.getSizePendingFlush() > 16384) { w.flush(); } } w.close(); w = null; ogg.close(); ogg = null; } }
57d1113c-0aee-46ca-91b5-f1b2993e5fce
8
public static void abundantOTUToSparseThreeColumn(String abundantOTUClust, String outFile, HashMap<String, String> sequenceToSampleMap) throws Exception { File in = new File(abundantOTUClust); BufferedReader reader = abundantOTUClust.toLowerCase().endsWith("gz") ? new BufferedReader(new InputStreamReader( new GZIPInputStream( new FileInputStream( in) ) )) : new BufferedReader(new FileReader(in)); BufferedWriter writer = new BufferedWriter(new FileWriter(outFile)); String nextLine = reader.readLine(); while(nextLine != null) { if( ! nextLine.startsWith("#Consensus")) throw new Exception("Unexpected first line " + nextLine); HashMap<String, Integer> countMap = new HashMap<String, Integer>(); StringTokenizer sToken = new StringTokenizer(nextLine, " \t="); sToken.nextToken(); String otuName = sToken.nextToken(); System.out.println(otuName); sToken.nextToken(); sToken.nextToken(); Integer.parseInt(sToken.nextToken()); nextLine = reader.readLine(); while( nextLine != null && ! nextLine.startsWith("#Consensus")) { sToken = new StringTokenizer(nextLine); sToken.nextToken(); sToken.nextToken(); String seqID = sToken.nextToken(); String sampleId = sequenceToSampleMap.get(seqID); if( sampleId == null) throw new Exception("could not find " + sampleId); Integer count = countMap.get(sampleId); if( count == null) count =0; count++; countMap.put(sampleId, count); nextLine = reader.readLine(); } for(String s : countMap.keySet()) { writer.write(s + "\t" + otuName + "\t" + countMap.get(s) + "\n"); } writer.flush(); } writer.flush(); writer.close(); }
120675e8-ea10-417a-812b-802e78882652
9
protected String stripData(StringBuffer str, String div) { final StringBuffer data = new StringBuffer(""); while(str.length()>0) { if(str.length() < div.length()) return null; for(int d=0;d<=div.length();d++) { if(d==div.length()) { str.delete(0,div.length()); return data.toString(); } else if(str.charAt(d)!=div.charAt(d)) break; } if(str.charAt(0)=='\n') { if(data.length()>0) return data.toString(); return null; } data.append(str.charAt(0)); str.delete(0,1); } if((div.charAt(0)=='\n') && (data.length()>0)) return data.toString(); return null; }
96ed7147-8fc0-4fa8-ac45-63261469aeb5
9
protected ESBLogUtils(Class<?> clazz) { if (!ESBServerContext.isProductMode()) { StackTraceElement[] ste = Thread.currentThread().getStackTrace(); String className = ste[3].getClassName(); Class<?> callClazz = null; try { callClazz = Class.forName(className); } catch (ClassNotFoundException ex) { } if (ClassUtils.isAbstract(callClazz) || callClazz.isInterface()) { // 跳过抽象类和接口的检查 } else if (callClazz != clazz && callClazz.isAssignableFrom(clazz)) { // 跳过Abstract类的日志对象检查 } else if (!className.equals(clazz.getName())) { StringBuilder msg = new StringBuilder(100); msg.append("UT-14001:类").append(className).append("第").append(ste[3].getLineNumber()).append("行") .append("创建日志输出对象的参数不是当前类"); throw new IllegalArgumentException(msg.toString()); } } this.log = new ESBBaseLogger(clazz); }
6e4581bb-d7c0-4221-9751-cb9a7157d169
9
@Override public void processLine(InOutParam inOutParam) { //Prepare output LineOutput lineOut = new LineOutput(); try { //Remove "is" and "?" String formattedLine = this.line.split("(\\sis\\s)")[1]; formattedLine = formattedLine.replace("?","").trim(); // search for all numerals for their values to compute the result String[] keys = formattedLine.split("\\s"); boolean isPresent = false; //To track if key is present in the defined maps StringBuffer romanBuff = new StringBuffer(); //To track the roman numbers in the string String errorMessage = null; //Just in case an error is found Stack<Double> computedValues = new Stack<Double>(); //Stack to keep track of computed variables in the string for(String key : keys) { //First look for the presence of key in assigned value map. If present it is a roman number isPresent = false; String romanValue = inOutParam.getAssignedValue(key); if(romanValue!=null) { romanBuff.append(romanValue); isPresent = true; } //If not found in assigned value map, then verify computed value map. If found add it to the stack. Double computedValue = inOutParam.getCalculatedValue(key); if(!isPresent && computedValue !=null) { computedValues.push(computedValue); isPresent = true; } if(!isPresent){ errorMessage = ErrorMessage.NO_IDEA_ABOUT_INPUT.getValue(); break; } } if(isPresent){ double netCalculatedValue = 1D; //Traverse the stack of computed variables and determine the actual worth of it. This is helpful in case we have more than two computed variables in the string for(int index = 0; index < computedValues.size(); index++){ netCalculatedValue *= computedValues.get(index); } //Let us get the integer worth of it int netCredits = (int) netCalculatedValue; //If roman numbers are present, then multiply its worth by the calculated worth of computed variables if(romanBuff.length() > 0){ netCredits = (int)(RomanNumber.convertRomanToArabic(romanBuff.toString()) * netCalculatedValue); } //Set output lineOut.setLineKey(formattedLine); lineOut.setLineValue(netCredits); lineOut.setCredits(true); } else{ lineOut.setError(true); lineOut.setErrorMessage(errorMessage); } inOutParam.addToOutputList(lineOut); } catch(Exception e){ ApplicationUtilities.print(ErrorMessage.INCORRECT_LINE_INPUT.getValue() + ApplicationConstant.COLON + line); } }
619007ea-1c71-4032-b36a-d291fcfe4c8b
4
Module removeCommand(String name) { if (null == this.commands || StringUtils.isEmpty(name)) { return this; } if (null != this.commands.remove(name) && this.commands.isEmpty()) { this.commands = null; } return this; }
10fc21af-93d6-4033-b3be-db6e2ea8608f
7
@Override public String getPageTitle() { String title = ""; if ((this.id >= 1) && (this.id <= 5)) { title = " - partner projektu Bezpečné paneláky"; } if (this.id == 4) { title = " - elektrikár - Bratislava"; } if ((this.id == 12) || (this.id == 18)) { title = " - dodávateľ bleskozvodov - Bezpečné paneláky"; } if (this.isManager()) { title = " - správa bytových domov - Bezpečné paneláky"; } if (title.length() == 0) { title = " - Bezpečné paneláky"; } title = this.getName() + title; return title; }
256aa872-c8d4-4010-9641-23a4e699d73a
2
public void run(boolean wait) { // Create an Akka system ActorSystem workQueue = ActorSystem.create("vcfWorkQueue"); // Create the master ActorRef master; if (masterClazz != null) master = workQueue.actorOf(new Props(masterClazz), "masterVcf"); else master = workQueue.actorOf(masterProps, "masterVcf"); // Start processing master.tell(new StartMasterVcf(fileName, batchSize, showEvery)); // Wait until completion if (wait) workQueue.awaitTermination(); }
a7b0dcf7-6683-493e-94ca-79b33555e55f
5
private Point chooseRandomLocation() { Point randomLocation; ArrayList<Point> listOfEmptyLocations = new ArrayList<>(); Player[][] locations = this.board.getBoardLocations(); // create list of empty locations for (int row = 0; row < locations.length; row++) { Player[] rowLocations = locations[row]; for (int col = 0; col < rowLocations.length; col++) { Player location = rowLocations[col]; if (location == null) { // location not occupied? listOfEmptyLocations.add(new Point(row, col)); } } } int noOfEmptyLocations = listOfEmptyLocations.size(); if (noOfEmptyLocations == 0) { // no empty locations? return null; } else if (listOfEmptyLocations.size() == 1) { // only one empty location? randomLocation = listOfEmptyLocations.get(0); return randomLocation; } else { // randomly choose one of the empty locations int randomNumber = new Random().nextInt(noOfEmptyLocations); randomLocation = listOfEmptyLocations.get(randomNumber); return randomLocation; } }
9c8fd64f-28b0-4d2f-962f-7b9feff8e548
0
public String getIsKey() { return isKey; }
ebd8e74e-8866-4f78-b942-2c6f10a18be2
3
public char nextClean() throws JSONException { for (;;) { char c = next(); if (c == 0 || c > ' ') { return c; } } }
64f00b16-76a5-43a4-897b-d14dbf1457d6
4
public void stopMoving(Direction dir) { boolean foundDir = false; for(int i = 0; i < queuedMoveDirectionPreferences.length - 1; i++) { if(!foundDir && queuedMoveDirectionPreferences[i] == dir) foundDir = true; if(foundDir) queuedMoveDirectionPreferences[i] = queuedMoveDirectionPreferences[i + 1]; } queuedMoveDirectionPreferences[queuedMoveDirectionPreferences.length - 1] = null; }
501bdb2f-1708-4a49-bfd6-c78b606b34a9
8
private static void handleMoveType3(PGNMove move, String strippedMove, byte color, byte[][] board) throws PGNParseException { byte piece = WHITE_PAWN; int fromhPos = getChessATOI(strippedMove.charAt(1)); int tohPos = getChessATOI(strippedMove.charAt(2)); int tovPos = strippedMove.charAt(3) - '1'; int fromvPos = -1; if (strippedMove.charAt(0) == PAWN.charAt(0)) { piece = (byte)(BLACK_PAWN * color); fromvPos = getPawnvPos(fromhPos, tovPos, piece, board); } else if (strippedMove.charAt(0) == KNIGHT.charAt(0)) { piece = (byte)(BLACK_KNIGHT * color); fromvPos = getSingleMovePiecevPos(tohPos, tovPos, fromhPos, piece, board, KNIGHT_SEARCH_PATH); } else if (strippedMove.charAt(0) == BISHOP.charAt(0)) { piece = (byte)(BLACK_BISHOP * color); fromvPos = getMultiMovePiecevPos(tohPos, tovPos, fromhPos, piece, board, BISHOP_SEARCH_PATH); } else if (strippedMove.charAt(0) == ROOK.charAt(0)) { piece = (byte)(BLACK_ROOK * color); fromvPos = getMultiMovePiecevPos(tohPos, tovPos, fromhPos, piece, board, ROOK_SEARCH_PATH); } else if (strippedMove.charAt(0) == QUEEN.charAt(0)) { piece = (byte)(BLACK_QUEEN * color); fromvPos = getMultiMovePiecevPos(tohPos, tovPos, fromhPos, piece, board, QUEEN_KING_SEARCH_PATH); } else if (strippedMove.charAt(0) == KING.charAt(0)) { piece = (byte)(BLACK_KING * color); fromvPos = getSingleMovePiecevPos(tohPos, tovPos, fromhPos, piece, board, QUEEN_KING_SEARCH_PATH); } if (fromvPos == - 1 || fromhPos == -1) { throw new PGNParseException(move.getFullMove()); } move.setFromSquare(getChessCoords(fromhPos, fromvPos)); move.setToSquare(getChessCoords(tohPos, tovPos)); }
24287c79-a9ed-4579-bd52-9237cac976cf
1
public List<String> tableNames(String schema) throws SQLException { ArrayList result = new ArrayList(); ResultSet rs = statement.executeQuery(String.format(getTableStatement, schema)); while (rs.next()) { result.add(rs.getString(1)); } return result; }
a2c0b3b2-c884-4ace-9863-99062e6ff999
3
public void setTarget(Slot target) { switch (destAction) { case (DEST_VISIBLE_TRUE): { component.setVisible(false); break; } case (DEST_VISIBLE_FALSE): { component.setVisible(true); break; } } if (this.target != null) { this.target.unSocket(); } this.target = target; reset(); }
a735f988-4dbd-4b1a-a989-61fd81637967
1
public void addShow(Show show){ if (show instanceof Movie){ movies.add((Movie) show); }else{ theatricals.add((Theatrical) show); } }
40cdd400-5310-4ce9-8dc5-4035b7a7bdde
2
public String useItem(int itemSlot) { if(inventory.hasItem(itemSlot)) { if(inventory.getItem(itemSlot).getRoomUsedIn() == currentRoom) { String ret = inventory.getItem(itemSlot).getUsedDescription(); inventory.removeItem(itemSlot); currentRoom.itemUsed(); itemRemoved = true; return ret; } return "You cannot use this item here"; } return "You don't have an item in that slot!"; }
69f4fea4-d12d-4704-aa70-a1911d04c5ec
0
public int getDepartmentId() { return departmentId; }
c2af385f-1571-4392-b6bc-1af41f360b5b
5
public void firstDeal() { this.dealerHand = new Hand(shoe.dealCard(), shoe.dealCard()); System.out .println("===================================================="); System.out.println(">Dealer's visible card is: " + dealerHand.getHand().get(1).toString()); System.out.println("TESTING: DEALER'S SECOND CARD - " + dealerHand.getHand().get(0).toString()); player.clearHand(); System.out.println(">Dealing cards to player..."); System.out .println("===================================================="); player.hit(shoe.dealCard()); player.hit(shoe.dealCard()); System.out.println(player.toString()); if (player.getBank() - (2 * player.getBet()) > 0) { System.out .println("\n>Would you like to double down now?(y/n) You have " + player.getBankString() + " remaining"); String answer = stringInput.nextLine(); answer.toLowerCase(); try { if (answer.equals("y")) { player.doubleDown(); } } catch (IllegalStateException e) { e.getMessage(); e.printStackTrace(); } } if (player.getHand().getHandValue() == 21) { dealerStand(); } else if (dealerHand.getHand().get(1).getRank().equals("Ace")) { player.insurance(); playerTurn(); } else { playerTurn(); } }
25530ea6-5fb4-4f2b-9b62-ee7f4b4e4c50
4
private void diceButtonListeners() { diceButton.addMouseMotionListener(genericMouseMotionListener); diceButton.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { BufferedImage buttonImage; try{ if(theBookLayout == 2){ buttonImage = ImageIO.read(new File("resources/buttons2/DiceButton.png")); } else { buttonImage = ImageIO.read(new File("resources/buttons/DiceButton.png")); } Image scaledButton = buttonImage.getScaledInstance(100,100,java.awt.Image.SCALE_SMOOTH); diceButton.setIcon(new ImageIcon(scaledButton)); }catch (IOException ex){ } diceButton.repaint(); } @Override public void mouseEntered(MouseEvent e) { BufferedImage buttonImage; try{ if(theBookLayout == 2){ buttonImage = ImageIO.read(new File("resources/buttons2/DiceButtonHover.png")); } else { buttonImage = ImageIO.read(new File("resources/buttons/DiceButtonHover.png")); } Image scaledButton = buttonImage.getScaledInstance(100,100,java.awt.Image.SCALE_SMOOTH); diceButton.setIcon(new ImageIcon(scaledButton)); }catch (IOException ex){ } diceButton.repaint(); } @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub } }); }
d8c48c0c-5656-4983-be47-f501113bf5d5
4
public static void initialMgrsDisplay() { System.out.println("You've entered the Manager's verification."); LoginDisplay.username(); Employee employee = LoginDisplay.getLoggedInEmployee(); if (employee.getAccessLevel().equalsIgnoreCase("Manager")) { System.out.print("Would you like Employee Management (Employee), Inventory Management (Inventory), " + "Exit?: "); String managersChoice = sc.nextLine(); switch (managersChoice.toUpperCase()) { case "EMPLOYEE": System.out.println("You selected Employee Management"); ManagersDisplay.employeeMenu(); break; case "INVENTORY": System.out.println("You selected Inventory"); ManagersDisplay.inventoryMenu(); break; case "EXIT": System.out.println(); InitialSalesDisplay.initialDisplay(); break; default: System.out.println("Please enter a valid option."); initialMgrsDisplay(); break; } InitialSalesDisplay.initialDisplay(); } else { System.out.println("You are not allowed to access this menu."); InitialSalesDisplay.initialDisplay(); } }
e8e0ed5e-27d4-4e07-b71b-4d03f6b00655
2
public boolean peutConsulter(Utilisateur utilisateur) { return (utilisateur != null && utilisateur.getRole().getValeur() >= getConsultationRoleMinimum().getValeur()) || getConsultationRoleMinimum() == Role.Visiteur; }
88090354-b38e-4460-a9cf-e968e950a623
0
@After public void tearDown() { }
65996183-de0c-4a36-912e-2174ec8484e0
9
@Override public void printApplication(Employee employee, HttpServletResponse httpServletResponse, XMLGenerator xmlGenerator, Map<String, String[]> parameterMap, HttpSession httpSession) { udane = false; String selectedOperation = null; if (parameterMap.get("Dalej") != null) { selectedTableName = parameterMap.get("tabliceSlownikowe")[0]; selectedOperation = parameterMap.get("operacje")[0]; if (selectedOperation.equals(dictionaryTablesOperations[0])) { generateAddDataForm(xmlGenerator); } else if (selectedOperation.equals(dictionaryTablesOperations[1])) { generateEditDataForm(xmlGenerator); } else if (selectedOperation.equals(dictionaryTablesOperations[2])) { generateDeleteDataForm(xmlGenerator); } } if (parameterMap.get("Dodaj") != null) { validateAndNormalizeData(parameterMap); if (formErrorsList.isEmpty()) // jeżeli nie ma błędów to można wpisać dane do bazy { addData(); } else { printFormErrors(xmlGenerator); } } else if (parameterMap.get("Edytuj") != null) { editData(parameterMap); } if (parameterMap.get("Kasuj") != null) { deleteData(parameterMap); } if (!udane) { generateDictionaryTablesForm(xmlGenerator); } }
1c390876-801f-4092-a61d-e4ecc2e26473
1
@Override public Object getRoot() { if (document == null) return null; return new XMLNodeWrapper(document.getRootElement()); }
771c7c02-a962-48e4-b3a5-60ab6566b9bb
0
private void handlePotentialConflicts(double[][] costs, int[] assigns, SegmentedImage A, SegmentedImage B){ //TODO: test some constants List<MergeCell> merges = detectPotentialMerge(costs, assigns, A, B, .9); List<SplitCell> splits = detectPotentialSplit(costs, assigns, A, B, .9); //TODO: finish method }
9854bf8e-45f5-4e3d-ba19-b56f346c25cc
1
public String getReturnType() { return returnType == null ? null : returnType.toString(); }
23a2a1d6-4490-4d68-aee3-f6b13f6a0666
6
public static void main(String[] args) throws Exception { try { if (args.length > 0) Logger.setActivated(Integer.parseInt(args[0]) != 0); if (args.length > 1) Logger.setLogSuffix(args[1]); } catch (NumberFormatException e) { } try { Reader reader = new Reader(); while (true) { reader.read(); } } catch (Exception e) { if (Logger.isActivated()) Logger.printException(e); else throw e; } }
0fc042b1-6573-4210-b986-f63dd6d08950
2
public static String getKeyFromLock(String item) throws IOException{ String lock = sanitizeKey(item,1); int len = lock.length(); //computing the key String key = ""+(char)(lock.charAt(0) ^ lock.charAt(len-1) ^ lock.charAt(len-2) ^ 5); for (int i = 1; i < len; i++){ key += lock.charAt(i) ^ lock.charAt(i-1); } char[] newchars = new char[len]; for (int i = 0; i < len; i++){ char x = (char)((key.charAt(i) >> 4) & 0x0F0F0F0F); char y = (char)((key.charAt(i) & 0x0F0F0F0F) << 4); newchars[i] = (char)(x | y); } key = sanitizeKey(String.valueOf(newchars),0); return key; }