method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
e291f306-c3e5-49e7-a1a0-18ecc50d27a6
4
private void afficherMatchs() throws IOException, SQLException { lbNumJour.setText(Integer.toString(jour)+"/01"); if (jour == 22) btPrec.setEnabled(false); else if (jour == 30) btSuiv.setEnabled(false); else { btPrec.setEnabled(true); btSuiv.setEnabled(true); } if (courtChoice.getSelectedItem().equals("Tous")) { //Mise à jour des bordures des panels panMatch2.setVisible(true); panMatch3.setVisible(true); panMatch4.setVisible(true); panMatch5.setVisible(true); panMatch6.setVisible(true); panMatch1.setBorder(new TitledBorder("Court central")); panMatch2.setBorder(new TitledBorder("Court annexe")); panMatch3.setBorder(new TitledBorder("Court d'entrainement 1")); panMatch4.setBorder(new TitledBorder("Court d'entrainement 2")); panMatch5.setBorder(new TitledBorder("Court d'entrainement 3")); //Mise à jour du label indiquant la sélection lbSelected.setText(heureChoice.getSelectedItem()); MatchDao mdao = DaoFactory.getMatchDao(); remplirPlanningHeure(mdao.selectMatchByDateByHour(jour, Integer.valueOf(heureChoice.getSelectedItem().substring(0, heureChoice.getSelectedItem().indexOf("h"))))); } else if (heureChoice.getSelectedItem().equals("Tous")) { //Mise à jour des bordures des panels panMatch2.setVisible(true); panMatch3.setVisible(true); panMatch4.setVisible(true); panMatch5.setVisible(true); panMatch6.setVisible(false); panMatch1.setBorder(new TitledBorder("8h")); panMatch2.setBorder(new TitledBorder("11h")); panMatch3.setBorder(new TitledBorder("15h")); panMatch4.setBorder(new TitledBorder("18h")); panMatch5.setBorder(new TitledBorder("21h")); //Mise à jour du label indiquant la sélection lbSelected.setText(courtChoice.getSelectedItem()); MatchDao mdao = DaoFactory.getMatchDao(); remplirPlanningCourts(mdao.selectMatchByTerrainByDate(jour, affecteNumCourt(courtChoice.getSelectedItem()))); } else { //Mise à jour des bordures des panels panMatch2.setVisible(false); panMatch3.setVisible(false); panMatch4.setVisible(false); panMatch5.setVisible(false); panMatch6.setVisible(false); panMatch1.setBorder(new TitledBorder(courtChoice.getSelectedItem() + " - " + heureChoice.getSelectedItem())); //Mise à jour du label indiquant la sélection lbSelected.setText(courtChoice.getSelectedItem() + " - " + heureChoice.getSelectedItem()); MatchDao mdao = DaoFactory.getMatchDao(); remplirPlanningCourtHeure(mdao.selectMatchByDateByHour(jour, Integer.valueOf(heureChoice.getSelectedItem().substring(0, heureChoice.getSelectedItem().indexOf("h"))))); } }
56c1162f-e2ec-4670-9e59-627c7c4c3ffb
8
public void newArray(final Type type) { int typ; switch (type.getSort()) { case Type.BOOLEAN: typ = Opcodes.T_BOOLEAN; break; case Type.CHAR: typ = Opcodes.T_CHAR; break; case Type.BYTE: typ = Opcodes.T_BYTE; break; case Type.SHORT: typ = Opcodes.T_SHORT; break; case Type.INT: typ = Opcodes.T_INT; break; case Type.FLOAT: typ = Opcodes.T_FLOAT; break; case Type.LONG: typ = Opcodes.T_LONG; break; case Type.DOUBLE: typ = Opcodes.T_DOUBLE; break; default: typeInsn(Opcodes.ANEWARRAY, type); return; } mv.visitIntInsn(Opcodes.NEWARRAY, typ); }
b00865b3-81d9-4ac5-9a9c-16ba9901fa8e
8
public ComparativeTableControl.DataSource getComparativeDataSource() { return new ComparativeTableControl.DataSource() { public int getRowCount() { int rowCount = 0; for (int dsftBinIndex = 0; dsftBinIndex < dsftBinSpriteSetList.size(); ++dsftBinIndex) { DsftBinSpriteSet dsftBin = (DsftBinSpriteSet)dsftBinSpriteSetList.get(dsftBinIndex); DsftBinSprite dsftBinSpriteArray[] = dsftBin.getDsftBinSpriteArray(); rowCount += dsftBinSpriteArray.length; } return rowCount; } public byte[] getData(int dataRow) { int currentRow = 0; for (int dsftBinIndex = 0; dsftBinIndex < dsftBinSpriteSetList.size(); ++dsftBinIndex) { DsftBinSpriteSet dsftBin = (DsftBinSpriteSet)dsftBinSpriteSetList.get(dsftBinIndex); DsftBinSprite dsftBinSpriteArray[] = dsftBin.getDsftBinSpriteArray(); for (int dsftBinSpriteIndex = 0; dsftBinSpriteIndex < dsftBinSpriteArray.length; ++dsftBinSpriteIndex) { if (dataRow == currentRow) { return dsftBinSpriteArray[dsftBinSpriteIndex].getData(); } else { ++currentRow; } } } throw new RuntimeException("Should never reach here"); } public int getAdjustedDataRowIndex(int dataRow) { return dataRow; } public String getIdentifier(int dataRow) { int currentRow = 0; for (int dsftBinIndex = 0; dsftBinIndex < dsftBinSpriteSetList.size(); ++dsftBinIndex) { DsftBinSpriteSet dsftBin = (DsftBinSpriteSet)dsftBinSpriteSetList.get(dsftBinIndex); DsftBinSprite dsftBinSpriteArray[] = dsftBin.getDsftBinSpriteArray(); for (int dsftBinSpriteIndex = 0; dsftBinSpriteIndex < dsftBinSpriteArray.length; ++dsftBinSpriteIndex) { if (dataRow == currentRow) { return String.valueOf(dsftBinIndex) + "." + String.valueOf(dsftBinSpriteIndex) + ": " + ((dsftBinSpriteArray[dsftBinSpriteIndex].getSetName().length() == 0) ? " " : dsftBinSpriteArray[dsftBinSpriteIndex].getSetName()) + "." + dsftBinSpriteArray[dsftBinSpriteIndex].getSpriteName(); } else { ++currentRow; } } } throw new RuntimeException("Should never reach here"); } public int getOffset(int dataRow) { return 0; } }; }
d1aabac7-4423-4cad-a448-dbbab5bdf546
6
public void mouseDragged(MouseEvent e) { if (buttonSelected == null || buttonSelected == ButtonSelected.DRAW_TRIANGLE) return; if (buttonSelected == ButtonSelected.SELECT) { if (handlesSelected) { // resizing shape createOrUpdateShape(e, Action.UPDATE_SELECTED, anchor); handleManager.createOutline(shapeManager.getSelectedShape()); System.out.println(anchor.x + " " + anchor.y); } else if (handleManager.isSomethingSelected()) { // dragging shape System.out.println("shifting.."); int xShift = e.getX() - pointClicked.x; int yShift = e.getY() - pointClicked.y; shapeManager.shiftShape(xShift, yShift); handleManager.shiftHandles(xShift, yShift); GUIFunctions.refresh(); } } else { if (initializeShape) { createOrUpdateShape(e, Action.STARTED_DRAWING, pointClicked); initializeShape = false; } else { createOrUpdateShape(e, Action.CURRENTLY_DRAWING, pointClicked); } } }
1498c2c1-f317-4e08-802d-6a8734219992
6
public static boolean fixedTimeEqual(String lhs, String rhs) { boolean equal = (lhs.length() == rhs.length() ? true : false); // If not equal, work on a single operand to have same length. if(!equal) { rhs = lhs; } int len = lhs.length(); for(int i=0;i<len;i++) { if(lhs.charAt(i) == rhs.charAt(i)) { equal = equal && true; } else { equal = equal && false; } } return equal; }
64b2d911-66d1-470c-825f-b498826ab958
5
public int canCompleteCircuit(int[] gas, int[] cost) { int[] r = new int[gas.length]; int idx = 0, s = 0, b = -1, ts = 0; for(int i = 0; i<gas.length; i++) r[i] = gas[i] - cost[i]; for(idx = 0; idx < r.length; idx++){ ts += r[idx]; s += r[idx]; if(s<0){ b = -1; s = 0; } else{ if(b == -1) b = idx; } } if(ts<0) return -1; else return b; }
c385c94c-d3c9-4f56-9ae5-a015a5308aa5
6
@Override public void keyPressed(KeyEvent e) { int delta_x = 0; int delta_y = 0; switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: delta_x = -OFFSET; break; case KeyEvent.VK_RIGHT: delta_x = OFFSET; break; case KeyEvent.VK_UP: delta_y = -OFFSET; break; case KeyEvent.VK_DOWN: delta_y = OFFSET; break; } if (delta_x != 0 || delta_y != 0) { Rectangle bounds = viewer.getViewportBounds(); double x = bounds.getCenterX() + delta_x; double y = bounds.getCenterY() + delta_y; viewer.setCenter(new Point2D.Double(x, y)); viewer.repaint(); } }
c387dfad-44ff-4a94-9be2-7463f07ed953
1
@Override public Converter put(String key, Converter value) { Converter v = super.put(key, value); if (v != null) { throw new IllegalArgumentException("Duplicate Converter for " + key); } return v; }
48179c15-52ad-4e3f-96ea-5dad8f1081e7
9
final public boolean handshakeResponse(ByteBuffer downloadBuffer) throws WebSocketException { ByteBuffer buffer = null; try{ if (state == State.INIT || state == State.DONE) { transitionTo(State.METHOD); responseStatus = -1; httpResponseHeaderParser = new HttpResponseHeaderParser(); bufferManager.init(); buffer = downloadBuffer; } else { buffer = bufferManager.getBuffer(downloadBuffer); } if (state == State.METHOD || state == State.HEADER) { int position = buffer.position(); if (!parseHandshakeResponseHeader(buffer)) { buffer.position(position); bufferManager.storeFragmentBuffer(buffer); return false; } transitionTo(State.BODY); } if (state == State.BODY) { int position = buffer.position(); if (!parseHandshakeResponseBody(buffer)) { buffer.position(position); bufferManager.storeFragmentBuffer(buffer); return false; } } return done(); }finally{ if(buffer != null && buffer != downloadBuffer){ downloadBuffer.position(downloadBuffer.limit() - buffer.remaining()); } } }
2b889dae-54ca-4d63-a2e7-b5852844e409
3
public void removeProfessor(String matricula) throws ProfessorInexistenteException { boolean teste = false; for (Professor e : professores) { if (e.getMatricula().equals(matricula)) { professores.remove(e); teste = true; break; } } if (teste == false) { throw new ProfessorInexistenteException( "Remove Professor Inexistente"); } }
30b75f66-433b-46a7-bd58-9eab85a1d74f
2
public Object get(String key) throws JSONException { if (key == null) { throw new JSONException("Null key."); } Object object = this.opt(key); if (object == null) { throw new JSONException("JSONObject[" + quote(key) + "] not found."); } return object; }
7749eaf1-4ab2-44d7-a2ad-f214e06b813c
9
public static void main(String[] args){ //int[] arr = {4, 3, 5, 1, 2, 6, 9, 2, 10, 11}; int[] arr = {4, 33, 5, 33, 2, 6, 9, 2, 10, 11,45}; int min; int max; int i = 0; int totalElements = arr.length; //no items in array, show a message if(totalElements == 0){ System.out.println("There are no itesm in the array"); } else if(totalElements == 1){ System.out.println("Min: " + arr[0]); System.out.println("Max: " + arr[0]); } else{ if(totalElements % 2 != 0){ min = arr[0]; max = arr[0]; i = 1; } else{ min = arr[0]; max = arr[1]; i = 2; } //check while there are items to go through while(i < totalElements - 1){ //here, we check if the left item is larger than the right, if it is, we then check the larger item with max and the smaller one with min. if(arr[i] > arr[i + 1]){ if(arr[i] > max){ max = arr[i]; } if(arr[i+1] < min){ min = arr[i+1]; } } //same as above, just flip the order else{ if(arr[i+1] > max){ max = arr[i+1]; } if(arr[i] < min) { min = arr[i]; } } //move counter two ahead because we've compared 2 ahead already i = i + 2; } System.out.println("Min is: " + min); System.out.println("Max is: " + max); } }
1a3c19e3-90de-4c71-9c08-4b3e6f979e55
3
public ImageCreatorDialog(final Panel panel) { setTitle("Create square image"); setBounds(1, 1, 250, 130); Toolkit toolkit = getToolkit(); Dimension size = toolkit.getScreenSize(); setLocation(size.width / 3 - getWidth() / 3, size.height / 3 - getHeight() / 3); this.setResizable(false); setLayout(null); JPanel pan1 = new JPanel(); pan1.setBorder(BorderFactory.createTitledBorder("Size")); pan1.setBounds(0, 0, 250, 60); JLabel sizeLabel = new JLabel("Size = "); final JTextField sizeField = new JTextField("300"); sizeField.setColumns(3); JButton okButton = new JButton("OK"); okButton.setSize(250, 40); okButton.setBounds(0, 60, 250, 40); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int size; try { size = Integer.valueOf(sizeField.getText().trim()); } catch (NumberFormatException ex) { new MessageFrame("Invalid data"); return; } if (size <= 0) { new MessageFrame("The image must be at least of 1x1"); return; } Image img = createBinaryImage(size, size); if (img != null) { panel.setImage(img); panel.repaint(); dispose(); } else { new MessageFrame("Invalid values"); return; } } }); pan1.add(sizeLabel); pan1.add(sizeField); this.add(pan1); this.add(okButton); }
ca92efae-cb1e-4edc-aed3-602d0fb1e875
6
@Override public void deserialize(Buffer buf) { super.deserialize(buf); id = buf.readInt(); if (id < 0) throw new RuntimeException("Forbidden value on id = " + id + ", it doesn't respect the following condition : id < 0"); lifePoints = buf.readInt(); if (lifePoints < 0) throw new RuntimeException("Forbidden value on lifePoints = " + lifePoints + ", it doesn't respect the following condition : lifePoints < 0"); maxLifePoints = buf.readInt(); if (maxLifePoints < 0) throw new RuntimeException("Forbidden value on maxLifePoints = " + maxLifePoints + ", it doesn't respect the following condition : maxLifePoints < 0"); prospecting = buf.readShort(); if (prospecting < 0) throw new RuntimeException("Forbidden value on prospecting = " + prospecting + ", it doesn't respect the following condition : prospecting < 0"); regenRate = buf.readUByte(); if (regenRate < 0 || regenRate > 255) throw new RuntimeException("Forbidden value on regenRate = " + regenRate + ", it doesn't respect the following condition : regenRate < 0 || regenRate > 255"); }
dbc29f78-f5e8-4603-904c-2ec4e82365e9
6
@Override public String toString() { String rtn = "size = " + size + "\nUndealt cards: \n"; for (int k = size - 1; k >= 0; k--) { rtn = rtn + cards.get(k); if (k != 0) { rtn = rtn + ", "; } if ((size - k) % 2 == 0) { // Insert carriage returns so entire deck is visible on console. rtn = rtn + "\n"; } } rtn = rtn + "\nDealt cards: \n"; for (int k = cards.size() - 1; k >= size; k--) { rtn = rtn + cards.get(k); if (k != size) { rtn = rtn + ", "; } if ((k - cards.size()) % 2 == 0) { // Insert carriage returns so entire deck is visible on console. rtn = rtn + "\n"; } } rtn = rtn + "\n"; return rtn; }
3cfa9bea-0f17-4f16-8c2c-9e2da8df90c5
4
private void openConnection() { if (this.dbConnParamUrl == null) return; try { if (this.dbconn != null && !this.dbconn.isClosed()) this.dbconn.close(); this.dbconn = DriverManager.getConnection( dbConnParamUrl, dbConnParamUser, dbConnParamPassword ); } catch (SQLException e) { e.printStackTrace(); this.dbconn = null; } }
8c416ea8-0975-492d-a72e-e794e3c29ac7
7
static final void method3260(int i) { for (Class348_Sub15 class348_sub15 = (Class348_Sub15) Class27.aClass356_389.method3484(0); class348_sub15 != null; class348_sub15 = (Class348_Sub15) Class27.aClass356_389.method3482(0)) { if (((Class348_Sub15) class348_sub15).aClass55_Sub1_6768 .method510((byte) -125)) Class64_Sub3.method690((byte) 70, (((Class348_Sub15) class348_sub15) .anInt6773)); else { ((Class348_Sub15) class348_sub15).aClass55_Sub1_6768 .method522((byte) -91); try { ((Class348_Sub15) class348_sub15).aClass55_Sub1_6768 .method517(-2); } catch (Exception exception) { Class156.method1242("TV: " + ((Class348_Sub15) class348_sub15).anInt6773, exception, 15004); Class64_Sub3.method690((byte) 15, (((Class348_Sub15) class348_sub15) .anInt6773)); } if (!((Class348_Sub15) class348_sub15).aBoolean6783 && !((Class348_Sub15) class348_sub15).aBoolean6781) { Class348_Sub23_Sub1 class348_sub23_sub1 = ((Class348_Sub15) class348_sub15) .aClass55_Sub1_6768.method512(0); if (class348_sub23_sub1 != null) { Class348_Sub16_Sub2 class348_sub16_sub2 = class348_sub23_sub1.method2971(-61); if (class348_sub16_sub2 != null) { class348_sub16_sub2.method2827(-17708, (((Class348_Sub15) class348_sub15) .anInt6782)); Class348_Sub43.aClass348_Sub16_Sub4_7065 .method2883(class348_sub16_sub2); ((Class348_Sub15) class348_sub15).aBoolean6783 = true; } } } } } int i_0_ = 48 % ((-17 - i) / 63); anInt10448++; }
298cbf9c-0328-4d9e-8b39-020e2303fd44
8
public static void main(String[] args) throws InstantiationException, IllegalAccessException { int boardSize = 10; int timeout = 20000; for (String arg : args) { System.err.println(arg); } PrintStream origOut = System.out; System.setOut(System.err); System.err.println(args.length); if (args.length < 2) { System.err.printf("Arguments: first-player-jar second-player-jar [board-size=%d] [timeout=%d]\n", boardSize, timeout); return; } if (args.length >= 3) { boardSize = Integer.parseInt(args[2]); } if (args.length >= 4) { timeout = Integer.parseInt(args[3]); } Class<? extends Player>[] cl = new Class[2]; for (int i = 0; i < cl.length; ++i) { cl[i] = JarPlayerLoader.load(args[i]); } System.setSecurityManager(new SecurityManager()); BoardFactory boardFactory = new SnortBoardFactory(); Map<String, Object> config = new HashMap<>(); config.put(BoardFactory.BOARD_SIZE, boardSize); boardFactory.configure(config); GameEngine g = new GameEngineImpl(boardFactory); g.setTimeout(timeout); Player[] p = new Player[cl.length]; String result = ""; for (int i = 0; i < cl.length; ++i) { p[i] = cl[i].newInstance(); g.addPlayer(p[i]); result += getName(p[i]) + ";"; } String error = ""; Color winner; try { winner = g.play(new Callback() { @Override public void update(Color c, Board b, Move m) { System.out.println(b); } }); } catch (RuleViolationException ex) { winner = Player.getOpponent(ex.getGuilty()); error = "\"" + escape(ex.toString()) + "\""; } result += "\"" + winner + "\";" + error + ";"; origOut.println(result); }
ea9a7880-a75d-4a14-9360-b8421f24f26b
9
protected void switchChannel(String toReplace, String replacing) { if (toReplace.equals(replacing.toLowerCase())) { //Nothing to edit, reload the initial picture this.changePicture(this.getRelURL()); this.revalidateContainer(); reloadChanges(); return; } // BufferedImage toEdit = getBufferedImage(); // FilteredImageSource filteredSrc; // // ColorFilter filter = new ColorFilter(); // // if (toReplace.toLowerCase().equals(labels[0].toLowerCase())) { // filter.setDisplayed(0xFF0000); // setOthers(filter, replacing, labels[1].toLowerCase(), 0x00FF00, 0x0000FF, 8, 16, LEFT_SHIFT); // } else if (toReplace.toLowerCase().equals(labels[1].toLowerCase())) { // filter.setDisplayed(0x00FF00); // setOthers(filter, replacing, labels[0].toLowerCase(), 0xFF0000, 0x0000FF, 8, 8, MIDDLE); // } else { // filter.setDisplayed(0x0000FF); // setOthers(filter, replacing, labels[0].toLowerCase(), 0xFF0000, 0x00FF00, 16, 8, RIGHT_SHIFT); // } BufferedImage toEdit = null; try { toEdit = getOriginalBufferedImage(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } FilteredImageSource filteredSrc = null; ColorSwapper filter = null; // if (replacing.toLowerCase().equals(labels[3].toLowerCase())) { // //filter = hideColor(toReplace); // //filteredSrc = new FilteredImageSource(toEdit.getSource(), filter); // // } else { filter = new ColorSwapper(); int[] redShift = {-1, -1, -1}, greenShift = {-1, -1, -1}, blueShift = {-1, -1, -1}; int redShiftIndex = 0, greenShiftIndex = 0, blueShiftIndex = 0; boolean[] greenLeftShift = new boolean[3]; boolean[] hideRed = {false, false, false}, hideGreen = {false, false, false}, hideBlue = {false, false, false}; for (int i =0; i < 3; i++ ) { if (((String)selectors[i].getSelectedItem()).toLowerCase().equals("red")) { redShift[redShiftIndex] = getShift("red", labels[i]); System.out.println("Adding to red shifts: " + redShift[redShiftIndex]); redShiftIndex++; } else if (((String)selectors[i].getSelectedItem()).toLowerCase().equals("green")) { greenShift[greenShiftIndex] = getShift("green", labels[i]); if (greenShift[greenShiftIndex] == -8) { greenLeftShift[greenShiftIndex] = true; greenShift[greenShiftIndex] = 8; } System.out.println("Adding to green shifts: " + greenShift[greenShiftIndex] + " " + greenLeftShift[greenShiftIndex]); greenShiftIndex++; } else if (((String)selectors[i].getSelectedItem()).toLowerCase().equals("blue")) { blueShift[blueShiftIndex] = getShift("blue", labels[i]); System.out.println("Adding to blue shifts: " + blueShift[blueShiftIndex]); blueShiftIndex++; } else { System.out.println("HIDING A COLOR"); if (labels[i].equals("Red")) { hideRed[redShiftIndex] = true; redShiftIndex++; } else if (labels[i].equals("Green")) { hideGreen[greenShiftIndex]=true; greenShiftIndex++; } else { hideBlue[blueShiftIndex]=true; blueShiftIndex++; } } } filter.setBlueColorShift(blueShift); filter.setGreenColorShift(greenShift); filter.setRedColorShift(redShift); filter.setGreenLeftShift(greenLeftShift); filter.setHideRed(hideRed); filter.setHideGreen(hideGreen); filter.setHideBlue(hideBlue); filteredSrc = new FilteredImageSource(toEdit.getSource(), filter); Image img = Toolkit.getDefaultToolkit().createImage(filteredSrc); this.changePicture(img); // redShift = getShift("red", ); // if (redShift == -1) { // filter.setHideRed(true); // } else { // filter.setRedColorShift(redShift); // } // greenShift = getShift("green", (String)selectors[1].getSelectedItem()); // if (greenShift == -1) { // filter.setHideGreen(true); // } else { // if (greenShift < 0) { // filter.setGreenLeftShift(true); // filter.setGreenColorShift(-greenShift); // } else { // filter.setGreenColorShift(greenShift); // } // } // // blueShift = getShift("blue", (String)selectors[2].getSelectedItem()); // if (blueShift == -1) { // filter.setHideBlue(true); // } else { // filter.setBlueColorShift(blueShift); // } // if (replacing.toLowerCase().equals(labels[0].toLowerCase())) { // System.out.println("REDFILTER"); // filter = new RedFilter(); // if (toReplace.equals(labels[1].toLowerCase())) { // // ((RedFilter)filter).setDisplayAs(0x00FF00); // } else { // ((RedFilter)filter).setDisplayAs(0x0000FF); // } // } else if (replacing.toLowerCase().equals(labels[1].toLowerCase())) { // filter = new GreenFilter(); // if (toReplace.equals(labels[0].toLowerCase())) { // // ((GreenFilter)filter).setDisplayAs(0xFF0000); // } else { // ((GreenFilter)filter).setDisplayAs(0x0000FF); // } // } else { // filter = new BlueFilter(); // if (toReplace.equals(labels[0].toLowerCase())) { // // ((BlueFilter)filter).setDisplayAs(0xFF0000); // } else { // ((BlueFilter)filter).setDisplayAs(0x00FF00); // } // } }
21542663-0fa9-4e39-9913-058af6ef244f
2
public void testWithFieldAdded8() { Partial test = createHourMinPartial(0, 0, ISO_UTC); try { test.withFieldAdded(DurationFieldType.minutes(), -1); fail(); } catch (IllegalArgumentException ex) { // expected } check(test, 0, 0); test = createHourMinPartial(0, 0, ISO_UTC); try { test.withFieldAdded(DurationFieldType.hours(), -1); fail(); } catch (IllegalArgumentException ex) { // expected } check(test, 0, 0); }
dec11a34-fd07-41bf-8cac-b7fe1f65d93d
0
public InternalRewrite(Map<String, String> headers, String uri) { super(null); this.headers = headers; this.uri = uri; }
ef811abf-74f4-4736-bb4f-51002b815e2d
0
public static CircleEquation newInstance(float a, float b, float r) { return new CircleEquation(a, b, r); }
da98c315-abd5-4839-874c-23e540144d53
8
public int insertObject(Object obj) { String table = this.getTableName(this.getObjectClass(obj).toString()); String fieldName[] = this.getField(obj); String sql = "INSERT INTO "+PREFIX+table+"("; for (int i = 0; i < fieldName.length; i++) { sql += fieldName[i]; if(i != fieldName.length -1) sql += ","; } sql += ") values("; int result = -1; try { Object value[] = this.getValue(obj); for (int i = 0; i < value.length; i++) { if(value[i] instanceof Date){ Date date = (Date)value[i]; String values = this.dateFormat(date); sql += "'"+values+"'"; }else{ if(!validUtf8(value[i].toString())){ sql += "N'"+value[i]+"'"; }else{ sql += "'"+value[i]+"'"; } } if(i != value.length -1) sql += ","; } sql += ")"; //system.out.println(sql); Statement stt = this.connection.createStatement(); result = stt.executeUpdate(sql); } catch (SQLException e) { // TODO Auto-generated catch block return result; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
a55c0939-1668-4440-9ff1-4938394df269
3
public static void main(String[] args) throws Exception { if (args.length < 2) { System.out.println("Usage: java JGrep file regex"); System.exit(0); } Pattern p = Pattern.compile(args[1]); // Iterate through the lines of the input file: int index = 0; Matcher m = p.matcher(""); for (String line : new TextFile(args[0])) { m.reset(line); while (m.find()) System.out.println(index++ + ": " + m.group() + ": " + m.start()); } }
1b0e1e78-5a1d-49be-958e-950120628256
1
private static String getExpressionWithToken(ParsedExpression parsedExpression, String token) { String originalExpression = parsedExpression.getOriginalExpression(); StringBuilder actualExpression = new StringBuilder(); List<String> paramNames = parsedExpression.getParameterNames(); int lastIndex = 0; for (int i = 0; i < paramNames.size(); i++) { int[] indexes = parsedExpression.getParameterIndexes(i); int startIndex = indexes[0]; int endIndex = indexes[1]; actualExpression.append(originalExpression.substring(lastIndex, startIndex)); actualExpression.append(token); lastIndex = endIndex; } actualExpression.append(originalExpression.substring(lastIndex, originalExpression.length())); return actualExpression.toString(); }
4565f9fa-701e-4908-9ed8-97b0525846fe
3
public TrialGroup(List<Trial> trials, boolean lowLoad) throws IncorrectNumberOfTrialsException { super(trials); if (trials.size() != Options.TRIALS_PER_GROUP) { //should not occur throw new IncorrectNumberOfTrialsException("Trying to create a group of " + Options.TRIALS_PER_GROUP + " trials, but only " + trials.size() + " were passed to the constructor!"); } else { for (int i = 0; i < trials.size(); i++) { trials.get(i).indexInTrialGroup = i; } if (lowLoad) { pattern = new LowloadPattern(); } else { pattern = new HighloadPattern(); } } }
207abfa5-a6ba-498b-978e-9d444f8eea5f
1
public static final List<String> getItemUrls( ResponseWrapper responseWrapper, Logger logger) { List<String> urlStrings = new ArrayList<String>(); Element doc = responseWrapper.getDoc(); Elements itemElements = doc.select("dl.item"); for (Element itemElement : itemElements) { Element aElement = itemElement.select("a.item-name").first(); String urlString = aElement.attr("href"); urlStrings.add(urlString); } return urlStrings; }
2cf18c7d-a7c2-42ca-86c6-1602c380087e
8
public static void globalBypass(String arg){ arg = arg.toLowerCase(); if(TOGGLES.containsKey(arg)){ if(!checkPermission("eCore.invBypass.global.toggle", true)) return; switch(TOGGLES.get(arg)){ case 0: GlobalDataManager.invBypass = !GlobalDataManager.invBypass; break; case 1: GlobalDataManager.invBypass = true; break; case 2: GlobalDataManager.invBypass = false; break; } PlayerManager.updateAllInventories(); sender.sendMessage(ChatColor.DARK_BLUE + "[eCore] " + ChatColor.WHITE + "Set the global invBypass to: " + (GlobalDataManager.invBypass?"true":"false")); } else { if(!checkPermission("eCore.invBypass.global.use", true)) return; sender.sendMessage(ChatColor.DARK_BLUE + "[eCore] " + ChatColor.WHITE + "The global invBypass currently is: " + (GlobalDataManager.invBypass?"true":"false")); } }
56a809d7-4845-4920-a4f9-9c57cc39b36a
8
final public void Print_statement() throws ParseException { /*@bgen(jjtree) Print_statement */ SimpleNode jjtn000 = new SimpleNode(JJTPRINT_STATEMENT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { jj_consume_token(PRINT); Expression(); jj_consume_token(SEMICOLON); } 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); jjtn000.jjtSetLastToken(getToken(0)); } } }
77d56027-f915-4da9-8c25-65a59e94589a
6
public boolean parsePatch(File f, String patch) { String s = null; boolean result = false; if(patch.equalsIgnoreCase(CARRIER_PATCH)) { s = findReturn(f, "this.carrierText = \""); if(s!=null) { carrierString = s.substring(s.indexOf("\"")+1, s.lastIndexOf("\"")); result = true; } } else if(patch.equalsIgnoreCase(TEXTCOLOUR_PATCH)) { s = findReturn(f, "color:"); if(s!=null) { s = s.substring(s.indexOf(":")+1, s.indexOf(";")).trim(); textColour = Color.decode(s); result = true; } } else if(patch.equalsIgnoreCase(OPACITY_PATCH)) { s = findReturn(f, "opacity:"); if(s!=null) { s = s.substring(s.indexOf(":")+1, s.indexOf(";")).trim(); opacity = (int)(Double.parseDouble(s)*100); result = true; } } return result; }
edddced3-0dd0-476b-bcff-070440781d81
1
public String getStatus() { if (active) { return "Active"; } else { return "Paused"; } }
900d2f3c-f095-4e1a-aee7-6f46352d65c1
8
@Override public List<Gruppi> getGruppiByUtente(Utente utente) { List<Gruppi> result = new ArrayList(); ResultSet rs = null; ResultSet rs1 = null; try { gIdGruppi_Utente.setInt(1, utente.getKey()); rs = gIdGruppi_Utente.executeQuery(); while (rs != null && rs.next()) { try { gGruppi.setInt(1, rs.getInt("id_gruppo")); rs1 = gGruppi.executeQuery(); } catch (SQLException exception) { Logger.getLogger(MeetingplanDataLayer.class.getName()).log(Level.SEVERE, null, exception); } while (rs1 != null && rs1.next()) { result.add(new GruppiMysqlImpl(this, rs1)); } } } catch (SQLException exception) { Logger.getLogger(MeetingplanDataLayer.class.getName()).log(Level.SEVERE, null, exception); } finally { try { if (rs != null) { rs.close(); } } catch (SQLException ex) { Logger.getLogger(MeetingplanDataLayerMysqlImpl.class.getName()).log(Level.SEVERE, null, ex); } } return result; }
464fbac2-abd7-4cdf-8322-d7164a50e831
1
@Override public String handle(String cmd) { if (cmd.equals("clear")) { setText(""); } else { return "unknown command '" + cmd + "'\n"; } return null; }
380daa1c-b384-47ad-9636-905a37e1c0cc
2
String paramList(String title, CSProperties p) { if (p.size() == 0) { return ""; } List<String> keys = new ArrayList<String>(p.keySet()); Collections.sort(keys); StringBuffer db = new StringBuffer(); db.append("<variablelist>"); for (String name : keys) { db.append(varlistentry(name, p.get(name).toString(), p.getInfo(name))); } db.append("</variablelist>"); return db.toString(); }
7987db6c-1fdf-4c9c-936b-67803d47424f
3
public boolean method537() { if (anIntArray658 == null) { return true; } boolean flag = true; for (int j = 0; j < anIntArray658.length; j++) { if (!Model.isCached(anIntArray658[j])) { flag = false; } } return flag; }
60428e1a-7441-413c-b79c-d62390c1bcc2
1
public void updateUi(String yourPlayerId) { updateUiPlayerId = yourPlayerId; game.sendUpdateUI(new UpdateUI(yourPlayerId, playersInfo, gameState.getStateForPlayerId(yourPlayerId), lastGameState == null ? null : lastGameState.getStateForPlayerId(yourPlayerId), lastMove, lastMovePlayerId, gameState.getPlayerIdToNumberOfTokensInPot())); }
6ab6fc40-23dd-4e0f-8b69-14a8f2c9bd2a
2
public DummySSLSocketFactory() { try { SSLContext sslcontent = SSLContext.getInstance("TLS"); sslcontent.init(null, new TrustManager[]{new DummyTrustManager()}, new java.security.SecureRandom()); factory = sslcontent.getSocketFactory(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(System.out); } catch (KeyManagementException e) { e.printStackTrace(System.out); } }
0842ff11-e6a5-4917-aaed-eea4584b8971
4
protected void append(LoggingEvent event) { if (!performChecks()) { return; } String logOutput = this.layout.format(event); appenderUI.doLog(logOutput); if (layout.ignoresThrowable()) { String[] lines = event.getThrowableStrRep(); if (lines != null) { int len = lines.length; for (int i = 0; i < len; i++) { appenderUI.doLog(lines[i]); appenderUI.doLog(Layout.LINE_SEP); } } } }
bf8a0daf-b80e-43d6-b312-fcd7d6b6cb34
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ClientMessage other = (ClientMessage) obj; if (_name == null) { if (other._name != null) return false; } else if (!_name.equals(other._name)) return false; return true; }
09d17254-77bb-4b0b-999d-a20e5f5af365
9
public int winner() { // A player captured enought seeds if (position[12] > 24) return SOUTH; if (position[13] > 24) return NORTH; if (position[12] == 24 && position[13] == 24) return DRAW; // The game hasn't ended yet if (hasLegalMoves()) return DRAW; // No legal moves can be performed. Each player captures the // remaining seeds on their side byte south = position[12]; for (int i = 0; i < 6; i++) south += position[i]; byte north = position[13]; for (int i = 6; i < 12; i++) north += position[i]; if (south == north) return DRAW; return (south > north) ? SOUTH : NORTH; }
e74aa8e7-d959-4cfb-b4e7-92fbaa892344
2
private boolean go(Direction dirToGo) { try { StringBuffer output = new StringBuffer(); boolean hasMoved = CommandController.getPlayer().move(dirToGo, output); printMessage(output.toString()); return hasMoved; } catch(Exception e) { if(e instanceof EndGameException) { ((EndGameException) e).handleExeception(); } printMessage(e.getMessage()); return false; } }
f923c8a5-14ec-43f2-9bd4-c5c8ae455550
9
public FileView(Composite parent) { this.canvas = new Canvas(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_BACKGROUND); canvas.addMouseWheelListener(new MouseWheelListener() { public void mouseScrolled(MouseEvent event) { ScrollBar bar = canvas.getVerticalBar(); bar.setSelection(bar.getSelection() - event.count * 50); } }); canvas.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent event) { setBounds(); canvas.redraw(); } }); canvas.addMouseListener(new MouseAdapter() { public void mouseUp(MouseEvent event) { int line = (canvas.getVerticalBar().getSelection() + event.y) / lineHeight; TreeItem treeItem = activeModel.getTreeItemAtRow(line); if(treeItem != null) { if(event.x + canvas.getHorizontalBar().getSelection() < 20) { if(treeItem.hasChildren()) { treeItem.toggleExpanded(); } setBounds(); canvas.redraw(); } } } }); canvas.getHorizontalBar().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { canvas.redraw(); } }); canvas.getVerticalBar().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { int diff = verticalOffset - canvas.getVerticalBar().getSelection(); canvas.scroll(0, diff, 0, 0, canvas.getBounds().width, canvas.getBounds().height, true); verticalOffset = canvas.getVerticalBar().getSelection(); } }); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent event) { Image buffer = new Image(Display.getCurrent(), canvas.getBounds()); GC gc = new GC(buffer); gc.setAntialias(SWT.ON); gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); int top = verticalOffset; int bottom = verticalOffset + canvas.getClientArea().height; Transform transform = new Transform(Display.getCurrent()); transform.translate(-canvas.getHorizontalBar().getSelection(), 0); gc.setTransform(transform); int offsetY = -(top % lineHeight); for( TreeItem treeItem = activeModel.getTreeItemAtRow(top / lineHeight); treeItem != null && treeItem.getRow() * lineHeight <= bottom; treeItem = treeItem.getNext() ) { int indent = 0; if(treeItem.hasChildren() || treeItem.getLevel() > 0) { gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); indent = 10; } else { gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); } gc.drawText(treeItem.getText(), 20 + indent, offsetY + 2); gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); if(treeItem.hasChildren()) { Rectangle expander = new Rectangle(3, offsetY + 4, 4, 8); if(treeItem.isExpanded()) { gc.drawLine(expander.x, expander.y + 2, expander.x + 10, expander.y + 2); gc.drawLine(expander.x, expander.y + 2, expander.x + 5, expander.y + 7); gc.drawLine(expander.x + 10, expander.y + 2, expander.x + 5, expander.y + 7); } else { gc.drawLine(expander.x + 2, expander.y, expander.x + 2, expander.y + 10); gc.drawLine(expander.x + 2, expander.y, expander.x + 7, expander.y + 5); gc.drawLine(expander.x + 2, expander.y + 10, expander.x + 7, expander.y + 5); } } offsetY += lineHeight; } event.gc.drawImage(buffer, 0, 0); buffer.dispose(); transform.dispose(); } }); }
666aa3c6-451a-4207-b9e4-73eb852c572f
6
@Override public boolean equals(Object obj) { if(!(obj instanceof Result)) { return false; } Result that = (Result) obj; if( this.coeff1==that.coeff1 && this.coeff2==that.coeff2 && this.gcd==that.gcd && this.errorFlag==that.errorFlag && this.err==that.err ) {return true;} return false; }
8482222b-7939-4e86-bb18-4cd8742cd1cd
3
private void runGA() { int generation = 1; while (generation<=this.generations) { System.out.println("Generation "+generation); population.evaluate(fitnessFunction); T populationFittest = population.getFittestIndividual(); if (generation == 1) fittestIndividual = populationFittest; else if (populationFittest.getFitness() > fittestIndividual.getFitness()) { fittestIndividual = populationFittest; } population.nextGeneration(); generation++; } }
a1bab904-8dd6-437c-91e0-c2354bbe919e
1
public String[] getAllPlayersName() { ArrayList<String> names = new ArrayList<String>(); for (Player player : players) { names.add(player.getName()); } return names.toArray(new String[names.size()]); }
85a57699-d584-486e-b93e-efdf71be0018
9
@Override public int hashCode( ) { final int prime = 31; int result = 1; result = prime * result + ( ativo ? 1231 : 1237 ); result = prime * result + ( ( codigo == null ) ? 0 : codigo.hashCode( ) ); result = prime * result + ( ( email == null ) ? 0 : email.hashCode( ) ); result = prime * result + ( ( idioma == null ) ? 0 : idioma.hashCode( ) ); result = prime * result + ( ( login == null ) ? 0 : login.hashCode( ) ); result = prime * result + ( ( nascimento == null ) ? 0 : nascimento.hashCode( ) ); result = prime * result + ( ( nome == null ) ? 0 : nome.hashCode( ) ); result = prime * result + ( ( senha == null ) ? 0 : senha.hashCode( ) ); result = prime * result + ( ( telefone == null ) ? 0 : telefone.hashCode( ) ); return result; }
95da04f6-1247-4e52-b228-466ece1c6b87
5
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof GeoPosition)) return false; GeoPosition other = (GeoPosition) obj; if (Double.doubleToLongBits(latitude) != Double.doubleToLongBits(other.latitude)) return false; if (Double.doubleToLongBits(longitude) != Double.doubleToLongBits(other.longitude)) return false; return true; }
72162136-8cae-46f6-9e8b-8725200bcc1e
9
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.length ][2]; // Array com valores e nomes // Preencher scoreVals e scoreNomes for(int i=0; i<scoresArr.length; i++) { String[] scoresTemp = scoresArr[i].trim().split("\t"); if( !scoresTemp[1].isEmpty() ) // Nome { scoresVals[i] = Util.parseInt( scoresTemp[0] ); // Valor scoresNomes[i][0] = scoresTemp[0]; // Valor scoresNomes[i][1] = scoresTemp[1]; // Nome } } // Ordenar scoreVals Arrays.sort( scoresVals ); // Preparar para escrita PrintStream out; try { out = new PrintStream( new File(Engine.TOP_SCORES_FILE) ); } catch (FileNotFoundException e) { return false; } // Escrever no ficheiro for(int i=0; i<scoresArr.length; i++) { // Para só escrever até ao máximo de pontuações if( i>=Engine.MAX_TOP_SCORES ) break; int pos = scoresArr.length-1-i; // Posição do valor int valor = scoresVals[pos]; // Valor // Encontrar o nome String nome = new String(""); for(int j=0; j<scoresArr.length; j++) { if( scoresNomes[j][0].equals( ""+scoresVals[pos] ) ) { nome = scoresNomes[j][1]; // Nome break; } } if( !nome.isEmpty() ) { out.println(valor+"\t"+nome); // Escrever } } // Fechar o ficheiro out.close(); return true; }
aa2572e7-5c2c-44be-a1be-ffee229a176f
5
public void connect(boolean useXMPPConnection){ if (useXMPPConnection) { Utils.printWithDate("XMPP Connection to: " + hostXMPP + " (Port " + portXMPP + ") ... ", Utils.DEBUGLEVEL.GENERAL); ConnectionConfiguration xmppConfig = new ConnectionConfiguration(hostXMPP, portXMPP); xmppConfig.setReconnectionAllowed(true); loadCertificate(xmppConfig); connection = new XMPPTCPConnection(xmppConfig); boolean retryConnection = true; while (retryConnection && !shutdown) { try { connection.connect(); connection.login(usernameXMPP, passwordXMPP); Presence p = new Presence(Presence.Type.available); p.setStatus("Recommender available"); connection.sendPacket(p); Utils.printWithDate("connected", Utils.DEBUGLEVEL.GENERAL); retryConnection = false; } catch (SmackException | IOException | XMPPException e) { e.printStackTrace(); } } if (shutdown) return; initializePubSubConnection(); } else { System.out.println("-------------NO CONNECTION TO XMPP SERVER-------------"); } }
42b4d575-98dc-48e5-879b-c87ab80d63c7
7
private FullHttpResponse performStatus() { StatDAO stat = new StatDAO(); ResultSet resultSetTableIP = null; ResultSet resultSetTableRedirect = null; ResultSet resultSetTableRecentConnections = null; // HTML head StringBuilder message = new StringBuilder(); StringBuilder table3 = new StringBuilder(); message.append("<html><head>"); message.append("<style type=\"text/css\"> "); message.append("table { margin: 1em; border-collapse: collapse; } "); message.append("td, th { padding: .3em; border: 1px #ccc solid; } "); message.append("thead { background: #A5C5E6; }"); message.append("p {margin: 1em}"); message.append("</style></head>"); // HTML Body message.append("<body>"); try { // 1 Total count of requests message.append(String.format("<p>Total: %d</p>", stat.getTotalRequests())); // 2 count of distinct IP resultSetTableIP = stat.getTableDataByIP(); int countByIP = 0; table3.append("<table>"); table3.append("<thead><tr><td>IP</td><td>Requests</td><td>Last time</td></tr></thead>"); while (null != resultSetTableIP && resultSetTableIP.next()) { table3.append("<tr><td>").append(resultSetTableIP.getString("URI_STRING")).append("</td><td>"); table3.append(resultSetTableIP.getString("C")).append("</td><td>"); table3.append(resultSetTableIP.getString("STAMP")).append("</td></tr>"); countByIP++; } table3.append("</table>"); message.append(String.format("<p>Distinct requests by IP: %d</p>", countByIP)); // 3 Count of distinct IP. table with columns | IP | Count of requests from this IP | Date of last Request | message.append(table3); // 4 Count of redirects. table with columns | IP | Count of requests from this IP | Date of last Request | resultSetTableRedirect = stat.getTableDataByRedirect(); message.append("<table>"); message.append("<thead><tr><td>URL</td><td>Redirects</td></tr></thead>"); while (null != resultSetTableRedirect && resultSetTableRedirect.next()) { message.append("<tr><td>").append(resultSetTableRedirect.getString("URI_STRING")).append("</td><td>") .append(resultSetTableRedirect.getString("R")).append("</td></tr>"); } message.append("</table>"); // 5 Count of current open connections message.append(String.format("<p>Current connections: %d</p>", currentOnline.count())); // 6 Recent requests, // table with columns | IP | Count of requests from this IP | Date of last Request | resultSetTableRecentConnections = stat.getTableDataLast16(); message.append("<table>"); message.append("<thead><tr><td>src_ip</td><td>URI</td><td>timestamp</td><td>sent_bytes</td><td" ).append(">received_bytes</td><td>speed (bytes/sec)</td></tr></thead>"); while (null != resultSetTableRecentConnections && resultSetTableRecentConnections.next()) { message.append("<tr><td>").append(resultSetTableRecentConnections.getString("IP")).append("</td><td>"); message.append(resultSetTableRecentConnections.getString("URI")).append("</td><td>"); message.append(resultSetTableRecentConnections.getString("STAMP")).append("</td><td>"); message.append(resultSetTableRecentConnections.getString("SENT_BYTES")).append("</td><td>"); message.append(resultSetTableRecentConnections.getString("RECEIVED_BYTES")).append("</td><td>"); message.append(resultSetTableRecentConnections.getString("SPEED")).append("</td></tr>"); } message.append("</table>"); } catch (SQLException ex) { Logger.getLogger(HttpServerHandler.class.getName()).log(Level.SEVERE, null, ex); } finally { StatDAO.attemptClose(resultSetTableIP); StatDAO.attemptClose(resultSetTableRedirect); StatDAO.attemptClose(resultSetTableRecentConnections); } message.append("</body></html>"); return createResponse(message.toString(), OK); }
adbb5afd-a89a-413e-9f39-f2781ed25b71
9
public boolean validaEmail(String Email) { boolean Validacao = true; if ((Email.contains("@")) && (Email.contains(".")) && (!Email.contains(" "))) { String usuario = new String(Email.substring(0, Email.lastIndexOf('@'))); String dominio = new String(Email.substring(Email.lastIndexOf('@') + 1, Email.length())); if ((usuario.length() >= 1) && (!usuario.contains("@")) && (dominio.contains(".")) && (!dominio.contains("@")) && (dominio.indexOf(".") >= 1) && (dominio.lastIndexOf(".") < dominio.length() - 1)) { Validacao = true; } else { Validacao = false; } } else { Validacao = false; } return Validacao; }
9f5c8a06-2510-4a4b-a52c-6de606cb2ade
4
public int compareTo(Endpoint other) { double length = Math.abs(value); double otherLength = Math.abs(other.value); double distance = length - otherLength; if (distance == 0.0d) { if (type.ordinal() < other.type.ordinal()) { return -1; } else if (type.ordinal() == other.type.ordinal()) { return 0; } else { return 1; } } else if (distance > 0.0d) return 1; else return -1; }
fce7bfba-345c-4f0e-9de3-fc610c100479
1
private boolean jj_2_23(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_23(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(22, xla); } }
7b6aa268-9a3b-4b2e-b069-b21cd17482d3
5
public void WGResetWord(String sender, Command command) { if(command.arguments.length == 4) { Game game = getGame(command.arguments[1]); if(game != null) { User user = getUserByNick(game, command.arguments[2]); if(user != null) { for(Word word : user.wordobjs) { if(word.word.equals(command.arguments[3])) { user.wordobjs.remove(word); user.addUnsetWord(); sendMessage(sender, MSG_WORDRESET); return; } } sendMessage(sender, MSG_NOSUCHWORD); } else { sendMessage(sender, MSG_NOSUCHUSER); } } else { sendMessage(sender, MSG_NOSUCHGAME); } } else { sendMessage(sender, "WGRESETWORD usage: !wgresetword <gameid> <user> <word>"); } }
7c6b6d5f-8242-45ac-ae8f-6dc246535115
4
@Override public ValueType returnedType(ValueType... types) throws EvalException { // Check the number of argument if (types.length == 1) { // If numerical if (types[0].isNumeric() || types[0] == ValueType.NONE) return types[0]; // if array if (types[0] == ValueType.ARRAY) return ValueType.ARRAY; // the type is incorrect throw new EvalException(this.name() + " function does not handle " + types[0].toString() + " type"); } // number of argument is incorrect throw new EvalException(this.name() + " function only allows one numerical parameter"); }
441a01b0-a3d2-4be0-9cc6-08bf88820d82
3
private static void setValue(CuratorFramework client, String command, String[] args) throws Exception { if (args.length != 2) { System.err.println("syntax error (expected set <path> <value>): " + command); return; } String name = args[0]; if (name.contains("/")) { System.err.println("Invalid node name" + name); return; } String path = ZKPaths.makePath(PATH, name); byte[] bytes = args[1].getBytes(); try { client.setData().forPath(path, bytes); } catch (KeeperException.NoNodeException e) { client.create().creatingParentsIfNeeded().forPath(path, bytes); } }
0794a64a-57bc-4b18-9ead-0fca69d45017
7
public void run(){ //TODO gossip runs and interface events need to be synchronised // Create demo interface D = new DemoInterface(); D.showGui("PA300m1.svg"); // minimise side panel D.gui.toggleSidePanelSize(); // add node click listener D.getGraphPanel().addNodeClickedListener(new NodeClickedListener(){ @Override public void nodeClicked(NodeClickedEvent evt) { if(evt.getModifier() == 1) { System.out.println("Want to remove " + evt.getNode()); removeNode(evt.getNode()); clicked = -1; } else { if(clicked == -1) { System.out.println("Clicked node: " + evt.getNode()); clicked = evt.getNode(); } else if(evt.getNode() != clicked) { System.out.println("Want to add/remove link between " + clicked + " and " + evt.getNode()); if(linkExists(clicked,evt.getNode())) { removeLink(clicked,evt.getNode()); } else { addLink(clicked, evt.getNode()); } clicked = -1; } else { clicked = -1; } } updateNodeColours(); } }); // add colour control box and listener switchControl colourControl = new switchControl("ccontrol","army colours",armyColours); colourControl.CheckBox.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { armyColours = !armyColours; updateNodeColours(); } }); D.addControlPanel(colourControl); // add reset button ButtonControl resetButton = new ButtonControl("resetControl","reset"); resetButton.Button.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { reset = true; } }); D.addControlPanel(resetButton); // create a general utility object to read the network General G = new General(); // read network from file network = netGen.fromNodeArray(G.readNetworkFromSimpleListPreserveIDs("PA300m1AL.csv")); idCounter = network.size(); // add gossipicoFAB addFAB(new GossipicoFAB(gen),true); // create colour map createColourMap(); // create order array int[] order = createOrder(); // run simulation while(true) { // shuffle order shuffleOrder(order); // activate all nodes for(int o:order) { network.get(o).getFAB(0).interact(); } if(reset) { reset = false; addFAB(new GossipicoFAB(gen),true); } updateNodeColours(); pause(250); } }
fa83d593-9ef6-4ff4-957c-dada6e77fdfa
9
public void collideCheck() { if (dead) return; float xMarioD = world.mario.x - x; float yMarioD = world.mario.y - y; float w = 16; if (xMarioD > -16 && xMarioD < 16) { if (yMarioD > -height && yMarioD < world.mario.height) { if (world.mario.ya > 0 && yMarioD <= 0 && (!world.mario.onGround || !world.mario.wasOnGround)) { world.mario.stomp(this); dead = true; xa = 0; ya = 1; deadTime = 100; } else { world.mario.getHurt(this); } } } }
61fb8eca-2802-4b9a-aa33-51a5996cca3b
0
public Twitter() { }
de0cb686-3c57-4020-b8ce-921b13ae1b41
3
@EventHandler(priority = EventPriority.LOWEST) public void onLogin(PostLoginEvent e) { ProxiedPlayer p = e.getPlayer(); if (!this.knownClientIPS.containsKey(p.getName())) { this.knownClientIPS.put(plugin.clearifyIP(p.getAddress().toString()), p.getName()); } if (plugin.maintenanceEnabled && !p.hasPermission("bungeeutils.bypassmaintenance")) { p.disconnect(new ComponentBuilder("").append(plugin.messages.get(EnumMessage.KICKMAINTENANCE)).create()); return; } }
4f54a310-73e0-481a-b38f-9d96aef30519
4
public Descriptor compile(SymbolTable table){ Descriptor d = null; if(type instanceof IdentNode){ String s = ((IdentNode) type).getIdentName(); if(s.equals("integer")){ d = new SimpleTypeDescriptor(Type.INTEGER); } else if(s.equals("boolean")){ d = new SimpleTypeDescriptor(Type.BOOLEAN); } else if(s.equals("string")){ d = new SimpleTypeDescriptor(Type.STRING); } else{ d = table.descriptorFor(s); } } else{ d = type.compile(table); } identList.compile(table, d); return d; }
10678e7c-78b1-42ab-b64d-96236134f7fa
0
public CompRegPumpingLemmaInputPane(RegularPumpingLemma l) { super(l, "<i>L</i> = {" + l.getHTMLTitle() + "} Regular Pumping Lemma"); }
3ff534be-7838-4ecf-b9d4-8d99e860698b
9
@Override public boolean equals(Object obj) { boolean result= false; Personajes myObj = (Personajes) obj; if(this == obj) result= true; if(obj == null || (this.getClass() != obj.getClass())) result = false; if((this.nombre == myObj.nombre) && (this.alias == myObj.alias)&& (this.origen == myObj.origen)&& (this.genero == myObj.genero)&& (this.fechaCreacion == myObj.fechaCreacion)&& (this.autor == myObj.autor)) result= true; return result; }
439d0816-5596-4be1-aa69-90cef9e8d8a1
1
public void setWindowInnerAnimation(Animation animation) { if (animation == null) { this.window_InnerAnimation = UIAnimationInits.INNERWINDOW.getAnimation(); } else { this.window_InnerAnimation = animation; } somethingChanged(); }
42e2c4c4-b2fb-4fc5-9d59-f881bd81f281
3
public static void main(String[] args) { Map<String, Integer> grades = new ArrayMap<>(); // Add a few entries into our grade map grades.put("Andy", 76); grades.put("John Doe", 95); grades.put("Jane Doe", 98); // Get the value of a few entries System.out.println(grades.get("Andy")); System.out.println(grades.get("John Doe")); System.out.println(grades.get("Nobody")); // Iterate over the keys for (String s : grades.keySet()) { System.out.println(s); } // Iterate over the values for (Integer i : grades.values()) { System.out.println(i); } // Remove "Andy", insert "Andy Berns", and update his score. System.out.println(grades.remove("Andy")); grades.put("Andy Berns", 83); System.out.println(grades.remove("Andy")); grades.put("Andy Berns", 84); // Iterate over the entries for (Entry<String, Integer> e : grades.entrySet()) { System.out.println(e); } ActorGraph ag = new ActorGraph(); ag.addAnActor("Hao Zheng"); ag.addAnActor("Yajie Yan", "Hao Zheng"); ag.addAnActor("Dou Hang", "Yajie Yan"); ag.addAnActor("Chao Yang", "Dou Hang"); ag.addAnActor("Yixin Chen", "Chao Yang"); ag.addAnActor("Baoluo Meng", "Yixin Chen"); ag.addAnActor("Chutian Gao", "Chao Yang"); ag.addAnActor("Tengyu Wang", "Chao Yang"); ag.addAnActor("Yuan Pan", "Dou Hang"); ag.addAnActor("Luan Rui", "Chutian Gao"); ag.addAnActor("Xinmei Zhang", "Chutian Gao"); ag.addAnActor("Ruoyu Zhang", "Xinmei Zhang"); ag.addAnActor("Yuanyuan Jiang", "Ruoyu Zhang"); ag.buildLink("Xinmei Zhang", "Yuan Pan"); ag.buildLink("Hao Zheng", "Chao Yang"); ag.buildLink("Baoluo Meng", "Hao Zheng"); ag.buildLink("Dou Hang", "Yuanyuan Jiang"); int spl = ag.getShorestPathLength("Hao Zheng", "Ruoyu Zhang"); System.out.println("Shorest path length: " + spl); char[] test = {'a','b','c'}; String tests = new String(test,0,3); System.out.println(tests); }
0d0a64b9-c402-4f7d-b92b-3c7e2fa5615d
0
private StartRouter() { // JFormDesigner - Action initialization - DO NOT MODIFY //GEN-BEGIN:initComponents putValue(NAME, "Iniciar Router"); putValue(SHORT_DESCRIPTION, "Iniciar Router"); putValue(LONG_DESCRIPTION, "Iniciar Router"); putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/images/resultset_next.png"))); putValue(ACTION_COMMAND_KEY, "StartRouter"); setEnabled(false); // JFormDesigner - End of action initialization //GEN-END:initComponents }
b8ed9935-7d0a-4984-bb7a-824562d7b205
3
public static int randomSelect(int[] array, int start, int end, int index){ if(start == end) return array[start]; else{ int q = randomized_partiton(array,start,end); int k = q - start +1; if(k ==index) return array[q]; else if(index < k) return randomSelect(array,start,q-1,index); else return randomSelect(array,q+1,end,index -k); } }
b9e8f265-ec9c-42ba-887f-b1aaf3c314dc
8
public Term setPerference(Term term) throws TermException { if (term.var == null) { Operation op = term.operation; Operation res = null; if (!op.modName.equals(this.modName)) { Operation[] ops = this.getOperationsWithName(op.getName()); for (int i=0; i<ops.length; i++) { if (ops[i].modName.equals(this.modName)) { if (res == null) { res = ops[i]; } else if (ops[i].less(this, res)) { res = ops[i]; } } } } if (res == null) { res = op; } Term[] terms = new Term[term.subterms.length]; for (int i=0; i<term.subterms.length; i++) { terms[i] = setPerference(term.subterms[i]); } //System.out.println("res = "+res+" "+term); return new Term(this, res, terms); } return term; }
2d4fe4b5-0fb3-4388-afc1-a61a4c365371
7
public Deserializer getDeserializer(Class cl) throws HessianProtocolException { if (ObjectName.class.equals(cl)) { return new StringValueDeserializer(cl); } else if (ObjectInstance.class.equals(cl)) { return new ObjectInstanceDeserializer(); } else if (MBeanAttributeInfo.class.isAssignableFrom(cl)) { return new MBeanAttributeInfoDeserializer(); } else if (MBeanConstructorInfo.class.isAssignableFrom(cl)) { return new MBeanConstructorInfoDeserializer(); } else if (MBeanOperationInfo.class.isAssignableFrom(cl)) { return new MBeanOperationInfoDeserializer(); } else if (MBeanParameterInfo.class.isAssignableFrom(cl)) { return new MBeanParameterInfoDeserializer(); } else if (MBeanNotificationInfo.class.isAssignableFrom(cl)) { return new MBeanNotificationInfoDeserializer(); } /* else if (MBeanInfo.class.equals(cl)) { return new MBeanInfoDeserializer(); } */ return null; }
7a6a7916-67b5-47c2-ae4d-721554b85a72
8
public static void main(String[] args) throws IOException { // wget // http://dumps.wikimedia.org/jawiki/20140503/jawiki-20140503-pages-meta-current.xml.bz2 // bunzip2 jawiki-20140503-pages-meta-current.xml.bz2 String wikiPagesMetaXmlFilePath = args[0]; String outPutDirPath = args[1]; File outPutDir = new File(outPutDirPath); outPutDir.mkdirs(); String titleFile = args[2]; Set<String> titles = new HashSet<>(FileUtils.readLines(new File(titleFile))); Date start = new Date(); StringBuilder sb = null; BufferedReader in = null; try { in = new BufferedReader(new FileReader(wikiPagesMetaXmlFilePath)); boolean hit = false; String line; String title = null; while ((line = in.readLine()) != null) { if (line.matches(".*<title>.*</title>.*")) { title = line.trim(); title = title.substring(7, title.length() - 8); if (!titles.contains(title)) { continue; } hit = true; sb = new StringBuilder("<page>\n"); } if (hit) { sb.append(line).append("\n"); if (line.contains("</page>")) { File xml = new File(outPutDir,title + ".xml"); System.out.println(title + " write start"); try { FileUtils.writeStringToFile(xml, sb.toString()); }catch(Exception e) { e.printStackTrace(); } System.out.println(title + " write end"); hit = false; } } } } catch (Exception e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } Date end = new Date(); System.out.println(sb); System.out.println("start:" + start); System.out.println("end :" + end); System.out.println("finish"); }
e7621068-cd5a-4383-abcc-f48c83735f7c
5
public static Genre getByName(String s) { switch( s ) { case "Drama": return DRAMA; case "Kinderbuch": return KIDS_BOOK; case "Lyrik": return LYRICS; case "Roman": return NOVEL; case "Sachbuch": return NONFICTION; default: throw new InvalidParameterException("There is no genre which has the specified name: " + s); } }
38a1a409-29e9-4f97-a7f4-811716ed91db
0
public ConnectEvent(Object client) { super(client); }
03fc2542-253e-403e-908f-def81cad5461
6
@EventHandler public void BlazeMiningFatigue(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getBlazeConfig().getDouble("Blaze.MiningFatigue.DodgeChance") / 100; final double ChanceOfHappening = random.nextDouble(); if (ChanceOfHappening >= randomChance) { dodged = true; } if (plugin.getBlazeConfig().getBoolean("Blaze.MiningFatigue.Enabled", true) && damager instanceof Blaze && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) { Player player = (Player) e; player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, plugin.getBlazeConfig().getInt("Blaze.MiningFatigue.Time"), plugin.getBlazeConfig().getInt("Blaze.MiningFatigue.Power"))); } }
67186d05-0320-4b0b-8ecc-bb5dff243387
1
@Override public String getTooltip() { String tooltip = name; for (GroupOfUnits u: garisson.getUnits()) { tooltip += "\n"+ u.type.name +" ("+u.getNumberDesc()+")"; } return tooltip; }
6124b47c-a9af-469b-a7cf-137c5d7357b1
7
public void renderItem(Graphics g, Entity entity, Item item) { if(item instanceof ItemSword || item instanceof ItemBow && entity != null) { float r = entity.getBB(entity.getCoords()).getBoundingCircleRadius(); Vector2f looking = entity.getLooking().copy().normalise().scale(r); int n = ((int)((item.getTextures().length - 1) *( 1 - (entity.lastAttackTimer / ((ItemWeapon)item).getAttackDelay())))); if(entity.lastAttackTimer / ((ItemWeapon)item).getAttackDelay() <= 0) n = 0; if(n < 0) n = 0; Image img = item.getTextures()[n].copy(); Shape bb = null; if(item instanceof ItemSword) bb = ((ItemSword) item).bb; else if (item instanceof ItemBow) bb = ((ItemBow) item).bb; img.rotate((float) entity.getLooking().getTheta()); g.drawImage(img, entity.getCenterCoords().copy().getX() - bb.getCenterX() + looking.copy().getX() + looking.copy().getPerpendicular().getX() - cLoc.x + cameraWidth / 2, entity.getCenterCoords().copy().getY() - bb.getCenterY() + looking.copy().getY() + looking.copy().getPerpendicular().getY() - cLoc.y + cameraHeight / 2); } else { float r = entity.getBB(entity.getCoords()).getBoundingCircleRadius(); Vector2f looking = entity.getLooking().copy().normalise().scale(r); Image img = item.getTextures()[0].copy(); Shape bb = new Rectangle(0, 0, img.getWidth(), img.getHeight()); img.rotate((float) entity.getLooking().getTheta()); g.drawImage(img, entity.getCenterCoords().copy().getX() - bb.getCenterX() + looking.copy().getX() + looking.copy().getPerpendicular().getX() - cLoc.x + cameraWidth / 2, entity.getCenterCoords().copy().getY() - bb.getCenterY() + looking.copy().getY() + looking.copy().getPerpendicular().getY() - cLoc.y + cameraHeight / 2); } }
88538946-2822-4e3c-b92c-98a27e6b2eec
6
private void calcGenomehs() { genomenr = new int[popdata.chromCount()][][]; genomehs = new ArrayList<ArrayList<ArrayList<ArrayList<Integer>>>>(); //for each genome nr: //which haplostructs in initorder have this genome nr (for both sides) possiblePairCount = new int[popdata.chromCount()][]; for (int chr=0; chr<popdata.chromCount(); chr++) { genomehs.add(new ArrayList<ArrayList<ArrayList<Integer>>>()); //TetraploidChromosome chrom = (TetraploidChromosome)popdata.getChrom(chr); //if (chrom.getPrefPairingProb() > 0.0) { genomenr[chr] = new int[2][popdata.ploidy]; possiblePairCount[chr] = new int[] {0,0}; //the number of possible preferential pairs //(for both sides) for (int side=0; side<2; side++) { genomehs.get(chr).add( new ArrayList<ArrayList<Integer>>()); for (int g=0; g<popdata.ploidy/2; g++) { genomehs.get(chr).get(side).add(new ArrayList<Integer>()); } for (int h=0; h<popdata.ploidy; h++) { //first get the genome number at the haplostruct side: genomenr[chr][side][h] = (side==0 ? haplostruct[chr][h].getFounderAtHead() : haplostruct[chr][h].getFounderAtTail()) % (popdata.ploidy/2); //and list all the haplostruct sides in genomehs: genomehs.get(chr).get(side).get(genomenr[chr][side][h]).add(h); } //count the number of possible prefpairs at this side: for (int g=0; g<popdata.ploidy/2; g++) { possiblePairCount[chr][side] += genomehs.get(chr).get(side).get(g).size()/2; } } //for side } //for chr } //calcGenomehs
30ecf1e7-c298-4128-a8f6-ffb073af1a1c
4
private JMenu getUsersMenu() { final JMenu usersMenu = new JMenu("Users"); //List of Users try { for (String user: client.getUsers()) { JLabel label = new JLabel(user); label.setBorder(BorderFactory.createEmptyBorder(2, 5, 3, 5)); usersMenu.add(label); } } catch (Exception e) { e.printStackTrace(); } usersMenu.addMenuListener(new MenuListener() { @Override public void menuCanceled(MenuEvent arg0) { } @Override public void menuDeselected(MenuEvent arg0) { } @Override public void menuSelected(MenuEvent arg0) { //refresh the users list whenever the menu button is pressed usersMenu.removeAll(); try { for (String user: client.getUsers()) { JLabel label = new JLabel(user); label.setBorder(BorderFactory.createEmptyBorder(2, 5, 3, 5)); usersMenu.add(label); } } catch (Exception e) { e.printStackTrace(); } } }); return usersMenu; }
833275e0-a3ee-41d8-8bcd-ef9d2a0ce99d
8
public static int getInverseTransfType(int type){ int inverse = 0; switch (type){ case 0: inverse = 0; break; case 1: inverse = 3; break; case 2: inverse = 2; break; case 3: inverse = 1; break; case 4: inverse = 4; break; case 5: inverse = 5; break; case 6: inverse = 6; break; case 7: inverse = 7; break; } return inverse; }
db904f08-da3f-4d18-a82e-cedf5d8cd832
5
private Tile[] rotate(int dgr) { Tile[] newTiles = new Tile[ROW * ROW]; int offsetX = 3, offsetY = 3; if (dgr == 90) { offsetY = 0; } else if (dgr == 180) { } else if (dgr == 270) { offsetX = 0; } else { throw new IllegalArgumentException( "Only can rotate 90, 180, 270 degree"); } double radians = Math.toRadians(dgr); int cos = (int) Math.cos(radians); int sin = (int) Math.sin(radians); for (int x : _0123) { for (int y : _0123) { int newX = (x * cos) - (y * sin) + offsetX; int newY = (x * sin) + (y * cos) + offsetY; newTiles[(newX) + (newY) * ROW] = tileAt(x, y); } } return newTiles; }
e7ad89d1-6bb8-4c08-ad84-ae5790a159ee
4
public static void main(String[] args) throws IOException { StringBuilder sb = new StringBuilder(); BufferedReader buf = new BufferedReader( new InputStreamReader(System.in)); String line = ""; d: do { line = buf.readLine(); if (line == null || line.length() == 0) break d; sb.append(convery(line)).append("\n"); } while (line != null && line.length() != 0); System.out.print(sb); }
6e39541a-9067-4f66-b2c0-9456cea1477d
2
private static void findAllC2(int n){ for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ allSwaps.add(new Point(i, j)); } } }
90e33004-30ce-4541-bbb5-339dbbad9990
3
public static String fetchURLGet(final String u, String parameters) { String returnedString = ""; try { final URL url = new URL(u + "?" + parameters); final BufferedReader reader = new BufferedReader( new InputStreamReader(url.openStream())); String line; while ((line = reader.readLine()) != null) { returnedString += line; } reader.close(); } catch (final MalformedURLException e) { System.out.println("MalformedURLException calling url" + u + e.getMessage()); } catch (final IOException e) { System.out.println("IOException calling url" + u + e.getMessage()); } return returnedString; }
7038cda8-c915-4252-ab7f-011add77c1f5
1
public static void main(String[] args) { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); String path = "resources/lena.png"; Mat image = Highgui.imread(path); Mat out = new Mat(); if(image.empty()) { System.out.println("Image not found !!"); return; } ImageUtils.displayImage(ImageUtils.toBufferedImage(image), "Before Smoothing"); Imgproc.GaussianBlur(image, out, new Size(5,5), 3,3); ImageUtils.displayImage(ImageUtils.toBufferedImage(out),"After Smoothing -- Gaussian Blur"); Imgproc.GaussianBlur(image, out, new Size(5,5), 3,3); ImageUtils.displayImage(ImageUtils.toBufferedImage(out),"After double Smoothing -- Gaussian Blur"); }
5530a917-c9cd-45b6-a1c5-5b3c76109bce
1
public static void setFoxCreationProbability(double FOX_CREATION_PROBABILITY) { if (FOX_CREATION_PROBABILITY >= 0) Simulator.FOX_CREATION_PROBABILITY = FOX_CREATION_PROBABILITY; }
34c40813-adfa-424c-adc4-abd732e0444e
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Genero other = (Genero) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; }
7700eaf3-ae46-45ec-9af3-cf3b2b9affd7
1
@Override public void addRecordToDB() { // add to database try { String statement = new String("INSERT INTO " + DBTable + " (qid, userid)" + " VALUES (?, ?)"); PreparedStatement stmt = DBConnection.con.prepareStatement(statement, new String[] {"id"}); stmt.setInt(1, quiz.quizID); stmt.setInt(2, user.userID); stmt.executeUpdate(); ResultSet rs = stmt.getGeneratedKeys(); rs.next(); recordID = rs.getInt("GENERATED_KEY"); rs.close(); } catch (SQLException e) { e.printStackTrace(); } }
5249862b-f652-471b-84d5-858931840786
1
public void setComfortType(ComfortType comfortType) throws CarriageException { if (comfortType == null) { throw new CarriageException("Comfort type is null"); } this.comfortType = comfortType; }
0beab6dc-3c19-44ba-a98e-55c094ad3f08
7
private int whitePosition(int i) { int whitePos; switch (i) { case 1: whitePos = 1; break; case 3: whitePos = 2; break; case 5: whitePos = 3; break; case 7: whitePos = 4; break; case 8: whitePos = 5; break; case 10: whitePos = 6; break; case 0: whitePos = 7; break; default: whitePos = 1; } return whitePos; }
f4a5c257-c225-46a2-9242-376fdd0ceb04
0
public GroupJoinIterator(Iterable<T> outer, Iterable<TInner> inner, Selector<T, TKey> outerKeySelector, Selector<TInner, TKey> innerKeySelector, Joint<T, TInner, TResult> joint, Comparator<TKey> comparator) { this._outer = outer; this._inner = inner; this._innerKeySelector = innerKeySelector; this._outerKeySelector = outerKeySelector; this._joint = joint; this._comparator = comparator; }
16fc9460-de07-481e-b259-619889eb255c
2
public Neg(byte[] buf) { int off; cc = cdec(buf, 0); bc = cdec(buf, 4); bs = cdec(buf, 8); sz = cdec(buf, 12); bc = MapView.s2m(bc); bs = MapView.s2m(bs).add(bc.inv()); ep = new Coord[8][0]; int en = buf[16]; off = 17; for (int i = 0; i < en; i++) { int epid = buf[off]; int cn = Utils.uint16d(buf, off + 1); off += 3; ep[epid] = new Coord[cn]; for (int o = 0; o < cn; o++) { ep[epid][o] = cdec(buf, off); off += 4; } } }
338367a8-1046-401d-b7fc-b1c6c37b252b
7
@Override public Attribute getBestAttribute(Attribute target, ArrayList<Attribute> attributes) { double entropyTarget = computeEntropy(target); // System.out.println("Entropy Target -> " + entropyTarget); // System.out.println(); Attribute bestAttribute = null; Double bestValue = Double.NEGATIVE_INFINITY; Attribute bestAttribute2 = null; Double bestValue2 = Double.NEGATIVE_INFINITY; for (Attribute attrib : attributes) { double vprs = computeVPRS(entropyTarget, target, attrib); // System.out.println(attrib+" ==> vprs="+vprs); if (vprs > bestValue) { // bestValue2 = bestValue; // bestAttribute2 = bestAttribute; bestValue = vprs; bestAttribute = attrib; } else if (vprs <= bestValue && vprs > bestValue2) { bestValue2 = vprs; bestAttribute2 = attrib; } // System.out.println(attrib + "\tinfoGain: "+infoGain); } // System.out.println(); // System.out.println(bestAttribute + " ==> " + bestValue); // System.out.println(bestAttribute2 + " ==> " + bestValue2); // System.out.println(); if ((bestAttribute2 == null)) { // System.out.println("retorna =>" + bestAttribute + "\n"); return bestAttribute; } double wd = wrough_difference(bestValue, bestValue2); double c = complexity(bestValue, bestValue2); // System.out.println("wd=>" + wd); // System.out.println("c=>" + c); // DEFINIR PARAMETROS!!! // breast-cancer:: minwrd=0.2;mincomp=0.8 // audiology:: minwrd=0.5;mincomp=0.5 79,5%/21 // audiology:: minwrd=0.5;mincomp=0.1 81.5%/21 // audiology:: minwrd=0.4;mincomp=0.1 82%/22 // soybean:: minwrd=0.2;mincomp=0.8:: 87,3%/14 // soybean:: minwrd=0.5;mincomp=0.5:: 87.94788%/14 //tic-tac-toe:: minwrd=0.2;mincomp=0.8 82,15/7 //tic-tac-toe:: minwrd=0.2;mincomp=0.7 85.07306889/7 //car_eval:: minwrd=0.2;mincomp=0.8 86,979 / 6 //car_eval:: minwrd=0.2;mincomp=0.9 87,3264 / 6 //car_eval:: minwrd=0.1;mincomp=0.9 87,44 / 6 //car_eval:: minwrd=0.1;mincomp=0.5 87,61 / 6 double minwrd = 0.1; double mincomp = 0.5; if (wd >= minwrd) { // System.out.println("retorna =>" + bestAttribute + "\n"); return bestAttribute; } if (c < mincomp) { // System.out.println("retorna =>" + bestAttribute + "\n"); return bestAttribute; } // System.out.println("retorna =>" + bestAttribute2 + "\n"); return bestAttribute2; }
b63c9dda-9590-481d-9f8e-7c8dbb63c6e7
0
public String getAlgorithm() { return algorithm; }
1778d37c-e0f9-43f9-9e95-16b5e6feddc7
6
public boolean connect() throws Exception { port = getPropPort(); portRate = 9600; //Service.WriteLog("Find port: "+port); parity = 0; rts = true; if (this.port.length()<1) { return false; } if (status == Device.DEVICE_READY || status == Device.DEVICE_WORKING) { return true; } portIdentifier = CommPortIdentifier.getPortIdentifier(this.port); if ( portIdentifier.isCurrentlyOwned() ) { status = Device.DEVICE_PORT_BUSY; } else { commPort = portIdentifier.open(this.getClass().getName(),2000); if ( commPort instanceof SerialPort) { serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(this.portRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,this.parity); serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); serialPort.setDTR(true); serialPort.setRTS(this.rts); serialPort.notifyOnDataAvailable(true); if (this.timeout>0) serialPort.enableReceiveTimeout(this.timeout); //serialPort.notifyOnOutputEmpty(true); //serialPort.setOutputBufferSize(this.bufferByte); portInputStream = serialPort.getInputStream(); portOutputStream = serialPort.getOutputStream(); serialPort.addEventListener(this); status = Device.DEVICE_READY; return true; } else { status = Device.DEVICE_PORT_NOT_FOUND; } } return false; }
3b21c87e-6175-4c1a-a42b-227327acf2db
1
private static boolean insertPatient(Patient bean, PreparedStatement stmt) throws SQLException{ stmt.setString(1, bean.getFirstName()); stmt.setString(2, bean.getLastName()); stmt.setDate(3, bean.getDob()); stmt.setString(4, bean.getPrimaryDoc()); stmt.setString(5, bean.getPhone()); stmt.setString(6, bean.getAddress()); stmt.setString(7, bean.getCity()); stmt.setString(8, bean.getState()); stmt.setString(9, bean.getZip()); stmt.setBigDecimal(10, bean.getCoPay()); int affected = stmt.executeUpdate(); if(affected == 1){ System.out.println("new patient added successfully"); }else{ System.out.println("error adding patient"); return false; } return true; }
6b75ec92-2b5d-4711-b348-1739829a7059
0
public Object get(int i){ return vector.get(i); }
128c61bd-376f-4c22-a197-a3e0a6fce9b0
7
public void resizeColumns() { if (_vertical) { TableColumn column = _table.getColumnModel().getColumn(1); int origWidth = column.getWidth(); int width = origWidth; Font font = _table.getFont(); FontMetrics fontMetrics = _table.getFontMetrics(font); for (Iterator<FieldValue> iter = _fieldListValues.iterator(); iter.hasNext();) { FieldValue value = (FieldValue)iter.next(); int textWidth = SwingUtilities.computeStringWidth(fontMetrics, value.getStringValue()); if (textWidth > width) width = textWidth; } if (width > origWidth) { width += _table.getIntercellSpacing().width; column.setPreferredWidth(width); _table.invalidate(); _table.doLayout(); _table.repaint(); } } else { int i = 0; boolean changed = false; Font font = _table.getFont(); FontMetrics fontMetrics = _table.getFontMetrics(font); for (Iterator<FieldValue> iter = _fieldListValues.iterator(); iter.hasNext();) { TableColumn column = _table.getColumnModel().getColumn(i); int origWidth = column.getWidth(); FieldValue value = (FieldValue)iter.next(); int width = SwingUtilities.computeStringWidth(fontMetrics, value.getStringValue()); if (width > origWidth) { width += _table.getIntercellSpacing().width; column.setPreferredWidth(width); } } if (changed) { _table.invalidate(); _table.doLayout(); _table.repaint(); } } }
7e7ab07c-8246-4bcf-bf48-47b3984b2844
7
protected void switchToBars() { if (m_plotSurround.getComponentCount() > 1 && m_plotSurround.getComponent(1) == m_legendPanel) { m_plotSurround.remove(m_legendPanel); } if (m_plotSurround.getComponentCount() > 1 && m_plotSurround.getComponent(1) == m_attrib) { return; } if (m_showAttBars) { try { m_attrib.setInstances(m_plot2D.getMasterPlot().m_plotInstances); m_attrib.setCindex(0);m_attrib.setX(0); m_attrib.setY(0); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(0, 0, 0, 0); constraints.gridx=4;constraints.gridy=0;constraints.weightx=1; constraints.gridwidth=1;constraints.gridheight=1; constraints.weighty=5; m_plotSurround.add(m_attrib, constraints); } catch (Exception ex) { System.err.println("Warning : data contains more attributes " +"than can be displayed as attribute bars."); if (m_Log != null) { m_Log.logMessage("Warning : data contains more attributes " +"than can be displayed as attribute bars."); } } } }
f23903a7-0cb2-4b7f-a79f-fb04d0da536c
4
private Object handlePrim(Object tos) { if ((tos instanceof Media && ((Media)tos).getPrimary() == null) || (tos instanceof ParentFamilyRef && ((ParentFamilyRef)tos).getPrimary() == null)) { return new FieldRef(tos, "Primary"); } return null; }
88476bb5-a034-423c-82e7-a315b751d52d
2
public boolean allVisitedMore(int comp) { for (Action a : actions) if (a.getVisits() < comp) return false; return true; }
4ba346d2-090a-4a06-ac26-d8604100ee85
6
private void drawVoltageGrid(Graphics g) { ArrayList<Double> list = makeList(voltageValue); Collections.sort(list); double belowZero = getNegativeAmount(list); double exactlyZero = getZeroAmount(list); double aboveZero = getPositiveAmount(list); for(int x = width/6 +5; x < width*5/6 -10; x+=pixel){ for (int y = height/6+5; y <height*5/6 + height/10 -30; y+=pixel){ double value = voltageValue[x][y]; g.setColor(Color.black); int colorVal = 128; boolean hot = false; if(value<0){ colorVal = (int)((belowZero - list.indexOf(value))/belowZero*128); colorVal = Math.min(colorVal, 128); hot = false; }else if(value>0){ colorVal = (int)((list.indexOf(value)-belowZero+2)/aboveZero*128); colorVal = Math.min(colorVal, 128); hot = true; } if(!hot){ g.setColor(new Color(128-colorVal, 0, colorVal+127)); } else if(hot){ g.setColor(new Color(colorVal+127, 0, 128-colorVal)); } g.fillRect(x, y, 7, 7); } } updateVoltageScaleText(list); }