text
stringlengths
14
410k
label
int32
0
9
protected void addDebito(double acrecimo)throws ExceptionPessoa{ if(acrecimo >0){ this.debito += acrecimo; }else{ throw new ExceptionPessoa("Tentativa de adocionar d��bito com valor negativo"); } }
1
public void setDifficulty(Difficulty diff) { difficulty = diff; // Remove check from all menu items. menuGameDiffEasy.setSelected(false); menuGameDiffMedium.setSelected(false); menuGameDiffHard.setSelected(false); // Check appropriate menu item. switch (diff) { ...
3
public MultipleBruteParseAction(GrammarEnvironment environment) { super("Multiple Brute Force Parse", null); this.environment = environment; this.frame = Universe.frameForEnvironment(environment); }
0
public void add_bits (int bitstring, int length) { int bitmask = 1 << (length - 1); do if (((crc & 0x8000) == 0) ^ ((bitstring & bitmask) == 0 )) { crc <<= 1; crc ^= polynomial; } else crc <<= 1; while ((bitmask >>>= 1) != 0); }
2
private void doAfterProcessing(ServletRequest request, ServletResponse response) throws IOException, ServletException { if (debug) { log("filtroAutenticacion:DoAfterProcessing"); } // Write code here to process the request and/or response after // the rest of the filter...
1
public boolean hasUnitLeft(Player player) { for (int i = 0; i < this.unitList.length; i++) { for (int j = 0; j < this.unitList.length; j++) { if (this.unitList[i][j] != null) { if (this.unitList[i][j].getName().equals(player.getFaction().getName())) { return true; } } } } return f...
4
public String scriptDownload(String appKey, String userKey, String testId) { try { appKey = URLEncoder.encode(appKey, "UTF-8"); userKey = URLEncoder.encode(userKey, "UTF-8"); testId = URLEncoder.encode(testId, "UTF-8"); } catch (UnsupportedEncodingException e) { ...
1
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
4
private static boolean goodWord(String s){ if(s.contains("-")){ return false; }else if(s.contains("'")){ return false; }else if(s.contains(" ")){ return false; }else if(s.contains(".")){ return false; }else if(s.contains("fuck")){ return false; }else if(s.contains("shit")){ return false; ...
7
public static void main(String[] args) throws Exception { for(int c=0; c<2; c++) { long lall = 0, tall = 0; for(File f : new File("resources/testdata/").listFiles()) { RandomAccessFile raf = new RandomAccessFile(f, "r"); byte[] data = new byte[(int) raf.length()]; raf.readFully(data); Buffer c...
3
protected void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { HttpSession session = req.getSession(true); HashMap<Product,Integer> map = (HashMap<Product,Integer>)session.getAttribute("cart"); int uid = (int)((User)session.getAttribute("currentSessionUser")).getI...
2
static Handler remove(Handler h, Label start, Label end) { if (h == null) { return null; } else { h.next = remove(h.next, start, end); } int hstart = h.start.position; int hend = h.end.position; int s = start.position; int e = end == null ?...
7
public void drawAATrapezoid(float line0, float line1, float x0, float x1, float x2, float x3 ) { for (int y = line0 < 0 ? 0 : (int)Math.round(line0); y < (int)Math.round(line1) && y < h; ++y) { int lx0 = (int)(x0 + (y + 0.5f - line0) * (x2 - x0) / (line1 - line0)); int lx1 = (int)(x1 + (y + 0.5f - line0) * (...
6
public void inicializarTransformador() { String inicializar = inicializarTiposTransformador(); if (puntoLuz.getTransformador() == null) { puntoLuz.setTransformador(new Transformador()); puntoLuz.getTransformador().setFabricante(new Fabricante()); puntoLuz.getTransfor...
9
public static String[] searchProduct(Integer ID) { Database db = dbconnect(); String [] Array = null; try { String query = ("SELECT * FROM product WHERE PID = ?"); db.prepare(query); db.bind_param(1, ID.toString()); ResultSet rs = db.executeQuery()...
2
public static ArrayList<Item> generateContents(int containerSize, int density){ ArrayList<Item> returnlist = new ArrayList<Item>(); Random rand = new Random(System.currentTimeMillis()); if (possibilities.isEmpty()) { makePossibilities(); } for (int x = 0; x < containerSize; x++){ if (rand.nextI...
3
protected void validateInterval(int start, int end) { if (end < start) throw new RuntimeException("Wrong interval: end < start"); // Console.Out.WriteLine("Checking interval "+start+" - " +end +" on "+name); if (start < 0 || start > fileSize) throw new RuntimeException("Wro...
5
public void AddPHPFileToDatabase(DatabaseAccess JavaDBAccess, String host, String url, int port, String FileURL) { File PHPFile; //The PHP file where we want to inject the vulnerabilities String filename = "." + File.separator; Connection conn = null; JFileChooser fc = new JFileChooser...
4
private void gameOverEvent(GameEvent gameEvent) { gameEvent.sourceGame = this.name; for (GameListener listener : gameListeners) { if (listener == null) continue; listener.onGameEnd(gameEvent); } }
2
@Override public void mouseWheelMoved(MouseWheelEvent e) { if(e.getWheelRotation()<0) { zoomIn(); } else if(e.getWheelRotation()>0) { zoomOut(); } }
2
public VentanaAgregar(){ this.config(); enviar = new JButton("Enviar"); nombre =new JLabel("Nombre: "); direccion = new JLabel("Direccion: "); fechaNacimiento = new JLabel("Fecha Nacimiento: "); nombre_ = new JTextField(); direccion_ = new JTextField(); fechaNacimiento_ = new JTextField(); ...
3
public String getPiloteJdbc() { return piloteJdbc; }
0
public int getFileSize() { return fileSize; }
0
public String convert1(String s, int numRows) { if(s.isEmpty()) { return ""; } if(s.length() <= numRows) { return s; } StringBuilder sb = new StringBuilder(s.length()); for(int i = 0; i < numRows; i++) { if(i%2 == 0) { ...
7
public Credentials(String name, String pass, String path) { this.name = null; this.pass = null; // the user provided in on command line if (name != null) { this.name = name; if (pass != null) { this.pass = pass; return; ...
9
private List<String> loadNoDeleteFiles(JsonObject configContent) { List<String> noDeleteFiles = new ArrayList<String>(); if (configContent != null) { JsonArray array = configContent.getAsJsonArray("no_delete"); if (array != null) { for (JsonElement elem : array) { if (elem instance...
4
private void prepararIteracion() { /* * Asignar tareas a los procesadores. */ for (Integer prioridadActual : this.tareasListasPorPrioridad.keySet()) { Iterator<Tarea> it = this.tareasListasPorPrioridad.get( prioridadActual).iterator(); while (it.hasNext()) { Tarea tarea = it.next(); boolea...
9
public String toString() { String s = ""; for (int i = 0; i < dungeon.size(); i++) { for (int j = 0; j < dungeon.size(); j++) { Site site = new Site(i, j); if (rogueSite.equals(monsterSite) && (rogueSite.equals(site))) s += "* "; else if (rogue...
9
public PlayerSave loadMythgame(String playerName, String playerPass) { boolean exists = (new File("./savedGames/"+playerName+".dat")).exists(); PlayerSave tempPlayer; try { if(exists || mythRetry == 3){ ObjectInputStream in = new ObjectInputStream(new FileInputStream("./savedGames/"+playerN...
3
public void stem() { k = i - 1; if (k > 1) { step1(); step2(); step3(); step4(); step5(); step6(); } i_end = k+1; i = 0; }
1
final public void columnAndAlias() throws ParseException { /*@bgen(jjtree) columnAndAlias */ SimpleNode jjtn000 = new SimpleNode(JJTCOLUMNANDALIAS); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { switch ((jj_ntk==-1)?jj_ntk(...
9
static public byte[] decode(byte[] in) { String out = new String(""); //We'll use a string so we don't need any expanding arrays int bits, tbits; HuffmanNode tmp; if(unsigned(in[0]) == 0xFF) { return Arrays.copyOfRange(in, 1, in.length); } tbits = (in.length-1)*8 - unsigned(in[0]); bits = 0; in = ...
4
public static void setTipoFunc(String tipoFunc) { Funcionario.tipoFunc = tipoFunc; }
0
private void paste() { try { switch(style) { case INTEGERS: text += Integer.parseInt((String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor)); break; default: text += (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor); ...
3
public static void initializeDataBaseSimulator(String fileName) throws Exception { DBSIMULATOR = new HashMap<String, DataPoint>(); BufferedReader reader = new BufferedReader(new FileReader(fileName)); String line=""; while((line=reader.readLine())!=null) { DataPoint current = new DataPoint(line); DB...
1
public void setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; }
0
public void paintTrack(Graphics g) { boolean leftToRight = JTattooUtilities.isLeftToRight(slider); g.translate(trackRect.x, trackRect.y); int overhang = 4; int trackLeft = 0; int trackTop = 0; int trackRight = 0; int trackBottom = 0; if (slider.getOrient...
9
public boolean isOfTypes(Class<?>... classes) { if (classes.length != size) return false; for (int i = 0; i < size; i++) { if (items[i] == null) continue; String inTuple = box(items[i].getClass().toString() .replaceAll("java.lang.", "").replaceAll("class", "") .replaceAll(" ", "")); String...
7
public T predecessor(T data) { if (this.isEmpty()) return null; if (this.getData().compareTo(data) < 0) { if (this.getRight() == null) return null; T tmp; if ((tmp = this.getRight().predecessor(data)) == null) return this.getData(); return tmp; } if (this.ge...
7
@Override public RemoteClass deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject object = (JsonObject) json; String name = null; String doc = null; boolean abstractValue = false; TypeRef extendsValue = null; Method cons...
8
@Override protected void paintComponent(Graphics g) { //Clears the window so it can be updated super.paintComponent(g); //Paints the updated image(s) inside of the window ImageIcon icon1 = new ImageIcon(GetBlackjackTable.class.getResource("/DragonBoard.jpg")); Image background = icon1.getImage(); ...
9
public Set<T> getSet(int i) { Set<T> res=null; if(this.size()<=i) { return this; } else { for(Set<T> p=this;p!=null;p=p.next) { if(i>0) { if(res==null) { res=new Set(p.a,null); } else { res=res.ins(p.a); } i--; }...
4
public void closeWriter() { try { this.writer.flush(); this.writer.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
1
@Override public void onError(ModelNotification notification) { setChanged(); notifyObservers(notification); errorsWhileStarting = true; stopServer(); }
0
public void buttonBuscarResultados() { destinoDAO = new DestinoDAO(); paisDAO = new PaisDAO(); listaDestinosAproximados = new ArrayList<>(); List<Destino> listaDestinosRetornados = destinoDAO.listar(); BigDecimal doubleArredondado = null; boolean achouCompativel ...
4
public String getRelationship(){ String relationshipStatus = new String(); if(love<-5){ relationshipStatus = "an enemy"; } else if(love<-1){ relationshipStatus = "a nuisance"; } else if(love<1){ relationshipStatus = "a person"; ...
4
public void weeklyBonus(Player player) { if (color == player.getColor()) { type.weeklyBonus(player); } }
1
public boolean isEmpty() { return first == null; }
0
public mxRectangle getCellContainmentArea(Object cell) { if (cell != null && !model.isEdge(cell)) { Object parent = model.getParent(cell); if (parent == getDefaultParent() || parent == getCurrentRoot()) { return getMaximumGraphBounds(); } else if (parent != null && parent != getDefaultParent())...
8
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("SHS BankServlet: doPost()"); processRequest(request, response); }
0
double[] randomSample() { double[] sample = new double[n]; for (int i = 0; i < n; i++) { sample[i] = (lowBound[i] + generator.nextDouble() * (upBound[i] - lowBound[i])); } return sample; }
1
public void mouseDragged(MouseEvent me) { // if out of range, don't even look at it if (me.getX() < 0 || me.getX() > squareSize * cols || me.getY() < 0 || me.getY() > squareSize * rows) return; int x = me.getX() - 1, y = me.getY() - 1; if (x < squareSize * col...
6
public void setWapSignalFromString(String s) { if (s == null) { wapSignal = WAP_SIGNAL_MEDIUM; return; } s = s.trim(); if (s.equalsIgnoreCase("none")) { wapSignal = WAP_SIGNAL_NONE; } else if (s.equalsIgnoreCase("low")) { wapSignal = WAP_SIGNAL_LOW; } else if ((s.equalsIgnoreCase("med...
7
private void initializeView() { this.setOpaque(true); this.setLayout(new BorderLayout()); resourcePanel = new JPanel(); resourcePanel.setLayout(new BoxLayout(resourcePanel, BoxLayout.Y_AXIS)); resourcePanel.setBackground(Color.WHITE); for(ResourceBarElement type : resourceElementList) { resource...
2
public boolean replaceSubBlock(StructuredBlock oldBlock, StructuredBlock newBlock) { if (innerBlock == oldBlock) innerBlock = newBlock; else return false; return true; }
1
public void gotfocus() { if (focusctl && (focused != null)) { focused.hasfocus = true; focused.gotfocus(); } }
2
public boolean isComplete() { try { boolean emptyFields = false; String name = nameField.getText(); String magneticHeading = magneticHeadingField.getText(); //String altitude = altitudeField.getText(); nameField.setBackground(Color.WHITE); magneticHeadingField...
5
public int getType() {return this.type;}
0
public byte[] getBytes() { return this.data.array(); }
0
@Override public void run() { log.warn("The creation of Linux shell-scripts is an untested feature and not supported!"); if (targetScriptFolder== null)targetScriptFolder = new File("."); if (runsh == null) runsh = new File("run.sh"); if (!runsh.isFile()) { log.error("run.sh searched at " + runsh.getAbsol...
7
public void testPropertySetDayOfYear() { DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0); DateTime copy = test.dayOfYear().setCopy(12); assertEquals("2004-06-09T00:00:00.000+01:00", test.toString()); assertEquals("2004-01-12T00:00:00.000Z", copy.toString()); try { ...
2
private static void recursivelyCatalogPDFs(java.util.ArrayList<File> allFiles, File directory) { File[] children = directory.listFiles(); if(children != null && children.length > 0) { java.util.ArrayList<File> directories = new java.util.ArrayList<File>(children.length); java.uti...
7
public boolean insertSkillScore(String employeeId, String skillName, int ratingId) { String sql = INSERT_SKILL_SCORE; Connection connection = new DbConnection().getConnection(); PreparedStatement preparedStatement = null; boolean flag = false; try { preparedStatement = connection.prepareStatement(sql);...
4
@Override public List<Country> load(Criteria criteria, GenericLoadQuery loadGeneric, Connection conn) throws DaoQueryException { int pageSize = 50; List paramList = new ArrayList<>(); StringBuilder sb = new StringBuilder(WHERE); String queryStr = new QueryMapper() { @Ove...
2
public int getSequence_Id() { return sequence_Id; }
0
public GUITreeComponentRegistry() {}
0
private ConnectionableCapability getSourceCapability( int x, int y ){ float bestScore = 1.0f; ConnectionableCapability result = null; ConnectionFlavor flavor = factory.getFlavor(); for( ConnectionableCapability capability : site.getCapabilities() ){ if( capability.isSource( flavor )){ float score = ca...
3
public Screen respondToUserInputClick(MouseEvent mouse) { int mx = mouse.getX(); int my = mouse.getY(); if(connectButton.intersects(mx, my)) { if(!isHost) { return new MultiplayerGame(Pong.ipText.getText(), Integer.parseInt(Pong.connectPortText.getText()), winScore...
5
@Test public void testGetSumm() { System.out.println("getSum"); assertEquals(12.0, new Tetrahedron(1.5,2,3.5,12).getSum(), 0.00001); }
0
public LSystem getLSystem() { return input.getLSystem(); }
0
public String findString(String key, String value, String find) { for (int i = 0; i < lines.size(); i++) { Line line = new Line(lines.get(i)); if (line.getString(key).equals(value)) { return line.getString(find); } } return null; }
2
public void paintComponent(Graphics g){ expertamd.setFont(normal); experenv.setFont(normal); Series.setFont(normal); ExactName.setFont(normal); PoolInfo.setFont(normal); CoinCalc.setFont(normal); ExpertModeCheckBox.setFont(normal); Walletaddress.setFont(normal); StartMining.setFo...
8
@Override public void sign(String apikey) { this.apikey = apikey; }
0
public static void insertPerson(PersonBean person){ PreparedStatement pst = null; Connection conn=null; boolean result = false; try { conn=ConnectionPool.getConnectionFromPool(); pst = conn .prepareStatement("INSERT INTO PERSON (FNAME, LNAME, ADDRESS, USERID, PASSWORD, TYPE) " + "VALUES ...
4
public static void saveScores(int score) throws IOException { BufferedReader reader = new BufferedReader(new FileReader( "F:/LearnMusic!/bin/hayden/scores.txt")); int counter = 0; boolean condition = false; String scores[] = new String[100]; String temp = ""; while (temp != null) { scores[counter] =...
9
public static void main(String[] args) { try { test1(); } catch (Exception e) { e.printStackTrace(); } StdOut.println("--------------------------------"); try { test2(); } catch (Exception e) { e.printStackTrace(); } ...
8
public void setBlogContentLable(String blogContentLable) { this.blogContentLable = blogContentLable; }
0
private static void addNeighbours(LinkedList<Vertex> unobstructed) { if (src.getClass() != Point.class) return; Point p = (Point)src; if (p.getLeft().isVertex()) unobstructed.add(p.getLeft()); if (p.getRight().isVertex()) unobstructed.add(p.getRight()); }
3
@Override public Void doInBackground() { progressBar.setVisible(true); loginScreen.repaint(); BackendInterface backend= new Backend(); //Variable to communicate with Model merely for modification and retrieval of information. try { backend= backend.readUser(); } catch (FileNotFoun...
7
void makeParseUneditable() { editable = false; try { parseTable.getCellEditor().stopCellEditing(); } catch (NullPointerException e) { } }
1
public static Image contrast(Image original, int r1, int r2, int s1, int s2) { if (original == null) { return null; } Image img = original.shallowClone(); for (int x = 0; x < img.getWidth(); x++) { for (int y = 0; y < img.getHeight(); y++) { double red = contrastValue(original.getPixel(x, y, RED), r1,...
3
public JSONWriter array() throws JSONException { if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { this.push(null); this.append("["); this.comma = false; return this; } throw new JSONException("Misplaced array."); }
3
public TWLInputForwarder(GUI gui, Input input) { if (gui == null) { throw new NullPointerException("gui"); } if (input == null) { throw new NullPointerException("input"); } this.gui = gui; this.input = input; }
2
public static int svm_check_probability_model(svm_model model) { if (((model.param.svm_type == svm_parameter.C_SVC || model.param.svm_type == svm_parameter.NU_SVC) && model.probA != null && model.probB != null) || ((model.param.svm_type == svm_parameter.EPSILON_SVR || model.param...
7
public static void addBillItem(int billID, int medicineID, int quantity) { String query = "SELECT ifnull(count(*),0) as count " + "FROM `billItem` " + "WHERE `billItem`.`billId` = '%d' " + "AND `billItem`.`medicineId` = '%d';"; int exists = 0; ...
4
public void renderMob(int xp, int yp, Sprite sprite) { xp -= xOffset; yp -= yOffset; for(int y = 0; y < sprite.SIZE; y++) { int ya = y + yp; for(int x = 0; x < sprite.SIZE; x++) { int xa = x + xp; if(xa < -sprite.SIZE || xa >= width || ya < 0 || ya >= height) break; if(xa < 0) xa = 0...
8
@Override /** * This method will be used by the table component to get * value of a given cell at [row, column] */ public Object getValueAt(int rowIndex, int columnIndex) { Object value = null; Language language = languages.get(rowIndex); switch (columnIndex) { case COLUMN_NAME: value = language.ge...
4
public String obtenTabla(String busqueda) { ArrayList<Equipo> lista = bd.buscaEquipo(Integer.parseInt(busqueda)); if (lista.size() == 0) { return "<label id=\"errorBusqueda\" class=\"errorFormulario\">No se encontraron equipos</label>"; } String tablaIn = "<table style=\"wid...
2
private void comboBox1ItemStateChanged(ItemEvent e) { // TODO add your code here if (comboBox1.getSelectedIndex()==0) { textField1.setText("[-0.5; 0.5] max"); } else { textField1.setText("[-0.2; 0.95] max"); } }
1
public void setPriority(Priority priority) { this.priority = priority; }
0
public void Forward(double value){ if (!forward){ start_pos = gyro[0]; } forward = true; speed = 1.2*value; }
1
public void testAddMonth() { Date date = DateUtils.addMonth(testDate, 1); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); assertEquals(Calendar.OCTOBER, calendar.get(Calendar.MONTH)); date = DateUtils.addMonth(testDate, 4); calendar.setTime(date); assertEquals(Calendar.JANUARY, calend...
0
private void followEdge(final int _x, final int _y, final BufferedImage _bi) { _bi.setRGB(_x, _y, rgb_border); for (int dX = 1; dX <= 1; dX++) { for (int dY = 1; dY <= 1; dY++) { if (!(dX == dY && dY == 1)) { int x = _x + dX; int y = _y + dY; if (x >= 0 && y >= 0 && x < _bi.getWidth...
9
void shootOnDos() { for (Entity e : DOServer.entities) if (e instanceof Dos) if (attackTimeout <= 0 && e.x > x - 500 && e.x < x + 500 && e.y > y - 500 && e.y < y + 500) { DOServer.entities.add(new Meatball(x, y, e.x, e.y)); attackTimeout = ATTACK_DELAY; return; } }
7
public int posWalkForwards(int begin_pos, int end_pos, double tmr, int end_time,int standstill_pos,int standstill_time,int standstill_count){ if (tmr < standstill_time) { double step = (standstill_pos - begin_pos)/(double)standstill_time; return begin_pos + (int)(tmr*step); } else if (tmr>=standstill_time&&t...
5
private void refreshEditData () { JList<River> jList = (JList<River>) riverList; River selRiver = (River) jList.getSelectedValue(); if (selRiver == null) return; riverNameField.setText(selRiver.getRiverName()); fromNameField.setText(selRiver.getTripFrom()); toNameField.setText(selRiver.getTripTo()); ...
1
private int seeders() { int count = 0; for (TrackedPeer peer : this.peers.values()) { if (peer.isCompleted()) { count++; } } return count; }
2
public static boolean downloadSSH(InetAddress ip, boolean toVM, String sessionid, String outputFolder){ try { JSch jsch = new JSch(); Session session; if (toVM) { session = jsch.getSession("root", ip.getHostAddress(), 22); } else { session = jsch .getSession(DefaultNetworkVariables.DAS4_USER...
5
@EventHandler public void onCuboidFind(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { Player player = event.getPlayer(); User user = EdgeCoreAPI.userAPI().getUser(player.getName()); if (user != null && CuboidHandler.getInstance().isSearching(player.getName()) &&...
6
private void setupEventListener() { captureMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_MASK)); newImageMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); openMenuItem.setAccelerator( ...
4