text
stringlengths
14
410k
label
int32
0
9
public void newNPC(int npcType, int x, int y, int heightLevel, int rangex1, int rangey1, int rangex2, int rangey2, int WalkingType, int HP, boolean Respawns) { // first, search for a free slot int slot = -1; for (int i = 1; i < maxNPCs; i++) { if (npcs[i] == null) { slot = i; break; } } if(slot...
5
public static Set<String> extracLinks(String url,LinkFilter filter){ Set<String> links=new HashSet<String>(); try{ FileOutputStream out = null ; OutputStreamWriter out1 = null ; BufferedWriter bw=null; Parser parser= new Parser(url); ...
9
@Override /* handles the answers inserted into the answertextfield on the answerpanel */ public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().startsWith(AntwortTextField.VALUE_CHANGED)) { correctAnswers = 0; if (fragebogen != null) { ...
9
private String findVal(Node[] state, Node myNode, int index) { String val; int id = myNode.getId(); int ring = id % 4; // ring = right value int left = 0; int mod = 0; int size = 4; int[] ids; // 0 = diagonal TL-BR, 1 = horizontal, 2 = diagonal BL-TR, 3 = vertical switch(index) { // TL-BR ...
7
@Override public int getRoot(int n) { int root = id[n]; while(root != id[root]) { id[root] = id[id[root]]; root = id[root]; } return root; }
1
private static SessionFactory buildSessionFactory() { try { return new Configuration().configure().buildSessionFactory(); } catch (Throwable ex) { System.err.println("===================================Initial SessionFactory creation failed." + ex); throw new Exceptio...
1
public Object [][] getDatos(){ Object[][] data = new String[getCantidadElementos()][colum_names.length]; //realizamos la consulta sql y llenamos los datos en "Object" try{ if (colum_names.length>=0){ r_con.Connection(); String c...
5
public void calcAdjacencies() { for (int i = 0; i < rows * columns; i++) { LinkedList<Integer> cells = new LinkedList<Integer>(); int column = i % columns; int row = i / columns; if (column > 0) { // left cells.add(i - 1); } if (column < columns - 1) { // right cells.add(i + 1); } ...
5
public static int getLevenshteinDistance (String s, String t) { if (s == null || t == null) { throw new IllegalArgumentException("Strings must not be null"); } int n = s.length(); // length of s int m = t.length(); // length of t if (n == 0) { return m; } else if (m...
8
public void run() { // signal that this thread has started threadStarted(); while (!isInterrupted()) { // get a task to run Runnable task = null; try { task = getTask(); } catch (Int...
4
public static void arc(double x, double y, double r, double angle1, double angle2) { if (r < 0) { throw new IllegalArgumentException("arc radius must be nonnegative"); } while (angle2 < angle1) { angle2 += 360; } double xs = scaleX(x); double ys = ...
4
private void writeType(YamlFile yamlFile, String key, Class<?> value) { yamlFile.set(key, value.getSimpleName()); }
1
public void setCountry(String country) { this.country = country; }
0
public Map<K, V> read(JsonReader in) throws IOException { JsonToken peek = in.peek(); if (peek == JsonToken.NULL) { in.nextNull(); return null; } Map<K, V> map = constructor.construct(); if (peek == JsonToken.BEGIN_ARRAY) { in.beginArray(); while (in.hasNe...
6
@Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((cellPhone == null) ? 0 : cellPhone.hashCode()); result = PRIME * result + ((email == null) ? 0 : email.hashCode()); result = PRIME * result + ((firstName == null) ? 0 : firstName.hashCode()); result = PRIME ...
5
@Override public String toString() { return "READ"; }
0
@Override public LinkedList<Individual> crossover(int[] parents, Population pop) { LinkedList<Individual> children= new LinkedList<Individual>(); Random r = new Random(); //for each 2 parents for (int i = 0; i < parents.length-1; i += 2) { // copy 2 parents to build children Expression ch1 = (Expr...
7
@Override public String getMCstring(){ String s = ""; for (int i = 0; i < mc.length; i++) { if(mc[i] == true) s = s.concat("1"); else s = s.concat("0"); if(i == 5 || i == 10 || i == 15 || i == 20 || i == 25) s = s.co...
7
public void sink(Map<String, Object> settings, TupleEntry tupleEntry, OutputCollector outputCollector) throws IOException { String rowKeyField = SettingsHelper.getMappingRowKeyField(settings); Tuple key = tupleEntry.selectTuple(new Fields(rowKeyField)); ByteBuffer keyBuffer = SerializerHelper.se...
8
@SuppressWarnings("deprecation") @EventHandler public void PlayerInteract(PlayerInteractEvent event) { final Player p = event.getPlayer(); int amount = p.getItemInHand().getAmount(); final Location loc = p.getTargetBlock(null, 256).getLocation(); if(p.hasPermission("skeptermod.useitem.chaoslightning") || (p.i...
7
public EsteenTyyppi eksistoi() { liikuta(); lenna(); return this.osuikoJohonkin; }
0
public String getName(){ return name; }
0
public boolean isRefresh() { if(frame == null) buildGUI(); return refresh.isSelected(); }
1
public static Object trapRead(Object[] args, String name) { if (args[0] == null) return _classobject.trapFieldRead(name); else return ((Metalevel)args[0])._getMetaobject().trapFieldRead(name); }
1
public void removePiece(Piece piece) { if (this.placedPiece == piece) { this.remove(piece); this.placedPiece = null; this.validate(); this.repaint(); } else { throw new PieceNotInFieldException(piece, this); } }
1
public static Integer getOpcodeFromToBit(Integer opcode, int fromBit, int toBit) { // Groesser kleiner ;) if(fromBit > toBit) { int tmp = toBit; toBit = fromBit; fromBit = tmp; } int operand = 0; for(int i = fromBit; i <= toBit; i++) { operand += Math.pow(2, i); } int k = opcode & 0x3fff; ...
2
public String getPackageClassName() { if(StringUtils.isBlank(className)){ return ""; } return StringUtils.isBlank(packageName)?className:packageName+"."+className; }
2
public InetAddress getAddress() { return address; }
0
@Deprecated public void loadTexture(String filename) { try { texture = TextureLoader.getTexture("PNG", new FileInputStream("./res/" + filename)); } catch (IOException e) { e.printStackTrace(); } }
1
public AnnotationVisitor visitParameterAnnotation(final int parameter, final String desc, final boolean visible) { AnnotationNode an = new AnnotationNode(desc); if (visible) { if (visibleParameterAnnotations == null) { int params = Type.getArgumentTypes(this.desc).length; visibleParameterAnnotations =...
5
@Override public String getId() { return id; }
0
public static byte[] encrypt(byte[] data, String publicKey, String privateKey) throws Exception { // 生成本地密钥 SecretKey secretKey = getSecretKey(publicKey, privateKey); // 数据加密 Cipher cipher = Cipher.getInstance(secretKey.getAlgorithm()); cipher.init(Cipher.ENCRYPT_MODE, secretKey); return cipher.doFina...
0
@Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(submit)) { credentials[0] = usernameField.getText(); credentials[1] = new String(passwordField.getPassword()); if (credentials[0].length() == 0 || credentials[1].length() == 0) return; setVisible(false); }...
9
private void load(InputStream in0) throws IOException { DataInputStream in = new DataInputStream(new GZIPInputStream(in0)); int bufferWidth = readInt(in); int bufferHeight = readInt(in); int ascent = readInt(in); if (bufferWidth == 0 || bufferHeight == 0) bufferWidth = bufferHeight = 0; this.bufferWidt...
3
protected void attackEntity(Entity var1, float var2) { if(!this.worldObj.multiplayerWorld) { int var3 = this.getCreeperState(); if((var3 > 0 || var2 >= 3.0F) && (var3 <= 0 || var2 >= 7.0F)) { this.setCreeperState(-1); --this.timeSinceIgnited; if(this.timeSince...
9
public void delete(String fname, String lname, String id, String major) { idError.setText(""); //System.out.println("id present"); fnameLabel.setVisible(true); lnameLabel.setVisible(true); idLabel.setVisible(true); majorLabel.setVisible(true); fnameField.setVisible(true); lnameField....
8
public Vector2f getDoorSize() { if(getTransform().getRotation().getY() == 90) { return new Vector2f(WIDTH, LENGHT); }else { return new Vector2f(LENGHT, WIDTH); } }
1
@Override public void setBackground( Color bg ) { super.setBackground( bg ); if( canvas != null ){ canvas.setBackground( bg ); } }
1
private void close(boolean saveChanges) { if (saveChanges) { if (!setMainDir()) return; if (!setModDir()) return; saveConfig(); } dispose(); }
3
@Override public synchronized void gridletSubmit(Gridlet gridlet, boolean ack) { // Create a server side Gridlet SSGridlet sgl = new SSGridlet(gridlet); if(!validateGridlet(sgl)) { try { // reject the Gridlet gridlet.setGridletStatus(Gridlet.FAILED); super.sendFinish...
4
private void applyFlank(char[][] board, int x, int y, int xInc, int yInc, char player, char opponent){ int origX = x, origY = y; while(true){ x += xInc; y += yInc; if(x < 0 || x >= SIZE || y < 0 || y >= SIZE) return; if(board[x][y] == player) break; else if(board[x][y] != opponent)...
9
public static String pipelineHome(String plUser, String plPort){ StringBuilder homePath = new StringBuilder(); // By getting the owner of the preferences file we can get the Pipeline user. Process p = null; try { String s = ""; if ( !plUser.equals("root") ) { ...
9
public void checkCollisions() { if (getEntities() == null) return; List<Entity> entities = getEntities().getList(null); for (Entity other : entities) { if (collidesWith((Positioned)other, false)) { reactToCollision(other, collidesWith...
3
boolean isSampleValid(double[] sample) { for (int i = 0; i < parameterNames.length; i++) { if (sample[i] < lowBound[i] || sample[i] > upBound[i]) { return false; } } return true; }
3
public void collideCheck() { if (dead) return; float xMarioD = world.mario.x - x; float yMarioD = world.mario.y - y; float w = 16; if (xMarioD > -w && xMarioD < w) { if (yMarioD > -height && yMarioD < world.mario.height) { if (...
9
public static Stella_Object accessKvConsSlotValue(KvCons self, Symbol slotname, Stella_Object value, boolean setvalueP) { if (slotname == Stella.SYM_STELLA_KEY) { if (setvalueP) { self.key = value; } else { value = self.key; } } else if (slotname == Stella.SYM_STELLA_...
6
public void fillPouch(int i) { if (i < 0) return; int toAdd = c.POUCH_SIZE[i] - c.pouches[i]; if (toAdd > c.getItems().getItemAmount(1436)) { toAdd = c.getItems().getItemAmount(1436); } if (toAdd > c.POUCH_SIZE[i] - c.pouches[i]) toAdd = c.POUCH_SIZE[i] - c.pouches[i]; if (toAdd > 0) { c.getItem...
4
public void doFrameEnterHighscore() { char key = getLastKeyChar(); clearLastKey(); if (key==KeyBackspace && playername.length()>0) playername = playername.substring(0,playername.length()-1); if (key==KeyEnter) { highscores = Highscore.insert(highscores, new Highscore(score,playername)); clearLastK...
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Noticia other = (Noticia) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; ...
6
public boolean simplify(Constraint other) { if (nvariables<other.nvariables) // Are we a subset of other? Let other figure it out. return other.simplify(this); // Is other a subset of us? for (int i=0; i<other.nvariables; ++i) for (int j=0; j<nvariables; ++j) if (variables[j].equals(other.variable...
8
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); if (init == false) { try { use...
6
@Override public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { // create a new space object if one wasn't supplied... if (space == null) { space = new AxisS...
8
public final IAMIndexBuilder decode(final IAMCodec codec) throws IOException, IllegalArgumentException { final IAMINDEXTYPE xmlIndex = JAXB.unmarshal(IO.inputReaderFrom(codec.getSourceData()), IAMINDEXTYPE.class); final IAMIndexBuilder indexBuilder = new IAMIndexBuilder(); codec.useByteOrder(IAMByteOrder.from(xm...
8
private double testQueueEnqueue(int inserts) { System.out.println("Testing queue with " + inserts + " pushes"); long[] times = new long[20]; long startTime; long endTime; for (int i = 0; i < 20; i++) { queue = new Queue(); startTime = System.currentTimeM...
3
public void setAverErrors(List< List<Double>> l_averErrors) { if(!this.averErrors.isEmpty()) {this.averErrors.clear();} /*this.averErrors.add(new ArrayList<Double>()); //trainig this.averErrors.add(new ArrayList<Double>()); //testing this.averErrors.add(new ArrayList<Double>()); //valida...
1
public int getBlue(){ return _blue; }
0
private static final JsonElement resolvePath(final JsonObject root, String key, JsonElement finalValue){ // treat all dots as a branch String[] segments = key.split("\\."); int segmentCount = segments.length; JsonObject currentProperty = root; String currentPath = ""; for(int i = 0; i < segmentCount; ...
4
public static String getIdNameById(int id){ if(id < 10){ return "000" + id; } else if(id >= 10 && id < 100){ return "00" + id; } else if(id >= 100 && id < 1000){ return "0" + id; } else{ return "" + id; } ...
5
public void addPlotter(final Plotter plotter) { plotters.add(plotter); }
0
@Override public String getExecCommand() { return execCommand; }
0
@Override public ICTMC load(String pathname) throws Exception { ICTMC ret = null; BufferedReader inputStrm; String currentLine; String[] fields; int i = -1; int j = -1; int n = -1; double h = -1; double T = -1; double e = -1; int k = -1; double[][] si = null; double[][] tmpQ = null; if(t...
8
private void sendSupportedFeatures() throws IOException { List<String> supportedFeatures = config.getSupportedFeatures(); if (supportedFeatures!=null && !supportedFeatures.isEmpty()) { //building $Supports string String supportsString = "$Supports"; for (String suppor...
6
private String myInitSubString(String varName) { String tmpName = null; int j = 0; for(int i = 0; i != varName.length(); i++) { if(varName.charAt(i) == '_' && j == 0) { j = i; continue; } if(varName.charAt(i) == '_' && j != 0) { tmpName = varName.substring(j + 1, i); break; } ...
5
int afterName() throws IOException { int n = in.next(); switch (n) { case ' ': case '\t': case '\r': case '\n': in.back(); String ws = parseWhitespace(in); if (!isIgnoreWhitespace()) { set(JSONEventType.WHITESPACE, ws, false); } return AFTER_NAME; case ':': return BEFORE_VALUE; cas...
7
@Override public void run() throws Exception { try { // Eclipse doesn't support System.console() BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); ConfigManager config = NetBase.theNetBase().config(); String server = config.getProperty("net.server.ip"); if ( server == nu...
9
@Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_LEFT) { canasta.setMoveLeft(false); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { canasta.setMoveRight(false); } else if (e.getKeyCode() == KeyEvent.VK_G) { if (!instrucc...
7
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { String text = aJCas.getDocumentText(); //Go through document word by word int pos = 0; StringTokenizer tokenizer = new StringTokenizer(text, " \t\n\r.<.>/?\";:[{]}\\|=+()!", true); //Get the string ID as the fir...
9
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (Object.class == method.getDeclaringClass()) { if ("equals".equals(name)) { Object obj = args[0]; return new Boolean(checkEquals(...
7
private boolean updateGameLevel() { if (linesToLevel <= 0) { int delay; switch (difficulty) { case Normal: ++level; linesToLevel += (int)(level * 1.25) + 5; // Level 1 fall rate is 1 second, ever level thereafter decrease by 50 ms delay = FALL_RATE - (75 * level); break; ...
4
@Override int trimIndex(Fastq fastq) { int qual[] = FastqTools.qualtityArray(fastq); for( int i = 0; i < qual.length; i++ ) { int median = median(qual, i); // Compute running median if( median < qualityThreshold ) return i; // Below threshold? => trim here } return qual.length; }
2
public void Set_edgewieghtE(float[][] temp){ int ni = temp.length; int nj = temp[0].length; for (int i = 0; i < ni; i++) { for (int j = 0; j < nj; j++) { t_edgeweight[i][j] = temp[i][j]; } } }
2
public void setPreserved() { if (!preserved) { preserved = true; Identifier ptr = this; while (ptr != null) { ptr.setSinglePreserved(); ptr = ptr.left; } ptr = right; while (ptr != null) { ptr.setSinglePreserved(); ptr = ptr.right; } } }
3
public static Tour crossoverDouble(Tour parent1, Tour parent2) { Tour child = new Tour(); int[] mrk = new int[4]; mrk[0] = (int) (r.nextInt(parent1.tourSize())); mrk[1] = (int) (r.nextInt(parent1.tourSize())); mrk[2] = (int) (r.nextInt(parent1.tourSize())); mrk[3] = (int) (r.nex...
9
private void cargarDatosPersona(){ txtCodigo.setText(String.valueOf(persona.getCodigo())); txtNombre.setText(persona.getNombre()); txtTelefonoFijo.setText(persona.getTelefonoFijo()); txtCelular.setText(persona.getCelular()); txtEmail.setText(persona.getEmail()); if(person...
2
private boolean login(HttpServletResponse response, HttpServletRequest request) { String userMail = request.getParameter("email"); String userPassword = request.getParameter("password"); UserBean user = this.model.getUser(userMail); HttpSession session; if(user != null){ ...
3
public void visitInnerClassType(final String name) { if (argumentStack % 2 != 0) { declaration.append('>'); } argumentStack /= 2; declaration.append('.'); declaration.append(separator).append(name.replace('/', '.')); separator = ""; argumentStack *= 2; }
1
public static void main(String[] args) { try { // Set platform look and feel UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (UnsupportedLookAndFeelException e) { // handle exception } catch (ClassNotFoundException e) { // handle exception } catch (InstantiationException...
4
@Override public void setMaxFileSize(String size) { if ((size != null) && (!size.isEmpty())) maxFileSize = size; }
2
private void jButtonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCloseActionPerformed //Récupération de la méthode contrôleur 'clode' ctrlCR.close(); }//GEN-LAST:event_jButtonCloseActionPerformed
0
@Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String[] line = value.toString().split(inDelimiter); String keyCol = ""; String valueCol = ""; for (int i = 0; i < line.length; i++) { if (i == Integer.parseInt(keyColumn)) keyCol = lin...
3
protected String convert(String line) { String[] words = line.split("\\s"); if (words.length < 3) return "*** Error : too few tokens on line ***"; if (words[0].length() != 2) return "*** Error : invalid prefix ***"; DPoint offset = osgb.GridSquareToOffset(words[0].charAt(0), words[0] .charAt(1)); ...
6
public Item next() { if (!hasNext()) throw new NoSuchElementException(); Item item = current.item; current = current.next; return item; }
1
private void printLambda(Node t, int n) { if (t.getCdr().isNull()) { t.getCar().print(n+4, false); System.out.println(); if (n > 0) { for (int i = 0; i < n; i++) System.out.print(" "); } t.get...
3
public static ConnectionBDD getInstance() { if(instance == null){ instance = new ConnectionBDD(); } return instance; }
1
@Override public boolean execute(CommandSender sender, String[] args) { return false; }
0
@Override public void run() { if (Updater.this.url != null) { // Obtain the results of the project's file feed if (Updater.this.read()) { if (Updater.this.versionCheck(Updater.this.versionName)) { if (Updater.this.versionLink != null...
6
@Override public int hashCode() { return id != null ? id.hashCode() : 0; }
1
public static Stella_Object accessIntegerIntervalIteratorSlotValue(IntegerIntervalIterator self, Symbol slotname, Stella_Object value, boolean setvalueP) { if (slotname == Stella.SYM_STELLA_INTERVAL_CURSOR) { if (setvalueP) { self.intervalCursor = ((IntegerWrapper)(value)).wrapperValue; } ...
6
@Override public void run() { try { openConnection(); while (running) { Socket socket; System.out.println("waiting for connection"); socket = serverSocket.accept(); ClientHandler h = new ClientHandler(new Connection(sock...
2
public void startEngine(String[] args) { try { final OptionManager om = OptionManager.instance(); final boolean hasArg = om.parseCommandLine(args,OPTION_CONTAINER); /* Update the verbosity level according to the verbosity option */ String verbosity = null; if (hasArg) { verbosity = (String)OptionMa...
9
public void saveLogEntrada(PosListaPrecio itemOracle, String tipo, int idPos){ logger.info("itemOracle.getPcaIdElemento() = " + itemOracle.getPcaIdElemento()); logger.info("idPos = " + idPos); logger.info("tipo = " + tipo); try { PhpposLogEntrada...
4
public void listAppConstant(String constantLabel) throws UnrecognizedCommandException { if (null != constantLabel && !"".equals(constantLabel.trim())) { try { printUsage(constantLabel); } catch (NullValueException e) { } } if (null == constantLabel) { String[] header = { "Constant", "Description" ...
6
public void updateElement() { if(this.GameElementListener != null) { this.GameElementListener.Update(this); } if(this.Gravitation.isxEnable()) { this.Location.setX(this.Location.getX() + this.Gravitation.getxValue()); } if(this.Gravit...
3
public Markers intersects(Markers interval1, Marker intervals) { Markers ints = new Markers(); for (Marker i : interval1) if (i.intersects(intervals)) ints.add(i); return ints; }
2
public int percentageOfInhabitedHabitats() { int amount = 0; for (Habitat h : habitats.values()) { if (h != null) { if (h.isInhabited()) amount++; } } return amount; }
3
void removeInternal(Node<K, V> node, boolean unlink) { if (unlink) { node.prev.next = node.next; node.next.prev = node.prev; node.next = node.prev = null; // Help the GC (for performance) } Node<K, V> left = node.left; Node<K, V> right = node.right; Node<K, V> originalParent = nod...
8
public void doGet(HttpRequest req, HttpResponse res) { logger.debug("Request received:\n"+req.toVerboseString()); //Get the possible query parameters. String username = req.getParameter("username"); String password = req.getParameter("password"); String logout = req.getParameter("logout"); //See if this...
9
private static void parseDocument() { // get the root element Element docEle = domBounds.getDocumentElement(); docEle.normalize(); System.out.println("Root element :" + docEle.getNodeName()); NodeList bl = docEle.getElementsByTagName("Bound"); if (bl != null && bl.getLength() > 0) { for (int i = 0; i < ...
7
@Override public boolean equals(Object obj) { if( this == obj ) { return true; } if( obj == null ) { return false; } if( getClass() != obj.getClass() ) { return false; } final CsvContext other = (CsvContext) obj; if( columnNumber != other.columnNumber ) { return false; } if( rowNumber !...
9
Sdef( String name, String defName, String consolFunc ) throws RrdException { super( name ); this.defName = defName; this.consolFunc = consolFunc; // -- Parse the consolidation function to be used if ( consolFunc.equalsIgnoreCase("AVERAGE") || consolFunc.equalsIgnoreCase("AVG") ) aggregate = Source.AGG_A...
9