method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
245024b3-7b50-4875-a55c-4cf55df6dfc5
0
@XmlTransient public Collection<Medico> getMedicoCollection() { return medicoCollection; }
13ed3c5f-c304-4802-9335-c0e954a5ae05
1
public double getWidth(Graphics pen) { if(myText.length() == 0) return 0; Graphics2D p = (Graphics2D)pen; FontRenderContext frc = p.getFontRenderContext(); TextLayout layout = new TextLayout(myText, FONT, frc); return layout.getBounds().getWidth(); }
cc6aa1a5-53d7-4af6-967a-60b5cdc5c459
8
public static void main(String args[]) { Initializer initilizer = new Initializer(); try { initilizer.initializeServerWithPersistDataInServer(); } catch (CubeXmlFileNotExistsException e) { e.printStackTrace(); } catch (CubeAlreadyExistsException e) { e...
c5e42911-7264-4e07-8d80-75adde3ac5f4
4
public void validateItemsInRoom() { List<Item> remItems = Runtime.getRemItems(); List<Item> items = getItems(); for (int cnt = 0; cnt < getItems().size(); cnt++) { for (int count = 0; count < (remItems.size()) && (!getItems().isEmpty()); count++) { System.out.println("You picked up " + remItems.size(...
56dced29-a283-49ea-b7df-e129c8818660
8
public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0; float lastX = 0, lastY = 0; float thisX = 0, thisY = 0; int type = ...
008250d1-7c09-4696-8347-38ad693eebf6
9
public boolean equals(Object p_other) { if ( this == p_other ) { return true; } else if ( p_other == null ) { return false; } ComboLeg l_theOther = (ComboLeg)p_other; if (m_conId != l_theOther.m_conId || m_ratio != l_theOther.m_r...
5281185c-246c-43e0-807a-d6e7c208b174
3
@Override protected void onMode(String channel, String sourceNick, String sourceLogin, String sourceHostname, String mode) { // User mode: +o nickname // Channel mode: +m String change = mode.substring(0, 1); boolean granted = change.equals("+"); ...
eb7eca7d-5f47-4d37-aba8-b3b645ccf063
0
@Override public String toString() { return String.format( "xor(%s, %s)", this.a, this.b ); }
4de34b82-b651-4af2-816b-e6c027dbf89d
0
private StateManager() { }
8fe4f31a-e508-4b6e-8282-06643f3a6b1d
3
@Override public void dispose() { if (!isClosed()) { WINDOW_LIST.remove(this); if (WINDOW_LIST.isEmpty()) { for (PaletteWindow window : getWindows(PaletteWindow.class)) { window.setAppWindow(null); } } } super.dispose(); WindowMenuProvider.update(); }
44905e62-6607-427b-a370-1bd628e71747
1
public Tester(String name) { this.name = name; }
ff795873-a772-4905-8391-3ec47927f793
0
public void left(int velocity) { controls.left(velocity); }
7a396d23-2b6f-4bb0-83ba-674d856d95ec
5
public void printInfo(UQuest plugin, Player player){ Quester quester = plugin.getQuestInteraction().getQuester(player); player.sendMessage(ChatColor.GOLD + this.name); player.sendMessage(ChatColor.GREEN + this.startInfo); //Progress player.sendMessage("Objective:"); for(Objective objective : this.objectives...
aa1f0afa-294a-4364-b0b1-3c4fe89a12b5
5
public static ArrayList<Question> findById_AllQuestions(int id, BaseSetting bs) { Connection connection = bs.getConnection(); ArrayList<Question> alq = new ArrayList<Question>(); try { String query = "SELECT * FROM Contains WHERE id_e = ?"; PreparedStatement p_statement...
291d6554-b6df-4c92-b135-98dd1459d1a1
2
public void login(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) { HttpSession session = httpRequest.getSession(); session.setAttribute("drupalauth.authCookieName", authCookieName); session.setAttribute("drupalauth.authValidationEndpoint", authValidationEndpoint); ...
9f7832d3-4b4b-4559-94df-a81028a197f5
1
public Line complete(int start) { String[] args = line.split(" "); StringBuilder string = new StringBuilder(); for (int i = start; i < args.length; i++) { string.append(args[i] + " "); } return new Line(string.toString().substring(0, string.length() - 1)); }
b97148af-862d-4df6-baad-cf871159ebb3
0
final void assertHasExactlyOneNamedNonEmptyElement(final Xpp3Dom testCase, final String name) { final Xpp3Dom[] children = testCase.getChildren(name); assertEquals("Expected exactly one " + name, 1, children.length); assertFalse("Expected " + name + " not to be empty.", children[0].getValue().is...
e04e1ead-e0dc-4927-9d2d-fbe3f4b700b0
5
@Override public ArrayList<Object> ifVoucher(SalesReceiptPO receipt) { // TODO Auto-generated method stub ArrayList<Object> returnPromotions=new ArrayList<Object>(); for(PromotionPO p:promotions){ if(p.getPromotionType()==PromotionSort.Voucher&& checkDateValid(receipt.getSerialNumber(), p)&& checkCu...
24eaaeec-7175-41aa-86d2-1d36b53f806e
3
private void generate_mode() { if(mode.equals("joint_stereo")) headerstring |= 0x40; if(mode.equals("dual_channel")) headerstring |= 0x80; if(mode.equals("single_channel")) headerstring |= 0xc0; }
58dcfe31-822c-4ad9-ba57-13d1a9cf7a1e
0
public void setOldTranslation(String oldTranslation){ this.oldTranslation.setText(oldTranslation); }
eb156153-2ba8-4b06-ba25-b84818f82f9c
9
private static String send(final EntityEnclosingMethod httpMethod, String url, RequestEntity requestEntity, String username, String pw) { HttpClient client = new HttpClient(); HttpConnectionManager connectionManager = client.getHttpConnectionManager(); try { ...
402aa29d-28c8-4f8b-9042-546e112011c9
1
public String getCode(){ String str = ""; if(identifiers != null) str += identifiers.getCode(); str += this.printLineNumber(true) + identifier.getNewName() + " := pop" + "\n"; return str; }
fa23253c-ee21-4ab5-ba72-03c321c75dbb
4
@Override public boolean getPoint(int mouseX, int mouseY){ int newX = -1; int newY = -1; if (mouseX < 800){ int cx = Boot.getPlayer().getX(); int cy = Boot.getPlayer().getY(); newX = cx + (mouseX / Standards.TILE_SIZE) - 12; newY = cy + ((Standards.W_HEIGHT - mouseY) / Standards.TILE_SIZE) - 12; ...
2a857583-fb45-49d6-a908-8c26cd539658
6
private RenderableObject generateObject(String next, Scanner inFile) { RenderableObject ro = null; switch (next) { case "Ellipse": ro = generateElipse(inFile); break; case "Rectangle": ro = generateRectangle(inFile); break; case "Text": ro = generateText(inFile); break; case "Shape": ro...
1639e72c-5b38-4f1a-9ba0-916796751a29
4
private TreeNode rotateRight(TreeNode rotatingNode) { TreeNode rotatedTreeRootNode = rotatingNode.left; rotatedTreeRootNode.parent = rotatingNode.parent; rotatingNode.left = rotatedTreeRootNode.right; if (rotatingNode.left != null) { rotatingNode.left.parent = rotatingNode; } rotatedTreeRootNode.righ...
7ceb5492-d83f-4f67-b74b-0ef2949b03ee
0
public int getAge() { return age; }
c95f2753-ab10-47c8-b862-ccbc19a20b32
0
@Test public void test() { String pattern = "AB*A"; String text1 = "Hello World ACA! NFA"; String text2 = "Hello World AA! NFA"; String text3 = "Hello World ABBBBA! NFA"; NFA nfa = new NFA(pattern); assert(nfa.recognizes(text1) == false); assert(nfa.recognizes(text2) == true); assert(nfa.recogniz...
0ab95075-5b3f-4858-ba3a-c4fb8134beb9
8
protected String getUrl() { String newUrl = ""; if(url != null && !"".equals(url.trim())) newUrl = newUrl+ url; if(url != null && !"".equals(url.trim()) && projectRoot != null && !"".equals(projectRoot.trim())) newUrl = newUrl + " in "; if(projectRoot != null && !"".equals(projectRoot.trim())) newUrl =...
12da0e61-e848-4e72-866c-b2777b5c00f9
6
public static void paramSendCheck(Object[] objs) throws NotSerializableException { for (int i = 0; i < objs.length; i++) { /* Check if parameters are all serializable */ if ( (objs[i] != null) && !(objs[i] instanceof Serializable) ) { throw new NotSerializableException("Non-serializable parameter"); } ...
9296751f-f602-4bee-9096-7ee97aa4c547
8
static public byte[] decode(final String source) { final String base32 = source.toLowerCase(); int i, index, lookup, offset, digit; byte[] bytes = new byte[base32.length()*5/8]; for(i = 0, index = 0, offset = 0; i < base32.length(); i++) { lookup = base32.charAt(...
9e3ec5b5-8a0b-4238-ae2e-c4a94d5d575f
1
public List<Token> getObjects(){ try{ CSVFileManager csvMgr = new CSVFileManager(); SimpleHttpReader reader = new SimpleHttpReader(); SimpleMatchParser parser = new SimpleMatchParser(TokenType.parse(csvMgr .readFile("res/pulsSheduleObjects.txt").getCSVObject())); SimpleTextWriter writer = new SimpleT...
21faa2ac-8b98-49ce-99f4-3bd67c5d1c02
9
public void loadSave(File loadPath) { int[] waveEnemies; int numEnemiesInWave; int numEnemies = 0; int airIdHolder = 0; try { Scanner loadScanner = new Scanner(loadPath); while (loadScanner.hasNext()) { Frame.gameScreen.level = loadScanner.nextInt(); Screen.myHealth = loadScanner.nex...
f540c8c6-e240-413d-a393-156082aa9f16
9
private static int[] mergeSort(int[] list){ if(list.length <= 1){ return list; } else{ //Split the array int[] la = mergeSort(Arrays.copyOfRange(list, 0, list.length/2)); int[] ra = mergeSort(Arrays.copyOfRange(list, list.length/2, list.length)); //Run through the list, replacing the values as we go ...
8e9c5137-d3ca-46c3-b4ae-3a6aa128fdd4
4
@Override public boolean doSmall() { if ((script.houseTask.getHouseLocation() != HouseTask.HouseLocation.YANILLE && !options.useOtherHouse.get())) { options.status = "House not in yanille"; return false; } else { options.status = "Walking to yanille portal"; final Tile tile = locationAttribute.getSmall...
e050a72b-e59b-498a-ab9e-f9bbcb10e145
8
public void addEventListener(String type, ipsilonS3ToolEngineListener listener) { if(type.equals(ipsilonS3ToolEvent.TYPE_DELETING)){ listenerDeleting.add(ipsilonS3ToolEngineListener.class, listener); } if(type.equals(ipsilonS3ToolEvent.TYPE_UPLOADING)){ listenerUploading.add(ipsilonS...
9b12999b-df54-447c-bc6f-639b86fc6f31
4
public int[] getVertexGridCoords(int xDim, int yDim, int value) { if (value > ((yDim * xDim) - 1) || xDim < 0 || yDim < 0 || value < 0) { throw new IllegalArgumentException(); } int yCoord = (int) Math.floor(value / xDim); int xCoord = (value - yCoord * xDim) + 1; yCoord += 1; int[] coords = new int...
da97d464-43cf-4368-8ae0-e8acaf528b5d
5
public void parseHtml() throws IOException { String html = "error"; int i=0; for(i=0;i<5 && html.equals("error");i++){ html = new GetHTML().getHtml(this.articleUrl,"UTF-8"); System.out.println("in Article...:"+this.articleUrl); } if(i<5){ Sys...
e4217ff0-0e03-4332-8fd2-f52ff282e903
3
public void secureDatabase() { logger.debug("<<<< DatabasePasswordSecurerBean is running!!! >>>>>"); getJdbcTemplate().query("select username, password, password_encrypted from users", new RowCallbackHandler() { @Override public void processRow(ResultSet rs) throws SQLException...
4b7b55d3-beab-4410-af77-d1f5911b2af3
4
@MethodInformation(author="Matthias", date="09.12.2012", description="Gives back a double that describes the average carrying capacity of all DieselTraktor") protected double avgCapacityDiesel() throws DivideByZeroException{ MyIterator it = (MyIterator) traktoren.iterator(); double sum = 0; int count = 0; w...
ecf23ced-af29-4985-a7cb-bb0fdfd2e906
1
public Range(Match match, Tile origin, Ability ability) { this.match = match; this.origin = origin; this.ability = ability; validTargetPaths = new ConcurrentHashMap<Tile, ArrayList<Tile>>(); invalidTargets = new ArrayList<Tile>(); blockingTiles = new ArrayList<Tile>(); //Movement ranges can "wrap"...
be187186-7aab-4ad9-8eda-401da10caeec
7
private void generateMoveList() { moveList = new ArrayList<Integer>(); int curX = 0, curY = 0; boolean upperCase = true; for(int i=0;i<name.length();i++) { char c = name.charAt(i); int newX = getCharX(c); int newY = getCharY(c); if(newX == -1 || newY == -1) throw new RuntimeException("invalid ch...
d04ca29d-87f5-43f9-bfaa-1cebc55bab56
7
private SpatialTree<E> octant(Vector3f position) { if (position.x > division_x) { if (position.y > division_y) { if (position.z > division_z) return octant1; else return octant5; } else { if (position...
3d0c79ea-e681-477b-b141-1b491ec89dc3
8
public static void initDatabase() { Session session = HibernateUtil.getSession(); session.beginTransaction(); /* Locals */ Local local1 = new Local("Palau Sant Jordi", "C/Falsa 123"); Local local2 = new Local("Indispuesto", "C/Parla"); Local local2_2 = new Local("PepeStage", "C/Tio Pepe"); Local local2_3...
84bef9b8-e45c-4414-a6ad-52a0fe8661df
6
private void attachTo(Component paramComponent) { if ((paramComponent instanceof ImageComponent)) { ((ImageComponent)paramComponent).addImageListener(this); } else if ((paramComponent instanceof ImageComposite)) { ((ImageComposite)paramComponent).addImageListener(this); } else if (((paramCompo...
afa98a11-699d-4d26-aef7-0a79ac46406b
5
public static void setPrizes(int prizeIncrease){ prizes[0] = 0; for (int i = 1; i < 16; i++) { if (i < 5) prizes[i] = prizeIncrease * (i + 1); if (i < 10 && i >= 5) prizes[i] = prizeIncrease * 2 * (i + 1); if (i >= 10) prizes[i] = prizeIncrease * 3 * (i + 1); } LOGG.logInfo("Prizes set."...
480c43c1-ee9f-4952-96a6-92f9d2000c48
0
@After public void tearDown() { }
1fc44263-5260-4bb7-aa19-bcc2ff82682c
3
synchronized void putLine(String inp) { try { while (available==size) wait(); } catch (InterruptedException exc) { throw new RTError("Buffer.putLine interrupted: "+exc); }; buffData[nextToPut] = new String(inp); if (++nextToPut >= size) nextToPut = 0; available++; notifyAll(); // Only notify() could...
f191bfa3-c488-4dae-8eb0-3cf66ccef391
6
public boolean processedMacro(StringBuilder sb, String text) { if (text.equals("LocalChanges")) { return processedLocalChangesMacro(sb, text); } else if (text.equals("RebasedChanges")) { return processedRebasedChangesMacro(sb, text); } else if (text.equals("TitleIndex")) ...
07562a00-c0dc-40c3-8645-762bb7287b78
3
public void renderTrail(float[] color) { if (body.hasTrail){ GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex3d(body.position.x, body.position.y, body.position.z); for (int i = 0; i < path.length; i++) { GL11.glColor4f(color[0], color[1], color[2], (float) Math.pow((1.0 - ((double) i / path.length))...
ef326048-8fcb-44a7-9a41-895d46d6cc69
8
public void runPersistentConnectionThread(){ int counter =0; //String persistent_header="HTTP/1.1: 200 OK\r\n"+"Content-Type: text/html\r\n" + "Connection:Keep-Alive\r\n" + "\r\n"; String persistent_header="<script>ThreadId-"+ Integer.toString(current_client_number) +"-</script>"; outputChannel.println( persi...
c617f97f-8a2d-47af-9b41-0e573c680bc1
0
public Double getPhi() { return phi; }
dc8f77fd-32a2-4309-a839-61b179e75c69
2
@Override public String toString() { StringBuilder print = new StringBuilder(); char[] blanks = new char[width()*height()]; Arrays.fill(blanks, '_'); print.append(blanks); for(Point p : _path) { print.setCharAt((p.x() - min_x()) + width()*((p.y() - min_y())), '#'); } print.setCharAt((start()...
1420f18c-9685-48bc-a9e2-8e29e906a8c3
9
public static void main(String[] args) throws IOException { String keyFileName; try { keyFileName = args[args.length-1]; if(keyFileName.startsWith("-")) throw new RuntimeException(); } catch(RuntimeException e) { System.err.println("No key file specified."); return; } String addr = null; sh...
e872fe96-968c-4b5c-86af-80d9c99b27c7
5
public boolean update(float tslf, Tile[][] tiles) { xpos += xspeed * tslf; ypos += yspeed * tslf; int tilexpos = (int) ((xpos + look.getWidth() / 2) / Texture.tilesize); int tileypos = (int) ((ypos + look.getHeight() / 2) / Texture.tilesize); if(tiles[tilexpos][tileypos].getLookID() == 3) return true; ...
96eea984-cf0b-4e04-9985-f3b461b6e1b6
8
public double getProportion(String oldUnit, String newUnit) { double result = 0; double numerador = 0; double denominador = 1; if(oldUnit.equalsIgnoreCase("Hours")) { numerador = 1; } else if(oldUnit.equalsIgnoreCase("Days")) { numerador = 24; } else if(oldUnit.equalsIgnoreCase("Months")) ...
5846382f-93bf-4480-9276-0624dfb41614
6
protected void lancerOption(int i) { switch (i) { case 0: new InstrumentSelectorFrame(0, 5); break; case 1: new InstrumentSelectorFrame(1, 5); break; case 2: new InstrumentSelectorFrame(2, 5); break; case 3: ...
acd86172-44f8-4077-b0c4-3f4c77009f79
7
public void renderSheet(int xp, int yp, SpriteSheet sheet, boolean fixed){ if(fixed){ xp -= xOffset; yp -= yOffset; } for(int y = 0; y < sheet.HEIGHT; y++){ int ya = y + yp; for(int x = 0; x < sheet.WIDTH; x++){ int xa = x + xp; if(xa < 0 || xa >= width || ya < 0 || ya >= height) continue; ...
49bc244c-8f83-494f-87bf-37a2cf9bef61
7
public List<Message> consumeMulti(final int number, Boolean shouldBeRequeued) throws Exception { if (shouldBeRequeued) { return this.rabbitTemplate.execute(new ChannelCallback<List<Message>>() { public List<Message> doInRabbit(Channel channel) throws IOException { List<Message> resultList = new Array...
bf029364-96ef-41d8-a6de-3dd229fcc7a1
1
@Override public void removeItem(final String item) { new Thread(new Runnable() { @Override public void run() { File removedFile = new File(workingDirectory + File.separator + item); if (removedFile.exists()) { removedFile.delete();...
2133f879-fd13-4fc8-9d7f-f3bccc9bef3e
9
public static void textPack(byte packedData[], java.lang.String text) { if (text.length() > 80) { text = text.substring(0, 80); } text = text.toLowerCase(); int carryOverNibble = -1; int ofs = 0; for (int idx = 0; idx < text.length(); idx++) { char...
6f31328a-3de3-4513-9a76-ea8343c80c60
4
public void incValue(float inc) { //Include weight, and use it to modify familiarity? // // Roll dice matching current relationship against magnitude of event. final int numDice = (int) (Math.abs(attitude / ATTITUDE_DIE) + 0.5f) ; int roll = 0 ; for (int n = numDice ; n-- > 0 ;) roll += Rand.ye...
9735c0a9-9cd5-46f4-94bc-6fd55ee0e67f
0
public AIScreen(String screenPath) { this.screenPath = screenPath; }
6ab4bd68-ee08-433b-a82d-c951e127766b
6
public EvidenziaFAM(Model mod){ //pulisco la damiera dalle vecchie caselle evidenziate mod.getDamiera().clearEvid(); //Evidenzio i pezzi che si possono muovere del giocatore che deve muovere for(int i=0;i<mod.getDamiera().getDim();i++) for(int j=0;j<mod.getDamiera().getDim();j++) if(mod.getDamier...
a4e3f39e-72f2-4274-9bab-b9ac2c6f33d7
7
public static void main(String[] args) { Class<?> c = null; try { c = Class.forName("type_information.ex01.FancyToy"); } catch(ClassNotFoundException e) { System.out.println("Can't find FancyToy"); System.exit(1); } printInfo(c); for(Cl...
1a781f44-5ac7-459f-b28e-f15991104907
8
private void putAllImpl(Map<? extends K, ? extends V> map) { if (resizingIntoElementData != null) { if (backgroundResizeComplete) { forceFinishResizing(); } } int capacity = elementCount + map.size(); if (capacity > threshold) { doResiz...
d1ca27fd-f1db-4b96-90de-0187a1052640
9
private boolean r_mark_suffix_with_optional_n_consonant() { int v_1; int v_2; int v_3; int v_4; int v_5; int v_6; int v_7; // (, line 132 // or, line 134 lab0: do { ...
218b9fd6-7491-4267-9e48-634e2a454ce0
0
public char getSuit() { return mySuit; }
b939b46f-cb2b-4903-bc30-54ce97247cf5
3
private void unplug () { assert (plugged); plugged = false; // Cancel all fd subscriptions. if (io_enabled) { io_object.rm_fd (handle); io_enabled = false; } // Disconnect from I/O threads poller object. io_object.unplug (); //...
59d113bf-9ea2-4038-84f5-b3fe50f6b1c6
2
public static void encodeFileToFile( String infile, String outfile ) throws java.io.IOException { String encoded = Base64.encodeFromFile( infile ); java.io.OutputStream out = null; try{ out = new java.io.BufferedOutputStream( new java.io.FileOutputStrea...
ea2ff401-5cd7-4b2a-9222-cf3a08e9fa28
5
public void receivePartyMemberHP() { if (party != null) { int channel = client.getChannel(); for (MaplePartyCharacter partychar : party.getMembers()) { if (partychar.getMapid() == getMapId() && partychar.getChannel() == channel) { MapleCharacter other ...
016a0728-08a3-40f8-b83a-4a0b02531058
4
public static int[] plusOne(int[] digits) { if(digits == null || digits.length == 0){ return null; } StringBuilder numBuilder = new StringBuilder(); for(int digit: digits){ numBuilder.append(digit); } long num = Long.valueOf(numBuilder.toString()); num += 1; int[] result = new int[String...
81db2d99-cf73-46ba-9d76-c3f883b38054
7
public static List<String> whoDrops(int itemid) { int searchid = itemid; List<String> retMobs = new ArrayList<String>(); MapleData data = null; MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("net.sf.odinms.wzpath") + "/" + "String.wz...
3a52863d-4f2a-45bd-9629-158ddac685b1
4
public static void main( String[] args ) throws Exception { UserImplementation userImplementation = new UserImplementation(); Protocol protocol = MessageProtocol.PROTOCOL; protocol.addListener( userImplementation ); Client client = protocol.newClient( MessageProtocol.HOST, MessageP...
e748f894-4ce2-4a44-969e-6c67b58fc857
4
public Player(TileMap tm) { super(tm); width = 30; height = 30; cwidth = 20; cheight = 20; moveSpeed = 0.3; maxSpeed = 1.6; stopSpeed = 0.4; fallSpeed = 0.15; maxFallSpeed = 4.0; jumpStart = -4.8; stopJumpSpeed = 0.3; facingRight = true; health = maxHealth = 5; fire = maxFire = 2500; ...
75c4f001-06fa-4018-ac28-89e83f69d87d
1
public static void insertActionCom( int idactiontype,int idutilisateur, Date dateaction, String actioncommercial ) throws SQLException { String query=""; try { query = "INSERT INTO ACTION_COM (ID_ACTION_TYPE,ID_INTERLOCUTEUR,ACTDATE,ACTCOMM) VALUES (?,?,?,?); " ; ...
e0f1f07a-278a-4571-8e3f-578c1a5a81b7
1
public static File open(JFrame view) { int fileChosen = chooser.showDialog(view, "Open file"); if (fileChosen == JFileChooser.APPROVE_OPTION) { chooser.requestFocus(); file = chooser.getSelectedFile(); } return file; }
443f9e19-2114-44ad-996c-ea398d2bdfb6
2
public Note findNoteOf(Critere c) { for (Note n : notes) { if (c.equals(n.getCritere())) { return n; } } return null; }
be13b738-ae78-43df-abbe-621736eedfca
9
private static void loadKeywords() { // if (wordTypes != null) { // return; // } // wordTypes = new HashMap<String, Character>(); wordTypes = new HashMap<String, Character>(); defaultWords = new HashMap<String, String>(); Scanner scanner = null; String l...
c1c0c563-17ce-4faf-b2fa-5821b24c6767
5
public void addPosition(final int x, final int y) { if (npoints >= xpoints.length || npoints >= ypoints.length) { int newLength = npoints * 2; if (newLength < MIN_LENGTH) { newLength = MIN_LENGTH; } else if ((newLength & (newLength - 1)) != 0) { ...
8b553282-0121-4ebb-bc0b-fa8575626d1f
4
protected Method getMethod(String name, boolean isStatic) { try { Method method = clazz.getDeclaredMethod(name, Map.class); if (!ConfigurationSerializable.class.isAssignableFrom(method.getReturnType())) { return null; } if (Modifier.isStatic(metho...
e2abcb00-c031-43b6-b1a8-1ebc925ae08b
3
@Override public void acceptDraggableObject(DraggableObject object) { if(object instanceof DraggableObjectFile) { DraggableObjectFile fileobj = ((DraggableObjectFile)object); if(fileobj.file != null) { if(Animation.isValidFile(fileobj.file.getName())) { textField.text = fileobj.file.getPath(...
f943eb0f-dab2-4b89-b4fc-5b225878eb6f
7
@SuppressWarnings("deprecation") private void processDictionaryRequest(OMMSolicitedItemEvent event) { OMMMsg msg = event.getMsg(); int msgType = msg.getMsgType(); Token token = event.getRequestToken(); switch (msgType) { case OMMMsg.MsgType.REQUEST: ...
344c2053-1311-422d-9a36-12cf421f8448
9
private void sink(int k) { //My method. if (false) { int i = k * 2; int length = size; while (i <= length) { if (i < length && less(i, i++)) { i++; } if (less(i, i / 2)) { exch(i, ...
ca3f0dfa-4323-4059-9dec-6276ee438714
2
private int findDay (String input) { Scanner s = new Scanner (input); int[] date = new int[3]; s.useDelimiter("/"); while(s.hasNext()) { for (int i = 0; i < date.length; i++) { date[i] = s.nextInt(); } } s.close(); return date[1]; }
29851521-e139-46fd-a2a0-90ff0d7b0cc6
1
public void update(int delta) { while(performAction(delta) != -1); }
bc0e4a21-862e-4858-8935-a1b6be37d703
0
protected final Logger getLogger() { return LoggerFactory.getLogger(this.getClass()); }
bcb39e80-68fe-44b4-abaa-d0d947360293
4
public void loadImageUrls() { try { List<String> lines = Files.readAllLines(Paths.get(MainClass.URLS_FILE), Charset.forName("UTF-8")); for (String url : lines) { downloadedUrls.put(url, Boolean.TRUE); } } catch (IOException ex) { File urls...
5e5e7c50-a56e-4f51-ab3b-6f9dd9e7f897
1
public static void addTraySelectionChangedListener( TraySelectionChangedListener listener) { if (listener != null) StorageUnitDisplayPanel.traySelectionChangedListeners .add(listener); }
41e86e55-2952-4240-af4a-394cb5a9f917
9
private String toDot(boolean includeAdvisors) { String STYLE_WAITING = ""; String STYLE_RUNNABLE = "style=filled color=yellow"; String STYLE_RUNNING = "style=filled color=green"; String STYLE_FINISHED = "style=filled color=grey"; StringBuilder sb = new StringB...
6b3d3ec8-61a7-419d-8190-2e9783facb4c
2
@Override public void run() { SpeechResult speechResult; while(running) { speechResult = listen(); String hypothesis = speechResult.getHypothesis(); if(!hypothesis.isEmpty()) { emit(new Event(EventType.INPUT, this, hypothesis)); } ...
f23f4403-fe87-4acc-9965-6606f05c48a7
7
protected void beforeCloseTag(final char c) { switch(c) { case ' ': case '\t': case '\r': case '\n': bufDex++; return; case '<': changeTagState(State.BEFORETAG); return; case '/': changeTagState(State.BEFORECLOSETAG); return; default: if(Character.isLetter(c)) changedTagState(State.INCLOSETAG); e...
6ca79cb4-a2f6-4c13-9103-525fbb72b655
3
private String getNodeIndex(JTree tree, TreeNode node) { TreeNode root = (TreeNode) tree.getModel().getRoot(); if (node == root) { return ""; } TreeNode parent = node.getParent(); if (parent == null) { return null; } String parentIndex= getNodeIndex(tree, parent); ...
36d1d317-a7c2-4f3c-8887-ba19e50336ca
2
@Override public void xwrite_activated (Pipe pipe_) { for (Map.Entry<Blob, Outpipe> it: outpipes.entrySet()) { if (it.getValue().pipe == pipe_) { assert (!it.getValue().active); it.getValue().active = true; break; } } ...
fd5c052c-550d-4292-b90e-bd444aa7f27f
0
@Override public String getName() { return super.getName(); }
563bd75b-d0b6-4d89-904d-8a1888bdb39e
2
@Override public void propertyChange(PropertyChangeEvent event) { JMenuItem mi = mTarget.get(); if (mi == null) { Action action = (Action) event.getSource(); action.removePropertyChangeListener(this); } else { if (event.getPropertyName().equals(Action.ACCELERATOR_KEY)) { mi.setAccelerator((KeyStroke...
50bdfb1e-5707-458e-a9d5-d781e89880f0
5
private void calculateSimilarities() { for (Map.Entry<Integer, HashSet<Integer>> movie1 : usersByMovie.entrySet()) { LinkedHashMap<Integer, Double> comparedMovies = new LinkedHashMap<Integer, Double>(); for (Map.Entry<Integer, HashSet<Integer>> movie2 : usersByMovie.entrySet()) { // Only calculate similari...
e5891392-15b6-4548-bf97-04b76d28d6c8
3
public static PackedImage threshold(PackedImage img, int level) { PackedImage outImg = new PackedImage(img.rows(), img.cols()); int sum; for (int r = 0; r < img.rows(); r++) { for (int c = 0; c < img.cols(); c++) { sum = img.at(r, c, 0) + img.at(r, c, 1) + img.at(r, c, 2); if (sum/3 < level...
75ac5357-29de-4c52-ad64-c1da09702d03
5
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { super.doGet(req, res); header("Places disponibles"); if (!testConnection()){ footer(); return; } String numS, date, nomS; numS = req.getParameter("numS"); date = req.getParameter("date"); nomS = req....
3e8ad31b-001d-488d-81cf-02d79d8f4763
5
@Override public void execute(CommandSender sender, String gateName, List<String> args) { this.sender = sender; if (gateName == null) { error("No gate given."); reply("Usage: /gate delete <gatename>"); } else if (!gateExists(gateName)) { reply("Gate not found: " + gateName); } else { DataGate th...
85b9e167-efb7-4658-a71e-0be18b5c8e29
6
protected void insertFix(TreeNode<K, D> nd) { while (nd.parent.color == RED) { if (nd.parent == nd.parent.parent.left) { TreeNode<K, D> nd2 = nd.parent.parent.right; if (nd2.color == RED) { nd.parent.color = BLACK; nd2.color = B...