text
stringlengths
14
410k
label
int32
0
9
private boolean isAttacking(){ if(state == StateActor.ATTACKINGUP || state == StateActor.ATTACKINGDOWN || state == StateActor.ATTACKINGLEFT || state == StateActor.ATTACKINGRIGHT){ return true; } else return false; }
4
public void WGAdmin(String sender, String login, String hostname, Command command) { if(adminpass == null) { System.out.println("[!] Admin identification attempt (no pass set). Nick: " + sender + " Login: " + login + " Hostname: " + hostname); sendMessage(sender, "No admin password has b...
3
@SuppressWarnings("unchecked") public void changeCapacityBy(int number) { int newSize = array.length + number; E[] temparray = (E[]) new Object[newSize]; System.arraycopy(array, 0, temparray, 0, array.length > newSize ? newSize : array.length); array = temparray; if (lastPos...
4
protected void processGlobalResourceList(Sim_event ev) { /*** NOTE: possible cases are - if there is only 1 local GIS and no other regional GISes - if there is only 1 user queries for this - if there are 2 or more users query at different time ****/ LinkedLis...
6
public String addGradeItem() throws IOException { InputStreamReader in = new InputStreamReader(System.in); BufferedReader keyboard = new BufferedReader(in); DBConnector db = new DBConnector(); System.out.println("Adding an assignment"); System.out.println("Assignment tit...
1
private void addQuarter() { _numQuarters++; if (_numQuarters <= getMaxQuarters()) { refreshLcd(); } else { returnQuarter(); } }
1
public synchronized void dispose() { //System.out.println("disposing..."); _outputThread.interrupt(); _inputThread.dispose(); }
0
@Override public int smarts(Algebra algebra) { Fraction frac = (Fraction) algebra; //if the fraction is a positive integer on top and bottom, but it's not fully simplified if(frac.getTop() instanceof Number && frac.getBottom() instanceof Number && ((Number)frac.getTop()).isInteger() && ((Number)frac.getBott...
6
@Override public String getErrorMessage(RecognitionException erro, String[] nomeDosSimbolos) { if (erro instanceof UnwantedTokenException) { UnwantedTokenException erroDeSimboloNaoDesejado = (UnwantedTokenException) erro; String entradaNaoDesejada = getTokenErrorDisplay(erroDeSimboloNaoDesejado...
9
private String selectWindow(String seleniumWindowName) { if (!proxyInjectionMode) { String result; try { result = doCommand("selectWindow", seleniumWindowName, ""); } catch (RemoteCommandException rce) { result = rce.getMessage(); } retur...
7
public Set<Map.Entry<Double,Float>> entrySet() { return new AbstractSet<Map.Entry<Double,Float>>() { public int size() { return _map.size(); } public boolean isEmpty() { return TDoubleFloatMapDecorator.this.isEmpty(); } ...
8
private void adicionarItemVenta(String idProd, int cantidad){ this.productosNegativos.clear(); if(!GuiPrincipal.listaFactCompProdExistentes.isEmpty()){ // booleano para comprobar si existe el producto en la lista. boolean existeProducto= false; for (HashMap compra : G...
7
public ResultSet executeQuery(String statement) { if (isFault()) { System.out.println("[Apply] Can't execute query, something wrong with connection"); return null; } if (statement.toLowerCase().startsWith("update") || statement.toLowerCase().startsWith("insert") || statem...
5
public void actionPerformed(ActionEvent e) { Grammar grammar = environment.getGrammar(); if (grammar == null) return; if (grammar.getProductions().length == 0) { JOptionPane.showMessageDialog(Universe .frameForEnvironment(environment), "The grammar should exist."); return; } // Create the i...
3
public static void update() { updateMouseButtons(); Point p = new Point(Mouse.getX(), Display.getHeight() - Mouse.getY()); if (pressPoint!=null) if (draggedModel != null && startPlate.contains(pressPoint)) { Point d=Camera.getTranslatedPoint(draggedModel.getCenter().x, drag...
5
static boolean isValidXmlChar(char ch) { return ((ch >= 0x20) && (ch <= 0xD7FF)) || (ch == 0x9) || (ch == 0xA) || (ch == 0xD) || ((ch >= 0xE000) && (ch <= 0xFFFD)) || ((ch >= 0x10000) && (ch <= 0x10FFFF)); }
8
public static void main(String[] args) throws InterruptedException { terminal = new TestTerminalFactory(args).createTerminal(); terminal.enterPrivateMode(); terminal.clearScreen(); terminal.moveCursor(10, 5); terminal.putCharacter('H'); terminal.putCharacter('e'); ...
3
static private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; if (++jj_gc > 100) { jj_gc = 0;...
6
private Tile[] gettrans(Coord tc) throws Loading { Tile[] r = map.gettrans(tc); if (r == null) throw (new Loading()); return (r); }
1
public float getRYAxisDeadZone() { if (ryaxis == -1) { return 0; } return getDeadZone(ryaxis); }
1
public Record getRecord(String username){ for(Record record:table){ if(record.getUsername().compareToIgnoreCase(username)==0){ return record; } } return null; }
2
@Before public void create_samples() throws IOException, URISyntaxException { // read them from file Path p = Paths.get(getClass().getResource("dbupdates.txt").toURI()); File file = p.toFile(); FileReader in = new FileReader(file); BufferedReader reader = new BufferedReader(in); samples = new ArrayList<St...
1
public void twrInJava6(URL url){ InputStream is = null; try{ File file = new File(""); is = url.openStream(); OutputStream out = new FileOutputStream(file); try{ byte[] buf = new byte[4096]; int len; while((l...
6
public void test_04_del() { initSnpEffPredictor("testCase"); String fileName = "./tests/vcf_04_del.vcf"; VcfFileIterator vcf = new VcfFileIterator(fileName, genome); vcf.setCreateChromos(true); for (VcfEntry vcfEntry : vcf) { for (Variant seqChange : vcfEntry.variants()) { if (!seqChange.isDel()) thro...
3
private void attachListeners() { _raceListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Object index = _raceBox.getSelectedItem(); for (BaseRace br : Character.RACES) { if (br.getName().equals(in...
6
public void scoreHand(Player myHand) { you.sortHand(); you.showHand(); boolean goOn = true; goOn = checkRoyalFlush(myHand); if (goOn == false) { goOn = checkStraightFlush(myHand); } if (goOn == false) { goOn = checkFourKind(myHand); } if (goOn == false) { goOn = checkFullHouse(myHand); ...
9
private static CallFrame initFrameForApplyOrCall(Context cx, CallFrame frame, int indexReg, Object[] stack, double[] sDbl, int stackTop, int op, Scriptable calleeScope, IdFunctionObject ifun, InterpretedFunction iApplyCallable) { Scriptable applyThis; if (indexReg...
7
private static char nextChar(StringBuilder buffer) { return buffer.length() > 0 ? buffer.charAt(0) : 0; }
1
private void roomFromInt(int room) { switch (room) { case 1: this.room =(RoomCard.Rooms.Ballroom); RoomCard.Rooms.Ballroom.setActive(); break; case 2: this.room =(RoomCard.Rooms.BilliardRoom); RoomCard.Rooms.BilliardRoom.setA...
9
public static <T> String implodeAlt(String glue, List<T> list) { // list is empty, return empty string if (list == null || list.isEmpty()) { return ""; } if (glue == null) glue = ""; Iterator<T> iter = list.iterator(); // init the builder with the first element StringBu...
4
final public void Field() throws ParseException { /*@bgen(jjtree) Field */ ASTField jjtn000 = new ASTField(JJTFIELD); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { Identifier(); Type(); } catch (Throwable jjte000) { ...
8
private final void step6() { j = k; if (b[k] == 'e') { int a = m(); if (a > 1 || a == 1 && !cvc(k-1)) k--; } if (b[k] == 'l' && doublec(k) && m() > 1) k--; }
7
private void parseNodes() { String lines[] = textArea_.getText().split("\n"); HashMap<Integer, ValueType> out = new HashMap<>(); for (int i = 0; i < lines.length; i++) { if (lines[i].contains(Export)) { out.put(new Integer(i), getExportType(lines[i])); } } for (Integer l : out.keySet()) { if (...
6
public Color getColor() { if (color == null) { Image image = sprite.getImage(); int clr= ((BufferedImage) image).getRGB(10,10); int red = (clr & 0x00ff0000) >> 16; int green = (clr & 0x0000ff00) >> 8; int blue = clr & 0x000000ff; color = new Color(red,green,blue); return color; } el...
1
public static int charCount(String s) { char c[] = s.toCharArray(); int count = 0; for (char element : c) { if (element != ' ') { count++; } } return count; }
2
private void setFullScreen() { setExtendedState(Frame.MAXIMIZED_BOTH); removeNotify(); setUndecorated(true); addNotify(); }
0
private void handleCannotJoinChannel(String response) { String channel = response.split(" ")[1]; ChannelEventsListener listener = getChannelEventsListener(channel); if (listener != null) listener.userLeft( this.getNick() ); }
1
public static void copyFolder(File src, File dest) throws IOException { if (src.isDirectory()) { // if directory not exists, create it if (!dest.exists()) { dest.mkdir(); } // list all the directory contents String[] files = src.list(); for (String file : files) { // construct ...
6
private void powVectors() { for (wordsDocument doc : webDocs) { HashMap<String, Integer> uniqueCounter = doc.uniqueCounter; doc.vectors = new double[dictionarySize]; int i = 0; int z = 0; for (String dictionaryKey : sortedDictionaryUniqueWords.keySet()) { for (String uniqueWord...
5
private boolean handleLogin(TACMessage msg) { int status = NO_ERROR; while (msg.nextTag()) { if (msg.isTag("userID")) { userID = msg.getValueAsInt(-1); log.fine("Logged in as " + userID); TACMessage msg2 = new TACMessage("serverTime"); sendMessage(msg2, this); // Do not request "nextGame" if already...
4
private void compareDirectories() { progress = 0; long start = System.currentTimeMillis(); // create array and fill him directories size ArrayList<Long> sizes = new ArrayList<Long>(); for (int i=0; i<directoryArray.size(); i++) { calculataAndPublishProgress(i, directoryArray.size(), "State 2 of 5: Calculat...
9
public void decrementEffectsLifetime() { for (Effect effect : effects) effect.decrementLifetime(); }
1
public static void sort(int[] source) { int len = source.length; if (len == 0) { System.out.println("Empty!"); return; } else if (len == 1) { return; } for (int i = 1; i < source.length; i++) { int j = i; int temp = source[j]; while (j > 0 && temp < source[j - 1]) { source[j] = source...
5
public void clearRegisters() { pc.setPC(0); ir.clear(); mar.write(-1); // -1 triggers clear mbr.write(null); for (int i = 0; i < 16; i++) { genRegisters.write(i, null); //Set each general purpose register to null } rCC.write(null); }
1
public ArrayList<Restriction> getRestrictionsFromEvent(String identifier) { //We iterate through the whole list, checking for the Event with that identifier //If we don't find any events with that identifier, we throw an exception for(Event e: events){ if(e.getIdentifier().e...
2
public static String sign(String data, String key) throws InvalidKeyException { Mac sha256HMAC; try { sha256HMAC = Mac.getInstance(HMAC_SHA256); } catch (NoSuchAlgorithmException e) { return null; } SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(), HMAC_SHA256); sha256HM...
1
private void runAction(String paramName, String name){ Task task = new Task(name); switch(paramName){ case "end_task": task.finish(); break; case "new_task": task.create(); break; } }
2
protected int[] initCenterRoomXY(int dirCode) { final int[] xy=new int[2]; switch(dirCode) { case Directions.NORTHEAST: xy[0]=xGridSize()-1; break; case Directions.NORTHWEST: break; case Directions.NORTH: xy[0]=xGridSize()/2; break; case Directions.SOUTHEAST: xy[1]=yGridSize()-1; xy[...
8
@EventHandler public void SkeletonMiningFatigue(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.getZombieConfig().getDouble("Skelet...
7
public static void main(String[] args) throws IOException { InputStream is = FindSchedulerError.class.getResourceAsStream("crontabjob.log"); BufferedReader br = new BufferedReader(new InputStreamReader(is) ); String line = null, duplicated = null; int count = 1; while ( (line = br.readLine() ) != n...
4
public static void merger(LinkedList<Integer> a, LinkedList<Integer> b) { int apos = 0; int bpos = 0; while (apos < a.size() && bpos < b.size()) { if (a.get(apos) < b.get(bpos)) { System.out.print(a.get(apos) + " "); apos++; } else { System.out.print(b.get(bpos) + " "); bpos++; } } if...
7
public void save() { File save = new File("assets/save"); if (!save.exists()) { try { save.mkdir(); } catch (SecurityException e) { e.printStackTrace(); } } try { FileOutputStream fout = new FileOutputStream(new File( "assets/save/" + "save1")); ObjectOutputStream oos = new ObjectO...
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://down...
6
public static Cons inheritAsTopLevelProposition(Proposition proposition, KeyValueMap mapping) { { Cons resultlist = Stella.NIL; if (mapping == null) { mapping = KeyValueMap.newKeyValueMap(); } { Keyword testValue000 = proposition.kind; if (testValue000 == Logic.KWD_AND) { ...
6
private boolean validarDatos() { //unicamente valido el numero de cuenta boolean valido = false; Validaciones val = new Validaciones(); if (jTextField1.getText().equals("") || jTextField2.getText().equals("")){ mensajeError("Ingrese un valor para Desde.. Hasta."); ...
6
protected BallNode mergeNodes(Vector list, int startIdx, int endIdx) throws Exception { for(int i=0; i<list.size(); i++) { TempNode n = (TempNode) list.get(i); n.anchor = calcPivot(n.points, new MyIdxList(), m_Instances); n.radius = calcRadius(n.points, new MyIdxList(), n.anchor, m_Instan...
7
public void updateLayout() { switch (state) { case 0: newGame.setVisible(true); loadGame.setVisible(true); options.setVisible(true); break; case 1: newGame.setVisible(false); loadGame.setVisib...
5
void seek() { if ( x == 0 && index == 0 ) extend(); if ( left == null ) addLeft(); if ( right == null ) addRight(); advance(); }
4
public Content getContent(String name){ int i = 0; while(i < content.size()){ if(content.get(i).getName().equals(name))return content.get(i); i++; } return null; }
2
public String getInput() { try { return lineInput.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return ""; } }
1
public double getDouble(int index) throws JSONException { Object object = get(index); try { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); } catch (Exception e) { throw new J...
2
* @return Returns true if the given cell is a valid source terminal. */ public boolean isValidSource(Object cell) { return (cell == null && allowDanglingEdges) || (cell != null && (!model.isEdge(cell) || isConnectableEdges()) && isCellConnectable(cell)); }
5
private static void dfsR(int node){ if(visited[node] == true) return; visited[node] = true; for(Integer neighbor:gR.get(node)){ dfsR(neighbor); } removed[node] = true; if(cost[node]<min){ min = cost[node]; minCount=1; } else if (cost[node]==min){ minCount++; } }
4
public boolean matches(Identifier ident) { String test = ident.getFullName(); if (firstStar == -1) { if (wildcard.equals(test)) { return true; } return false; } if (!test.startsWith(wildcard.substring(0, firstStar))) return false; test = test.substring(firstStar); int lastWild = firstStar; ...
6
private void setColorForPlayer(String line, int player){ String input = line.substring(2, line.length()); try { int colNo = Integer.parseInt(input); Color retCol = getColor(colNo); if (retCol != null) { if (player == 1){ controller....
3
public double getWidth() { return width; }
0
public void setSequenceId(int sequence_Id) { this.sequence_Id = sequence_Id; TypeConvert.int2byte(sequence_Id, buf, 8); }
0
public void setModuleId(String moduleId) { this.moduleId = moduleId; }
0
private static boolean deletePrescription(Prescription bean, PreparedStatement stmt) throws SQLException{ stmt.setInt(1, bean.getPrescriptionID()); int affected=stmt.executeUpdate(); if(affected==1){ System.out.println("Prescription with ID "+bean.getPrescriptionID()+" has been Removed from database.");...
1
public mainUI() { setContentPane(contentPane); setModal(true); getRootPane().setDefaultButton(buttonOK); vecList = new ArrayList<IClusterCalculable>(); // for (int i = 1; i < 19; i++) { // typeBox.addItem(i + ""); //// rgbs[i] = (int) (Math.random() * 1000 %...
9
@Test public void testSingleTablePopulation() throws SQLException, ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Populator p = new Populator(); p.generators.add(new IntegerGenerator("ride", "id", 0)); p.generators.add(new RandomDateGenerator("ride", "cre...
0
public void computeShortestPaths(DialARideModel model) { List<Node> nodes = model.getNodes(); int numOfNodes = nodes.size(); int[][] cost = model.getCost(); int[][] prev = model.getPrev(); for (int sourceNode = 0; sourceNode < numOfNodes; sourceNode += 1) { boolean[] visited = new boolean[numOfNodes]; f...
8
private void btnGuncelleMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnGuncelleMousePressed if(!btnGuncelle.isEnabled()) return; HashMap<String, String> values = new HashMap<>(); values.put("ad", txtAd.getText().trim()); values.put("soyad...
3
public WeightedQuickUnion(int N) { super(N); this.treeSize = new int[N]; for(int i = 0; i < this.treeSize.length; i++) { this.treeSize[i] = 1; } }
1
@Override public int hashCode() { int hash1 = first == null ? 0 : first.hashCode(); int hash2 = second == null ? 0 : second.hashCode(); return hash1 ^ hash2; }
2
public List<Object> findFirstNodeNotInTree(String pattern, Tree.Node root) { Tree.Node parent = root; List<Object> returnList = new ArrayList<Object>(); for (int i = 0; i < pattern.length(); i++) { boolean found = false; String stringToCompare = String.valueOf(pattern.c...
4
protected Animator getAnimation() { if (standardAnimation) return animation; if (direction == Direction.WEST) return animationLeft; if (direction == Direction.EAST) return animationRight; if (Game.type != GameType.PLATFORMER) { if (direction == Direction.NORTH) return animati...
6
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void onEvent(@Observes LogEvent logEvent) { if (!this.enabled) { return; } LogRecord lr = new LogRecord(Level.OFF, String.format(logFormat, logEvent.getTimestamp(), logEvent.getSource(), logEvent.getMessage()));...
8
public void examineDirectory(File folder) throws ParseException, IOException { for (File file : folder.listFiles()) { if (file.isDirectory()) { examineDirectory(file); } else { if (file.getName().endsWith(".java")) { parsedInput = JavaParser.parse(file); String fileName = file.getName().su...
9
public void reset() { //float[] floatp; // float[] floatp2; // initialize v1[] and v2[]: //for (floatp = v1 + 512, floatp2 = v2 + 512; floatp > v1; ) // *--floatp = *--floatp2 = 0.0; for (int p=0;p<512;p++) v1[p] = v2[p] = 0.0f; // initialize samples[]: //for (floatp = samples +...
2
@Override protected EntityManager getEntityManager() { return em; }
0
public boolean getBoolean(int index) throws JSONException { Object object = this.get(index); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String)object).equalsIgnoreCase("false"))) { return false; } else if (object.equals(Boolean....
6
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; WithList withList = (WithList) o; if (list != null ? !list.equals(withList.list) : withList.list != null) return false; return true; }
5
private boolean computeCell(int col, int row) { // liveCell is true if the cell at position (col,row) in world is live boolean liveCell = getCell(col, row); // neighbours is the number of live neighbours to cell (col,row) int neighbours = countNeighbours(col, row); // we will return this...
8
public String goRoom(String direction) { // Try to leave current room. if(currentRoom instanceof BlockedRoom) { BlockedRoom br = (BlockedRoom) currentRoom; if(br.isBlocked())// why is this here? { if(br.getBlocked(direction)) { return "There is a gate in the wa...
6
public String[] getDataAt(int index) { return allPorts.get(index); }
0
public int getRowCount() { return rows; }
0
public static Cons mostSpecificCollections(Cons descriptions) { if (descriptions.rest == null) { return (descriptions); } { Cons cursor1 = descriptions; Cons cursor2 = null; Stella_Object value1 = null; Stella_Object value2 = null; while (!(cursor1 == Stella.NIL)) { va...
7
@Override public void checkForMutations() { // Convenience variables. ReplicatableCollection<ReplicatableInteger> replicateCollection = (replicationResult.getReplicate()); Collection<ReplicatableInteger> original = collection.getSubcomponents(); Collection<ReplicatableInteger> replicate = replicateCollection....
9
private void makeTable() { int tableSize = (int) Math.pow(2, Expression.getVariableCount()); compactTable.clear(); String compactTableString = new String(Expression.getCompactExpression()); List<String> expressionRow = new ArrayList<>(); List<String> emptyRow = new ArrayList<>(); for (int i = 0; i < compac...
3
public int getInterval () { int interval = getU8 (6); String type = getType (); boolean highspeed = iface.getDevice ().getSpeed () == "high"; if (type == "iso" || highspeed) { if ((type == "bulk" || type == "control") && interval == 0) /* never NAKs */ ; else interval = 1 << (interval - 1); } i...
6
private void list() { if (agents.isEmpty()) { UI.setError("No hay agents activos"); } else { UI.clearError(); Agent agent; int i; UI.printHeader(); System.out.println(agents.size() + " agentes activos:"); System.out.println(""); for (i = 0; i < agents.size(); i++) { agent = agents.get(...
3
public void setExecute(boolean execute) { this.execute = execute; }
0
public GameBoardGraphics getGridPanel() { boolean test = false; if (test || m_test) { System.out.println("Drawing :: getGridPanel() BEGIN"); } if (test || m_test) System.out.println("Drawing:: getGridPanel() - END"); return gameBoardGraphics; }
4
@Test public void test() throws BiffException, IOException{ Workbook workbook = null; workbook = Workbook.getWorkbook(new File("/Users/kimgyupyo/project/workspace/kbs6/resuorcemanager_t/src/test/java/data.xls")); int sheetnumber = workbook.getNumberOfSheets(); System.out.println(sheetnumber); Sheet she...
5
public void facePlayer(){ if(main.character!=null){ float dx = main.character.getPosition().x - getPosition().x; if(dx > 0 && isFacingLeft()) changeDirection(); else if (dx < 0 && !isFacingLeft()) changeDirection(); } }
5
public void luoLukija(){ try { lukija = new Scanner(tiedosto); } catch (FileNotFoundException ex) { System.out.println("Tiedostoa ei löydy!"); } }
1
public ListenerManager getListenerManager() { return this.listener; }
0
private void choseFood() { for (int i : RSC.FOOD_IDS) { if (Bank.getItem(i) != null) { foodId = i; break; } } if (foodId == -1) { KingBlackDragon.stop = true; } }
3
public void sendCorrectMessages(Player player, int count) { if (player.hasPermission("idc.keepallitems")) { player.sendMessage(ChatColor.GOLD + plugin.getFiles().ALL_ITEMS_SURVIVED); return; } String itemMessage = plugin.getFiles().ITEMS_MESSAGE_ON_RESPAWN .replace("{0}", count + ""); player.se...
7