method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
68c1eda5-ecca-440f-9bb6-8218f067d763
0
private Handshake(ByteBuffer data, ByteBuffer infoHash, ByteBuffer peerId, boolean isObfuscated) { this.data = data; this.infoHash = infoHash; this.peerId = peerId; this.isObfuscated = isObfuscated; }
fc06e8a6-ce1f-4e45-a392-50a96ba6ac22
3
private void setUpListener(final JScrollPane contents) { changeListButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(pageListShowing==true){ setUpButtonImage(changeListButton,"ChangePageButton.png"); pageListShowing=false; listModel.cl...
7f688904-da4b-49f0-bcbd-8640d9bf1cf1
9
private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); } else { jj_lastpos = jj_scanpos = jj_scanpos.next; } } else { jj_scanpos = jj_...
dc3ba016-283a-4f22-bee3-bd4ea86d9e35
8
public Object getValueFor(int[] position, int crosstabDataIndex){ Object result = null; boolean allPositionsAreEqual = true; if(position != null){ //iterate over dataList for (IntermediateTotalInfo totalInfo : totalsDataList) { int[] positionRelativeToHeader = totalInfo.getPositionRelativeToHeader...
937dd3bf-5867-4f68-93ba-b13c7b32efd0
7
public void paintComponent(Graphics gfx) { super.paintComponent(gfx); Graphics2D g = (Graphics2D) gfx; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setPaint(Color.blue); //Draw all the lines for(int i = 0; i < (items.le...
7dce1bad-f965-4ffc-b3b4-2b649109dbd6
2
public void addFload(int n) { if (n < 4) addOpcode(34 + n); // fload_<n> else if (n < 0x100) { addOpcode(FLOAD); // fload add(n); } else { addOpcode(WIDE); addOpcode(FLOAD); addIndex(n); } ...
8cb2a005-4c87-4fee-97b6-47c0811428fd
5
@Test public void canRetrieveCellFromCoordinates() { for (int x = 0, size = sudoku.getGridLength(); x < size; x++) for (int y = 0; y < size; y++) sudoku.setCellValue(x, y, x * 100 + y); for (int i = 0, sudokuSize = sudoku.getSudokuSize(); i < sudokuSize; i++) { ...
ee131ad1-f7ef-4d3f-b652-a9d47a13d9dc
2
public String getMatchingStartExpression(String text) { String matchedExpression = null; int expressionCount = getExpressionCount(); for (int i = 0; i < expressionCount; i++) { // Look for a matching Expression String currentExpression = getExpression(i); boolean isMatchingExpression = text.startsWith...
77780531-40d6-4e7f-993a-4af1b9b72256
7
private boolean sort() { // Obter pontuações String contents = toString(); if(contents == null) return false; String[] scoresArr = contents.split( Util.EOL ); // Array de pontuações int[] scoresVals = new int[ scoresArr.length ]; // Array com valores String[][] scoresNomes = new String[ scoresArr.leng...
c2bbcfe7-5e6f-4433-b058-c38e00045cd0
8
private void compareDistances(int edge) { System.out.println("edge: " + edge); d.msDelay(3000); if (edge == 1) { if (turnLeft()) { Sputnik.robotMap.setPosition(new Node(0, 4)); Sputnik.robotMap.setHeading(1); } else { Sputnik.robotMap.setPosition(new Node(3, 4)); Sputnik.robotMap.setHea...
312ddd29-a089-4b4a-b7c5-731adcfcb0aa
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://down...
a07dac05-b528-40bf-840c-0ea76ff2e8c9
8
@Override public Validator<ResourceModel> getValidator() { return new Validator<ResourceModel>() { @Override public Set<ConstraintViolation> validate(ResourceModel item) { Set<ConstraintViolation> constraints = new HashSet<ConstraintViolation>(); Map<String, Resour...
b4408432-0d7e-48c4-b61e-d5cbf83beca8
0
@Override public String getHdfs() { //return "hdfs://192.168.178.41:8020"; return "hdfs://192.168.43.180:9000"; }
c6198069-c600-47bb-86b5-bb0aeac92d3b
1
public void visit_ifgt(final Instruction inst) { if (longBranch) { final Label tmp = method.newLabel(); addOpcode(Opcode.opc_ifle); addBranch(tmp); addOpcode(Opcode.opc_goto_w); addLongBranch((Label) inst.operand()); addLabel(tmp); } else { addOpcode(Opcode.opc_ifgt); addBranch((Label) inst....
04c957ef-85ce-4e97-912f-e7769a0dade0
9
@Override public Object getValueAt(int rowIndex, int columnIndex) { switch(columnIndex) { case 0: return competition.getRaces().get(rowIndex).getNumber(); case 1: return competition.getRaces().get(rowIndex).getJogger().getName(); case 2: return (competition.getStartTime() != null) ? new SimpleDateFormat("dd...
00347e5b-2850-4407-8a4c-67d7e2caf3c6
9
public int DBCount(String journal, String from, String to) { if(journal==null) return 0; journal = DB.injectionClean(journal); from = DB.injectionClean(from); to = DB.injectionClean(to); synchronized(journal.toUpperCase().intern()) { int ct=0; DBConnection D=null; try { D=DB.DBFetch(...
7cf43fc2-053b-4517-b86a-b045a7d42512
4
public static String read(final InputStream is) { final char[] buffer = new char[2048]; final StringBuilder out = new StringBuilder(); try { Reader in = null; try { in = new InputStreamReader(is, "UTF-8"); while (true) { int rsz = in.read(buffer, 0, buffer.length); if (rsz < 0) break...
21494fcf-18eb-4929-a2bd-33a88a8ed562
3
public boolean generate(World var1, Random var2, int var3, int var4, int var5) { for(int var6 = 0; var6 < 64; ++var6) { int var7 = var3 + var2.nextInt(8) - var2.nextInt(8); int var8 = var4 + var2.nextInt(4) - var2.nextInt(4); int var9 = var5 + var2.nextInt(8) - var2.nextInt(8); ...
87cb7ca8-e0ac-44a3-91c7-a0c6db9d21ee
2
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); for(int x = 0; x< IConfig.LARGEUR_CARTE;x++ ){ for(int y = 0; y< IConfig.HAUTEUR_CARTE;y++ ){ this.mapGraph[x][y].repaint(); } } }
1590bcbe-db2c-4157-a941-9fb7691ccbd0
4
public static int searchSign(Block block) { Set<BlockFace> signFaces = EnumSet.of(BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH); for (BlockFace face : signFaces) { Block relativeBlock = block.getRelative(face); if (relativeBlock.getType() == Material.WALL_SIGN) { ...
2f0afb77-9ec6-460e-bb12-afceb0e7ffce
6
public boolean controlarRegistros(){ try { r_con.Connection(); ResultSet rs=r_con.Consultar("select pc_fecha_cierre,pc_fecha_impresion_diario,pc_fecha_inicio from parametros_contables"); rs.next(); Fechas fechas=new Fechas(); String fechaCierre...
575c46cf-cd88-46ff-a6e9-399473a2ca15
2
private static void handleAcceptOffer(SerializableAcceptOffer pack) { // send to the seller for which the offer was accepted the confirmation Server.loggerServer.info("[Server] Received accept offer packet"); String seller; List<String> refusedSellers = new ArrayList<String>(); SelectionKey key = Server.regi...
08b6197f-7bfe-44c0-ade7-daf0fc93a0f5
0
public static Date getLastDayOfTheMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), lastDay, 0, 0, 0); return calendar.getTime(); }
43f37be6-b676-4f7c-a301-812eb769820f
1
@SuppressWarnings("static-method") protected StdImage getIcon(Row row, Column column, boolean selected, boolean active) { Object data = row.getData(column); return data instanceof StdImage ? (StdImage) data : null; }
91b7f1a0-47df-496d-8462-5b6eedd17b90
3
public LegalMovesIterator(Board b) { switch (b.turn()) { case WHITE: _pieces = b._whiteSetMap.keySet().iterator(); break; case BLACK: _pieces = b._blackSetMap.keySet().iterator(); break; default: ...
d200df58-473c-4125-b7a9-d28dce9c86bb
3
@Test public void testFullTextSearch_on_a_field() { ReadResponse resp = factual.fetch(TABLE, new Query().field("name").search("Fried Chicken")); for (String name : resp.mapStrings("name")) { assertTrue(name.toLowerCase().contains("frie") || name.toLowerCase().contains("fry") ...
aaef8b14-a079-4463-a51b-f8ae226b62ab
5
private void save(File file) { BufferedWriter writer = null; try { try { file.getParentFile().mkdir(); file.createNewFile(); writer = new BufferedWriter(new FileWriter(file)); for(int row = 1; row < countRows + 1; row++) { StringBuild...
75888a66-6689-407e-8058-78d3d97348cb
3
public static Config unserialize(){ Config config = null; try { File file = new File(CONFIG_FILE_NAME); if(!file.exists()) return null; FileInputStream fileIn = new FileInputStream(CONFIG_FILE_NAME); ObjectInputStream objectIn = new ObjectInputStream(file...
db088144-3b31-425c-99bb-a331851f254f
1
@Override public void actionPerformed(ActionEvent e) { // if we're not in a totally-maximized state // [which would make this all pointless] ... if (!Outliner.desktop.isMaximized()) { // grabaholda the topmost doc OutlinerDocument doc = (OutlinerDocument) Outliner.documents.getMostRecentDocumentTouche...
cd3ba2b2-afbf-4e38-b3fe-9b8b7f301ae8
0
@Test public void test_something() throws IOException, InterruptedException { final Map<String, String> server_script = new HashMap<String, String>(); server_script.put("foo", "bar"); final int port =9247; StringTrafficker st = new StringTrafficker(port, ...
955fa2d9-908f-4ad7-ad0a-7dfa4de6a3ed
6
public void updateUser() { if (id != null) { PreparedStatement st = null; String q = "UPDATE users SET email = ?, first_Name = ?, last_name = ? "; if (!StringUtil.isBlank(password)) { q += ",password = MD5(?)"; } q += "WHERE id = ?"; ...
a7cb4403-8c6b-4859-8326-5911f4f2e206
5
public static boolean isInteger(String line){ for(int i = 0; i < line.length(); i++){ char element = line.charAt(i); if(isNumber(element) == false){ if(i == 0 && element == '-' && line.length() > 1){ continue; } return ...
5d8e6f2e-c8cb-4c1c-894c-de0b194659cd
7
public void listInfo(Intersection closest, JTextArea textOutput) { Set<Integer> roadIds = new HashSet(); double lat = closest.getLatitude(); double lon = closest.getLongitude(); ArrayList<String> roadNames = new ArrayList<String>(); for (Segment seg : segments) { if ((seg.getNodeID1().getID() == closest.ge...
2c6b2aa6-7d97-4122-a7d2-d8c4b2ce7cb4
0
public int getK() { return k; }
5bfa0022-e238-414f-8360-db46a9f0c11c
9
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { if(!CMProps.getBoolVar(CMProps.Bool.EMAILFORWARDING)) { mob.tell(L("This feature is not activated.")); return false; } String parm = (commands.size() > 1) ? CMParms.combine(commands,1) : ""; ...
dcc70c27-7a3d-409a-b6d3-984b33f7f2aa
0
public void setMed_depotLegal(String med_depotLegal) { this.med_depotLegal = med_depotLegal; }
7aee55bf-6460-4258-a3f2-e1fdc15bd8aa
9
public PlacesList<Place> placesForUser(int placeType, String woeId, String placeId, String threshold, Date minUploadDate, Date maxUploadDate, Date minTakenDate, Date maxTakenDate) throws FlickrException { Map<String, Object> parameters = new HashMap<String, Object>(); PlacesList<Place> place...
398ae2df-7967-49ce-a1b3-e7230fb7bcb5
6
public Object clone() { Automaton a; // Try to create a new object. try { // I am a bad person for writing this hack. // if (this instanceof TuringMachine) // a = new TuringMachine(((TuringMachine) this).tapes()); // else a = (Automaton) getClass().newInstance(); } catch (Throwable e) { // Well...
dde77097-eac1-4224-928c-e6b858f25c92
5
public int getHandValue() { int value = 0; for (int i = 0; i < this.hand.size(); i++) { value += this.hand.get(i).getNumValue(); } if(value > 21 && hasAce) { for(int i = 0; i < aceIndex; i++) { value = value - 10; if(value <= 21) break; } } return value; }
16e02010-effa-4e3c-ab7c-5e7a403ed918
8
public static int tipoInterseccion(int u1, int v1, int u2, int v2, int x1, int y1, int x2, int y2) { int res; int a1,a2,b1,b2,c1,c2,dd; double xx,yy; res = -1; // cuando uno de los segmentos es un punto // res := 0 cuando son paralelas pero no colineales (no se intersectan) // re...
99312690-239f-49cf-b637-25b0c5721db1
2
public TestDaoGenerator( Table table ) { super( table ); this.daoName = "Test" + table.getDomName() + "Dao"; filePath = "src/test/java/" + packageToPath() + "/dao/" + daoName + ".java"; for( Column col : table.getColumns() ){ if ( col.isKey() ){ param += toJav...
78bb0d15-82fe-4a44-8b3a-2a27739ec6bb
1
private void chargerListeLabo() throws DaoException { List<Labo> desLabos = daoLabo.getAll(); getVue().getModeleJComboBoxLabo().removeAllElements(); for (Labo unLabo : desLabos) { getVue().getModeleJComboBoxLabo().addElement(unLabo); } }
0816f247-b1f5-42a4-bfb6-68bfd12c9d8f
7
public EvolvingGraph readEvolvingGraph () throws FileNotFoundException { Schedule sched; String u, v; int source, dest, cost, numsched; int aux = 0; File f = new File (filename); EvolvingGraph graph = new EvolvingGraph(0); graph.setMaxTime(0); Scanner sc = new Scanner (f); sc.nextInt(); int edges =...
fdf6cf22-7824-47cb-b1f7-d4a58726942c
3
private void buildQueue(LinkedList<BTPosition<T>> ll, ArrayList<BTPosition<T>> al) { BTPosition<T> c; while (!ll.isEmpty()) { c = ll.poll(); if (c.getLeft() != null) ll.add(c.getLeft()); if (c.getRight() != null) ll.add(c.getRight()); al.add(c); } }
7ccd060a-af2d-4377-bf4a-e230160c00cd
1
private Comparator<Row> comparatorFromOrderCriteria(OrderCriteria criteria){ Integer columnIndex = header.findByCellValue(criteria.getColumnName()).getCellIndex(); Comparator<Row> natural = (e1, e2) -> e1.getCellByIndex(columnIndex).getCellValue(). compareTo(e2.getCellByIndex(columnInde...
31f51313-ec29-4c60-b870-9240d408354e
6
private VillageDoorInfo getVillageDoorAt(int par1, int par2, int par3) { Iterator var4 = this.newDoors.iterator(); VillageDoorInfo var5; do { if (!var4.hasNext()) { var4 = this.villageList.iterator(); VillageDoorInfo var6; ...
01f9664d-4055-47a9-9844-30092bc3a0d5
2
public DiscoveredClient getClientForUsername(String username) { synchronized(threadLock) { Iterator<DiscoveredClient> it = getClients().iterator(); while ( it.hasNext() ) { DiscoveredClient thisClient = it.next(); if ( thisClient.getUsername().equals(username) ) return thisClient; } } ...
dd85cd37-3dca-4b29-8f5e-712fd171c501
7
public static int computeFieldSize(final FieldDescriptorLite<?> descriptor, final Object value) { WireFormat.FieldType type = descriptor.getLiteType(); int number = descriptor.getNumber(); if (descriptor.isRepeated()) { if (descriptor.isPacked()) { int data...
8c15355e-f7e2-4623-8b36-31fbe7f1b979
6
public void shoot(){ if(shoot && BulletTimer == 0){ Bullet b = new Bullet(); // Creates a new bullet; b.setBullet(1, 6 + xShip + ship.getWidth() / 8, window.getHeight() - ship.getHeight() / 2); // Sets bullet's Parameters bullets.add(b); // adds to array BulletTi...
80f0a63f-8ffa-486e-a538-a32329247a1a
1
public static int[] toIntArray(Integer[] data) { int[] result = new int[data.length]; for (int i = 0; i < data.length; i++) { result[i] = data[i].intValue(); } return result; }
2b14707a-ac58-4ad0-917e-f4637cc022f4
2
public void sendEndActions(){ JSONObject o = new JSONObject(); try { o.put("message", "endactions"); sendMessage(o); } catch (JSONException e){} catch (IOException e){ Debug.error("Error writing to graphics: " + e.getMessage()); } }
cf535ae1-cc50-4ce1-850f-d991926aeb6e
3
private void paintScreen() { Graphics g; try { g = this.getGraphics(); if ((g != null) && (dbImage != null)) { g.drawImage(dbImage, 0, 0, null); } // Sync the display on some systems. // (on Linux, this fixes event queue proble...
a9189ce4-2b0e-4f1f-a03a-35f1b3ed60ef
5
private int berekenSchotRichting(double hoekRad, double kracht, double windSnelheid, double zwaartekracht, Orientatie tankRichting){ //testen in welke richting het schot gaat, returnt 0 wanneer rechtop, -1 wanneer links en 1 wanneer rechts if((int)Math.round(Math.pow((kracht * Math.cos(hoekRad) + windSnelheid),...
cb143ed6-f9ef-410f-8865-e7edf945045f
6
@Override public List<Cell> createCells(Line rawLine) { String line = rawLine.getRawLine(); int lengthOfLine = rawLine.numberOfCharakters(); int charaktersRead = 0; while (true) { char workingCharakter = line.charAt(charaktersRead); Symbol symbol = new Symbol(...
ba811aaa-bf66-4c77-b11d-7cc50049acb8
4
private void calculateNextGeneration() { //// Prepare selection algorithms crossSelector.updateSpeciments(population); transferSelector.updateSpeciments(population); mutationSelector.updateSpeciments(population); //// Reproduce species int speci...
3a4712e7-73ad-42f7-bc16-e2fe4cefebfe
7
public static double[][] readTransitionProbHDFS(String directory, int number_reducers, FileSystem fs) { int number_of_lines = findNumberOfLinesHDFS(directory, "transition-r-", number_reducers, fs); double[][] transition_prob = new double[number_of_lines][number_of_lines]; try { for(int i = 0; i<number_reducer...
9c24493f-3136-41ea-8b4c-8208968ae8c6
2
public void removePush() { if (condStack != null) cond = condStack.mergeIntoExpression(cond); thenBlock.removePush(); if (elseBlock != null) elseBlock.removePush(); }
d95fe38c-eb48-4075-acca-6df09546c555
6
public Imagen getImagenMR(int windowCenter, int windowWidth) { Imagen imgObj = new Imagen(); int alto = rasterDicom.getHeight(); int ancho = rasterDicom.getWidth(); int minX = rasterDicom.getMinX(); int minY = rasterDicom.getMinY(); imgObj.setFormato("P2"); imgObj...
e0bd5474-2e52-4691-82ee-bca63316b97c
0
private void setColorBenchmarks() { findExtremes(); this.tempRangesHigh = new long[4]; tempRangesHigh[1] = (HIGH_TEMP + MAX_TEMP) >>> 1; // mid-point tempRangesHigh[0] = (HIGH_TEMP + tempRangesHigh[1]) >>> 1; // lower quartile tempRangesHigh[2] = (MAX_TEMP + tempRangesHigh[1]) >>...
d2f6de45-4fb8-4987-827b-23a91d52d763
3
public static void initializeCoefficients() { N = 0; postProb = 0.0; // Create window to store old samples if (Settings.agingFlag == Settings.windowAge) { oldSamples = new double[Settings.windowSize][2]; } // Set all scaling coefficients to 0 Transform.scalingCoefficients = new double[Transform.s...
6493a2e2-d336-4415-8b37-9fcebd606451
3
@Override public void run() { while (true) { String message = produce(); try { if (message.contains("Await receipt")) { System.out.println("transfer done"); queue.transfer(message); // blocks if there is no matching take() pendi...
e74a5b7f-ff18-49ed-8497-f2bff398370b
9
public IPPacket processPacket(IPPacket packet, int direction) { long now = 0; try {now = System.nanoTime();} catch (Exception e) {} if (direction == DIRECTION_IN) { int offset = packet.getIPHeaderByteLength(); int len = packet.getIPPacketLength() - offset; byte[] esp = packet.getDataUnprotected(); ...
ac5ff67e-330d-4eb0-83d8-eaf1dfccddad
6
final void method3049(ByteBuffer class348_sub49, int i, int i_0_) { anInt9179++; int i_1_ = i; while_152_: do { do { if (i_1_ != 0) { if ((i_1_ ^ 0xffffffff) != -2) { if ((i_1_ ^ 0xffffffff) == -3) break; break while_152_; } } else { anInt9176 = class348_sub49.getShort(); ...
a384222e-d62c-4759-9e4b-73d6be6c0d93
2
public boolean isReference() { return !special && (clazz == null || !clazz.isPrimitive()); }
869f5e0f-4c44-43a3-9e6d-b6679253c8a1
9
public void run() { writer.println("PLAY "+name); writer.flush(); while(!socket.isClosed()){ try { String response = reader.readLine(); if(response.equals("WAIT")) System.out.println("Esperando al otro jugador..."); else if(response.startsWith("VERSUS")){ String name = response.s...
b000ea16-dc8f-4743-823f-33b189200614
9
public static Factory get(Class<? extends ASTNode> type, Class<?> argType) { if (type == null) { return null; } try { final Method method = type.getMethod(Parser.kFactoryName, new Class<?>[] { argType }); return new Factory() { protected ASTNode make0(Object args) throws Exception { return ...
d6518256-ec8d-49f4-b0b9-9449ec57db50
0
public void setFirst(T newValue) { first = newValue; }
8033e333-e10b-4fc8-93ea-5b0309787e09
5
private static boolean getNext( int[] num, int n, int r ) { int target = r - 1; num[target]++; if ( num[target] > ((n - (r - target)) + 1) ) { while ( num[target] > ((n - (r - target))) ) { target--; if (target < 0) { break; ...
a1e9d2af-03db-40d6-a2b0-c4f7d0f58933
7
private void createRandomTestSuite(final int i) { StroopTest stroopTest = stroopTestProvider.getActiveStroopTest(); if (stroopTest != null) { // FIXME send event + add MainWindow where null int choice = JOptionPane.showConfirmDialog(null, "Wenn Sie einen neuen Test anlegen wird der Alte gel"+oe+"scht...
5c8fb126-ceee-4cfc-a971-0a288bb0cb24
1
public void operation() { if (mComponent != null) { mComponent.operation(); } }
ce6915af-4625-4de0-b6d8-e325d8a091ca
8
@Override public void transit(StateMachineEvent<EventType> event) throws InvalidEventException { Future<?> future = threadPoolFacade.process(new FSMTransitionTask(threadPoolFacade, event,true), syncRunnableProducer); try { future.get(); } catch (InterruptedException ex) { ...
66a24128-0205-4b66-9438-3b2d960db4cb
9
public ItemType getItemType(TypeHierarchy th) { boolean isSchemaAware = true; try { isSchemaAware = getExecutable().isSchemaAware(); } catch (NullPointerException err) { // ultra-cautious code in case expression container has not been set if (!th.getConfigurat...
b51d8af2-c008-483b-a79d-84d9e0324e7f
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://down...
17405ef8-7791-4402-aec9-bb25a40bcc6a
2
@Override public void run() { try { InputStream is = socket.getInputStream(); while (true) { BufferedReader buffer = new BufferedReader(new InputStreamReader(is)); String str = buffer.readLine(); System.out.println("received msg from server:" + str); } } catch (IOExc...
124f2a23-3a54-454e-8519-93df099165c6
5
public void update(Observable obs, Object arg) { if (obs instanceof WeatherData) { WeatherData weatherData = (WeatherData)obs; float temperature = weatherData.getTemperature(); temperatures.add(temperature); int count = temperatures.size(); if (count ...
7dcc5ee4-697d-4175-a25f-317486a1ca37
3
public void montarJanelaEditar() { tratadorEventosEditar = new TratadorEventosEditar(acessoBanco, this); painelPrincipal = new JPanel(); MigLayout migLayout = new MigLayout("wrap 3"); painelPrincipal.setLayout(migLayout); botoes.add(botaoCancelar); botoes.add(botaoSalvar); try { MaskFormatter maskar...
23676ce5-e657-4882-8010-23d5f8fbe303
9
public Vector getOddCycle( Bipartition b ) { //For each vertex, traverse the graph until an endpoint is reached or until a cycle is found. //Keep track of the path to the original vertex and the distance. If the distance is odd, print out the //odd cycle. Vector path = new Vect...
72da9e04-9dd8-46d7-a10f-c295284b3c7e
3
private void generateIsland(float y, int minSize, int maxSize) { gen = new IslandGenerator(minSize, maxSize, y); gen.start(); while (gen.finishedIsland == null) { lastProgress = new Float(progress); progress = (gen.progress / factor) + progressBefore; if (progress != lastProgress) { try { ...
7eb4c9de-6760-4edb-9669-fa55deac1803
2
public static double commonBaggageWeight( PassengerTrain train ){ double res = 0; for ( RailwayVehicle it : train ){ if ( it instanceof PassengerCar ){ PassengerCar pCar = (PassengerCar)it; res+= pCar.getBaggageWeight(); } } return res; }
e2b21485-9318-4e66-b39a-70cb64a6a162
2
public static Object loadObject(String file_name) { ObjectInputStream ois; try { ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(new File(file_name)))); Object object = ois.readObject(); ois.close(); return object; } catch (IOException e) { System.err.println("Error loading:...
1b086f8a-643c-444b-94be-798a0c1c5009
3
public String getSelectedNote() { String selectedNote = null; int row = table.getSelectedRow(); if(row!=-1) { if(table.getValueAt(row, 0)!=null) { selectedNote = table.getValueAt(row, 0).toString(); } if(table.getValueAt(row, 1)!=null) { selectedNote = table.getValueAt(row, 1).toString(); ...
44eedce6-fb63-4689-844a-3c608b64734a
6
public static int dehexchar(char c) { if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'F') { return c - ('A' - 10); } if (c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; }
5b2fd1c6-6697-4634-9767-58c22066895c
5
public static ArrayList<MediaCopy> searchMediaByID(String ID){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<MediaCopy> media = new ...
cc0fbdea-5bd8-448b-8743-21646e419e4c
6
public static HashMap<String, HashMap<String, Integer>> getMap(String filePath) throws Exception { HashMap<String, HashMap<String, Integer>> map = new HashMap<String, HashMap<String,Integer>>(); BufferedReader reader = filePath.toLowerCase().endsWith("gz") ? new BufferedReader(new InputStreamReader( ...
1f9e03a3-4123-460a-bf41-2f52f8336156
9
public static File[] filterImagesFromFolder (File[] folder) { List<File> files = new ArrayList<File>(); File[] listOfImages = null; int i=0; try{ for(File file:folder) { if(file.getName().endsWith(".jpg")||file.getName().endsWith(".jpeg")||file.getName().endsWith(".png") || file.getName().endsW...
0cfed858-4c2d-4d19-9c2e-e296c3265cd6
7
private void canSeeNothingAction() { switch (this.getType()) { case "Goalie" : //MP- If you can see the ball, face it if (canSeeBall) { turnTowardBall(); } else if (canSeeOpponentGoal) {//MP- If you can't see the ball, face the oppo...
bb44a6b4-2d4c-48c1-85d8-dc8eb52d9207
8
public static BufferedImage applyGaussianBlur(final BufferedImage image, final int filterRadius, final float alphaFactor, final boolean useOriginalImageAsDestination) { if (filterRadius < 1) { throw new IllegalArgumentException("Illegal filter radius: expected to be >= 1, was " + filterRadius); } float[] kern...
382a175a-8cac-4dd4-8dbe-bd67b3341917
1
public Economy getEconomy() { if (econHook == null) { throw new NullPointerException("Economy was called but hasn't been setup!"); } return econHook; }
f585414a-107b-4260-8b9e-bd531bdb907f
8
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ChunkSQL other = (ChunkSQL) obj; if (worldName == null) { if (other.worldName != null) return false; } else if (!worldName.equals(other....
e9e08fed-eb47-4bdd-97ee-3eb549b23a76
4
public static ArrayList<Student> chgGradeMenu(ArrayList<Student> inList){ int choice = 0; do { System.out.println("What would you like to do: \n 1) Change Grade \n 2) Switch Classes \n 3) return to main menu"); Scanner userinput = new Scanner(System.in); choice = userinput.nextInt(); ...
eba293ec-195f-49cb-a5b9-83d1e17014c8
1
public Tile (int id, Sprite[] sprites, int levelColour) { this.tileID = (byte)id; if(tiles[id] != null) {throw new RuntimeException("Duplicate tile id on " + id);} this.sprites = sprites; this.levelColour = levelColour; tiles[id] = this; spriteID = random.nextInt(sprites.length); System.out.println(sprite...
4256b6fc-d66b-48b4-915c-137cc649c452
7
public List<ExtendedEntityType> getIndividualMobs() { List<ExtendedEntityType> types = new ArrayList<ExtendedEntityType>(); if (mobMaximums != null) { for (int i = 0; i < mobMaximums.length; ++i) { if (mobMaximums[i] != Short.MAX_VALUE) { types.add(ExtendedEntityType.valueOf(i)); } }...
2d74dbae-3a45-4675-aa7b-c73ca82a9187
4
protected final short get_reduce(int state, int sym) { short tag; short[] row = reduce_tab[state]; /* if we have a null row we go with the default */ if (row == null) return -1; for (int probe = 0; probe < row.length; probe++) { /* is this entry labeled with our Symbol or...
88710b12-4987-4ebb-b550-bacd2848af10
1
private static Object toAnnoType(Annotation anno, ClassPool cp) throws ClassNotFoundException { try { ClassLoader cl = cp.getClassLoader(); return anno.toAnnotationType(cl, cp); } catch (ClassNotFoundException e) { ClassLoader cl2 = cp.getClass().g...
78aa34cc-2d04-48fd-a4c9-c8db72362cf6
8
@Override public void mouseClicked(MouseEvent e) { //Afficher le contenu de la pioche ouverte if ( e.getSource() == this.openPick && tileViewer == null && !this.selected.hasSelection()) { this.tileViewer = this.openPick.viewTiles(); if (this.tileViewer != null) { this.add(tileViewer, 0); this.client....
d16ab5d2-8c38-4b09-83b5-6faf802c715e
2
private void initializeTetrominoes() { tetromino = bag.draw(); next = new LinkedList<>(); for (int i = 0; i < PREVIEW_COUNT; i++) { next.add(bag.draw()); } if (nextTetrominoesChangedListener != null) nextTetrominoesChangedListener.onNextTetrominoesChanged(next); }
64b0246d-8eb2-4b4e-9937-9def24dce3f6
5
public static ArrayList<BookCopy> searchBookByISBN(String iSBN){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<BookCopy> books = new...
40778bd2-7acd-48b7-bb11-04ea12711dda
5
final void method1716(boolean bool) { if (((Class239) this).aClass348_Sub51_3136.method3425(-82)) ((Class239) this).anInt3138 = 0; anInt5904++; if ((((Class348_Sub51) ((Class239) this).aClass348_Sub51_3136) .aClass239_Sub24_7235.method1820(-32350) ^ 0xffffffff) == -1) ((Class239) this).anInt3...
e2bd6872-5754-4436-830e-7173d914635a
4
public byte[] readBytesReverse(int amount, ValueType type) { byte[] data = new byte[amount]; int dataPosition = 0; for (int i = buffer.readerIndex() + amount - 1; i >= buffer.readerIndex(); i--) { int value = buffer.getByte(i); switch (type) { case A: value -= 128; break; case C: ...
1be3fbf1-a9c2-4c56-bc62-96805bf5d39f
9
@Override public void add(Difference difference) { if(ignorePaths == null) { list.add(difference); } else { String pathA = trimNonXmlElements(difference.getPathA()); String pathB = trimNonXmlElements(difference.getPathB()); if (ignorePaths.contains(pat...