text
stringlengths
14
410k
label
int32
0
9
public boolean isFlying() { return isAlive(); }
0
public int[] find_ant(int id, Colour col){ int p[] = new int[2]; if(ant_is_alive(id, col)){ boolean found = false; int x = 0; int y = 0; while(x < world.getRows() && !found){ while(y < world.getColumns() && !found){ p[0] = x; p[1] = y; Cell c = world.getCell(p[0],p[1]); if(c.isAn...
8
public CachedLocations(){ List<EndPoint> north = new ArrayList<>(); List<EndPoint> south = new ArrayList<>(); List<EndPoint> east = new ArrayList<>(); List<EndPoint> west = new ArrayList<>(); for( EndPoint endPoint : endPoints ){ switch( calcPosition( endPoint )){ case WEST: west.add( ...
5
public void handle(HttpExchange exchange) throws IOException { String requestMethod = exchange.getRequestMethod(); if (!requestMethod.equalsIgnoreCase("GET")) { // GET requests only. return; } // Print the user request header. Headers requestHeaders = exchange.getRequestHeaders(); _logger.debug("Incomin...
8
public static String getHttp(String url, String body) //getHTTP method called in Main() for Coinbase connections throws InvalidKeyException, NoSuchAlgorithmException, // Error handling ClientProtocolException, IOException { String nonce = String.valueOf(System.currentTimeMillis...
4
@Override public void actionPerformed(ActionEvent event) { if(event.getSource() == this.environments) { this.methods.removeAllItems(); Environment env = (Environment) this.environments.getSelectedItem(); if(env != null) { for(ServiceMethod method : env.getMethods()) { if(NewQueryDialog.operationPan...
7
private Class getClassImpl(String name) throws UtilEvalError { Class c = null; // Check the cache if (classCache != null) { c = classCache.get(name); if (c != null) return c; } // Unqualified (simple, non-compound) name boolean unqualifiedName = !Name.isCompound(name); // Unqualified name ch...
8
private static void extractFromZip( String szZipFilePath, String szExtractPath, String szName, ZipFile zf, ZipEntry ze) { if(ze.isDirectory()) return; String szDstName = slash2sep(szName); String szEntryDir; if(szDstName.lastIndexOf(File.separator) != -1) { ...
6
public static void main(String[] args) throws Exception { HashMap<String, FastaSequence> fastaMap = FastaSequence.getFirstTokenSequenceMap(ConfigReader.getChinaDir() + File.separator + "ncbi" + File.separator + "ncib16.fasta"); BufferedWriter writer= new BufferedWriter(new FileWriter(new File(Config...
8
public void setIdConnection(Long idConnection) { this.idConnection = idConnection; }
0
@Override public TypeOfValue peek() throws EmptyStackException { if (null == this.firstNode) { throw new EmptyStackException(); } return (TypeOfValue) firstNode.getObject(); }
1
public Enumeration<?> getKeys() { return properties.propertyNames(); }
1
private void initCommandBtnFontMenu(Color bg) { this.commandBtnPanel = new JPanel(); this.commandBtnPanel.setBackground(bg); this.commandBtnPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT)); String initFontTmp = this.skin.getCommandButtonFont(); int initFontSizeTmp = t...
7
public void execute() { receiver.turnOn(); }
0
@EventHandler public void onInventoryOpenEvent(InventoryOpenEvent e){ if (e.getInventory().getHolder() instanceof Chest || e.getInventory().getHolder() instanceof DoubleChest){ System.out.println("Opened chest!"); } }
2
*/ private void setSystemObjectKeeping(SystemObject systemObject) { // die Liste der in Bearbeitung befindlichen Objekte wird durchgearbeitet for(ConfigurationArea configurationArea : _editingObjects.keySet()) { for(CheckedObject checkedObject : _editingObjects.get(configurationArea)) { if(checkedObject.get...
9
@Override public int hashCode() { return (int) this.user.getId(); }
0
public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels) { buf.setLength(0); for (int i = 0; i < labels.length; ++i) { declareLabel(labels[i]); } declareLabel(dflt); buf.append("mv.visitLookupSwitchInsn("); appendLabel(dflt); buf.append(", new int[] {"); for (in...
5
public int retrieveScore() { FileHandle file = Gdx.files.local(filePath);//internal does not work String stringa = file.readString(); int score = -1; if(stringa!=null||stringa!=""){ score=Integer.parseInt(stringa); } return score; }
2
public static byte[] gzip(String input) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = null; try { gzos = new GZIPOutputStream(baos); gzos.write(input.getBytes("UTF-8")); } catch (IOException e) { e.printStackTrace...
3
public String getParagraph() { return paragraph; }
0
private XinWen initXinWen(ResultSet rs) throws SQLException { XinWen xinWen = new XinWen(); xinWen.setId(rs.getString("ID") == null ? "" : rs.getString("ID")); xinWen.setTitle(rs.getString("TITLE") == null ? "" : rs.getString("TITLE")); xinWen.setEntitle(rs.getString("ENTITLE") == null ?...
8
private int getPlacement (final String checkSkill) { for (int i = 0; i < SKILLS.length; i++) { if (SKILLS[i].equalsIgnoreCase(checkSkill)) return i; } return -1; }
2
public String patchToString(Path path, Patch patch){ String s = path.toString()+" differs:\n"; for(Delta d : patch.getDeltas()){ s+= StringUtils.trim(d.toString())+"\n"; } return s; }
1
@Override public void run() { //obtiene el pescator plyr = plugin.getServer().getPlayer(plugin.getConfig().getString("thePescator")); final Calendar cal = new GregorianCalendar(); final int segActual = cal.get(Calendar.SECOND); timeDone = plugin.getConfig().getInt("users.TimePescado." + plyr.getDisplayNam...
9
public Map<String, String> handleProbe(String... keys) { Map<String, String> map=new TreeMap<>(); for(String key: keys) { if(key.startsWith("jmx")) { handleJmx(map, key); continue; } if(key.startsWith("reset-stats")) { r...
7
private static IStrategy getUserFixedStrategy(BufferedReader br) { System.out.println("Insert the fix value"); while (true) { try { int value = Integer.parseInt(br.readLine()); return new FixedStrategy(value); } catch (Exception e) { ...
2
public void update() { while (!m_shell.isDisposed()) { if (!m_display.readAndDispatch()) { m_display.sleep(); } for (int i = 0; i < m_clients.size(); ++i) { if (!m_shell.isDisposed()) clientLogic(m_clients.get(i)); } if(!m_shell.isDisposed()) serverLogic(m_server); } m_display.di...
5
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } Result n = (Result) o; return word.equals(n.word); }
3
@Override public int analyse(LexicalAnalyser analyser, int beginIndex) throws AnalyseException { String content = analyser.getSentence(); if (!WordTable.isDigit(content.charAt(beginIndex))) { throw new AnalyseException(String.format("Error Undefined String [%c] ", content.charAt(beginIndex))); } for (int in...
5
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Equation other = (Equation) obj; if (a == null) { if (other.a != null) return false; } else if (!a.equals(other.a)) return false; i...
9
public String kNearestNeighbour(Datum point, int k) { HashMap<Double,String> vals = new HashMap<Double,String>(); ArrayList<Double> dists = new ArrayList<Double>(); double dist; for (Datum d : data) { dist = point.getDistSquared(d); vals.put(dist, d.name); dists.add(dist); } Double[] sortedD...
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; SimpleAuthenticationCredentialProvider other = (SimpleAuthenticationCredentialProvider) obj; if (sharedSecret == null) { if (other.sharedSecre...
9
@Test(expected = Exception.class) public void NullName() throws Exception { LoginCheck logCh = new LoginCheck(); name = ""; if (kesh.containsKey(name)) { kesh.get(name); } else { boolean result = logCh.validate(name); kesh.put(name, result); ...
1
@Override public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd, String[] args) { if(args.length > 0) return false; if(!Commands.isPlayer(sender)) return false; Player p = (Player) sender; Messenger.tell(p, Msg.GLOBAL_CHAT_ENTERED); PlayerChat.plugin.CustomChat.remove(p.getNa...
2
public void normalize() { if (x != 0.0 || y != 0.0 || z != 0.0) { double modulo = modulo(); x /= modulo; y /= modulo; z /= modulo; } }
3
@Override public Piece getPieceAt(Location location) { Piece result = null; if (location.equals(redMarshalLocation) && gameStarted && !gameOver) { result = redMarshal; } else if (location.equals(redFlagLocation)) { result = redFlag; } else if (location.equals(blueFlagLocation)) { result = gameOver ? ...
7
public boolean myTurn(int player) { if (player == currentPlayer) return true; else return false; }
1
private boolean isBinary(final ClientServices client, final String filename, final Map<StringPattern, KeywordSubstitutionOptions> directoryLevelWrappers) throws CommandException { KeywordSubstitutionOptions keywordSubstitutionOptions = getKeywordSubst(); if (keyw...
9
public String getAlgorythmName(){ return algorythmName; }
0
public boolean benutzerLoeschen(String benutzername) { Benutzer benutzer = dbZugriff.getBenutzervonBenutzername(benutzername); if(benutzer != null){ try{ benutzer.loeschen(); return true; } catch(SQLException e){ System.out.println(e); } } return false; }
2
protected <T> List<T> readFromListElement(String tagName, XMLStreamReader in, Class<T> type) throws XMLStreamException { if (!in.getLocalName().equals(tagName)) { throw new XMLStreamException(tagName + " expected, not:" + in.getLocalName()); } final int length = Integer.parse...
8
protected void createStatment() throws SQLException { if ((stmt == null || stmt.isClosed()) && (conn != null && !conn.isClosed())) { stmt = conn.createStatement(); } }
4
public void abrirFactura(String path){ try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(new File(path)); } } catch (IOException ioe) { ioe.printStackTrace(); } }
2
public void run(){ //Try to establish write connection with client. try{ output = new PrintWriter(userSocket.getOutputStream(), true); }catch(IOException e){ System.out.println("Error writing to client: " + user.getName() + "(" + user.getIP() + ")."); e.printStackTrace(); } //Try to establish r...
5
private static Node findPredecessor(Node r, Node t) { if (t.left != null) { Node p = t.left; while (p.right != null) { p = p.right; } return p; } else { Node p = r; Node prev = null; while (p != t) { if (p == null) return null; if (p.v < t.v) { prev = p; p = p.right; ...
6
public List<LngLatAlt> getExteriorRing() { assertExteriorRing(); return coordinates.get(0); }
0
public Compass getOctant() { if (isOrigin()) return Compass.CENTER; double angle = rep.arg(); if (angle < OCT1) return Compass.W; if (angle < OCT2) return Compass.SW; if (angle < OCT3) return Compass.S; if (angle < OCT4) return Compass.SE; if (angle < OCT5) return...
9
public List<BranchLeader> findBranchLeadersByEventBranchId(final Long eventBranchId) { return new ArrayList<BranchLeader>(); }
0
public Event getNextEvent(){ Event a,b; a=this.listCustAr.peek(); b=this.listOrderArrival.peek(); if (a!=null && b!=null) { if (b.getTime()>a.getTime()) return this.listCustAr.remove(); else return this.listOrderArrival.remove(); } else if (b!=null...
5
public static void main(String args[]) { String s = JOptionPane .showInputDialog("Vilken text vill du ska rulla?"); CharController c = new CharController(s); Array7x7[] characterArray = c.getCharacterArray(); RollingTextViewer theWindow = new RollingTextViewer(); Array7x7[] theBlocks = new Array7x7[4];...
5
public String findDataFile(File[] files) { for (File file : files) { String s = file.getAbsolutePath(); if (s.endsWith(".dat")) { if (s.contains("file_cache")) { return s; } } } return null; }
3
private JLabel getJLabel3() { if (jLabel3 == null) { jLabel3 = new JLabel(); jLabel3.setText("CsvName:"); } return jLabel3; }
1
public boolean removeProtocol(String protocolName) { for (int i = 0, limit = protocols.size(); i < limit; i++) { FileProtocol protocol = (FileProtocol) protocols.get(i); if (protocol.getName().equals(protocolName)) { protocols.remove(i); // Also remove it from the list of formats stored in the pref...
2
public Sign(float x, float y) { super(""); this.x = x; this.y = y; this.width = 12; this.height = 18; try { texture = TextureLoader.getTexture("PNG", this.getClass() .getResourceAsStream("sign.png")); System.out.println(texture.getImageWidth()); } catch (IOException e) { e.printStackTrace();...
1
public static String getModelId(Class model) { if (model.isAssignableFrom(Model.class)) throw new IllegalArgumentException(EXC_NOTAMODEL); Method[] all = model.getDeclaredMethods(); String id = ""; boolean found = false; for (Method m : all) /*TODO: make conventions ind. */ if (m.isAnnotati...
6
public int maxProfit(int[] prices) { if(prices == null || prices.length <= 1) return 0; int L = prices.length; int [] maxLeft = new int [L+1]; int [] maxRight = new int [L+1]; int curMin = prices[0]; int maxL = -1; for(int i = 0; i < L; ++i){ if(prices[i] - curMin > maxL){ maxL = prices[i] - curMi...
9
public void run() { RevEnglishCustomerBean bean = (RevEnglishCustomerBean) context.getBean("revEnglishCustomerBean"); bean.writeTemplate(template); LinkedList<String> templates = new LinkedList<String>(); Integer currentPrice = Integer.MAX_VALUE; Date start = new Date(); Template match = bean.waitF...
7
public static boolean checkCellInDirection(Board board, int x, int y, DirectionX dirx, DirectionY diry) { boolean finished = false; int count = 0; Counter turn = board.getPosition(x, y); //Iterate check if the cell is connected while((count <= Game.WINCON) && !finished && (x >= Board.MINWIDTH) && (y >= Bo...
9
@Override public boolean isCommonSubexpression(Instruction i) { if(i instanceof UnaryInstruction) { UnaryInstruction u = (UnaryInstruction)i; return this.getOpcode() == u.getOpcode() && this.argument.equals(u.argument); } return false; }
2
@Override public OreLookup lookup(String player, Integer time, List<Integer> restrict) { List<Block> blocks = new ArrayList<Block>(); int i = 0; for (int value : restrict){ blocks.add(i,new Block(value, -1)); i++; } OreLookup ore = new OreLookup(player); for (String w : plugin.getConfiguration().getW...
4
@Override public PermissionType getType() { return PermissionType.RCON; }
0
public int[] getBestTranslations(int sourceWord, int transCount){ int totalTransCount = translations[sourceWord].length; if(totalTransCount < transCount) transCount = totalTransCount; int[] bestTranslation = new int[transCount]; double[] bestScores = new double[transCount]; for(int i=0; i<transCount; i++){ ...
6
@Override public final int find(final IAMArray key) throws NullPointerException { if (key == null) throw new NullPointerException("key = null"); int i = this._rangeMask_; if (i != 0) { final IAMArray range = this._rangeOffset_; i = key.hash() & i; for (int l = range._get_(i), r = range._get_(i + ...
7
@Override public void run() { try { /* // get login information String username = _in.readLine(); String password = _in.readLine(); String responseMessage; if (validateLogin(username, password)) { responseMessage = "ok"; } else { responseMessage = "nok"; } resp...
7
private void InfectSurroundingHumans( int rowPosition, int columnPosition ) { int[] infectLeft = CalculateMove( rowPosition, columnPosition, "Left" ); int[] infectRight = CalculateMove( rowPosition, columnPosition, "Right" ); int[] infectUp = CalculateMove( rowPosition, columnPosition, "Up" ); int[] infectDown...
8
@Override public void startDocument() throws SAXException { System.out.println("start Document"); }
0
public static boolean validateEvent(){ boolean isValid=false; return isValid; }
0
private static void validerSujet(Sujet sujet) throws ChampInvalideException, ChampVideException { if (sujet.getSujet() == null|| sujet.getSujet().isEmpty()) throw new ChampVideException("Le sujet n'a pas de titre"); if (!sujet.getCategorie().peutCreerSujet(sujet.getCreateur())) ...
3
public void flush() { if (isOpen()) { flushImpl(); } }
1
public void listPaare(){ for(Paar p : paare){ if(p == null) continue; System.out.println("Paar: " + p.paarnummer + ", Name Herr: "+ p.nameH + ", Name Dame: "+ p.nameD); } }
2
@Override protected boolean collidingWithWall() { if(!collidable) return false; if(game.getCurrentLevel().isBlockAtPixelCollidable((int)tx+(width/2)-4,(int)ty-(height/4)) && game.getCurrentLevel().isBlockAtPixelCollidable((int)tx+(width/2)-4,(int)ty+(height/4)) ){ return true; } else if(game.getCurrentLev...
5
public Object invokeConstructor(Reference ref, Object[] params) throws InterpreterException, InvocationTargetException { Constructor c; try { String[] paramTypeSigs = TypeSignature.getParameterTypes(ref .getType()); Class clazz = TypeSignature.getClass(ref.getClazz()); Class[] paramTypes = new Clas...
7
public static String toString(Inventory i) { YamlConfiguration configuration = new YamlConfiguration(); configuration.set("Title", i.getTitle()); configuration.set("Size", i.getSize()); for (int a = 0; a < i.getSize(); a++) { ItemStack s = i.getItem(a); if (s != n...
2
private void setSequence(URL midiSource) { if (sequencer == null) { errorMessage("Unable to update the sequence in method " + "'setSequence', because variable 'sequencer' " + "is null"); return; } if (midiSource == null) { errorMessage("Unable to load Midi file in method 'setSequence'."); r...
7
private void readFile(BufferedReader reader) throws IOException{ startTime = System.nanoTime(); textfields.setControlfile("Starting assembly ..."); for ( String line; ( line = reader.readLine() ) != null; ) { textfields.setProgramfile(linecounter + " " + lin...
9
@Override protected Object doInBackground() throws Exception { socketChannel.register(selector, SelectionKey.OP_CONNECT); while (running) { selector.select(); for (Iterator<SelectionKey> it = selector.selectedKeys().iterator(); it .hasNext();) { SelectionKey key = it.next(); it.remove(); t...
6
private void checkEarning() { if (cb.isCanCreateMeoMeo()) { pp.addMeoMeo(); cb.setCanCreateMeoMeo(false); } if (cb.isCanUpgradeMeoMeo()) { pp.upgradeMeoMeo(); cb.setCanUpgradeMeoMeo(false); } }
2
@Test public void testRunStartServerSpotStudent()throws Exception{ AccessControlServer server = new AccessControlServer(1931); server.start(); SpotStub spot = new SpotStub("312",1931); spot.start(); sleep(1000); String ans = ""; int x = 0; ...
3
public void setBody( final Foil f ) { final StringBuilder sB = new StringBuilder(); final int count = f.size(); final int digits = String.valueOf( count ).length(); sB.append( "<html>" ); sB.append( "<pre>" ); final int eC = f.getErrorCount(); int index = 0; if ( eC > 0 ) { ...
9
public String output() { String str = ""; if (data<10) { str+="0"; } if (data<100) { str+= "0"; } str+= "" + data + " data2: " + data2 + " text: " + text; return str; }
2
private void writeFile(byte[] content, String filename) throws IOException { File file = new File(filename); if (!file.exists()) { file.createNewFile(); } FileOutputStream fop = new FileOutputStream(file); fop.write(content); fop.flush(); fop.close(); }
1
@Override public List<Kolegij> fetchAllKolegijList() { List<Kolegij> listaKolegija = new ArrayList<Kolegij>(); for (int i = 0; i < 10; i++) { listaKolegija.add(mock(Kolegij.class)); } return listaKolegija; }
1
private void doubleRightRotate (Tree degTree) { Tree leftChild = degTree.getLeftChild(), parent = degTree.getParent(), rightGrandson = leftChild.getRightChild(); leftChild.setParent(rightGrandson); leftChild.setRightChild(rightGrandson.getLeftChild()); if (rightGrandson.getLeftChild() != null) ...
6
@Override protected boolean xsend (Msg msg_, int flags_) { if (pipe == null || !pipe.write (msg_)) { ZError.errno(ZError.EAGAIN); return false; } if ((flags_ & ZMQ.ZMQ_SNDMORE) == 0) pipe.flush (); // Detach the original message from the dat...
3
@Override public void update() { /** Coleta eventos de explosão. */ List<Event> explosionEvents = getEntityManager().getEvents( InAnExplosionEvent.class); /** Verifica se a lista de eventos não está vazia. */ if (explosionEvents != null) { for (Event event : explosionEvents) { InAnExplosionEvent exp...
9
public int getYLocation() { return yLocation; }
0
public IdentityDiscGridFactory(Grid grid, FullGridFactory factory) { if (grid == null) throw new IllegalArgumentException("Grid can't be null!"); if (factory == null) throw new IllegalArgumentException("Factory can't be null!"); this.factory = factory; this.grid = grid; }
2
public void updateAllBoard() { Cell cCell; for (int y = 0; y < ySize; y++) { for (int x = 0; x < xSize; x++) { cCell = curMap.getCell(y, x); if (cCell.containsRock()) { board[x][y] = new Hexagon(this, rock); } else if (cCell.containsBlackAnt()) { board[x][y] = new Hexagon(this, antB); }...
9
public void run() { String currentIP = TakitDNS.getIP(); String file = TakitDNS.getURL( "http://freedns.afraid.org/api/?action=getdyndns&sha=" + Security.SHA1(username.toLowerCase()+"|"+password) ); if ( file==null ) { return; } String[] entries = file.split("\n"); String[] entry = null; for...
5
public void method468(int i) { super.modelHeight = 0; anInt1650 = 0; anInt1651 = 0; anInt1646 = 0xf423f; anInt1647 = 0xfff0bdc1; anInt1648 = 0xfffe7961; anInt1649 = 0x1869f; for (int j = 0; j < anInt1626; j++) { int k = anIntArray1627[j]; int l = anIntArray1628[j]; int i1 = anIntArray1629[j]; ...
9
protected void showFamilyAsChild() { Person person = personPanel.getPerson(); List<Family> families = person.getFamiliesAsChild(); Family family = null; if (families != null) family = families.get(0); if (family != null) { familyPage.setFamily(family); parent.setSelectedIndex(1); } }
2
public void printListBackwards() { if (previous != null) { System.out.println(this.getData()); previous.printListBackwards(); } else { System.out.println(this.getData()); } }
1
@Override public void handle(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { // Cache Validation String ifModifiedSince = request.headers().get(IF_MODIFIED_SINCE); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { SimpleDateFormat dateFormatter =...
3
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Perfil)) { return false; } Perfil other = (Perfil) object; if ((this.idPerfil == null && other.idPerfil != null...
5
public void readXML(XMLStreamReader parser) throws IOException, XMLStreamException { parser.require(XMLStreamReader.START_ELEMENT, null, "matrix"); m = Integer.parseInt(parser.getAttributeValue(null, "rows")); n = Integer.parseInt(parser.getAttributeValue(null, "cols")); A = new double[m][n]; ...
4
protected boolean shouldShowStatePopup() { return true; }
0
private AudioChannel getAudioChannel(int objectId) { if (channels.containsKey(objectId)) { return channels.get(objectId); } Iterator<Entry<Integer, AudioChannel>> it = channels.entrySet() .iterator(); while (it.hasNext()) { Entry<Integer, AudioChannel> entry = it.next(); if (entry.getValue().isFr...
3
public static String combineSplit(int startIndex, String[] string, String separator) { if (string == null) { return ""; } else { StringBuilder builder = new StringBuilder(); for (int i = startIndex; i < string.length; i++) { builder.append(string[i]); ...
2
void cancelLastCommand() { try { worker.abort(); } catch (Exception ex) { } }
1