method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
321240af-1ba2-400c-8de8-cdde7bf96abe
8
private boolean r_Step_1c() { int v_1; // (, line 51 // [, line 52 ket = cursor; // or, line 52 lab0: do { v_1 = limit - cursor; lab1: do { // literal, line 52 if (!(eq_s_b(1, "y"))) { break lab1; } break lab0; } while (false); cursor = limit - v_1; // literal, line 52 if (!(eq_s_b(1, "Y"))) { return false; } } while (false); // ], line 52 bra = cursor; // gopast, line 53 golab2: while(true) { lab3: do { if (!(in_grouping_b(g_v, 97, 121))) { break lab3; } break golab2; } while (false); if (cursor <= limit_backward) { return false; } cursor--; } // <-, line 54 slice_from("i"); return true; }
54fbb8a4-55eb-4818-8ac2-0caccd4de6ac
0
void pushSearchTask(File f) throws InterruptedException { taskQueue.push(new FileSearchBean(f)); }
a373ba62-780c-4561-ab24-3f16678c10e0
7
public void reproduceAvg(int cutoff){ Random rand = new Random(); int numOffsprings = C(cutoff,2); if(numOffsprings + cutoff > population.length){ System.out.println("Invalid cutoff!"); return; } Stack<Cell> temp = new Stack<Cell>(); for(Cell c : population){ temp.add(c); } Collections.sort(temp); ArrayList<Cell> survivors = new ArrayList<Cell>(); ArrayList<Cell> newGen = new ArrayList<Cell>(); for(int i=0; i<cutoff; i++){ Cell t = temp.pop(); survivors.add(t); newGen.add(t); } temp = null; for(int i=0; i<survivors.size()-1; i++){ for(int j=i+1; j<survivors.size(); j++){ float multiplier = rand.nextFloat(); float p1[] = survivors.get(i).behavior.dna; float p2[] = survivors.get(j).behavior.dna; float child[] = new float[p1.length]; for(int k=0; k<child.length; k++){ child[k] = (multiplier * p1[k]) + ((1-multiplier) * p2[k]); } newGen.add(new Cell(new Behavior(child),newGen.size())); } } for(int i=newGen.size(); i<population.length; i++){ newGen.add(new Cell(new Behavior())); } newGen.toArray(population); generation++; }
5617e5e5-fea4-48a6-85c8-c7978072d12e
0
@Override public AbstractPlay mkRandom() { return everyPlay.get(rnd.nextInt(everyPlay.size())); }
5275af35-bcf3-4b26-8002-4b14e15697d9
4
public final T getNode(int x, int y) { if(x < 0 || x > width || y < 0 || y > height){ throw new IllegalArgumentException("X & Y must be more than 0, but less than w/h"); } return nodes[x][y]; }
02a4442b-16bd-4492-bb59-f36fcd3fb938
7
public Symbol debug_parse() throws java.lang.Exception { /* the current action code */ int act; /* the Symbol/stack element returned by a reduce */ Symbol lhs_sym = null; /* information about production being reduced with */ short handle_size, lhs_sym_num; /* set up direct reference to tables to drive the parser */ production_tab = production_table(); action_tab = action_table(); reduce_tab = reduce_table(); debug_message("# Initializing parser"); /* initialize the action encapsulation object */ init_actions(); /* do user initialization */ user_init(); /* the current Symbol */ cur_token = scan(); debug_message("# Current Symbol is #" + cur_token.sym); /* push dummy Symbol with start state to get us underway */ stack.removeAllElements(); stack.push(getSymbolFactory().startSymbol("START",0, start_state())); tos = 0; /* continue until we are told to stop */ for (_done_parsing = false; !_done_parsing; ) { /* Check current token for freshness. */ if (cur_token.used_by_parser) throw new Error("Symbol recycling detected (fix your scanner)."); /* current state is always on the top of the stack */ //debug_stack(); /* look up action out of the current state with the current input */ act = get_action(((Symbol)stack.peek()).parse_state, cur_token.sym); /* decode the action -- > 0 encodes shift */ if (act > 0) { /* shift to the encoded state by pushing it on the stack */ cur_token.parse_state = act-1; cur_token.used_by_parser = true; debug_shift(cur_token); stack.push(cur_token); tos++; /* advance to the next Symbol */ cur_token = scan(); debug_message("# Current token is " + cur_token); } /* if its less than zero, then it encodes a reduce action */ else if (act < 0) { /* perform the action for the reduce */ lhs_sym = do_action((-act)-1, this, stack, tos); /* look up information about the production */ lhs_sym_num = production_tab[(-act)-1][0]; handle_size = production_tab[(-act)-1][1]; debug_reduce((-act)-1, lhs_sym_num, handle_size); /* pop the handle off the stack */ for (int i = 0; i < handle_size; i++) { stack.pop(); tos--; } /* look up the state to go to from the one popped back to */ act = get_reduce(((Symbol)stack.peek()).parse_state, lhs_sym_num); debug_message("# Reduce rule: top state " + ((Symbol)stack.peek()).parse_state + ", lhs sym " + lhs_sym_num + " -> state " + act); /* shift to that state */ lhs_sym.parse_state = act; lhs_sym.used_by_parser = true; stack.push(lhs_sym); tos++; debug_message("# Goto state #" + act); } /* finally if the entry is zero, we have an error */ else if (act == 0) { /* call user syntax error reporting routine */ syntax_error(cur_token); /* try to error recover */ if (!error_recovery(true)) { /* if that fails give up with a fatal syntax error */ unrecovered_syntax_error(cur_token); /* just in case that wasn't fatal enough, end parse */ done_parsing(); } else { lhs_sym = (Symbol)stack.peek(); } } } return lhs_sym; }
f960a7ac-c129-46ca-9d5d-a861523dcfd3
0
public TPLogger(Logger logger) { this.logger = logger; this.logger.setLevel(Level.ALL); }
adc4732e-8147-4d71-bbe4-0b1342f5100a
4
private void analysisInteraction() { Enumeration<PhysObject3D> e = world.getObjects(); int i = 0; PhysObject3D temp; while(e.hasMoreElements()) { temp = e.nextElement(); if(temp instanceof HasMassInterface) { gravityInteraction[gravityInteraction[numObjs]] = i; gravityInteraction[numObjs]++; if(temp instanceof CanAttractInterface) { sourceGravity[sourceGravity[numObjs]] = i; sourceGravity[numObjs]++; } } else if(temp instanceof HasChargeInterface){ electromagneticInteraction[electromagneticInteraction[numObjs]] = i; electromagneticInteraction[numObjs]++; } i++; objects.add(temp); } }
bfaf91cd-b249-4be1-a859-b00d8e712ab1
3
public static ArrayList<String> getInput(String filename) { ArrayList<String> entry = new ArrayList<String>(); try { BufferedReader reader = new BufferedReader(new FileReader(filename)); String line = reader.readLine(); while(line != null) { entry.add(line); line = reader.readLine(); } reader. close(); } catch(FileNotFoundException e) { System.out.println("This is not a valid directory for the file path specified."); } catch(IOException e) { } return entry; }
8def89ba-13f8-465c-9980-9a0c88ed6af0
9
public void controlarComandoRecebido(Jogada jogada) throws PecaAlheiaException, MovimentoInvalidoException, CaminhoBloqueadoException, CasaVaziaException, CapturaInvalidaPecaInexistenteException, CapturaInvalidaPecaPropriaException { switch (jogada.getTipoJogada()) { case MOVIMENTO: controlarMovimentoPeca(jogada); controlarPromocaoPeca(); controlarXeque(); break; case CAPTURA: controlarCapturaPeca(jogada); controlarPromocaoPeca(); controlarXeque(); break; case DESISTENCIA: desistirPartida(); break; case PONTUACAO: exibirPontuacaoJogador(); break; case ROQUE_MAIOR: break; case ROQUE_MENOR: break; case SALVAR: controlarSalvarPartida(); break; case SAIR: controlarSairPartida(); controlarMenuInicial(); break; case INEXISTENTE: controladorTela.exibirMensagem("Que porra eh essa?!"); } }
9e6f1ad1-40fd-45a6-a7ef-780ee6fa12eb
1
public static GameQueues getInstance(){ if(instance == null){ instance = new GameQueues(); } return instance; }
5f254e6f-4308-4203-993c-e211095f9eac
8
public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Triplet)) return false; @SuppressWarnings("unchecked") final Triplet triplet = (Triplet) o; if (first != null ? !first.equals(triplet.first) : triplet.first != null) return false; if (second != null ? !second.equals(triplet.second) : triplet.second != null) return false; if (third != null ? !third.equals(triplet.third) : triplet.third != null) return false; return true; }
4fb0d3fe-ce9f-4309-a79b-c921ae3c1fde
1
public List<Product> getProductsFromBasket(int basketId) { List<Product> list = null; Basket basket = null; try { beginTransaction(); basket = (Basket) session.get(Basket.class, basketId); list = basket.getProducts(); } catch (Exception e) { e.printStackTrace(); } finally { closeSession(); } return list; }
74b87e5b-7092-4123-97b1-f29d5028143d
1
public void setBody(Body body) { if(this.body != null){ this.body.setUsed(false); } this.body = body; this.body.setUsed(true); }
65707862-b2c4-4a79-b5db-80169f6aa62c
6
protected static Set<Point> getSortedPointSet(Point[] points) { final Point lowest = getLowestPoint(points); if (lowest == null) { return null; } TreeSet<Point> set = new TreeSet<Point>(new Comparator<Point>() { @Override public int compare(Point a, Point b) { if(a == b || a.equals(b)) { return 0; } // use longs to guard against int-underflow double thetaA = Math.atan2((long)a.y - lowest.y, (long)a.x - lowest.x); double thetaB = Math.atan2((long)b.y - lowest.y, (long)b.x - lowest.x); if(thetaA < thetaB) { return -1; } else if(thetaA > thetaB) { return 1; } else { // collinear with the 'lowest' point, let the point closest to it come first // use longs to guard against int-over/underflow double distanceA = Math.sqrt((((long)lowest.x - a.x) * ((long)lowest.x - a.x)) + (((long)lowest.y - a.y) * ((long)lowest.y - a.y))); double distanceB = Math.sqrt((((long)lowest.x - b.x) * ((long)lowest.x - b.x)) + (((long)lowest.y - b.y) * ((long)lowest.y - b.y))); if(distanceA < distanceB) { return -1; } else { return 1; } } } }); Collections.addAll(set, points); return set; }
2a47d718-b933-4660-9e81-08c943c4b0b6
9
private static double toDouble(Object value) { if (value instanceof Number) { return ((Number)value).doubleValue(); } else if (value instanceof String) { return ScriptRuntime.toNumber((String)value); } else if (value instanceof Scriptable) { if (value instanceof Wrapper) { // XXX: optimize tail-recursion? return toDouble(((Wrapper)value).unwrap()); } else { return ScriptRuntime.toNumber(value); } } else { Method meth; try { meth = value.getClass().getMethod("doubleValue", (Class [])null); } catch (NoSuchMethodException e) { meth = null; } catch (SecurityException e) { meth = null; } if (meth != null) { try { return ((Number)meth.invoke(value, (Object [])null)).doubleValue(); } catch (IllegalAccessException e) { // XXX: ignore, or error message? reportConversionError(value, Double.TYPE); } catch (InvocationTargetException e) { // XXX: ignore, or error message? reportConversionError(value, Double.TYPE); } } return ScriptRuntime.toNumber(value.toString()); } }
29567568-fc3d-402f-ac09-4769cd366885
5
public void mousePressed(int mx, int my, GUIComponent component) { if (component instanceof CardComponent && component.belongsTo(playersComponent) && ((CardComponent) component).getAssociatedPlayer() instanceof HumanPlayer) { if (selectedCardComponent != component && selectedCardComponent != null) { ((CardComponent) component).getAssociatedPlayer().swapCards(((CardComponent) component).getCard(), selectedCardComponent.getCard()); setSelectedCardComponent(null); } else { setSelectedCardComponent((CardComponent)component); } } else { setSelectedCardComponent(null); } }
b8521f28-a96c-4cf3-ac60-2002088e4dba
3
public String makeString(Double make){ if(make>=1000000000) { return df.format(make/1000000000)+"b"; } else if(make>=1000000) { return df.format(make/1000000)+"m"; } else if(make>=1000) { return df.format(make/1000)+"k"; } return df.format(make); }
0854c131-dce3-4455-80b8-933f400aceaa
7
public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MatrixSeries)) { return false; } MatrixSeries that = (MatrixSeries) obj; if (!(getRowCount() == that.getRowCount())) { return false; } if (!(getColumnsCount() == that.getColumnsCount())) { return false; } for (int r = 0; r < getRowCount(); r++) { for (int c = 0; c < getColumnsCount(); c++) { if (get(r, c) != that.get(r, c)) { return false; } } } return super.equals(obj); }
acd7c51f-7f0b-4f7a-a163-424a2b6a51f5
3
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final WordCount other = (WordCount) obj; return Objects.equal(this.word, other.word); }
5acfe8b1-1805-438a-a12f-6634864db836
7
@Override public void sessionOpened(IoSession session) throws Exception { final String address = session.getRemoteAddress().toString().split(":")[0]; if (BlockedIP.contains(address)) { session.close(); return; } final Pair<Long, Byte> track = tracker.get(address); byte count; if (track == null) { count = 1; } else { count = track.right; final long difference = System.currentTimeMillis() - track.left; if (difference < 2000) { // Less than 2 sec count++; } else if (difference > 20000) { // Over 20 sec count = 1; } if (count >= 10) { BlockedIP.add(address); tracker.remove(address); // Cleanup session.close(); return; } } tracker.put(address, new Pair(System.currentTimeMillis(), count)); // End of IP checking. // log.info("IoSession with {} opened", session.getRemoteAddress()); if (channel > -1) { if (ChannelServer.getInstance(channel).isShutdown()) { session.close(); return; } } byte key[] = {0x13, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, (byte) 0xB4, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00}; byte ivRecv[] = {70, 114, 122, 82}; byte ivSend[] = {82, 48, 120, 115}; ivRecv[3] = (byte) (Math.random() * 255); ivSend[3] = (byte) (Math.random() * 255); MapleAESOFB sendCypher = new MapleAESOFB(key, ivSend, (short) (0xFFFF - MAPLE_VERSION)); MapleAESOFB recvCypher = new MapleAESOFB(key, ivRecv, MAPLE_VERSION); MapleClient client = new MapleClient(sendCypher, recvCypher, session); client.setChannel(channel); session.write(LoginPacket.getHello(MAPLE_VERSION, ivSend, ivRecv)); session.setAttribute(MapleClient.CLIENT_KEY, client); session.setIdleTime(IdleStatus.READER_IDLE, 30); session.setIdleTime(IdleStatus.WRITER_IDLE, 30); }
5f239440-e4be-47b3-a79e-0819906814b9
6
static private void validate(Team team) { if (team == null) { throw new IllegalArgumentException("team is null"); } if (team.getName() == null || team.getName().isEmpty()) { throw new ValidationException("no name"); } if (team.getCoach() == null || team.getCoach().isEmpty()) { throw new ValidationException("no coach"); } if (team.getStatus() == null) { throw new ValidationException("no status"); } }
ba938df6-9bca-4e06-a381-46cd657c41b1
6
public static BigInteger nCrBigInt(int n, int r) { if (r > n || r < 0) { return BigInteger.ZERO; } if (r == 0 || r == n) { return BigInteger.ONE; } if (r > n / 2) { // As Pascal's triangle is horizontally symmetric, use that property to reduce the for-loop below r = n - r; } BigInteger value = BigInteger.ONE; for (int i = 0; i < r; i++) { value = value.multiply(BigInteger.valueOf(n - i)).divide(BigInteger.valueOf(i + 1)); } return value; }
baae3303-9883-4511-b051-e706d045120c
8
public static char rightOf(char direction){ //determine the direction to the right of this one switch(direction){ case '1': return '4'; case '2': return'1'; case '3': return '2'; case '4': return '7'; case '6': return '3'; case '7': return '8'; case '8': return '9'; case '9': return '6'; default: return '0'; } }
5986a170-b8df-4c31-8e67-2c3ae4fd297d
5
public void assign(Rectangle rect, V value) { if (!split) { values.put(rect, value); color = true; return; } if (tl.intersects(rect)) { tl.assign(rect, value); } if (tr.intersects(rect)) { tr.assign(rect, value); } if (bl.intersects(rect)) { bl.assign(rect, value); } if (br.intersects(rect)) { br.assign(rect, value); } }
8e30d61c-ced4-4920-9a10-54628f18d77a
3
private void func_28214_a(File var1, String var2, File var3) { File var4 = new File(var1, var2); if(var4.exists() && !var4.isDirectory() && !var3.exists()) { var4.renameTo(var3); } }
91eee54b-ce00-42c8-b52c-870df195f0d7
6
private void inputHandling() { if(Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !spaceWasPressed){ Mouse.setCursorPosition(Display.getWidth()/2, Display.getHeight()/2); Mouse.setGrabbed(!Mouse.isGrabbed()); spaceWasPressed = true; } else if(!Keyboard.isKeyDown(Keyboard.KEY_SPACE)){ spaceWasPressed = false; } if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)){ running = false; } if(Keyboard.isKeyDown(Keyboard.KEY_F1)){ GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } else if(!Keyboard.isKeyDown(Keyboard.KEY_F1)){ GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); } }
4ee2fb6c-670a-4e92-b69b-f2484bd75733
0
public static <E> Iterator<E> toIterator(Enumeration<E> enumeration) { return new EnumerationIterator<E>(enumeration); }
cc986cd6-76fc-4682-8849-1f0345dcdd9a
1
public static void main(String[] argsv) { // Setting op a bank. Bank christmasBank = new Bank(); christmasBank.addAccount(new BankAccount(BigInteger.valueOf(100))); christmasBank.addAccount(new BankAccount(BigInteger.valueOf(50), BigInteger.valueOf(-1000))); // Print the balance of all accounts with a balance not below some threshold. // System.out.print("Enter the threshold for the balance: "); // Scanner inputStreamScanner = new Scanner(System.in); // BigInteger threshold = BigInteger.valueOf(inputStreamScanner.nextLong()); Set<BankAccount> accountsBalanceNotBelowThreshold = christmasBank.getAccountsSatisfying( new Checker<BankAccount>() { public boolean check(BankAccount account) { return (account.getBalance().compareTo(BigInteger.valueOf(70)) >= 0); } }); for (BankAccount account: accountsBalanceNotBelowThreshold) System.out.println(account.getBalance()); }
474c540a-01f5-4441-bb1a-95d046b4c499
9
private String readByteArray() { StringBuffer buf = new StringBuffer(); int count = 0; char w = (char) 0; // read individual bytes and format into a character array while ((this.loc < this.stream.length) && (this.stream[this.loc] != '>')) { char c = (char) this.stream[this.loc]; byte b = (byte) 0; if (c >= '0' && c <= '9') { b = (byte) (c - '0'); } else if (c >= 'a' && c <= 'f') { b = (byte) (10 + (c - 'a')); } else if (c >= 'A' && c <= 'F') { b = (byte) (10 + (c - 'A')); } else { this.loc++; continue; } // calculate where in the current byte this character goes int offset = 1 - (count % 2); w |= (0xf & b) << (offset * 4); // increment to the next char if we've written four bytes if (offset == 0) { buf.append(w); w = (char) 0; } count++; this.loc++; } // ignore trailing '>' this.loc++; return buf.toString(); }
0b23649a-70f1-41be-9184-e0cbec204546
2
public Map load(String name) throws MapNotFoundException { Map m = null; if(!mapMap.containsKey(name)){ throw new MapNotFoundException(); } else{ File f = new File(mapMap.get(name)); try { m = (Map) biIn.load(f); } catch (IOException ex) { Logger.getLogger(MapLoader.class.getName()).log(Level.SEVERE, null, ex); } } return m; }
c125aa20-728c-4ec9-abab-93b8ac555e74
6
public static void manageStudents() { System.out.print("Do you want to add (0) or delete (1) a student ? "); int res = -1; while (res < 0 || res > 1) { Scanner sc = new Scanner(System.in); res = sc.nextInt(); } switch (res) { case 0: createStudent(); break; case 1: if (FileReadService.sList.isEmpty()) { System.out.println("There is no Student !"); } else { System.out.println("Which student do you want delete ?"); displayStudentList(); Scanner scIndexS = new Scanner(System.in); Student s = null; while (s == null) { int iS = scIndexS.nextInt(); s = chooseStudentList(iS); FileReadService.pList.get(iS).remove(s); } FileReadService.sList.remove(s); System.out.println("The student " + s.displayNames() + " has been deleted."); } break; default: createStudent(); break; } }
7c449cd5-1fb1-4d41-8565-38ec2541bfca
1
public void dumpExpression(TabbedPrintWriter writer) throws java.io.IOException { subExpressions[0].dumpExpression(writer, getPriority() + 1); writer.breakOp(); writer.print(getOperatorString()); writer.print(objectType ? "null" : "0"); }
3a192119-91ce-479b-bc66-d729233d91a2
3
public List listUsers() { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); List result = session.createQuery("from User u where u.username = :username and u.id = :id").setParameter("username","lisi").setParameter("id",2L).list(); session.getTransaction().commit(); if (null != result && result.size() > 0) { for (Object obj : result) { User u = (User) obj; System.out.println(u.getUsername() + "-------&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&----"+u.getId()); } } return result; }
0ddb0aea-b83f-4d38-bbda-2fe2edadc6d7
3
public static String[] getList(int pageNumber) { String[] line = new String[PAGE_LINES]; int temp = 0; if(pageNumber > 1) {temp = PAGE_LINES * (pageNumber - 1);} for(int i = 0; (i < PAGE_LINES); i++) { if(temp >= list.size()) break; line[i] = list.get(temp); temp++; } return line; }
a752417b-de2e-4913-830c-ccc973d10bcc
4
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPainelMenu = new javax.swing.JPanel(); jInserir = new javax.swing.JButton(); jEditar = new javax.swing.JButton(); jExcluir = new javax.swing.JButton(); jCancelar = new javax.swing.JButton(); jPDadosPessoais = new javax.swing.JPanel(); jLNome = new javax.swing.JLabel(); jLEndereco = new javax.swing.JLabel(); jLBairro = new javax.swing.JLabel(); jLCidade = new javax.swing.JLabel(); jLCep = new javax.swing.JLabel(); jLEstado = new javax.swing.JLabel(); jLTelefone = new javax.swing.JLabel(); jLCelular = new javax.swing.JLabel(); jLCPF = new javax.swing.JLabel(); jLEmail = new javax.swing.JLabel(); jLData = new javax.swing.JLabel(); jNome = new javax.swing.JTextField(); jEndereco = new javax.swing.JTextField(); jBairro = new javax.swing.JTextField(); jCidade = new javax.swing.JTextField(); jCelular = new javax.swing.JTextField(); try { javax.swing.text.MaskFormatter celular = new javax.swing.text.MaskFormatter("(##)####-####"); jCelular = new javax.swing.JFormattedTextField(celular); } catch (Exception e) { } jTelefone = new javax.swing.JTextField(); try { javax.swing.text.MaskFormatter telefone = new javax.swing.text.MaskFormatter("(##)####-####"); jTelefone = new javax.swing.JFormattedTextField(telefone); } catch (Exception e) { } jCPF = new javax.swing.JTextField(); jData = new javax.swing.JTextField(); try { javax.swing.text.MaskFormatter data = new javax.swing.text.MaskFormatter("##/##/####"); jData = new javax.swing.JFormattedTextField(data); } catch (Exception e) { } jCep = new javax.swing.JTextField(); jEmail = new javax.swing.JTextField(); jCEstado = new javax.swing.JComboBox(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); tabela = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setResizable(false); jPainelMenu.setBorder(javax.swing.BorderFactory.createTitledBorder("")); jInserir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/bicicletaria/imagens/Ok.png"))); // NOI18N jInserir.setText("Inserir"); jInserir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jInserirActionPerformed(evt); } }); jEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/bicicletaria/imagens/edit.png"))); // NOI18N jEditar.setText("Editar"); jEditar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jEditarActionPerformed(evt); } }); jExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/bicicletaria/imagens/del.png"))); // NOI18N jExcluir.setText("Excluir"); jExcluir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jExcluirActionPerformed(evt); } }); jCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/bicicletaria/imagens/canc.png"))); // NOI18N jCancelar.setText("Cancelar"); jCancelar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCancelarActionPerformed(evt); } }); javax.swing.GroupLayout jPainelMenuLayout = new javax.swing.GroupLayout(jPainelMenu); jPainelMenu.setLayout(jPainelMenuLayout); jPainelMenuLayout.setHorizontalGroup( jPainelMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPainelMenuLayout.createSequentialGroup() .addContainerGap() .addComponent(jInserir, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(38, 38, 38) .addComponent(jEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addComponent(jExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE) .addComponent(jCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPainelMenuLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jCancelar, jEditar, jExcluir, jInserir}); jPainelMenuLayout.setVerticalGroup( jPainelMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPainelMenuLayout.createSequentialGroup() .addContainerGap() .addGroup(jPainelMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jInserir, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(17, Short.MAX_VALUE)) ); jPainelMenuLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jCancelar, jEditar, jExcluir, jInserir}); jPDadosPessoais.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados Pessoais")); jLNome.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLNome.setText("Nome *"); jLEndereco.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLEndereco.setText("Endereço"); jLBairro.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLBairro.setText("Bairro"); jLCidade.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLCidade.setText("Cidade"); jLCep.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLCep.setText("CEP"); jLEstado.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLEstado.setText("Estado"); jLTelefone.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLTelefone.setText("Telefone *"); jLCelular.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLCelular.setText("Celular"); jLCPF.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLCPF.setText("CPF *"); jLEmail.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLEmail.setText("E-mail"); jLData.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLData.setText("Data de Nascimento"); jNome.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jNomeActionPerformed(evt); } }); try { javax.swing.text.MaskFormatter cpf_mask = new javax.swing.text.MaskFormatter("###.###.###-##"); jCPF = new javax.swing.JFormattedTextField(cpf_mask); } catch (Exception e) { } jCPF.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jCPFKeyTyped(evt); } }); jCEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Acre", "Alagoas", "Amapá", "Amazonas", "Bahia", "Ceara", "Distrito Federal", "Espirito Santo", "Goiás", "Maranhão", "Mato Grosso", "Mato Grosso do Sul", "Minas Gerais", "Para", "Paraiba", "Parana", "Pernambuco", "Piaui", "Rio de Janeiro", "Rio Grande do Norte", "Rio Grande do Sul", "Rondônia", "Roraima", "Santa Catarina", "São Paulo", "Sergipe", "Tocantins" })); javax.swing.GroupLayout jPDadosPessoaisLayout = new javax.swing.GroupLayout(jPDadosPessoais); jPDadosPessoais.setLayout(jPDadosPessoaisLayout); jPDadosPessoaisLayout.setHorizontalGroup( jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addContainerGap() .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jNome, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE) .addGap(222, 222, 222)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLTelefone, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(89, 89, 89) .addComponent(jLCelular, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(87, 87, 87))) .addGap(4, 4, 4)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jCPF) .addGap(141, 141, 141)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jEndereco, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jCidade, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLCidade, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(223, 223, 223))) .addGap(17, 17, 17)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jTelefone) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCelular) .addGap(16, 16, 16)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(243, 243, 243)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLNome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(236, 236, 236)) .addComponent(jEmail) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLCPF, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(248, 248, 248))) .addGap(6, 6, 6) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jCEstado, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jCep) .addComponent(jBairro) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLData, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE) .addGap(3, 3, 3)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLBairro, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(82, 82, 82)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLCep, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(96, 96, 96)) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addComponent(jLEstado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(78, 78, 78)) .addComponent(jData)) .addGap(50, 50, 50))))) .addContainerGap()) ); jPDadosPessoaisLayout.setVerticalGroup( jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPDadosPessoaisLayout.createSequentialGroup() .addContainerGap() .addComponent(jLNome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jNome) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLBairro, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jEndereco) .addComponent(jBairro)) .addGap(18, 18, 18) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLCidade, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLCep)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jCep) .addComponent(jCidade)) .addGap(8, 8, 8) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLEstado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLCelular, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLTelefone, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(16, 16, 16) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTelefone) .addComponent(jCelular) .addComponent(jCEstado)) .addGap(18, 18, 18) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLCPF, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(4, 4, 4) .addGroup(jPDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jData) .addComponent(jCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jEmail) .addContainerGap()) ); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 20, Short.MAX_VALUE) ); tabela.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null, null, null, null}, {null, null, null, null, null, null, null, null, null, null, null} }, new String [] { "Nome", "Endereço", "Bairro", "Cidade", "CEP", "Telefone", "Celular", "Estado", "CPF", "Data Nascimento", "Email" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class }; boolean[] canEdit = new boolean [] { false, false, false, false, false, false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); tabela.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN); tabela.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tabelaMouseClicked(evt); } }); jScrollPane1.setViewportView(tabela); tabela.getColumnModel().getColumn(2).setResizable(false); tabela.getColumnModel().getColumn(3).setResizable(false); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 574, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(582, 582, 582) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPainelMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPDadosPessoais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPDadosPessoais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPainelMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); java.awt.Dimension dialogSize = getSize(); setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2); }// </editor-fold>//GEN-END:initComponents
653fe048-ea94-4aa5-a8eb-853211cbcff8
5
public void acceptValuationVisitor(ValuationVisitor visitor) { PortfolioIterator iterator = new PortfolioIterator(); Investment i; while (iterator.hasNext()) { i = iterator.next(); if (i instanceof Bond) { visitor.visitBond((Bond) i); } else if (i instanceof Stock) { visitor.visitStock((Stock) i); } else if (i instanceof MoneyMarket) { visitor.visitMoneyMarket((MoneyMarket) i); } else if (i instanceof Portfolio) { i.acceptValuationVisitor(visitor); } else { throw new NoSuchElementException("Object of class " + i.getClass() + " is unknown"); } } }
94b5de7d-84d5-457e-807a-000e89175822
2
public static String getErrorMessage(String response) throws Exception { if (response == null || response.trim().length() == 0) { return "Null response from server"; } Document doc = stringToXmlDocument(response); return doc.getElementsByTagName("errortext").item(0).getTextContent().trim(); }
b38a59fa-1cac-4328-829e-941bae2848f0
7
private void changeRoomIFN() { int doorId = room.getSquareValue(coord); if (room.isDoorLocked(doorId)) { return; } else if(doorId == -1) { System.out.println("Door id not found at coord " + coord); return; } Room nextRoom = room.getNeighbor(doorId); if(nextRoom == null) { System.out.println("No neighbor room found from door " + doorId); return; } Coord newCoord = room.getStartingCoordFromDoor(doorId); if(newCoord == null) { System.out.println("The starting coords were not found from door " + doorId); return; } if (nextRoom.canWalkOnSquare(id, newCoord)) { room.freeSquare(coord); if (id == controllablePlayerId) room.unloadImg(); room = nextRoom; if (id == controllablePlayerId) room.loadImg(); setCoord(newCoord); setChangedRoom(); notifyObservers(); } }
b3843618-a0fd-4adf-8d3a-5d4bac2fdf1f
0
public int getVal() { return mySlider.getValue(); }
85dd6fe7-2ecc-49a5-a61d-a56332bb7861
0
public Points getPoints() { return points; }
cef90d41-4836-4866-accf-934ab75ac8fc
7
@Override public void run ( ) { final Vector<Character> chars = new Vector<Character> ( ) ; for ( int i = 1 ; i < this.inp.length ; i++ ) { for ( final char c : this.inp[ i ].toLowerCase ( ).toCharArray ( ) ) { chars.add ( c ) ; } } for ( final char c : chars ) { if ( c >= 'a' && c <= 'z' || c == '*' ) { try { this.main.hand.add ( this.bag.draw ( c ) ) ; } catch ( BagEmptyException e ) { GUI.write ( "The bag does not contain the character " + c + "." ) ; } } } }
f595647e-c593-4bee-968f-7e3ca3981022
9
public static PreciseDecimal parse(final String s) { int factor = 0; long base = 0; int i = 0; boolean fractional = false; final boolean neg; if (s.charAt(i) == '-') { neg = true; i++; } else { neg = false; } while (i < s.length()) { final char c = s.charAt(i++); if (c == '.') { fractional = true; } else { if (c < '0' || c > '9') { throw new IllegalArgumentException("Not a decimal number " + s); } if (fractional) { factor++; } if (base == 0) { base = (c - '0'); } else { base = base * 10 + (c - '0'); } if (DPU.isTooBigBase(base)) { throw new NumberFormatException("Too long number " + s); } } } return getInstance(neg ? -base : base, factor); }
a5baf41c-46e0-4430-93d5-4dbcab2c0053
4
protected static boolean checkResource(Resource resource) { boolean isValid; if (isValid = resource != null) { isValid = TYPES.contains(resource.getType()); isValid = isValid && resource.getProperty(NODES_PROPERTY) != null; isValid = isValid && resource.getProperty(USERNAME_PROPERTY) != null; isValid = isValid && resource.getProperty(PASSWORD_PROPERTY) != null; } return isValid; }
a0afed0c-378e-4a7d-92f6-05dca9908bf3
4
private void update() { checkXp(); for(int i = 0; i < bullets.size(); i++) { if(bullets.get(i).isDead()) { bullets.remove(i); } if(bullets.get(i) != null) { bullets.get(i).render(); } } if(isDead()) { killEntity(); } checkForKeyPress(); box.update(x,y,width,height); GameCore.collisionEngine.isCollisionBoxColliding(box); }
5f8d9372-a594-4aad-92cb-9b7036da7f05
1
private void displayCommand(String command) { String data = textArea.getText(); while (data.endsWith("\n")) data = data.substring(0, data.length()-1); int lastIndex = lastCommandOffset = data.lastIndexOf("\n"); lastCommandOffset++; data = data.substring(0,lastIndex+1) + command; textArea.setText(data); textArea.append("\n"); textArea.setCaretPosition(textArea.getDocument().getLength()); }
c63536d8-a278-4501-a1a9-92b7d57ccd45
3
public String compress(String html) { if(!enabled || html == null || html.length() == 0) { return html; } //calculate uncompressed statistics initStatistics(html); //preserved block containers List<String> condCommentBlocks = new ArrayList<String>(); List<String> preBlocks = new ArrayList<String>(); List<String> taBlocks = new ArrayList<String>(); List<String> scriptBlocks = new ArrayList<String>(); List<String> styleBlocks = new ArrayList<String>(); List<String> eventBlocks = new ArrayList<String>(); List<String> skipBlocks = new ArrayList<String>(); List<String> lineBreakBlocks = new ArrayList<String>(); List<List<String>> userBlocks = new ArrayList<List<String>>(); //preserve blocks html = preserveBlocks(html, preBlocks, taBlocks, scriptBlocks, styleBlocks, eventBlocks, condCommentBlocks, skipBlocks, lineBreakBlocks, userBlocks); //process pure html html = processHtml(html); //process preserved blocks processPreservedBlocks(preBlocks, taBlocks, scriptBlocks, styleBlocks, eventBlocks, condCommentBlocks, skipBlocks, lineBreakBlocks, userBlocks); //put preserved blocks back html = returnBlocks(html, preBlocks, taBlocks, scriptBlocks, styleBlocks, eventBlocks, condCommentBlocks, skipBlocks, lineBreakBlocks, userBlocks); //calculate compressed statistics endStatistics(html); return html; }
7a6483f9-5612-43ae-a35e-d761dbac01f7
1
public final void addObservable(PositionChangedObservable o) { if(o != null) observables.add(o); }
c85e1cb0-ad2a-4b72-8755-ffccd7d961ee
2
public void checkW(double[][] coord) { if (coord[0][3] == 0) { coord[0][3] = 1; } else if (coord[0][3] != 1) { coord[0][0] /= coord[0][3]; coord[0][1] /= coord[0][3]; coord[0][2] /= coord[0][3]; coord[0][3] /= coord[0][3]; } }
98f2e4b8-88a1-4dc4-b6f8-cd83702ccbfe
8
final private short determineElementCount() throws Exception { switch (type) { case BOOL: case SINT: case INT: case DINT: case BITS: case REAL: return (short) (data.capacity() / type.element_size); case STRUCT: { final Type el_type = Type.forCode(data.getShort(0)); if (el_type == Type.STRUCT_STRING) return 1; else throw new Exception("Structure elements of type " + type + " not handled"); } default: throw new Exception("Type " + type + " not handled"); } }
a4f9a508-920f-4d34-9c95-984fd70fb42e
7
public static String secondsToDHMSString(double seconds) { if (seconds < 60) { return doubleToString(seconds, 2, 2) + 's'; } long secs = (int) (seconds); long mins = secs / 60; long hours = mins / 60; long days = hours / 24; secs %= 60; mins %= 60; hours %= 24; StringBuilder result = new StringBuilder(); if (days > 0) { result.append(days); result.append('d'); } if ((hours > 0) || (days > 0)) { result.append(hours); result.append('h'); } if ((hours > 0) || (days > 0) || (mins > 0)) { result.append(mins); result.append('m'); } result.append(secs); result.append('s'); return result.toString(); }
f5b51297-88df-4b57-807e-9b1b904f0bf0
9
public static double evaluateRecall(int k, HashMap<String, HashMap<Integer,Double>> relevance_judgments, String path){ double value = 0.0; int countRelevance = 0; try { BufferedReader reader = new BufferedReader(new FileReader(path)); int RR = 0; String readLineString = null; for(int i=0; i<k; i++){ readLineString = reader.readLine(); Scanner s = new Scanner(readLineString).useDelimiter("\t"); String query = s.next(); int did = s.nextInt(); if(!relevance_judgments.containsKey(query)){ throw new IOException("query not found"); } HashMap<Integer,Double> qr = relevance_judgments.get(query); countRelevance = 0; for (int key : qr.keySet()) { if (qr.get(key)>0.0){ countRelevance++; } } if(qr.containsKey(did) && qr.get(did) > 0.0){ RR++; } } if(countRelevance != 0){ value = (double)RR/countRelevance; } reader.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return value; }
bc199c62-3db8-43f4-aecd-0f00b24588ae
8
public boolean interrogateNewAgent_NETCAT_OLDER(BufferedReader brSocket) { try { String strThirdLine = brSocket.readLine(); if ((strThirdLine != null) && (strThirdLine.trim().equals(""))) { Drivers.sop("-->>> Almost there... Confidence level is 75% ..."); sendCommand_RAW(""); String strFourthLine = brSocket.readLine(); if ((strFourthLine != null) && (strFourthLine.trim().endsWith(">"))) { Drivers.sop("-->>>> OK. So as best as I can tell, this is a netcat agent. I will label this implant netcat -->>>> Confidence level for netcat: 100% -->>>> I am sending commands to better interrogate the system now..."); this.myIMPLANT_ID = 1; try { this.myImplantName = Driver.ARR_IMPLANT_NAME[this.myIMPLANT_ID]; } catch (Exception e) { this.myImplantName = "UNKNOWN"; } this.i_am_NETCAT_Agent = true; this.myImplantInitialLaunchDirectory = strFourthLine; brSocket.readLine(); } } sendCommand_RAW("hostname"); brSocket.readLine(); this.myHostName = brSocket.readLine(); sendCommand_RAW("echo %username%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.myUserName = brSocket.readLine(); sendCommand_RAW("echo %homedrive%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.myHomeDrive = brSocket.readLine(); if ((this.myHomeDrive != null) && (this.myHomeDrive.trim().equals("%homedrive%"))) { this.myHomeDrive = " - "; } sendCommand_RAW("echo %NUMBER_OF_PROCESSORS%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.myNumberOfProcessors = brSocket.readLine(); sendCommand_RAW("echo %OS%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.myOS_Type = brSocket.readLine(); sendCommand_RAW("echo %PROCESSOR_ARCHITECTURE%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.myProcessorArchitecture = brSocket.readLine(); sendCommand_RAW("echo %SystemRoot%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.mySystemRoot = brSocket.readLine(); sendCommand_RAW("echo %USERDOMAIN%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.myUserDomain = brSocket.readLine(); sendCommand_RAW("echo %USERPROFILE%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.myUserProfile = brSocket.readLine(); sendCommand_RAW("echo %TEMP%"); brSocket.readLine(); brSocket.readLine(); brSocket.readLine(); this.myTempPath = brSocket.readLine(); Drivers.sop("PUNT!!! Nope. I am stopping the interrogation of this system early. I did not expect to encounter an agent running an older version of cmd.exe and it is unclear if I can interact with wmic on the target. If needed, contact Splinter and ask for the methods to continue the interrogation."); return true; } catch (Exception e) { Drivers.eop("interrogateNewAgent_NETCAT_OLDER", this.strMyClassName, e, e.getLocalizedMessage(), false); } return false; }
f5c56ba5-42b3-42aa-8bdc-c94c8b3d8ca6
1
public void tick() { for (int i = 0; i < entities.size(); i++) { entities.get(i).tick(); } }
e8866fde-6702-488c-96bb-fe18684b4830
1
public boolean rollback(){ if(isSetForCommitting()){ session.getTransaction().rollback(); return true; } return false; }
79b0b973-385f-416c-a3a0-8eeabfd1b179
8
public void nextGeneration() { List<LightningSegment> newSegments = new ArrayList<LightningSegment>(); int size = segments.size(); for (int i = 0; i < size; i++) { LightningSegment lightningSegment = segments.get(i); if (getGeneration() == GameController.MAX_LIGHTNING_GENERATIONS) { segments.remove(i); size--; if (segments.isEmpty()) { return; } continue; } Coordinates mid = lightningSegment.getMidCoordsWithOffset(getRandomOffset(offsetX), getRandomOffset(offsetY)); Coordinates start = lightningSegment.getStart(); Coordinates end = lightningSegment.getEnd(); LightningSegment startToMid = new LightningSegment(start, mid, lightningSegment.isTrunk()); LightningSegment MidToEnd = new LightningSegment(mid, end, lightningSegment.isTrunk()); newSegments.add(startToMid); newSegments.add(MidToEnd); if (size == 1) { double angle = getRandomAngle(); LightningSegment forkEndSeg = getFork(angle, mid, start, end); newSegments.add(forkEndSeg); } else if (size / 2 <= i) { if (random.nextInt(100) > 50) { double angle = getRandomAngle(); LightningSegment forkEndSeg = getFork(angle, mid, start, end); newSegments.add(forkEndSeg); } } generation++; } if (offsetX != 0) { offsetX /= 2; } if (offsetY != 0) { offsetY /= 2; } segments = newSegments; }
3a11c456-a83b-40c9-a251-157c438640f3
2
private void Remover_CampoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Remover_CampoActionPerformed try { if (NomeCampo_TextField2.getText().equals("")) { JOptionPane.showMessageDialog(null, "Indique qual o nome do campo a remover!", "Alerta!", JOptionPane.WARNING_MESSAGE); } else { a.removeCampo(NomeCampo_TextField2.getText(), Escola_ComboBox2.getSelectedItem().toString()); } } catch (HeadlessException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "Erro!", JOptionPane.ERROR_MESSAGE); } }//GEN-LAST:event_Remover_CampoActionPerformed
3b4550c1-ea86-41db-947d-d413a60e8887
8
boolean traverseGroup(boolean next) { Control root = computeTabRoot(); Widget group = computeTabGroup(); Widget[] list = root.computeTabList(); int length = list.length; int index = 0; while (index < length) { if (list[index] == group) break; index++; } /* * It is possible (but unlikely), that application code could have * disposed the widget in focus in or out events. Ensure that a disposed * widget is not accessed. */ if (index == length) return false; int start = index, offset = (next) ? 1 : -1; while ((index = ((index + offset + length) % length)) != start) { Widget widget = list[index]; if (!widget.isDisposed() && widget.setTabGroupFocus(next)) { return true; } } if (group.isDisposed()) return false; return group.setTabGroupFocus(next); }
312fc46e-e18c-42cf-9325-72c2bfea0cd7
0
public void removeAllPawns() { pawns.clear(); currentPawn = null; }
85250ced-9cdf-48af-a5ae-d7b07963db68
6
public void drawButton(Minecraft par1Minecraft, int par2, int par3) { if (this.drawButton) { FontRenderer var4 = par1Minecraft.fontRenderer; GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture("/gui/gui.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); boolean var5 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; int var6 = this.getHoverState(var5); this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + var6 * 20, this.width / 2, this.height); this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + var6 * 20, this.width / 2, this.height); this.mouseDragged(par1Minecraft, par2, par3); int var7 = 14737632; if (!this.enabled) { var7 = -6250336; } else if (var5) { var7 = 16777120; } this.drawCenteredString(var4, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, var7); } }
84720dee-f1e7-47c0-84db-dc2ae22c1640
9
public void endScene() { co.setX(350); co.setY(10); burnedVillage.setX(350); boolean newVillage = false; Image off = createImage(WIDTH,HEIGHT); Graphics second = off.getGraphics(); CloudObject text1 = new CloudObject(100,10,pane.getClass().getResourceAsStream("spence_end.png"),"spence_end.png",280,171); CloudObject text2 = new CloudObject(100,310,pane.getClass().getResourceAsStream("village_end.png"),"village_end.png",280,171); while(curTime<timeOut+13000) { curTime = System.currentTimeMillis(); backGround.paintIcon(pane, second, backGround.getX(), (int)backGround.getY()); co.paintIcon(this, second, co.getX(),(int)co.getY()); burnedVillage.paintIcon(this, second, burnedVillage.getX(),(int)burnedVillage.getY()); for (int i=0;i<drops.size();i++) { drops.get(i).paintIcon(pane,second, drops.get(i).getX(), (int)drops.get(i).getY()); if (drops.get(i).getY()>HEIGHT) { drops.remove(drops.get(i)); break; } else { drops.get(i).move(); } } if ( newVillage == false && curTime>timeOut+ 3000 ) { burnedVillage.setFileName(pane.getClass().getResourceAsStream("saved_village.png")); newVillage = true; } if (curTime>timeOut+3000 && curTime<timeOut+8000) { text2.paintIcon(pane, second, text2.getX(),(int) text2.getY()); } if (curTime>timeOut+7900 && curTime<timeOut+13000) { text1.paintIcon(pane, second, text1.getX(),(int) text1.getY()); } pane.rain(); pane.getGraphics().drawImage(off, 0,0,pane); } CloudObject youWon = new CloudObject(0,0,pane.getClass().getResourceAsStream("you_won.png"),"you_won.png",800,600); youWon.paintIcon(pane, pane.getGraphics(), youWon.getX(), (int)youWon.getY()); }
340e1dc3-6110-42a9-9127-f5f6df1bab37
1
public boolean isTheirWin() { return (!theirSea.fleetDestroyed() && mySea.fleetDestroyed()); }
5ac33a4b-c878-4b68-9600-ec60a31c3b73
6
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); while ((line = in.readLine()) != null && line.length() != 0) { int n = Integer.parseInt(line.trim()); for (int i = 0; i < n; i++) { line = in.readLine().trim(); int size = line.length(); s = (line + line).toCharArray(); int[] sa1 = suffixArray(); for (int j = 0; j < sa1.length; j++) { if (sa1[j] < size) { for (int k = 0; k < size; k++) out.append(s[sa1[j] + k]); break; } } out.append("\n"); } } System.out.print(out); }
e19c02f1-8c98-43f9-bed9-4f7721481bc6
3
@Override public boolean next() { if (brParser == null) { // this should not happen, throw exception throw new RuntimeException("No parser available to fetch row"); } if (getMetaData() == null) { setMetaData(((AbstractParser) brParser).getPzMetaData()); } clearRows(); final Row r = brParser.buildRow(this); if (r != null) { addRow(r); } return super.next(); }
684cec16-adc7-4e58-8572-b1edad0189c8
4
public double standardizedItemMinimum(int index){ if(!this.dataPreprocessed)this.preprocessData(); if(index<1 || index>this.nItems)throw new IllegalArgumentException("The item index, " + index + ", must lie between 1 and the number of items," + this.nItems + ", inclusive"); if(!this.variancesCalculated)this.meansAndVariances(); return this.standardizedItemMinima[index-1]; }
1ecc4eaa-aa80-4803-969d-6f766b952406
8
@SuppressWarnings("unchecked") private static final Object[] decodeDictionary(byte[] bencoded_bytes, int offset) throws BencodingException { HashMap map = new HashMap(); ++offset; ByteBuffer info_hash_bytes = null; while(bencoded_bytes[offset] != (byte)'e') { // Decode the key, which must be a byte string Object[] vals = decodeString(bencoded_bytes, offset); ByteBuffer key = (ByteBuffer)vals[1]; offset = ((Integer)vals[0]).intValue(); boolean match = true; for(int i = 0; i < key.array().length && i < 4; i++) { if(!key.equals(ByteBuffer.wrap(new byte[]{'i', 'n','f','o'}))) { match = false; break; } } int info_offset = -1; if(match) info_offset = offset; vals = decode(bencoded_bytes, offset); offset = ((Integer)vals[0]).intValue(); if(match) { info_hash_bytes = ByteBuffer.wrap(new byte[offset - info_offset]); info_hash_bytes.put(bencoded_bytes,info_offset, info_hash_bytes.array().length); } else if(vals[1] instanceof HashMap) { info_hash_bytes = (ByteBuffer)vals[2]; } if(vals[1] != null) map.put(key,vals[1]); } return new Object[] {new Integer(++offset), map, info_hash_bytes}; }
c8af0373-ffbb-4992-8489-0b24c00bed70
7
private int decimalDigits ( double d, boolean expo ) { if( d == 0.0 ) return 0; d = Math.abs( d ); int e = intDigits( d ); if( expo ) { d /= Math.pow(10, e-1); e = 1; } if( e >= digits ) return 0; int iD = Math.max(1, e); int dD = digits - e; if( !trailing && dD > 0 ) { // to get rid of trailing zeros FloatingPointFormat f = new FloatingPointFormat( iD + 1 + dD, dD, true); String dString = f.format( d ); while( dD > 0 ) { if( dString.charAt(iD+1+dD-1) == '0' ) { dD--; } else break; } } return dD; }
6123734b-2462-40ae-b3c0-e7a57c4105df
5
public void work() { Iterator<ISystem> sysIter = systems.iterator(); updateTimer(); long now = now(); Collection<IEntity> entities = entitiesByID.values(); for (IEntity each : entities) { if (each.hasChanged()) { updateInfoPacks(each); each.setChanged(false); } } while (sysIter.hasNext()) { ISystem system = sysIter.next(); if (system.isRunning() && now - system.getLast() > system.getWait()) { system.setLast(now); system.work(now); } } }
c46ee801-f850-4c44-b2db-334394b35e3d
9
public static BigDecimal normalizeCycle( Cycle<Nucleotide, InteractionEdge> ac, boolean basepaironly) { List<Nucleotide> verts = ac.getVertexList(); LinkedList<Integer> tmpints = new LinkedList<Integer>(); for (Nucleotide aNuc : verts) { try { int nn = aNuc.getNormalizedNucleotide(); tmpints.add(nn); } catch (NullPointerException e) { System.out.println("offending nucleotide: " + aNuc); e.printStackTrace(); System.exit(1); } InteractionEdge ie = ac.getNextEdge(aNuc); Set<NucleotideInteraction> nis = ie.getInteractions(); for (NucleotideInteraction aNi : nis) { if (aNi instanceof BasePair) { try { if (basepaironly == false) { int bp = ((BasePair) aNi) .getNormalizedBasePairClass(); tmpints.add(bp); } else { int bp = 1; tmpints.add(bp); } } catch (NullPointerException e) { e.printStackTrace(); } } if (aNi instanceof PhosphodiesterBond) { int pdb = ((PhosphodiesterBond) aNi) .getNormalizedBackBone(); tmpints.add(pdb); } // break; } } String intStr = ""; for (Integer anInt : tmpints) { intStr += anInt; } BigDecimal d = null; try { d = new BigDecimal(intStr); } catch (NumberFormatException e) { e.printStackTrace(); } return d; }
5dc53e8d-43f7-44ae-bfd5-15c845505ba1
6
@Override public void bsp( BSPPeer<NullWritable, NullWritable, NullWritable, NullWritable, NullWritable> peer) throws IOException, SyncException, InterruptedException { int nbRowsBlocks = nbRowsA / blockSize; int nbColsBlocks = nbColsB / blockSize; int nbBlocks = nbRowsBlocks * nbColsBlocks; int blocksPerPeer = nbBlocks / peer.getNumPeers(); int p = peer.getPeerIndex(); int lastBlock = (p+1)*blocksPerPeer; if (p==peer.getNumPeers()-1) { lastBlock = nbBlocks; } ArrayList<Block> aBlocks = new ArrayList<Block>(); ArrayList<Block> bBlocks = new ArrayList<Block>(); for (int block = p*blocksPerPeer; block<lastBlock; block++){ int i = block/nbColsBlocks; int j = block%nbColsBlocks; for (int k = 0; k < nbRowsBlocks; k++) { Block aBlock = new Block(i, k, blockSize); aBlocks.add(aBlock); Block bBlock = new Block(k,j,blockSize); bBlocks.add(bBlock); } } int aILast = ((lastBlock-1)/nbColsBlocks)*blockSize+blockSize; int bILast = nbRowsBlocks*blockSize; HamaConfiguration conf = peer.getConfiguration(); int rows = conf.getInt(inputMatrixARows, 4); int cols = conf.getInt(inputMatrixACols, 4); Utils.readMatrixBlocks(new Path(conf.get(inputMatrixAPathString)), peer.getConfiguration(), rows, cols, blockSize, aILast, aBlocks); rows = conf.getInt(inputMatrixBRows, 4); cols = conf.getInt(inputMatrixBCols, 4); Utils.readMatrixBlocks(new Path(conf.get(inputMatrixBPathString)), peer.getConfiguration(), rows, cols, blockSize, bILast, bBlocks); HashMap<String, Matrix> resBlocks = new HashMap<String, Matrix>(); for (int b = 0; b<aBlocks.size(); b++){ Block aBlock = aBlocks.get(b); Block bBlock = bBlocks.get(b); String ind = aBlock.getI() + "," + bBlock.getJ(); Matrix resBlock = resBlocks.get(ind); if (resBlock==null){ resBlock = new Matrix(blockSize,blockSize); resBlock.zeroes(); } resBlock = resBlock.sum(aBlock.getBlock().strassen(bBlock.getBlock())); resBlocks.put(ind, resBlock); } for (String ind : resBlocks.keySet()){ Matrix block = resBlocks.get(ind); Path path = new Path(conf.get(inputMatrixCPathString)+"/"+ind); Utils.writeMatrix(block.getValues(), path, conf); } }
d3937249-c1ad-4295-b178-12f95aee5cb0
5
public boolean validate() { if (!HAS_DAY || !HAS_TIME || !HAS_NAME) { VALIDATED = false; return VALIDATED; } if (HAS_TEACHER == false) setTeacher("Unknown"); if (HAS_ROOM == false) setRoom("Unknown"); generatePID(); VALIDATED = true; return VALIDATED; }
ec315c23-9379-4ec7-bbda-6d6306f0304e
1
public void wdgmsg(Widget sender, String msg, Object... args) { if(sender == cbtn) { wdgmsg("close"); } else { super.wdgmsg(sender, msg, args); } }
606c490a-4926-4761-97d5-69c6ab49f64a
2
private List<SoftwareSystem> generateSystemsEP() { List<SoftwareSystem> systems = new ArrayList<>(); for (HardwareSystem hardwareSystem : project.getHardwareSystemsEP()) for (DeploymentAlternative deploymentAlternative : project.getDeploymentAlternatives()) systems.add(new SoftwareSystem(hardwareSystem, deploymentAlternative, project.getFunctionalRequirements().size())); return systems; }
07f236fb-6d1d-4224-b770-2c57f3470956
4
public static ArrayList<Packet> extractPacketsInfo(String file){ BufferedReader reader = null; ArrayList<String> linesList = new ArrayList<String>(); ArrayList<Packet> packetList = new ArrayList<Packet>(); try { reader = new BufferedReader(new FileReader(file)); String line2 = reader.readLine(); String[] parts2; int start2 = 0; float startTime2 = 0; while(line2 != null){ if(start2 == 0){ start2 = 1; linesList.add(line2); parts2 = linesList.get(0).split("\t"); startTime2 = Float.valueOf(parts2[0]); packetList.add(new Packet(Float.valueOf(parts2[0])-startTime2, Integer.valueOf(parts2[1]))); line2 = reader.readLine(); continue; } linesList.add(line2); parts2 = line2.split("\t"); packetList.add(new Packet(Float.valueOf(parts2[0])-startTime2, Integer.valueOf(parts2[1]))); line2 = reader.readLine(); } reader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return packetList; }
05a379e0-dca4-44ee-a39d-1aa895859414
0
@Override public boolean supportsMoveability() {return false;}
7ae00494-52df-43ef-a187-e7c94b4ba0f2
9
@Override public Ability[] getTimsAdjResCast(Item I, int[] castMul) { Ability A; final Ability[] RET=new Ability[3]; // adj, res, cast castMul[0]=1; for(int i=0;i<I.numEffects();i++) { A=I.fetchEffect( i ); if(A instanceof TriggeredAffect) { final long flags=A.flags(); final int triggers=((TriggeredAffect) A).triggerMask(); if( CMath.bset( flags, Ability.FLAG_ADJUSTER ) && (( triggers&(TriggeredAffect.TRIGGER_WEAR_WIELD|TriggeredAffect.TRIGGER_GET|TriggeredAffect.TRIGGER_MOUNT ))>0)) RET[0]=A; else if( CMath.bset( flags, Ability.FLAG_RESISTER ) && (( triggers&(TriggeredAffect.TRIGGER_WEAR_WIELD|TriggeredAffect.TRIGGER_GET|TriggeredAffect.TRIGGER_MOUNT ))>0)) RET[1]=A; else if( CMath.bset( flags, Ability.FLAG_CASTER ) && (triggers > 0)) { RET[2]=A; if((triggers & TriggeredAffect.TRIGGER_HITTING_WITH)>0) castMul[0]=-1; } } } return RET; }
cdef7b10-560a-4b11-bb49-04413450b0e2
1
public void testWithFieldAdded5() { TimeOfDay test = new TimeOfDay(10, 20, 30, 40); try { test.withFieldAdded(DurationFieldType.days(), 6); fail(); } catch (IllegalArgumentException ex) {} }
608fa571-f2df-4412-acc2-2c3c807bba51
6
public static LinkedListNode findLoop(LinkedListNode head){ LinkedListNode fast=head; LinkedListNode slow=head; // boolean loop=false; while(fast != null && fast.next != null){ fast=fast.next.next; slow=slow.next; if(fast==slow){ // loop=true; break; } } if(fast == null || fast.next == null){ return null; } // if(loop){ slow=head; while(slow != fast){ fast=fast.next; slow=slow.next; } return fast; // } // // return null; }
312b6482-de6e-4cad-b618-44b4e37bc353
6
public void pauseObjects(){ if (player1 != null) player1.pause(); if (player2 != null) player2.pause(); for (Asteroid asteroid: asteroids) asteroid.pause(); for (Bullet bullet: bullets) bullet.pause(); if (alienShip != null) alienShip.pause(); if (rogueSpaceship != null) rogueSpaceship.pause(); }
d6198741-e71b-4492-bdcf-fc3e8573b263
4
@SuppressWarnings("unchecked") @Override public int compare(Column column, Row one, Row two) { Object oneObj = one.getData(column); Object twoObj = two.getData(column); if (!(oneObj instanceof String) && oneObj.getClass() == twoObj.getClass() && oneObj instanceof Comparable<?>) { return ((Comparable<Object>) oneObj).compareTo(twoObj); } return NumericComparator.caselessCompareStrings(one.getDataAsText(column), two.getDataAsText(column)); }
aa179178-2ed3-42e5-8a5e-e3a414c6187e
3
public double[] getInitConcns(){ if(!this.psi0set && !this.sigmaSet)unpack(); double[] conc = Conv.copy(this.initConcn); for(int i=0; i<this.numOfIons; i++)conc[i] *= 1e-3; return conc; }
5e533ae6-f51d-4594-95ac-2739d697e592
2
public boolean isBlockedByTanq(int x, int y, int width, int height) { synchronized (tanqs) { for (Tanq t: tanqs) { if (t.isTouching(new Vector3D(x, y, 0), (int)Math.sqrt(width * width + height * height))) return true; } } return false; }
70f0393a-cdfd-4bf4-ae5d-e6505a97193d
4
public void checkType(Symtab st) { exp1.setScope(scope); exp1.checkType(st); exp2.setScope(scope); exp2.checkType(st); if (!exp1.getType(st).equals("int") && !exp1.getType(st).equals("decimal")) { Main.error("type error in minus!"); } if (!exp2.getType(st).equals("int") && !exp2.getType(st).equals("decimal")) { Main.error("type error in minus!"); } }
84d39a4f-84b6-41fd-8afb-28531732b1ed
3
public void addItem(Time item) { if ((!items.contains(item)) && (!item.equals(emptyTime))) { items.add(0, item); } if (items.size() > maxItems) { items.remove(items.size() - 1); } }
4e723fc0-ffff-4434-980d-c317329644ef
1
private void setAttr(Attributes attr) { // atributo 'nome' if (attr.getIndex("nome") >= 0) { this.nome = attr.getValue("nome"); } else { System.out.println("BD: Faltando o atributo 'nome'"); } }
c908595c-bf35-4e74-99e6-691ea6be6487
9
public void step() { log.debug("============== Stepping "+tam.getId()+" currentState "+currentState+ " ================"); switch (getState()) { case READ_ID: if(tam.isRobotPresent()){ // if there is a robot in the tam //try to read a value from it log.info("ID from robot: " + tam.getRobotDataReceived()); if (tam.getRobotDataReceived() == 5) currentState = TAMState.WRITE_RAND; } break; case WRITE_RAND: if(tam.isRobotPresent()){ // if there is a robot in the tam int randomValue = 37; //sends a random value between 0 and 10 log.info("Sending " + randomValue +" to robot... "); tam.setRobotDataToSend(randomValue); log.info("...done"); currentState = TAMState.READ_RAND; } break; case READ_RAND: if(tam.isRobotPresent()){ // if there is a robot in the tam //try to read a value from it int value = tam.getRobotDataReceived(); log.info("Random value from robot: " + value); if (value == 37){ // it works log.info("Test success"); tam.setLedColor(LED_GREEN); currentState = TAMState.DONE; } } break; case DONE: log.info("Experiment done"); break; } log.debug("=============================="); }
c22468ec-3797-4145-8cdb-1073288c1fa4
2
public void deposit(BigInteger amount) throws IllegalArgumentException { if ( (amount == null) || (amount.compareTo(BigInteger.ZERO) <= 0) ) throw new IllegalArgumentException(); setBalance(this.getBalance().add(amount)); }
101c7a2f-532f-4519-883d-882d3a5cad67
4
public QuadTreeNode getChild(Position pos){ switch (pos){ case northWest: return nw; case northEast: return ne; case southWest: return sw; case southEast: return se; default: return null; } }
531d0b65-2141-4327-98d5-11a9eacf4a6b
9
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory, Object value) { // this local field is required to make sure exception block works with the same coercionRequired value // and it is not changed by another thread while setter is invoked boolean attemptedCoercion = coercionRequired; try { if (coercionRequired) { return method.invoke(ctx, convert(value, targetType)); } else { return method.invoke(ctx, value == null && primitive ? PropertyTools.getPrimitiveInitialValue(targetType) : value); } } catch (IllegalArgumentException e) { if (ctx != null && method.getDeclaringClass() != ctx.getClass()) { Method o = getBestCandidate(EMPTY, method.getName(), ctx.getClass(), ctx.getClass().getMethods(), true); if (o != null) { return executeOverrideTarget(o, ctx, value); } } if (!attemptedCoercion) { coercionRequired = true; return setValue(ctx, elCtx, variableFactory, value); } throw new RuntimeException("unable to bind property", e); } catch (Exception e) { throw new RuntimeException("error calling method: " + method.getDeclaringClass().getName() + "." + method.getName(), e); } }
61e88eb0-f38f-4e1f-8d66-af36ae0b9240
0
public CheckResultMessage checkSheetFormat() { return report.checkSheetFormat(); }
f62975f3-3ddc-43ee-b4e6-9b88f8235f54
1
private boolean isPossibleToPlaceDiagRightAbove(int position, int dimension, int positionRightAbove) { return elementDiagonallyRightAbove(dimension, position, positionRightAbove) >= 0 && (elementDiagonallyRightAbove(dimension, position, positionRightAbove)) % dimension < dimension - 1; }
e868c6cc-f955-4419-8ef8-2898e2343e84
8
public static int mss(String dna1, String dna2, boolean print) { int[][] matrix = new int[dna2.length() + 1][dna1.length() + 1]; int i = 0, j = 0; for(;i<=dna2.length();i++) matrix[i][0] = i; for(;j<=dna1.length();j++) matrix[0][j] = j; for(i=1;i<=dna1.length();i++) { for(j=1;j<=dna2.length();j++) { if(dna1.charAt(i - 1) == dna2.charAt(j - 1)) { matrix[i][j] = matrix[i-1][j-1]; } else { matrix[i][j] = min_3(matrix[i-1][j] + 1, matrix[i][j-1] + 1, matrix[i-1][j-1] + 1); } } } if(print) { for(int l1 = 0; l1 <= dna1.length(); l1++) { for(int l2 = 0; l2 <= dna2.length(); l2++) { System.out.print(matrix[l2][l1] + " "); } System.out.println("\n"); } } return matrix[dna2.length()][dna1.length()]; }
4026d07c-7547-44b5-98e2-52cdbb4b07f3
2
public List<Group> getGroupList(int schedule) { List<Group> list = new ArrayList<Group>(); try { ResultSet rs = con.createStatement().executeQuery( "SELECT * FROM groups WHERE schedule=" + schedule ); while(rs.next()) { list.add(getGroupFromRS(rs)); } rs.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; }
6a1487b1-8699-43a6-9b0f-2c415f3bc3fe
3
public int[] molecularSizeDistrb(){ int maxSize=0; for (int i=0; i<bucket.size(); i++){ maxSize = (bucket.get(i).getSize() > maxSize)? bucket.get(i).getSize() : maxSize; } int[] sizeDistrb = new int[maxSize+1]; for (int i=1; i<bucket.size(); i++){ sizeDistrb[bucket.get(i).getSize()] += bucket.get(i).getSize(); } return sizeDistrb; }
8853a7a5-a5ed-4d9c-b80b-758a2b34d10e
0
public String getNick() { return _nick; }
1032e5e8-d61e-41cf-b7e7-a29e45e9eb10
4
public boolean setPath(String p) { boolean test = false; if (test || m_test) { System.out.println("FileManager :: setPath() BEGIN"); } m_path = p; if (test || m_test) { System.out.println("FileManager :: setPath() END"); } return true; }
c2bcf445-a0da-4ec7-9f09-e1e22fd782a8
1
public static void createNetGame(Socket Toserv, ObjectOutputStream out, ObjectInputStream in, String user) { try { AppGameContainer app = new AppGameContainer(new GameFrame(Toserv, out, in, user)); app.setDisplayMode(viewW, viewH, false); app.setVSync(true); app.start(); } catch (SlickException e) { e.printStackTrace(); } }
a6dfa34e-e865-467d-8ddf-04b2dcbe4cde
0
@Override public void lostOwnership(Clipboard clipboard, Transferable contents) { }
51da35ce-bd30-46a1-9ad4-48001a51020c
3
@SuppressWarnings("unchecked") @Override protected Class<? extends Number> translateReturnType(Class<?> clazz) { //no widening used for Minimum return (Class<? extends Number>) clazz; }
8b707015-ad8e-466d-9c96-b9f8357dcba4
1
public Image loadImage(String image){ try { return Toolkit.getDefaultToolkit().createImage(image); } catch (Exception e) { e.printStackTrace(); } return null; }