method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
3a1d8cfc-8400-48ed-9e2d-57aea551c1c3
1
public int lastSelectedIndex() { int index = mSelection.length() - 1; return index < mSize ? index : -1; }
55317292-03bc-448e-ab51-e154a5b47bdf
5
public static ParentInfo getParentInfo(Map<String, Set<String>> graph) { Set<String> allParents = new HashSet<String>(); for (Set<String> parents : graph.values()) { allParents.addAll(parents); } Set<String> unseenParents = new HashSet<String>(); unseenParents.addAll(allParents); unseenParents.removeAll(graph.keySet()); Set<String> rootIds = new HashSet<String>(); for(Map.Entry<String, Set<String>> entry : graph.entrySet()) { Set<String> parents = entry.getValue(); if (parents == null || parents.size() == 0) { rootIds.add(entry.getKey()); continue; } assert_(parents.size() > 0); Set<String> unknownParents = new HashSet<String>(); unknownParents.addAll(parents); unknownParents.removeAll(unseenParents); // BUG: ??? Revisit. what if only some parents are unknown? //# All parents are unknown if (unknownParents.size() == 0) { rootIds.add(entry.getKey()); } } return new ParentInfo(allParents, rootIds); }
390dc25c-862a-4849-9865-617773efdcf6
4
private Document httpGetXmlContent(String queryString) { try { URIBuilder builder = new URIBuilder(); builder.setScheme("http"); builder.setHost(this.endpointUri); builder.setPath("/sparql"); builder.setParameter("query", queryString); builder.setParameter("output", "xml"); URI uri = builder.build(); DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return parser.parse(uri.toString()); } catch (SAXException ex) { Logger.getLogger(SparqlClient.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(SparqlClient.class.getName()).log(Level.SEVERE, null, ex); } catch (ParserConfigurationException ex) { Logger.getLogger(SparqlClient.class.getName()).log(Level.SEVERE, null, ex); } catch (URISyntaxException ex) { Logger.getLogger(SparqlClient.class.getName()).log(Level.SEVERE, null, ex); } return null; }
ed96f922-8de6-461d-98fb-e30556329f08
8
@Override public void run()//GameLoop { while (marioWorld.getWhatcha() != Doing.EXIT) { if ((System.currentTimeMillis() - gameTimer) > GAMESPEED) { gameTimer = System.currentTimeMillis(); marioWorld.doLoopAction(); switch (marioWorld.getWhatcha())//doing { case PLAYING: view.drawStage(marioWorld.getStage()); break; case MAIN: view.drawMenu(marioWorld.getMainMenu()); break; case PAUSE: view.drawMenu(marioWorld.getPauzeMenu()); break; case SELECTSTAGE: view.drawStageSelector(marioWorld.getStageSelector()); break; } // <editor-fold defaultstate="collapsed" desc="commented code from old code. Usable for referense"> // if (!marioWorld.getGame().isRunning()) // { // selectedMenu = mainMenu; // view.drawMenu(mainMenu); // } // else // { // if (marioWorld.getGame().isPaused()) // { // selectedMenu = pauzeMenu; // view.drawMenu(pauzeMenu); // } // else // { // // gameTimer = System.currentTimeMillis(); // ////System.out.println("going loop----------------------------------------------------------------"); // marioWorld.getGame().removeObjects(); // marioWorld.getGame().getAiDirector().createMapObjects(); // // gameObjectLoopAction(); // // collisionDetector.detectCollisionsGameObjects(); // // view.draw(); // // ////System.out.println("end loop----------------------------------------------------------------"); // } // }// </editor-fold> } try { Thread.sleep(1); } catch (InterruptedException ex) { Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex); } } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkExit(0); } System.exit(0); }
36465abb-098b-4bc0-8191-12b6c6399ff6
2
public LocalInfo findSlot(int slot) { for (int i = 0; i < count; i++) if (locals[i].getSlot() == slot) return locals[i]; return null; }
6af337cf-116c-4610-b4d9-a677b2ad0615
1
public synchronized void addReceivedPacketHistoryToOutgoingPacket(Packet packet) { if(packet != null) { packet.setLastReceivedSequenceNumber(lastReceivedPacketSequenceNumber); packet.setReceivedPacketHistory(receivedPacketHistoryInt); } }
0b6c1cfb-4f53-493f-969d-651143290427
7
private void btn_submitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_submitActionPerformed if ((cbx_backTrouble.getSelectedIndex() == 0) || (cbx_heartTrouble.getSelectedIndex() == 0) || txt_heightInput.getText().isEmpty()) { // if no options were chosen txt_output.setText("Please answer all the questions.");// prompt the user to answer the questions } else { // practicing using the (condition) ? (true) : (false); structure of writing if statements. // I realize that it would have been more clear and easier to use an iff statment, but i want the practise. txt_output.setText((122 > (Integer.parseInt(txt_heightInput.getText())) || //if user is smaller then 122 cm (Integer.parseInt(txt_heightInput.getText())) > 188 || // or taller then 188 cm // checking for a response that starts with y allows for the covering of a wide range of affirmative statements (cbx_backTrouble.getSelectedIndex() == 1) || // or has back trouble (cbx_heartTrouble.getSelectedIndex() == 1)) ? // or has heart trouble ("Sorry, it is not safe for you to ride this roller coaster.") : // do this if any of the above is true ("It is okay for you to ride this roller coaster. Have fun!")); // do this if everything is false. that is they can ride the coaster. } }//GEN-LAST:event_btn_submitActionPerformed
b0b16384-db2a-485c-8483-79eef5c12b09
4
@Override public void run() { try { while(!Thread.interrupted()) { synchronized(this) { while(restaurant.meal != null) { wait(); // ... for the meal to be taken } } if(++count == 10) { print("Out of food, closing"); restaurant.exec.shutdownNow(); return; } printnb("Order up! "); synchronized(restaurant.waitPerson) { restaurant.meal = new Meal(count); restaurant.waitPerson.notifyAll(); } TimeUnit.MILLISECONDS.sleep(100); } } catch(InterruptedException e) { print("Chef interrupted"); } }
b67878f6-d123-4d81-848d-188eb6aef529
8
public int ramainQuantity(String cou_name){ Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; String sql = ""; int result = 0; try{ conn = getConnection(); sql = "select cou_name,count(*) as quantity from coupon where cou_name=? ans cou_usage=1"; pstmt = conn.prepareStatement(sql); pstmt.setString(1, cou_name); rs =pstmt.executeQuery(); if(rs.next()){ result = rs.getInt("quantity"); } }catch(Exception ex){ ex.printStackTrace(); }finally{ if(rs!=null)try{rs.close();}catch(SQLException ex){} if(pstmt!=null)try{pstmt.close();}catch(SQLException ex){} if(conn!=null)try{conn.close();}catch(SQLException ex){} } return result; }
f5693ed8-68dc-45ee-b000-2bb0da82b52f
5
public void minHeapify_top_down(int index) { int small; if (index * 2 + 1 >= heap.size()) return; else if (2 * index + 2 == heap.size()) { if (heap.get(2 * index + 1).compareTo(heap.get(index)) < 0) { Type temp = heap.get(2 * index + 1); heap.set(2 * index + 1, heap.get(index)); heap.set(index, temp); } return; } if (heap.get(index * 2 + 1).compareTo(heap.get(2 * index + 2)) < 0) { small = index * 2 + 1; } else { small = 2 * index + 2; } if (heap.get(small).compareTo(heap.get(index)) < 0) { Type temp = heap.get(small); heap.set(small, heap.get(index)); heap.set(index, temp); minHeapify_top_down(small); } }
f8129145-1aea-46d8-85b6-3f7127eee49f
3
static Constructor getDeclaredConstructor(final Class clazz, final Class[] types) throws NoSuchMethodException { if (System.getSecurityManager() == null) return clazz.getDeclaredConstructor(types); else { try { return (Constructor) AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { return clazz.getDeclaredConstructor(types); } }); } catch (PrivilegedActionException e) { if (e.getCause() instanceof NoSuchMethodException) throw (NoSuchMethodException) e.getCause(); throw new RuntimeException(e.getCause()); } } }
257415eb-4580-4a41-ac3c-9af0fdadf480
9
public void start() { try { Display.setFullscreen(true); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1, -1); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); textures = Materials.getTextures(); TerrainGen.init(); while (run && !Display.isCloseRequested()) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); for(int i = 0; i < TILE_NUM; i++){ for(int j = 0; j < TILE_NUM; j++){ Tile t = tiles[i][j]; if(t!=null){ t.draw(); Iterator<Resource> itr = t.resources.iterator(); while(itr.hasNext()){ Resource r = itr.next(); r.draw(t.x, t.y, TILE_SIZE); } } } } GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); double SCREEN_SIZE_X = Display.getWidth(); double SCREEN_SIZE_Y = Display.getHeight(); GL11.glOrtho(Camera.x - (SCREEN_SIZE_X/2) * Camera.z, (Camera.x- (SCREEN_SIZE_X/2)) + SCREEN_SIZE_X,Camera.y - (SCREEN_SIZE_Y/2)* Camera.z, (Camera.y- (SCREEN_SIZE_Y/2)) + SCREEN_SIZE_Y, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); try { Input.showInput(); } catch (LWJGLException e) { e.printStackTrace(); } Display.update(); Display.sync(60); } for(Texture t: textures){ t.release(); } Display.destroy(); }
5a868ad6-86a6-4ad9-b876-9508bc77a322
6
public double getMeleeDefence(Client o) { double level = c.playerLevel[1]; double levelMultiplier = 1.00; if (c.prayerActive[2]) levelMultiplier *= 1.05; else if (c.prayerActive[7]) levelMultiplier *= 1.1; else if (c.prayerActive[15]) levelMultiplier *= 1.15; else if (c.prayerActive[24]) levelMultiplier *= 1.20; else if (c.prayerActive[25]) levelMultiplier *= 1.25; double effectiveDefence = (int) (level * levelMultiplier); double maxDefence = effectiveDefence * getMeleeDefenceBonus(o); if (maxDefence < 1) { maxDefence = 1; } return maxDefence * 1.20; }
50d5a98c-d120-4797-9d74-d56f26edcb0b
9
private void writePostData(OutputStream out, PostData postData) throws IOException { InputStream in = postData.getInputStream(); int contentLength = -1; if (mHeaders != null) { Integer i = mHeaders.getInteger("Content-Length"); if (i != null) { contentLength = i.intValue(); } } byte[] buf; if (contentLength < 0 || contentLength > 4000) { buf = new byte[4000]; } else { buf = new byte[contentLength]; } try { int len; if (contentLength < 0) { while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } else { while (contentLength > 0) { len = buf.length; if (contentLength < len) { len = contentLength; } if ((len = in.read(buf, 0, len)) <= 0) { break; } out.write(buf, 0, len); contentLength -= len; } } } finally { in.close(); } }
6220ede5-859f-4cd1-a9fd-1ac84b486353
7
void processMouseMoved(MouseEvent e) { if (!hasFocus()) return; int x = e.getX(); int y = e.getY(); getModel().runMouseScript(MouseEvent.MOUSE_MOVED, x, y); if (energizerOn) { if (energizer != null) { if (x >= energizer.x) { energizer.mouseEntered(x, y); } else { energizer.mouseExited(); } energizer.paint((Graphics2D) getGraphics()); } } if (steeringForceController != null && steeringForceController.currentReading != 0) { if (y >= steeringForceController.incrButton.y) steeringForceController.mouseEntered(x, y); else steeringForceController.mouseExited(); steeringForceController.paint((Graphics2D) getGraphics()); } }
05d17142-6756-4612-8fbd-d51e5149ed9d
3
public int isGemCollision(int x, int y, ArrayList gems) { Gem tempGem; int number; for (int i = 0; i < gems.size(); i++) { tempGem = (Gem) gems.get(i); if(tempGem.x == x && tempGem.y == y) { number = i; return number; } } //No collision return -1; }
a76c3bdb-5de0-4315-8ed2-5c139602744b
9
public void Check() { if( ((this.x >= p.x-p.w && this.x < p.x+p.w) && (this.y >= p.y-p.l && this.y < p.y+p.l)) ){ Game.stuff.update(); p.kill(); } for(Enemy A: Game.Enemies){ if( ((this.x >= A.x-A.w && this.x < A.x+A.w) && (this.y >= A.y-A.l && this.y < A.y+A.l)) ){ this.xSpeed = -this.xSpeed; this.ySpeed = -this.ySpeed; A.xSpeed = -A.xSpeed; A.ySpeed = -A.ySpeed; } } }
d95148b1-0902-44c8-8a81-6c887d72a179
6
public void upgrade(T snap) { Transaction me = Thread.getTransaction(); Locator oldLocator = this.start.get(); T version = (T) oldLocator.fastPath(me); if (version != null) { if (version != snap) { throw new SnapshotException(); } else { return; } } ContentionManager manager = Thread.getContentionManager(); Locator newLocator = new Locator(me, (Copyable)factory.create()); while (true) { oldLocator.writePath(me, manager, newLocator); if (!me.isActive()) { throw new AbortedException(); } if (snap != newLocator.oldVersion) { throw new SnapshotException(); } if (this.start.compareAndSet(oldLocator, newLocator)) { return; } oldLocator = this.start.get(); } }
95199b46-609c-44df-997a-4652f4b1535d
4
void addWithArgument( AbstractOptionSpec<?> spec, String argument ) { detectedSpecs.add( spec ); for ( String each : spec.options() ) detectedOptions.put( each, spec ); List<String> optionArguments = optionsToArguments.get( spec ); if ( optionArguments == null ) { optionArguments = new ArrayList<String>(); optionsToArguments.put( spec, optionArguments ); } if ( argument != null ) optionArguments.add( argument ); }
dd867c42-6660-4979-811a-de8ef6c2fe0a
5
@Override @Command public MessageResponse upload(String filename) throws IOException { File f = new File(directory, filename); if(f.exists()) { BufferedReader br = new BufferedReader(new FileReader(f)); try { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append('\n'); line = br.readLine(); } String text = sb.toString(); UploadRequest request = new UploadRequest("",filename, 0, text.getBytes()); this.sendToServer(request); try { return (MessageResponse)objectInput.readObject(); } catch(SocketException se) { shell.writeLine("Socket closed unexpectedly."); exit(); } catch(EOFException eof) { shell.writeLine("Socket closed unexpectedly"); exit(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } finally { br.close(); } } else { return new MessageResponse("The file you wanted to upload doesn't exist."); } return null; }
0b301049-ef93-423e-8530-51d6168a7987
0
protected int getBreedingAge() { return breeding_age; }
f3d6ec2e-4335-4d55-af12-2f6579b66b01
9
public NullInfoRegistry add(NullInfoRegistry other) { if ((other.tagBits & NULL_FLAG_MASK) == 0) { return this; } this.tagBits |= NULL_FLAG_MASK; this.nullBit1 |= other.nullBit1; this.nullBit2 |= other.nullBit2; this.nullBit3 |= other.nullBit3; this.nullBit4 |= other.nullBit4; if (other.extra != null) { if (this.extra == null) { this.extra = new long[extraLength][]; for (int i = 2, length = other.extra[2].length; i < extraLength; i++) { System.arraycopy(other.extra[i], 0, (this.extra[i] = new long[length]), 0, length); } } else { int length = this.extra[2].length, otherLength = other.extra[2].length; if (otherLength > length) { for (int i = 2; i < extraLength; i++) { System.arraycopy(this.extra[i], 0, (this.extra[i] = new long[otherLength]), 0, length); System.arraycopy(other.extra[i], length, this.extra[i], length, otherLength - length); } } else if (otherLength < length) { length = otherLength; } for (int i = 2; i < extraLength; i++) { for (int j = 0; j < length; j++) { this.extra[i][j] |= other.extra[i][j]; } } } } return this; }
4d2fedf6-6551-40fe-8be2-53905a709c4f
6
private void serverConnectionAction(ActiveUser activeUser, String msg) { if(activeUser.getUsername()==null) { try { activeUser.setUsername(Xmlhandle.extractUsername(msg)); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { xmlHandle.performMessageInstructions(Xmlhandle.stringToXML(msg)); } catch (NumberFormatException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }
938d491e-93d2-4096-af79-3dffeabb447c
0
public void setCoefiente(int coefiente) { this.coefiente = coefiente; }
e1126b56-1a35-4852-a187-176ee70a9499
5
int[] kmpTable(String needle) { if (needle.length() == 0) return null; if (needle.length() == 1) { int[] T = new int[1]; T[0] = -1; return T; } int[] T = new int[needle.length()]; int pos = 2; // the current position we are computing in T int cnd = 0; // current candidate substring T[0] = -1; T[1] = 0; while (pos < needle.length()) { if (needle.charAt(pos - 1) == needle.charAt(cnd)) { cnd++; T[pos] = cnd; pos++; } else if (cnd > 0) { cnd = T[cnd]; } else { // cnd == 0 T[pos] = 0; pos++; } } return T; }
99a416f9-4c56-4416-8764-d31f61270971
6
@PUT @Path("/{isbn}") @Timed(name = "update-book") public Response updateBook(@PathParam("isbn") long isbn, @QueryParam("status") String status) throws Exception { try{ if(!status.equalsIgnoreCase("avialable") && !status.equalsIgnoreCase("lost") && !status.equalsIgnoreCase("checked-out") && !status.equalsIgnoreCase("in-queue")) { throw new NotFoundException("In-valid value entered for status. Valid values are [avialable,lost,checked-out,in-queue]"); } } catch (Exception e) { throw e; } Book retrieveBook=new_book_entry.get(isbn); retrieveBook.setStatus(status); BookDto bookResponse = new BookDto(); bookResponse.addLink(new LinkDto("view-book", "/books/" + retrieveBook.getIsbn(), "GET")); bookResponse.addLink(new LinkDto("update-book","/books/" + retrieveBook.getIsbn(), "PUT")); bookResponse.addLink(new LinkDto("delete-book","/books/" + retrieveBook.getIsbn(), "DELETE")); bookResponse.addLink(new LinkDto("create-review","/books/" + retrieveBook.getIsbn() + "/reviews", "POST")); if (retrieveBook.getReviews().size() !=0 ){ bookResponse.addLink(new LinkDto("view-all-reviews","/books/" + retrieveBook.getIsbn() + "/reviews", "GET")); } return Response.ok().entity(bookResponse.getLinks()).build(); }
76c3e332-c157-4de9-9ae7-df1cdc80286c
3
public static String[] jobSearch(String inJob) { String[] userInfo = new String[5]; Connection c = null; Statement stmt = null; try { Class.forName("org.sqlite.JDBC"); c = DriverManager.getConnection("jdbc:sqlite:Restuarant.db"); c.setAutoCommit(false); System.out.println("Opened database successfully"); stmt = c.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM USERS;"); while (rs.next()) { String name = rs.getString("name"); String job = rs.getString("job"); String password = rs.getString("password"); if (job.equals(inJob)) { userInfo[0] = (name); userInfo[1] = (job); userInfo[2] = (password); rs.close(); stmt.close(); c.close(); } } } catch (Exception e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); System.exit(0); } return userInfo; }
9d23391b-3701-4624-a791-98cd7ce12be2
8
public Object set(Context cx, Object value) { switch (type) { case SPECIAL_NONE: return ScriptRuntime.setObjectProp(target, name, value, cx); case SPECIAL_PROTO: case SPECIAL_PARENT: { Scriptable obj = ScriptRuntime.toObjectOrNull(cx, value); if (obj != null) { // Check that obj does not contain on its prototype/scope // chain to prevent cycles Scriptable search = obj; do { if (search == target) { throw Context.reportRuntimeError1( "msg.cyclic.value", name); } if (type == SPECIAL_PROTO) { search = search.getPrototype(); } else { search = search.getParentScope(); } } while (search != null); } if (type == SPECIAL_PROTO) { target.setPrototype(obj); } else { target.setParentScope(obj); } return obj; } default: throw Kit.codeBug(); } }
30935626-2fb9-4bbd-b5fd-ad6e10f301d5
1
@Override protected CycNaut toCycTerm(final Money obj) throws ParseException { ensureCurrencyMapInitialized(); final CycFort functor = lookupCycCurrencyTerm(obj.getCurrency()); if (functor == null) { throwParseException("Cannot find Cyc UnitOfMoney for currency code " + obj.getCurrency().getCurrencyCode()); } return new CycNaut(functor, obj.getQuantity()); }
14aa65d7-226d-4541-ab06-c6f2c6ed129a
1
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Library library = new Library(); request.setAttribute("bookResults", library.getBooks("", "Title", "Title", 0)); } catch (SQLException e) { e.printStackTrace(); } request.getRequestDispatcher("WEB-INF/browsing.jsp").forward(request, response); }
df846c9e-1dc4-482d-a793-760319fb6368
2
public static void setHost(String host) { if (host.length() > 0 && !host.substring(host.length() - 1).equals("/")) { host += "/"; } getInstance().host = host; }
b23fba12-b0f1-47cc-839e-df5bbfacb515
7
public boolean equals(Object y) { if (y == this) return true; if (y == null) return false; if (y.getClass() != this.getClass()) return false; SET<Key> that = (SET<Key>) y; if (this.size() != that.size()) return false; try { for (Key k : this) if (!that.contains(k)) return false; } catch (ClassCastException exception) { return false; } return true; }
ead8d0a8-213f-46e8-8e13-6cc94b9b61cd
2
public void pushPreferences() { try { if (rpcURL == null) { preferences.put("rpcurl", ""); } else { preferences.put("rpcurl", rpcURL.toString()); } preferences.putLong("updateinterval", updateInterval); preferences.put("rpcuser", rpcUser); preferences.put("rpcpass", encryptor.encryptString(rpcPass)); preferences.putBoolean("aurl.autopaste", addURLAutoPaste); preferences.putInt("window.height", interfaceWindowConfig.getWindow().getHeight()); preferences.putInt("window.width", interfaceWindowConfig.getWindow().getWidth()); preferences.putInt("window.x", interfaceWindowConfig.getWindow().getX()); preferences.putInt("window.y", interfaceWindowConfig.getWindow().getY()); preferences.putInt("window.hs", interfaceWindowConfig.getWindow().getHorizontalSplit()); preferences.putInt("window.vs", interfaceWindowConfig.getWindow().getVerticalSplit()); } catch (Throwable e) { //TODO: Add detailed exception handling Arietta.handleException(e); } }
ac86894d-c1bc-47b3-accf-297e8d11a5f3
4
@Override public boolean execute(AdrundaalGods plugin, CommandSender sender, String... args) { // Grab the argument, if any. String arg1 = (args.length > 1 ? args[0] : ""); if(arg1.isEmpty()) { plugin.saveConfigs(); plugin.saveDataFiles(); Messenger.sendMessage(sender, ChatColor.GRAY+"All files saved"); return true; } if(arg1.equalsIgnoreCase("config")) { plugin.saveConfigs(); Messenger.sendMessage(sender, ChatColor.GRAY+"Configs saved"); return true; } else if(arg1.equalsIgnoreCase("data")) { plugin.saveDataFiles(); Messenger.sendMessage(sender, ChatColor.GRAY+"Data files saved"); return true; } else return false; }
d9005a71-6cea-4f70-91cf-580a8a7daf69
3
public String dibujarMuneco(){ String m = ""; if(nivel.equals("Basico")){ m = munecoBasico(); } if(nivel.equals("Intermedio")){ m = munecoIntermedio(); } if(nivel.equalsIgnoreCase("Avanzado")){ m = munecoAvanzado(); } return m; }
fcb33d88-a00c-4b9b-b49b-fea1e36839b0
3
private int medianOf3(int[] array, int left, int right){ int center = (left+right)/2; if( array[left] > array[center] ) swap(array,left, center); if( array[left] > array[right] ) swap(array,left, right); if( array[center] > array[right] ) swap(array, center, right); swap(array, center, right-1); return array[right-1]; }
445cc619-5450-4970-b201-a926dd7aceef
0
public int getNumEntries() { return numEntries; }
e62e0791-c13c-4cd4-859c-13a1119782d8
7
private void arrayList(JsonArray array) { if(currTok.getType() == STR || currTok.getType() == NUM || currTok.getType() == LBRACE || currTok.getType() == LBRACKET || currTok.getType() == BOOL || currTok.getType() == NULL) { array.addValue(value()); arrayListTail(array); } else if(currTok.getType() != RBRACKET) { error(STR, NUM, LBRACE, LBRACKET, BOOL, NULL, RBRACKET); } }
1f9c3c06-841e-4537-b0ab-ceb72d7d9594
7
@Override public boolean equals(Object o){ if(o instanceof Pair){ Pair<?, ?> p = (Pair<?, ?>) o; if(getValueOne().equals(p.getValueOne()) && getValueTwo().equals(p.getValueTwo())){ return true; } } return false; }
618b31d6-75db-443d-ab9d-61d69e46e6c7
3
public void attemptClose(Dockable dockable) { if (dockable instanceof CloseHandler) { if (mDockables.contains(dockable)) { CloseHandler closeable = (CloseHandler) dockable; if (closeable.mayAttemptClose()) { closeable.attemptClose(); } } } }
359129c7-c3b7-4a7f-b97c-0df1b337003d
6
private void copyRGBtoBGRA(ByteBuffer buffer, byte[] curLine) { if(transPixel != null) { byte tr = transPixel[1]; byte tg = transPixel[3]; byte tb = transPixel[5]; for(int i=1,n=curLine.length ; i<n ; i+=3) { byte r = curLine[i]; byte g = curLine[i+1]; byte b = curLine[i+2]; byte a = (byte)0xFF; if(r==tr && g==tg && b==tb) { a = 0; } buffer.put(b).put(g).put(r).put(a); } } else { for(int i=1,n=curLine.length ; i<n ; i+=3) { buffer.put(curLine[i+2]).put(curLine[i+1]).put(curLine[i]).put((byte)0xFF); } } }
80c4dc98-d3d0-4ed4-9ff5-28ed7cc8c156
5
double getKth(int[] a, int[] b, int k) { int m = a.length; int n = b.length; if (n == 0) return a[k - 1]; if (m == 0) return b[k - 1]; if (k == 1) return Math.min(a[0], b[0]); // divide k into two parts int p1 = Math.min(k / 2, m); int p2 = Math.min(k - p1, n); if (a[p1 - 1] < b[p2 - 1]) return getKth(Arrays.copyOfRange(a, p1, m), b, k - p1); else if (a[p1 - 1] > b[p2 - 1]) return getKth(a, Arrays.copyOfRange(b, p2, n), k - p2); else return a[p1 - 1]; }
10e2dc88-9456-475c-b15d-3e81b617bf01
0
public static CarJsonConverter getInstance() { return instance; }
bcca8b96-cc64-496c-90e3-accc29d44e2b
7
public static void main(String[] args) throws Exception { for( int x=1; x < NewRDPParserFileLine.TAXA_ARRAY.length; x++) { System.out.println(NewRDPParserFileLine.TAXA_ARRAY[x]); File inFile = new File(ConfigReader.getTopeSep2015Dir() + File.separator + "spreadsheets" + File.separator + NewRDPParserFileLine.TAXA_ARRAY[x] + "asColumnsLogNormalPlusMetadataFilteredCaseControl.txt"); int numSamples = getNumSamples(inFile); BufferedReader reader = new BufferedReader(new FileReader(inFile)); BufferedWriter writer = new BufferedWriter(new FileWriter(new File( ConfigReader.getTopeSep2015Dir() + File.separator + "spreadsheets" + File.separator + NewRDPParserFileLine.TAXA_ARRAY[x] + "asColumnsLogNormalPlusMetadataFilteredCaseControl.arff" ))); writer.write("% " + NewRDPParserFileLine.TAXA_ARRAY[x] + "\n"); writer.write("@relation " + NewRDPParserFileLine.TAXA_ARRAY[x] + "_sep15\n"); String[] topSplits = reader.readLine().replaceAll("\"","").split("\t"); for( int y=6; y < topSplits.length; y++) { writer.write("@attribute " + topSplits[y].replaceAll(" ", "_") + " numeric\n"); } writer.write("@attribute isCase { true, false }\n"); writer.write("\n\n@data\n"); writer.write("%\n% " + numSamples + " instances\n%\n"); for( String s= reader.readLine(); s != null; s = reader.readLine()) { s = s.replaceAll("\"", ""); String[] splits = s.split("\t"); if( splits.length != topSplits.length) throw new Exception("Parsing error!"); for( int y=6; y < splits.length; y++) { writer.write( splits[y] + ","); } int caseInt = Integer.parseInt(splits[4]); if( caseInt == 0 ) writer.write("false\n"); else if( caseInt ==1) writer.write("true\n"); else throw new Exception("Parsing error\n"); } writer.flush(); writer.close(); reader.close(); } }
d31635cd-d2c3-424f-8e14-d27f4c372cbe
6
public void notifyPatternTableToBeModified(int pageNum, int index) { if (editorRegion != null) { byte b[] = editorRegion.getTileMask(); int byteOffset = index * 16; System.arraycopy(b, 0, modelRef.getCHRModel().patternTable[pageNum], byteOffset, 16); } if (supportPageSwitch(pageNum)) { modelRef.lastPageNum = pageNum; } modelRef.lastPatternIndex = index; // redundant if (editorRegion != null) { editorRegion.setTile(index, modelRef.patternTableTiles[pageNum][index].asMask()); } for (int i = 0; i < nameTableRegions.length; i++) { if (nameTableRegions[i] != null) { nameTableRegions[i].updateNameTableTiles(true); } } if (animationGrid != null) { animationGrid.updateAnimationView(); } }
a725ce91-7261-453b-8e0f-3c7fbb6d5b92
3
public static boolean isServerUp() { Map<String, String> connParams = getServerConnectionParams(serverId); try { System.setProperty("java.rmi.server.hostname", connParams.get("serverIP")); Registry registry = LocateRegistry.getRegistry( connParams.get("serverIP"), serverPort); server = (ServerInterface) registry.lookup("ServerInterfaceImpl"); return true; } catch (NotBoundException | RemoteException e) { // e.printStackTrace(); serverId = getOtherServerIds().get(0); connParams = getServerConnectionParams(serverId); try { System.setProperty("java.rmi.server.hostname", connParams.get("serverIP")); Registry registry = LocateRegistry.getRegistry( connParams.get("serverIP"), serverPort); server = (ServerInterface) registry .lookup("ServerInterfaceImpl"); return true; } catch (NotBoundException | RemoteException e2) { // e.printStackTrace(); serverId = getOtherServerIds().get(1); connParams = getServerConnectionParams(serverId); try { System.setProperty("java.rmi.server.hostname", connParams.get("serverIP")); Registry registry = LocateRegistry.getRegistry( connParams.get("serverIP"), serverPort); server = (ServerInterface) registry .lookup("ServerInterfaceImpl"); return true; } catch (NotBoundException | RemoteException e3) { return false; } } } // return false; }
51d6a6c8-654b-4572-ba62-0c56d255e01d
3
public void visitTableSwitchInsn(final int min, final int max, final Label dflt, final Label[] labels) { buf.setLength(0); for (int i = 0; i < labels.length; ++i) { declareLabel(labels[i]); } declareLabel(dflt); buf.append("mv.visitTableSwitchInsn(").append(min).append(", ") .append(max).append(", "); appendLabel(dflt); buf.append(", new Label[] {"); for (int i = 0; i < labels.length; ++i) { buf.append(i == 0 ? " " : ", "); appendLabel(labels[i]); } buf.append(" });\n"); text.add(buf.toString()); }
4f802e0a-6c13-4b55-b617-2934cb2b2011
8
void getValue() { String methodName = "get" + nameCombo.getText(); getText.setText(""); Widget[] widgets = getExampleWidgets(); for (int i = 0; i < widgets.length; i++) { try { java.lang.reflect.Method method = widgets[i].getClass().getMethod(methodName, (Class<?>)null); Object result = method.invoke(widgets[i], (Object)null); if (result == null) { getText.append("null"); } else if (result.getClass().isArray()) { int length = java.lang.reflect.Array.getLength(result); if (length == 0) { getText.append(result.getClass().getComponentType() + "[0]"); } for (int j = 0; j < length; j++) { getText.append(java.lang.reflect.Array.get(result,j).toString() + "\n"); } } else { getText.append(result.toString()); } } catch (Exception e) { getText.append(e.toString()); } if (i + 1 < widgets.length) { getText.append("\n\n"); } } }
1c054822-9461-4596-991d-9595cd3dbec5
3
@Override public List<Categoria> listAll() { Connection conn = null; PreparedStatement pstm = null; ResultSet rs = null; List<Categoria> categorias = new ArrayList<>(); try{ conn = ConnectionFactory.getConnection(); pstm = conn.prepareStatement(LIST); rs = pstm.executeQuery(); while(rs.next()){ Categoria c = new Categoria(); c.setId_tipo(rs.getInt("id_categoria")); c.setDescricao(rs.getString("descricao_ct")); categorias.add(c); } }catch(Exception e){ JOptionPane.showMessageDialog(null,"Erro ao listar categorias " + e); }finally{ try{ ConnectionFactory.closeConnection(conn, pstm, rs); }catch(Exception e){ JOptionPane.showMessageDialog(null,"Erro ao desconectar com o banco " + e); } } return categorias; }
fda9321f-e1b2-4e2b-87a4-c84d59fc3095
8
public boolean Shift(int amt) { int i; if(amt < 0) { /* right-shift: discarding digits */ /* get positive magnitude */ amt *= -1; if(amt >= this.size) { /* discarding all digits -- set to zero */ this.SetToNative(0); } else { /* copy digits down, and update size */ for(i = 0; i < this.size - amt; i++) { this.digits[i] = this.digits[i + amt]; } this.size -= amt; } } else if(amt > 0) { /* left-shift: adding trailing zeroes -- can require reallocation, which can fail */ i = this.size + amt; while(this.size < i) { if(!this.AddLeadingZero()) { return false; } } for(i--; i >= amt; i--) { this.digits[i] = this.digits[i - amt]; } while(i >= 0) { this.digits[i] = 0; i--; } } return true; }
76ddb58e-2c6d-4bcc-8785-7f3e3d85e22f
0
public String toString() { String affiche = "message intelligence"; return affiche; }
676b885c-2a41-4f3c-b492-554587146d6b
4
public static void main(String args[]){ /*for(int x=0;x<16;x++){ for(int y=0;y<4; y++){ System.out.printf("%b\t", lookUp[x][y]); } System.out.printf("\n"); } }*/ for( int x = 0; x < 256; x++){ String bin = Integer.toBinaryString(x); if(bin.length()<8){ String padding = ""; for(int p=0; p<8-bin.length(); p++){ padding += "0"; } bin=padding+bin; } printBoolVal("{", bin.charAt(0), ",\t"); for( int y=1; y<7; y++){ printBoolVal("", bin.charAt(y), ",\t"); } printBoolVal("", bin.charAt(7), "},\n"); } }
9d97ff84-c9bb-4c94-ba3c-0c8360cae961
9
public void loadHeatSources() { try { plugin.heatSources.clear(); try { for (String tempSource : GlobalConf.getConfigurationSection("HeatSources").getKeys(false)) { if (Material.getMaterial(tempSource) != null) { if (!GlobalConf.isSet("HeatSources." + tempSource)) { GlobalConf.set("HeatSources." + tempSource, (double) 0); } plugin.heatSources.put(Material.getMaterial(tempSource), GlobalConf.getDouble("HeatSources." + tempSource)); } } } catch (NullPointerException ex) { RealWeather.log.log(Level.SEVERE, "NPE Error in loading 'HeatSources'. Make sure it is configured in Global.yml!"); } plugin.heatInHand.clear(); try { for (String tempSource : GlobalConf.getConfigurationSection("HeatInHand").getKeys(false)) { if (Material.getMaterial(tempSource) != null) { if (!GlobalConf.isSet("HeatInHand." + tempSource)) { GlobalConf.set("HeatInHand." + tempSource, (double) 0); } plugin.heatInHand.put(Material.getMaterial(tempSource), GlobalConf.getDouble("HeatSources." + tempSource)); } } } catch (NullPointerException ex) { RealWeather.log.log(Level.SEVERE, "NPE Error in loading 'HeatInHand'. Make sure it is configured in Global.yml!"); } } catch (Exception e) { RealWeather.log.log(Level.SEVERE, null, e); plugin.sendStackReport(e); } }
6d8b1ddf-5ba5-4b92-949e-d1fc182013f1
2
public static Dao getInstance() { if (Dao.instance == null) { if (useJpa) Dao.instance = new JpaDao(); else Dao.instance = new ListDao(); } return Dao.instance; }
44189a4f-ae8c-459c-99ee-734d67db17a6
8
public void run() { try { boolean eos = false; while (!eos) { OggPage op = OggPage.create(source); synchronized (drainLock) { pageCache.add(op); } if (!op.isBos()) { bosDone = true; } if (op.isEos()) { eos = true; } LogicalOggStreamImpl los = (LogicalOggStreamImpl) getLogicalStream(op .getStreamSerialNumber()); if (los == null) { los = new LogicalOggStreamImpl(UncachedUrlStream.this); logicalStreams.put(op.getStreamSerialNumber(), los); los.checkFormat(op); } while (pageCache.size() > PAGECACHE_SIZE) { try { Thread.sleep(200); } catch (InterruptedException ex) { } } } } catch (EndOfOggStreamException e) { // ok } catch (IOException e) { e.printStackTrace(); } }
c5cbb5b5-c5f4-419c-8c0d-46efa86a2de2
6
public int[] getClosestClusters(){ int []arr = new int[2]; arr[0]=0; arr[1]=0; double largestSimilarity = -100; for (int i = 0; i < numberOfDocuments; i++) { for (int j = 0; j < numberOfDocuments; j++) { if( i>=j || !clustersExists.get(i) || !clustersExists.get(j) ) continue; if(similairtyMatrix[i][j] > largestSimilarity){ arr[0]=i; arr[1]=j; largestSimilarity = similairtyMatrix[i][j]; } } } return arr; }
932f2b24-0198-41e0-b998-b79bb8abf8f2
2
public void startGame() { // Start the game. mode = ZombieMode.PLAYING; maxLevel = level.houseList.size() - 1; levelNum = 0; score = 0; initialScore = 0; zombieLevel = new ZombieLevel(level.houseList.get(levelNum)); house = zombieLevel.getHouse(); player = house.player; playerStart = new Point(player.getPosition().x, player.getPosition().y); player.buildMap(house); zombies = house.zombieList; assert (player != null) : "player is null"; assert (zombies != null) : "zombies is null"; assert (zombieLevel != null) : "zombieLevel is null"; frame.startGraphics(house, tileSet); graphics = frame.getGameGraphics(); graphics.update(); // Change the music. if (sounds != null) { sounds.switchMenu(); } // DEBUG if (DEBUG) { printCurrentLevel(); } }
09d52835-655e-4083-82d7-fe8cb49fc802
6
public static String slowEncrypt(String msg, String password) { // KeyGenerator keyGenerator = null; // try { // keyGenerator = KeyGenerator.getInstance("DESede"); // } catch (Throwable e1) { // e1.printStackTrace(); // } // if (keyGenerator == null) // return ""; // keyGenerator.init(168); SecretKey secretKey = null; try { secretKey = new SecretKeySpec(password.getBytes("UTF8"),"DESede"); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } Cipher cipher = null; try { cipher = Cipher.getInstance("DESede"); } catch (Throwable t) { t.printStackTrace(); } String clearText = msg; byte[] clearTextBytes = null; try { clearTextBytes = clearText.getBytes("UTF8"); } catch (Throwable e) { e.printStackTrace(); } try { cipher.init(Cipher.ENCRYPT_MODE, secretKey); } catch (Throwable e) { e.printStackTrace(); } byte[] cipherBytes = null; try { cipherBytes = cipher.doFinal(clearTextBytes); } catch (Throwable e) { e.printStackTrace(); } try { return new String(cipherBytes, "UTF8"); } catch (Throwable t) { t.printStackTrace(); } return ""; }
5d6f3fa3-b417-4706-b6c9-102426742a06
8
private void sliderock(Map m, int i, int j) { if( m.map[i+1][j+1]==Pos.EMPTY || prev!=null && (m.map[i+1][j+1]==Pos.ROCK && prev.map[i+1][j+1]==Pos.EMPTY)){ m.map[i+1][j+1]=Pos.ROCK; m.map[i][j]=Pos.EMPTY; } else if( m.map[i+1][j-1]==Pos.EMPTY || prev!=null && (m.map[i+1][j-1]==Pos.ROCK && prev.map[i+1][j-1]==Pos.EMPTY)){ m.map[i+1][j-1]=Pos.ROCK; m.map[i][j]=Pos.EMPTY; } }
2d2fa4c2-39af-4afd-ad77-28ddb810a105
8
public void move(int dGameX, int dGameY) { if (getState() == State.MOVING) return; if (!canMove(dGameX, dGameY)) return; if (dGameX == 0 && dGameY == 0) return; setNScreenX(getScreenX()); setNScreenY(getScreenY()); if (dGameX != 0) { setNScreenX(getScreenX() + dGameX * level.getFloorTile(getGameX(), getGameY()).getImageWidth()); setDirection(dGameX > 0 ? Direction.RIGHT : Direction.LEFT); setState(State.MOVING); setGameX(getGameX() + dGameX); } if (dGameY != 0) { setNScreenY(getScreenY() + dGameY * level.getFloorTile(getGameX(), getGameY()).getImageHeight()); setDirection(dGameY > 0 ? Direction.UP : Direction.DOWN); setState(State.MOVING); setGameY(getGameY() + dGameY); } }
f5b7a6e9-334e-4eeb-980e-0ab7fc4ac3da
0
public String getFname() { return fname; }
bd4f864c-df22-4534-8e00-d35a4c7591c1
9
public Props getStats(StatType tp) { if (tp == null) { tp = StatType.FULL; } Props p = new Props(); int nsp = sps.length(); if (tp == StatType.FULL || tp == StatType.PAIRTABLE) { p.put("date", (new Date()).toString()); String desc = String.format("%s v%s by %s", BurstiDAtor.NAME, BurstiDAtor.VERSION, BurstiDAtor.AUTHORS); p.put("analysis", desc); } String fn = sps.getName(); p.put("filename", fn); if (nsp == 0) { return p; } p.put("firstSp", sps.get(0)); p.put("lastSp", sps.get(nsp - 1)); double recdur = sps.get(nsp - 1) - sps.get(0); p.put("recDur", recdur); double rnddur = Settings.getInstance().getD("rndupdur"); // round up to 10 second bins, or whatever is the setting // of "rndupdur" double recdurrnd = Math.round(recdur / rnddur + 1 / (2 * rnddur)) * rnddur; p.put("recDurRndUp", recdurrnd); p.put("nSp", nsp); p.put("avgSpRate", recdur / ((double) nsp)); p.put("avgSpRateRndUp", recdurrnd / ((double) nsp)); p.put("avgSpFreq", ((double) nsp) / recdur); p.put("avgSpFreqRndUp", ((double) nsp) / recdurrnd); Vector<Burst> bs = getBursts(); int nbs = bs.size(); p.put("nBu", nbs); String nbs_or_nada="" + (nbs==0 ? "" : nbs); p.put("nBuOrNada", nbs_or_nada); if (nbs == 0) { return p; } double firstbucenter = Double.NaN; double lastbucenter = Double.NaN; if (nbs > 1) { Props pb0 = bs.get(0).getStats((String) null); // first burst Props pbX = bs.get(nbs - 1).getStats((String) null); // last burst firstbucenter = pb0.getD("center"); lastbucenter = pbX.getD("center"); } int spinbucount = 0; // spikes in burst double prevburstend = 0; // end of previous burst double interburstsum = 0; // sum of interburst intervals for (int k = 0; k < nbs; k++) { Burst b = bs.get(k); Props s = b.getStats((String) null); spinbucount += s.getI("nSp"); double burststart = s.getD("firstSp"); double burstend = s.getD("lastSp"); if (k > 0) { interburstsum += burststart - prevburstend; } prevburstend = burstend; } double pctinburst = 100 * ((double) spinbucount) / ((double) nsp); p.put("pctSpInBu", pctinburst); p.put("interBuIvl", interburstsum / (((double) nbs) - 1)); p.put("firstToLastBuCentered", lastbucenter - firstbucenter); p.put("CycleBu", (lastbucenter - firstbucenter) / (((double) nbs) - 1)); p.put("avgBuFreq", ((double) nbs) / recdur); p.put("avgBuFreqRndUp", ((double) nbs) / recdurrnd); p.put("avgBuFreq60", (60.0 * (double) nbs) / recdur); p.put("avgBuFreq60RndUp", (60.0 * (double) nbs) / recdurrnd); // compute stats across bursts final String[] statfields = { "nSp", "SpFreq", "BuDur", "interSp" }; final String[] summarytps = { "mu", "md", "std" }; Props sumstats = Props.getSummaryStats(getBurstStats(statfields), summarytps); p.append(sumstats); return p; }
f4bade96-2ae9-4298-9183-b6466ea58d11
0
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "DigestMethod") public JAXBElement<DigestMethodType> createDigestMethod(DigestMethodType value) { return new JAXBElement<DigestMethodType>(_DigestMethod_QNAME, DigestMethodType.class, null, value); }
8faa46f6-0f7e-42a9-9765-6c19b39fc14f
7
static final void method3254(int i, int i_2_, int i_3_, Class318_Sub1_Sub4 class318_sub1_sub4, Class318_Sub1_Sub4 class318_sub1_sub4_4_) { Class357 class357 = Class348_Sub46.method3321(i, i_2_, i_3_); if (class357 != null) { ((Class357) class357).aClass318_Sub1_Sub4_4406 = class318_sub1_sub4; ((Class357) class357).aClass318_Sub1_Sub4_4403 = class318_sub1_sub4_4_; int i_5_ = aa_Sub1.aSArray5191 == Class332.aSArray4142 ? 1 : 0; if (class318_sub1_sub4.method2376(-109)) { if (class318_sub1_sub4.method2377((byte) 122)) { ((Class318_Sub1) class318_sub1_sub4).aClass318_Sub1_6379 = Class250.aClass318_Sub1Array3226[i_5_]; Class250.aClass318_Sub1Array3226[i_5_] = class318_sub1_sub4; } else { ((Class318_Sub1) class318_sub1_sub4).aClass318_Sub1_6379 = Node.aClass318_Sub1Array4293[i_5_]; Node.aClass318_Sub1Array4293[i_5_] = class318_sub1_sub4; Class348_Sub16_Sub2.heightLevelChanged = true; } } else { ((Class318_Sub1) class318_sub1_sub4).aClass318_Sub1_6379 = Class115.aClass318_Sub1Array1754[i_5_]; Class115.aClass318_Sub1Array1754[i_5_] = class318_sub1_sub4; } if (class318_sub1_sub4_4_ != null) { if (class318_sub1_sub4_4_.method2376(-118)) { if (class318_sub1_sub4_4_.method2377((byte) 122)) { ((Class318_Sub1) class318_sub1_sub4_4_) .aClass318_Sub1_6379 = Class250.aClass318_Sub1Array3226[i_5_]; Class250.aClass318_Sub1Array3226[i_5_] = class318_sub1_sub4_4_; } else { ((Class318_Sub1) class318_sub1_sub4_4_) .aClass318_Sub1_6379 = Node.aClass318_Sub1Array4293[i_5_]; Node.aClass318_Sub1Array4293[i_5_] = class318_sub1_sub4_4_; Class348_Sub16_Sub2.heightLevelChanged = true; } } else { ((Class318_Sub1) class318_sub1_sub4_4_).aClass318_Sub1_6379 = Class115.aClass318_Sub1Array1754[i_5_]; Class115.aClass318_Sub1Array1754[i_5_] = class318_sub1_sub4_4_; } } } }
231176af-b35d-49df-8310-f5e9982c07c1
2
@Override public List<Tour> load(Criteria criteria, GenericLoadQuery loadGeneric, Connection conn) throws DaoQueryException { int pageSize = 10; List params = new ArrayList<>(); StringBuilder sb = new StringBuilder(); StringBuilder sbw = new StringBuilder(); Boolean f1 = formQueryTour(criteria, params, sb, sbw); Boolean f2 = formQueryDirect(criteria, params, sb, sbw); Boolean f3 = formQueryCountry(criteria, params, sb, sbw, f2); Boolean f4 = formQueryCity(criteria, params, sb, sbw, f2|f3); Boolean f5 = formQueryStay(criteria, params, sb, sbw, f2|f3|f4); Boolean f6 = formQueryHotel(criteria, params, sb, sbw, f2|f3|f4|f5, f5); if (f1|f2|f3|f4|f5|f6) { sb.append(sbw); } sb.append(LOAD_QUERY_TOUR_GROUP); try { return loadGeneric.sendQuery(sb.toString(), params.toArray(), pageSize, conn, (ResultSet rs, int rowNum) -> { Tour bean = new Tour(); bean.setIdTour(rs.getInt(DB_TOUR_ID_TOUR)); bean.setDepartDate(rs.getDate(DB_TOUR_DATE)); bean.setDaysCount(rs.getInt(DB_TOUR_DAYS_COUNT)); bean.setPrice(rs.getFloat(DB_TOUR_PRICE)); bean.setDiscount(rs.getInt(DB_TOUR_DISCOUNT)); bean.setTotalSeats(rs.getInt(DB_TOUR_TOTAL_SEATS)); bean.setFreeSeats(rs.getInt(DB_TOUR_FREE_SEATS)); bean.setDirection(new Direction(rs.getInt(DB_TOUR_ID_DIRECTION))); bean.setStatus(rs.getShort(DB_TOUR_STATUS)); return bean; }); } catch (DaoException ex) { throw new DaoQueryException(ERR_SEARCH_TOUR_LOAD, ex); } }
57941d94-2d62-48d8-83d6-411965ac70e3
9
private <T, E extends LangElem> void addAnnotatedClass(Class<T> clazz) throws MappingException { AnyMapping<T, ?> mapping; if (clazz.isAnnotationPresent(DefAtom.class)) { mapping = createAtomMapping(clazz); } else if (clazz.isAnnotationPresent(DefTerm.class)) { mapping = createTermMapping(clazz); } else if (clazz.isAnnotationPresent(DefConstant.class)) { mapping = createConstantMapping(clazz); } else { return; //no inner resolving. assume explicit mapping given } if (mapping instanceof InputMapping) { addInputMapping(clazz, (InputMapping<T, E>) mapping); } if (mapping instanceof OutputMapping) { addOutputMapping(clazz, (OutputMapping<T, E>) mapping); } Collection<Class<?>> innerClasses = getAnnotatedInnerClasses(clazz); for (Class<?> innerClass : innerClasses) { this.add(innerClass); } }
a223f274-80da-409b-9856-c9c720c001f6
8
@Override public Vector solveLinearEquationsSystem(Matrix equationMatrix, Vector results) { isValid(equationMatrix); if (equationMatrix.getRows() != equationMatrix.getColumns()) { throw new MathArithmeticException("Cannot solve linear equations system for nonsquare matrix."); } if (equationMatrix.getRows() != results.getSize()) { throw new DimensionMismatchException("Cannot solve linear equations system: dimension mismatch."); } if (rank(equationMatrix) != equationMatrix.getRows()) { throw new MathArithmeticException("Cannot solve linear equations system: linearly dependent rows."); } //prepare equation matrix Matrix eqMat = new Matrix(equationMatrix.getRows(), equationMatrix.getColumns() + 1); for (int x = 0; x < equationMatrix.getRows(); x++) { for (int y = 0; y < equationMatrix.getColumns(); y++) { eqMat.setElement(y, x, equationMatrix.getElement(x, y)); } eqMat.setElement(x, equationMatrix.getColumns(), results.getElement(x)); } eqMat = gauss(eqMat); //set result vector from values prepared in eqMat Vector result = new Vector(equationMatrix.getColumns()); for (int x = eqMat.getColumns() - 2; x >= 0; x--) { for (int y = eqMat.getColumns() - 2; y >= x; y--) { if (y == x) { result.setElement(x, galoisField.divide(eqMat.getElement(x, eqMat.getColumns() - 1), eqMat.getElement(x, x))); } else { eqMat.setElement(x, eqMat.getColumns() - 1, galoisField.subtract(eqMat.getElement(x, eqMat.getColumns() - 1), galoisField.multiply(eqMat.getElement(x, y), result.getElement(y)))); } } } return result; }
5ee204e3-75e9-4208-9cda-65cb280f9a0a
3
public EncryptableObject decrypt(Key key) throws Exception{ String Algrithem; if(key instanceof PrivateKey){Algrithem = "RSA";} else{Algrithem = "AES";} if(encrypted == null) return null; Cipher decrypt = Cipher.getInstance(Algrithem); decrypt.init(Cipher.DECRYPT_MODE, key); ByteArrayInputStream bais = new ByteArrayInputStream(encrypted); CipherInputStream cin=new CipherInputStream(bais, decrypt); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buf = new byte[2048]; int read=0; while((read=cin.read(buf))!=-1) {//reading encrypted data out.write(buf,0,read); //writing decrypted data out.flush(); } out.close(); cin.close(); bais.close(); return EncryptableObject.fromByteArray(out.toByteArray()); }
c7068640-84bc-4729-a43b-ce1ef902355b
9
public SingleGuide(DependencyParserConfig configuration, GuideHistory history, GuideMode guideMode) throws MaltChainedException { this.configuration = configuration; this.guideMode = guideMode; final FeatureEngine system = new FeatureEngine(); system.load("/appdata/features/ParserFeatureSystem.xml"); system.load(PluginLoader.instance()); featureModelManager = new FeatureModelManager(system, getConfiguration().getConfigurationDir()); // initialize history this.history = history; Class<?> kBestListClass = null; int kBestSize = 1; if (guideMode == ClassifierGuide.GuideMode.CLASSIFY) { kBestListClass = (Class<?>)getConfiguration().getOptionValue("guide", "kbest_type"); kBestSize = ((Integer)getConfiguration().getOptionValue("guide", "kbest")).intValue(); } history.setKBestListClass(kBestListClass); history.setKBestSize(kBestSize); history.setSeparator(getConfiguration().getOptionValue("guide", "classitem_separator").toString()); // initialize feature model String featureModelFileName = getConfiguration().getOptionValue("guide", "features").toString().trim(); if (featureModelFileName.endsWith(".par")) { String markingStrategy = getConfiguration().getOptionValue("pproj", "marking_strategy").toString().trim(); String coveredRoot = getConfiguration().getOptionValue("pproj", "covered_root").toString().trim(); featureModelManager.loadParSpecification(featureModelFileName, markingStrategy, coveredRoot); } else { featureModelManager.loadSpecification(featureModelFileName); } if (getConfiguration().getConfigLogger().isInfoEnabled()) { getConfiguration().getConfigLogger().info(" Feature model : " + featureModelFileName+"\n"); if (getGuideMode() == ClassifierGuide.GuideMode.BATCH) { getConfiguration().getConfigLogger().info(" Learner : " + getConfiguration().getOptionValueString("guide", "learner").toString()+"\n"); } else { getConfiguration().getConfigLogger().info(" Classifier : " + getConfiguration().getOptionValueString("guide", "learner")+"\n"); } } featureModel = getFeatureModelManager().getFeatureModel(getConfiguration().getOptionValue("guide", "features").toString(), 0, getConfiguration().getRegistry()); if (getGuideMode() == ClassifierGuide.GuideMode.BATCH && getConfiguration().getConfigurationDir().getInfoFileWriter() != null) { try { getConfiguration().getConfigurationDir().getInfoFileWriter().write("\nFEATURE MODEL\n"); getConfiguration().getConfigurationDir().getInfoFileWriter().write(featureModel.toString()); getConfiguration().getConfigurationDir().getInfoFileWriter().flush(); } catch (IOException e) { throw new GuideException("Could not write feature model specification to configuration information file. ", e); } } }
bee89a2c-52d5-4a72-b17f-3432c042269c
0
@Override public void execute() { }
474cdbaa-b83e-44b2-9cad-3bf306990b6a
8
public void run() { checkTimestamp(); if (RealTimeOrdersSingleton.instance.getLoopStatus()) { ServiceArgs loginArgs = new ServiceArgs(); loginArgs.setUsername(splunk_username); loginArgs.setPassword(splunk_password); loginArgs.setHost(splunk_hostname); loginArgs.setPort(splunk_serviceport); try { Service service = Service.connect(loginArgs); String outputMode = splunk_output_mode; Args queryArgs = new Args(); queryArgs.put("earliest_time", splunk_start); queryArgs.put("latest_time", splunk_end); queryArgs.put("output_mode", outputMode); queryArgs.put("count", 0); log.debug("Executing Search Query: " + splunk_search_query); InputStream stream = service.oneshotSearch(splunk_search_query, queryArgs); ArrayList<OrderObject> temp_order_object_array = new ArrayList<OrderObject>(); // 2013-09-22T15:37:15.000-04:00 SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS"); try { ResultsReaderXml resultsReader = new ResultsReaderXml( stream); HashMap<String, String> map; while ((map = resultsReader.getNextEvent()) != null) { GeocodeAbstractor geo = new GeocodeAbstractor(); GeocodedPostalCode gpc = new GeocodedPostalCode(); Boolean pass = false; String current_timestamp = map.get("_time"); current_timestamp = current_timestamp.substring(0, current_timestamp.length() - 6); Date whatever = dateFormat.parse(current_timestamp); Calendar startthis = Calendar.getInstance(); startthis.setTime(whatever); current_timestamp = Long.toString(startthis .getTimeInMillis()); String full_zip = map.get(postalcode_key); if (full_zip != null && full_zip.length() >= 5 && !full_zip.contains(postalcode_exclusion)) { String short_zip = full_zip.substring(0, 5); pass = true; gpc = geo.geocode(short_zip); } if (pass) temp_order_object_array.add(new OrderObject(gpc .getpostalCode(), gpc.getlatitude(), gpc .getlongitude(), current_timestamp)); } resultsReader.close(); RealTimeOrdersSingleton.instance .regenerateArray(temp_order_object_array); } catch (Exception e) { log.error(e); e.printStackTrace(); } } catch (Exception e) { log.error(e); } } }
e7d1a998-4b37-4e92-88e7-ae376140332e
5
public void aff_plateau(List<Coup> coups) { String[][] tab = new String[plateau.getLigne()][plateau.getColonne()]; String newLine = System.getProperty("line.separator"); for (int i = 0; i < plateau.getLigne() ; i++) { for (int j = 0; j < plateau.getColonne() ; j++) { tab[i][j] = "*"; } } for (Coup cur_coup : coups) { int ligne = cur_coup.getCoordx(); int colonne = cur_coup.getCoordy(); String sym = cur_coup.getJoueur().getSymbole(); tab[ligne-1][colonne-1] = sym ; } for (int i = 0; i < plateau.getLigne() ; i++) { for (int j = 0; j < plateau.getColonne() ; j++) { System.out.print(" "+tab[i][j]+" "); } System.out.println(newLine); } }
d9b68cbb-a5bb-407f-8186-290a4fce9d31
6
final void method415(int i, int j, int k) { if (k != 0) { int l = anIntArray2815[k]; int k1 = anIntArray2807[k]; for (int j2 = 0; j2 < anInt2818; j2++) { int i3 = yPositions[j2] * l + xPositions[j2] * k1 >> 16; yPositions[j2] = yPositions[j2] * k1 - xPositions[j2] * l >> 16; xPositions[j2] = i3; } } if (i != 0) { int i1 = anIntArray2815[i]; int l1 = anIntArray2807[i]; for (int k2 = 0; k2 < anInt2818; k2++) { int j3 = yPositions[k2] * l1 - zPositions[k2] * i1 >> 16; zPositions[k2] = yPositions[k2] * i1 + zPositions[k2] * l1 >> 16; yPositions[k2] = j3; } } if (j != 0) { int j1 = anIntArray2815[j]; int i2 = anIntArray2807[j]; for (int l2 = 0; l2 < anInt2818; l2++) { int k3 = zPositions[l2] * j1 + xPositions[l2] * i2 >> 16; zPositions[l2] = zPositions[l2] * i2 - xPositions[l2] * j1 >> 16; xPositions[l2] = k3; } } }
e2401bff-7ba0-4966-a361-06d3a02e40e3
1
public static void main(String[] args) throws IOException { // AuctionService as = new AuctionService(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try( Socket client = new Socket("localhost", 10000); BufferedReader file = new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter pw = new PrintWriter(new OutputStreamWriter(client.getOutputStream()))){ String userInput = br.readLine(); pw.write(userInput); client.close(); } catch (IOException e) { e.printStackTrace(); } }
5c0c4389-fd58-4400-8f7f-771d08ac95a9
8
@Override public List<Administrador> Buscar(Administrador obj) { // Corpo da consulta String consulta = "select f from Administrador f WHERE f.ativo = 1 AND f.id != 0 "; // A parte where da consulta String filtro = " "; // Verifica campo por campo os valores que serão filtrados if (obj != null) { //Nome if (obj.getNome() != null && obj.getNome().length() > 0) { filtro += " AND f.nome like '%"+obj.getNome()+"%' "; } //Id if (obj.getId() != null && obj.getId() > 0) { filtro += " AND f.id like '%"+obj.getId()+"%'"; } //Cpf if (obj.getCpf() != null && obj.getCpf().length() > 0) { filtro += " AND f.cpf like '%"+obj.getCpf()+"%'"; } // Se houver filtros, coloca o "where" na consulta if (filtro.length() > 0) { consulta += filtro; } } // Cria a consulta no JPA Query query = manager.createQuery(consulta); // Executa a consulta return query.getResultList(); }
6ff43dbf-d054-4b04-82f5-88b8abba39b2
2
private void defineVariables() { spawnWorld = Bukkit.getWorld(getConfig().getString("SBB World")); for (String s : getConfig().getConfigurationSection("Arenas").getKeys(false)) { try { Integer.valueOf(s); } catch (Exception e) { continue; } String[] redSpawn = getConfig().getString("Arenas." + s + ".RedSpawn").split(","); String[] blueSpawn = getConfig().getString("Arenas." + s + ".BlueSpawn").split(","); int redSpawnX = Integer.valueOf(redSpawn[0]), redSpawnY = Integer.valueOf(redSpawn[1]), redSpawnZ = Integer.valueOf(redSpawn[2]); int blueSpawnX = Integer.valueOf(blueSpawn[0]), blueSpawnY = Integer.valueOf(blueSpawn[1]), blueSpawnZ = Integer.valueOf(blueSpawn[2]); arenaList.add(new Arena(getConfig().getInt("Arenas." + s + ".minX"), getConfig().getInt("Arenas." + s + ".maxX"), getConfig().getInt("Arenas." + s + ".minZ"), getConfig().getInt("Arenas." + s + ".maxZ"), new Location(Bukkit.getWorld(getConfig().getString("SBB World")), redSpawnX, redSpawnY, redSpawnZ), new Location(Bukkit.getWorld(getConfig().getString("SBB World")), blueSpawnX, blueSpawnY, blueSpawnZ), Integer.valueOf(s))); } }
ecb6d069-abba-424f-913d-fba0189b2650
9
public void SetDest(int antiPredict) { String type=this.instruction.type; if(type.equals("LW")|| type.equals("ADD")|| type.equals("NAND")|| type.equals("ADDI")|| type.equals("MUL")|| type.equals("DIV")|| type.equals("JALR")) this.dest=this.instruction.Rd; if(type.equals("SW")) this.dest=-1; if(type.equals("BEQ")) this.dest=antiPredict; }
acc61a68-78a0-43d0-b04e-b5bbf299c330
7
public static HLinkedList getSortedLinkedList(HLinkedList list){ /* If the list is null, return a null list. */ if (list.getHeadNode() == null) { return new HLinkedList(); } /* If the list root is the only node, return the same list. */ if (list.length() == 1){ return new HLinkedList(list.getHeadNode()); } /* An array of the nodes of the unsorted list for sorting. */ HTreeNode[] nodeArray = new HTreeNode[list.length()]; /* Reference to the head node of the unsorted list for iteration. */ HTreeNode hNode = list.getHeadNode(); /* The linked list to be sorted by character frequency. */ HLinkedList sortedList = new HLinkedList(); /* Copies the nodes of the unsorted list into an array for comparison. */ for (int i = 0; i < list.length(); i++){ nodeArray[i] = hNode; hNode = hNode.next(); } /* Sorts the nodes in ascending order based on their frequency. */ Arrays.sort(nodeArray); /* * Checks for and eliminates any duplicates from the sorted node array by checking next node. * Not necessarily needed, but can be helpful if reading of string file misses duplicates. */ for (int i = 0; i < nodeArray.length - 1; i++){ /* If node is equal to next node, move nodes back in array. */ if(nodeArray[i].equals(nodeArray[i+1])) { /* Moves the nodes back by one in the index. */ for (int j = i; j + 1 < nodeArray.length; j++) { nodeArray[j] = nodeArray[j + 1]; } } } /* Inserts the sorted nodes into the list, in ascending order of their frequencies. */ for (int i = 0; i < nodeArray.length; i++){ sortedList.insertAtEnd(nodeArray[i]); } return sortedList; }
f310e1d3-fa86-448d-9d44-4aa90595f316
8
public void stratify(int numFolds) { if (numFolds <= 0) { throw new IllegalArgumentException("Number of folds must be greater than 1"); } if (m_ClassIndex < 0) { throw new UnassignedClassException("Class index is negative (not set)!"); } if (classAttribute().isNominal()) { // sort by class int index = 1; while (index < numInstances()) { Instance instance1 = instance(index - 1); for (int j = index; j < numInstances(); j++) { Instance instance2 = instance(j); if ((instance1.classValue() == instance2.classValue()) || (instance1.classIsMissing() && instance2.classIsMissing())) { swap(index,j); index++; } } index++; } stratStep(numFolds); } }
567fdebd-f284-47cb-a0d9-625a4036aacf
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof User)) { return false; } User other = (User) object; if ((this.userid == null && other.userid != null) || (this.userid != null && !this.userid.equals(other.userid))) { return false; } return true; }
3268bb93-44fb-45f7-b44f-655f8d553017
3
private void put(final Item i) { if (index + typeCount > threshold) { int ll = items.length; int nl = ll * 2 + 1; Item[] newItems = new Item[nl]; for (int l = ll - 1; l >= 0; --l) { Item j = items[l]; while (j != null) { int index = j.hashCode % newItems.length; Item k = j.next; j.next = newItems[index]; newItems[index] = j; j = k; } } items = newItems; threshold = (int) (nl * 0.75); } int index = i.hashCode % items.length; i.next = items[index]; items[index] = i; }
9a57dbba-5cec-4aae-aae7-efc9e1af7ec6
2
public static Couleur parseCouleur(char codeCouleur) { for (Couleur couleur : Couleur.values()) if (couleur.colorChar == codeCouleur) return couleur; return null; }
04a93bb2-cec5-4a62-bd0d-05da90715e1b
8
private void enableThisDrag() { final Delta dragDelta = new Delta(); thisShape.getEllipse().setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { // record a delta distance for the drag and drop operation. String curAction = MainController.preferences.get("action").getStringPreference(); if(curAction.equals("edit")) { dragDelta.x = thisShape.getEllipse().getCenterX() - mouseEvent.getX(); dragDelta.y = thisShape.getEllipse().getCenterY() - mouseEvent.getY(); ellipse.getScene().setCursor(Cursor.MOVE); } } }); thisShape.getEllipse().setOnMouseReleased(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { String curAction = MainController.preferences.get("action").getStringPreference(); if(curAction.equals("edit")) { ellipse.getScene().setCursor(Cursor.HAND); } } }); thisShape.getEllipse().setOnMouseDragged(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { String curAction = MainController.preferences.get("action").getStringPreference(); double finalX, finalY; if(curAction.equals("edit")) { finalX = ((mouseEvent.getX()+dragDelta.x) ); finalY = ((mouseEvent.getY()+dragDelta.y) ); if(thisShape.getParent().getParent() != null) { moveComponent(thisShape.getParent(), finalX, finalY); } else { moveComponent(thisShape, finalX, finalY); } //thisShape.getEllipse().setTranslateX(30); } } }); thisShape.getEllipse().setOnMouseEntered(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (!mouseEvent.isPrimaryButtonDown()) { String curAction = MainController.preferences.get("action").getStringPreference(); if(curAction.equals("edit")) { thisShape.getEllipse().getScene().setCursor(Cursor.HAND); } } } }); thisShape.getEllipse().setOnMouseExited(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (!mouseEvent.isPrimaryButtonDown()) { String curAction = MainController.preferences.get("action").getStringPreference(); if(curAction.equals("edit")) { thisShape.getEllipse().getScene().setCursor(Cursor.DEFAULT); } } } }); }
724952e6-f56d-4a14-8c67-e14dd9cb03c0
9
public void run(int i) { while(sim40.memory[i] != -1) { switch(sim40.memory[i]) { /* stop */ case 0: return; /* print, printb, printch */ case 1: case 2: case 3: this.stdStream.getOutput().add(result(i)); ++i; break; default: /* jump, comp, xcomp, ycomp, jineg, jipos, jizero, jicarry */ if(sim40.memory[i] >= 19 && sim40.memory[i] <= 26) i = compareExecute(i); else if(sim40.memory[i] >= 4 && sim40.memory[i] <= 9) i = unaryExecute(i); else i = binaryExecute(i); } checkResetAllRegsAndFlags(); sim40.updateViewVars(); sim40.memory[Simulator.PROGRAM_COUNTER] = i; } }
1554ec6b-dc82-4afd-a7c0-680871dcaeec
4
public void init() throws IOException{ if(basicInfos == null){ try { initBasicInfoFromInternet(); } catch (JsonSyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } initBasicInfoFromFile(); } }
3ae066ea-b7fc-4439-b065-4b6b6e53a843
2
private void handleMessage() { AbstractTab tab = InputHandler.getActiveTab(); if (tab == null) { InputHandler.showNotConnectedError(); return; } else if (tab instanceof ServerTab) { tab.appendError("Nelze odeslat zprávu. Toto není chatovací místnost!"); return; } String message = getText(); String target = tab.getTabName(); InputHandler.handlePrivMessage(target + " " + message); }
d65db709-ace7-4e95-8205-33503fd625a7
5
public Solution(Environment env) { environment = env; assignmentMap = new TreeMap<String, Assign>(environment.getFixedAssignments()); numLectures = environment.getLectureList().size(); TreeSet<Session> sessionList = environment.getSessionList(); for (Session session : sessionList) { currentRoomCapacities.put(session, new Long(session.getRoom().getCapacity())); lecturesInSession.put(session, new TreeSet<Lecture>()); } for (Course course : environment.getCourseList()) { sessionsOfCourses.put(course, null); } complete = numLectures == assignmentMap.size() ? true : false; // penalty = calculatePenalty(); // Our inital list of unassigned lectures will contain every lecture unassignedLectures = new TreeSet<Lecture>(environment.getLectureList()); // Now we'll remove the lectures which are assigned for (Assign assign : assignmentMap.values()) { Lecture lecture = assign.getLecture(); if (unassignedLectures.contains(lecture)) unassignedLectures.remove(lecture); Session session = assign.getSession(); addLectureToSession(session,lecture); decreaseSessionCapacity(session,lecture); } }
ed961ff3-2721-4e88-a54e-0eff97d9f0eb
4
@Override public boolean containsShort(String name) { JOSObject<? , ?> raw = this.getObject(name); if(raw == null) return false; if(raw.getName().equalsIgnoreCase(SHORT_NAME)) return true; return false; }
7f5254b6-23c3-4944-b6f4-4f2cb07b8dd1
9
@SuppressWarnings("unchecked") public void updateLocalWords() { RestWrapper restRep = new RestWrapper(); Map<String, Serializable> fileSnapshot = restRep.getFileSnapshot(); String requestPrefix = (String) fileSnapshot.get("request_prefix"); Map<String, String> newFileMap = (Map<String, String>) fileSnapshot .get("data"); String localSnapshotURI = ML.config.get(ML.CACHE_DIR) + File.separator + ML.config.get(ML.SERVICE_NAME) + "_" + ML.config.get(ML.TARGET_LANG) + SNAPSHOT_FILE_SUFFIX; File localSnapshotFile = new File(localSnapshotURI); if (localSnapshotFile.exists()) { String data = getFileContent(localSnapshotURI); Map<String, Object> fileMap = null; try { fileMap = JSONUtil.toMap(data.toString()); } catch (JSONException e) { MLLogger.getLogger().severe( "Cannot turn local file string into map"); MLLogger.getLogger().severe(e.getLocalizedMessage()); return; } for (String filename : newFileMap.keySet()) { if (filename.endsWith(ML.WORD_FILE_SUFFIX)) { if (fileMap.containsKey(filename)) { if (!fileMap.get(filename).equals( newFileMap.get(filename))) { String filecotent = restRep.get(requestPrefix + "/" + filename + "?md5=" + newFileMap.get(filename), null); writeFileToLocalDir( ML.config.get(ML.CACHE_DIR) + File.separator + ML.config.get(ML.SERVICE_NAME) + "_" + ML.config.get(ML.TARGET_LANG) + "_" + filename, filecotent); } } else { String filecotent = restRep.get(requestPrefix + "/" + filename, null); writeFileToLocalDir( ML.config.get(ML.CACHE_DIR) + File.separator + ML.config.get(ML.SERVICE_NAME) + "_" + ML.config.get(ML.TARGET_LANG) + "_" + filename, filecotent); } } } } else { for (String filename : newFileMap.keySet()) { if (filename.endsWith(ML.WORD_FILE_SUFFIX)) { String filecotent = restRep.get(requestPrefix + "/" + filename, null); writeFileToLocalDir(ML.config.get(ML.CACHE_DIR) + File.separator + ML.config.get(ML.SERVICE_NAME) + "_" + ML.config.get(ML.TARGET_LANG) + "_" + filename, filecotent); } } } try { writeFileToLocalDir(ML.config.get(ML.CACHE_DIR) + File.separator + ML.config.get(ML.SERVICE_NAME) + "_" + ML.config.get(ML.TARGET_LANG) + SNAPSHOT_FILE_SUFFIX,JSONUtil.toJSON(newFileMap)); } catch (JSONException e) { MLLogger.getLogger().severe(e.getLocalizedMessage()); } }
3ea00f55-53fa-45d5-aff6-abaf7d4db364
8
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { if(!mob.isInCombat()) { mob.tell(L("You must be in combat to do this!")); return false; } if(mob.rangeToTarget()>0) { mob.tell(L("You can't do that from this range.")); return false; } final MOB target=this.getTarget(mob,commands,givenTarget); if(target==null) return false; if(!super.invoke(mob,commands,givenTarget,auto,asLevel)) return false; final boolean success=proficiencyCheck(mob,-(target.charStats().getStat(CharStats.STAT_DEXTERITY)),auto); if(success) { final CMMsg msg=CMClass.getMsg(mob,target,this,CMMsg.MSK_MALICIOUS_MOVE|CMMsg.TYP_JUSTICE|(auto?CMMsg.MASK_ALWAYS:0),auto?"":L("^F^<FIGHT^><S-NAME> feint(s) at <T-NAMESELF>!^</FIGHT^>^?")); CMLib.color().fixSourceFightColor(msg); if(mob.location().okMessage(mob,msg)) { mob.location().send(mob,msg); done=false; maliciousAffect(mob,target,asLevel,2,-1); } } else return maliciousFizzle(mob,target,L("<S-NAME> feint(s) at <T-NAMESELF>, but <T-HE-SHE> do(es)n't buy it.")); return success; }
7f863502-0bfe-4b28-b5b9-41a42c09709f
2
private void dragColumnDivider(int x) { int old = mDividerDrag.getWidth(); if (x <= mColumnStart + DIVIDER_HIT_SLOP * 2) { x = mColumnStart + DIVIDER_HIT_SLOP * 2 + 1; } x -= mColumnStart; if (old != x) { adjustColumnWidth(mDividerDrag, x); } }
bd133e9e-74e5-486f-9aa1-d7ea05e81af6
8
public boolean equals( Object other ) { if ( ! ( other instanceof TObjectShortMap ) ) { return false; } TObjectShortMap that = ( TObjectShortMap ) other; if ( that.size() != this.size() ) { return false; } try { TObjectShortIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); Object key = iter.key(); short value = iter.value(); if ( value == no_entry_value ) { if ( !( that.get( key ) == that.getNoEntryValue() && that.containsKey( key ) ) ) { return false; } } else { if ( value != that.get( key ) ) { return false; } } } } catch ( ClassCastException ex ) { // unused. } return true; }
42b8a93f-fe06-4edd-b54a-5fd5ab116115
6
@Override public String getDescription(Hero hero) { int height = (int) SkillConfigManager.getUseSetting(hero, this, "Height", 3, false); int width = (int) SkillConfigManager.getUseSetting(hero, this, "width", 2, false); int maxDist = (int) SkillConfigManager.getUseSetting(hero, this, Setting.MAX_DISTANCE, 5, false); String type = SkillConfigManager.getUseSetting(hero, this, "BlockType", "STONE"); String base = String.format("Makes a wall of %s which is %s wide by %s high up to %s blocks away (Targetted)", type, width, height, maxDist); StringBuilder description = new StringBuilder( base ); //Additional descriptive-ness of skill settings int initCD = SkillConfigManager.getUseSetting(hero, this, Setting.COOLDOWN.node(), 0, false); int redCD = SkillConfigManager.getUseSetting(hero, this, Setting.COOLDOWN_REDUCE.node(), 0, false) * hero.getSkillLevel(this); int CD = (initCD - redCD) / 1000; if (CD > 0) { description.append( " CD:"+ CD + "s" ); } int initM = SkillConfigManager.getUseSetting(hero, this, Setting.MANA.node(), 0, false); int redM = SkillConfigManager.getUseSetting(hero, this, Setting.MANA_REDUCE.node(), 0, false)* hero.getSkillLevel(this); int manaUse = initM - redM; if (manaUse > 0) { description.append(" M:"+manaUse); } int initHP = SkillConfigManager.getUseSetting(hero, this, Setting.HEALTH_COST, 0, false); int redHP = SkillConfigManager.getUseSetting(hero, this, Setting.HEALTH_COST_REDUCE, 0, true) * hero.getSkillLevel(this); int HPCost = initHP - redHP; if (HPCost > 0) { description.append(" HP:"+HPCost); } int initF = SkillConfigManager.getUseSetting(hero, this, Setting.STAMINA.node(), 0, false); int redF = SkillConfigManager.getUseSetting(hero, this, Setting.STAMINA_REDUCE.node(), 0, false) * hero.getSkillLevel(this); int foodCost = initF - redF; if (foodCost > 0) { description.append(" FP:"+foodCost); } int delay = SkillConfigManager.getUseSetting(hero, this, Setting.DELAY.node(), 0, false) / 1000; if (delay > 0) { description.append(" W:"+delay); } int exp = SkillConfigManager.getUseSetting(hero, this, Setting.EXP.node(), 0, false); if (exp > 0) { description.append(" XP:"+exp); } return description.toString(); }
56b59438-c667-4cbb-bb6e-95645162a358
6
public synchronized int hashCode() { if (__hashCodeCalc) { return 0; } __hashCodeCalc = true; int _hashCode = super.hashCode(); if (getAirlineName() != null) { _hashCode += getAirlineName().hashCode(); } if (getEmployeeId() != null) { _hashCode += getEmployeeId().hashCode(); } if (getHireDate() != null) { _hashCode += getHireDate().hashCode(); } if (getJobDesc() != null) { _hashCode += getJobDesc().hashCode(); } if (getPosition() != null) { _hashCode += getPosition().hashCode(); } __hashCodeCalc = false; return _hashCode; }
c14c99df-0345-4c61-a72b-d29b37114500
9
private void jComboBox2actionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2actionPerformed // TODO add your handling code here: if (this.jComboBox2.getSelectedIndex() == 0) { return; } int ptr = this.jComboBox2.getSelectedIndex() - 1; String str = "The select event --- "+ "code index = "+ptr+"\n"+this.getCodeDispt(ptr); double[] tempGamma=new double[this.CRSM.gamma.length]; System.arraycopy(this.CRSM.gamma, 0, tempGamma, 0, this.CRSM.gamma.length); CRSM.gamma=new double[]{(double) 0, (double)1}; double[][] inPattern=new double[this.CRSM.numSpace][]; for (int k=0;k<CRSM.numSpace;k++) { inPattern[k] = new double [CRSM.len[k]]; } System.arraycopy(resetStatus(inPattern[0]), 0, inPattern[0], 0, inPattern[0].length); System.arraycopy(resetStatus(inPattern[1]), 0, inPattern[1], 0, inPattern[1].length); inPattern[1][ptr*2]=1; inPattern[1][ptr*2+1]=0; System.out.println("Test for previuos event patter in:"); String test_str="IF current siuation is : "; int[] preCode=this.getEventIdx(inPattern[0]); int[] curCode=this.getEventIdx(inPattern[1]); for(int i=0;i<curCode.length;i++){ test_str+=curCode[i]+"\t"; } test_str+="THEN previous siuation is : "; for(int i=0;i<preCode.length;i++){ test_str+=preCode[i]+"\t"; } System.out.println(test_str); int[] winners = this.CRSM.findWinnerK(inPattern, CRSM.FUZZYART,0,0.99); str+="**************************\n"; str+="*Previous event generated*\n"; str+="**************************\n"; if(winners==null){ System.out.println("Unsuccessful retrieve!!!!"); this.jTextArea1.setText(str+"N.A."); return; } for(int i=0;i<winners.length;i++){ if(winners[winners.length-1]==this.CRSM.numCode-1){ System.out.println("enters!!"); int[] rewinners=new int[winners.length-1]; System.arraycopy(winners, 0, rewinners, 0, rewinners.length); winners=new int[winners.length-1]; winners=rewinners; } else{ System.out.println("winner @ code "+winners[i]+": pattern consistent? "+this.isSamePattern(inPattern[1], CRSM.weight[winners[i]][1])); winners[i]=this.getEventIdx(CRSM.weight[winners[i]][0])[0]; } } for(int i=0;i<winners.length;i++){ if(winners[i]<this.episodic.eventLearner.numCode){ str +=i+ ". "+ "code index = "+winners[i]+"\n"+this.getCodeDispt(winners[i])+"\n"; } } this.jTextArea1.setText(str); System.arraycopy(tempGamma, 0, this.CRSM.gamma, 0, this.CRSM.gamma.length); }//GEN-LAST:event_jComboBox2actionPerformed
16cae002-7da8-4578-bea4-e81f0d1ab4a6
8
/* */ public void start() { /* 74 */ if (this.applet != null) { /* 75 */ this.applet.start(); /* 76 */ return; /* */ } /* 78 */ if (this.gameUpdaterStarted) return; /* */ /* 80 */ Thread t = new Thread() { /* */ public void run() { /* 82 */ Launcher.this.gameUpdater.run(); /* */ try { /* 84 */ if (!Launcher.this.gameUpdater.fatalError) /* 85 */ Launcher.this.replace(Launcher.this.gameUpdater.createApplet()); /* */ } /* */ catch (ClassNotFoundException e) /* */ { /* 89 */ e.printStackTrace(); /* */ } catch (InstantiationException e) { /* 91 */ e.printStackTrace(); /* */ } catch (IllegalAccessException e) { /* 93 */ e.printStackTrace(); /* */ } /* */ } /* */ }; /* 97 */ t.setDaemon(true); /* 98 */ t.start(); /* */ /* 100 */ t = new Thread() { /* */ public void run() { /* 102 */ while (Launcher.this.applet == null) { /* 103 */ Launcher.this.repaint(); /* */ try { /* 105 */ Thread.sleep(10L); /* */ } catch (InterruptedException e) { /* 107 */ e.printStackTrace(); /* */ } /* */ } /* */ } /* */ }; /* 112 */ t.setDaemon(true); /* 113 */ t.start(); /* */ /* 115 */ this.gameUpdaterStarted = true; /* */ }
71ded6a7-b240-4fb3-af49-81dc8a66caac
1
public static Object trapWrite(Object[] args, String name) { Metalevel base = (Metalevel)args[0]; if (base == null) _classobject.trapFieldWrite(name, args[1]); else base._getMetaobject().trapFieldWrite(name, args[1]); return null; }
2a2775ae-a160-4d26-ad2c-801e8e232a9a
8
public void combine(String IP_PORT, String apiKey){ DBService dbService = new DBService(); HashMap data = null; FileService fileService = new FileService(); if(this.link.contains("haitao.smzdm")){ PageHaitao pageHaitao = new PageHaitao(); data = pageHaitao.getInfo(this.link); } if(this.link.contains("fx.smzdm")){ PageFaxian pageFaxian = new PageFaxian(); data = pageFaxian.getInfo(this.link); } ArrayList<String> bodyTxt = (ArrayList<String>) data.get("content"); ArrayList<String> bodyPic = (ArrayList<String>) data.get("bodyPicPieces"); String title = this.title; String smalldesc = this.smalldesc.length()>0?this.smalldesc:(String)data.get("smalldesc"); smalldesc = smalldesc.length()>30?smalldesc.substring(0,29):smalldesc; String source = (String) data.get("source"); String releasetime = this.releasetime.length()>1?this.releasetime:(String) data.get("releasetime"); String curl = this.link; String createtime = FormatTime.getCurrentFormatTime(); String classify = this.classify; String smallurl = fileService.uploadPic(this.imgUrl, IP_PORT, apiKey); String cont = contentMix(bodyTxt,bodyPic,IP_PORT,apiKey,curl); String contId = fileService.uploadFile(createtime, cont, IP_PORT, apiKey); MyLog.logINFO("contentId:" + contId); if(smallurl.length()==0 || (smallurl.length()>33&&smallurl.contains("."))){ Debug.showDebut(this.imgUrl, smallurl); dbService.insertNews(title, smalldesc, smallurl, source, releasetime, contId, classify, curl, createtime); } }
da42216e-bbc8-4478-a76c-c983839244f3
3
private String getResponse(HttpURLConnection conn) { String xml = ""; try { BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); String next = null; while ((next = reader.readLine()) != null) xml += next.equals("") ? next : next + "\n"; } catch (IOException e) { log.error("{}", e); } return xml; }
993be944-8b00-4fcc-805b-f95c5ba1315b
0
public void setStatus(Status status) { this.status = status; }