text
stringlengths
14
410k
label
int32
0
9
public void addANewRoute(String newIP, ArrayList<String> configurationFile){ element = new String[3]; for(int i=0; i<configurationFile.size(); i++){ for(int j=0; j<configurationFile.size(); j++){ element[0] = getAddress(configurationFile.get(i)); element[1] = ...
3
private static String getAttribute( Element e, String name, Object defaultValue ) throws IOException { String value = e.getAttribute( name ); if (value.isEmpty()) { if (defaultValue == null) { throw new IOException( "Required attribute '" + name + "' for element '" + ...
2
private void removeStudentFromDB(Student student) throws ServerException { if (log.isDebugEnabled()) log.debug("Method call. Arguments: " + student); try { NodeList groups = document.getElementsByTagName("group"); Element group = getGroupNodeByNumber(groups, student.getGroupNumber()); if (group == ...
7
final int method1714(int i, int i_24_) { anInt5866++; if (Cache.method576(i_24_, 29)) { if (((Class348_Sub51) ((Class239) this).aClass348_Sub51_3136) .aClass239_Sub25_7271.method1830((byte) -97) && !Class151.method1210((byte) -113, ((Class348_Sub51) (((Class239) this) .aClass348_...
6
public K findKey (Object value, boolean identity) { V[] valueTable = this.valueTable; if (value == null) { K[] keyTable = this.keyTable; for (int i = capacity + stashSize; i-- > 0;) if (keyTable[i] != null && valueTable[i] == null) return keyTable[i]; } else if (identity) { for (int i = capacity + st...
9
public Section get(int id){ return this.section[id]; }
0
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...
6
@Test public void deltaVectors_test() { try{ double []vec1= {1.0,2.0,3.0,1.0}; double []vec2= {2.0,1.0,1.0,3.0}; double result = FastICA.deltaVectors(vec1,vec2); double exp=1.5; Assert.assertEquals(result,exp,0.0); } catch (Exception e) { // TODO Auto-generated catch block fail("Not yet impl...
1
public static String deFront(String str) { int len = str.length(); if (len == 0) { return str; } if (len == 1) { return str.charAt(0) == 'a' ? str : ""; } if (str.charAt(0) == 'a') { if (str.charAt(1) == 'b') { return...
6
public Attributes[] toArray() { Attributes[] result = new Attributes[size]; System.arraycopy(attributeLists, 0, result, 0, size); return result; }
0
public void showError(Throwable t, String resource) { String text; try { text = resources.getString(resource + ".text"); } catch (MissingResourceException e) { text = resources.getString("error.text"); } String title; t...
2
public static void removeCardFromCurrentlyOpenCardViewer(String cardID) { if (!mostRecentCardViewer.isShowing()) { return; } Card previous; for (Card e : mostRecentCardViewer.cards) { previous = e; if (e.getID().equals(cardID)) { mostRe...
4
public double findClosestValue(int nums, double sumBudgets, List<PriceBean> beans, List<SelectedPrice> result) { int numberSize = 0; for (int i = 0; i < beans.size(); i++) { if (beans.get(i).getName() > sumBudgets) { numberSize = i; break; } } int[] numbers = new int[numberSize]; double[] pri...
3
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; PrefixQuery other = (PrefixQuery) obj; if (prefix == null) { if (other.prefix != null) return false; ...
6
public boolean setUsertileImageFrameHeight(int height) { boolean ret = true; if (height <= 0) { this.usertileImageFrame_Height = UISizeInits.USERTILE_IMAGEFRAME.getHeight(); ret = false; } else { this.usertileImageFrame_Height = height; } se...
1
public static void packData(String from) throws Exception { logger.info("Starting to pack map data"); DatabaseConnection con = DatabaseManager.getSingleton().getConnection("info"); List<PreparedStatement> statements = new ArrayList<PreparedStatement>(); for (int i = 0; i < 16384; i++) { if (new File(from + i...
4
public final void ban(String channel, String hostmask) { this.sendRawLine("MODE " + channel + " +b " + hostmask); }
0
private boolean applySelectedUpdates() { for(DBUpdate u : updates) { console.printf("Executing Update %s ... ", u.getFileName().toString()); if (db.executeScript(u.getPath())) { console.printf("done\n"); } else { //console.printf("failed!\n"); return false; } } return true; }
2
@Override public void eliminar(Elemento e) { Integer aEliminar = e.get(); //Explicación. ConsolaManager.getInstance().escribirInfo(Messages.getString("HASH_ABIERTO_NOMBRE") + tipo, Messages.getString("HASH_ABIERTO_ELEMENTO_A_INSERTAR", new Object[]{aEliminar} )); //$NON-NLS-1$ //$NON-NLS-2$ //Se busc...
9
public String getFingerPrint(){ if(hash==null) hash=genHash(); byte[] kblob=getPublicKeyBlob(); if(kblob==null) return null; return getKeySize()+" "+Util.getFingerPrint(hash, kblob); }
2
public void setCategorieParent(Categorie categorie) { if (getCategorieParent() != null) { getCategorieParent().getSousCategories().remove(this); getCategorieParent().ajouterNbreSujets(-getNbreSujets()); getCategorieParent().ajouterNbreReponses(-getNbreReponses()); } ...
2
private boolean isValidInput(final String s) { return s.matches("[0-9]{4}[-][0-9]{1,2}"); }
0
private void buttonComputeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonComputeActionPerformed String errorMessage = ""; boolean error = true; try { loanCalculate.setMonthlyInterest(Float.parseFloat(textInterest.getText())); } catc...
5
protected void initializeHttpClient(HttpClient aaHTTPClient) { if (aaHTTPClient == null) { this.caHTTPClient = createHttpClient(); setSocketTimeout(DEFAULT_SOCKET_TIMEOUT); setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); } else { this.caHTTPClient = aaHT...
1
public static boolean checkFor0Points(Data myData) { //0 points only allowed in "none" semesters for(Subject thisSubject:myData.subjects){ for(Semester thisSemester:thisSubject.semesters){ if (thisSemester.mark==0 && thisSemester.usedState!=UsedState.none) ...
4
public float fruitOccuranceMLE(int fruit) { float sum = 0f; for (int i = 0; i < occuranceHist[fruit].length; i++){ sum += occuranceHist[fruit][i] * i; } return sum / occuranceHist[0].length; }
1
public static String getRandomGrid(){ Random rand = new Random(); int max = 50; int randomNum = rand.nextInt(max); System.out.println(randomNum); return possibleGrids[randomNum]; }
0
public static CubicSpline[] oneDarray(int n, int m){ if(m<3)throw new IllegalArgumentException("A minimum of three data points is needed"); CubicSpline[] a =new CubicSpline[n]; for(int i=0; i<n; i++){ a[i]=CubicSpline.zero(m); } return a; }
2
private String makeDurationString(Duration dur) { Dur d = VEventHelper.durationToICALDur(dur); String out = ""; int days = d.getDays(); if (days > 0) out += days + " " + (days == 1 ? ApplicationSettings.getInstance().getLocalizedMessage("lvip.day") : ApplicationSettings.getInstance().getLocalizedMessage("lvi...
8
@Override public void initializeLanguage() { Array<Letter> lettersAvailable = this.getLanguage().getLettersAvailable(); char[] letterDistribution = new char[] { 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', ...
1
public static Clientes sqlLeer(Clientes cli){ String sql="SELECT * FROM clientes WHERE idclientes = '"+cli.getId()+"'"; if(!BD.getInstance().sqlSelect(sql)){ return null; } if(!BD.getInstance().sqlFetch()){ return null; } cli.setRut(...
2
@Deprecated private void flipMap(){ LogicalTile[][] map = worldMap; LogicalTile[][] fliped = new LogicalTile[map.length][map[0].length]; int newX; int newY =0; for(int y = map.length-1;y>=0 ;y--){ newX = 0; for(int x = map.length-1;x >=0;x--){ fliped[newY][newX] = map[y][x]; //System.out.printl...
5
private void updateWaitTimes(double timestep) { if (this.timeSinceRTL != -1) { this.timeSinceRTL += timestep; } for (Message m: sentMessageDuration.keySet()) { double time = sentMessageDuration.get(m); sentMessageDuration.put(m, time + timestep); } ...
5
public void checkInputs(List inputs) throws IllegalArgumentException { Object [] list = inputs.toArray(); // first off, check that we got the right number of paramaters if (list.length != 3) throw new IllegalArgumentException("requires three inputs"); // now, try to cast th...
9
public boolean searchMatrix(int[][] matrix, int target) { int low; int high; int mid; low = 0; high = matrix.length - 1; while (low <= high) { mid = (low + high) >>> 1; int value = matrix[mid][0]; if (target < value) h...
7
public final void show() { StackPane parentRoot = (StackPane) ((Stage) stage.getOwner()) .getScene().getRoot(); parentRoot.getChildren().add(mask); stage.show(); }
0
public DriverThread(Vector<File> imageQueue) { this.imageQueue = imageQueue; }
0
public void testFactory_standardWeeksIn_RPeriod() { assertEquals(0, Weeks.standardWeeksIn((ReadablePeriod) null).getWeeks()); assertEquals(0, Weeks.standardWeeksIn(Period.ZERO).getWeeks()); assertEquals(1, Weeks.standardWeeksIn(new Period(0, 0, 1, 0, 0, 0, 0, 0)).getWeeks()); assertEqual...
1
public Artikel getArtikel() { return artikel; }
0
public void testConstructorEx3_TypeArray_intArray() throws Throwable { try { new Partial(new DateTimeFieldType[] {DateTimeFieldType.dayOfYear()}, null); fail(); } catch (IllegalArgumentException ex) { assertMessageContains(ex, "must not be null"); } }
1
public static double sumRow(int[][] matrix, int u) { double a = 0.0D; for(int m = 0; m < matrix[u].length; m++) { a += matrix[u][m]; } return a; }
1
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Pair other = (Pair) obj; if (this.first == null) ...
9
public static void main(String[] args) { Scanner sc = new Scanner(System.in); String login; boolean bb = false; while(!bb){ System.out.println("Input your Login"); login = sc.nextLine(); if(valid(login)){ bb = true; ...
8
public pagingAction(int currentPage, int totalCount, int blockCount, int blockPage) { this.blockCount = blockCount; this.blockPage = blockPage; this.currentPage = currentPage; this.totalCount = totalCount; // 전체 페이지 수 totalPage = (int) Math.ceil((double) totalCount / blockCount); if (totalPage == 0) ...
8
public BigDecimal getAvailability() { LinkedHashSet<PhysicalLink> uniqPhysicalLinks = new LinkedHashSet<PhysicalLink>(); LinkedHashSet<PhysicalNode> uniqIntermediaryNodes = new LinkedHashSet<PhysicalNode>(); for(VirtualLink virtualLink : linksMapping.keySet()) { PhysicalNode sourcePhysical...
8
@Override public ArrayList<BERoleTime> readRoleTime() throws SQLException { ArrayList<BERoleTime> res = new ArrayList<>(); Statement stm = m_connection.createStatement(); stm.execute("select * from [Role/Time] " + "inner join Incident " + "on [Role/Time].incid...
9
@Override public void validate() { if (platform == null) { addActionError("Please Select Platorm"); } if (location == null) { addActionError("Please Select Location"); } if (gender == null) { addActionError("Please Select Gender"); ...
4
public void showAllPorts() { model.showAllData(); }
0
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final LicenciaConductor other = (LicenciaConductor) obj; if (this.numero != other.numero) { return ...
7
@Override public int top() { if (amount != 0) { return stack[0]; } else return error; }
1
protected ToggleButton createToggleButton(final Object[] args) { String tip = new String(); String text = new String(); try{ tip = ((args.length > 0) && (args[0] != null)) ? args[0].toString() : null; } catch(final ...
9
public static void main(String[] args) { Originator o = new Originator(); o.createMemento(); o.modifyState(80); // 获取备份 o.getMemento(); }
0
public CodeEntry(byte[] buf) { int[] off = new int[1]; off[0] = 0; while (off[0] < buf.length) { pe.put(Utils.strd(buf, off), Utils.strd(buf, off)); } }
1
public void checkCharacterCollision(){ for(Character c1 : characters){ for(Character c2 : characters){ if( !c1.equals(c2) ){ if(c1.getBounds().intersects(c2.getBounds())){ moveBack(c1); } } } } }
4
private boolean wrapNonInfixIfCondition(IfStatement parent, AstNode node) { if (parent.getCondition() != node) return false; else if (node instanceof ParenthesizedExpression) return false; else return true; }
2
@Override public void draw(Graphics2D g) { bg.draw(g); p.draw(g); op.draw(g); Rectangle rect = p.getRectangle(); g.draw(rect); Rectangle rect2 = new Rectangle(p.getx() - (p.getWidth() / 2), p.gety() - (p.getHeight() / 2), p.getWidth(), p.getHeight()); g.draw(rect2); // health1 g.drawImage(Imag...
2
public void speelMuziek(Soundtracks huidigeSoundtrack){ if(this.huidigeSoundtrack != huidigeSoundtrack){ if(this.huidigeSoundtrack != null) this.huidigeSoundtrack.getGeluid().stop(); this.huidigeSoundtrack = huidigeSoundtrack; if(this.huidigeSoundtrack != null) huidigeSoundtr...
3
public String toString() { switch(t) { case FAILURE: return "FAILURE " + node; case START: return "START " + node; case EXIT: return "EXIT"; case COMMAND: return "COMMAND " + node + " executes " + command; case ECHO: return "ECHO " + msg; case TIME: return "TIME " + msg; case DELIVERY:...
8
public static boolean isStaff(CommandSender sender) { if(sender instanceof ConsoleCommandSender) { return true; } Player player = (Player) sender; if(!StaffChat.getStaffChat().isVaultPresent()) { return false; } if(StaffChat.getStaffChat().isPermissionsPresent()) { ...
7
public String getQuad() { String stt = "0"; //search for 4 equal cards... if (cards[0].getRank() == cards[1].getRank() && cards[1].getRank() == cards[2].getRank() && cards[2].getRank() == cards[3].getRank()) { stt = Character.toString(cards[0].ge...
6
private void respawnPlayer() { long time = System.currentTimeMillis(); try { for (Player p : players) { if (p.getTimeDied() != 0 && time - p.getTimeDied() > RESPAWN_TIME) { p.respawn(); Server.sendToAll(5, p.getName()); ...
5
public static void main(String args[]){ Game game = new ConnectFour(); ConnectFourAI C4AI; ConnectFourAI C4AI2; C4AI2 = new ConnectFourAI(game, "test1",Color.blue); C4AI = new ConnectFourAI(game,"test2",Color.red); if(C4AI.getGame() == game) System.out.println("Set Game Success"); if(C4AI.getPlayerNam...
5
@Override public void updateMedicine(MedicineDTO medicine) throws SQLException { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.update(medicine); session.getTransaction().com...
3
public void maintainBounderies(float pf_width, float pf_height) { /*Check if the rectangle is outside the canvas bounderies and move it inside if that is the case*/ if(x < 0) { setXPos(0); } else if((x + width) > pf_width) { setXPos(pf_width - width); } if(y < Breakout.STATUS_FIELD_HEIGHT) { setYPo...
4
@XmlElement public void setName(String name) { this.name = name; }
0
public void updateThisPlayerMovement(Stream str) { synchronized(this) { if(mapRegionDidChange) { str.createFrame(73); str.writeWordA(mapRegionX+6); str.writeWord(mapRegionY+6); } if(didTeleport) { str.createFrameVarSizeWord(81); str.initBitAccess(); str.writeBits(1, 1); str.writ...
9
void compress( int init_bits, OutputStream outs ) throws IOException { int fcode; int i /* = 0 */; int c; int ent; int disp; int hsize_reg; int hshift; // Set up the globals: g_init_bits - initial number of bits g_...
9
public static Boolean isPrime(Long n) { boolean prime = true; for (long i = 3; i <= Math.sqrt(n); i += 2){ if (n % i == 0) { prime = false; break; } } if ((n % 2 != 0 && prime && n > 2) || n == 2) { return true; } else { return false; } }
6
@Override public boolean run() { if (verbose) Timer.showStdErr("Calculating ACAT score on input: " + vcfFile); countByAcat = new CountByType(); countByEff = new CountByType(); VcfFileIterator vcf = new VcfFileIterator(vcfFile); for (VcfEntry ve : vcf) { if (vcf.isHeadeSection()) { addHeader(vcf); // ...
5
@Override public void run() { if (this.ID != null) { search (this.ID); } this._view.init(); }
1
@SuppressWarnings("deprecation") public boolean insertar(FaltaVO entrada){ Statement consulta = Conexion.getConexion().hacerConsulta(); boolean bandera = false; String columna = "INSERT INTO faltas("; String valores = "VALUES ("; if(entrada.getAlumno() != null){ columna += "alumno, "; va...
7
@EventHandler public void onPrepareItemEnchantEvent(PrepareItemEnchantEvent e) { if (e.getEnchanter() != null) { if (!plugin.getLevels().containsKey(e.getEnchanter().getName())) return; if (!plugin.getThreads().containsKey(e.getEnchanter().getName()) && plugin.getLevels().containsKey(e.getEnchanter().g...
4
public void sort() { for (String key : map.keySet()) { List<PathPattern<U>> list = map.get(key); if (list != null) { Collections.sort(list); } } }
2
public String notation() { return this.from != null && this.to != null ? this.from.toString() + this.to.toString() : null; }
2
public void hide() { for(RadioButton rb : btns) rb.hide(); }
1
public void takeAttack(AttackBox incoming){ switch (incoming.getType()) { case 'p': if(stats.naturalAR > 0){ stats.damageHP((int) (100.0 / (100 + stats.naturalAR) * incoming.getForce()) ); }else{ stats.damageHP((int) (2 - (100.0 / (100 - stats.naturalAR))) * incoming.getForce() ); } break; c...
4
public boolean equals(Object production) { if (production instanceof Production) { Production p = (Production) production; return getRHS().equals(p.getRHS()) && getLHS().equals(p.getLHS()); } return false; }
2
private void addMines(double x, double y) { for(int i = 0; i < 75; i++) { double tx = x + random.nextGaussian() * 6; double ty = y + random.nextGaussian() * 6; StoneMine sm = new StoneMine(tx,ty); if(isEmpty(sm)) { entities.add(sm); } else { sm = null; } } for(int i = 0; i < 2...
4
public static int requestDecision(Team team, String msg) { if(!team.isOnline()) { return team.getIndexOfStrength(Team.WEAKEST); } team.setLastInput(null); sendMsg(team, msg); long start = System.currentTimeMillis(); boolean maxTimeout = false; boolean avgTimeout = false; while((maxTimeout = (Syste...
9
public static void main(String[] args) throws Exception { ArrayList<Integer> list = new ArrayList<Integer>(); ArrayList<Integer> even = new ArrayList<Integer>(); ArrayList<Integer> multipleOf3 = new ArrayList<Integer>(); ArrayList<Integer> others = new ArrayList<Integer>(); B...
7
public static InputSource getFromHTTP(String adresse){ //String result = ""; URL url = null; System.out.println("downloading..."); try{ url = new URL(adresse.replace(" ", "%20")); HttpURLConnection client = (HttpURLConnection) url.openConnection(); client.setRequestProperty("User-Agent", "Xeno...
1
public Image loadImage (String file) // this method reads and loads the image { try { InputStream m = this.getClass().getResourceAsStream(file); return (ImageIO.read (m)); } catch (IOException e) { System.out.println ("Error: File " +...
1
@Override public String toString() { return String.format( "isAssignableTo(%s)", this.superclassOrInterface.getSimpleName() ); }
0
public void visitLdcInsn(final Object cst) { if (cst instanceof Long || cst instanceof Double) { minSize += 3; maxSize += 3; } else { minSize += 2; maxSize += 3; } if (mv != null) { mv.visitLdcInsn(cst); } }
3
@Override public void restoreCurrentToDefault() {cur = def;}
0
public static <GInput, GValue> Field<GInput, GValue> conditionalField(final Filter<? super GInput> condition, final Field<? super GInput, GValue> accept, final Field<? super GInput, GValue> reject) throws NullPointerException { if (condition == null) throw new NullPointerException("condition = null"); if (accept ...
8
public User getCurrentUser() { for(PinochlePlayer player : players) { if(player.getPosition() == currentTurn) { return player.getUser(); } } return null; }
2
public void augment(Edge[] path) { // find the bottleneck capacity delta on path P float delta = Float.MAX_VALUE; for (int i = 0; i < path.length; i++) { float tempWeight = path[i].getWeight(); if (tempWeight < delta) { delta = tempWeight; } ...
9
@Override public TableData checkIfColumnExist(String tableName, String columnName) throws IllegalArgumentException{ if(connexion == null && path == null) return new TableData(ApiResponse.MYAPI_NOT_INITIALISE,null); DatabaseMetaData databaseMeta = null; try { if(connect == null || connect.isClosed()) re...
8
protected PairVector<MOB,String> getAllPlayersHere(Area area, boolean includeLocalFollowers) { final PairVector<MOB,String> playersHere=new PairVector<MOB,String>(); MOB M=null; Room R=null; for(final Session S : CMLib.sessions().localOnlineIterable()) { M=S.mob(); R=(M!=null)?M.location():null; if(...
9
@Override public String toString() { String format = "\t%-20s: \"%s\"\n"; StringBuilder sb = new StringBuilder(); sb.append("Feature (line " + lineNum + "): '" + type // + "' [ " + start + ", " + end + " ]\t" // + (complement ? "complement" : "") // + "\n" // ); // More coordinates? if (featu...
4
public FloatResource(float value) { this.value = value; }
0
@Override public int getRowCount() { if (dfa != null) return dfa.getStates().size(); else return 0; }
1
@Override public void desenhar(Graphics2D g) { // TODO Auto-generated method stub Shape s = new Ellipse2D.Double(getPosX(), getPosY(), raio/2, raio/2); g.draw(s); }
0
private void resetPosition(Tile current, int row, int col){ if(current == null) return; int x = getTileX(col); int y = getTileY(row); int distX = current.getX() - x; int distY = current.getY() - y; if(Math.abs(distX) < Tile.SLIDE_SPEED){ current.setX(current.getX() - distX); } if(Math.abs...
7
public boolean isAlive() { return alive; }
0
public void setR(Route r)throws IllegalArgumentException { if(r == null) throw new IllegalArgumentException("Er is geen route"); this.r = r; }
1
private void displayInfo(){ String txt = typingArea.getText(); displayArea.append(txt + "\n"); displayArea.setCaretPosition(displayArea.getDocument().getLength()); }
0
public static void main(String[] arguments) { Dimension aDimension = Toolkit.getDefaultToolkit().getScreenSize(); Robot aRobot = null; try { aRobot = new Robot(); } catch (Exception anException) { System.err.println(anException); throw new RuntimeException(anException.toString()); } Buffered...
5
private void updateContainerInfo() { try { int total = ImageUtils.calculatePossibleDataSpace(new File(edContainerFile.getText()), edBoardCode.getText()); int used = EncryptionProvider.SHA_256_HASH_SIZE_BYTES * 2 + "{ \"timestamp\": 0000000000000, \"postText\": \"\" }".length() + txtPostT...
2