text
stringlengths
14
410k
label
int32
0
9
public void loadFiles() { for (Files file : Files.values()) { File confFile = new File(file.getPath()); if (confFile.exists()) { if (_configurations.containsKey(file)) { _configurations.remove(file); } YamlConfiguration conf = YamlConfiguration.loadConfiguration(confFile); _configurations....
4
public boolean getBoolean(int index) throws JSONException { Object o = get(index); if (o.equals(Boolean.FALSE) || (o instanceof String && ((String)o).equalsIgnoreCase("false"))) { return false; } else if (o.equals(Boolean.TRUE) || (o in...
6
@Override public int compareTo(Team o) { if (o.points == this.points) if (o.wins == this.wins) if (o.goalDiference == this.goalDiference) if (o.goalScored == this.goalScored) if (o.games == this.games) return this.name.toLowerCase().compareTo( o.name.toLowerCase()); e...
5
public static String[][] board(int row, int column, String user, String boardArray[][]) { for (int i = 0; i < 3; i++) { System.out.println("-------------"); for (int j = 0; j < 4; j++) { System.out.print("| "); if (i == row && j == column) { boardArray[i][j] = user; } else if (boardArray[i][...
5
public static ASTList concat(ASTList a, ASTList b) { if (a == null) return b; else { ASTList list = a; while (list.right != null) list = list.right; list.right = b; return a; } }
2
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Cartao other = (Cartao) obj; if (dezenas == null) { if (other.dezenas != null) return false; } else if (!dezenas.equals(other.dezenas)) ...
8
public void run() { ircConnection.isRunning = true; try { String line = ircConnection.input.readLine(); while (ircConnection.isRunning && !this.ircConnection.waitingForReconnect && (line != null)) { if (ircConnection.debug) { System.out.println("< " + line); } Iterator itr = ircConnection.han...
6
public Osoba getOsoba() { return osoba; }
0
public JSONWriter key(String string) throws JSONException { if (string == null) { throw new JSONException("Null key."); } if (this.mode == 'k') { try { this.stack[this.top - 1].putOnce(string, Boolean.TRUE); if (this.comma) { ...
4
@Override public void run() { // ustawienie flagi informującej, że wykonywanie komend jest w toku if(!ExecuteCmdTask.plugin.execFlag) { ExecuteCmdTask.plugin.execFlag = true; } else if(this.fromExecTask == false) { return; } // jeśli coś czeka w kolejce if(!ExecuteCmdTask.plugin.cmdQueue.isEmpty()...
6
@Override public boolean tick(Tickable ticking, int tickID) { if(!super.tick(ticking,tickID)) return false; if(affected==null) return false; if(affected instanceof Room) { final Room room=(Room)affected; if(!room.getArea().getClimateObj().canSeeTheMoon(room,this)) unInvoke(); else for(in...
8
private static int expectBoolean ( Object value ) throws SocketException { int v; try { v = ( (Boolean) value ).booleanValue() ? 1 : 0; } catch ( ClassCastException e ) { throw new AFUNIXSocketException("Unsupport value: " + value, e); } catch ( Nu...
3
public void createWeights() { WordWeight wordWeight = new WordWeight(this.startWord, 0); this.wordWeight.put(this.startWord, wordWeight); char alphabetLetter; int i; //label used for breaking loop outerLoop: while(!(this.queue.isEmpty())) { char[] splitWord = this.queue.get(0).toCharArray(); ...
4
private void setFitnessValues() { individuals.stream() .forEach(chromo -> chromo.setFitness(computeFitness.apply(chromo))); fittestChromo = individuals.stream() .sorted((i1, i2) -> Double.compare(i2.getFitness(), i1.getFitness())) .findFirst().get(); }
0
@Override public void run() { ///////////////////////////////////////////// // iterations 0 to max-1 setToleranceAsFraction(initialToleranceFraction); bom.resetSummary(); int numIts = 0; while (numIts < maxIts) { if (numIts > 0) { // update parameters based on previous results ...
8
public Gem(int x,int y) { super(x,y); }
0
public void setDigestMethod(DigestMethodType value) { this.digestMethod = value; }
0
public void run() { do { if (failed >= 3) { } } while (true); }
2
@Override public void run(){ isAlive = true; try{ PrintWriter printWriter = new PrintWriter(socket.getOutputStream()); while(isAlive){ synchronized (messageList){ while(!messageList.isEmpty()){ printWriter.println(me...
4
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } CacheKey other = (CacheKey) obj; if (this.last...
7
private void setEncoding(){ String encoding = "cp1251"; //if(Environment.isWin()) encoding = "Cp866"; if(Environment.isWin()) encoding = "utf8"; else if (Environment.isMac()) encoding = "utf8"; else if (Environment.isUnix()) encoding = "utf8"; message(Environment.getOsN...
5
static public void main(String[] args) throws SAXException, IOException { InferHandler handler = new InferHandler(new DatatypeLibraryLoader()); XMLReaderCreator xrc = new Jaxp11XMLReaderCreator(); XMLReader xr = xrc.createXMLReader(); xr.setContentHandler(handler); for (int i = 0; i < args.length; i...
8
static boolean test1(int val) { System.out.println("test1(" + val + ")"); System.out.println("result: " + (val < 1)); return val < 1; }
0
private static int decode4to3( byte[] source, int srcOffset, byte[] destination, int destOffset, int options ) { // Lots of error checking and exception throwing if( source == null ){ throw new NullPointerException( "Source array was null." ); } // end if ...
8
private void clearFields() { initQuantity(); initTotalAmount(); initItemCounter(); txtBarCode.clear(); txtBarCode.requestFocus(); table.getItems().clear(); hideChange(); countCustomers(); updateItemCounter(0); }
0
public void removeTab(AbstractTab tab) { remove(tab); if ( getComponentCount() == 0 ) MainWindow.getInstance().resetTitle(); }
1
public void execute() throws MojoExecutionException, MojoFailureException { if (workingDirectory == null) { try { BSFManager.registerScriptingEngine("ruby", JRubyEngine.class.getName(), new String[]{"rb"}); BSFManager rubyManager = new BSFManager(); ...
3
@EventHandler public void handleDamage(EntityDamageEvent event) { Entity entity = event.getEntity(); if (entity instanceof Player) { Player player = (Player) entity; Cuboid cuboid = Cuboid.getCuboid(player.getLocation()); if (cuboid != null) { if (cuboid.hasEvent(CuboidEvent.God)) {...
8
public static Automaton makeInterval(int min, int max, int digits) throws IllegalArgumentException { Automaton a = new Automaton(); String x = Integer.toString(min); String y = Integer.toString(max); if (min > max || (digits > 0 && y.length() > digits)) throw new IllegalArgumentException(); int d; if (di...
9
void checkTryCatchOrder() { /* * Check if try/catch ranges are okay. The following succeeds for all * classes generated by the sun java compiler, but hand optimized * classes (or generated by other compilers) will fail. */ Handler last = null; for (Iterator i = handlers.iterator(); i.hasNext();) { ...
8
public static Image getMirrorImage(Image image) { return getScaledImage(image, -1, 1); }
0
public void setTribe(String name) throws InvalidFieldException { String[] s = GameData.getCurrentGame().getTribeNames(); name = name.trim(); if (!name.equalsIgnoreCase(s[0]) && !name.equalsIgnoreCase(s[1])) { throw new InvalidFieldException( InvalidFieldException.Field.CONT_TRIBE, "Invalid Tribe."); } ...
2
public ThePlayer getThePlayer() { for (int r = 0; r < getNumRows(); r++) { for (int c = 0; c < getNumCols(); c++) { Location loc = new Location(r, c); if (get(loc) instanceof ThePlayer) return (ThePlayer) get(loc); ...
3
@EventHandler public void PlayerMiningFatigue(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getPlayerConfig().getDouble("Player.M...
6
public Path findCircuit(int citiesRemaining, Vertex home, Graphics g) { this.visited = true; Path bestPath = new Path(); bestPath.cost = 1000000000; if(citiesRemaining == 0) { //Checks this node's edges to //find the edge that goes back home for(Edge e : this.edges) { if(e.toV...
8
public JTextField getTimePeriodTextField() { return timePeriodTextField; }
0
@Override public HashMap< String, String > getResult(String SQL) { HashMap< String, String > tableColInfo = new HashMap< String, String >(); Datenbank db = (Datenbank)this.context.getObject("cms.datenbank", ContextType.USED, null); if((SQL.toLowerCase()).indexOf("insert") == ...
9
private void buy(String type, int id) throws DataBaseConnectorException { if(type != null){ int cost = -1; if(type.equals("$tank$")){ cost = dataBaseConnector.getTankCost(id); } else if(type.equals("$armor$")){ cost = dataBase...
8
public void setCtrFecha(int ctrFecha) { this.ctrFecha = ctrFecha; }
0
boolean classCreationAllowed(Chain<SootClass> classes, String classname){ boolean bool = true; for (SootClass cl : classes){ if(cl.getName().equals(classname)){ bool = false; break; } } return bool; }
2
public void validar(ActionEvent event) { if (event.getComponent().getId().equals("validarId")) { try { FacesContext context = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) context .getExternalContext().getResponse(); Usuario us = new Usuario(); Usuari...
7
public void dumpExpression(TabbedPrintWriter writer) throws java.io.IOException { if (!isInnerMost) { writer.print(writer.getClassString(classInfo, Scope.AMBIGUOUSNAME)); writer.print("."); } writer.print("this"); }
1
Object put(Object key, Object value) throws IOException { if (value == null) { return remove(key); } int hash = hashCode(key); long child_recid = _children[hash]; if (child_recid == 0) { // no bucket/page here yet, let's create a bucket Has...
6
public Vector obtenerOfertasIncluidasEntre(java.sql.Date diaIni, java.sql.Date diaFin) { Vector vector = new Vector(); try { java.sql.Date dateAuxIni; java.sql.Date dateAuxFin; String numReserva; Oferta oferta; Enumeration e = this.ofertas.elements(); while (e.hasMoreElements()) { oferta = ...
7
public static String toString(JSONObject jo) throws JSONException { StringBuffer sb = new StringBuffer(); sb.append(escape(jo.getString("name"))); sb.append("="); sb.append(escape(jo.getString("value"))); if (jo.has("expires")) { sb.append(";expires="); s...
4
private void checkCollisions(GameContext g) { if (isResolved()) { return; } List<Collidable> possibleCollisions = g.quadTree.retrieve(new ArrayList<Collidable>(),this); float percent; for (Collidable c : possibleCollisions) { if (!c.isResolved()) { if ((percent = Collisions.detectCollision(this,c...
4
private void unicast (Message m, int delay) { int src = m.getSource(); int dst = m.getDestination(); Record source = r.find (src); Record destination = r.find (dst); if ((source == null) || (destination == null)) { /* In this unlikely event. */ String msg = String.format("Error: link <P%d, ...
7
public int getMana() { return mana; }
0
private LinkedList<BasketballPlayer> getPlayers(){ LinkedList<BasketballPlayer> players = new LinkedList<BasketballPlayer>(); if(pointGuard1 != null){ players.add(pointGuard1); } if(pointGuard2 != null){ players.add(pointGuard2); } if(shootingGuard1 != null){ players.add(shootingGuard1); } if(s...
9
@Override public void setupSurface(Surface surface, Face direction) { this.surface = surface; //get the warped texture image surfaceTexture = warpImage("/texture/" + surface.roomView.room.getWallTexture() + ".png"); //set bounds for the surface surfaceWidth = surface.roomView.width / 4; surfaceHeight =...
9
public void setBlogDelegate(BlogDelegate blogDelegate) { this.blogDelegate = blogDelegate; }
0
public int print(Graphics g, PageFormat fmt, int index) { if(index > 0) return Printable.NO_SUCH_PAGE; int n = jcb.getSelectedIndex(); try { return pg.getPrintable(n).print(g, fmt, n); } catch(Exception ex) {} return Printable.PAGE_EXISTS; }
2
public Tuple<Integer,Integer> getAnyUncapturedMosquito ( int[][] board ) { List<Tuple<Integer,Integer>> uncapturedMosquitoes = new ArrayList<Tuple<Integer,Integer>>(); Tuple<Integer,Integer> mosquito = null; for ( int i = 0; i<100; i++ ) { for ( int j = 0; j<100; j++ ) { if ( board[i][j] > 0 ) { Tuple...
5
private static void findBitSets(int size, int cardinality, BitSetStrategy strategy) { if (Thread.currentThread().isInterrupted()) { throw new RuntimeException("Timed out."); } if (size < cardinality) { return; } BitSet b = new BitSet(size); if (cardinality == 0) { strategy.execute(b); return; ...
8
public void updateRecord(long now, DNSRecord rec) { // We do not want to block the entire DNS while we are updating the // record for each listener (service info) List listenerList = null; synchronized (this) { listenerList = new ArrayList(listeners); } ...
8
public static void showGUI(){ /*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. ...
6
private ArrayList<Group> setV1ToCoverNextTer(HashSet v1Marked, HashSet v1Set, ArrayList<Integer> uncoveredV2) { //v1Marked = conjuntos dos nos de I que ja foram marcados ArrayList<NodeDegree> sortedMarked = new ArrayList<NodeDegree>(); Iterator<Integer> it = v1Marked.iterator(); while(it.hasNext()) { int ...
8
private void remove(){ List<Map.Entry<String, Integer>> folder = new ArrayList<Map.Entry<String, Integer>>(frqMap2.entrySet()); Collections.sort(folder, new Comparator<Map.Entry<String, Integer>>() { public int compare(Map.Entry<String, Integer> e1, Map.Entry<S...
8
public double mean() { //************************** return this.mean; //************************** }
0
public synchronized void logout(String robot_name) { robots.remove(robot_name); }
0
boolean IsStandardToken(char data){ //Pre: //Post: if ( data >='a' && data <= 'z' || data >='A' && data <= 'Z' || data >= '0' && data <='9' || data == '_' || data == '.' || data == '-') return true; ...
9
public void skipToSequenceNumber(int sid, int sequenceNumber) throws IOException { OggPacket p = null; while( (p = getNextPacket()) != null ) { if(p.getSid() == sid && p.getSequenceNumber() >= sequenceNumber) { nextPacket = p; break; } } ...
3
public static String tensionUnitIndexToString(int index) { switch (index) { case 0: return "N"; case 1: return "lbf"; case 2: return "kgf"; case 3: return "daN"; default: r...
4
public Order() { }
0
private static int parseArgs(String[] args, HamaConfiguration conf, BSPJob bsp) { conf.set(inputMatrixAPathString, args[0]); conf.setInt(inputMatrixARows, Integer.parseInt(args[1])); conf.setInt(inputMatrixACols, Integer.parseInt(args[2])); conf.set(inputMatrixBPathString, args[3]); conf.setInt(inputMatrix...
7
public void onEnable() { initConfig(); Runnable runnable = null; host = host.toLowerCase(); if ( host.equals(FREEDNS_AFRAID_ORG) ) { runnable = new Afraid(this, username, password, domain); } else if ( host.equals(DYNS_DNS) ) { runnable = new Dyn(this, username, password, domain); } else if ( h...
5
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!sender.hasPermission("cyom.commands.sudo")) { sender.sendMessage(plugin.translate(sender, "command-no-perms", "You do not have permission to use this command")); return true;...
8
public static Language getLanguageBySource(String src) { switch (src) { case "java": return Java; case "pas": return Pascal; case "c": return C; case "cpp": return Cplus; case "py": ...
5
public void read(String pathToProperty) { try { Logger.debug("Working Directory = " + System.getProperty("user.dir")); load(new FileReader(pathToProperty)); } catch (IOException e) { throw new ConfigurationLoadingException(e); } }
1
public void renderTo(Rendering rendering) { ///if (colour != null && colour.r < 1) I.say(" Colour: "+colour) ; super.renderTo(rendering) ; final MoteFX displayed = statusFX.atIndex(statusDisplayIndex) ; if (displayed != null) { displayed.progress += 0.04f ; float alpha = displayed.progress...
4
@EventHandler public void SilverfishWaterBreathing(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getSilverfishConfig().getDouble(...
6
public static TopQueue search(String target, String dictFile) throws IOException { BufferedReader reader; reader = new BufferedReader(new FileReader(dictFile)); TopQueue topQueue = new TopQueue(); String word; int distance; while((word = reader.readLine()) != null) ...
3
private void resolutionFullAleat(){ Plateau tmp=new Plateau(plat); //tant que le score du plateau n'est pas egal au score maximal while(tmp.getScore()!=tmp.scoreOptimal && !resolu){ //on melange la liste de polyominos shuffle(); //on creer un plateau temporaire vide tmp=new Plateau(plat); ...
3
public void removeOldImagesIfNecessary() { imageTemplateRepository.removeOldImagesIfNecessary(); }
0
@Override protected void doAction(int option) { switch (option) { case 1: teamMenu(); break; case 2: matchMenu(); break; case 3: rankingMenu(); break; c...
5
public static Path getBackgroundDirectory() { Path ret = null; // Setting depends on the authui location. It is not possible to control if the directory is // already there. if (!isX86() && FileUtil.control(SystemInformation.getOSPath().resolve(SYSTEMFILE_AUTHUI_x64))) { ret...
2
public boolean[] decodeBooleans() { boolean[] res = new boolean[decodeInt()]; for (int i = 0; i < res.length; i++) { res[i] = decodeBoolean(); } return res; }
1
public XMLGregorianCalendar getExpiryDate() { return expiryDate; }
0
public String readString(DataInputStream stream, int maxLength) throws Exception { short length = stream.readShort(); if (length > maxLength || length < 0) return null; StringBuilder builder = new StringBuilder(); for (int i = 0; i < length; i++) { builder.append(stream.readChar()); } return builder.t...
3
private void dropElement() { BufferedReader in; try { ElementListViewHelper helper = (ElementListViewHelper) dropElementComboBox.getSelectedItem(); if(helper == null) return; NetworkHardware nh = (NetworkHardware) helper.getNetworkHardware(); DataOutputStream dos = new DataOutputStream(socket...
4
protected static long getChildLong(String str, Element elem) { String str2 = getTextContent(str, elem); if (null == str2 || "".equals(str2)||"null".equals(str)) { return -1; } else { return Long.valueOf(str2); } }
3
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:/...
6
public void controllerUpdate(ControllerEvent evt) { if (evt instanceof ConfigureCompleteEvent || evt instanceof RealizeCompleteEvent || evt instanceof PrefetchCompleteEvent) { synchronized (waitSync) { stateTransitionOK = true; waitSync.notifyAll(); } } else if (...
5
@Override public Node visitThirdPriorExp(ThirdPriorExpContext ctx) { String symbol = ""; if (ctx.GREATERE() != null) symbol = ">="; if (ctx.LESSE() != null) symbol = "<="; if (ctx.LESS() != null) symbol = "<"; if (ctx.GREATER() != null) symbol = ">"; return new Operation(ctx.start.getLine(), sy...
4
@Override public ElementHandler createHandler(String name) { if ("pos".equals(name)) { return new VectorBuilder(parentContext, new FinishCallback<Vector3>() { @Override public void handle(Vector3 value) { CameraBuilder.this.position = value; ...
7
public static boolean[] getArticulationPoints(boolean[][] graph) { boolean[] visited=new boolean[graph.length]; int[] disc=new int[graph.length]; int[] low=new int[graph.length]; int[] parent=new int[graph.length]; int i=0; for(i=0;i<parent.length;i++) parent[i]=-1; boolean[] ap=new boolean[graph.leng...
3
public SqlLimitResponse limit(SqlLimitRequest request) { StringBuilder sb = new StringBuilder(500); int firstRow = request.getFirstRow(); int lastRow = request.getMaxRows(); if (lastRow > 0) { // fetch 1 more than we return so that // we know if more rows are available lastRow = las...
7
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
ServerMessage(int code, MessageHandler handler) { m_handler = handler; m_map.put(code, this); }
7
@Override public double evaluate(int[][] board) { int rCol1 = 0, rCol2 = 0, rRow1 = 0, rRow2 = 0; for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[0].length; j++) { if (i != board.length - 1) { if (board[i][j] < board[i + 1][j]) { ...
8
public Bitmap flipX() { int[] temp = new int[pixels.length]; for(int i = 0; i < width; i++) for(int j = 0; j < height; j++) temp[i + j * width] = pixels[(width - i - 1) + j * width]; pixels = temp; return this; }
2
private List<Layer> makeLayersHierarchy(List<Layer> layers) { LinkedList<LinkedList<Layer>> layersStack = new LinkedList<LinkedList<Layer>>(); ArrayList<Layer> rootLayers = new ArrayList<Layer>(); for (Layer layer : layers) { switch (layer.getType()) { case HIDDE...
7
public void setApplicant(Application app, boolean is) { if (is) { for (Application a : applications) if (a.matches(app)) return ; applications.add(app) ; } else for (Application a : applications) if (a.matches(app)) { applications.remove(a) ; } }
5
public boolean getStartAtTop() { return this.startAtTop; }
0
void dumpPageMap(final int count, final long from, final long timestamp, final int recordSize) throws PersistitIOException { if (count * PM.ENTRY_SIZE + PM.OVERHEAD != recordSize) { throw new CorruptJournalException("Invalid record size " + recordSize + " for PM record at " ...
9
@Before public void setUp() { createInjector( new EventBusModule() { @Override protected void configure() { bindBus( "eventbus.test" ).toAnyBoundClass(); } } ).injectMembers( this ); }
0
@Override public AbstractTableModel getTableModel() { return new AbstractTableModel() { @Override public String getColumnName(int col) { return columnsNames[col]; } @Override public int getRowCount() { return docume...
8
public Direction isAnExit(Room room){ if(exits.containsValue(room)){ for(Entry<Direction, Room> entry : exits.entrySet()){ if(entry.getValue().equals(room)) return entry.getKey(); } } return null; }
3
public int getValue(){ int value = 0, count = getCards_count(); boolean isAce = false; cards cards; int cards_value; for(int i = 0; i<count; i++){ cards = getCards(i); cards_value = cards.getValue(); if(cards_value > 10){ cards_value = 10;} if(cards_va...
5
private void addQuantumDynamicsMenuItems() { if (model.isSubatomicEnabled()) { if (lightSourceMenuItem == null) { lightSourceMenuItem = new JMenuItem(model.getActions().get("Edit the light source")); String s = getInternationalText("LightSource"); lightSourceMenuItem.setText((s != null ? s : "Ligh...
7