method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
e41ae629-6130-47f9-bbe6-b30d3796cb2d
9
@Override public void start(Map<String, List<String>> incAttributes, String incUrl, Socket socket) { System.out.println("Starting NavigationSystem Plugin"); ResponseHandler respHandle = new ResponseHandler(socket); if (incAttributes.isEmpty()) { try { respHandle.s...
4ed97f11-37b7-41b2-98c6-74fecdbf9008
3
@Override protected void mine(Player p) { //oven can not be destroyed with items in it if(inventory[0] == null && inventory[1] == null && inventory[2] == null){ super.mine(p); }else{ System.out.println("Oven can not be recovered while it has items stocked !"); resetHealth(); } }
6c38653f-2775-4c39-a4f0-8c074862936e
0
public DigestMethodType getDigestMethod() { return digestMethod; }
4aa3bca8-3651-4a61-8dd5-8eed6be6be94
1
public List<Material> Wastage(int ME) { List<Material> wastage; wastage = new ArrayList<Material>(); for (int i = 0; i < Materials.size(); i++) { Material mat; mat = new Material(); mat.ProductID = Materials.get(i).ProductID; mat.ProductName = Mate...
6e0e5957-1c6c-4918-8081-6ccd87982a95
9
public static void main(String[] args) { logger.setLevel(Level.SEVERE); ConsoleHandler handler = new ConsoleHandler(); handler.setLevel(Level.SEVERE); logger.addHandler(handler); if (args.length == 0) { logger.warning("Invalid arguments count."); return; ...
4d9a874e-6077-47d2-81a9-8a0e32901b82
6
public static Set<Player> run(GameState state, GameSettings gSettings) { //Setup global game settings settings = gSettings; //Launch the GUIs state.launchGUIs(); //Hello! state.log("The game is starting!\nLook for a log of game events here"); //get the list of all the drawable cards ArrayList<...
87e8cb63-13a5-410a-8040-b63eaa22c9b9
9
public static String reverseVowels(String s) { if (s == null) return ""; char chars[] = new char[s.length()]; int i = 0, j = s.length() - 1; while (i <= j) { while (i < s.length() - 1 && !isvowel(s.charAt(i))) { chars[i] = s.charAt(i); i++; } while (j >= 0 && !isvowel(s.charAt(j))) { cha...
2e96c9ad-cd56-44e4-b345-8bc474976d2c
5
public double standardError_as_double() { boolean hold = Stat.nFactorOptionS; if (nFactorReset) { if (nFactorOptionI) { Stat.nFactorOptionS = true; } else { Stat.nFactorOptionS = false; } } double standardError = 0.0D; switch (type) { case 1: double[] dd = this.getArray_as_double(); ...
bc3ee56a-c5e0-4a4d-bd1c-d20183d62837
7
private DecisionTreeNode parseNode(XMLStreamReader reader, String[] labels) throws XMLStreamException { DecisionTreeNode result = null; //Put reader on the next node goToNext(reader, "node"); //Leaf or not ? if(reader.getAttributeValue(null, "type").equals("leaf")) { //Create decision Decision d =...
77ac38f1-f2ef-49e2-bc53-bb5047e12361
4
public Log_record(String one_line_rec) { //14/03/09 13:41:36.852 subsys event print_job_start user_name=operator1; file_name=default; sizeX=1200; sizeY=600; inkC=678; inkM=756; inkY=456; inkK=789; data = new Date(); data.setTime(0); subsystem = record_subsystems.Unknown; mes...
0d8d39d6-43c5-4425-b91b-acf91a10916d
2
@Override protected void process(List<RuleTaskState> chunks) { for (RuleTaskState chunk : chunks) { int progressValue = chunk.i; String stringToLog = chunk.s; if (progressValue == -1) { rd.addToMatchesList(stringToLog); continu...
cd882615-cfdc-4f3b-9fcd-3fd5a594469a
8
private boolean rekAble(int x, int y) { for (int i=1;i<this.rekAbleR;i++) { for (int j=1;j<this.rekAbleR;j++) { if (y-j>=0 && x-i>=0) if (this.P[x-i][y-j].rek==1) return false; if (y+j<this.tabSizeY && x+i<this.tabSizeX) if (this.P[x+i][y+j].rek==1) return false; }//j }//i return true; }//--
03a94880-72f6-4ffe-9c27-4714a2ac9212
0
public String[] GetData() { return dataPieces; }
8bcffe87-1747-4a61-aed7-133650b95ea5
8
@SuppressWarnings("unchecked") private void updateIncomingReferences(ModelElementInstance oldInstance, ModelElementInstance newInstance) { String oldId = oldInstance.getAttributeValue("id"); String newId = newInstance.getAttributeValue("id"); if (oldId == null || newId == null) { return; } ...
7783b74e-8101-4f08-8747-c85aa1ee92c6
0
public void setjCheckBoxComptesRendus(JCheckBox jCheckBoxComptesRendus) { this.jCheckBoxComptesRendus = jCheckBoxComptesRendus; }
78df4007-b1e2-4de5-9cfd-06cd3a007074
1
private void deleteFolder_fileManagerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteFolder_fileManagerButtonActionPerformed try { selectedDevice.getFileSystem().delete(directoryLabel_fileManagerLabel.getText() + jList1.getSelectedValue()); } catch (IOException...
693c542e-b286-41d4-a9f6-224dca96ba11
4
private void dealtDamage(int getX, int getY, int getWidth, int getLength, int getTime, int getDelay, double getDamage,int applyForce) { if (character.equals("P1")) // player 1 { if (moveDirection) { // add new object (player 1) into the world at the correctio...
601dbf7b-82b5-4f53-92d6-4f011cd75f28
1
public int getXAxisValue() { if (xaxis == -1) { return 127; } return getAxisValue(xaxis); }
9b6f6094-2918-4c65-a641-7f6b392f61e6
9
@Override public void endElement(String uri, String localName, String qName) throws SAXException { currentLevel--; currentElement = false; String name = null; if (localName != null && localName.length() != 0 && !elementsHandled.contains(localName)) { name = ...
769cbdb1-e49d-408c-b02b-7831effa42da
6
public void updateGenerator() { if (generatorCoolDown == 0) { int structGenWeight; Random structGenRdm = new Random(); structGenWeight = structGenRdm.nextInt(15); if (structGenWeight == 11) { int valueWeight; ...
7c9c9b2a-64ac-4480-ac25-1d1050f0894e
2
private void fullCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fullCBActionPerformed tablespaceT.clearSelection(); if(fullCB.isSelected()){ for(int i=0;i<tablespaceT.getRowCount();i++){ tablespaceT.getModel().setValueAt(false,i,1); } ...
4c7664e6-29ac-41b5-a096-bcea5925b649
9
public static void ClockLoop(int duration) { // GUI_NB.GCO("Clock time is now " + DisplayTimeFull() + " with time rate " + ClockControl.PrintTimeScale()); GlobalFuncs.ticksStable++; if (GlobalFuncs.runtoEq || GlobalFuncs.updateVapor) { GlobalFuncs.maxDelta = 0; GlobalFuncs.scenMap.updateVapor...
8e8ec4aa-d8b1-4211-ba88-46f5947725eb
4
public boolean collide(Block block) { if (this.hasPoint(block.getX() - block.getWidth() / 2, block.getY() - block.getHeight() / 2) || this.hasPoint(block.getX() - block.getWidth() / 2, block.getY() + block.getHeight() / 2) || this.hasPoint(block.getX() + block.getWidth() / 2, block.getY() - block.getHeight() / ...
0e494327-19b6-4ad5-ab20-9ea88a50fde9
3
public int matchScore(Person p, Person q){ set.forEach(k -> engine.put(k, p.match(q, k))); Object ret = null; try{ ret = ((Invocable)engine).invokeFunction(FUNC_NAME); } catch (ScriptException | NoSuchMethodException ex){ throw new RuntimeException(ex); } ...
ee29cf23-e863-4ed3-89a5-9c1c146f038a
2
private void Jornada_ComboBox2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_Jornada_ComboBox2ItemStateChanged // TODO add your handling code here: int i = 0; if (Jornada_ComboBox2.getSelectedIndex() > -1) { int p = Integer.parseInt(Jornada_ComboBox2.getSelectedIte...
f382980a-6294-44b6-ab1d-4c6b7a5cb8b4
5
public static void sort(Comparable[] a){ int N = a.length, h = 1; // while(h < N/3) h = 3*h + 1; while(h < N/3) h = 3*h ; while(h>=1){ for(int i = h; i < N; i++){ for(int j = i; j>=h; j-=h){ if(a[j].compareTo(a[j-h]) < 0){ Comparable tmp = a[j-h]; a[j-h] = a[j]; a[j] = tmp; } ...
57de4b76-fdac-45a5-80d1-3b403d3b53e7
6
protected boolean isValidLocation(UnitMover mover, int sx, int sy, int x, int y) { boolean invalid = (x < 0) || (y < 0) || (x >= map.getWidthInTiles()) || (y >= map.getHeightInTiles()); if ((!invalid) && ((sx != x) || (sy != y))) { invalid = map.blocked(mover, x, y); } return !invalid; }
c9b92763-8d6b-4389-8809-c50c55a59aac
5
public void run() { Debug.println("PhysicsEngine.run()"); synchronized (workQueue) { while (true) { if (workQueue.peek() == null) { try { workQueue.wait(); } catch (InterruptedException e) { continue; } } else { int doWhat = workQueue.poll(); switch (doWhat) { c...
45828d45-b483-4b29-957b-daa936efd30f
2
private static void handleDropOfferReq(SerializableDropOfferReq pack) { //List<String> sellers = pack.commandInfo; Server.loggerServer.info("[Server] drop auction"); List<String> sellers = new ArrayList<String>(); SelectionKey key; sellers.addAll(pack.commandInfo); // reset list in pack (no longer needed) ...
98aeddab-f030-4624-924e-e02c1e07078b
8
protected void findBounds(int w,int h) { // top line for ( int y=0;y<h;y++ ) { if ( !hLineClear(y) ) { downSampleTop=y; break; } } // bottom line for ( int y=h-1;y>=0;y-- ) { if ( !hLineClear(y) ) { downSampleBottom=y; break; }...
1be75eab-2b4f-4412-a029-897dd8e7f5c3
7
public static void anotherWatcher() { try { WatchService watchService = FileSystems.getDefault().newWatchService(); Path dir = Paths.get("/home/xander/test/"); dir.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY); FileTime lastModified = null; ...
6d9c889c-a74f-40f6-881e-cb6657f954da
6
private static void loadComponents(AutoCodeConfig autoCodeConfig,Map variables) throws InvalidPropertiesFormatException { if(variables == null || variables.get("component") == null){ throw new InvalidPropertiesFormatException("Can't find any component!"); } if(!(variables.get("compon...
e2e534a1-1486-4834-a1a8-72d912550dac
6
@Override public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("Save")) { // Saves the current values in an existing notice model.edit(view.getNotice(), view.getSubject(), view.getText(), view.getPriority()); view.actualizeList(model.getSubjects()); view.revalidate(); view.repaint(...
47f7ce08-1511-47d6-a650-1ec80299cd35
3
@Test public void timer() { final List<Long> expecteds=Arrays.asList(1L,2L,3L,4L,5L); final List<Long> actuals=new ArrayList<Long>(); final Timer timer = new Timer(1000, 5); timer.addEventListener(TimerEvent.TIMER, new EventListener() { @Override public void handleEvent(Event event) { System.out....
be08ed1b-a1eb-4e2f-adb0-04da38c7bb4a
3
public boolean remove(String sana) { if (etsiSana(sana) == false) { return false; } Node poistettava = getChild(sana.charAt(0)); if (sana.length() > 1) { String loput = sana.substring(1); poistettava.remove(loput); } if (poistettava.si...
d7d83bac-a81d-4ca7-a8ef-3c24c5d55f95
2
@Override public void run() { while (true) { try { String data = blockingDeque.takeFirst(); System.out.println(Thread.currentThread().getName() + " take(): " + data); Thread.sleep(1000); } catch (InterruptedExcep...
f4bea69a-2858-4328-acb5-7af1e0c1853a
9
public String convertInitial(char initial){ String name = null; if(initial == 'C'){ name = "Conservatory"; } if(initial == 'K'){ name = "Kitchen"; } if(initial == 'B'){ name = "Ballroom"; } if(initial == 'R'){ name = "Billiard room"; } if(initial == 'L'){ name = "Library"; } if(in...
a826b07e-0f7a-42fc-a222-47ba0daca3bc
3
public void appendSamples(int channel, float[] f) { int pos = bufferp[channel]; short s; float fs; for (int i=0; i<32;) { fs = f[i++]; fs = (fs>32767.0f ? 32767.0f : (fs < -32767.0f ? -32767.0f : fs)); s = (short)fs; buffer[pos] = s; pos += channels; } buf...
d71aa70d-5145-46f5-8c75-07275d12d1c6
9
@Override public void executeMove(ChessBoard board) { promoted_coin = null; if (option == NOT_DEFINED) { // PromotionDialog temp = new PromotionDialog(null, true); // temp.setVisible(true); // option = temp.getOption(); } switch (option) { ...
b301203d-4b11-40a0-a376-262bb4753bbc
8
public boolean either24(int[] nums) { boolean is22 = false; boolean is44 = false; for (int i = 0; i < nums.length-1; i++) { if (nums[i] == 2 && nums[i+1] == 2) { is22 = true; } else if (nums[i] == 4 && nums[i+1] == 4) { is44 = true; ...
5691e3f4-d385-4cd9-a5d3-1e5d37d2fab3
6
public void createFromXML(NodeList attributes) { Node n = attributes.item(0); while(n != null) { if(n.getNodeType() == Node.ELEMENT_NODE) { if(n.getNodeName().equals("rateOfFire")) { rateOfFire = Float.parseFloat(n.getFirstChild().getNodeValue()); ...
3f55ce66-d195-4017-8acb-f49794e4d634
8
private void findOutAboutFriends() { //Friend names String alexName; alexName = JOptionPane.showInputDialog("What is your name"); alexFriend.setName(alexName); String alexHumorStyle; alexHumorStyle = JOptionPane.showInputDialog("What is your humor style"); alexFriend.setHumorStyle(alexHumorStyle); ...
50090526-e5cc-4878-bb6c-8ce84741363f
9
static protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = maxNextCharInd = 0; available = tokenBegin; } else if (tokenBegin < 0) bufpos...
dccfdd99-cb6f-4c46-bd6f-893be31774ca
4
public boolean isBlockAlreadyInRoulette(Block block) { Set<Integer> tilesKeys = tilesLocations.keySet(); for(Integer key : tilesKeys) { SerializableLocation blockLocation = new SerializableLocation(block.getLocation()); if(tilesLocations.get(key).contains(blockLocation)) return true; } Set<Integer> spin...
e6bbafce-6585-4eb2-b143-425f053ef145
8
@Override public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) { final java.util.Map<String,String> parms=parseParms(parm); final String last=httpReq.getUrlParameter("SOCIAL"); if(parms.containsKey("RESET")) { if(last!=null) httpReq.removeUrlParameter("SOCIAL"); return "";...
a0bea7d8-d37f-4f43-936a-3f9d80e649de
3
void kvpExpand(StringBuilder b, List<KVP> l, String method) { for (KVP c : l) { String[] from = c.getKey().split("\\."); String tos = c.getValue().toString().trim(); String[] t = tos.split("\\s+"); // multiple @In for (String kvp : t) { String to_obj = kvp; // default target is just object name St...
44f79769-b396-4133-8436-1205c0dab289
3
public byte[] decrypt(byte[] in) { int iterations = 1; if(in.length > 128) { iterations = (int)Math.ceil(in.length/128); } int messageLen = 0; byte[] message = new byte[iterations * 117]; try { for(int i = 0; i < iterations; i++){ byte[] toBeDecrypted = new byte[128]; System.array...
89476ac8-2a01-4545-8884-7f5146fa284a
1
public static ClassLoader getClassLoader() { ClassLoader contextCL = Thread.currentThread().getContextClassLoader(); ClassLoader loader = contextCL == null ? ClassHelper.class.getClassLoader() : contextCL; return loader; }
07ee42b4-b249-4334-9af4-8bbc0f727af4
6
private Map makeRequest(HttpGet httpGet) { InputStream inputStream = null; for (int i = 0; i < 15; i++) { // try some times try { HttpClient httpClient = new DefaultHttpClient(); HttpResponse response = httpClient.execute(httpGet); HttpEntity e...
bef8974c-65d9-4992-bdb1-b727cd72d3db
9
@Override public String toString() { StringBuilder sb = new StringBuilder(); if (target == null) { sb.append(BeansUtils.NULL); } else { Class<?> clazz = target.getClass(); sb.append(clazz == String.class ? BeansUtils.QUOTE : BeansUtils ...
d05f726b-6dc1-47e6-8db6-9bc8c0936607
3
@Test public void peekingDoesntChangeHeap() { heap.insert(1); for (int i = 0; i < 1336; i++) heap.insert((int)(2 + Math.random() * 10000)); int j = -1; for (int i = 0; i < 1337; i++) j = heap.peek(); assertTrue(j == 1 && heap.size() == 1337); }
34acf9ed-0f2b-48d8-a862-e9463f99b740
2
private String encryptString(String str) { StringBuffer sb = new StringBuffer (str); int lenStr = str.length(); int lenKey = key.length(); for (int i=0, j=0; i < lenStr; i++, j++ ) { if (j >= lenKey) j = 0; sb.setCharAt(i, (char)(str.char...
75e797fd-67e1-41a8-b40e-0a487bc115b6
5
public static void deleteDir(String path){ File f =new File(path); if(f.exists() && f.isDirectory()) { if(f.listFiles().length == 0) { f.delete(); } else { File delFile[] = f.listFiles(); int i = f.listFiles().length; for(int j=0;j<i;j++) { if(delFile[j].isDirectory()){ ...
6f91a8e1-7d37-4503-a537-2dde0567a864
1
public void deleteTeacher(int id) { try { PreparedStatement ps = con.prepareStatement( "DELETE FROM teacher WHERE id=?" ); ps.setInt( 1, id ); ps.executeUpdate(); ps.close(); } catch( SQLException e ) { e.printStackTrace(); } }
2e00fcbc-4dde-4a0c-b408-fd410ecd7ac1
5
public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 1){ Transition trans = getDrawer().transitionAtPoint(event.getPoint()); if (trans != null){ if (trans.isSelected){ trans.isSelected = false; selectedTransition = nu...
8f252a4a-b2c5-47c2-99aa-55b4fa71e6ae
3
public Component getComponentWithCard(Card card) { for(Component comp : this.getComponents()) { if(comp instanceof CardInHand) { if(((CardInHand) comp).getName().toLowerCase().equals(card.getName().toLowerCase())) { return comp; } } } return null; }
c0894517-95f5-4068-8931-0f06798810b2
4
static void resampleProcess(int newR) throws IOException{ /* * Determine the threshold for resampling */ long indexsize = index.size(); int threshold = -1; long c = 0; estiRatio = getEstimateRatio(); measuredRatio = (double)dup/total/estiRatio; resultRecord.println("Total chunks are: " + totalChu...
ee363090-a218-41e5-9e72-cf68f11a4102
5
public Object getAnswers(ClientRequest clientRequest) { Question question = (Question) clientRequest.getObject(); Random random = new Random(); GameDBLogic bLogic = new GameDBLogic(); List<Answer> allAnswers = null; try { allAnswers = bLogic.getAnswers(question); ...
994c25fa-09cd-4bb2-ab3c-303aadf9de7b
3
public boolean Save() { String filename = m_fileTitle.getText(); //Stop saving if no filename is given. if (filename.isEmpty()) { JOptionPane.showMessageDialog(null, "No filename"); return false; } int width; int height; String str_width = m_chartWidth.getText().toString(); String str_h...
234280fd-82fa-41d7-bd85-e5bf33835d27
8
public void renderScreen() { if (buffer == null) { // create the buffer buffer = createImage(PWIDTH, PHEIGHT); dbg = buffer.getGraphics(); } // Render campus dbg.setColor(Color.LIGHT_GRAY); for (int i=0; i<TILESX; i++) for (int j=0; j<TILESY; j++) { if (tiles[i][j]!=null) dbg.drawImage...
094af0b7-37a3-4462-ab44-8603135c0b8c
9
public static Direction getPlayerDirection(int x, int y) { if (x != 0) { if (x > 0) { if (y > 0) { return Direction.DOWNRIGHT; } else if (y < 0) { return Direction.UPRIGHT; } else { return Dir...
f61efd07-2025-4d73-8089-467d89cbf47d
8
public static void main(String[] args) throws Exception { String env = null; if (args != null && args.length > 0) { env = args[0]; } if (! "dev".equals(env)) if (! "prod".equals(env)) { System.out.println("Usage: $0 (dev|prod)\n"); ...
aeed67aa-34cb-4448-b0e9-dd2c75da0559
4
private boolean hasEveryIdentityDiscPositionOnlyOneIdentityDisc(Grid grid) { List<IdentityDisc> identityDiscs = getIdentityDiscsOfGrid(grid); for (IdentityDisc idDisc : identityDiscs) { final Position idDiscPos = grid.getElementPosition(idDisc); for (Element e : grid.getElementsOnPosition(idDiscPos)) ...
27db7179-b1b7-4312-98a9-98de9954f4ec
7
public void pack() { boolean isrunestone = cap.text.equals("Runestone"); Coord max = new Coord(0, 0); for (Widget wdg = child; wdg != null; wdg = wdg.next) { if ((wdg == cbtn) || (wdg == fbtn)) continue; if ((isrunestone) && (wdg instanceof Label)) { ...
b6a150a1-6ec2-4114-b0a3-8330a50ab8d8
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 Requests)) { return false; } Requests other = (Requests) object; if ((this.id == null && other.id != null) || (...
4dadda7e-ef6c-4297-9472-02c123d475d1
0
public Date getFecha() { //no pongas mierda en mi codigo return fecha; }
f76de2d0-0988-425b-b813-2f95152c7b66
0
public int getHeight() { return height; }
0c166576-2ef2-4680-8b70-dffbe05e5216
3
public Coord getMaxCoord(){ int max = 0; Coord res = new Coord(); for(int i = 0 ; i < taille ; i++){ for(int j = 0 ; j < taille ; j++){ if(getValue(i,j)> max){ max = getValue(i,j) ; res.x = i; res.y = j; ...
268d1626-8546-43db-94d3-9b8c6abc8aab
8
public void gameUpdated(GameUpdateType type) { // find our super parent frame -- needed for dialogs Component c = this; while (null != c.getParent()) c = c.getParent(); switch (type) { case ERROR: boardFrame.bp.repaint(); boardPanel.repaint(); controlPanel.play.setEnabled(false); controlPan...
2d84fed7-ebdb-4e01-a5f9-9f7466843519
8
static long LCA(int p, int q) { int tmp, log, i; // if p is situated on a higher level than q then we swap them if (L[p] < L[q]) { tmp = p; p = q; q = tmp; } // we compute the value of [log(L[p)] for (log = 1; 1 << log <= L[p]; log++) ; // ---- log--; long sum = 0; // we find the ancestor ...
e4dc7c82-3a95-4e4c-a3f2-e99aed21b10e
1
public static void main(String[] args) { StudentList students = new StudentList(10000); //System.out.println(students); SeparateChainingHashST sc = new SeparateChainingHashST(97); for (int i = 0; i < 10000; i++) { sc.put(students.getList()[i].getLdap(), students.get...
89546642-4014-43a1-884b-17537d569074
9
private boolean r_postlude() { int among_var; int v_1; // repeat, line 75 replab0: while(true) { v_1 = cursor; lab1: do { // (, line 75 ...
bc09c33a-e2e3-4830-86db-3adb3fe9d414
4
public void or(BitSet set) { if (this == set) return; int wordsInCommon = Math.min(wordsInUse, set.wordsInUse); if (wordsInUse < set.wordsInUse) { ensureCapacity(set.wordsInUse); wordsInUse = set.wordsInUse; } ...
a4a4c7a0-e762-420b-b4e4-ea81cc34e933
3
public void simpan(Mahasiswa k) { try { Connection c = koneksi.connect(); long myId = 0; String sqlIdentifier = "select * from mahasiswa"; PreparedStatement pst = c.prepareStatement(sqlIdentifier); synchronized (this) { ResultSet rs = pst.executeQuery(); if (rs.next()) { myId = rs.getLong...
61235b7a-11b5-4498-b8b3-57042322f61c
2
public void updateSocialVelocity() { for(int i = velocities.length / 2; i < velocities.length; i++){ for(int k = 0; k < velocities[i].length; k++){ int socialBest = neighbourhood.neighbourhoodBest(i); double normDevDist = calculateNormalisedDeviationDistance(k, positions[i][k], personalBest[socialBest]); ...
8a9e9d57-7ac6-4809-b726-370860744d5a
7
public Msg process(Msg msg) { System.out.println("MSG TYPE:"+msg.get_msg_tp()); Msg ret_msg = new Msg(); if (msg.get_msg_tp() == MESSAGE_TYPE.LOOKUP) { String name = msg.getObj_name(); // suppose the remote object is in the registry if (reg.get(name) != null) { ret_msg.setRemote_ref(re...
fc9111b2-cb59-4a2a-9c48-39945a8e2c2c
7
public void run() { mainFrame.lock(true); final String osMinecraftName = profile.getOs().getMinecraftName(); LogUtils.log(Level.INFO, Constants.PLAY_TASK_PREFIX + "Debug infos :"); LogUtils.log(Level.INFO, Constants.PLAY_TASK_PREFIX + "OS : " + profile.getOs().getName()); LogUtils.log(Level.INFO, Constants.P...
91c8b93c-8a0b-41e8-8938-964bcda18e7b
2
@Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.BLACK); g.fillRect(0, 0, this.getWidth(), this.getHeight()); g.setColor(Color.GREEN); ArrayList frame = synth.outputHistory; //we cannot use frame.size() here because it is ...
c6d343eb-2634-457b-8788-6b6f4228b76f
4
protected String getUrlForPath(final String path) { if (path.startsWith("http://") || (path.startsWith("https://"))) { return path; } else if (getHostname().startsWith("http://") || (getHostname().startsWith("https://"))) { return getHostname() + path; } e...
e33fe425-4176-4fa8-a4b0-78cf902f5276
5
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!sender.hasPermission("under50.kick")) { sender.sendMessage(ChatColor.RED + "No access"); return true; } if (args.length < 1) { sender.sendMessage(...
26d166e7-206b-4a03-888e-7c2ea15c8a0a
4
@Override public void onNodeCreate(DataSourceEvent event) throws ResourceException { DataNode node = event.getNode(); DataNode parentNode = event.getParent(); if (node.getName().equals(ResourceDefinition.RESOURCE_TAG)) { String id = node.getAttribute(ResourceDefinition.ID); String parentId = parentNode.g...
9c145902-9856-4765-a9d0-ee0f03a2cc26
3
private void readTableHeader() throws IOException { long columnCount = nraf.readUnsignedInt(); long l = 0; StringBuilder sb; Set<String> row = new LinkedHashSet<String>(); while(l < columnCount) { sb = new StringBuilder(); long charCount = nraf.readUnsignedInt(); long m = 0; while(m < ...
bb20697d-567f-4d94-97ce-c65c7de0be22
6
public int largestRectangleArea(int[] height) { Stack<Integer> stack = new Stack<Integer>(); int top ; int length = height.length; int max = 0; int i=0; while(i < length){ if(stack.empty() || height[stack.peek()] <= height[i]) stack.push(i++); ...
30b86be8-50eb-43f6-8ae1-489bc0222b8c
9
private static AckResponse generateResponse(Request req, String userID, String type, String groupID) { if (req instanceof ReadRequest) { Journal jurre = db.getJournal(req.getID(), userID, groupID, type); if (jurre == null) return new AckResponse(false, "\"acce...
839cff93-62ce-42c0-8dc0-c17172bdae11
1
private static void shuffle(int[] arr, Random gen) { for (int i = 0 ; i != arr.length ; ++i) { int j = gen.nextInt(arr.length - i) + i; int t = arr[i]; arr[i] = arr[j]; arr[j] = t; } }
a3ef13d1-d2bb-4295-8871-ae1715b46c2e
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
47c08e15-2273-4776-9284-ab139d478a76
2
@Override protected Object doGet(final String key) { Element element = null; try { element = cache.get(key); } catch (Throwable e) { CacheErrorHandler.handleError(e); } if (element != null) { return element.getObjectValue(); } else { return null; } }
5c55ef95-bc98-4840-b547-5b0e8b0666da
2
private synchronized void doParse(String systemId, String publicId, Reader reader, InputStream stream, String encoding) throws java.lang.Exception { basePublicId = publicId; baseURI = systemId; baseReader = reader; baseInputStream = stream; initialize...
ff309ee8-15d1-41f6-afaa-ebbf7dcd7c71
5
@Test public void depthest02opponent5() { for(int i = 0; i < BIG_INT; i++) { int numPlayers = 6; //assume/require > 1, < 7 Player[] playerList = new Player[numPlayers]; ArrayList<Color> factionList = Faction.allFactions(); playerList[0] = new Player(chooseFaction(factionList), new SimpleAI()); ...
b8e3e7d7-0e97-4235-94be-eeb68d7fbb17
7
private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) { int rounds, i, j; int cdata[] = (int[])bf_crypt_ciphertext.clone(); int clen = cdata.length; byte ret[]; if (log_rounds < 4 || log_rounds > 31) throw new IllegalArgumentException ("Bad number of rounds"); rounds = 1 << log_rounds; ...
1a374ca9-656c-46ac-9fe9-847d7aa3a97e
0
public Timestamp getSumbitTime() { return this.sumbitTime; }
4179c8bc-6d39-437d-a4be-0c22319ec42a
9
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target==null) return false; if(target.fetchEffect(ID())!=null) { mob.tell(targ...
ebb4c95c-f65a-4fe0-942f-5efa9454b799
5
public static Car create(String className, Map<String, Object> content) throws Exception { Class<?> inputClass = Class.forName(className); Class<? extends Car> currentCarClass = inputClass.asSubclass(Car.class); Car car = currentCarClass.newInstance(); for (Entry<String, Object> entry : content.entrySet())...
c02908fe-03fa-40ff-a5ac-3187165866c6
1
public boolean addUnit(Unit u) { if (unit == null) { unit = u; //System.out.println("Unit added at: (" + x + ", " + y + ")"); return true; } return false; }
5f3392a7-12b6-46d6-9f34-c81999c55ced
4
public OperationExpression simplify() { if (((PrimitiveOperator) op).isComplexIDOfLeft()) { return new UnaryOpExpression(new PrimitiveOperator(PrimitiveOperator.ID_OP), left); } if (((PrimitiveOperator) op).isComplexNotOfLeft()) { return new UnaryOpExpression(new PrimitiveOp...
fe4c4e59-28ac-4106-9b02-8e6062f26cea
4
public double[] processWindow(double[] window, int start) throws IllegalArgumentException { //number of unique coefficients, and the rest are symmetrically redundant int fftSize = (windowSize / 2) + 1; //check start if(start < 0) throw new IllegalArgumentException("start must be a positve value...
e7259a86-e2c2-4b17-b9f9-7a5da426b800
5
public static int findLIS(int size) { int[] dp = new int[size]; Arrays.fill(dp, 1); int ans = 1; for (int i = 0; i < dp.length; i++) for (int j = 0; j < i; j++) if (match(j, i) && dp[i] + 1 > dp[j]) dp[i] = Math.max(dp[i], dp[j] + 1); for (int i = 0; i < dp.length; i++) ans = Math.max(ans, d...
85b0fe6f-3797-4691-a3d1-16e0d904a8bf
3
@SuppressWarnings("unchecked") @EventHandler public void onPlayerDeath(EntityDeathEvent e){ if(e instanceof PlayerDeathEvent){ if(this.plugin.getConfig().getBoolean("show_death") && !this.privatePlayers.contains(e.getEntity()) ){ JSONObject json = new JSONObject(); json.put("message",((PlayerDeathEvent) ...
0ae24ae3-a685-401a-ba94-5ba7fa019c37
6
private boolean registraUsuario(HttpServletRequest request, HttpServletResponse response) throws IOException { ConexionBD bd = new ConexionBD(); String categoria = request.getParameter("categoria"); String nombre = request.getParameter("nombre"); String login = request.getParameter("log...
ff2a206e-ff4d-4541-8141-26d22d27ab2c
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { ...