method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
750e5b32-3c23-4493-afdf-3c630ec62ee1
6
@Test public void testConvertingHashMapToSQLArray() { HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); for (int i = 0; i < 10; i++) { map.put(i + 1, i); } String result = null; try { Method method = DBHandler.class.getDeclaredMethod("converHashMaoToSQLArray", map.getClass()); method.setAccessible(true); result = (String) method.invoke(null, map); } catch (SecurityException e) { e.printStackTrace(); Assert.fail(); } catch (IllegalArgumentException e) { e.printStackTrace(); Assert.fail(); } catch (NoSuchMethodException e) { e.printStackTrace(); Assert.fail(); } catch (IllegalAccessException e) { e.printStackTrace(); Assert.fail(); } catch (InvocationTargetException e) { e.printStackTrace(); Assert.fail(); } assertEquals("{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}", result); }
50650ca2-884c-4397-b2de-fec2b81ad8d1
2
public void setOxygen( int n ) { oxygen = n; if ( oxygen == 100 ) { bgColor = maxColor; } else if ( oxygen == 0 ) { bgColor = minColor; } else { double p = oxygen / 100.0; int maxRed = maxColor.getRed(); int maxGreen = maxColor.getGreen(); int maxBlue = maxColor.getBlue(); int minRed = minColor.getRed(); int minGreen = minColor.getGreen(); int minBlue = minColor.getBlue(); bgColor = new Color( (int)(minRed+p*(maxRed-minRed)), (int)(minGreen+p*(maxGreen-minGreen)), (int)(minBlue+p*(maxBlue-minBlue)) ); } }
5df4d580-ed5e-47d1-b6a1-ccf00a4232d5
6
public static void deleteAccounts(List<Account> accountList, Accounts accounts){ if(!accountList.isEmpty()) { ArrayList<String> failed = new ArrayList<String>(); for(Account account : accountList) { try{ accounts.removeBusinessObject(account); }catch (NotEmptyException e){ failed.add(account.getName()); } } if (failed.size() > 0) { if (failed.size() == 1) { ActionUtils.showErrorMessage(ActionUtils.ACCOUNT_NOT_EMPTY, failed.get(0)); } else { StringBuilder builder = new StringBuilder(getBundle("BusinessActions").getString("MULTIPLE_ACCOUNTS_NOT_EMPTY")+"\n"); for(String s : failed){ builder.append("- ").append(s).append("\n"); } JOptionPane.showMessageDialog(null, builder.toString()); } } } ////ComponentMap.refreshAllFrames(); }
61e40c1e-6456-44d3-bbb2-826b3cd90be1
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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new menu().setVisible(true); } }); }
76613843-a9a9-48ae-8f92-d2a3fefeefac
8
private GameState findSetToTrue(GameState state, Card card) { //Check the hand for(Card c : state.getPlayer(card.getFaction()).getHand()) { if(c.equals(card)) { state.getPlayer(card.getFaction()).removeFromHand(c); c.setTrue(state.getTime()); state.getPlayer(card.getFaction()).addToHand(c); } } //Check the discard for(Card c : state.getPlayer(card.getFaction()).getDiscard()) { if(c.equals(card)) { state.getPlayer(card.getFaction()).removeFromDiscard(c); c.setTrue(state.getTime()); state.getPlayer(card.getFaction()).addToDiscard(c); } } //Check the den for(Card c : state.getPlayer(card.getFaction()).getDen()) { if(c.equals(card)) { state.getPlayer(card.getFaction()).removeFromDen(c); c.setTrue(state.getTime()); state.getPlayer(card.getFaction()).addToDen(c); } } //Check the board for(Card c : state.getBoard().getDeck()) { if(c.equals(card)) { state.getBoard().removeCard(c); c.setTrue(state.getTime()); state.getBoard().addCard(c); } } return state; }
883510f0-5b38-47e9-a0b0-471b528df61b
7
public static void main(String[] args) { File dictionary = null; File document = null; String option = ""; if(args.length < 2 || args.length > 3) { System.out.println("Incorrect number of arguments!"); return; } dictionary = new File(args[0]); if(!dictionary.isFile()){ System.out.println("Unable to use the dictionary file!"); return; } document = new File(args[1]); if(!document.isFile()){ System.out.println("Unable to use the document file!"); return; } // If a third parameter was passed for the options, check its validity if (args.length == 3) if(args[2].equalsIgnoreCase("-p") || args[2].equalsIgnoreCase("-f")) option = args[2]; else { System.out.println("Invalid printing or filing option argument!"); return; } // Passing the dictionary file, document file, and the option run_spell_check(dictionary, document, option); }
384e75a0-fac0-4f59-ac91-99105f2c9b37
8
public static void copybitmap(osd_bitmap dest, osd_bitmap src, int flipx, int flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color) { rectangle myclip=new rectangle(); /* if necessary, remap the transparent color */ if (transparency == TRANSPARENCY_COLOR) transparent_color = Machine.pens[transparent_color]; if ((Machine.orientation & ORIENTATION_SWAP_XY)!=0) { int temp; temp = sx; sx = sy; sy = temp; temp = flipx; flipx = flipy; flipy = temp; if (clip!=null) { /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = clip.min_y; myclip.min_y = temp; temp = clip.max_x; myclip.max_x = clip.max_y; myclip.max_y = temp; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_X)!=0) { sx = dest.width - src.width - sx; if (clip!=null) { int temp; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = dest.width-1 - clip.max_x; myclip.max_x = dest.width-1 - temp; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_Y)!=0) { sy = dest.height - src.height - sy; if (clip!=null) { int temp; myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_y; myclip.min_y = dest.height-1 - clip.max_y; myclip.max_y = dest.height-1 - temp; clip = myclip; } } if (dest.depth != 16) { copybitmap_core8(dest,src,flipx,flipy,sx,sy,clip,transparency,transparent_color); } else { throw new UnsupportedOperationException("copybitmap_core16"); //copybitmap_core16(dest,src,flipx,flipy,sx,sy,clip,transparency,transparent_color); } }
1daf2b6f-b915-4c85-9e82-17c69a111051
0
public Modele getPlateau1() { return plateau1; }
da787dca-d14b-4e91-88e7-43fd635268f7
6
public boolean write(aos.apib.OutStream out, aos.apib.Base o) { PeerInfo__Tuple v = (PeerInfo__Tuple)o; int i = -1; while ((i = out.nextField(i, this)) >= 0) { switch (i) { case 0: out.putInt(v.id, i, __def.id, this); break; case 1: out.putBool(v.isAlive, i, __def.isAlive, this); break; case 2: out.writeBaseClasses(o, this); break; default: if (i >= 0 && i <= 2) break; out.error("Writer for PeerInfo__Tuple: illegal field number:"+i); return false; } } return true; }
a9f18084-d077-4bfc-bc42-cf36b210bc3c
4
public static void main(String[] args) { /* Use an appropriate Look and Feel */ try { //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); long l = Long.parseLong("1111222222222222"); Date d = new Date(l); Calendar c = Calendar.getInstance(); c.setTimeInMillis(l); UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } catch (InstantiationException ex) { ex.printStackTrace(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } /* Turn off metal's use of bold fonts */ UIManager.put("swing.boldMetal", Boolean.FALSE); //Schedule a job for the event dispatch thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); }
4becd18f-8c33-4f0a-8fd3-ef5efb2f8f8e
9
public Dimension getPreferredSize() { Insets i = getInsets(); return new Dimension(i.left + i.right + 2 + (image != null && text != null && textVisible ? textImageGap : 0) + (image != null ? image.getWidth(this) : 0) + (metrics != null && textVisible && text != null ? metrics.stringWidth(text) : 0), i.top + i.bottom + Math.max(image != null ? image.getHeight(this) : 0, (metrics != null ? metrics.getHeight() : 0))); }
61f4acd7-0e23-4953-a54a-2ccd907150ad
8
protected void oneMoreStoryChar(){ if(curStory.isEmpty()&&curPStory.isEmpty()){ timer.stop(); storyDiscription=""; pStoryDiscription=""; storyCharIndex=0; pStoryCharIndex=0; return; } if(!curStory.isEmpty()){ if(storyCharIndex<curStory.firstElement().firstElement().length()){ storyDiscription+=curStory.firstElement().firstElement().charAt(storyCharIndex); storyCharIndex++; } else{ curStory.firstElement().remove(0); storyCharIndex=0; } if(curStory.firstElement().isEmpty()){ curStory.remove(0); storyCharIndex=0; } } if(!curPStory.isEmpty()){ if(pStoryCharIndex<curPStory.firstElement().firstElement().length()){ pStoryDiscription+=curPStory.firstElement().firstElement().charAt(pStoryCharIndex); pStoryCharIndex++; } else{ curPStory.firstElement().remove(0); pStoryCharIndex=0; } if(curPStory.firstElement().isEmpty()){ curPStory.remove(0); pStoryCharIndex=0; } } this.jTextArea1.setText(storyDiscription+"_"); this.jTextArea2.setText(pStoryDiscription+"_"); }
d54b6e49-5f41-4291-85e3-fb57101d8113
7
public ClassifierCustomizer() { m_ClassifierEditor. setBorder(BorderFactory.createTitledBorder("Classifier options")); m_updateIncrementalClassifier. setToolTipText("Train the classifier on " +"each individual incoming streamed instance."); m_updateIncrementalClassifier. addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_dsClassifier != null) { m_dsClassifier. setUpdateIncrementalClassifier(m_updateIncrementalClassifier. isSelected()); } } }); m_incrementalPanel.add(m_updateIncrementalClassifier); m_executionSlotsText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_dsClassifier != null && m_executionSlotsText.getText().length() > 0) { int newSlots = Integer.parseInt(m_executionSlotsText.getText()); m_dsClassifier.setExecutionSlots(newSlots); } } }); m_executionSlotsText.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) {} public void focusLost(FocusEvent e) { if (m_dsClassifier != null && m_executionSlotsText.getText().length() > 0) { int newSlots = Integer.parseInt(m_executionSlotsText.getText()); m_dsClassifier.setExecutionSlots(newSlots); } } }); m_blockOnLastFold.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_dsClassifier != null) { m_dsClassifier.setBlockOnLastFold(m_blockOnLastFold.isSelected()); } } }); JPanel executionSlotsPanel = new JPanel(); executionSlotsPanel. setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); JLabel executionSlotsLabel = new JLabel("Execution slots"); executionSlotsPanel.setLayout(new BorderLayout()); executionSlotsPanel.add(executionSlotsLabel, BorderLayout.WEST); executionSlotsPanel.add(m_executionSlotsText, BorderLayout.CENTER); m_holderPanel. setBorder(BorderFactory.createTitledBorder("More options")); m_holderPanel.setLayout(new BorderLayout()); m_holderPanel.add(executionSlotsPanel, BorderLayout.NORTH); // m_blockOnLastFold.setHorizontalTextPosition(SwingConstants.RIGHT); m_holderPanel.add(m_blockOnLastFold, BorderLayout.SOUTH); JPanel holder2 = new JPanel(); holder2.setLayout(new BorderLayout()); holder2.add(m_holderPanel, BorderLayout.NORTH); JButton OKBut = new JButton("OK"); JButton CancelBut = new JButton("Cancel"); OKBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { m_parentFrame.dispose(); } }); CancelBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // cancel requested, so revert to backup and then // close the dialog if (m_backup != null) { m_dsClassifier.setClassifierTemplate(m_backup); } m_parentFrame.dispose(); } }); JPanel butHolder = new JPanel(); butHolder.setLayout(new GridLayout(1,2)); butHolder.add(OKBut); butHolder.add(CancelBut); holder2.add(butHolder, BorderLayout.SOUTH); setLayout(new BorderLayout()); add(m_ClassifierEditor, BorderLayout.CENTER); add(holder2, BorderLayout.SOUTH); }
65939f4c-1a51-46cc-9672-3d814d5f7945
5
public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); ArrayList<ArrayList<Integer>> a = new ArrayList<>(); for (int i = 0 ; i <= 100 ; i++){ ArrayList<Integer> b = new ArrayList<>(); a.add(i, b); } for (int j = 0 ; j < n ; j++){ int id = in.nextInt(); int m = in.nextInt(); ArrayList<Integer> t = a.get(m); t.add(id); } StringBuilder d = new StringBuilder(""); for (int k = 100 ; k >= 0 ;k--){ ArrayList<Integer> c = a.get(k); int s = c.size(); for (int h = 0 ; h < s; h++){ d.append(c.get(h)); d.append(" "); d.append(k); d.append("\n"); if (d.length()>8000){ out.println(d); d.setLength(0); } } } out.println(d); out.flush(); }
d20bf472-3d29-48b9-adc4-86a5e2b0901c
5
public void sinkDown(int k){int a = mH[k]; int smallest =k; if(2*k<position && mH[smallest]>mH[2*k]){ smallest = 2*k; } if(2*k+1<position && mH[smallest]>mH[2*k+1]){ smallest = 2*k+1; } if(smallest!=k){ swap(k,smallest); sinkDown(smallest); } }
ee2fbf14-23cd-4355-8305-551b99def722
3
public void trimData( int maxLength ) { if( audioData == null || maxLength == 0 ) audioData = null; else if( audioData.length > maxLength ) { byte[] trimmedArray = new byte[maxLength]; System.arraycopy( audioData, 0, trimmedArray, 0, maxLength ); audioData = trimmedArray; } }
51799eec-4480-4938-a512-032bc84aae12
5
@EventHandler (priority = EventPriority.NORMAL) public void onBlockPlace(BlockPlaceEvent event){ Player p = event.getPlayer(); if(!RPSystem.permission.has(p, plugin.config.getString("block-restriction.override-permission")) && !p.isOp()){ if(plugin.itemConfig.getStringList("restricted-items").contains(event.getBlock().getType().toString())){ // If the item is a restricted item... if(!RPSystem.permission.has(p, plugin.itemConfig.getString(event.getBlock().getType().toString() + ".place-permission")) && !p.isOp()){ p.sendMessage(ChatConstants.err("Permission to place " + event.getBlock().getType().toString() + " denied.")); p.sendMessage(ChatConstants.err("You do not have permission: " + ChatColor.DARK_RED + plugin.itemConfig.getString(event.getBlock().getType().toString() + ".place-permission") + ChatColor.RED)); event.setCancelled(true); } } } }
60896f79-c713-4b43-a794-832d5dd728f9
0
public int getS1() { return this.state; }
ada3ae03-c1e6-42e5-a6ed-7ef569bedf83
7
public static void main( String[] args ) { /* * Given following method signature, print all the combinations of the numbers: void combinations(int maxNumber); */ System.out.println("01---------------------------------------"); int[] sampleArray = { 1, 2, 3,4 }; ArrayList<Object> arr = new ArrayList<Object>(); for(int i=0; i < sampleArray.length; i++) arr.add(sampleArray[i]); Combination com = new Combination(); ArrayList<ArrayList<Object>> ff = new ArrayList<ArrayList<Object>>(); ff = com.comp(arr); System.out.println("Combination is: " +ff.size() ); System.out.println(ff); /* * Given N numbers, how to find the minimum M numbers of them? i.e, the minimum 3 numbers in 2,1,6,7,4,5,7,8 is 1,2,4. */ System.out.println("02---------------------------------------"); int min[] = {2 ,1 ,6 ,7 ,4 ,5 ,7 ,8}; int num = 7; System.out.println("Minimum number : " + num); System.out.println(MinNumber.findMinNumber(min, num)); /* * Given such definition of Linked List */ System.out.println("03---------------------------------------"); //Exmple LinkedList is not cyclic, no loop or cycle found LinkedListLoop linkedList = new LinkedListLoop(); linkedList.appendIntoTail(new LinkedListLoop.Node("101")); linkedList.appendIntoTail(new LinkedListLoop.Node("201")); linkedList.appendIntoTail(new LinkedListLoop.Node("301")); linkedList.appendIntoTail(new LinkedListLoop.Node("401")); //System.out.println("Linked List : " + linkedList); if(linkedList.isCyclic()){ System.out.println("Linked List is cyclic as it contains cycles or loop"); }else{ System.out.println("LinkedList is not cyclic, no loop or cycle found"); } //Exmple LinkedList is cyclic LinkedListLoop linkedListLopp = new LinkedListLoop(); linkedListLopp.appendIntoTail(new LinkedListLoop.Node("101")); LinkedListLoop.Node cycle = new LinkedListLoop.Node("201"); linkedListLopp.appendIntoTail(cycle); linkedListLopp.appendIntoTail(new LinkedListLoop.Node("301")); linkedListLopp.appendIntoTail(new LinkedListLoop.Node("401")); linkedListLopp.appendIntoTail(cycle); //System.out.println("Linked List : " + linkedListLopp); if(linkedListLopp.isCyclic()) { System.out.println("Linked List is cyclic as it contains cycles or loop"); }else{ System.out.println("LinkedList is not cyclic, no loop or cycle found"); } /* * Given a list of N people and let h be an unsorted array such that h( i) * is the height of a person i. A person height is between 10cm and 400cm. * If we form everyone in a line in an increasing order based on their height, * what is the height of the middle person in this line? */ System.out.println("04---------------------------------------"); int arrper[] = {130,142,143,153,154,155,166}; ArrayList<Object> person = new ArrayList<Object>(); for(int i=0; i < arrper.length; i++) person.add(arrper[i]); System.out.println("Middle height of " + person + " is " + MiddleHeight.finfMiddleHeight(arrper)); int arrper1[] = {130,142,143,153,154,155,166,177}; ArrayList<Object> person1 = new ArrayList<Object>(); for(int i=0; i < arrper1.length; i++) person1.add(arrper1[i]); System.out.println("Middle height of " + person1 + " is " + MiddleHeight.finfMiddleHeight(arrper1)); /* * Given N total different shirts numbered from 1 to N and a number k of all different baskets (1<=k<=N) */ System.out.println("05---------------------------------------"); System.out.println("2 shirts - 1 basket: " + ShirtBasket.keep(2, 1));// 2 shirts - 1 basket System.out.println("2 shirts - 2 basket: " + ShirtBasket.keep(2, 2));// 2 shirts - 2 basket System.out.println("2 shirts - 3 basket: " + ShirtBasket.keep(2, 3));// 2 shirts - 3 basket System.out.println("2 shirts - 4 basket: " + ShirtBasket.keep(4, 2));// 2 shirts - 4 basket /* * Given an N*N matrix of integers, write code to rotate the matrix */ System.out.println("06---------------------------------------"); int[][] matrix = { {1, 2, 3}, {4,5,6}, {7,8,9}}; System.out.println("Before"); MatrixRotate.print(matrix); System.out.println("After"); MatrixRotate.print(MatrixRotate.rotate(matrix)); /* * Given two sorted integer array, find the Kth smallest element among both arrays */ System.out.println("07---------------------------------------"); int[] array1 = { 2, 9, 15, 22, 24, 25, 26, 30 }; int[] array2 = { 1, 4, 5, 7, 18, 22, 27, 33 }; System.out.println("Kth smallest element is: " + KthSmallest.findKthValue(array1,array2, 6)); /* * Reverse a linked list without recursion */ System.out.println("08---------------------------------------"); System.out.println("Reverse link list not recursion"); ReverseNotRecursion list = new ReverseNotRecursion(); ReverseNotRecursion.Node n1 = new ReverseNotRecursion.Node(1); ReverseNotRecursion.Node n2 = new ReverseNotRecursion.Node(2); ReverseNotRecursion.Node n3 = new ReverseNotRecursion.Node(3); n1._next = n2; n2._next = n3; list.head = n1; list.printV(); list.reverse_all(); list.printV(); /* * Given two unsorted integer array a and b with same size, determine if a is an permutation of b with some solution better than sorting. */ System.out.println("09---------------------------------------"); int[] pArray1 = { 1, 2, 3, 4, 5 }; int[] pArray2 = { 3, 4, 2, 5, 1 }; System.out.println("Permutation 2 arrays: "+ Permutation.isPermutation(pArray1, pArray2)); /* * Given a array of characters, reverse all the words in the array */ System.out.println("10---------------------------------------"); char[] reverArray = "The quick brown fox jumped over lazy old dog.".toCharArray(); System.out.println("Sample: "); for (char tmp : reverArray) { System.out.print(tmp); } System.out.println("\nResult: "); for (char tmp : ReverseWordByWord.reverseChars(reverArray)) { System.out.print(tmp); } }
718fe4f9-a986-4599-831f-18e5ccd0f06b
5
public static BufferedImage getPanel(int w, int h, BufferedImage img) { BufferedImage res = new BufferedImage(w, h, 2); int onew = img.getWidth() / 3; int oneh = img.getHeight() / 3; res.getGraphics().drawImage(img.getSubimage(0, 0, onew, oneh), 0, 0, onew, oneh, null); res.getGraphics().drawImage(img.getSubimage(onew * 2, 0, onew, oneh), w - onew, 0, onew, oneh, null); res.getGraphics().drawImage(img.getSubimage(0, oneh * 2, onew, oneh), 0, h - oneh, onew, oneh, null); res.getGraphics().drawImage(img.getSubimage(onew, oneh, onew * 2, oneh * 2), w - onew, h - oneh, onew, oneh, null); try{res.getGraphics().drawImage(fill(img.getSubimage(onew, 0, onew, oneh), w - onew * 2, oneh), onew, 0, w - onew * 2, oneh, null);}catch(Exception e){} try{res.getGraphics().drawImage(fill(img.getSubimage(0, oneh, onew, oneh), onew, h - oneh * 2), 0, oneh, onew, h - oneh * 2, null);}catch(Exception e){} try{res.getGraphics().drawImage(fill(img.getSubimage(onew, oneh * 2, onew, oneh), w - onew * 2, oneh), onew, h - oneh, w - onew * 2, oneh, null);}catch(Exception e){} try{res.getGraphics().drawImage(fill(img.getSubimage(onew * 2, oneh, onew, oneh), onew, h - oneh * 2), w - onew, oneh, onew, h - oneh * 2, null);}catch(Exception e){} try{res.getGraphics().drawImage(fill(img.getSubimage(onew, oneh, onew, oneh), w - onew * 2, h - oneh * 2), onew, oneh, w - onew * 2, h - oneh * 2, null);}catch(Exception e){} return res; }
881d848c-446a-42c6-b5b5-4f2bb115d8fc
4
public void leftRotate( int d) { int i, j, k, temp; int n = arr.length; int gcd = gcd(d, n); for (i = 0; i < gcd; i++) { /* move i-th values of blocks */ temp = arr[i]; j = i; while (true) { k = j + d; if (k >= n) k = k%n; if (k == i) break; arr[j] = arr[k]; j = k; count++; } arr[j] = temp; count++; } }
ada5c0b2-9304-4bc2-9b1c-ce6b18bb3746
5
@Override public boolean execute(final CommandSender sender, final String[] split) { if (sender instanceof Player) { if (MonsterIRC.getHandleManager().getPermissionsHandler() != null) { if (!MonsterIRC.getHandleManager().getPermissionsHandler() .hasCommandPerms((Player) sender, this)) { sender.sendMessage("[IRC] You don't have permission to preform that command."); return true; } } else { sender.sendMessage("[IRC] PEX not detected, unable to run any IRC commands."); return true; } } if (sender instanceof Player) { sender.sendMessage("Attempting to connect to IRC server!"); } final Thread t = new Thread(connect); t.setPriority(Thread.MAX_PRIORITY); t.setDaemon(false); t.start(); if (sender instanceof Player) { sender.sendMessage("Successfully connected!"); } return true; }
042f0906-0a83-4db8-b0c5-e51d0336a0b8
0
public void getMemento() { Memento memento = (Memento) c.getMemento(); state = memento.getState(); System.out.println("the state is " + state + " now"); }
8f7d84c9-42b2-4b81-99fd-09bb335da418
1
@Test public void fieldFilterIsCaseInsensitive() { citations.add(c1); filter.addFieldFilter("author", "kekkonen"); List<Citation> filtered = filter.getFilteredList(); assertTrue(filtered.contains(c1) && filtered.size() == 1); }
88cd19e5-5abe-4de2-90bd-85b8f5554343
3
private synchronized void invia (String v, int a, int b) throws JMSException { QueueConnection qc =null; QueueSession qs =null; ///prova mess try { qc = qcf.createQueueConnection(); } catch (JMSException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); } catch (JMSException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Prova connessione "); try { this.sender = qs.createSender( altro); } catch (JMSException e) { // TODO Auto-generated catch block e.printStackTrace(); }//manda al rivale CreateMessage Mess = new CreateMessage(this.name, this.room, v, a, b); //STEP Message ObjectMessage j = qs.createObjectMessage(Mess); j.setBooleanProperty("multy", true); j.setJMSReplyTo(que); qc.start(); System.out.println("Invio messaggio a " + altro.toString()); this.sender.send(j); qc.close(); }
612c8092-1786-4ebb-b1e7-d22e3254045d
7
private static Map processJsonAsMap(JsonElement jsonElement, Class<?> mapClass, Class<?> valueClass) throws JsonException, IllegalAccessException, InstantiationException { Map map; if (mapClass.isInterface()) { if (mapClass.isAssignableFrom(HashMap.class)) map = new HashMap(); else throw new JsonException("Unsupported collection type"); } else map = (Map)mapClass.newInstance(); try { Map<String, JsonElement> jsonMap = jsonElement.getData(); if (jsonMap == null) return null; for (Map.Entry<String, JsonElement> entry : jsonMap.entrySet()) map.put(entry.getKey(), getSubObject(jsonElement.get(entry.getKey()), valueClass)); return map; } catch (ClassCastException e) { throw new JsonException("Class Cast Problem: " + e.getMessage()); } }
c79aa20c-5cf7-489f-a9e9-3e38cfe496aa
0
public void setDescription (String d) { description = d; }
a510fa43-e77e-4055-855f-85581e3e92bc
1
@Override public void handleNotOpenEnded( int x, int y ) { if( itemShown ){ parent.removeItem( line ); } itemShown = false; }
0f0d3c57-a1c9-4557-8ae9-11255f2253ef
7
void placeAllShipsRandomly(){ Random generator = new Random(); int randomRow = generator.nextInt(10); int randomCol = generator.nextInt(10); boolean isHorizontal = generator.nextBoolean(); // place the battle ship Battleship battleship = new Battleship(); battleship.setBowRow(randomRow); battleship.setBowColumn(randomCol); battleship.setHorizontal(isHorizontal); while(!battleship.okToPlaceShipAt(randomRow, randomCol, isHorizontal, this)){ randomRow = generator.nextInt(10); randomCol = generator.nextInt(10); isHorizontal = generator.nextBoolean(); } // System.out.println("battleship random row: " + randomRow + "column: " + randomCol); battleship.placeShipAt(randomRow, randomCol, isHorizontal, this); // place two cruisers for(int i = 0; i < 2; i++){ Cruiser cruiser = new Cruiser(); cruiser.setBowRow(randomRow); cruiser.setBowColumn(randomCol); cruiser.setHorizontal(isHorizontal); while(!cruiser.okToPlaceShipAt(randomRow, randomCol, isHorizontal, this)){ randomRow = generator.nextInt(10); randomCol = generator.nextInt(10); isHorizontal = generator.nextBoolean(); } // System.out.println("cruiser random row: " + randomRow + "column: " + randomCol); cruiser.placeShipAt(randomRow, randomCol, isHorizontal, this); } // place three destroyers for(int i = 0; i < 3; i++){ Destroyer destroyer = new Destroyer(); destroyer.setBowRow(randomRow); destroyer.setBowColumn(randomCol); destroyer.setHorizontal(isHorizontal); while(!destroyer.okToPlaceShipAt(randomRow, randomCol, isHorizontal, this)){ randomRow = generator.nextInt(10); randomCol = generator.nextInt(10); isHorizontal = generator.nextBoolean(); } // System.out.println("destroyer random row: " + randomRow + "column: " + randomCol); destroyer.placeShipAt(randomRow, randomCol, isHorizontal, this); } // place four submarine for(int i = 0; i < 4; i++){ Submarine submarine = new Submarine(); submarine.setBowRow(randomRow); submarine.setBowColumn(randomCol); submarine.setHorizontal(isHorizontal); while(!submarine.okToPlaceShipAt(randomRow, randomCol, isHorizontal, this)){ randomRow = generator.nextInt(10); randomCol = generator.nextInt(10); isHorizontal = generator.nextBoolean(); } // System.out.println("submarine random row: " + randomRow + "column: " + randomCol); submarine.placeShipAt(randomRow, randomCol, isHorizontal, this); } }
675993be-cf44-4041-a70d-bbb995337873
8
@Override public void erzeugeAnmeldung(AnmeldungDTO a) { Laeufer provLaeufer = new Laeufer(); Laufveranstaltung provLaufveranstaltung = new Laufveranstaltung(); Verein provVerein = new Verein(); for(int i = 0; i < laeuferList.size(); i++) { provLaeufer = laeuferList.get(i); if(provLaeufer.getNachname().equals(a.getLaeufer().getName()) && provLaeufer.getVorname().equals(a.getLaeufer().getVorname())) { break; } } for(int i = 0; i < laufveranstaltungList.size(); i++) { provLaufveranstaltung = laufveranstaltungList.get(i); if(provLaufveranstaltung.getName().equals(a.getVeranstaltung())) { break; } } for(int i = 0; i < vereinList.size(); i++) { provVerein = vereinList.get(i); if(provVerein.getName().equals(a.getVerein())) { break; } else{ if (i == vereinList.size() - 1) { provVerein = erstelleVerein(new VereinDTO(a.getVerein())); } } } anmeldung = new Anmeldung(); anmeldung.addLaeuferLaufveranstaltung(provLaeufer, provLaufveranstaltung); anmeldung.setVerein(provVerein); anmeldung.setBezahlstatus(a.isBezahlt()); anmeldung.setStartnummer(a.getStartnummer()); anmeldungList.add(anmeldung); log.debug("Anmeldung erzeugt"); }
c0e4c096-e062-442e-a91b-1f008f0b1e47
1
@Override public void handleEvent(Event event) { if (event.getType() == EventType.END_ACTION) endActionUpdate(); }
365cfafb-68af-4a51-b389-ad5b9068814d
5
public final void update(Level level, int x, int y, int z, Random rand) { if(rand.nextInt(4) == 0) { if(!level.isLit(x, y, z)) { level.setTile(x, y, z, DIRT.id); } else { for(int var9 = 0; var9 < 4; ++var9) { int var6 = x + rand.nextInt(3) - 1; int var7 = y + rand.nextInt(5) - 3; int var8 = z + rand.nextInt(3) - 1; if(level.getTile(var6, var7, var8) == DIRT.id && level.isLit(var6, var7, var8)) { level.setTile(var6, var7, var8, GRASS.id); } } } } }
ab09c309-991b-45ea-bf7b-95dab6cad4e0
0
public int run(){ sort(aInt); return 0; }
8ee1c83e-ed16-4290-9941-d7729c9ca702
8
@Override public void run() { resetFlags(); try { this.in = this.socket.getInputStream(); // attempt to start a WebSocket session - failure caught in error handler String responseString = startSession(in); sendResponse(responseString); // the main connection loop takes the remaining message input while(true) { parseFrame(); // close out of the loop if we are to close the WebSocket if (closing) { System.out.println("Closing WebSocket"); sendResponse(response); break; } // if this is the last frame of the message; return the response and then // reset flags for new message if (FIN) { if (controlFrame) { WSControlHandler.respond(this); } else { server.handler.response(this); // System.out.println(new String(response.getResponse())); System.out.println("Reset all flags as we've received the last frame of the current message."); resetFlags(); } } } } catch (SWSSException swssue) { // the HTTP Upgrade failed System.out.println("Upgrade Error: " + swssue.getMessage()); } catch (IOException ioe) { // anything System.out.println("ERROR: " + ioe.getMessage()); } catch (InterruptedException ie) { System.out.println("InterruptedException: " + ie.getMessage()); } catch (Exception e) { System.out.println(e.getMessage()); } System.out.println("Shutting down the request"); this.server.handler.onClose(this); }
347d34c5-9e41-4057-967c-a22f0821dc0a
2
public Builder staffRepository(Repository respository) { // If we didn't get a repository, do nothing. if (respository == null) { return this; } if (message.staffRepositoryList == null) { message.staffRepositoryList = new ArrayList<Repository>(); } message.staffRepositoryList.add(respository); return this; }
f651e6df-b6fd-402c-9d5c-e4522a26f124
0
public static void flipCell(JCellule[][] grid, int x, int y, JLabel lblGeneration, JButton btnProchaineGeneration) { ControllerGrille.grid.flipCell(x, y); synchroniser(grid, lblGeneration, btnProchaineGeneration); }
4b4cf273-2ec7-4cd3-b603-524d124ed11a
6
public static int findNumYouIs(String content) { int result = 0; if (content != null && !content.equals("")) { ArrayList<String> sentences = findSentences(content); for (String sentence : sentences) { if (sentence.contains("IMHO")) result += countNumberOfOccurence(sentence, "IMHO"); if (sentence.contains("IMO")) result += countNumberOfOccurence(sentence, "IMHO"); result += countNumberOfOccurence(sentence, "I"); sentence = sentence.toLowerCase(); if (sentence.contains("you")) result += countNumberOfOccurence(sentence, "you"); } } return result; }
1ea58253-950d-40ca-94b6-211c0e79c487
5
public static String convertPatternExtractBracketedExpression( String pattern ) { String[] s = pattern.split( "\\[" ); if( s.length > 1 ) { pattern = ""; for( String value : s ) { int zz = value.indexOf( "]" ); if( zz != -1 ) { String term = ""; if( value.charAt( 0 ) == '$' ) { term = value.substring( 1, zz ); // skip first $ } else { term = value.substring( 0, zz ); } if( term.indexOf( "-" ) != -1 ) // extract character TODO: locale specifics { pattern += term.substring( 0, term.indexOf( "-" ) ); } else { pattern += term; } } pattern += value.substring( zz + 1 ); } } return pattern; }
bff1b356-00de-4d9e-a62a-51c721a9cef9
5
@Override public void doChangeBrightness(int brightnessAmountNum) { if (imageManager.getBufferedImage() == null) return; WritableRaster raster = imageManager.getBufferedImage().getRaster(); for (int x = 0; x < raster.getWidth(); x++) { for (int y = 0; y < raster.getHeight(); y++) { double[] pixel = new double[3]; raster.getPixel(x, y, pixel); if (pixel[0] + brightnessAmountNum > 255) pixel[0] = 255; else if (pixel[0] + brightnessAmountNum < -255) pixel[0] = -255; else pixel[0] += brightnessAmountNum; pixel[1] = pixel[0]; pixel[2] = pixel[0]; raster.setPixel(x, y, pixel); } } GUIFunctions.refresh(); }
6a0d4bad-4912-4f63-9734-adcc65e8a4b8
1
@Override public void copyDifferentItemsToRightList() throws RemoteException { try { toList.addItems(fromList.getWorkingDirectory(), fromList.getDifferentItems(toList)); } catch (IOException ex) { throw new RuntimeException(ex); } }
78c07f58-c799-4edc-9985-a5e735e59f6b
9
@Override public boolean envelopesPoint(double xx, double yy) { return (((a > 0 && (xx >= x && yy >= y)) && (xx <= x + a) && (yy <= y + a)) || ((a < 0 && (xx <= x && yy <= y)) && (xx >= x + a) && (yy >= y + a))); }
c6c2f42c-a322-428f-83d8-88a286010923
1
public boolean matches( Class<?> clazz ) { return clazz.isAnnotationPresent( this.annotationType ); }
b848a115-b227-43b9-a061-95a26ac6623f
6
final public UpdateCommand Update() throws ParseException { String tableName; List<AttributeAssign> attrAssgs = new ArrayList<AttributeAssign>(); String condition = ""; AttributeAssign attrAssg; jj_consume_token(KW_UPDATE); tableName = getTokenImage(); jj_consume_token(KW_SET); attrAssg = AttributeAssg(); attrAssgs.add(attrAssg); label_8: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 51: ; break; default: jj_la1[18] = jj_gen; break label_8; } jj_consume_token(51); attrAssg = AttributeAssg(); attrAssgs.add(attrAssg); } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case KW_WHERE: jj_consume_token(KW_WHERE); condition = Expression(); break; default: jj_la1[19] = jj_gen; ; } {if (true) return new UpdateCommand(tableName, attrAssgs, condition);} throw new Error("Missing return statement in function"); }
c7aa371f-26cd-42e2-95fd-336ee7e54350
9
private void assertTagValue(JsonObject node, String propertyName, String value) throws XPathExpressionException { List<JsonElement> list = new ArrayList<>(); if (propertyName.startsWith("/")) { findJsonElementsPath(node, propertyName.substring(1).split("/"), list); } else { findJsonElementsProp(node, propertyName, list); } if (list.isEmpty()) { fail("Property '" + propertyName + "' no found in the document"); } else { for (JsonElement elem : list) { if (elem instanceof JsonPrimitive) { if (value.equals(((JsonPrimitive) elem).getAsString())) { return; } } else if (elem instanceof JsonArray) { JsonArray elemArray = (JsonArray) elem; for (JsonElement arrayElem : elemArray) { if (arrayElem instanceof JsonPrimitive) { if (value.equals(((JsonPrimitive) arrayElem).getAsString())) { return; } } } } } fail("There is no tag '" + propertyName + "' with value '" + value + "'"); } }
56fb09da-6327-489f-ad7f-fb9d222ad9dc
9
@Override protected void processClasspathResources(List<ClasspathResource> classpathResources) { updateStatus("Searching for overlaping jars"); List<JarPair> overlapReportLines = scanner.findOverlappingJars(classpathResources, false); for (JarPair overlapPair : overlapReportLines) { Json jsonObject = new Json(); jsonObject.setProperty("jar1", overlapPair.getJar1().getUrl()); jsonObject.setProperty("jar2", overlapPair.getJar2().getUrl()); jsonObject.setProperty("dupsTotal", overlapPair.getDupClassesTotal().toString()); String json = jsonObject.stringify(); System.out.println("#OVERLAP_JARS# " + json); } System.out.println("#SUMMARY_FINISHED#"); if (isReportClassFileDuplicatesOn) { updateStatus("Searching for class file duplicates"); List<ClasspathResource> classFilesWithDuplicates = scanner.findClassFileDuplicates(classpathResources, false); // class file duplicates report for (ClasspathResource classFile : classFilesWithDuplicates) { Matcher matcher = FILE_NAME.matcher(classFile.getName()); if (matcher.matches()) { String packageName = matcher.group(1); String className = matcher.group(2); if (packageName != null) { packageName = packageName.replaceAll("/", "\\."); } Json jsonObject = new Json(); jsonObject.setProperty("packageName", packageName); jsonObject.setProperty("className", className); jsonObject.setProperty("numberOfVersions", "" + classFile.getNumberOfVersions()); String json = jsonObject.stringify(); System.out.println("#DUPLICATE_CLASS# " + json); } else { logger.error("could not process " + classFile.getName()); } } for (ClasspathResource classFile : classFilesWithDuplicates) { for (ClasspathResourceVersion resourceVersion : classFile.getResourceFileVersions()) { String fileFullPathName = classFile.getName(); String classpathEntry = resourceVersion.getClasspathEntry().getUrl(); if (classpathEntry != null) { Matcher matcher = JAR_NAME.matcher(classpathEntry); if (matcher.matches()) { classpathEntry = matcher.group(1); } } long size = resourceVersion.getFileSize(); Json json = new Json(); json.setProperty("size", Long.toString(size)); json.setProperty("file", fileFullPathName); json.setProperty("entry", classpathEntry); System.out.println("#DETAIL# " + json.stringify()); } } } }
33f1d570-a4f5-49e7-b70c-f240b1ad16f9
7
private String DDCRET_String(int retcode) { switch ( retcode ) { case DDC_SUCCESS: return "DDC_SUCCESS"; case DDC_FAILURE: return "DDC_FAILURE"; case DDC_OUT_OF_MEMORY: return "DDC_OUT_OF_MEMORY"; case DDC_FILE_ERROR: return "DDC_FILE_ERROR"; case DDC_INVALID_CALL: return "DDC_INVALID_CALL"; case DDC_USER_ABORT: return "DDC_USER_ABORT"; case DDC_INVALID_FILE: return "DDC_INVALID_FILE"; } return "Unknown Error"; }
6eca562c-34ff-46ed-93fa-e2a5e67f5fdf
0
public Tool(AutomatonPane view, AutomatonDrawer drawer) { this.view = view; this.drawer = drawer; automaton = drawer.getAutomaton(); }
4fce99ed-fef4-4fe0-80a0-ce31ae9ed925
2
private int signOf(double x) { if (x > 0.1) return 1; else if (x < -0.1) return -1; else return 0; }
be5b80e3-94c8-4898-a965-ead37f7a6661
0
public Period getDepartureTime() { return this._departureTime; }
984f3ea9-19d4-458d-8778-a2e267f5681f
5
private void boutonAsgardMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boutonAsgardMouseClicked // TODO add your handling code here: if (partie.getAs().isActif()) { if (!partie.getDieuActuel().isaJouerEnAsgard() || ((partie.getDieuActuel().getNom().compareTo("Freyja") == 0 && ((Freyja) partie.getDieuActuel()).getaJouerEnAsgard() < 2)&&Dieu.pouvoirDieu)) { partie.jouerAsgard(page); verifFinTour(); } else { JOptionPane.showMessageDialog(page, "Vous avez déjà joué dans ce monde", "Yggdrasil", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(page, "Un géant bloc l'accés à ce monde", "Yggdrasil", JOptionPane.INFORMATION_MESSAGE); } }//GEN-LAST:event_boutonAsgardMouseClicked
66564e47-2129-4618-890e-da713fea133a
5
public static boolean driveDistance(double distance) { if (!encoderInit) { resetEncoders(); currentDistance = 0.0; encoderInit = true; } if (distance > 0) { while (currentDistance < distance) { currentDistance = getEncoderAverage(); return false; } } else if (distance < 0) { while (currentDistance > distance) { currentDistance = getEncoderAverage(); return false; } } return true; }
013bd1bf-fa9f-433e-abfa-a5b0871163ca
4
public Partie() { lstJoueurs = new LinkedList<Joueur>(); peuplesPris = new LinkedList<Class<? extends Peuple>>(); peuplesDispo = new LinkedList<Class<? extends Peuple>>(); pouvoirsPris = new LinkedList<Class<? extends Pouvoir>>(); pouvoirsDispo = new LinkedList<Class<? extends Pouvoir>>(); argentPeuple = new LinkedList<Integer>(); initPeuples(); initPouvoirs(); }
06fc165f-4c22-457d-a775-da313f5fb881
4
public boolean setFile(String file) { boolean test = false; if (test || m_test) { System.out.println("FileManager :: setFile() BEGIN"); } m_inFile = new File(this.m_path + file); if (test || m_test) { System.out.println("FileManager :: setFile() END"); } return true; }
da838bb8-74df-463c-8f69-dc9f7456e5d9
1
public Types getObjectType(String name) { int index; if((index = ObjectNames.indexOf(name)) != -1) { return ObjectType.get(index); } return null; }
978240d1-4876-4a01-940e-6e7120bff406
5
public void initRGBbyHSL( int H, int S, int L ) { int Magic1; int Magic2; pHue = H; pLum = L; pSat = S; if( S == 0 ) { //Greyscale pRed = (L * RGBMAX) / HSLMAX; //luminescence: set to range pGreen = pRed; pBlue = pRed; } else { if( L <= (HSLMAX / 2) ) { Magic2 = ((L * (HSLMAX + S)) + (HSLMAX / 2)) / (HSLMAX); } else { Magic2 = L + S - ((L * S) + (HSLMAX / 2)) / HSLMAX; } Magic1 = 2 * L - Magic2; //get R, G, B; change units from HSLMAX range to RGBMAX range pRed = ((hueToRGB( Magic1, Magic2, H + (HSLMAX / 3) ) * RGBMAX) + (HSLMAX / 2)) / HSLMAX; if( pRed > RGBMAX ) { pRed = RGBMAX; } pGreen = ((hueToRGB( Magic1, Magic2, H ) * RGBMAX) + (HSLMAX / 2)) / HSLMAX; if( pGreen > RGBMAX ) { pGreen = RGBMAX; } pBlue = ((hueToRGB( Magic1, Magic2, H - (HSLMAX / 3) ) * RGBMAX) + (HSLMAX / 2)) / HSLMAX; if( pBlue > RGBMAX ) { pBlue = RGBMAX; } } }
86b16b89-58b5-44a1-8ced-1939ef63021d
9
public static void stopServer() { // TODO Fix bug, server not sending message to all clients //send message to clients informing them of server shutdown try { for(int a = 0; a < clients.size(); a++) { //System.out.println("Exit: " + clients.elementAt(a).setServerMessage("ServerShutdown"); for(int b = 0; b < clients.size(); b++) { //System.out.println("Exit: " + clients.elementAt(b).setServerMessage("ServerShutdown"); for(int c = 0; c < clients.size(); c++) { //System.out.println("Exit: " + clients.elementAt(c).setServerMessage("ServerShutdown"); } for(int c = 0; c < clients.size(); c++) { //System.out.println("Exit: " + clients.elementAt(c).setServerMessage("ServerShutdown"); } } } registry.unbind("WhiteboardServer"); System.exit(0); }catch (ArrayIndexOutOfBoundsException e) { //e.printStackTrace(); } catch (AccessException e) { //e.printStackTrace(); } catch (RemoteException e) { //e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (NotBoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
088ecf49-a763-494f-afe9-90ce4c18cae5
5
public void checkValid(Loader l) throws InterruptedException { boolean test = false; if (test || m_test) { System.out.println("ControlButtonListener :: " + "checkValid() BEGIN"); } if (l.getValid()) { m_game.getGrid().setGrid(l.getGridArray()); m_game.setPlayer1(l.getPlayer1()); m_game.setPlayer2(l.getPlayer2()); setVisible(false); m_game.resumeGame(); getGame().startTimer(l.getTimer()); } else { JOptionPane.showMessageDialog(player, "ERROR Loading File", "Load ERROR", JOptionPane.ERROR_MESSAGE); dispose(); new GameSelecter(); } if (test || m_test) { System.out.println("ControlsButtonListener :: " + "checkValid() END"); } }
cb4ea0d7-a71c-40c1-bcaa-9aca5b5e7814
4
private void asetaKimmotusehto(Pelihahmo h){ if (0 > h.getMinX() || kentanLeveys < h.getMaxX()){ setEhtoX(h, getEhtoX(h)+1); } else { setEhtoX(h, 0); } if (0 >= h.getMinY() || kentanKorkeus <= h.getMaxY()){ setEhtoY(h, getEhtoY(h)+1); } else { setEhtoY(h, 0); } }
a93ef3f8-4f6f-4ffb-8bb3-a8e39ff72a2c
4
public int isGameOver () { if (gameover!=NOPLAYER) return gameover; // cached value switch (neutron_x) { case 1: gameover=BLACK; break; case 5: gameover=WHITE; break; default: if (!canNeutronMove()) { gameover=whoDidLastMove(); break; } gameover=NOPLAYER; } return gameover; }
31ffcb42-d017-464e-bc0d-42adbd3fbcd1
4
public FilesWatcher(int periodInSec) { period = periodInSec * 1000; timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { List<File> hasChanged = new ArrayList<File>(); synchronized (LOCK_WATCHERS) { for (FileWatcher watcher : watchers) { if (watcher.hasChanged()) hasChanged.add(watcher.getFile()); } } // - Not synchronized in order to avoid dead locks if (!hasChanged.isEmpty()) { File[] changedFiles = new File[hasChanged.size()]; changedFiles = hasChanged.toArray(changedFiles); for (FilesWatcherListener t : listeners) { t.fileModified(new FilesWatcherEvent(changedFiles)); } } } }, 10000, period); }
be8668f4-1c26-43b8-8cfe-2c2fbc2e2d6a
0
public int getComboMonth() { return combo2.getSelectedIndex(); }
6ef596c4-450a-4f9e-838c-e62a02aa309a
4
public int bestAction() { int selected = -1; double bestValue = -Double.MAX_VALUE; for (int i=0; i<children.length; i++) { if(children[i] != null) { //double tieBreaker = m_rnd.nextDouble() * epsilon; double childValue = children[i].totValue / (children[i].nVisits + this.epsilon); childValue = Utils.noise(childValue, this.epsilon, this.m_rnd.nextDouble()); //break ties randomly if (childValue > bestValue) { bestValue = childValue; selected = i; } } } if (selected == -1) { System.out.println("Unexpected selection!"); selected = 0; } return selected; }
c2a3fc8d-f4ad-489e-af6b-031c923545b5
8
protected PseudoSequenceBIDE trimBeginingAndEnd(Position positionStart, Position positionEnd){ int itemsetStart = 0; int itemStart =0; int itemsetEnd=lastItemset; int itemEnd=lastItem; if(positionStart != null){ // where the cut starts itemsetStart = positionStart.itemset; itemStart = positionStart.item + 1; if(itemStart == getSizeOfItemsetAt(itemsetStart)){ itemsetStart++; itemStart =0; } if(itemsetStart == size()){// the resulting sequence is empty! return null; } } if(positionEnd != null){ // We cut the right part itemEnd = positionEnd.item -1; itemsetEnd = positionEnd.itemset; if(itemEnd<0){ itemsetEnd = positionEnd.itemset -1; if(itemsetEnd < itemsetStart){ return null; } itemEnd = getSizeOfItemsetAt(itemsetEnd)-1; } } // Check if the end is not before the beginning of the sequence! if(itemsetEnd == itemsetStart && itemEnd < itemStart){ // System.out.println("TEST"); return null; } return new PseudoSequenceBIDE(this, itemsetStart, itemStart, itemsetEnd, itemEnd); }
8ebcab7b-565d-4942-ba25-0913b52c6591
1
@Test public void removeHousehold() throws InstanceNotFoundException, ParseException, DuplicateInstanceException { Household hh = familyService.findHousehold(0); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); Calendar cal3 = Calendar.getInstance(); cal3.setTime(sdf.parse("12/03/2006")); Student student = new Student(hh, "Alejandro", "Fortes", Student.Category.PRIMARIA, cal3, new HashSet<Activity>(), new HashSet<Booking>()); familyService.createStudent(student); familyService.removeHousehold(hh.getBanckAccount()); try { familyService.findHousehold(hh.getBanckAccount()); } catch (InstanceNotFoundException e) { assertTrue(true); } }
c2b9e7ca-8613-426b-bfde-7fdcca87257e
7
public String getDayOfWeekName(Integer dayOfWeek){ switch (dayOfWeek){ case 1: return "Sun"; case 2: return "Mon"; case 3: return "Tue"; case 4: return "Wed"; case 5: return "Thu"; case 6: return "Fri"; case 7: return "Sat"; default: return "ERROR"; } }
af0d7cc8-2d1d-4719-a72f-4e1791ed860e
7
private String formatNodes(ViterbiNode[][] startsArray, ViterbiNode[][] endsArray) { this.nodeMap.clear(); this.foundBOS = false; StringBuilder sb = new StringBuilder(); for (int i = 1; i < endsArray.length; i++) { if(endsArray[i] == null || startsArray[i] == null) { continue; } for (int j = 0; j < endsArray[i].length; j++) { ViterbiNode from = endsArray[i][j]; if(from == null){ continue; } sb.append(formatNodeIfNew(from)); for (int k = 0; k < startsArray[i].length; k++) { ViterbiNode to = startsArray[i][k]; if(to == null){ break; } sb.append(formatNodeIfNew(to)); sb.append(formatEdge(from, to)); } } } return sb.toString(); }
ee2bb193-d9e8-4af1-9027-a949632eabef
7
public void createDirectedGraph() { for(String word1 : parseUtil.getFeatureWordSet()) { Map<String, Double> rowMap = new HashMap<String, Double>(); for (String word2 : parseUtil.getFeatureWordSet()) { rowMap.put(word2, 0.0); } directedGraph.put(word1, rowMap); } Iterator iterator = parseUtil.getTweetWordList().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry mapEntry = (Map.Entry) iterator.next(); Set<String> tweetSet = (Set<String>) mapEntry.getValue(); for (String word1 : tweetSet) { Map<String, Double> rowMap = directedGraph.get(word1); Double rowCount = 0.0; for (String word2 : tweetSet) { if (!word1.equals(word2)) { rowMap.put(word2, rowMap.get(word2) + 1.0); rowCount = rowCount + 1; } } directedGraph.put(word1, rowMap); rowTotalMap.put(word1, rowTotalMap.containsKey(word1) ? rowTotalMap.get(word1) + rowCount : rowCount); } } }
d54f0bbc-0916-421e-8055-1229d0272fe2
9
public void writeBlocks(DAWG graph) throws IOException { // use heuristic to estimate number of blocks // estimated overhead of 15 and 25KB / block target size int blockNumber = graph.text.length() / 1000 * 15 / 25; if (blockNumber < 100) { blockNumber = 100; } int threshhold = (graph.size() / blockNumber) + 1; LinkedList<Integer> blockNumbers = new LinkedList<Integer>(); for (int i = 1; i <= blockNumber; i++) { blockNumbers.add(i); } Collections.shuffle(blockNumbers, new SecureRandom()); // important: Graph needs to implements a depth-first iterator! int nodesInBlock = threshhold; ArrayList<Block> blockList = new ArrayList<Block>(); int block = -1; for (Node n : graph) { if (n != graph.source) { if (nodesInBlock == threshhold) { // draw new block number and write blockArray if (block != -1) { // this is the first run, dont write anything backend.writeBlockArray(blockList, block); blockList.clear(); } block = blockNumbers.pop(); nodesInBlock = 0; } Block b = new Block(n.getNumOccurs()); n.setBlock(block); n.setIndex(nodesInBlock); for (char c : n.getEdges()) { int targetBlock = n.getEdge(c).getBlock(); int targetIndex = n.getEdge(c).getIndex(); b.addEdge(new Edge(c, targetBlock, targetIndex)); } if (n == graph.source) { // make sure that the root node is always on position 0 blockList.add(0, b); } else { blockList.add(b); } nodesInBlock++; } } // write last block backend.writeBlockArray(blockList, block); // write source node to block 0 Block b = new Block(0); for (char c : graph.source.getEdges()) { b.addEdge(new Edge(c, graph.source.getEdge(c).getBlock(), graph.source.getEdge(c).getIndex())); } backend.writeBlock(b, 0); }
8651f201-3448-4701-96ff-cf920b328c0d
1
public static double processLightHouse(LightHouse lightHouse) { long timeStart = System.currentTimeMillis(); while (!lightHouse.canBeLifted()) { //Random balloon with diameter 20..30 cm and fullness 80..100% Balloon b = Balloon.getRandomBalloon(0.10, 0.15, 0.8, 1.0); lightHouse.addBalloon(b); } long timeFinish = System.currentTimeMillis(); long execTime = timeFinish - timeStart; return execTime; }
b134d5d5-7eaf-4f2e-90bf-ce90aa9be119
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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ new Login().setVisible(true); }
de363ba0-6fcd-4f1c-98f4-29354265035a
8
private String getUpdatedTokenWithAlias(final String querySchema, final String tableName, final String fieldToken, final String aliasBefore, final String aliasAfter) { if (fieldToken.lastIndexOf(SQLFormatter.DOT) != -1) { final boolean isAggrToken = isAggregateToken(fieldToken); final String[] split = fieldToken.split("\\" + SQLFormatter.DOT); final String aggrToken; final String tableNameOfToken; final String fieldOfToken; final String schema; if (split.length == 3) { schema = querySchema; } else { schema = null; } boolean appendAggrTokenSpace = false; if (schema != null) { if (isAggrToken) { aggrToken = split[0].split("\\(")[0]; } else { aggrToken = null; } tableNameOfToken = split[1]; fieldOfToken = split[2]; } else { if (isAggrToken) { final String[] functionSplit = split[0].split("\\("); aggrToken = functionSplit[0]; tableNameOfToken = functionSplit[1]; appendAggrTokenSpace = tableNameOfToken.startsWith(" "); } else { tableNameOfToken = split[0]; aggrToken = null; } fieldOfToken = split[1]; } if (isTableAliasMatches(aliasBefore, tableName, tableNameOfToken)) { String updatedToken = ""; if (aggrToken != null) { updatedToken = aggrToken + "("; if (appendAggrTokenSpace) { updatedToken = updatedToken + " "; } } return updatedToken + aliasAfter + SQLFormatter.DOT + fieldOfToken; } } return null; }
94b7550c-b46e-4e59-af53-48ed2c262661
2
@Override public boolean canMove(Board board, Field currentField, Field emptyField) { return this.validSetupForMove(currentField, emptyField) && this.inSameRankOrFile(currentField, emptyField) && board.clearPathBetween(currentField, emptyField); }
6f9f9ccd-dada-4fa6-a037-4669e5562819
9
private void afficherFixerCoefficient() { System.out.println("Fixer un coefficient."); System.out.println("Liste de vos modules :"); Professeur professeur = (Professeur) this.modeleApplication.getCurrent(); ArrayList<Module> modules = this.universite.getModulesParProfesseur(professeur); if (modules.isEmpty()) { System.out.println("Vous n'avez aucun module"); try { Thread.currentThread().sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(BatchProfesseur.class.getName()).log(Level.SEVERE, null, ex); } this.afficherMenuPersonnel(); } for (int i = 0; i< modules.size(); i++) { System.out.println(i+1+"- "+modules.get(i).getCode()); } System.out.println("Pour quel module souhaitez vous fixer un coefficient ?"); int indice = scan.nextInt(); if (indice < 1 || indice > modules.size()+1) { System.out.println("Cet indice n'est pas bon. Retour au choix de module."); this.afficherFixerCoefficient(); } System.out.println("Liste de vos modules : "); System.out.println("1- Coefficient du module"); System.out.println("2- Coefficient du CM"); System.out.println("3- Coefficient du TD"); System.out.println("4- Coefficient du TP"); System.out.println("Quel modules souhaitez vous modifier ?"); // On recupere le type qu'on souhaite modifier int type = scan.nextInt(); if (type < 1 || indice > 4) { System.out.println("Cet indice n'est pas bon. Retour au choix de module."); this.afficherFixerCoefficient(); } // On recupere le coefficient a ajouter System.out.println("Quel est le coefficient ?"); int coefficient = scan.nextInt(); if (coefficient < 0) { System.out.println("Cet indice n'est pas bon. Retour au choix de module."); this.afficherFixerCoefficient(); } Boolean result = this.modeleApplication.setCoefficient(modules.get(indice-1), coefficient, type); if (!result) { System.out.println("Une erreur est survenue. Retour au choix de module."); this.afficherFixerCoefficient(); } this.afficherMenuPersonnel(); }
7152a009-9a40-4bb3-bed5-70f2275cd3c7
8
protected boolean update(SunFishFrame parent, display.DisplayData displayData) { title = displayData.getFileName(); doc = (Document)(displayData.getData(0)); Node documentRoot = doc.getDocumentElement(); DefaultMutableTreeNode treeRoot = addTreeNodes(documentRoot); tree = new JTree(treeRoot); tree.setCellRenderer(new XMLTreeCellRenderer()); this.setLayout(new BorderLayout()); boolean isLamarc = false; if ( ((TreeNodeElement)treeRoot.getUserObject()).getNameText().equalsIgnoreCase("lamarc") || doc.getFirstChild().getNodeName().equalsIgnoreCase("lamarc") ) isLamarc = true; else { //Scan all top-level nodes to see if there's some any have 'lamarc' in the name DefaultMutableTreeNode node = (DefaultMutableTreeNode)treeRoot.getFirstChild(); while (node != null && isLamarc==false) { isLamarc = ((TreeNodeElement)node.getUserObject()).getNameText().equalsIgnoreCase("lamarc"); node = node.getNextSibling(); } } if (isLamarc) { Object[] options = {"Display sequences", "Display xml", "Display both"}; int n = JOptionPane.showOptionDialog(parent, "This LAMARC file may have embedded sequences, would you like to display the sequences?", "LAMARC file detected", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, //do not use a custom Icon options, //the titles of buttons options[0]); if (n==0) { displayLamarcSequences(doc); return false; //Don't display this display } if (n==1) { scrollPane = new JScrollPane(tree); add(scrollPane, BorderLayout.CENTER); GenericXMLSummary xmlSummary = new GenericXMLSummary(this); xmlSummary.analyze(displayData.getFileName(), doc); parent.displayOutput(xmlSummary); this.repaint(); } if (n==2) { displayLamarcSequences(doc); scrollPane = new JScrollPane(tree); add(scrollPane, BorderLayout.CENTER); GenericXMLSummary xmlSummary = new GenericXMLSummary(this); xmlSummary.analyze(displayData.getFileName(), doc); parent.displayOutput(xmlSummary); this.repaint(); } } else { scrollPane = new JScrollPane(tree); add(scrollPane, BorderLayout.CENTER); GenericXMLSummary xmlSummary = new GenericXMLSummary(this); xmlSummary.analyze(displayData.getFileName(), doc); parent.displayOutput(xmlSummary); this.repaint(); } return true; }
a2474643-11ff-4208-bfa9-41e36e4a67f8
9
public void add(DimensionValueCollection o, Long TimeStamp, InfoStored type) { if(size() == CAPACITY && !containsKey(TimeStamp)) { Iterator <Long> i = keySet().iterator(); Long oldest = i.next(); while(i.hasNext()) { Long check = i.next(); if(check < oldest) oldest = check; } remove(oldest); } EnumMap <InfoStored, DimensionValueCollection> e; if(!containsKey(TimeStamp)) e = new EnumMap <InfoStored,DimensionValueCollection> (InfoStored.class); else e = super.get((Object)TimeStamp); switch(type) { case PERFORMED_ACTION: e.put(InfoStored.PERFORMED_ACTION, o); break; case CURRENT_STATE: e.put(InfoStored.CURRENT_STATE, o); break; case NEW_STATE: e.put(InfoStored.CURRENT_STATE, o); } if(e.size() > 0) put(TimeStamp, e); }
7bdd4e09-91e0-4f09-9d30-300738085026
5
private static void read(int[] symbols, FileReader reader) throws IOException { int c; while ((c = reader.read()) != -1) { if (c - 'a' < 26 && c - 'a' >= 0) { symbols[c - 'a']++; } else { if (c - 'A' < 26 && c - 'A' >= 0) { symbols[c - 'A']++; } } } }
31829023-c5cc-4e77-92ca-be8b395950c3
6
public static void exportProcess(){ BufferedWriter file =null; String nameFile = "UsiExportQuartier"; try{ File dir = new File("export"); dir.mkdirs(); FileWriter fileWriter = new FileWriter("export\\" + nameFile + ".csv"); file = new BufferedWriter(fileWriter); file.write("Id : "); file.write("Nom : "); file.write("Description : "); file.write("Responsable : "); file.write("Responsable suppléant : "); file.write("Date de début : "); file.write("Date de fin : "); file.write("Zone : "); file.write("Liste d'ilot : "); file.newLine(); for(myObject.Process p : data.IHM.DataIHM.getListAllProcess()){ if(p.getName().equals("__Aucun") == false){ file.write(Integer.toString(p.getId())); file.write(" : "); file.write(objectValue(p.getName())); file.write(" : "); file.write(objectValue(p.getDescription())); file.write(" : "); file.write(objectValue(p.getResponsible())); file.write(" : "); file.write(objectValue(p.getResponsibleDeputy())); file.write(" : "); file.write(objectValue(p.getValidFrom())); file.write(" : "); file.write(objectValue(p.getValideUntil())); file.write(" : "); file.write(objectValue(p.getSegment())); file.write(" : "); for(Capability c : p.getListCapability()){ file.write(objectValue(c)); System.out.println(objectValue(c)); file.write(";"); } file.newLine(); } } }catch(IOException err){ err.toString(); } finally{ try { if(file != null) file.close(); } catch (IOException err) { err.getMessage(); } } }
4acb95aa-55b2-49f8-8e55-fabfe545031a
3
private List<Movement> listPositionsToMove(Player player) { if (player == null) throw new IllegalArgumentException("Player can't be null!"); List<Movement> possibleMovements = new ArrayList<Movement>(); for (Movement move : Movement.values()) { if (grid.canMove(player, move)) possibleMovements.add(move); } return possibleMovements; }
aad8cd98-4fbe-4187-81d5-b9f4c737cffd
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Route other = (Route) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; }
3e16e8cd-9e8b-4879-af8d-b550d085196b
2
public Lexicon(boolean stressSensitive, boolean trace, boolean useTrust, boolean useProbMem, boolean useNorm, double probAmount, double decayAmount, SubSeqCounter counter) { this.stressSensitive = stressSensitive; this.trace = trace; this.useTrust = useTrust; this.NORMALIZATION = useNorm; this.counter = counter; // Set up probabilistic memory this.useProbMem = useProbMem; this.probAmount = useProbMem ? probAmount : 0.0; // Other constants this.initScore = INIT_SCORE; this.smoothingMin = SMOOTHING_MIN; this.unknownWordScore = UNKNOWN_WORD_SCORE; // Set up decay on words if (decayAmount != 0.0) { Word.setDecay(true, decayAmount); } lexicon = new THashMap<String, Word>(); time = 1; numTokens = 0; rand = new Random(0); }
3ea3fe9d-7b4e-4d58-af4d-0338158d444e
0
public String getSaveEncoding() { return saveEncoding; }
a32cd027-deac-4fc6-9dc9-6ce8bbaed676
2
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); System.out.println("desde NEXT"); String salir = request.getParameter("salir"); String newsC = request.getParameter("newsC"); String nextJSP; nextJSP = "/indexOld.jsp"; if(salir != null){ session.invalidate(); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP); dispatcher.forward(request, response); System.out.println("adios"); } else if(newsC != null){ // CONSULTA PUBLICA nextJSP = "/clientePub.jsp"; RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP); dispatcher.forward(request, response); } else { // Usuario user = (Usuario) session.getAttribute("user"); // System.out.println("user.getCompleteName() = " + user.getCompleteName()); // NUEVO doPost(request, response); //HABIA /* if(user != null){ doPost(request, response); // nextJSP = "/frameset.jsp"; } else { //usuario nulo RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP); dispatcher.forward(request, response); }*/ } }
f7eae596-7b24-40d2-8726-5b7f06d907b7
2
public void printOriginalGraph() { int vertex = 0; int neighbor = 0; int edge = 0; Iterator<Integer> it = originalGraph.keySet().iterator(); while (it.hasNext()) { vertex = it.next(); System.out.print(vertex + ":"); HashMap<Integer, Integer> neighbors = originalGraph.get(vertex); Iterator<Integer> innerIt = neighbors.keySet().iterator(); while (innerIt.hasNext()) { neighbor = innerIt.next(); edge = neighbors.get(neighbor); System.out.print("(" + neighbor + "," + edge + ") "); } // System.out.println(); } }
612776d6-94b7-4be3-a64a-3a03a2dc6da3
5
static final void method701(Class273 class273, int i, int i_0_) { ClientScript class348_sub42_sub19 = Class153.method1223(i, i_0_, 96837648, class273); if (class348_sub42_sub19 != null) { anIntArray1164 = (new int [((ClientScript) class348_sub42_sub19).anInt9688]); aStringArray1155 = (new String [((ClientScript) class348_sub42_sub19).anInt9689]); if ((((ClientScript) class348_sub42_sub19).aClass273_9691 == Class90.aClass273_1512) || (((ClientScript) class348_sub42_sub19) .aClass273_9691) == Class59_Sub1_Sub2.aClass273_8664 || (((ClientScript) class348_sub42_sub19) .aClass273_9691) == IsaacCipher.aClass273_1298) { int i_1_ = 0; int i_2_ = 0; if (Class168.aClass46_2249 != null) { i_1_ = ((Widget) Class168.aClass46_2249).anInt800; i_2_ = ((Widget) Class168.aClass46_2249).anInt750; } anIntArray1164[0] = Class258_Sub4.mouseMovementListener.method3597(true) - i_1_; anIntArray1164[1] = (Class258_Sub4.mouseMovementListener.method3594((byte) 80) - i_2_); } method711(class348_sub42_sub19, 200000); } }
552704f3-89c5-42da-afc5-21c5599f4508
6
public Response handleRequest() { switch (criteria) { case CREATE_ACCOUNT: (new ApplyAccountCreate(list)).accountCreate(); break; case CHECK_LOGIN: return (new ApplyLoginCheck(list)).checkLogin(); case CHECK_REGISRTY: if (new ApplyLoginCheck(list).addressIsExist()) { return new Response(null, null, false); }else{ (new ApplyAccountCreate(list)).accountCreate(); return new Response(null, null, true); } case SEND_LETTER: new LetterService().storeLetter(objList); return new Response(null, null, true); case GET_INBOX_LETTERS_LIST: return (new LetterService().getListLetters(list.get(0), list.get(1))); } return new Response(null,null,false); }
36dde0d6-83b5-4279-8a54-44d4a1253820
1
public int[] exceptionTypes() { if (exceptions != null) { return exceptions.exceptionTypes(); } return new int[0]; }
0cc30056-9c89-4b2f-96a2-b16ff1aa1bb3
9
public void paint(Graphics g) { super.paint(g); if (shapes == null) return; long timeOverlap = - System.currentTimeMillis(); // reset overlaps for (Shape s: shapes) s.overlaps = false; // Calculate overlaps for (Shape s1: shapes) { for (Shape s2: shapes) { if (s1.hashCode() < s2.hashCode()) { // check distinct pairs once if (s1.overlaps(s2)) { s1.overlaps = true; s2.overlaps = true; } } } } // Calculate overlap with off-screen canvas: (Can't move objects off-screen to win) for (Shape s1: shapes) { if(s1.overlapsOffscreen(width/scale, height/scale)) // omit "pixelWidth" s1.overlaps = true; } timeOverlap += System.currentTimeMillis(); long timeDisplay = - System.currentTimeMillis(); for (Shape s: shapes) { s.paint(g,scale); } timeDisplay += System.currentTimeMillis(); System.out.println("Timing Breakdown: Overlap="+timeOverlap+"ms, Display="+timeDisplay+"ms"); }
9403b951-26a2-4f0b-8bc4-ea87897d0c53
2
protected boolean canPutInBackpack(Actor actor) { System.out.println(getName() + " is finding out if it can add " + ((SimpleWorldActor)actor).getName() + " to its backpack."); return getBackpack() != null && //must have a backpack actor instanceof ContainableSimWo && //a is containable getBackpack().canContain((ContainableSimWo)actor); //backpack can contain }
5da19958-4604-46b9-a859-9c12194a84bd
9
public static ByteBuffer get(FileDescription description) { if (description.getIndex() == 255 && description.getArchive() == 255) { return meta; } if (data.containsKey(description)) { return data.get(description); } ArchiveMeta meta = cache.get(description.getIndex()).getArchiveMeta( description.getArchive()); ByteBuffer buffer = ByteBuffer.allocate(meta.getSize()); int remaining = meta.getSize(); int block = meta.getBlock(); int cycles = 0; while (remaining > 0) { int read = Constants.BLOCK_SIZE; if (read > remaining) { read = remaining; } try { ByteBuffer data = datum.map(MapMode.PRIVATE, block * Constants.BLOCK_DATA, read + Constants.BLOCK_HEADER); int expectedArchive = data.getShort() & 0xFFFF; int expectedCycle = data.getShort() & 0xFFFF; int nextBlock = (data.get() & 0xFF) << 16 | (data.get() & 0xFF) << 8 | (data.get() & 0xFF); int expectedIndex = data.get() & 0xFF; if (expectedArchive != description.getArchive() || expectedCycle != cycles++ || expectedIndex != description.getIndex() + 1) { throw new IOException(); } remaining -= read; block = nextBlock; buffer.put(data); } catch (IOException e) { e.printStackTrace(); } } buffer.flip(); data.put(description, buffer); return buffer; }
6f7db55d-39a2-41fc-9b2c-2fbb183adfa2
2
public void InsertarOtro(ArrayList datos) { // Cambiamos todos los datos, que se puedan cambiar, a minúsculas for(int i = 0 ; i < datos.size() ; i++) { try{datos.set(i, datos.get(i).toString().toLowerCase());} catch(Exception e){} } biblioteca.insertarRegistros("otro", datos); }
f176ef83-1768-4af0-abea-058772b78e66
2
public GridSizeDialog() { myPanel.add(new JLabel("Width:")); wField.setText("10"); myPanel.add(wField); myPanel.add(Box.createHorizontalStrut(15)); myPanel.add(new JLabel("Height:")); chooseFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("text files", "txt"); chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName()); File file = chooser.getSelectedFile(); try { inputStream = new FileInputStream(file); } catch (FileNotFoundException e1) { e1.printStackTrace(); } } } }); hField.setText("10"); myPanel.add(hField); myPanel.add(chooseFile); myPanel.add(gameTypeSelect); }
d74f0b74-a395-4744-9977-a149ef4d7f34
2
public boolean isGetMethodPresentFor(Field field) { FieldStoreItem item = store.get(FieldStoreItem.createKey(field)); if(item != null) { return item.getGetMethod() != null ? true : false; } return false; }
af4a27ed-1a8e-425f-b77e-6b69d96c7aed
0
public void stop(){ distributedService.dispose(); }
5ded3c7a-5be8-43e3-bef3-3e64d2c62181
3
@Override public void paintComponent(Graphics g) { super.paintComponent(g); // Determine the width of the space available to draw the line number FontMetrics fontMetrics = component.getFontMetrics( component.getFont() ); Insets insets = getInsets(); int availableWidth = getSize().width - insets.left - insets.right; // Determine the rows to draw within the clipped bounds. Rectangle clip = g.getClipBounds(); int rowStartOffset = component.viewToModel( new Point(0, clip.y) ); int endOffset = component.viewToModel( new Point(0, clip.y + clip.height) ); while (rowStartOffset <= endOffset) { try { if (isCurrentLine(rowStartOffset)) g.setColor( getCurrentLineForeground() ); else g.setColor( getForeground() ); // Get the line number as a string and then determine the // "X" and "Y" offsets for drawing the string. String lineNumber = getTextLineNumber(rowStartOffset); int stringWidth = fontMetrics.stringWidth( lineNumber ); int x = getOffsetX(availableWidth, stringWidth) + insets.left; int y = getOffsetY(rowStartOffset, fontMetrics); g.drawString(lineNumber, x, y); // Move to the next row rowStartOffset = Utilities.getRowEnd(component, rowStartOffset) + 1; } catch(Exception e) {break;} } }
87c68eb8-4a44-4b5f-9748-a3b43da8fab0
5
void readCdsFastaFile(String cdsFastaFileName) { int lineNum = 1; if (!quiet) System.out.print("Reading file:" + cdsFastaFileName + "\t"); FastaFileIterator ffi = new FastaFileIterator(cdsFastaFileName); for (String cds : ffi) { // Transcript ID String trid = GprSeq.readId(ffi.getHeader()); // Repeated transcript Id? => Check that CDS is the same if ((cdsByTrId.get(trid) != null) && (!cdsByTrId.get(trid).equals(cds))) System.err.println("ERROR: Different CDS for the same transcript ID. This should never happen!!!\n\tLine number: " + lineNum + "\n\tTranscript ID:\t" + trid + "\n\tCDS:\t\t" + cdsByTrId.get(trid) + "\n\tCDS (new):\t" + cds); cdsByTrId.put(trid, cds); lineNum++; } if (!quiet) System.out.println("done reading " + cdsByTrId.size() + " CDSs"); }
7da029b5-4bd0-4183-88e4-9b67651fa48a
2
public void executeJob(IJob job){ JobExecutor executor = new JobExecutor(job, updateable, id); try { executor.run(); } catch (Exception e) { e.printStackTrace(); try { //Executing the job went wrong, we signal the master and shut ourselves down updateable.send(new StatusUpdate("VM " + id + " Failure: " + e.getMessage(), id, VMState.FAILED)); System.exit(0); } catch (Exception e1) {} } }
0094c425-f1e9-4732-bcbf-8f87ea095b78
6
private static void solve(Integer[] in) { int cuts = 0; int min = Integer.MAX_VALUE; // for (int item : in) { // if (item > 0 && item < min) { // min = item; // } // } // boolean minset = false; for (int i = 0; i < in.length; i++) { if (onlyZeros(in)) { break; } if (in[i] <= 0) { continue; } else if(!minset) { min = in[i]; minset = true; } if(minset==true) { in[i] = in[i] - min; cuts++; } if (i==in.length) minset=false; } System.out.println(cuts); }
dd332e3f-44bc-44c5-bd3a-ee16eee633c4
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Sequence other = (Sequence) obj; if (definitionLine == null) { if (other.definitionLine != null) return false; } else if (!definitionLine.equals(other.definitionLine)) return false; if (nucleotides == null) { if (other.nucleotides != null) return false; } else if (!nucleotides.equals(other.nucleotides)) return false; return true; }
b84abee1-b3d7-4b9e-a538-1dba6e3bcebe
2
public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String sM = reader.readLine(); String sN = reader.readLine(); int nM = Integer.parseInt(sM); int nN = Integer.parseInt(sN); for (int i = 1; i <= nM; i++) { for (int j = 1; j <= nN; j++) { System.out.print("8"); } System.out.println(); } }
d010e1d0-e681-47be-8a4d-b1fe0e4fa098
9
public boolean onPlayerRightClick(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack, int par4, int par5, int par6, int par7) { this.syncCurrentPlayItem(); this.netClientHandler.addToSendQueue(new Packet15Place(par4, par5, par6, par7, par1EntityPlayer.inventory.getCurrentItem())); if (par3ItemStack != null && par3ItemStack.getItem() != null && par3ItemStack.getItem().onItemUseFirst(par3ItemStack, par1EntityPlayer, par2World, par4, par5, par6, par7)) { return true; } int var8 = par2World.getBlockId(par4, par5, par6); if (var8 > 0 && Block.blocksList[var8].blockActivated(par2World, par4, par5, par6, par1EntityPlayer)) { return true; } else if (par3ItemStack == null) { return false; } else if (this.creativeMode) { int var9 = par3ItemStack.getItemDamage(); int var10 = par3ItemStack.stackSize; boolean var11 = par3ItemStack.useItem(par1EntityPlayer, par2World, par4, par5, par6, par7); par3ItemStack.setItemDamage(var9); par3ItemStack.stackSize = var10; return var11; } else { if (!par3ItemStack.useItem(par1EntityPlayer, par2World, par4, par5, par6, par7)) { return false; } if (par3ItemStack.stackSize <= 0) { ForgeHooks.onDestroyCurrentItem(par1EntityPlayer, par3ItemStack); } return true; } }