method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
87d5d594-ed1f-430d-9932-f84767bf4320
1
public Player() { for (int i = 0; i < 11; i++) { frame[i] = new Frame(); accumScore[i] = -1; } }
0de01410-6950-4763-baed-98e7b0187e4b
8
private int[] paataSuunta(int i, int j){ Random r = new Random(); int suunta = r.nextInt(4); int[] palkoord = new int[2]; if(suunta == 0){ if(tarkistin(i, j+1)){ palkoord[0] = i; palkoord[1] = j+1; } } else if(suunta...
e2023c58-25d7-4e81-bbec-3b7227732c6a
7
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == btnGenerate) { int w = 0, h = 0; try { w = Integer.parseInt(tfMazeWidth.getText()); h = Integer.parseInt(tfMazeHeight.getText()); if (w < 5 || h < 5) { throw new NumberFormatException(); } } catch (Nu...
a5baf557-da0d-415a-91ee-c74acbe445bb
2
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Theme)) return false; Theme theme = (Theme) o; return id == theme.id; }
ed1abb75-3850-408f-ba27-c3350056eabe
8
public Element handle(FreeColServer server, Player player, Connection connection) { ServerPlayer serverPlayer = server.getPlayer(connection); Unit carrier; try { carrier = player.getFreeColGameObject(carrierId, Unit.class); } catch (Exception e) { ...
2294dbc9-88e8-4171-b526-2c7a2426b992
8
private boolean camposCompletos (){ if((!field_codigo.getText().equals(""))&& (!field_descripcion.getText().equals(""))&& (!field_cantidad.getText().equals(""))&& (!field_costo_u.getText().equals(""))&& (!field_precio_venta.getText().equals(""))&& (!field_t...
55d9decd-a647-41f0-b767-76e0a2b92969
2
public boolean hitWall(Wall w){ if(this.isLive && this.getRect().intersects(w.getRect())){ this.stay(); return true; } else return false; }
d96ab1ec-6ff9-4616-99d2-027b72f978c7
7
void exec_if() throws StopException, SyntaxError{ var_type cond; return_state r; cond = evalOrCheckExpression(false); //evaluate the conditional statement if(cond.value.doubleValue()!=0){ // if any bit is not 0 statementColor = trueHightlightColor; symbolTable.pushLocalScope(); r = interp_block(bloc...
27717f36-489b-4e84-96b0-e7a70092671c
1
public void mettreAJourLignes() { //synchronized(MenuDroite.modelListeLigne) { MenuDroite.modelListeLigne.clear(); Iterator it = Main.lignes.entrySet().iterator(); while(it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); System.out.println(pairs.getKey()); MenuDroite.mode...
968a644b-e35a-4e15-a881-012fd428dd1b
2
public static void setSpeed(int x) { if(x < 1 || x > 10) return; diff = x * 0.1; }
85818fc7-8692-4414-8a64-d359c1aacbbb
5
public void hit(Card card) { cards.add(card); try { score += Integer.parseInt(card.getValue()); } catch (NumberFormatException e) { if (card.getValue().equals("KING") || card.getValue().equals("JACK") || card.getValue().equals("QUEEN")) { score += 10; } if (card.getValue().equals("ACE"))...
40c75523-bf5f-4506-a9f2-ff4410ecef81
8
public void paivitaTilanne(int creaturetPoydassa) { if (this.tuplamanat&&this.cradle) { this.mana = (creaturetPoydassa + this.landit) * 2; } else if (this.tuplamanat&&!this.cradle) { this.mana = this.landit * 2; }else if (!this.tuplamanat&&this.cradle) { this....
7a241ed0-d6de-46fe-ae66-dbeefd672346
8
public static boolean isPrimitiveWrapper(Object o) { return o instanceof Boolean || o instanceof Character || o instanceof Byte || o instanceof Short || o instanceof Integer || o instanceof Long || o instanceof Float || o instanceof Double || o instanceof Void; }
5cb6069a-bf10-4a5e-b8ef-676607536ac5
6
public boolean getBoolean(int index) throws JSONException { Object object = this.get(index); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String) object) .equalsIgnoreCase("false"))) { return false; } else if (object.equal...
cabe0114-206d-4fd1-b599-6e9c850e9702
8
private boolean saveSettings() { int maxDownloads, downloadPartCount, serverCheckInterval; float deleteLimit; try { maxDownloads = Integer.parseInt(maxParallelDownloadsText.getText()); if (maxDownloads < 0) throw new NumberFormatException(); } catc...
50fd64f9-ac6c-41fd-921f-2fb9e7f5e189
6
public void init() { // se inicializa la pausa en falso booPausa = false; //se inicializa guardar en false booGuardar = false; // se inicializa space en false booSpace = false; // se incializa la ayuda en true para que se muestr...
bdddea07-9551-4eba-8f42-931685533723
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); addActionListener(this); }
e1777b2f-367f-45ac-b0f8-91a51a156bd3
1
public String getSelectedFastbootDevice() { if (jList2.getSelectedValue() != null) return (String) jList2.getSelectedValue(); else return null; }
ee890d51-8f00-43f1-aef1-3b013d509b8c
3
void createSetGetGroup() { /* * Create the button to access set/get API functionality. */ final String [] methodNames = getMethodNames (); if (methodNames != null) { final Button setGetButton = new Button (otherGroup, SWT.PUSH); setGetButton.setText (ControlExample.getResourceString ("Set_Get")); s...
8429f59c-5101-4bad-9ce7-63b8e208d023
0
public void skladanie(){ dysk = fabrykaPodzespolowKomputerowych.produkujemyDysk().dawajDysk(); grafika = fabrykaPodzespolowKomputerowych.produkujemyGrafike().dawajGrafike(); procesor = fabrykaPodzespolowKomputerowych.produkujemyProcesor().dawajProcesor(); ram = fabrykaPodzespolowKomputerowych.produkujemyRam().d...
725d7862-7095-41ca-8821-2656da094c17
0
public String getAgencia() { return this.agencia ; }
82d874fa-55e0-4b0d-8217-f16eac0fab19
1
public static void writeXML() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document highScoreListe = builder.newDocument(); Element root = highScoreListe.createElement("root"); ...
81a6b870-3f74-49c1-ada2-3b84f77dae60
5
@Override public boolean activate() { return (!Inventory.isFull() && Settings.root.getRoot() == 1 && !Inventory.contains(Constants.INVENTORY_BURNED_ROOT_ID) && !validate(Constants.WAITFOR_WIDGET) && !validate(Constants.FLETCH_WIDGET) && !Settings.burning ); }
c9e603aa-d38e-45e0-82bc-4ca76a7fd305
2
private boolean isWinningMove(Move move) { return winsOnColumn(move) || winsOnRow(move) || winsOnDiagnal(move); }
8a057aeb-7a69-485e-9704-7dce4ecc1075
3
public void addRow(Object... params) { if (params.length != definition.length) { Session.logger .warn("Element counts doesn't match column definition"); } TableRow row = new TableRow(definition.length); int len = (params.length < definition.length ? params.length : definition.length); for (int i =...
e7da717d-1ded-4489-8d01-67e4672c1e57
2
public void serializationLoadNo() { if (JOptionPane.showConfirmDialog(this, "This will erase the existing data. Continue?", "Confirm Operation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { StartupSequence.deleteSerializedData(); ...
b393281e-6e3e-4ee3-a3a2-8d2cdef61c87
5
private boolean isThreeOfAKind(ArrayList<Card> player) { if(isFullHouse(player)){ return false; } ArrayList<Integer> sortedHand= sortHand(player); int tripleCounter=0; for(int i=0;i<player.size()-1;i++) { if(sortedHand.get(i)==sortedHand.get(i+1)) tripleCounter++; else { if(tripleCounter==1)...
90910519-2b00-413f-bae2-00ccd5a05c43
0
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) public List<Film> getFilm() { return film; }
8e2eada0-7086-4a3f-bed7-b074ca2fcb90
8
private void gaussianHeightScaling() { int kernel_size = (int)(Math.sqrt(gaussian_kernel.length)); int kernel_size2 = kernel_size / 2; int startx = FROMx == 0 ? kernel_size2 : FROMx; int starty = FROMy == 0 ? kernel_size2 : FROMy; int endx = TOx == detail ? detail - kernel_size...
183a29b8-5049-423a-85df-02e796f0dee1
7
private void extractFile(ZipFile zipFile, ZipEntry src, String destDir) { String filename = src.getName(); /*check existence of subdirectory*/ String[] paths = filename.split("/"); String curP = ""; for (int i = 0; i < paths.length; i++) { if (paths[i] != null && !pa...
1c048173-e7c1-454e-ab95-0533a1654868
6
public void draw(Graphics g, JPanel p, int x, int y, int height, int width) { Image img = null; if(getModel() == null) { try { img = ImageIO.read(new File("empty.jpg")); g.drawImage(img, x, y, p); } catch (IOException e) { e.printStackTrace(); } } else { if (((Pion)getModel()).getPio...
e184edae-5abb-4ade-9611-2cc2c8d749d8
6
private void debugPrint(GameBoard game) { String title = "Tetris"; for (int i = 0; i < ((game.COLUMS - (title.length()/2) )/ 2); i++) { System.out.print(SPACE); } System.out.println(title); System.out.print('+'); for (int i = 0; i < game.COLUMS; i++) { ...
c1b96e71-c242-4e21-9687-dd4f5165db8b
9
public static boolean isPalindrome(String string) { if (string == null || string.length() == 0) return false; String s = string.toLowerCase(); String regex = "[a-z]"; Pattern pattern = Pattern.compile(regex); int leftIndex = 0; int rightIndex = string.length() - 1; while (leftIndex < rightInde...
473cc1cd-ffc4-4da0-be42-10c7f9224113
2
@Override public ArrayList<Visiteur> getAll() throws DaoException { ArrayList<Visiteur> result = new ArrayList<Visiteur>(); ResultSet rs; // préparer la requête String requete = "SELECT * FROM VISITEUR"; try { PreparedStatement ps = Jdbc.getInstance().getConnexion...
38595faa-5f9d-4d82-a1c0-17d9f250f01d
8
public void handleInput() { if ((p.health <= 1) || (op.health <= 1) || (endResult.length() > 1)) { if (KeyHandler.isPressed(KeyHandler.ENTER)) { gsm.setState(GameStateManager.STARTMENU); } return; } p.setLeft(KeyHandler.keyState[KeyHandler.LEFT]); p.setRight(KeyHandler.keyState[KeyHandler.RIGHT])...
c8dcf3c8-72bf-4c84-bae1-2e13bccece13
0
@Override public Set<String> getWorlds() { return getList(worldYamlConfiguration); }
dcf6a86c-f67a-4952-9786-7bb608beb8c7
8
private double[][] generatePerlinNoise(double[][] baseNoise, int octaveCount) { int width = baseNoise.length; int height = baseNoise[0].length; double[][][] smoothNoise = new double[octaveCount][][]; // an array of 2D arrays containing //double persistance = 0.5f; // generate smooth noise for (int i = 0;...
290cd22b-961f-46d7-bfcf-91cc87c0d616
9
public void runProgram() throws FileNotFoundException, IOException { //Deserializes the file objectsVector = deSerFile.DeserializeFile(); //Count the number of each object if(debug.getDebugVal() == 0) { int numType1 = 0; int numType2 = 0; Boolean bln = true; //Check & display unique # of c...
c63b9fdf-c808-454c-8958-87223a48109c
1
final Object pop() { int size = stack.size(); return size == 0 ? null : stack.remove(size - 1); }
f10e3eca-40c1-4f68-9822-b704055bd8e0
9
@Override public void projectChanged(Project source, ProjectInfo i) { if ((i.isSimulationControlStateModified() || i.isSimulationChanged()) && source.hasSimulation() && source == session.getCurrentProject()) { simulationTimer.setDelay(source.getTimerDelay()); if (sour...
a8cf78da-d67f-44e6-8397-a1fbdd8c83c5
4
public String processInstructions(String instructions) { /*regex to check if the input is valid. to break it down further: ^\d+ \d+\n checks for a number followed by a space and a number, then a line break. This is the platform size. Then, (\d+ \d+ [NESW] check is the same but followed ...
00f1e34b-0fe8-4ae5-9942-f037fbf3acd6
1
public int[] next() { if (repeat-- > 0) { shuffle(p, random); return p; } else return null; }
d1cc0b1b-aeda-4124-9816-6384be6bd316
5
public void paint( Graphics g ){ super.paint(g); if (isSelect()) g.setColor(getColorSelect()); else g.setColor(getColorNormal()); switch (relacion.getTipo()){ case CONST.R_ASOCIACION : pintarAsociacion(g); break; case CONST.R_AGREGACION : pintarAgregacio...
af429efb-e5d1-422b-bba4-71691a1fd27d
5
public String addEdge(String src_region, String src_agent, String src_plugin, String dst_region, String dst_agent, String dst_plugin, String className) { String edge_id = null; int count = 0; try { while((edge_id == null) && (count != retryCount)) { ...
f7c045d7-738c-4f96-8e43-f629dc60bc3c
9
public boolean isBlocked(Location l, boolean playersBlock){ if (playersBlock) { //Return true if occupied by any player for (Player player : players) { if (l.equals(player.getLocation())) return true; } } //Return true if the location is beyond the edge of the map if(l.getX() >= MAX_X ||...
c04c2f71-782d-49ba-a5a9-22cb63ff1bb2
5
public Ausrichtung string2Ausrichtung(String input) { int richtung = 0; // -1,1,-2,2 == -x,x,y,-y Ausrichtung ausrichtung = null; try { richtung = Integer.parseInt(input); } catch (Exception e) { // Nothing } switch (richtung) { case 1: ausrichtung = Ausrichtung.XPLUS; break; case -1: ...
87df4269-d219-435b-8da5-fd713a35c4f7
0
public void setTopping(String topping) { this.topping = topping; }
fcc853cf-db66-42a3-ba58-1bf1f561f78a
2
void inputAppend(String s){ int maxLength = 4; if (currentState == MasterMindGraphic.FEEDBACK) { maxLength = 2; } if (input.length() < maxLength) { this.input += s; } }
8853460c-07f3-455a-ab5a-1d7e24d7ce69
2
public void testGetValue() throws Throwable { MockPartial mock = new MockPartial(); assertEquals(1970, mock.getValue(0)); assertEquals(1, mock.getValue(1)); try { mock.getValue(-1); fail(); } catch (IndexOutOfBoundsException ex) {} try { ...
dd6b7f0d-1e1b-4e9c-972a-c9283c15f0af
8
@Override public void keyPressed(KeyEvent e) { int KeyCode = e.getKeyCode(); if (KeyCode == KeyEvent.VK_A || KeyCode == KeyEvent.VK_LEFT) { left = true; } if (KeyCode == KeyEvent.VK_D || KeyCode == KeyEvent.VK_RIGHT) { right = true; } if (Key...
afd76891-60c4-43ec-a5f5-0b7f14962583
6
public UserDTO getUserByNickname( String nickname ) throws DAOException{ UserDTO user = null; query = ""; query += "SELECT \n"; query += "id, passwd, register_date, email, status \n"; query += "FROM chat_user \n"; query += "WHERE nickname = ? \n"; try{ connection = DBManager.getConnection( ); ...
54d550e6-8d27-4e45-9bdc-b75c35c46e1f
6
@Override public void run() { boolean done = false; try { Shell sh = ShellManager.getReference().getShell(m_ConnectionData.getLoginShell()); do { sh.run(this); if (m_Dead) { done = true; break; ...
efa3fff0-c7d3-4128-9a06-ef2999d7123c
6
private List<MorrisLineAdjacent> getColumnLineAdjacent() { List<MorrisLineAdjacent> lines = new ArrayList<MorrisLineAdjacent>(); boolean bu = this.hasUp(); boolean bd = this.hasDown(); MorrisLineAdjacent oneLine = null; if (bu && bd) { //this is in the middle oneLine = new MorrisLineAdjacent(this, this.up(...
1a1a9d94-5f51-493d-909c-80e12a8b00d0
6
public ArrayList<String> apiGetLinks (String Client_ID, String url) throws IOException { ArrayList<String> foundLinks = new ArrayList<String>(); if(isRunning){//We only want to do this if the app is running. String YOUR_REQUEST_URL = url; URL imgURL = new URL(YOUR_REQUEST_URL); HttpURLConnect...
9953bd8e-e2f4-4f44-b4d8-071f1f0eaeb1
9
@Override public long periodUntil(DateTime endDateTime, PeriodUnit unit) { if (endDateTime instanceof LocalTime == false) { throw new DateTimeException("Unable to calculate period between objects of two different types"); } LocalTime end = (LocalTime) endDateTime; if (unit instanceof ChronoUnit...
f330612e-de97-4495-80db-2d8f9296363e
6
public static void main(String[] args) throws ClassNotFoundException,SQLException { Connection conn = null; PreparedStatement ps = null; try{ conn = DBConnection.getConnection(); //just a test to get some user input and insert into the db Scanner scanner = new Scanner(System.in); System.out.p...
f7278ddf-534b-461b-94a9-e2ac2d43cd73
1
@Override public void display(UserInterface ui) { UserInterface.print("Breakpoints cleared on lines: "); for (String breakpointLine : breakpointLinesToClear) { UserInterface.print(breakpointLine + " "); } UserInterface.println("\n"); ui.signalNeedToDisplayFunction...
1117180b-866e-4717-b243-8d48133b82ca
3
@Override public void render(Graphics2D g) { double angle = Math.toDegrees(connectedObject.getRotationAngle()); angle = angle < 0 ? 360 + angle : angle; double radius = connectedObject.getRadius(); double diameter = 2 * radius; double x = connectedObject.getX() - radius; ...
3fbade63-b649-4473-80f2-9dd2715d36ee
1
public void setNumber(int number) { if (number <= 0) { throw new IllegalArgumentException("Number should be bigger than zero."); } this.number = number; }
313a2c4d-3c6e-42cf-b584-cdd283e23bc2
3
private boolean isCorrect(JTextField field) { boolean correct = false; if (field.getText().length() == 5) { String[] pieces = field.getText().split(":"); if (Utils.isNumeric(pieces[0]) && Utils.isNumeric(pieces[1])) { correct = true; } } ...
caa2134e-f78c-4a89-ab17-87b6939cd84b
7
public boolean isBoundingBoxBurning(AxisAlignedBB var1) { int var2 = MathHelper.floor_double(var1.minX); int var3 = MathHelper.floor_double(var1.maxX + 1.0D); int var4 = MathHelper.floor_double(var1.minY); int var5 = MathHelper.floor_double(var1.maxY + 1.0D); int var6 = MathHelpe...
00eab101-8831-4537-9d26-1847ed20c57c
8
public static void setText(ArrayList<JavaProcess> newLabel){ newLabels = newLabel; labelListValue = labelList.size()/6; newLabelsValue = newLabels.size(); //System.out.println(newLabels.size() + " "+ labelList.size()); if(newLabelsValue < labelListValue){ SwingUtilities.invokeLater(new Runnab...
20d8e3e5-d9d8-4bf0-b0f2-3fd782e019ed
8
public void roundComplete() throws Exception { this.roundCount++; if (roundCount % 100 == 0) { List<Statistics> stats = listStats(); Collections.sort(stats); if (stats.size() < 3) //not enough stats yet { return; } ...
8627bfeb-268b-43cc-b84e-c47a0e82006c
6
public static boolean innersolveSudoku(char[][] board) { for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[i].length; j++) { if ('.' == board[i][j]) { for (int k = 0; k < 9; k++) { board[i][j] = (char) ('1' + k); if (isValidSudoku(board)) { ...
2fadb069-e038-4608-b866-b1be4a4ea41c
7
public static final Formula empiricalFromMolecular(String formula) { int gcd = Integer.MAX_VALUE; Formula empiricalFormula = FtHelper.parseFormula(formula); List<Integer> subscripts = empiricalFormula.getSubscripts(); // We'll find GCDs in pairs and store them in tryGCD int[] tryGcd = new int[10]; ...
0ca2ab7e-7d44-428b-a0f8-86e88a8b9dd2
6
public static void removeWordsStartWithConsonant(Text text, int length) { log.trace("Subtask N12"); for (int i = 0; i < text.getAllElements().size(); i++) { Sentence sentence = text.getChildElement(i); if (sentence.getClass() != Listing.class) { for (int j = 0; j ...
08e7fb38-6c77-4e83-b90e-4d0268e4277c
4
public static void navigate(String url) { if (java.awt.Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI(url)); } catch (IOException e) { BmLog.error(e); } catch (URISyntaxException e) { BmLog.error(e); ...
6e04f571-e714-4ca8-abd3-26ac9697d66a
2
public static void closeDB(DB db) { if (db != null) { LOGGER.trace("正在关闭MongoDB[" + db.getName() + "]"); try { db.requestDone(); } catch (Throwable ex) { LOGGER.debug("关闭MongoDB时发生未知异常", ex); } } }
f574776c-9c3f-4b84-99c0-8993499c25e9
0
@Override public void dosomething() { super.dosomething(); this.anothing(); }
c2565ce9-7dfa-4152-b8ef-309b2ee7e4b9
4
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String line = (caseSensitive) ? value.toString() : value.toString().toLowerCase(); for (String pattern : patternsToSkip) { line = line.replaceAll(pattern, ""); ...
fdde79bf-003e-4364-948d-d21a4416b0eb
8
public void handleEntityMovement() { MovementPoint walkingPoint = null, runningPoint = null; if (getEntity().getUpdateFlags().contains("teleporting")) { resetMovement(); } else { walkingPoint = getNextPoint(); if (isRunning()) { runningPoint = getNextPoint(); } getEntity().setWalkingDirection(w...
d1a1f7c9-c310-4624-a71d-bc88797c35e4
9
protected void printTopWordsDistribution(int topK, String topWordFile) { Arrays.fill(m_sstat, 0); System.out.println("print top words"); for (_Doc d : m_trainSet) { for (int i = 0; i < number_of_topics; i++) m_sstat[i] += m_logSpace ? Math.exp(d.m_topics[i]) : d.m_topics[i]; } Utils.L1Normaliza...
c7728fd7-b56f-40b3-bfe8-cc143b0e67e3
2
private static void printBuildingTable(ArrayList<ParkerPaulTaxable> taxables) { double totalTaxes = 0.00; // total taxes for items double minTaxes = -1.00; // min taxes for items double maxTaxes = 0.00; // max taxes for items int count = 0; // count of items printBuildingHeader...
94a2421a-3eb1-496e-8af2-5dcdb0e54178
8
public void save(File file) { FileOutputStream outputStream = null; try { if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); } if (file.canWrite()) { outputStream = new FileOutputStream(file); for (Device device : devicesHistory.values()) { device.write(outputSt...
0a337bcb-b9dd-492b-94a2-fc64fa849470
4
public void monitorFileModify(Path file){ if(file.startsWith(targetPath) && !Files.isDirectory(file)){ Path subPath = targetPath.relativize(file); Path newPathSource = sourcePath.resolve(subPath); Path newPathTarget = targetPath.resolve(subPath); try { if(!FileUtils.conten...
dadf0d8d-dcab-4488-a6ce-f3f554b3e606
7
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Customer customer = (Customer) o; if (!firstName.equals(customer.firstName)) return false; if (!id.equals(customer.id)) return false; i...
6897c15b-2ccb-491e-a575-a2589088d486
9
static final void loadScriptSettings(int i) { if (i != 1) aString1761 = null; anInt1760++; FileOnDisk class234 = null; try { SignlinkRequest class144 = Class348_Sub23_Sub1.signlink.method2233((byte) -46, "2", true); while ((class144.state ^ 0xffffffff) == -1) Class286_Sub5.method2161((byt...
1d32ec75-7b83-4872-94d8-dce9eddb21ec
2
public void showPersonalPosts() { for (TimedPosts post : posts) { long elapsedTimeInSec = (System.nanoTime() - post.getTime()) / 1000000000; if (elapsedTimeInSec < 60) { int elapsedTime = (int) elapsedTimeInSec; System.out.println(post.getPost() + "(" + el...
98244daa-503c-4a09-967a-c81ac00dce7f
7
protected Node representData(Object data) { objectToRepresent = data; // check for identity if (representedObjects.containsKey(objectToRepresent)) { Node node = representedObjects.get(objectToRepresent); return node; } // } // check for null first ...
ba1be49f-5635-4e9c-892d-24101e0a38a8
4
public void mouseDragged(MouseEvent e) { if(Global.isRunning) { return; } // block mouse input while simulating if(shiftStartPoint != null) { // shift the view pt.moveView((int) ((shiftStartPoint.x - e.getX()) / pt.getZoomPanelZoomFactor() * pt.getZoomFactor()), (int) ((shiftStartPoint.y - e.g...
79c728af-7b92-4564-9088-1f319eb78e4e
8
public void run() { PrintStream outOld = null; PrintStream outNew = null; String outFilename = null; // is the output redirected? if (m_CommandArgs.length > 2) { String action = m_CommandArgs[m_CommandArgs.length - 2]; if (action.equals(">")) { outOld = System.out; try { ...
403d7fdb-f60f-4817-a834-862141ddf8a0
5
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); int nCase = 1; while ((line = in.readLine()) != null) { if (line.trim().startsWith("#")) break; char[] a = ...
c27b8a03-71b4-4107-b49e-9909b9a9979b
4
private void parse(JSONObject action) { // Initialize the keywords available for this Action keywords = new ArrayList<String>(); // Assign the name and execution code for this Action name = action.getString("name"); execute = action.getString("execute"); // Pull off the keywords from the JSONObject an...
15f32b7b-005b-48a8-94a2-1aa5e6124652
9
public Rule cloneWithModeChange(final Mode toMode) throws RuleException { if ("".equals(toMode)) throw new RuleException("invalid mode [" + toMode + "] to convert"); boolean isModified = false; Rule newRule = clone(); List<Mode> modeUsedInBody = getModeUsedInBody(); if (modeUsedInBody.size() == 0) { } els...
fed7ef78-5fd2-42bc-8a4c-a4d36058eb81
5
public int getBlockTypeIdFromPixel(int imagePixel) { int blockTypeId = -1; String[] line = (String[])groups.get(imagePixel); if(line != null) { int newBlockType = blockManager.getRandomIdByGroup(line[0]); if(newBlockType > 0) { blockTypeId = newBlockType; ...
05b28d9f-2bdc-402a-9cbe-49c6dfd03694
8
@Override public void onEnable() { loadConfig(); PluginManager pm = getServer().getPluginManager(); pSpout = pm.getPlugin("Spout"); pTag = pm.getPlugin("TagAPI"); formatTranslations(); setupDatabase(); pm.registerEvents(playerlistener, this); for (DNCCommands cmd : DNCCommands.val...
dd155fed-f58e-4a30-992c-51ebabe61fb4
2
@Override public boolean subscribe(Client client, SubscribeMessage message) throws Exception { String[] topics = message.getTopics(); QoS[] qoses = message.getRequestedQoSes(); List<String> allowedTopics = new ArrayList<String>(); List<QoS> allowedQoses = new ArrayList<QoS>(); int index = 0; for (St...
dc03321b-23bd-499f-9138-abfcbe0f4805
6
public Element featureChange(Element element) { Game game = getGame(); Specification spec = game.getSpecification(); boolean add = "add".equalsIgnoreCase(element.getAttribute("add")); FreeColGameObject object = game.getFreeColGameObject(element.getAttribute("id")); NodeList nodes...
242191f2-a65c-4efb-b27a-1192414c7613
3
public boolean doSendPackage() { boolean result = false; try { synchronized (mOutPkgs) { while (mOutPkgs.size() > 0) { mBos.reset(); ObjectOutputStream out = new ObjectOutputStream(mBos); NetSystem.Package pkg = mOutPkgs.poll(); out.writeObject(pkg); byte[] data = mBos.toByteArray()...
0a3f2d1c-9436-48bb-9c83-0e4a4806ba27
5
private int selectRGBTransform(RGBTransformAvailable chanel,Color color){ int colorReturn=0; switch (chanel){ case GBR: colorReturn=super.colorRGBtoSRGB(new Color(color.getGreen(), color.getBlue(), color.getRed(),color.getAlpha())); br...
e1fbb5ee-1b87-4aba-851f-23f1b8e805d4
0
private void printTotalScores(Player player, int count) { System.out.println(player.getName() + " wins " + player.getNumberOfWins() + " of " + count + " games."); }
fa70b6d6-3285-46f2-b57c-eecc78c75789
6
private static Entry[] merge(Entry[] list1, Entry[] list2) { Entry[] output = new Entry[list1.length + list2.length]; int p1 = 0, p2 = 0; for(int i = 0; i < output.length; i++) { if(p2 >= list2.length) { output[i] = list1[p1]; p1++; } else if(p1 >= list1.length || list1[p1].getScore() < list2[p2].ge...
ff34c64d-4999-4dc5-ae6b-343754ee1c65
2
protected void processCondCommentBlocks(List<String> condCommentBlocks) { if(generateStatistics) { for(String block : condCommentBlocks) { statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); } } }
a2e1e999-7833-456c-9421-e8c1a5395cfb
2
private void showAboutPanel() { String html = MessageFormat.format(resources .getString("dialog.about.text"), new Object[] { resources.getString("version.id") }); String[] props = { "java.version", "java.vendor", "java.home", "os.name", "os.arch", "os.version", "user....
854f11e6-6d3c-4e97-ac14-73dc1f44c783
1
@Override public List<? extends DefaultModel> getObj(String campo) { return null; }
eb397f45-0968-48c9-a6a3-5efdd0e14838
9
public Address getAddresses(String content, String encodingString) throws UnsupportedEncodingException { // 这里调用pconline的接口 String urlStr = "http://ip.taobao.com/service/getIpInfo.php"; // 从http://whois.pconline.com.cn取得IP所在的省市区信息 String returnStr = this.getResult(urlStr, content, encodi...
05de0f84-8fd5-46dc-9a1c-e17e8be79e7a
4
public void enterParkedState(int parkingTime, int intendedDuration) throws VehicleException { exitTime = parkingTime + intendedDuration; this.parkingTime = parkingTime; // this.intendedDuration = intendedDuration; if (isParked() == true) { throw new VehicleException("Vehicle is already parked."); } ...
e3fc4f40-4159-40e0-9f6e-6e90e3d044b9
7
public boolean isE(char c) { if ((c >= 'a' && c <= 'z')) { return true; } switch (c) { case '.': return true; case '-': return true; case '/': return true; case '#': return true; case '?': return true; } return false; }
b7e8d959-3dc4-4219-81cf-a1d00df02abe
5
public ProcessState execute(final CommandSender sender, final Command cmd, final String label, final String[] args) { ProcessState state = null; if ( sender instanceof Player ) { final IPlayerExecutor exec = this.playerExec.get(args.length); if ( exec != null ) state = exec.execPlayer((Player) s...
c84fd711-5933-4e4b-a6a8-02a17b07b485
6
public int[][][] loadLevel(String levelName) { int[][][] level = new int[2][Constants.levelHeight][Constants.levelWidth]; try { Scanner scanner = new Scanner(this.getClass().getResourceAsStream("resources/levels/" + levelName + ".lvl")); while (scanner.hasNext()) { for (int i = 0; i < level[0].le...