text
stringlengths
14
410k
label
int32
0
9
public static void unpackConfig(Archive container) { Stream buffer = new Stream(container.get("spotanim.dat")); int len = buffer.getUnsignedShort(); if (SpotAnimation.spotAnimationCache == null) { SpotAnimation.spotAnimationCache = new SpotAnimation[len]; } for (int i = 0; i < len; i++) { if (SpotAnimat...
3
private boolean checkDirection(GameBoard gb, int player, Coordinates coord, int x, int y) { try { Coordinates newCoord = new Coordinates(coord.getRow() + x, coord.getCol() + y); if (gb.getOccupation(newCoord) == EMPTY) { return false; } if (gb.getO...
5
@Override public void draw(Graphics g, Display d, int bottomPixelX, int bottomPixelY, boolean drawHealth){ double percentMoved = count * 0.25; // Tile coordinates of The Dude (x,y) double x, y; if(attacking == null) { x = this.oldX + (this.x - this.oldX) * percentMoved; y = this.oldY + (this.y - thi...
7
public void addPosition(Position position) { if (position == null) throw new IllegalArgumentException("Position can't be null"); if (position.xCoordinate < 0 || position.yCoordinate < 0) throw new IllegalArgumentException("The given position is invalid!"); otherPositions.add(position); if (otherPosi...
4
public Teleport(int x, int y, boolean tagurpidi) throws SlickException { this.x = x; this.y = y; this.tagurpidi = tagurpidi; pildid = new Image[11]; if (!tagurpidi) { for (int i = 0; i < pildid.length; i++) { pildid[i] = new Image("disintegrate0" + i + ".png"); } animation = new Animation(pildid,...
3
public void setUnit(Unit u) { unit = u; }
0
@Override public V get(K key) { int elementIndex = findKeyIndex(key); if (elementIndex == -1) { return null; } return mapArray[elementIndex].getValue(); }
1
@Override public Bus driverBus() { return new BmwBus(); }
0
public static Color textHighlight(int type){ //if the message is encrypted, compressed or both, add different backgrounds switch(type){ case 1: //compress return new Color(206, 255, 185); case 2: //crypt...
3
private JButton getJButton0() { if (jButton0 == null) { jButton0 = new JButton(); jButton0.setText("ok"); jButton0.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { jButton0MouseMouseClicked(event); } }); } return jButton0; }
1
private String checkExists(String downloadName) { File fx = new File(opt.getDownloadPath()+File.separator+downloadName+".mp3"); if (fx.exists()){ if (ifExist.equalsIgnoreCase("Overwrite")){ fx.delete(); return downloadName; }else if (ifExist.equalsIgnoreCase("Skip")){ return null; }else{ ...
7
private void expand1(byte[] src, byte[] dst) { for(int i=1,n=dst.length ; i<n ; i+=8) { int val = src[1 + (i >> 3)] & 255; switch(n-i) { default: dst[i+7] = (byte)((val ) & 1); case 7: dst[i+6] = (byte)((val >> 1) & 1); case 6: dst[i+...
8
public void stop() throws BITalinoException { try { socket.write(0); Thread.sleep(SLEEP); close(); } catch (Exception e) { throw new BITalinoException(BITalinoErrorTypes.BT_DEVICE_NOT_CONNECTED); } }
1
public static boolean isNum(String str){ return str.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$"); }
0
public static double newtonRaphson(double x0, double epsilon, int cantIter, Funcion fun) throws Exception { double x1; int iter = 0; x1 = x0 - (fun.f(x0) / fun.fd(x0)); while ((iter < cantIter) && (Math.abs(x1 - x0) >= epsilon)) { x0 = x1; x1 = x0 - (fun.f(x0) / ...
4
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
public List < AState > search() { if(!this.calculated) { this.stateOpened = 0; List < AState > opened = new LinkedList < AState >(); AState current = this.map.getStartState(); long start = System.currentTimeMillis(); while(!current.isGoal()) { current.setClosed(true); List < A...
8
public void makeVisible(Component com) { if(TargetSet) { return; } int ht = com.getHeight(), vy = com.y; int WindowTransition = parent.TranselateY; int ActualPosition = WindowTransition + vy; if(ActualPosition + ht > y+height) { ...
7
private final String getChunk(String s, int slength, int marker) { StringBuilder chunk = new StringBuilder(); char c = s.charAt(marker); chunk.append(c); marker++; if (isDigit(c)) { while (marker < slength) { c = s.charAt(marker...
5
@Override public AbstractActionPanel getAction() { if ( owner.getSelected() ) { return new ActionPanelWorker(); } else { return new ActionPanelBlank(); } }
1
private void updateVillainMissiles3() { ArrayList<VillainMissile3> deadVillainMissiles = new ArrayList<VillainMissile3>(); for(int i = 0; i < villainMissiles3.size(); i++) { VillainMissile3 v = villainMissiles3.get(i); v.move(); if(CollisionDetector.isColliding(v, sc)) { if(!sc.isShieldActive()) ...
5
public ArrondissementVille find(int id) { ArrondissementVille arrondissement = new ArrondissementVille(); try { ResultSet result = this.connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY).executeQuery("SELECT * FROM eleve WHERE elv_id = " + id); ...
2
public static int tileColour(int[] bands, Raster r) { final int[] co = new int[] {6,4,0,1,2,3,5,6}; int[] pCount = { 0, 0, 0, 0, 0, 0, 0 }; final int w = r.getWidth(); final int h = r.getHeight(); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { int[] hsv = argbToHSV(r, x, y); // First c...
7
private void doRepeat() { // Repeat the previous 1, 4, 8, 16 beats switch (REPEAT_STATE) { case BEAT: if (OUTPUT_BEATS.size() >= 1) { LAST_BEAT = OUTPUT_BEATS.get(OUTPUT_BEATS.size() - 1); OUTPUT_BEATS.add(LAST_BEAT); DUR...
8
private void replicateCards(Card remoteCard, String typeofCard) { if (typeofCard.equals("remotePlayer")) { remoteCards.newCard(remoteCard); pcardPanel.removeAll(); pcardPanel.add(playerlabel); Iterator<Card> pscan = (player.inHand).iterator(); while (pscan.hasNext()) { pcardPanel.add(new JLabel(p...
9
public void testToStandardMinutes() { Period test = new Period(0, 0, 0, 0, 0, 6, 7, 8); assertEquals(6, test.toStandardMinutes().getMinutes()); test = new Period(0, 0, 0, 0, 1, 6, 0, 0); assertEquals(66, test.toStandardMinutes().getMinutes()); test = new Period(...
1
public void startElement(String name) { stack.addFirst(name); if (name.equals("module")) { currentModule = org.analyse.main.Main.getModule(id.toUpperCase()); asiModuleHandler = ((FilterASIModule) (currentModule .getFiltre("ASI"))).getASIHandler(); ...
2
private Location findFood(Location location) { Field field = getField(); List<Location> adjacent = closestPrey(field.adjacentLocations(getLocation(), 2)); Iterator<Location> it = adjacent.iterator(); while(it.hasNext()) { Location where = it.next(); Object ani...
5
@Override /** * Returns a String representation of the Item. */ public String toString() { StringBuilder returnString = new StringBuilder(); // Append quantity if it is there. if (this.quantity > 0) { returnString.append(this.quantity + " "); } // If has name, use it. if (!this...
9
public void replaceBreakContinue(BreakableBlock block) { java.util.Stack todo = new java.util.Stack(); todo.push(block); while (!todo.isEmpty()) { StructuredBlock[] subs = ((StructuredBlock) todo.pop()) .getSubBlocks(); for (int i = 0; i < subs.length; i++) { if (subs[i] instanceof BreakBlock) { ...
4
private Boolean validParameterType(Class<?> type) { if(type == int.class) { return true; } else if(type == float.class) { return true; } else if(type == String.class) { return true; } else if(type == String[].class) { return true; } return false; }
5
@Basic @Column(name = "FUN_ID") public Integer getFunId() { return funId; }
0
public synchronized List<Turnstile> init() { if (turnstiles == null) { turnstiles = new MyArrayList<Turnstile>(NUM_TURNSTILES); for (int i = 0; i < NUM_TURNSTILES; ++i) { Turnstile turnstile = new Turnstile(); turnstile.connect(this); turns...
2
Message receiveMessageFromSocket (FragmentProcessor fp, ByteArrayOutputStream baos) throws IOException { baos.reset (); int currentOpcode = 0; do { fp.readHeader (); if (!fp.mask) throw new IOException ("unmasked fragment"); if (currentOpcode == 0) { if (fp.opcode != 0) cur...
9
public int getNumMappedReads(String path){ int numReads = 0; try { TextFile filtSam; if (alnFnamePattern.isEmpty()) filtSam = new TextFile(path.replace(fnamePattern, "accepted_hits.filtered.sam"), false); else filtSam = new TextFile(pat...
4
public List<List<Integer>> subsets(int[] s){ Arrays.sort(s); int num = s.length ; int total = (int)Math.pow(2,num); List<List<Integer>> result= new ArrayList<List<Integer>>(); for(int i=0;i < total;i++) result.add(new ArrayList<Integer>()); for(int i =0;i < n...
4
public String nextString() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } String result; if (p == PEEKED_UNQUOTED) { result = nextUnquotedValue(); } else if (p == PEEKED_SINGLE_QUOTED) { result = nextQuotedValue('\''); } else if (p == PEEKED_DO...
7
@Test public void gameIsOverWhenNoMorePlayers() { rp.resetGame(); boolean b1 = !rp.isGameOver(); rp.getEntities().addEntity(new TestRat()); rp.getScore().resetScore(rp.getPlayers()); boolean b2 = !rp.isGameOver(); for (int i = 0; i < Const.initialLifeAmount; i++) ...
5
private void harvestColor(){ //OPCIONAL CREAR CLASE DE SOURCE TAMBIEN switch(env.getMapObjectInPosition(positionX, positionY)){ case Environment.REDSOURCE: if(currentColor == COLORRED){ if(capacity<amountToHarvest){ colorAmount = ca...
9
private ValueMatcher buildValueMatcher(String str, ValueParser parser) throws Exception { if (str.length() == 1 && str.equals("*")) { return new AlwaysTrueValueMatcher(); } ArrayList values = new ArrayList(); StringTokenizer st = new StringTokenizer(str, ","); while (st.hasMoreTokens()) { String elem...
8
private void registerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registerButtonActionPerformed String password = new String(passwordField.getPassword()); String confirmPassword = new String(confirmPasswordField.getPassword()); if(password.equals(confirmPassword)){ ...
3
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; StudentContact other = (StudentContact) obj; if (internalID == null) { if (other.internalID != null) return false; } else if (!internalI...
6
private void doSignCommand(CommandSender sender, Command cmd, String label, String[] args) { if(sender instanceof Player) { ItemStack item = ((Player) sender).getItemInHand(); BookMeta meta = null; Matcher titleMatcher = null; if(item.getType() == Material.WRITTEN_BOOK) { meta = (BookMeta) item.getIte...
7
public void handlePark(Park park) { park.setManaged(true); this.parkList.add(park); }
0
public static String getByteString( byte[] bt, boolean pad ) { if( bt.length == 0 ) { return "null"; } StringBuffer ret = new StringBuffer(); for( int x = 0; x < bt.length; x++ ) { if( ((x % 8) == 0) && (x > 0) ) { ret.append( "\r\n" ); } //String bstr = Integer.toOctalString(bt[x]); // ...
6
public boolean replaceSubBlock(StructuredBlock oldBlock, StructuredBlock newBlock) { if (subBlock == oldBlock) subBlock = newBlock; else return false; return true; }
1
public List<Command> getCommands() { List<Command> list = new ArrayList<>(); Match commands = rootElement.xpath("commands").children(); for ( Match command : commands.each() ) { String name = command.attr("name"); String content = command.text(); list.add( new...
1
public void formGraph() { a = new ArrayList<>(); for (int i = 0; i < size; i++) { a.add(new HashSet<Integer>()); for (int j = 0; j < size; j++) { if (i != j && matr[i][j] == 1) { a.get(i).add(j); } } ...
4
@Override public void finalize() throws IOException { fileWriter.close(); }
0
@Override public void start() { run = true; if(firstStart) { firstStart = false; super.start(); } }
1
public void saveConfig(String configString, File file) { String configuration = this.prepareConfigString(configString); try { BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.write(configuration); writer.flush(); writer.close(); } catch (IOException e){e.printStackTrace...
1
public AlgorythmFile(String name, String type, File file){ algorythmName = name; algorythmType = type; algorythmFile = file; }
0
public boolean registerCommand(ChunkyCommand command) throws ChunkyUnregisteredException { if (command.getParent() == null) { if (!registeredCommands.containsKey(command.getFullName())) { registeredCommands.put(command.getFullName(), command); registerSuperAliases(com...
5
public static boolean isValidSolution(Team heroes){ if(useBudget && heroes.getCost() > budget){ return false; } if(heroes.getDurability() < Helper.villains.getDurability()) return false; if(heroes.getEnergy() < Helper.villains.getEnergy()) return false; if(heroes.getFightingSkills() < Helper.villains...
8
@Override public void handle(IHttpRequest httpRequest,IHttpResponse httpResponse) throws IOException { try{ String command = httpRequest.getParametro("command"); String[] comandi =command.split("_"); for (int i = 0; i < comandi.length; i++) { String comando = comandi[i]; if(!comando.isEmpty()){ ...
9
public byte[] getP() { return p; }
0
private void moveRow(Board b, int caller) { int posNr = 0; Position tmp = null; int i, j; int foundPos = -1; i = 1; j = 1; while (j <= b.getHeight()) { i = 1; while (i + 1 <= b.getWidth()) { if (b.isFree(i, j) && b.isFree(i + 1, j)) { b.set(i, j); b.set(i + 1, j); foundPos = pos.s...
9
public void lancerMatchs() throws IOException, ClassNotFoundException, InterruptedException { ArrayList<Partie> match; match = new ArrayList<Partie>(); for(int i=0;i<IA.size();i++) { for(int j=0;j<IA.size();j++) { if(i!=j) { ...
6
private byte[] writeDataIndex(DataIndex dataIndex) throws IOException, XmlException { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); getPersister().write(dataIndex, outputStream, "UTF-8"); return outputStream.toByteArray(); } catch (Ex...
1
private int getLengthHelper(Node<T> node) { if (node == null) { return 0; } else { return 1 + getLengthHelper(node.getTail()); } }
1
public void setLivePanel() { if (livePanel != null) { livePanel.set(mp3list.getSong()); } }
1
public List<ClusterType> getCluster() { if (cluster == null) { cluster = new ArrayList<ClusterType>(); } return this.cluster; }
1
public void save(BufferedWriter out, Object object) throws IOException { IConfig config = (IConfig) object; try { beginConfigTag(out); for (Method method : config.getClass().getMethods()) { if (method.getDeclaringClass().equals(Config.class)) { writeStartTag(method.getName(), out); o...
4
public void paint(Graphics g) { BufferedImage image = new BufferedImage(SCREEN_W, SCREEN_H, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = image.createGraphics(); super.paint(g2d); if(loading) return; synchronized(this){ int xOffset = getOffset(player.getColumn(), 13,COLUMNS); int yOffset = ge...
9
public void print(int n) { if (n > 0) { for (int i = 0;i < n; i++) System.out.print(" "); } System.out.print(intVal + " "); }
2
public void setLatestPreview(Object preview) { if ((this.previewedThread != null) && this.previewedThread.isComplete()) { this.previewLabel.setText("Final result"); Object finalResult = this.previewedThread.getFinalResult(); this.textViewerPanel.setText(finalResult != null ? ...
7
public static void DoTurn(PlanetWars pw) { // (1) Find my strongest planet. Planet source = null; double sourceScore = Double.MIN_VALUE; for (Planet myPlanet : pw.MyPlanets()) { // skip planets with only one ship if (myPlanet.NumShips() <= 1) continue; //This score is one way of defining how 'g...
7
private boolean readRomanPageBackwards() { ArrayList<Character> saved = new ArrayList<Character>(); char token = prevChar(); // if ( token=='p') // System.out.println("p"); int len = 0; // saved leading newline chars while ( token=='\n'||token=='\r' ) ...
8
public ScreenArea getMenuBounds() { int color = 6116423; Point mouse = Mouse.getMousePosition(); int x = mouse.x; int y = mouse.y; int lastX = 0; int lastY = 0; int lastXX = 0; int lastYY = 0; for(int i = 0; i < 200; i++) { if(ImageTool.isInTolerance(color, ImageTool.getPixel(x, y), 0)) { lastX...
8
@Override public void processInput(ByteBuffer buffer) throws IOException { while (buffer.hasRemaining()) { if (parse(buffer.get())) { processRequest(); reset(); } } }
2
private static boolean comparerTabProduitsCode (Produit[] tab, int[] tabTest, int n) { boolean pareil = true; int i = 0; try { if (tab == null && tabTest == null) { pareil = true; } else if (tab != null && tabTest != null && tabTest.le...
9
@Override public boolean equals(Object object) { if(!(object instanceof Edge<?>)) { return false; } Edge<?> edge = (Edge<?>) object; return from.equals(edge.from) && to.equals(edge.to); }
5
private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // The plugin's description file containg all of the plugin data such as name, version, author, etc PluginDescriptionFile description = plugin.getDescription(); // Construct the post data String data = encode("g...
8
public IFilter buildFilterChain() { List<Class<? extends IFilter>> list = getConfiguredFilters(); ListIterator<Class<? extends IFilter>> listIterator = list.listIterator(list.size()); IFilter innerFilter = null; while (listIterator.hasPrevious()) { Class<? extends IFilter> filterClass = listIterat...
8
public Vector AStarSearch(Agent agent) { PQ openQ = new PQ(); // initialize a start node Node startNode = new Node(); startNode.location = startLoc; startNode.costFromStart = 0; startNode.costToGoal = pathCostEstimate(startLoc, goalLoc, agent); startNode.totalCo...
9
public Produtos buscaProdutos(int idProduto){ produtos = this.getProdutos(); this.getConectaBanco(); try { if (this.getConn() != null || !this.getConn().isClosed()) { this.getConn().setAutoCommit(false); this.setStmt(this.getBuscaProdutos()); this.getStmt().setInt(1, idProduto...
6
public static void cantPass(){ System.out.println("パスできません!おける場所があります。"); }
0
public Program() { days = new Day[7]; for (int i = 0; i < 7; i++) { days[i] = new Day(); } }
1
private boolean method66(int i, int j, int k) { int i1 = i >> 14 & 0x7fff; int j1 = worldController.method304(plane, k, j, i); if(j1 == -1) return false; int k1 = j1 & 0x1f; int l1 = j1 >> 6 & 3; if(k1 == 10 || k1 == 11 || k1 == 22) { ObjectDef class46 = ObjectDef.forID(i1); int i2; int j2; ...
7
@Override public boolean equals(Object otherObj) { if(this == otherObj) return true; if(otherObj == null) return false; if(getClass() != otherObj.getClass()) return false; ExpressionItem other = (ExpressionItem)otherObj; String val = value.toString(); retur...
4
public UpdateListener(String message) { this.message = message; }
0
@Override public void run() { try { nouvelleConnexion(); } catch (IOException e1) { System.err.println("Erreur E/S sur l'utilisation des flux lors d'une nouvelle connexion" + e1); } while (true) { try { byte code = fluxEntree.readByte(); if (code == DESACTIVE_BOUTON_PARAMETRE) { ...
7
public void setTime(){ if(morningTime){setInterfaceWalkable(65535);} if(afternoonTime){setInterfaceWalkable(12416);} if(eveningTime){setInterfaceWalkable(12418);} if(nightTime){setInterfaceWalkable(12414);}}
4
public void create(Date bookingDate, Date checkinDate, Date checkoutDate, String status) { this.setBookingDate(bookingDate); this.setCheckinDate(checkinDate); this.setCheckoutDate(checkoutDate); this.setStatus(status); }
0
public AbsenceValidator(String msg) { if (msg != null && !msg.isEmpty()) this.msg = msg; }
2
private void writeHref(JspWriter out) throws IOException { if (href != null && !href.isEmpty()) { out.write("href='" + href + "' "); } out.write(">"); }
2
public static boolean checkArticle(String article){ if(!checkSemicolon(article)){ System.out.println("semicolon problem"); return false; } String[] fields = article.split(";"); if(fields.length!=4){ System.out.println("Format not accept"); return false; } if(fields[0]==null||fields[0].isEmpt...
9
protected Object[] handleRemove(Object[] cells) { Set removedRoots = new HashSet(); if (cells != null && cells.length > 0) { Set rootsSet = new HashSet(roots); for (int i = 0; i < cells.length; i++){ if (getParent(cells[i]) == null && rootsSet.contains(cells[i])) { removedRoots.add(cells[i]); } ...
9
public static double scaleTMP(final int port, final int raw, boolean celsius){ double result = (((raw/getResolution(port))*VCC) - 0.5)*100; if (!celsius) // Convert to fahrenheit result = result*((double)9/5) + 32; return new BigDecimal(result).setScale(2, RoundingMode....
1
public static long getCastleMoves(int player, State4 s){ if(!s.kingMoved[player] && (!s.rookMoved[player][0] || !s.rookMoved[player][1])){ long moves = 0; final long agg = s.pieces[0]|s.pieces[1]; if(!s.rookMoved[player][0] && (Masks.castleBlockedMask[player][0] & agg) == 0 && !maskIsAttacked(Masks.cast...
9
public void checkCollisions() { for(int i = 0;i<world.entities.size();i++) { Entity e = world.entities.get(i); if(e != this) if(e != null && !alreadyCollisionsChecked.contains(e)) { if(e.clipAABB().collide(clipAABB())) { e.onCollide(this); this.onCollide(e); } e.alreadyCollisi...
5
public String authenticate(String supplied) { if(!supplied.equals(password)) { return "Protection proxy: No access"; } else { subject = new Subject(); return "Protection Proxy: Authenticated"; } }
1
private static void putClasses(final List<File> classes, final File directory) { for (final File file : directory.listFiles()) { if (file.isDirectory()) { putClasses(classes, file); } else if (file.toString().endsWith(".class")) { classes.add(file); ...
3
@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, LogicException { String subcategory = request.getParameter(ParameterName.SUBCATEGORY); String category = request.getParameter(ParameterName.CATEGORY); PrintWriter out; t...
2
@Override public void paint(Graphics g, Component game) { if (gameState == GameState.RUNNING) { // draw background g.drawImage(background, bg1.getBgX(), bg1.getBgY(), game); g.drawImage(background, bg2.getBgX(), bg2.getBgY(), game); // draw tiles paintTiles(g, game); // paint projectiles Arr...
6
public ConcreteColleagueA(String name) { super(name); }
0
@Override public synchronized void beginW(Actor arg0) throws InterruptedException, DeadLockException { /*Si redacteur ou lecture ou nb minimal de lecture non atteint */ while(writers>0 || readers>0 || N_R>0){ wait(); } writers++; System.out.println("(REDACTEUR) L'Acteur n°"+arg0.ident()+" accède ...
3
private void findCDSSplitLocations(){ //There are no split locations if there is only one/zero CDS if(CDS.size() < 2){ return; } //Forward strand //The CDS are in nucleic acid lengths, but the code needs the lengths in amino acids, so each length must be divided by 3. //Get the first CDS split locati...
8
private boolean checkWeight(Item item){ if (item == null){ int weight = 0; for (Weapon weapon : weapons) { weight += weapon.getWeight(); } for (NormalItem object : inventory) { weight += object.getWeight(); } ...
5
protected String getProperty(String key) { return properties.get(key); }
0