method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
b8e71125-5de4-4150-ba2c-db9313ef6615
1
private final void setBufferStrategy() { try { createBufferStrategy(2); Thread.sleep(1000); } catch (Exception e) { logger.error(e, "Couldn't set buffer strategy"); Runtime.getRuntime().exit(0xDEADBEEF); } bufferStrategy = getBufferStrategy(); }
59a06a9d-5221-4a4c-9d96-8f63c860cf23
1
protected String getExtension(String path) { String extension = ""; int i = path.lastIndexOf('.'); if (i > 0) { extension = path.substring(i+1); } return extension; }
19d65d9c-1732-4083-86a7-3d476324aaf0
4
@Override public void caseAParaComando(AParaComando node) { inAParaComando(node); if(node.getVar() != null) { node.getVar().apply(this); } if(node.getADe() != null) { node.getADe().apply(this); } if(node.getAAte() != null) ...
22e33e46-9453-44ec-ae11-6ed4ae9e76a3
4
public Node<T> getSuccessor(Node<T> node) { if (node.getRight() != null) { node = node.getRight(); while (node.getLeft() != null) node = node.getLeft(); return node; } Node<T> temp = node.getParent(); while (temp != null && node == temp.getRight()) { node = temp; te...
7cef6965-f717-4811-a660-d99dbd196fc6
4
private int writeXrefSubSection(int beginIndex) throws IOException { int beginObjNum = entries.get(beginIndex).getReference().getObjectNumber(); // Determine how many entries in this sub-section int nextContiguous = beginObjNum + 1; for(int i = beginIndex+1; i < entries.size(); i++) { ...
4a7aaaf3-e2f5-4f5b-9583-676d3a5226dd
6
public void saveAs() { try { FileNameExtensionFilter filter = new FileNameExtensionFilter( "Windows BMP file", "bmp"); FileNameExtensionFilter filter2 = new FileNameExtensionFilter( "JPEG file", "jpg", "jpeg"); FileNameExtensionFilter filter3 = new FileNameExtensionFilter( "PNG", "png"); J...
dcae5b5d-16d2-4d27-b8a2-96c5cb9a87b7
8
public static void main(String[] args) { try { test1(); } catch (ArithmeticException e) { e.printStackTrace(); } StdOut.println("--------------------------------"); try { test2(); } catch (ArithmeticExc...
07c9ac6e-f2e2-40de-8607-5b44c2c18aec
3
public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String input = sc.nextLine(); boolean isPalindrome = false; int counter = 0; int middle = input.length()/2; for (int i=0; i<middle; i++){ int m = input.length(); if (input.charAt(i...
502aa12a-b90e-4a7e-b090-8a932def160a
1
public String getURLName() { return "n!\"" + name.replace(" ", "+") + (set != null ? "\"%20e:" + set : "\""); }
07421de6-6882-4dc6-94e9-9328d6c45ff7
0
public long getS() { return initTemps[0]; }
4eac3bc6-2155-40c6-ba77-0005eba10daa
2
public Deck(){ super(); // Populate our deck Card.CARD_SUIT[] arrSuits = Card.CARD_SUIT.values(); Card.FACE_VALUE[] arrFaces = Card.FACE_VALUE.values(); for(Card.CARD_SUIT s : arrSuits) { for(Card.FACE_VALUE f : arrFaces) { this.addCard(new Card(s, f)); } } }
025abcdc-d341-4fe2-af10-6522dc3dd709
5
@SuppressWarnings({"unchecked"}) private void heapifyMax(int index) { int left = getLeft(index); int right = getRight(index); int greatest; if (left < size && comparator.compare((T) queue[left], (T) queue[index]) > 0) { greatest = left; } else { grea...
7a32e6d6-30a9-4ea8-af59-7195de76c3e7
3
public boolean insertarProceso(Proceso p) { int prioridad = p.getPrioridadDinamica(); boolean agrego = false; if (this.listas[prioridad].indexOf(p) == -1) { if (prioridad < this.menorPrioridadNoVacia) { this.menorPrioridadNoVacia = prioridad; } ...
c16574ca-a23a-4e1b-a8b0-23f4ff7c7705
3
private static int initOriginal(final Display display, Composite inComposite) { final Composite originalCompsite = new Composite(inComposite, SWT.BORDER); int heightHint = 0; try { original = new Image(display, Resource.class.getResourceAsStream(IMAGE_PATH)); if (original.getImageData().depth != 8 && origi...
7f100be9-b09b-47a8-9027-7ae87b9dfec1
3
public void dump() { int i = 0; while (i<hp) { int len = heap[i]; System.out.print("Object at address " + (i - size) + ", length=" + len + ", data=["); for (int j=1; j<=len; j++) { System.out.print(Integer.toString(heap[i+j])); if (...
500aa2aa-0bc3-4b6d-b03a-9814fbdfaa68
4
@Override public synchronized void execute() throws IOException, RoutingException { try { /* Set the local node as already asked */ nodes.put(this.localNode.getNode(), ASKED); /** * We add all nodes here instead of the K-Closest because there may...
099de88a-54ac-489a-8fde-d402279518d2
5
private int[] parsePrefix() { assert (peek() != null) : "parsePrefix() can't start at EOF"; int[] toReturn = {0, 0, 0}; // First, parse a digit, if we begin with one Boolean quitNow = parseFirstDigit(toReturn); if (quitNow == Boolean.TRUE){ return to...
3c49216c-8e69-44e0-bec8-0ba5052ff75f
3
private void connectToNotchers() { //define and instantiate a worker thread to create the file //---------------------------------------------------------------------- //class SwingWorker // workerThread = new SwingWorker<Void, String>() { @Override public Void doInBackground() {...
96e3d89c-35f0-4248-bf9b-c0529f57f81b
7
public void update() { int xa = 0, ya = 0; if(anim < 7500) anim++; else anim = 0; if (input.up) ya--; if (input.down) ya++; if (input.left) xa--; if (input.right) xa++; if (xa != 0 || ya != 0){ move(xa, ya); walking = true; } else walking = false; }
cf633a10-69f9-49b8-a1d9-223a50ec6f7c
7
private void goToMarket() { switch(mSSN % 4) { case 0: mItemsDesired.put(EnumItemType.PIZZA, sBaseWanted); break; case 1: mItemsDesired.put(EnumItemType.STEAK, sBaseWanted); break; case 2: mItemsDesired.put(EnumItemType.CHICKEN, sBaseWanted); break; case 3: mItemsDesired.put(E...
dae5c133-7e4e-4ae9-9513-8ea3d4c13ea8
0
public long getSalary() { return salary; }
44ab4176-0b5d-4dd8-a0cc-5279829a0113
6
@EventHandler public void EnderDragonFastDigging(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getEnderDragonConfig().getDouble("...
e196b219-a78d-4049-b711-68d2742a412c
0
public void mapToKey(GameAction gameAction, int keyCode) { keyActions[keyCode] = gameAction; }
db9d47a9-012e-4c28-8419-27256267b664
2
public void setLayout(int layoutType){ switch (layoutType) { case LookManager.GREEN_LAYOUT: Dimension size = (getSize().height == 0 ? getPreferredSize() : getSize()); setIcon(new ImageIcon(imgLdr.scaleBufferedImage(imgLdr.loadBufferedImage(GUIImageLoader.GREEN_BUTTON_ACTIVE), size))); setRolloverIcon(new I...
af1d7ebb-2c5a-45d8-bdd0-b0a949172312
8
public void dragSelectCard(CardView clickCardView , int distance) { int startindex = cardViews.indexOf(clickCardView); int endIndex = 0; if (distance < 0) { distance -= cardGap / 2; } int count = distance/cardGap; boolean isModeZero = (distance % cardGap == 0); if(count > 0) { endIndex = startind...
119a3fea-9744-4cd4-9bfd-f3de0161bee1
2
public void updateBundles(byte[] data) { bundles.clear(); int dIndex = 0; while (dIndex < data.length) { int startIndex = dIndex+2; byte bundleID = data[dIndex+1]; int endIndex = (int)data[dIndex] + dIndex; long value = 0; ...
e89059e9-9f1d-47f8-835f-0e86dc5b99b3
8
public boolean ewify() throws IOException, FileNotFoundException{ FileReader input = new FileReader(this.source); BufferedReader bufRead = new BufferedReader(input); String myLine = null; ArrayList<EweRule> arrayRules=new ArrayList<EweRule>(); int currentRule=0; boolean flagThen=false; boolean flagWhen...
6b4c0c14-bfee-4906-b600-cfedcab50606
4
static void graph1(Metrics metrics, Main main){ Metrics.Graph graph = metrics.createGraph("action"); String ac = main.getConfig().getString("action"); if (ac.equalsIgnoreCase("warn")) { graph.addPlotter(new SimplePlotter("Warn")); } else if(ac.equalsIgnoreCase("kick")){ ...
a095220b-edff-407c-bee2-d71ebb61a725
3
public static void noSpace(String string) throws JSONException { int i, length = string.length(); if (length == 0) { throw new JSONException("Empty string."); } for (i = 0; i < length; i += 1) { if (Character.isWhitespace(string.charAt(i))) { throw...
41d31064-04eb-4a8a-9b43-bcbfb7564e32
7
private void jRadioButtonXMLtoJSONActionPerformed( final java.awt.event.ActionEvent evt) { switch (etat) { case INIT_JSON_XML: etat = Etat.INIT_XML_JSON; break; case INIT_XML_JSON: etat = Etat.INIT_XML_JSON; break; case OUTPUT_JSON_XML: throw new RuntimeException("Bouton Convertir : " + "...
07b61a58-006a-4d3b-9cd7-e21fa1b5c030
1
public static void main( String[] args ) { JFrame frame = new JFrame( "Graph" ); frame.setBounds( 20, 20, 800, 600 ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); Graph graph = new Graph(); for( GraphItem item : createTestItems() ){ graph.addItem( item ); } ConnectionableCapabilityHand...
f1dc8a18-fbb4-4330-9b7a-f441b5d2ac0d
1
public void printATMs() { Set<Integer> keys = supportedATMs.keySet(); System.out.println("Bank " + bankID + " ATMs:"); for(Integer key: keys) { System.out.println(supportedATMs.get(key)); } }
df1b6238-ee7d-4eb2-9a9b-a497d38de00e
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...
de546dfd-c353-42c2-82f1-9cae7530a986
1
public synchronized void transfer(int from, int to, double amount) throws InterruptedException { while (accounts[from] < amount) wait(); System.out.print(Thread.currentThread()); accounts[from] -= amount; System.out.printf(" %10.2f from %d to %d", amount, from, to); accounts[to...
5eae78b1-d337-45ad-832a-da80ecebb918
1
@Override protected void finalize() throws Throwable { try { close(); } catch (final IOException ex) { LOGGER.warn("Problem trying to auto close file handles...", ex); } finally { super.finalize(); } }
31f968da-04e7-4aa1-858d-7b5211d16ed2
9
public List<Integer> findSubstring2(String S, String[] L) { List<Integer> res = new ArrayList<Integer>(); if(S == null || S.length() == 0 || L == null || L.length == 0) return res; int L2 = S.length(); int l = L[0].length(); int L1 = L.length * l; for(int i = 0; i <= L2 -...
7241b8a0-8099-4d1b-b49d-f3511263b432
5
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: try{ //Se extraen todas las caciones leer_archivo cancionesActualizadas=new leer_archivo(100); String [] lista_p=cancio...
6ceb279b-447c-44b5-86b8-0ece4bc77c43
3
int snake( int x, int y, FragList fl ) { while ( x<fl.fragments.size()&&y<fragments.size() ) { if ( fragments.get(y).equals(fl.fragments.get(x)) ) { x++; y++; } else break; } return x; ...
c6e789c3-bb2a-44ec-bbfe-1df9d7640235
1
public int calculateRewardPoints() { int points = 0; for (int i = 0; i < purchases; i++) { points = points + 100; } return points; }
62dfb0a2-21dd-4780-823f-1f93c8744fef
5
public void putByte(byte newByte) { byte[] ar = new byte[1]; ar[0] = newByte; msg = new String(ar); if (newByte == '<') { // new Message Start detected // reset Msg String and add Start-delimiter //outmsg = msg; receivingMessage = true; } else if (newByte == '>' && receivingMessage == true) { ...
2a898fc5-14a2-454b-91b1-c90dffaedd18
5
@Test public void sizeIsCorrect() { boolean test = true; for (int i = 0; i < 10000; i++) { queue.clear(); Random rand = new Random(); int r = rand.nextInt(1000); for (int j = 0; j < r; j++) queue.enqueue("allo"); int b = (r <= 0...
32727e29-03b5-45be-99c6-711e005acec1
1
public StartMenu(GameStateManager gsm) { this.gsm = gsm; try { bg = new Background("/Background/Background.png", 1, false, 0); bg.setVector(-0.1, 0); titleColor = new Color(128, 0, 0); titleFont = new Font("Maximilien", Font.PLAIN, 28); maximilien = new Font("Maximilien", Font.PLAIN, 15); } ca...
f6e3e64e-3b10-4b47-9efb-705096e149c1
3
public synchronized static void addTheaterSeats(TheaterSeats theSeats){ if(!seats.contains(theSeats)){ if(seats.size() < cacheLimit) seats.add(theSeats); else{ for(int i=0;i<(cacheLimit/10);i++) seats.removeFirst(); //Removes the oldest seat in the list seats.add(theSeats); } } else{ ...
a857dcad-2b5f-49a6-a219-ebfc1e550f0d
7
public static String doubleToString(double d) { if (Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } // Shave off trailing zeros and decimal point, if possible. String string = Double.toString(d); if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && ...
c5d90006-c8ea-4afb-a29f-ba5b7ea545d9
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...
eff9ff25-1913-4934-aa2a-a90ece4cf452
2
public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = this.keys(); while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; }
18867d7a-74b3-4f3f-9c0a-b2fc5605f117
1
public void updateDamageListener(String resource, int damageToAdd) { GameActor actor = actors.get(resource); if(actor == null) { createPrototype(resource); actor = actors.get(resource); } WeaponsComponent wc = (WeaponsComponent)actor.getComponent("Weapons...
bf50a8db-5edd-499f-84ad-e094420a9e1b
6
public ConvexMultivariateRealFunction[] getResourcesConvexConditions(double alpha) { resourcesConvex = null; // нужный костыль if(resourcesConvex == null) { double talpha = getT(alpha); int mainSize = db.tools.size(); int rowSize = db.resources.size(); ...
3b99996b-dde5-4e00-bec5-caef4e4f3dca
8
void updateHash(byte[] input, int pos, int end) { // WINDOW_MASK int hPos = pos & 0x7FFF; int val = this.val; val = ((val << 5) ^ (pos + 2 < end ? input[pos + 2] & 0xFF : 0)) & 0x7FFF; hashVal[hPos] = val; int tmp = head[val]; prev[hPos] = (tmp != -1 && hashVal[...
7a2074c3-bf95-432c-aaba-c331ccd4743f
2
public static void listPortals( BSPlayer p ) { for ( ServerInfo s : portals.keySet() ) { String message = ""; message += ChatColor.GOLD + s.getName() + ": " + ChatColor.RESET; ArrayList<Portal> list = portals.get( s ); for ( Portal portal : list ) { ...
abe60b55-e8d7-470d-84df-c5d13b91b61f
0
public Point2D[] points() { return (Point2D[]) verticesToPoints.values().toArray(new Point2D[0]); }
b31db982-91b0-481d-8496-7d2fbbb6e483
8
private void fileUpload(final DataPacket<AFile> dp, Object[] args){ /* * Get some information out of data packet */ AFile recvAfile = dp.getContent(); byte[] filecontent = recvAfile.getFile(); Log fileLog = dp.getLog(); byte[] logToByte = recvAfile.getEditInfo().getBytes(); PublicKey c...
d757dc27-f7b5-4168-b3db-564543a9ad79
3
private Integer findNext(String date, TreeSet<Integer> dates) { int givenDate = Integer.parseInt(date.split("/")[0] + date.split("/")[1]); for (Integer integer : dates) { if (integer == givenDate || integer > givenDate) return integer; } return 0; }
166499d9-8214-4847-82cc-4267f763a43c
8
private void generateOpenAndClosedLists() { /*load intial starting cell into the open list*/ for (int i = 0; i < localMap.size(); i++) { if (localMap.get(i).locX == sX && localMap.get(i).locY == sY) { openList.add(generateNewCell(localMap.get(i), new Cell(localMap.get(i), sX, sY, 0, 0)...
2c4800b7-4ee7-471c-9234-e3d886d3947c
8
private int countEmptyNeighbor(char colorPiece) { int cnt = 0; int[] nIndex = new int[TOTALPOS]; for (int t = 0; t < TOTALPOS; t++) { nIndex[t] = TOTALPOS; } for (int i = 0; i < position.length; i++) { MorrisIntersection pos = position[i]; if (pos.getLetter() == colorPiece) { List<MorrisIntersect...
2de535e7-f848-4012-b97a-ec7fc0353e48
3
private void recalcLevel() { hasGainedLevels = levelOfTower.recalculateLevel(); if (hasGainedLevels != 0) { for ( GameAction action : getGameActions()) { if (action.getAttackData() != null) { // getAttackData() returns null if the gameAction does not have an attack. ...
6e67bc0c-a43e-48c5-b6b3-f9a2da98d209
9
@Override public Response list() throws IOException { if(username.equals("")) { return new MessageResponse("Please log in first."); } else { synchronized(serverIdentifier) { if(serverIdentifier.isEmpty()) { return new MessageResponse("No files available"); } else { Set...
a42a7757-968a-4b1b-b3d6-1dad6940fbe9
6
private void spawnBox(int size, int xStart, int yStart){ size = size + 2; for (int i = 0; i < size; i++){ for (int j = 0; j < size; j++){ if (i == 0 || i == size - 1 || j == 0 || j == size - 1){ Boot.getWorldObj().getTileAtCoords(xStart + i, yStart + j).setTileID(TileID.ASPHALT); } } } }
c39849bb-0042-4965-94f3-e748c6aa287e
8
@Override public List<V_Ficha_Trab_Num_C> Buscar_Ficha_Trabajador(String iddep, String dni, String nom, String ape_p, String ape_m) { this.conn = FactoryConnectionDB.open(FactoryConnectionDB.ORACLE); String sql = "select d.*,RHFU_VIG_CON (d.id_trabajador) as VI_CONTRATO from (select * from RHVD_TRAB...
2732f18e-7676-424f-99e9-8a6972e986bf
7
public static String doubleToString(double d) { if (Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } // Shave off trailing zeros and decimal point, if possible. String string = Double.toString(d); if (string.indexOf('.') > 0 && string.indexOf('e') < 0 ...
9770582c-02d8-4671-82fb-270f1c1bfe55
3
public char[] readFile(String filename) { char[] content = null; File file = new File(filename); //for ex foo.txt FileReader reader = null; try { reader = new FileReader(file); char[] chars = new char[(int) file.length()]; reader.read(chars); //content = ne...
1a4d5894-7ddd-4cbd-ac19-fe0cbf9720aa
1
@Override public void windowClosing(WindowEvent e) { if (e.getID() == WindowEvent.WINDOW_CLOSING) { this.setVisible(false); this.dispose(); } }
ffff1183-8602-4327-9761-ee5bde2bf8c9
5
private Map<String, String> getProperties() { Map<String, String> properties = new HashMap<String, String>(); String line; try { while ((line = bundle.readLine()) != null) { boolean isComment = line.trim().length() < 1 && line.trim().startsWith("#"); i...
7eca7378-eae4-4c8e-95ad-863f267c518b
1
public static ByteArrayInputStream readStreamToMemory(InputStream inputStream) throws IOException { if (inputStream instanceof ByteArrayInputStream) { inputStream.reset(); return (ByteArrayInputStream) inputStream; } try { ByteArrayOutputStream outputStream = ...
8a4d8e2c-c8bc-409b-9006-66a54dd6cb05
0
public boolean canEncode(Serializable structure) { return false; // Serialization is deprecated as a saving method. }
e1b5e8f7-3daa-4409-8d6d-bc01eccfe36c
5
public static void processCollision(RigidBody rigidBody1, Vector3d point1, RigidBody rigidBody2, Vector3d point2, Vector3d relativeVelocity, Vector3d normal, Matrix3d k, double restitution, double timeStep) { Vector3d impulse = new Vector3d(); // Coefficient of friction double friction = Math.max(rigidBody...
8b049930-92a2-4f6a-9db7-2ed3816e5835
0
public static void main(String[] args) { System.out.println("hello Hyun Kyu"); }
f42eee64-e170-4fe1-86af-4888b3361330
9
int writeJavaAnnotations(List<Attribute.Compound> attrs) { if (attrs.isEmpty()) return 0; ListBuffer<Attribute.Compound> visibles = new ListBuffer<Attribute.Compound>(); ListBuffer<Attribute.Compound> invisibles = new ListBuffer<Attribute.Compound>(); for (Attribute.Compound a : attrs) {...
360cb2fb-c5e5-4e8a-9e04-891544b8d838
2
public void setDAO(String daoLine) { if (daoLine.equals("Mock")) { dao = new MockDAO(); } else if (daoLine.equals("MySQL")) { dao = new MySQLDAO(); } }
b7ef2619-130e-4722-82fc-ffe75153e0fd
7
@Override public void actionPerformed(ActionEvent event) { /* Redo listenner */ if (event.getSource().equals(redo)) { points = drawPanel.getPoints(); for (Point point : pointstoAddorRemove) { points.add(point); } drawPanel.setPoints(points); drawPanel.paintComponent(drawPanel.getNextGraphics());...
e228d45e-4226-4f9d-88dd-41ee8f12b793
3
public void insertIntoGraph(mxICell cell) { mxICell parent = cell.getParent(); mxICell source = cell.getTerminal(true); mxICell target = cell.getTerminal(false); // Fixes possible inconsistencies during insert into graph cell.setTerminal(null, false); cell.setTerminal(null, true); cell.setParent(null); ...
3a46d49f-6e2e-4ee1-9a2c-66b5d8b3b8ab
3
@Override public int getPixel(int x, int y) { int bx = x / 8; int by = y / 8; int offs = bx + by * (width / 8) - tileOffset; if (offs < 0) return 0; offs *= 64; offs += x % 8 + 8 * (y % 8); if (offs < 0) return 0; if (offs ...
5e82a2ba-4567-4b2e-b4f8-b74483764832
1
public InputStream getInputStream() throws java.io.IOException{ if (inputStream==null) { setInputStream(socket.getInputStream()); } return inputStream; }
4738f313-1049-4d72-9592-5a84e7f21a8a
3
@Override public void logicUpdate(GameTime gameTime) { // Decrease the timer by the current game time in milliseconds countDownTimer.decreaseTimer(gameTime.getElapsedTimeMilli()); // If our timer is now over, time to call our timeOver method. The class // that instantiates this will have to provide that metho...
fc2f4f39-da1d-4b71-b0c2-ce44aa68720e
5
public String cypher(String input) throws UnsupportedEncodingException { try { MessageDigest md = MessageDigest.getInstance("MD5"); //MD5 is the only allowed algorithm. String intermediate = new String(md.digest(input.getBytes("UTF-8"))); // don't do UTF-16 String output = new String(); //iterat...
eb1ed84c-59bc-4907-a61a-d92d57aa23a4
7
private static String formatMessage(String msg, String p, boolean b) { String message = (b ? (PARAGRAPH + "9[SkyDregg] ") : "") + PARAGRAPH + p; Pattern pattern = Pattern.compile("(?<NUMBER>[ ][0-9]+)|(?<WHITESPACE>[ \f\t\r\n])|(?<WORD>[^ ]+)"); Matcher matcher = pattern.matcher(msg); while (matcher.find()) { ...
033b5f25-ccca-4183-9290-532cc704b2cd
6
@EventHandler public void ZombieRegeneration(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getZombieConfig().getDouble("Zombie.Re...
dac3801b-7b4e-46ba-8f10-1abd6c8a8097
3
private void encrypt(String pass) { try { byte[] utf8 = pass.getBytes("UTF8"); byte[] enc = this.encrypter.doFinal(utf8); this.setEncryptedPass(Base64.encode(enc)); } catch (javax.crypto.BadPaddingException e) { } catch (IllegalBlockSizeException e) { } catch (UnsupportedEncodingException e) { } }
a79abbfa-44a3-47cc-bff3-8762a25e7d0b
1
@Test public void tiedostonMuokkaaminenToimii() { kasittelija.setFile(tiedosto); kasittelija.tallennaTiedostoon("testi1\ttesti2\ttesti3\ttesti4\ttesti5"); String a = ""; ArrayList<String[]> lista = new ArrayList<>(); lista.add(new String[]{"testi1", "testi2", "testi3", "testi...
06712bf2-70ae-44d3-ad27-7f8764101f6f
1
public void train(){ int sinceBelowMin = 0; Player[] players = new Player[]{ new PlayerComputer(this), new PlayerComputer(new ModelRandom()) }; while (sinceBelowMin < 50) { Game g = Game.create(players, 5, 1, false); g.play(new Random().nextInt(players.length)); sinceBelowMin = rl.gamesSinceBel...
24e1ef41-de44-4270-9b93-4592dc6b4e15
3
public static void write() { //writes the file back out if it's been modified if(file == null) { JOptionPane.showMessageDialog(null, "Read-only file was imported. Can not write.", "Read-Only file", JOptionPane.INFORMATION_MESSAGE); return; } try { fWriter = new PrintWriter(file, "UTF-8"); wr...
36b94665-6959-4819-8b6b-b7092f6fcdc6
8
public static ListNode partition(ListNode head, int x) { ListNode f = null; ListNode s = null; ListNode p = null, q = null; ListNode h = head; ListNode e = h; while (null != h) { if (h.val < x) { if (null == f) f = h; if (null == p) p = h; else { p.next = h; p = p.next; } } e...
307697d2-71f1-4f56-a40a-8601550f880f
9
@SuppressWarnings("rawtypes") public final static Pedidos jsonToPedidos(String json) throws ParseException { Pedidos ped= new Pedidos(); JSONParser parser = new JSONParser(); ContainerFactory containerFactory = new ContainerFactory() { public List<String> creatArrayContainer() { return new LinkedList<Stri...
ffc0954a-6ab3-49a6-b14e-6d9b212de311
5
@Override public List<Produto> searchProducts(String category, String price) { try { String query = ""; if (!category.equals("")) { query = "where categoria like '%" + category + "%'"; } if (!price.equals("") && price.equals("max")) { ...
7dffb91c-d5c1-490e-bdde-0d601c06cc92
4
public static boolean isRequired(Parameter parameter) { boolean angleBrackets; Requirement requirement = parameter.getProperty(Properties.REQUIREMENT); requirement = requirement == null ? DEFAULT : requirement; switch (requirement) { case REQUIRED: ...
0df43d08-69ea-4c09-858b-84a8a6cd964a
1
public BoxSelectionCapability( DefaultBox<?> box ) { this.box = box; }
d3cee2b4-3549-4be0-a9d5-ff3875c33d76
5
public void actionPerformed(ActionEvent e) { if (e.getSource() == mntmExportar) { do_mntmExportar_actionPerformed(e); } if (e.getSource() == mntmSair) { do_mntmSair_actionPerformed(e); } if (e.getSource() == btnCalcularSubrede) { do_btnCalcularSubrede_actionPerformed(e); } if (e.getSource() == bt...
ab0c1efb-1e9f-4486-946c-f62b2e059c55
6
public void testEquipBravesNotEnoughReqGoods() { Game game = ServerTestHelper.startServerGame(getTestMap()); AIMain aiMain = ServerTestHelper.getServer().getAIMain(); FreeColTestCase.IndianSettlementBuilder builder = new FreeColTestCase.IndianSettlementBuilder(game); IndianS...
3db9fb83-701d-4af5-af67-5354437211b7
4
@Override protected Rectangle[] createHandles() { p = createPoints(state); Rectangle[] h = new Rectangle[4]; mxPoint p0 = state.getAbsolutePoint(0); mxPoint pe = state.getAbsolutePoint(state.getAbsolutePointCount() - 1); h[0] = createHandle(p0.getPoint()); h[2] = createHandle(pe.getPoint()); // Creat...
26206221-58d9-4e47-a0c4-7389f18d25c0
9
public void clearCircle(int cx, int cy, int radius) { int ci = getI(cx); int cj = getJ(cy); int iradius = getI(radius); for (int i = ci - iradius; i < ci + iradius; i++) { for (int j = cj - iradius; j < cj + iradius; j++) { if (i < 0 || j < 0 || i >= voxels.length || j >= voxels[0].length) co...
b5bc45eb-4e73-4b11-a1a8-741a2f37e68c
6
public void addMessage(CheckResultMessage message) { if (message == null || message.getMessage().trim().isEmpty()) { return; } if (message.getType() == CheckResultMessage.SYSTEM) { addSystemMessage(message.getMessage()); } else if (message.getType() == CheckResultMessage.CHECK_OK) { this.addOkMessage(...
7e17d4e1-4ac0-4f77-8800-2497c8c45fb8
8
public RandomListNode copyRandomList(RandomListNode head) { if(head == null ) return head; //copy and linked. RandomListNode prev; RandomListNode head2; for(prev = head;prev != null;prev = prev.next.next){ //copy a node RandomListNode t = new RandomListNode(prev.label); t.next = prev.next; //l...
ca64250f-8b74-469a-ace4-3072ec7f9a50
6
private static String getPortImageFile(PortType portType) { switch (portType) { case WOOD: return "images/ports/port_wood.png"; case BRICK: return "images/ports/port_brick.png"; case SHEEP: return "images/ports/port_sheep.png"; case WHEAT: return "images/ports/port_wheat.png"; cas...
db1f7167-93b7-44c3-8867-171e39d2923b
9
private void creatTPoly(){ double xO = (this.getWidth()/2. - (10.5*l)/2.); double yO = (this.getHeight()/2. - (7*l*Math.sqrt(3))/2.); int k = 4,alignD =1; int num=0; for(int i=0;i<7;i++){ if(i>3){alignD=i -3;} else{alignD=0;} for(int j=0;j<k;j++){ int xA=(int)((j * 3./2. * l )+ l + alignD * 3./2....
d731770f-4d28-4222-9ea0-55db10f2f2dd
9
public boolean validateStr(String s) { char[] tempCharArray = s.toCharArray(); boolean check = false; if (s.equals("")) { // if the user does not input anything: return false return false; } else { // for loop cycles through each position of the char array to check // if there are any characters ...
c9eb13f5-5ef6-4866-9ad7-7f8d7c67c750
6
@SuppressWarnings("unchecked") public TypeComboBox(JFrame frame, EnterTyped fn) { setEditable(true); setModel(new MyFilterComboBoxModel(ComboElemPersistence.getComboData())); setPreferredSize(new java.awt.Dimension(100, 21)); getEditor().getEditorComponent().addKeyListener(new KeyAdapte...
c00d1cb8-9b82-419b-8e66-c11a5fcf9489
3
public void dump(String prefix) { System.out.println(toString(prefix)); if (children != null) { for (int i = 0; i < children.length; ++i) { SimpleNode n = (SimpleNode)children[i]; if (n != null) { n.dump(prefix + " "); } } } }
9dd74fb9-e13c-4852-94f8-7a144d8be81b
1
@Override public Long countAll() throws Exception { try { session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); //Query q = session.getNamedQuery("count.all"); Query q = session.getNamedQuery(getNamedQueryToCountAll()); ...
a4cd5118-e0a3-461c-bbfd-963cf2cbdc53
0
public BaiduPhotoSpider(String startSite, String dirPath, Cobweb cobweb, int maxDepth) throws Exception { super(startSite, dirPath, cobweb, maxDepth); }
675b990d-b0af-4b5e-bcc7-2ed6285c3b63
5
public JSONObject increment(String key) throws JSONException { Object value = this.opt(key); if (value == null) { this.put(key, 1); } else if (value instanceof Integer) { this.put(key, (Integer) value + 1); } else if (value instanceof Long) { this.put(...