method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
05df4152-e517-4507-a802-261f1befeccd
4
public static Inventory deserialize(String s) { String size = s.substring(0,s.indexOf("!")-1); Inventory inv = Bukkit.getServer().createInventory(null, Integer.parseInt(size)); String[] istacks = s.split("&"); for(int i=0;i<istacks.length;i++) { ItemStack is = deserializeBasicSection(istacks[i]); if(istacks[i].contains("e#")) { String[] enchs = istacks[i].substring(istacks[i].indexOf("e#")).split("$"); for(String ench : enchs) { String[] ed = ench.split(","); if(ed.length==2) { is.addEnchantment(Enchantment.getById(Integer.parseInt(ed[0])), Integer.parseInt(ed[1])); } } } } return inv; }
b9fb9ad3-e20c-4e65-be92-01718fa24551
9
private Comparison comparison() { ArrayList<Expr> exprlist = new ArrayList<Expr>(); ArrayList<CompOp> compopList = new ArrayList<CompOp>(); Expr fisrtExpr = expr(); while (lexer.token == Symbol.EQ || lexer.token == Symbol.NEQ || lexer.token == Symbol.NOT || lexer.token == Symbol.GT || lexer.token == Symbol.LT || lexer.token == Symbol.GE || lexer.token == Symbol.LE || lexer.token == Symbol.IN || lexer.token == Symbol.IS) { compopList.add(comp_op()); exprlist.add(expr()); } Comparison comp = new Comparison(fisrtExpr, compopList, exprlist); return comp; }
0d41c981-82cd-4f1f-8766-255bea8e98e5
9
public int[] render(int xOffset, int yOffset, int w, int h) { if(isBlankTiles) { return null; } if(!APIMain.getAPI().renderMapOnce || pix == null || update) { pix = new int[w * h]; MapManager mm = MapManager.instance; Tile tilevoid = mm.getTileFromID(0); Tile currentTile = tilevoid; int[] currentPixels = currentTile.getPixels(); for(int x = xOffset; x < w + xOffset; x++) { for(int y = yOffset; y < h + yOffset; y++) { int xx = (x - xOffset); int yy = (y - yOffset); if(currentTile != mm.getTileFromID(map[(width/Tile.SIZE) * (int)(yy / Tile.SIZE) + (int)(xx / Tile.SIZE)])) { currentTile = mm.getTileFromID(map[(width/Tile.SIZE) * (int)(yy / Tile.SIZE) + (int)(xx / Tile.SIZE)]); currentPixels = currentTile.getPixels(); } if(xx > width || yy > height) { pix[w * yy + xx] = tilevoid.getPixelAt(Tile.SIZE, (int)(yy / Tile.SIZE), (int)(xx / Tile.SIZE)); } else { pix[w * yy + xx] = currentPixels[Tile.SIZE * (yy % Tile.SIZE) + (int)(xx % Tile.SIZE)]; } } } update = false; } return pix.clone(); }
32919f50-0e81-449b-bfe7-08edd2e80410
3
@Override public void run(CommandArgs arg0) { CommandLine c = arg0.getCommandline(); String[] args = arg0.getRawArgs().split(" "); if (args.length > 1 && args[0].equals("site")) { Integer id = Integer.parseInt(args[1]); // Get the site Site site = WebServer.getSiteByID(id); if (site == null) { WebServer.triggerPluggableError("No Site with ID " + id); } else { c.println("Stopping site: '" + site.getName() + "'"); WebServer.stop(site); c.println("Site Successfully Stopped"); } } else { c.println("Server is going down"); // Stop the Server WebServer.stop(); c.println("Server Exiting"); // Quit System.exit(0); } }
21fc1c0f-5df3-4ae4-ab8e-4deed6f42852
2
public static void main(String[] args) { // TODO Auto-generated method stub double gallons, liters; int counter; counter = 0; for(gallons = 1; gallons <= 100; gallons++) { liters = gallons * 3.7854; System.out.println(gallons + " gallons is " + liters + " liters."); counter++; if (counter == 10) { System.out.println(); counter = 0; }//end of counter loop }//end of gallons increment } //end of main
4c92c163-595f-42b3-97f9-701b2830e2c6
0
public void setTableName(String tableName) { this.tableName = tableName; }
457672b0-ec9a-4992-a080-25d8b4212c03
1
private String calc(String input) { String reversed = ""; for(int i = input.length(); i > 0; i --){ reversed = reversed + input.charAt(i-1); } return reversed; }
e191d38d-9311-472c-acab-073fae2f0888
5
public static void main(String[] args) { Jsaper jsaper = new Jsaper(); Path file = null; Path targetDirectory = null; Map<String, Object[]> map = jsaper.getParamList(args); if(map.get("one")[0].equals(true)) { file = initAchiveFile(map.get("other")[0].toString()); UnZipper zipper; try { zipper = new UnZipper(file.toFile()); if(Utils.printMessage(zipper.checkOptions(map))) { System.exit(1); } } catch (IOException e) { System.err.println("Error while unzipping " +map.get("other")[0].toString()); e.printStackTrace(); System.exit(-41); } } else if(map.get("two")[0].equals(true)) { file = initAchiveFile(map.get("other")[0].toString()); targetDirectory = Paths.get(map.get("other")[1].toString()); UnZipper zipper; try { zipper = new UnZipper(file.toFile()); zipper.setOptionMap(map); zipper.extract(targetDirectory); } catch (IOException e) { System.err.println("Error while unzipping " +map.get("other")[0].toString()); e.printStackTrace(); System.exit(-42); } } System.exit(0); }
fed36f9c-9579-4b19-9b47-cfe0ff76e554
4
public Connection getConnection() { if (_connection == null) { try { _connection = ConnectionContext.getConnection(); if (!_connection.isConnected()) { _connection.connect("USER","_SYSTEM","DATA"); } } catch (GlobalsException ex) { log.WriteToFile(ex.getMessage(), true); throw ex; } catch (Exception ex) { log.WriteToFile(ex.getMessage(), true); } } return _connection; }
a959a861-68e4-4ca9-a810-dc744f396919
7
public void init() { String serverConnectStr = "Enter server: "; while (true) { String hostStr = JOptionPane.showInputDialog(serverConnectStr, Connection.DEFAULT_HOST + ":" + String.valueOf(Connection.DEFAULT_PORT)); if (hostStr == null) { return; } try { this.conn = new Connection(hostStr); break; } catch (NumberFormatException e) { serverConnectStr = "Invalid port. Enter server:"; } } this.net = new NetManager(conn); try { net.connectToServer(); userName = (String) JOptionPane.showInputDialog("Write username!"); if (userName == null) { return; } else if (userName.length() == 0) { JOptionPane.showMessageDialog(null, "Empty user name not allowed.", "Error", JOptionPane.ERROR_MESSAGE); return; } InitializeClientMessage icm = new InitializeClientMessage(userName); Encoder enc = new Encoder(); String mess; try { mess = enc.encode(icm); net.send(mess); } catch (JSONException e) { JOptionPane.showMessageDialog(null, "Can't connect to server!", "Warning", JOptionPane.ERROR_MESSAGE); } this.stage = 1; Tick(); } catch (IOException e) { e.printStackTrace(); } }
15cb18ca-16cb-4567-b03c-5df045ae56a2
7
public void traverseRayTopDown(OctreeHitResult hit_result){ if( hit_result == null ){ return ; } IDX_SHFT = 0; DwRay3D ray_mod = hit_result.ray.copy(); // copy ray if( mirrorComponent(root.aabb, ray_mod, 0) ) IDX_SHFT |= 4; if( mirrorComponent(root.aabb, ray_mod, 1) ) IDX_SHFT |= 2; if( mirrorComponent(root.aabb, ray_mod, 2) ) IDX_SHFT |= 1; // get intersection intervals float[] t0 = DwVec3.multiply_new(DwVec3.sub_new(root.aabb.min, ray_mod.o), ray_mod.d_rec); float[] t1 = DwVec3.multiply_new(DwVec3.sub_new(root.aabb.max, ray_mod.o), ray_mod.d_rec); OctreeTraversalData otd = new OctreeTraversalData(root,t0,t1); // if ray hits octree (root), traverse childs if( otd.tNear() < otd.tFar() ){ // traverseOctree(otd, hit_result); traverseOctreeRecursive(otd, hit_result); for( OctreeTraversalData td_checked : hit_result.traversal_history){ for(int id : td_checked.node.IDX_triangles){ obj.f[id].FLAG_CHECKED = false; // reset flags! } } } }
279d73bf-9360-4fac-86c7-00a9f5a16b19
8
@Override public HashMap<String,ClassNode> refactor(){ //if (!Updater.useOutput) // Deob.deobOutput.add("* Starting Arithmetic Deob*"+System.getProperty("line.separator")); System.out.println("* Starting Arithmetic Deob*"); List<InsnWrapper> replace = getInstructions(); for(InsnWrapper wrap : replace){ for(ClassNode node : classes.values()){ if(!wrap.owner.equals(node.name)) continue; for (MethodNode mn : (Iterable<MethodNode>) node.methods) { if(mn.name.equals(wrap.mn.name) && mn.desc.equals(wrap.mn.desc)) { int i = 0; while (i < mn.instructions.size()) { if (!wrap.insnArray.get(i).equals(null)) mn.instructions.set(mn.instructions.get(i), wrap.insnArray.get(i)); i++; } } } } } //if (!Updater.useOutput) // Deob.deobOutput.add("* Arithmetic Deob Finished*"+System.getProperty("line.separator")); System.out.println("* Arithmetic Deob Finished*"); return classes; }
13f5419b-8394-4072-819b-1bc5d1c1c1a4
5
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Hospedagem other = (Hospedagem) obj; if (this.IdHospedagem != other.IdHospedagem && (this.IdHospedagem == null || !this.IdHospedagem.equals(other.IdHospedagem))) { return false; } return true; }
97e6e737-9dd2-499f-99ca-d418d7236612
9
public static String getFormattedTime(int time) { // throws Exception{ if (time < 10 && time >= 0) { return String.format("0%d00", time); } else if (time <= 24 && time >= 0) { return String.format("%d00", time); } else if (time >= 100 && time <= 2400) { if (time % 100 < 60 && time % 100 >= 0) { if (time >= 1000) { return String.format("%d", time); } else { return String.format("0%d", time); } } } return ""; // Added to return false result // throw new Exception("Invalid time."); }
0a0e5e9b-8a95-422d-ad42-1bea1c29bfb3
0
public DefaultTempFile(String tempdir) throws IOException { file = File.createTempFile("NanoHTTPD-", "", new File(tempdir)); fstream = new FileOutputStream(file); }
53c00164-e675-4996-be49-f83e9e822db7
8
void shutdown() { if (preferences != null && owner != null) { Rectangle bounds = owner.getBounds(); preferences.putInt("Upper-left x", bounds.x); preferences.putInt("Upper-left y", bounds.y); MenuBar menuBar = (MenuBar) owner.getJMenuBar(); preferences.put("Latest E2D Path", menuBar.getLatestPath("e2d")); preferences.put("Latest HTM Path", menuBar.getLatestPath("htm")); preferences.put("Latest PNG Path", menuBar.getLatestPath("png")); preferences.put("Latest IMG Path", menuBar.getLatestPath("img")); String[] recentFiles = menuBar.getRecentFiles(); if (recentFiles != null) { int n = recentFiles.length; if (n > 0) for (int i = 0; i < n; i++) preferences.put("Recent File " + i, recentFiles[n - i - 1]); } preferences.putInt("Sensor Maximum Data Points", Sensor.getMaximumDataPoints()); } MiscUtil.shutdown(); if (launchedByJWS || "true".equalsIgnoreCase(System.getProperty("NoUpdate"))) { System.exit(0); } else { if (appDirectoryWritable) { owner.setVisible(false); // UpdateStub.update(); Updater.install(); } System.exit(0); } }
0b5c5e57-f11c-4b26-a024-af623852b174
7
public void handle(String target, Request serverRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (!target.equals("/shutdown") || !request.getMethod().equals("POST") || !secret.equals(request.getParameter("secret"))) return; try { // You should probably do something clever with this if you handle a lot of transactions etc // BigIP fortunately handles sessions to my nodes, so I haven't put much effort into this. response.setStatus(SC_OK); PrintWriter out = response.getWriter(); out.println("Shutting down"); try { out.close(); } catch (Exception ignored) {} try { context.stop(); } catch (Exception ignored) {} try { server.stop(); } catch (Exception ignored) {} } catch (Exception ignored) {} System.exit(0); }
5c810209-4eda-4c94-9a6f-1dcde9dbf4d0
6
void createColorAndFontGroup () { super.createColorAndFontGroup(); TableItem item = new TableItem(colorAndFontTable, SWT.None); item.setText(ControlExample.getResourceString ("Item_Foreground_Color")); item = new TableItem(colorAndFontTable, SWT.None); item.setText(ControlExample.getResourceString ("Item_Background_Color")); item = new TableItem(colorAndFontTable, SWT.None); item.setText(ControlExample.getResourceString ("Item_Font")); item = new TableItem(colorAndFontTable, SWT.None); item.setText(ControlExample.getResourceString ("Cell_Foreground_Color")); item = new TableItem(colorAndFontTable, SWT.None); item.setText(ControlExample.getResourceString ("Cell_Background_Color")); item = new TableItem(colorAndFontTable, SWT.None); item.setText(ControlExample.getResourceString ("Cell_Font")); shell.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { if (itemBackgroundColor != null) itemBackgroundColor.dispose(); if (itemForegroundColor != null) itemForegroundColor.dispose(); if (itemFont != null) itemFont.dispose(); if (cellBackgroundColor != null) cellBackgroundColor.dispose(); if (cellForegroundColor != null) cellForegroundColor.dispose(); if (cellFont != null) cellFont.dispose(); itemBackgroundColor = null; itemForegroundColor = null; itemFont = null; cellBackgroundColor = null; cellForegroundColor = null; cellFont = null; } }); }
9dc385d2-6cf2-4e7d-a9d6-4620dadb3081
1
public synchronized boolean remover(int i) { try { new PesquisaDAO().remover(list.get(i)); list = new PesquisaDAO().listar(""); preencherTabela(); } catch (Exception e) { return false; } return true; }
0dbe3098-dd56-489a-a02e-fd17cce9d3cb
5
private void calculateSimilarities() { for (Integer user1 : userRatedMovies.keySet()) { for (Integer user2 : userRatedMovies.keySet()) { if (user1 > user2) { double sim = computeSimilarity(user1, user2); if (similarities.containsKey(user1)) { similarities.get(user1).put(user2, sim); } else { LinkedHashMap<Integer, Double> s = new LinkedHashMap<Integer, Double>(); s.put(user2, sim); similarities.put(user1, s); } if (similarities.containsKey(user2)) { similarities.get(user2).put(user1, sim); } else { LinkedHashMap<Integer, Double> s = new LinkedHashMap<Integer, Double>(); s.put(user1, sim); similarities.put(user2, s); } } } } }
e8842ada-bc0c-45ff-bc9f-aa2cf90ddcee
3
public ParseTree optimise(ParseTree root) { //This is the root that will replace the unoptimised root ParseTree optimisedTree = new ParseTree(); //Copy the root's data into the optimised tree optimisedTree.value = root.value; optimisedTree.attribute = root.attribute; //Optimise all children if (root.children != null && root.children.size() > 0) for (int i = 0; i < root.children.size(); i++) optimisedTree.children.add(optimise(root.children.get(i))); //Optimise the current node optimisedTree = optimiseNode(optimisedTree); return optimisedTree; }
22746874-154c-49b3-8bae-5424e55de785
4
private void guardarNuevo(){ if(partida.getInvasores() != null){ final String nombre = JOptionPane.showInputDialog( this, "El nombre del juego debe estar\ncomprendido entre 3 y 15 caracteres " ,"¿Con qué nombre quieres guardar el juego?", JOptionPane.QUESTION_MESSAGE ); if(nombre == null|| nombre.length() < 3 || nombre.length() > 15) return; partida.getJuego().setNombre(nombre); lblInfoGuardar.setText("> Guardando, espera unos instantes ..."); new Thread(new Runnable(){ @Override public void run() { dao.insert(partida); refrescarPartidas(); lblInfoGuardar.setText("> Partida guardada con éxito."); } }).start(); } else { lblInfoGuardar.setText("> ¡No puedes guardar una partida que no existe!"); } }
b8ffc3ac-0c6a-4ae7-ab38-2fedfc34424c
4
public int getItemRankLevel(String rank){ String r = rank; if(r.equalsIgnoreCase("*")){ return 1; }else if(r.equalsIgnoreCase("**")){ return 2; }else if(r.equalsIgnoreCase("***")){ return 3; }else if(r.equalsIgnoreCase("****")){ return 4; }else{ return 0; } }
bde07cd1-d973-45f0-aa69-848ac273b828
9
private boolean formulaOK(Stock stock, ArrayList<EconomicIndicator> indicatorsTest, ArrayList<Double> formula) { //Will all indicators very high result in an unusable price? double calcPrice = 0; for (int i = 0; i < indicators.size(); i++){ calcPrice += indicatorsMin.get(i) * formula.get(i); } if(calcPrice > STOCK_MAX_PRICE || calcPrice < STOCK_MIN_PRICE) return false; //Will all indicators very low result in an unusable price? calcPrice = 0; for (int i = 0; i < indicators.size(); i++){ calcPrice += indicatorsMax.get(i) * formula.get(i); } if(calcPrice > STOCK_MAX_PRICE || calcPrice < STOCK_MIN_PRICE) return false; //run through the formula and see if at any point the price goes outside the limits ArrayList <EconomicIndicator> testindicators = copyIndicaotrs(indicators); for (int i = 1; i < MAX_ROUNDS*2; i++){ updateIndicatorsTrend(i, testindicators); stock.updatePrice(i, calculateBasicStockPrice(stock, testindicators, formula)); if(stock.currentPrice() >= STOCK_MAX_PRICE || stock.currentPrice() <= (STOCK_MIN_PRICE)){ return false; } } return true; }
050c4559-f8c2-434b-9af5-c8f3e6db5f0c
8
private Map<Integer, Integer> dijkstra(Integer start, Integer stop) { for (Integer inte : graph.getEdges()) { PonderatePoint pp; if(inte.equals(start)) { pp = new PonderatePoint(inte,0); } else{ pp = new PonderatePoint(inte,INFINITE); } predecessors.put(inte, -1); vertex.add(pp); distance.put(inte, (inte.equals(start)) ? 0 : INFINITE); }; while(!vertex.isEmpty()) { int t = vertex.pollFirst().getName(); Iterator<?> neighbors = graph.neighbors(t); int s, dt, weightTS; while(neighbors.hasNext()) { if(stop.compareTo(t) == 0) { return predecessors; } s = (Integer) neighbors.next(); dt = distance.get(t); weightTS = graph.getWeight(t, s); int ds = distance.get(s); if(dt + weightTS < ds) { distance.put(s, dt + weightTS); predecessors.put(s, t); vertex.add(new PonderatePoint(s, dt+weightTS)); } } } return predecessors; }
5f17a3a3-af25-4a6d-8f19-2dd143879ed5
3
public AnimExplosion(float width, float height) { SpriteSheet explosion = null; try { explosion = new SpriteSheet("resources/explosion.png", 256, 256); } catch (SlickException e) { // TODO Auto-generated catch block e.printStackTrace(); } explode = new Animation(); for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { explode.addFrame(explosion.getSprite(j, i), 20); } } explode.setLooping(false); WIDTH = width; HEIGHT = height; }
9cc88786-5f6b-44dd-8b62-3e10672fcc01
9
public static void evalPrecision(Dataset dataset) { double trainTotal = 0, trainCorrect = 0; double testTotal = 0, testCorrect = 0; double quizTotal = 0, quizCorrect = 0; for(Instance inst : dataset.data) { if(inst.type == InstanceType.Train) { trainTotal++; if(inst.target == inst.predict) trainCorrect++; } else if(inst.type == InstanceType.Test) { testTotal++; if(inst.target == inst.predict) testCorrect++; } else { quizTotal++; if(inst.target == inst.predict) quizCorrect++; } } if(trainTotal > 0) System.out.print(String.format("Train: %.4f %d\t", trainCorrect/trainTotal, (int)trainTotal)); if(testTotal > 0) System.out.print(String.format("Test: %.4f %d\t", testCorrect/testTotal, (int)testTotal)); if(quizTotal > 0) System.out.print(String.format("Quiz: %.4f %d\t", quizCorrect/quizTotal, (int)quizTotal)); System.out.println(); }
2a0ed7f1-62a1-4951-b6a7-3b5375f3e854
9
private void writeEscaped(final char[] buffer, final int offset, final int len) throws IOException { final int maxi = offset + len; for (int i = offset; i < maxi; i++) { final char c = buffer[i]; if (c == '\n') { this.writer.write("<br />"); } else if (c == ' ') { this.writer.write("&nbsp;"); } else if (c == '\t') { this.writer.write("&nbsp;&nbsp;&nbsp;&nbsp;"); } else if (c == '<') { this.writer.write("&lt;"); } else if (c == '>') { this.writer.write("&gt;"); } else if (c == '&') { this.writer.write("&amp;"); } else if (c == '\"') { this.writer.write("&quot;"); } else if (c == '\'') { this.writer.write("&#39;"); } else { this.writer.write(c); } } }
71a72678-7b2b-4836-966f-130b3c1223bc
8
public void updateLatestWrite(ReadIncOperation riop) { ReadIncOperation riop_var_wriop = null; for (String var : GlobalData.VARSET) // variable by variable { riop_var_wriop = riop.getLatestWriteMap().getLatestWrite(var); if (riop_var_wriop != null) if (this.getLatestWrite(var) == null || this.getLatestWrite(var).getWid() < riop_var_wriop.getWid()) this.latestWriteMap.put(var, riop_var_wriop); // update to the most latest one } if (riop.isWriteOp() && ! riop.getWritetoOrder().isEmpty()) // there is some READ reads from @param riop { String var = riop.getVariable(); if (this.getLatestWrite(var) == null) this.latestWriteMap.put(var, riop); else if (this.getLatestWrite(var).getWid() < riop.getWid()) this.latestWriteMap.put(var, riop); } }
ad73381d-f100-40e6-ab2d-0ae71bb60e42
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(Update.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Update.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Update.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Update.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the dialog */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { Update dialog = new Update(null, true, true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); }
bbb26636-3ef7-477e-9021-4a9e41b610f4
6
public final void setMeso(final int meso) { if (locked || partner == null || meso <= 0 || this.meso + meso <= 0) { return; } if (chr.getMeso() >= meso) { chr.gainMeso(-meso, false, true, false); this.meso += meso; chr.getClient().getSession().write(MaplePacketCreator.getTradeMesoSet((byte) 0, this.meso)); if (partner != null) { partner.getChr().getClient().getSession().write(MaplePacketCreator.getTradeMesoSet((byte) 1, this.meso)); } } }
49ad98ab-084d-417a-99fa-41fc0a7f2dfd
4
public ServerListen(Socket connection) { try { ObjectInputStream oInputStream; ObjectOutputStream oOutputStream; this.connection = connection; oInputStream = new ObjectInputStream(connection.getInputStream()); client = (Player) oInputStream.readObject(); clientIp = connection.getInetAddress().getHostAddress(); username = client.getPlayerName(); for (int i = 0; i < Server.players.size(); i++) { if(Server.players.get(i).getPlayerName().equals(username)) { client.setPlayerName(username + "(1)"); } } Server.players.add(client); oOutputStream = new ObjectOutputStream(connection.getOutputStream()); oOutputStream.writeObject(client.getPlayerName()); System.out.println("Server: Client with username:"+ client.getPlayerName() + " connected successfully"); Server.list_clients_model.addElement(client.getPlayerName() + " - " + clientIp); System.out.println("Server: Thread for user " + client.getPlayerName() + " successfully started!"); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
b4f04c52-632a-4c7b-bcdd-e3ba7e018a20
3
int getOrderIndex () { CTableColumn[] orderedColumns = parent.orderedColumns; if (orderedColumns == null) return getIndex (); for (int i = 0; i < orderedColumns.length; i++) { if (orderedColumns [i] == this) return i; } return -1; }
4678cadc-e0c4-4803-8371-6d9d5974d625
5
public void edit(Employee employee) throws NonexistentEntityException, Exception { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); employee = em.merge(employee); em.getTransaction().commit(); } catch (Exception ex) { String msg = ex.getLocalizedMessage(); if (msg == null || msg.length() == 0) { Long id = employee.getId(); if (findEmployee(id) == null) { throw new NonexistentEntityException("The employee with id " + id + " no longer exists."); } } throw ex; } finally { if (em != null) { em.close(); } } }
8ec4b657-ce55-4c53-949c-01d223488fa0
1
protected int Seek(long offset) { int rc; try { file.seek(offset); rc = DDC_SUCCESS; } catch (IOException ioe) { rc = DDC_FILE_ERROR; } return rc; }
ed63b0aa-4c7a-48c6-b834-a570843a0b85
6
private int getFirstIdenticalVertexId(Model model, int vertex) { int vertexId = -1; int x = model.verticesX[vertex]; int y = model.verticesY[vertex]; int z = model.verticesZ[vertex]; for (int v = 0; v < vertexCount; v++) { if (x != verticesX[v] || y != verticesY[v] || z != verticesZ[v]) continue; vertexId = v; break; } if (vertexId == -1) { verticesX[vertexCount] = x; verticesY[vertexCount] = y; verticesZ[vertexCount] = z; if (model.vertexSkins != null) vertexSkins[vertexCount] = model.vertexSkins[vertex]; vertexId = vertexCount++; } return vertexId; }
a5fde65d-88e1-409a-a857-7132754d794b
7
public void expandNode(final Node n) { new Thread() { public void run() { synchronized (LocalityUtils.this) { if (!locality.getCompleteEltSet().contains(n)) return; tgPanel.stopDamper(); for(int i=0;i<n.edgeNum();i++) { Node newNode = n.edgeAt(i).getOtherEndpt(n); if (!locality.contains(newNode)) { newNode.justMadeLocal = true; try { locality.addNodeWithEdges(newNode); Thread.currentThread().sleep(50); } catch ( TGException tge ) { System.err.println("TGException: " + tge.getMessage()); } catch ( InterruptedException ex ) {} } else if (!locality.contains(n.edgeAt(i))) { locality.addEdge(n.edgeAt(i)); } } try { Thread.currentThread().sleep(200); } catch (InterruptedException ex) {} unmarkNewAdditions(); tgPanel.resetDamper(); } } }.start(); }
6a40c5a4-1105-454d-aae3-2f591652f6e6
1
@Override public boolean checkCanPlace() { boolean canPlace = super.checkCanPlace(); String group = registry.getBlockManager().getBlockGroup(mapX, mapY); if(group.equals("Town")) { canPlace = false; } return canPlace; }
46585ec0-335a-42ba-9a72-ef93bab6449d
0
protected void _reallocate(int newCapacity) { buf = Arrays.copyOf(buf, newCapacity); }
5760a260-4d0a-495a-9d0d-ebb28672e594
6
@Override public void mouseMoved(MouseEvent event) { JFrame frame = Game.get().display.getFrame(); float zoomX = (frame.getWidth()-frame.getInsets().left-frame.getInsets().right)/800f; float zoomY = (frame.getHeight()-frame.getInsets().top-frame.getInsets().bottom)/800f; int mouseX = (int) (event.getX()/zoomX); int mouseY = (int) (event.getY()/zoomY); if(mouseX == Game.get().mouseX && mouseY == Game.get().mouseY){ return; } if(mouseX <800 && mouseX>=0 && mouseY <800 && mouseY>=0){ Game.get().latestMouseX = Game.get().mouseX; Game.get().latestMouseY = Game.get().mouseY; Game.get().mouseX = mouseX; Game.get().mouseY = mouseY; }else{ Game.get().latestMouseX = -1; Game.get().mouseX = -1; Game.get().mouseY = -1; } }
6d7f657f-3f56-4afc-9ed0-bb77463e2ced
4
public void testConstructor_int_int_Chronology() throws Throwable { TimeOfDay test = new TimeOfDay(10, 20, JulianChronology.getInstance()); assertEquals(JulianChronology.getInstanceUTC(), test.getChronology()); assertEquals(10, test.getHourOfDay()); assertEquals(20, test.getMinuteOfHour()); assertEquals(0, test.getSecondOfMinute()); assertEquals(0, test.getMillisOfSecond()); try { new TimeOfDay(-1, 20, JulianChronology.getInstance()); fail(); } catch (IllegalArgumentException ex) {} try { new TimeOfDay(24, 20, JulianChronology.getInstance()); fail(); } catch (IllegalArgumentException ex) {} try { new TimeOfDay(10, -1, JulianChronology.getInstance()); fail(); } catch (IllegalArgumentException ex) {} try { new TimeOfDay(10, 60, JulianChronology.getInstance()); fail(); } catch (IllegalArgumentException ex) {} }
a8032f93-7b6c-465d-a6b6-dd36e232b74d
6
private void actionListener(){ mntmClientes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new AddCliente(); } }); mntmFuncionarios.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new AddFuncionario(); } }); mntmClientes_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new DelCliente(); } }); mntmFuncionarios_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new DelFuncionario(); } }); mntmProdutos.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AddProdutos(); } }); mntmProdutos_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new DelProdutos(); } }); mntmSair.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); tglbtn_vendaPorCliente.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (tglbtn_VendaPorFuncionario.isSelected()) { tglbtn_VendaPorFuncionario.setSelected(false); } else if ( tglbtn_VendaPorMes.isSelected() ) { tglbtn_VendaPorMes.setSelected(false); } else { tabelaVendaFunc.setVisible(false); tabelaVendaData.setVisible(false); tabelaVendaCliente.setVisible(true); } } }); tglbtn_VendaPorFuncionario.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (tglbtn_vendaPorCliente.isSelected()) { tglbtn_vendaPorCliente.setSelected(false); } else if ( tglbtn_VendaPorMes.isSelected() ) { tglbtn_VendaPorMes.setSelected(false); } else { tabelaVendaCliente.setVisible(false); tabelaVendaData.setVisible(false); tabelaVendaFunc.setVisible(true); } } }); tglbtn_VendaPorMes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (tglbtn_VendaPorFuncionario.isSelected()) { tglbtn_VendaPorFuncionario.setSelected(false); } else if ( tglbtn_vendaPorCliente.isSelected() ) { tglbtn_vendaPorCliente.setSelected(false); } else { tabelaVendaCliente.setVisible(false); tabelaVendaFunc.setVisible(false); tabelaVendaData.setVisible(true); } } }); mntmClientes_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new ClienteTable(); } }); mntmProdutos_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new ProdutosTable(); } }); mntmFuncionario.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new FuncionarioTable(); } }); }
e3295c08-9cdb-446a-955b-644911d34a25
3
private String getFileChecksum() throws IOException, NoSuchAlgorithmException { InputStream in = new FileInputStream(file.getAbsolutePath()); byte[] buffer = new byte[1024]; int bytes_read; MessageDigest complete = MessageDigest.getInstance("MD5"); do { bytes_read = in.read(buffer); if(bytes_read>0) complete.update(buffer, 0, bytes_read); }while(bytes_read!=-1); in.close(); byte[] b = complete.digest(); String result = ""; for(int i = 0;i<b.length;i++) result += Integer.toString( (b[i]&0xff) + 0x100, 16).substring(1); return result; }
f12795d5-718c-4122-b01d-b952e9b0d1fa
9
private void addButtonSet(JPanel panel, String[] buttons, int rows, int leftPadding) { int row = 0; int column = 1; for (String numButton : buttons) { String[] sizeText = numButton.split(","); int width = SMALL_BUTTON_WIDTH; int sep = SMALL_BUTTON_SEP; int rowAdd = 1; if (sizeText[0].equalsIgnoreCase("L")) { width = LARGE_BUTTON_WIDTH; sep = sep * 2; rowAdd++; } if (!sizeText[1].equalsIgnoreCase("SPACER")) { JButton button = new JButton(sizeText[1]); button.setBounds(leftPadding + sep * row, PADDING + (BUTTON_HEIGHT + PADDING) * column, width, BUTTON_HEIGHT); if (sizeText[1].equalsIgnoreCase("\u2190")) { button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = output.getText(); if (text.length() > 0) output.setText(text.substring(0, text.length() - 1)); if (output.getText().length() == 0) output.setText("0"); } }); } else if (sizeText[1].equalsIgnoreCase("=")) { button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { solver.solve(output.getText()); } }); } else if (sizeText[1].equalsIgnoreCase("AC")) { button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { output.setText("0"); } }); } else { button.addActionListener(new SpecifiedActionListener(this, sizeText[2], sizeText[2].equalsIgnoreCase("."))); } button.setMargin(new Insets(0, 0, 0, 0)); panel.add(button); } row += rowAdd; if (row >= rows) { row = 0; column++; } } }
fb9f0fae-ad71-4211-8c7a-b982c4e72668
1
@Override public BigDecimal getPrice(String sku) throws SkuNotFoundException { final BigDecimal price = this.dataAccess.getPriceBySku(sku); if (price == null) { throw new SkuNotFoundException(); } return price.add(price); }
ce243002-b89d-4ae9-8107-080157293e28
1
private boolean jj_3R_74() { if (jj_3R_72()) return true; return false; }
ded7b4d6-583b-4640-8a1d-d453cbfb83bd
8
public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); //System.out.println("Release: " + e.getKeyText(e.getKeyCode())); KeyBoard mInstance = KeyBoard.getInstance(); switch (keyCode) { case KeyEvent.VK_UP : mInstance.Release(KeyBoard.KEY_CODE.KEY_UP); break; case KeyEvent.VK_DOWN : mInstance.Release(KeyBoard.KEY_CODE.KEY_DOWN); break; case KeyEvent.VK_RIGHT : mInstance.Release(KeyBoard.KEY_CODE.KEY_RIGHT); break; case KeyEvent.VK_LEFT : mInstance.Release(KeyBoard.KEY_CODE.KEY_LEFT); break; case KeyEvent.VK_Z : mInstance.Release(KeyBoard.KEY_CODE.KEY_Z); break; case KeyEvent.VK_X : mInstance.Release(KeyBoard.KEY_CODE.KEY_X); break; case KeyEvent.VK_C : mInstance.Release(KeyBoard.KEY_CODE.KEY_C); break; case KeyEvent.VK_SPACE : mInstance.Release(KeyBoard.KEY_CODE.KEY_SPACE); break; default: break; } }
0f2d3dc1-efab-4a8b-acb5-b474f8d7aac6
1
@Override public boolean equals(final Object obj) { final ComparableNumber num; try { num = (ComparableNumber) obj; } catch (ClassCastException c) { return false; } return number.equals(num.getNumber()); }
0b7e00f0-58e4-4b6b-b4ec-d89dc1189088
7
static final public void sum() throws ParseException { term(); label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: case MINUS: ; break; default: jj_la1[1] = jj_gen; break label_1; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: jj_consume_token(PLUS); break; case MINUS: jj_consume_token(MINUS); break; default: jj_la1[2] = jj_gen; jj_consume_token(-1); throw new ParseException(); } term(); } }
40d757b4-fc27-4b8f-8142-2ffa0e9b005e
6
public void generateHardwareSetAlternatives() { generateDummyHardwareAlternatives(); for (HardwareAlternative cpuAlternative : cpuAlternatives) for (HardwareAlternative hddAlternative : hddAlternatives) for (HardwareAlternative memoryAlternative : memoryAlternatives) for (HardwareAlternative networkAlternative : networkAlternatives) for (HardwareAlternative platformAlternative : platformAlternatives) for (HardwareAlternative otherAlternative : otherAlternatives) { HardwareSetAlternative hardwareSetAlternative = new HardwareSetAlternative(this); hardwareSetAlternative.setCpuAlternative(cpuAlternative); hardwareSetAlternative.setHddAlternative(hddAlternative); hardwareSetAlternative.setMemoryAlternative(memoryAlternative); hardwareSetAlternative.setNetworkAlternative(networkAlternative); hardwareSetAlternative.setPlatformAlternatives(platformAlternative); hardwareSetAlternative.setOtherAlternative(otherAlternative); hardwareSetAlternative.initializeId(); hardwareSetAlternatives.add(hardwareSetAlternative); } }
27c331ad-c905-4580-adea-b20d909a9f0a
8
@Override public void collides(Entity... en) { for (Bullet B : b) { if (B == null || B.getBounds() == null || B == null || B.cull()) { continue; } for (Entity e : en) { if (e == B) continue; Polygon p = e.getBounds(); if (B.shape.intersects(e.getBounds())) { B.takeDamage(e.doDamage()); e.takeDamage(B.doDamage()); return; } } } return; }
a938eef0-7907-45dc-b610-25bf551caab6
9
@Override protected boolean isSubTypeOf(final BasicValue value, final BasicValue expected) { Type expectedType = expected.getType(); Type type = value.getType(); switch (expectedType.getSort()) { case Type.INT: case Type.FLOAT: case Type.LONG: case Type.DOUBLE: return type.equals(expectedType); case Type.ARRAY: case Type.OBJECT: if ("Lnull;".equals(type.getDescriptor())) { return true; } else if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { return isAssignableFrom(expectedType, type); } else { return false; } default: throw new Error("Internal error"); } }
5f4626ce-0582-45d6-9519-a196bfe2c66a
6
@Override public Choice getChoice(List<Choice> choices) { while (true) { for (int i = 0; i < choices.size(); i++) { Choice mc = choices.get(i); System.out.print((i+1) + ". "); System.out.println(mc.getDescription()); } // ask for input String input = console.nextLine(); try { int choiceNum = Integer.parseInt(input); if(choiceNum>choices.size()||choiceNum<=0){ System.out.println("INVALID CHOICE! Choose one of the options below."); System.out.println(); } else{ return choices.get(choiceNum-1); } } catch (NumberFormatException ex) { if (!input.equals("q")) { System.out.println(); System.out.println("I'm sorry, I didn't understand that command."); System.out.println("Please choose a number from the list, or type 'q' to quit."); System.out.println(); } else { return null; } } } }
c1dc978e-a15f-4b5e-b1cb-7f7c62290eb2
9
static void initiateParameters() throws IOException { InputParams inputParams = new InputParams(); while (!inputParams.isFinised) { sikuli.wait(1); } rowNum = inputParams.getRowNum(); cowNum = inputParams.getCowNum(); cards = new Card[rowNum + 2][cowNum + 2]; isScaned = new boolean[rowNum + 2][cowNum + 2]; for (int i = 0; i < rowNum + 2; i++) for (int j = 0; j < cowNum + 2; j++) { cards[i][j] = new Card(); if (i == 0 || j == 0 || i == rowNum + 1 || j == cowNum + 1) { cards[i][j].setKind(0); isScaned[i][j] = true; } } capturePicDirectory = System.getProperty("user.dir"); capturePicDirectory += File.separator + "capture.png"; BufferedImage fatherImage = ImageIO.read(new File(capturePicDirectory)); captureHeight = fatherImage.getHeight(); captureWidth = fatherImage.getWidth(); sikuli.wait(5); CardHeight = captureHeight / rowNum; CardWidth = captureWidth / cowNum; ScreenRegion fatherRegion = sikuli.find(capturePicDirectory); sikuli.wait(5); Assert.assertNotNull(fatherRegion); GameX = fatherRegion.getUpperLeftCorner().getX(); GameY = fatherRegion.getUpperLeftCorner().getY(); Coordinate coordinate = null; int kind = 1; while ((coordinate = getNextEmpty()) != null) { BufferedImage sonImage = null; sonImage = fatherImage.getSubimage((coordinate.getC() - 1) * (CardWidth + 1), (coordinate.getR() - 1) * (CardHeight + 1), CardWidth - cowNum + 1, CardHeight - rowNum + 1); Target finaltarget = new ColorImageTarget(sonImage); // set the similarity between the target region and the screenRegion finaltarget.setMinScore(0.8); List<ScreenRegion> finalRegions = sikuli.findAll(finaltarget); // just for debuging for (ScreenRegion screenRegion : finalRegions) { int c = (screenRegion.getCenter().getX() - GameX) / CardWidth; int r = (screenRegion.getCenter().getY() - GameY) / CardHeight; cards[r + 1][c + 1] = new Card(); cards[r + 1][c + 1].setKind(kind); isScaned[r + 1][c + 1] = true; } kind++; } }
7161301b-df8a-4e0e-93a5-36096d22d1f2
0
@Override public String toString() { return this.value; }
d31363b2-8ded-4594-bb2b-1427cf136d06
6
public static void save(double[] input, String filename) { // assumes 44,100 samples per second // use 16-bit audio, mono, signed PCM, little Endian AudioFormat format = new AudioFormat(SAMPLE_RATE, 16, 1, true, false); byte[] data = new byte[2 * input.length]; for (int i = 0; i < input.length; i++) { int temp = (short) (input[i] * MAX_16_BIT); data[2*i + 0] = (byte) temp; data[2*i + 1] = (byte) (temp >> 8); } // now save the file try { ByteArrayInputStream bais = new ByteArrayInputStream(data); AudioInputStream ais = new AudioInputStream(bais, format, input.length); if (filename.endsWith(".wav") || filename.endsWith(".WAV")) { AudioSystem.write(ais, AudioFileFormat.Type.WAVE, new File(filename)); } else if (filename.endsWith(".au") || filename.endsWith(".AU")) { AudioSystem.write(ais, AudioFileFormat.Type.AU, new File(filename)); } else { throw new RuntimeException("File format not supported: " + filename); } } catch (Exception e) { System.out.println(e); System.exit(1); } }
b28ef7c7-06d9-4f1e-b91e-a0127c0f9df4
7
@Override public void preUpdate() { if(destruction) destroy(); if(x<=16 || x>=map.getMapWidth()-16 ) hspeed=-hspeed; if( y<=16 || y>=map.getMapHeight()-16) vspeed=-vspeed; if(!activated && placeFree() ) { activated=true; } // TODO Auto-gene rated method stub }
98d08793-de1e-4607-b30e-1565d8fdac55
4
public void render(GameObject object) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); forwardAmbient.bind(); object.renderAll(forwardAmbient, this); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glDepthMask(false); glDepthFunc(GL_EQUAL); for(BaseLight light : lights) { activeLight = light; object.renderAll(light.getShader(), this); } glDepthFunc(GL_LESS); glDepthMask(true); Vector3f oldAmbient = getVector3f("ambient"); forwardAmbient.bind(); for(BaseLight light : lights) { if(light instanceof PointLight && !(light instanceof SpotLight)) { Quaternion currentRot = light.getTransform().getRotation(); light.getTransform().lookAt(mainCamera.getTransform().getPosition(), new Vector3f(0, 1, 0)); addVector3f("ambient", light.getColor()); forwardAmbient.updateUniforms(light.getTransform(), flareMat, this); flareMesh.draw(); light.getTransform().setRotation(currentRot); } } addVector3f("ambient", oldAmbient); glDisable(GL_BLEND); }
80ce47e8-d504-439b-b845-200ecf36b993
5
public CheckResultMessage checkF08(int day) { int r1 = get(20, 5); int c1 = get(21, 5); int r2 = get(47, 5); int c2 = get(48, 5); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); if (0 != getValue(r1 + 8, c1 + day, 5).compareTo( getValue(r2 + day, c2 + 2, 12))) { return error("支付机构汇总报表<" + fileName + ">向备付金银行缴存现金形式预付卡押金F08 = N3:" + day + "日错误"); } in.close(); } catch (Exception e) { } } else { try { in = new FileInputStream(file); xWorkbook = new XSSFWorkbook(in); if (0 != getValue(r1 + 8, c1 + day, 5).compareTo( getValue(r2 + day, c2 + 2, 12))) { return error("支付机构汇总报表<" + fileName + ">向备付金银行缴存现金形式预付卡押金F08 = N3:" + day + "日错误"); } in.close(); } catch (Exception e) { } } return pass("支付机构汇总报表<" + fileName + ">向备付金银行缴存现金形式预付卡押金F08 = N3:" + day + "日正确"); }
e1e05aba-7d8c-429b-8320-5d79b81fd3cd
0
public String getName() { return this._name; }
eb8d6367-af7f-4a82-bf1b-92603639de21
3
public static void keyDown(long delta, int key) { switch (key) { case Keyboard.KEY_UP: Game.player.jump(delta); break; case Keyboard.KEY_LEFT: Game.player.move(delta, "left"); break; case Keyboard.KEY_RIGHT: Game.player.move(delta, "right"); break; default: System.err.println(Keyboard.getKeyName(key) + " is not supported"); } }
2a68e56d-fcad-4a51-9ff4-5b9f2b9d6d5d
4
private PreparedStatement statement(Object[] args, Sql annotation, Connection c) throws SQLException { logger.info("Start prepare statement"); Map<String, Object> queryParams = new HashMap<String, Object>(); int argNr = 1; if (args != null) { for (Object arg: args) { Mapper mapper = Mapper.Registry.get(arg.getClass()); Map map = null; if (mapper != null) { map = mapper.toMap(arg); } if (map != null) { queryParams.putAll(mapper.toMap(arg)); } else { queryParams.put(argNr+"", arg); } argNr++; } } PreparedStatement st = PreparedStatementEx.prepare(c, annotation.value(), queryParams); return st; }
59159659-949e-4a6b-be6f-315574f3c77d
6
public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int l = Integer.parseInt(br.readLine()); String[] in = br.readLine().split(" "); int[] r = new int[l]; int max_all = 0; for (int i = 0; i < l; i++) { int max = Integer.MIN_VALUE; int currNum = Integer.parseInt(in[i]); for (int j = 0; j < i; j++) { int num = Integer.parseInt(in[j]); if (num <= currNum) { max = max > r[j] ? max : r[j]; } } if (max < 0) max = 0; max = max + currNum; r[i] = max; max_all = max_all > max ? max_all : max; } System.out.println(max_all); }
7b5d3e9a-432d-42db-a69e-654c64b2fc1d
0
public void setSkillName(String skillName) { this.skillName = skillName; }
4aa651a3-3d37-450f-9c51-5352044250a8
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(Scanner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Scanner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Scanner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Scanner.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 Scanner().setVisible(true); } }); }
61c54f5f-6394-49a5-8c16-81a63e1f0d13
7
@Override public void mouseExited(MouseEvent e) { Virucide.moving = true; try { Robot r = new Robot(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); if (game && !Virucide.menu && !Virucide.pause && !clickedAgain && !Virucide.loose && !Virucide.win) { r.mouseMove((dim.width) / 2, (dim.height) / 2); //basically if the mouse moves off screen set it back to the center Virucide.oldx = (dim.width) / 2; Virucide.newx = (dim.width) / 2; } } catch (AWTException ex) { } Virucide.moving = false; }
e96b8d25-e4f3-4b0d-ae67-a2b080588d16
1
private void toggleSpareElement(boolean direction) { final String SPARE_FILE = baseTestNoteRepository + SPARE_TESTFILE_UUID; File spareFile = new File(SPARE_FILE + ".spare"); File jsonFile = new File(SPARE_FILE + ".json"); if (direction == SPARE2JSON) { assertTrue(spareFile.renameTo(jsonFile)); } else { assertTrue(jsonFile.renameTo(spareFile)); } }
b78a1569-1dfd-4fdd-a4ae-9b5935675a31
8
@Override public char getIndicator() { final int len = source.length(); char ind = (len > 0) ? source.charAt(0) : ' '; switch (ind) { case '*': case '/': case '$': break; case 'D': // Debugging line is marked by a 'D'/'d' followed case 'd': // by space. char next = (len > 1) ? source.charAt(1) : ' '; ind = (next == ' ') ? ind : ' '; break; default : ind = ' '; } return ind; }
c1c0f068-b2dd-4418-afb1-6e987d431b5a
0
public final synchronized void disconnect() { this.quitServer(); }
44235c2c-b623-4a10-9867-1bc31db2206b
5
public void inactivaItem(PosListaPrecio itemOracle, int idPos){ // PREGUNTO SI EL ID DEL ITEM VIENE EN NULO if (itemOracle.getPcaIdElemento() != null) { //TRAIGO EL ITEM POS SEGUN EL PCIDELEMENTO DE ORACLE PhpposItemsEntity itemPos = getItemPos(itemOracle.getPcaIdElemento()); if (itemPos != null) { // SI EXISTE EN EL POS Session hbSession = getSession(); // SESSION MYSQL Transaction ts = hbSession.beginTransaction(); // Inactivo itemPos.setActive(0); getHibernateTemplate().update(itemPos); boolean successMySQL = false; boolean successOracle = false; // se usa el facOracleDao try { // ACTUALIZO PcaEstado en D EN ORACLE successOracle = facOracleDAO.updatePosListaPrecioDisable(itemOracle); successMySQL = true; } catch (Exception e) { e.printStackTrace(); // } finally { if (successMySQL && successOracle) { ts.commit(); hbSession.flush(); hbSession.close(); // LOG ENTRADAS saveLogEntrada(itemOracle, "I", idPos); logger.info(" "); logger.info(" ======== ITEM DESACTIVADO =========================== "); logger.info("itemPos.getItemId() = " + itemPos.getItemId()); logger.info("itemPos.getDescription() = " + itemPos.getDescription()); logger.info("itemPos.getUnitPrice() = " + itemPos.getUnitPrice()); logger.info("itemPos.getQuantity() = " + itemPos.getQuantity()); logger.info("itemPos.getActive() = " + itemPos.getActive()); logger.info(" ======================================================= "); logger.info(" "); } else { ts.rollback(); hbSession.flush(); hbSession.close(); } } // END FINALLY } else { // NO EXISTE EN EL POS logger.info(" ======== ITEM CON PROBLEMAS DE INACTIVATE =============== "); logger.info(" ======== NO EXISTE ITEM EN EL POS CON: =============== "); logger.info("itemOracle.getPcaIdElemento() = " + itemOracle.getPcaIdElemento()); logger.info("itemOracle.getPcaDescripcion() = " + itemOracle.getPcaDescripcion()); logger.info("itemOracle.getPcaPosId() = " + itemOracle.getPcaPosId()); logger.info("idPos = " + idPos); logger.info(" ======================================================= "); } } else { logger.info(" ======== ITEM A DESACTIVAR CON getPcaIdElemento NULL ============= "); logger.info("itemOracle.getPcaIdElemento() = " + itemOracle.getPcaIdElemento()); logger.info("itemOracle.getPcaDescripcion() = " + itemOracle.getPcaDescripcion()); logger.info("itemOracle.getPcaPosId() = " + itemOracle.getPcaPosId()); logger.info("idPos = " + idPos); logger.info(" ======================================================= "); } }
5f56ff51-b245-4fab-bc4f-81945798bbc1
8
private int isNextSequenceCard(Card prev_card, Card this_card, int jokers_inbetween) { int ret = -1; if ((prev_card == null) || (this_card == null)) return ret; if (prev_card.getSuite().compareTo(this_card.getSuite()) != 0) return ret; int pval = Rummy.this.cardValue(prev_card, false); int tval = Rummy.this.cardValue(this_card, false); do { int gap = tval - pval - 1; if ((pval + 1) == tval) { ret = 0; break; } else if ((gap > 0) && (gap <= jokers_inbetween)) { ret = gap; break; } else if (prev_card.getValue() == Card.Value.ACE) pval = 1; // If the card is an ACE, try A,2,3 like sequence else break; } while (true); return ret; }
60d201a3-b247-4b3a-ace6-6558e0c9fc03
1
public StatusModel(String ipaddress) { ip = ipaddress; try { a = (Inet4Address) InetAddress.getByName(ip); } catch (UnknownHostException e) { } }
48c9a354-6139-45be-9589-65e9e3109835
7
public static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double)o).isInfinite() || ((Double)o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); } } else if (o instanceof Float) { if (((Float)o).isInfinite() || ((Float)o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); } } } }
d6dc5c29-fefd-4362-b44e-c8634391265e
9
public void Checkwhile(String cond){ if(new_flag==2){ current_register--; } new_flag=0; current_label++; TypeTable.put(current_register,current_element.E_type); if(cond.equals("TRUE")){ AddOperation("STOREI","1",CString("T",current_register),"dk"); // System.out.println(";STOREI "+"1 "+CString("T",current_register)); current_register++; TypeTable.put(current_register,current_element.E_type); AddOperation("STOREI","1",CString("T",current_register),"dk"); // System.out.println(";STOREI "+"1 "+CString("T",current_register)); AddOperation("NE",CString("T",current_register-1),CString("T",current_register), Integer.toString(current_label)); // System.out.println(";NE "+CString("r",current_register-1)+" "+CString("r",current_register)+" label"+current_label); current_register++; }else if(cond.equals("FALSE")){ AddOperation("STOREI","1",CString("T",current_register),"dk"); // System.out.println(";STOREI "+"1 "+CString("T",current_register)); current_register++; TypeTable.put(current_register,current_element.E_type); AddOperation("STOREI","1",CString("T",current_register),"dk"); // System.out.println(";STOREI "+"1 "+CString("T",current_register)); AddOperation("EQ",CString("T",current_register-1),CString("T",current_register), Integer.toString(current_label)); // System.out.println(";EQ "+CString("T",current_register-1)+" "+CString("T",current_register)+" label"+current_label); current_register++; }else if(cond.equals("!=")){ AddOperation("EQ",CString("T",current_register-1),CString("T",current_register), Integer.toString(current_label)); // System.out.println(";EQ "+CString("T",current_register-1)+" "+CString("T",current_register)+" label"+current_label); }else if(cond.equals(">=")){ AddOperation("LT",CString("T",current_register-1),CString("T",current_register), Integer.toString(current_label)); // System.out.println(";LT "+CString("T",current_register-1)+" "+CString("T",current_register)+" label"+current_label); }else if(cond.equals("<=")){ AddOperation("GT",CString("T",current_register-1),CString("T",current_register), Integer.toString(current_label)); // System.out.println(";GT "+CString("T",current_register-1)+" "+CString("T",current_register)+" label"+current_label); }else if(cond.equals("=")){ AddOperation("NE",CString("T",current_register-1),CString("T",current_register), Integer.toString(current_label)); // System.out.println(";NE "+CString("T",current_register-1)+" "+CString("T",current_register)+" label"+current_label); }else if(cond.equals(">")){ AddOperation("LE",CString("T",current_register-1),CString("T",current_register), Integer.toString(current_label)); // System.out.println(";LE "+CString("T",current_register-1)+" "+CString("T",current_register)+" label"+current_label); }else if(cond.equals("<")){ AddOperation("GE",CString("T",current_register-1),CString("T",current_register), Integer.toString(current_label)); // System.out.println(";GE "+CString("T",current_register-1)+" "+CString("T",current_register)+" label"+current_label); } AddOperation("JUMP",CString("label",dostack.peek()),"dk","dk"); //System.out.println(";JUMP "+"label"+dostack.peek()); AddOperation("LABEL",CString("label",current_label),"dk","dk"); //System.out.println(";LABEL "+"label"+current_label); current_label++; }
7c566153-a7dc-4e50-8312-1ebf80435eed
1
* * @throws IOException if a communications error occurs * @throws UnknownHostException if the Cyc server cannot be found * @throws CycApiException if the Cyc server returns an error */ public CycList getApplicableBinaryPredicates(CycList kbSubsetCollections) throws UnknownHostException, IOException, CycApiException { CycList result = new CycList(); for (int i = 0; i < kbSubsetCollections.size(); i++) { CycFort kbSubsetCollection = (CycFort) kbSubsetCollections.get( i); String query = "(#$and \n" + " (#$isa ?binary-predicate " + kbSubsetCollection.stringApiValue() + ") \n" + " (#$isa ?binary-predicate #$BinaryPredicate))"; result.addAllNew(queryVariable(CycObjectFactory.makeCycVariable("?binary-predicate"), makeCycSentence(query), inferencePSC, new DefaultInferenceParameters(this))); } return result; }
063beac0-5130-4c19-96d4-b72c705eef31
4
public int comparer(NextTickListEntry var1) { return this.scheduledTime < var1.scheduledTime?-1:(this.scheduledTime > var1.scheduledTime?1:(this.tickEntryID < var1.tickEntryID?-1:(this.tickEntryID > var1.tickEntryID?1:0))); }
1b1baf77-cacb-4183-bd74-df5b60119d61
5
@Override public boolean tableExists(String table) { ResultSet res = null; table = table.replace("#__", prefix); try { DatabaseMetaData data = this.con.getMetaData(); res = data.getTables(null, null, table, null); return res.next(); } catch (SQLException e) { if (this.dbg) { e.printStackTrace(); } return false; } finally { try { if (res != null) { res.close(); } } catch (Exception e) { if (this.dbg) { e.printStackTrace(); } return false; } } }
c0afd7fb-81e6-4b51-919b-af53bfd17f70
6
public void removeTime(Node v, int t) { ArrayList<Edge> toRemove = new ArrayList<Edge>(); for (Edge edge : adj){ Schedule s = edge.getSchedule(); if (edge.getV() == v) s.remove(t, t+1); else s.remove(t-1,t+2); if (s.isEmpty()) toRemove.add(edge); Edge inv = edge.getInv(); if (inv != null){ s = inv.getSchedule(); s.remove(t-1, t+2); if (s.isEmpty()){ inv.getU().getAdj().remove(inv); } } } for (Edge edge : toRemove){ adj.remove(edge); } }
b3029778-6416-4c75-9ec5-82effd761279
2
public static ParticleEffect fromName(String name) { for (Entry<String, ParticleEffect> entry : NAME_MAP.entrySet()) { if (!entry.getKey().equalsIgnoreCase(name)) { continue; } return entry.getValue(); } return null; }
3304460e-8959-4f84-bd92-7551bb797bc8
8
@EventHandler public void handleBlockPlacements(BlockPlaceEvent event) { Player player = event.getPlayer(); User user = EdgeCoreAPI.userAPI().getUser(player.getName()); if (user != null) { Cuboid cuboid = Cuboid.getCuboid(player.getLocation()); if (cuboid == null) { if (!WorldManager.getInstance().isGlobalBlockInteractionAllowed() && !Level.canUse(user, Level.ARCHITECT)) { player.sendMessage(lang.getColoredMessage(user.getLanguage(), "cuboid_nopermission")); event.setCancelled(true); } } else { if (Cuboid.getCuboid(event.getBlock().getLocation()) == null && !WorldManager.getInstance().isGlobalBlockInteractionAllowed() && !Level.canUse(user, Level.ARCHITECT)) { player.sendMessage(lang.getColoredMessage(user.getLanguage(), "cuboid_nopermission")); event.setCancelled(true); } if (!Flag.hasFlag(cuboid, Flag.PlaceBlocks, player.getName())) { player.sendMessage(lang.getColoredMessage(user.getLanguage(), "cuboid_nopermission")); event.setCancelled(true); } } } }
dc8c4e91-62b2-4de8-a065-3c236e325385
2
public void adicionarAula(Aula aula) { if(aula == null){ throw new IllegalStateException("Aula inválida."); } if(grade.contains(aula)){ throw new IllegalStateException("Professor já contem esta aula em sua grade"); } grade.add(aula); }
589835df-16c6-4b82-82fc-24a54fd3ed6c
3
@Override public void fill(Parameter parameter, Type type, Annotation[] annotations) { for (Annotation annotation : annotations) { if (annotation instanceof Default) { Class value = ((Default)annotation).value(); if (value == DefaultValue.class) { value = parameter.getProperty(Properties.TYPE); } parameter.offer(Properties.DEFAULT_PROVIDER, value); return; } } }
de06283b-467e-4015-bc73-6d5146b620db
2
public static String[] removeEmptyStrings(String[] data) { ArrayList<String> result = new ArrayList<String>(); for (int i = 0; i < data.length; i++) { if (!data[i].equals("")) { result.add(data[i]); } } String[] res = new String[result.size()]; result.toArray(res); return res; }
f66eeca0-9062-4af7-bf81-734ac77c2b72
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(Usuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Usuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Usuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Usuario.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 Usuario().setVisible(true); } }); }
16d97615-b545-4791-abe4-661d27f4f855
1
public static boolean isAlNum(int c) { return isAlpha(c) || isDigit(c); }
f00fd9db-d780-43a3-8a3b-54b86a1c3b86
4
public void play() { finishedExecuting = false; Thread t = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub result = engine.setUpGame(); finishedExecuting = true; } }); t.start(); try { t.join(3600000); if(finishedExecuting = false) { t.stop(); timedOut = true; } if(result) while(engine.step()) { } else System.out.println("Result was false!"); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
47003ca3-4232-4143-a988-d3582fb3588f
1
public boolean add(List<String> args) throws InvalidTableRowException { if (args.size() != columnNames.size()) { throw new InvalidTableRowException("args massive size doesn't map table column size"); } String key = args.get(0); Row row = new Row(args); rows.put(key, row); return true; }
7e51d964-1c5d-4e02-86d2-0c239b8525e6
4
@SuppressWarnings("unchecked") private void fridayCheckActionPerformed(java.awt.event.ActionEvent evt) { if(this.dayChecks[5].isSelected()) { this.numSelected++; if(this.firstSelection) { stretch(); } this.models[5] = new DefaultListModel<Object>(); this.fridayJobList.setModel(this.models[5]); this.fridayScrollPane.setViewportView(this.fridayJobList); this.fridayJobName.setColumns(20); this.fridayLabel.setText("Job Name:"); this.fridayAddJob.setText("Add Job"); this.fridayAddJob.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if(!Config.this.fridayJobName.getText().isEmpty()) { Config.this.models[5].addElement(Config.this.fridayJobName.getText()); Config.this.fridayJobList.setModel(Config.this.models[5]); Config.this.fridayJobName.setText(""); } } }); this.fridayDeleteJob.setText("Delete Job"); this.fridayDeleteJob.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { while(!Config.this.fridayJobList.isSelectionEmpty()) { int n = Config.this.fridayJobList.getSelectedIndex(); Config.this.models[5].remove(n); } } }); javax.swing.GroupLayout fridayTabLayout = new javax.swing.GroupLayout(this.fridayTab); this.fridayTab.setLayout(fridayTabLayout); fridayTabLayout.setHorizontalGroup( fridayTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(fridayTabLayout.createSequentialGroup() .addContainerGap() .addComponent(this.fridayScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(fridayTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(fridayTabLayout.createSequentialGroup() .addComponent(this.fridayLabel) .addGroup(fridayTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(fridayTabLayout.createSequentialGroup() .addGap(14, 14, 14) .addComponent(this.fridayAddJob)) .addGroup(fridayTabLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(this.fridayJobName, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addComponent(this.fridayDeleteJob)) .addContainerGap(431, Short.MAX_VALUE)) ); fridayTabLayout.setVerticalGroup( fridayTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(fridayTabLayout.createSequentialGroup() .addContainerGap() .addGroup(fridayTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(fridayTabLayout.createSequentialGroup() .addGroup(fridayTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(this.fridayJobName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(this.fridayLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(this.fridayAddJob) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(this.fridayDeleteJob)) .addComponent(this.fridayScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(25, Short.MAX_VALUE)) ); this.dayTabs.addTab("Friday", this.fridayTab); } else { this.numSelected--; stretch(); this.dayTabs.remove(this.fridayTab); } }
a9199cf9-e245-4815-bfad-245b066564de
5
public String toString() { StringBuilder sb = new StringBuilder(); List<String> ruleStrings = new ArrayList<String>(); for (String parent : binaryRulesByParent.keySet()) { for (BinaryRule binaryRule : getBinaryRulesByParent(parent)) { ruleStrings.add(binaryRule.toString()); } } for (String parent : unaryRulesByParent.keySet()) { for (UnaryRule unaryRule : getUnaryRulesByParent(parent)) { ruleStrings.add(unaryRule.toString()); } } for (String ruleString : CollectionUtils.sort(ruleStrings)) { sb.append(ruleString); sb.append("\n"); } return sb.toString(); }
2eff5639-757f-4063-801e-309822f8cd7e
9
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); if(this.SceneManager.getMapBuffer() != null) { // declare the selected scene Scene SelectedScene = this.SceneManager.getCurrentScene(); // create the game image and get the graphic Graphics2D g2d = (Graphics2D) g; // Beginn Draw this.beginPaint(g2d); // Draw the Background Image if(this.BackgroundImage != null) { g2d.drawImage(this.BackgroundImage, 0, 0, this.getWidth(), this.getHeight(), null); } // draw the mapbuffer g2d.drawImage(this.SceneManager.getMapBuffer(), SelectedScene.getLocation().getX(), SelectedScene.getLocation().getY(), SelectedScene.getSize().getWidth(), SelectedScene.getSize().getHeight(), null); // draw the dynamic elements for(GameElement Element : SelectedScene.getGameElements()) { if(Element.getRenderMode() == RenderModes.OnGameDraw) { if(Element.getLocation().getX() > 0 && Element.getLocation().getY() > 0 && Element.getLocation().getX() < this.getWidth() && Element.getLocation().getY() < this.getHeight()) { Element.renderElement(g2d); } } } // draw the UI if(this.UIManager != null) { this.UIManager.renderContents(g2d); } // End Paint this.endPaint(g2d); } }
6f840aec-8827-41c6-b312-d1d725803f09
0
public FileNameTooLongException(Exception ex, String name) { super(ex, name); }
38101cad-ad7c-4d94-a3d3-136effc14b10
6
public HistoricoResponse validaIngresoParametros(CriterioRequest criterio) { HistoricoResponse historicoResponse = new HistoricoResponse(); if (criterio.getAgencia().equalsIgnoreCase("") && criterio.getCanal().equalsIgnoreCase("") && criterio.getCodigoVendedor() == 0 && criterio.getEstado().equalsIgnoreCase("") && criterio.getFechaDesde() == null && criterio.getFechaHasta() == null) { historicoResponse.setCodigoError(100); historicoResponse.setDescripcionError("No hay criterios de busqueda"); historicoResponse.setMensajeError("Para buscar minimo un criterio"); } return historicoResponse; }
f2283f7f-bc05-4ee5-b017-32198ba7fbac
9
@Override public boolean visitTree(VisitContext context, VisitCallback callback) { // First check to see whether we are visitable. If not // short-circuit out of this subtree, though allow the // visit to proceed through to other subtrees. if (!isVisitable(context)) return false; FacesContext facesContext = context.getFacesContext(); // NOTE: that the visitRows local will be obsolete once the // appropriate visit hints have been added to the API boolean visitRows = requiresRowIteration(context); // Clear out the row index is one is set so that // we start from a clean slate. int oldRowIndex = -1; if (visitRows) { oldRowIndex = getRowIndex(); setRowIndex(-1); } // Push ourselves to EL pushComponentToEL(facesContext, null); try { // Visit ourselves. Note that we delegate to the // VisitContext to actually perform the visit. VisitResult result = context.invokeVisitCallback(this, callback); // If the visit is complete, short-circuit out and end the visit if (result == VisitResult.COMPLETE) return true; // Visit children, short-circuiting as necessary // NOTE: that the visitRows parameter will be obsolete once the // appropriate visit hints have been added to the API if ((result == VisitResult.ACCEPT) && doVisitChildren(context, visitRows)) { // First visit facets // NOTE: that the visitRows parameter will be obsolete once the // appropriate visit hints have been added to the API if (visitFacets(context, callback, visitRows)) return true; // Next column facets // NOTE: that the visitRows parameter will be obsolete once the // appropriate visit hints have been added to the API if (visitColumnsAndColumnFacets(context, callback, visitRows)) return true; // And finally, visit rows // NOTE: that the visitRows parameter will be obsolete once the // appropriate visit hints have been added to the API if (visitRows(context, callback, visitRows)) return true; } } finally { // Clean up - pop EL and restore old row index popComponentFromEL(facesContext); if (visitRows) { setRowIndex(oldRowIndex); } } // Return false to allow the visit to continue return false; }
0bc602fc-3629-4df9-8232-497705290569
1
public void save() { if (isConfirmPassword()) { user.setPassword(DigestUtils.md5Hex(getPassword())); IndexedEntityService.save(getUser()); goToLogin(); } }
dd0d08b0-e3ed-4d3e-9d5c-78091520e473
1
@Override public void mouseExited( MouseEvent e ) { for( MouseListener listener : listeners( MouseListener.class )){ listener.mouseExited( e ); } }
2f570827-f437-44a8-ba79-5d87c5ab32f1
9
private static boolean interpretLine(DatabaseUtil databaseUtil, String line) { boolean result; String command; List<?> objects; int affected; result = false; try { command = StringUtils.substringBefore(line, " "); switch (command) { case "quit": result = true; break; case "begin": databaseUtil.openTransaction(); System.out.println("Transaction started"); break; case "commit": databaseUtil.commitTransaction(); System.out.println("Transaction committed"); break; case "rollback": databaseUtil.rollbackTransaction(); System.out.println("Transaction rollbacked"); break; case "update": case "delete": affected = databaseUtil.executeUpdate(line); System.out.printf("%d objects affected%n", affected); break; case "select": objects = databaseUtil.executeSelect(line); System.out.printf("%d objects found%n", objects.size()); printResultList(objects); break; default: System.err.println("Command not understood"); } } catch (Throwable oops) { System.err.println(oops.getMessage()); // oops.printStackTrace(System.err); } return result; }
6559c740-904b-486d-b32e-54cd478423ca
9
public static boolean isValid(List<TableEntity> tables) { if (tables == null || tables.size() == 0) { logger.error("input table information is empty"); return false; } for (TableEntity table : tables) { if (!(Argument.isDeleteAction() && table.isOfCheckSheet())) { if (table.records.size() == 0) { logger.error("[{}][{}] table's record size is 0", table.sheetName, table.name); return false; } if (table.count == 0) { logger.error("[{}][{}] table's count is 0", table.sheetName, table.name); return false; } if (table.records.size() != table.count) { logger.error("[{}][{}] table's size and count are not matching", table.sheetName, table.name); return false; } } else { if (table.records.size() != table.deleteRowCount) { logger.error("[{}][{}] table's size and deleteRowcount are not matching", table.sheetName, table.name); return false; } } logger.info("[{}][{}] is target table with {} records to work", new Object[] {table.sheetName, table.name, table.count}); } return true; }
13209c6b-93c2-4441-adce-ad6ca3fe9116
5
@Test(expected = DAIllegalArgumentException.class) public void testInfixToPostfix14() throws DAIllegalArgumentException, DAIndexOutOfBoundsException, ShouldNotBeHereException, BadNextValueException, UnmatchingParenthesisException { try { infix.addLast("/"); infix.addLast("0"); QueueInterface<String> postFix = calc.infixToPostfix(infix); } catch (DAIllegalArgumentException e) { throw new DAIllegalArgumentException(); } catch (DAIndexOutOfBoundsException e) { throw new DAIndexOutOfBoundsException(); } catch (ShouldNotBeHereException e) { throw new ShouldNotBeHereException(); } catch (BadNextValueException e) { throw new BadNextValueException(); } catch (UnmatchingParenthesisException e) { throw new UnmatchingParenthesisException(); } }
c04bddf1-537e-4963-a785-7a8aa53ed433
3
@Override public String skip_spaces(String str){ String[] split = str.split(" "); if(split.length > 0){ String output = split[0]; for(int index = 1; index < split.length; index++){ if(split[index].length() > 0) output += " " + split[index]; } return output; } else return ""; }
c457b19e-80f7-492e-9b3f-132231e14c1f
6
@Override public String solve(Cube cube){ String movements = ""; for (int f = 1; f < 6; f = f == 2 ? f + 2 : f + 1) { TileColor c1 = TileColor.get(f); if (c1.getInt() != 0 && c1.getInt() != 3) { TileColor c2 = c1.getInt() == 2 ? TileColor.get(4) : c1.getInt() == 5 ? TileColor.get(1) : TileColor.get(c1.getInt() + 1); String cornerTop = putCornerOnTop(cube, c1, c2); String edgeTop = putEdgeOnTop(cube, c1, c2); String algorithm = findAlgorithm(cube, c1, c2); movements += cornerTop; movements += edgeTop; movements += algorithm; } } return movements; }