text
stringlengths
14
410k
label
int32
0
9
public boolean shellCollideCheck(Shell shell) { if (deadTime != 0) return false; float xD = shell.x - x; float yD = shell.y - y; if (xD > -16 && xD < 16) { if (yD > -height && yD < shell.height) { world.sound.play(Art.samples[Art.SAMP...
7
public ArrayList<Object> findObject(String command, String keywords) throws RemoteException { if(command.equals("userFind")){ return new UserController().find(keywords); } if(command.equals("accountFind")){ return new FinanceController().find(keywords) ; }if(command.equals("getCustomer")){ ArrayList...
5
public static void scanWorlds() { for(World a:Bukkit.getWorlds()) { if(!AddressBook.containsWorld(a.getName())) { AddressBook.writeAddress(a.getName(), new ChevronWorld(a.getName(),a.getName(),"NONE",1,(a.getName().equals("world_nether")? true:false),false,false,false)); File f = new File(data + "/wo...
5
public Ink_Calculator(List<RecParametr> params) { if(params != null) for(RecParametr rp : params) { InkMass im = new InkMass(rp); if(im.GetColor() != record_ink.Unknown) inks.add(im); } }
3
public Object invokeMethod(Reference ref, boolean isVirtual, Object cls, Object[] params) throws InterpreterException, InvocationTargetException { if (isWhite(ref)) return super.invokeMethod(ref, isVirtual, cls, params); MethodIdentifier mi = (MethodIdentifier) Main.getClassBundle() .getIdentifier(ref)...
3
public int rocRLookback( int optInTimePeriod ) { if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) ) optInTimePeriod = 10; else if( ((int)optInTimePeriod < 1) || ((int)optInTimePeriod > 100000) ) return -1; return optInTimePeriod; }
3
public void setInstances(Instances inst) { m_Instances = inst; String [] attribNames = new String [m_Instances.numAttributes()]; for (int i = 0; i < attribNames.length; i++) { String type = ""; switch (m_Instances.attribute(i).type()) { case Attribute.NOMINAL: type = "(Nom) "; break...
7
@Override public ProvaEscrita alterar(IEntidade entidade) throws SQLException { if (entidade instanceof ProvaEscrita) { Connection connection = ConnectionFactory.getConnection(); ProvaEscrita provaEscrita = (ProvaEscrita) entidade; String sql2 = "delete from candidato_...
6
public boolean opEquals(Operator o) { if (o instanceof ConstOperator) { Object otherValue = ((ConstOperator) o).value; return value == null ? otherValue == null : value .equals(otherValue); } return false; }
2
public String getHtmlCode() { return htmlCode; }
0
public int run() { qSortBase(aInt, 0, aInt.length-1); return 0; }
0
public static void finalizeOneClass(Stella_Class renamed_Class) { { Object old$Module$000 = Stella.$MODULE$.get(); Object old$Context$000 = Stella.$CONTEXT$.get(); try { Native.setSpecial(Stella.$MODULE$, renamed_Class.homeModule()); Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella....
9
public Object invoke(Bindings bindings, ELContext context, Class<?> returnType, Class<?>[] paramTypes, Object[] paramValues) { Object base = prefix.eval(bindings, context); if (base == null) { throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix)); } Object property = getP...
8
public Card chooseSeven() { CardArray sevenCards = new CardArray(); for (Card i : cards) if (i.num() == 7) sevenCards.add(i); if (sevenCards.isEmpty()) return null; Card.Suit mSuit = Agonia.findDominantSuit(sevenCards); for (Card i : sevenCards) if (i.suit() == mSuit) { cards.remove(i); ...
5
private List<String> getNumCombinations(String phoneNum) { List<String> numCombinations = new ArrayList<String>(); // Get Position Combinations for Inserting, each combination may form a new set of words List<String> insertPointList = getInsertPositions(phoneNum.length() - 1); Iterator<String> itorator = inse...
3
public List<T> getNextValues() { List<T> values = new ArrayList<T>(); for (int i = 0; i < count(); i++) { values.add(getNextValue(i)); } return values; }
1
public void handleAbilityButtonClick(Ability ability) { panel.getMatchInfoPanel().setSurrenderPending(false); if (inProgress && selectedTile != null) { //Ignore ability button clicks when the match is over. setRange(new Range(this, selectedTile, ability)); } }
2
final void method3669(Canvas canvas, int i, int i_90_) { do { try { anInt8025++; Object object = null; if (canvas == null || canvas == ((NativeToolkit) this).aCanvas7925) object = anObject8020; else if (aHashtable8014.containsKey(canvas)) object = aHashtable8014.get(canvas); if (object == nu...
8
public void transferImage() throws IOException, DBException { VersionDTO version = getVersion(); if (null == version) throw new IllegalStateException("Cannot transfer an image: target version is not set"); if (version.isImageAvailable()) return; InputStream image = null; Logger log = log(); log.fin...
7
private static int rank_recursive(int[] N, int key, int hi, int lo) { if (lo > hi) { return KEY_NOT_FOUND; //base case } int mid = findMidpoint(hi, lo); // find the midpoint if (key < N[mid]) { // the key is in the lower half so lower the upper bound hi = --mid; rank_recursive(N, key, hi, l...
3
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String action = request.getParameter("action"); String nextPage = "showResult.jsp"; String message = "action nulo o invalido"; try { HttpSession session = request.getSession(); switch (ac...
9
public void run(){ try { synchronized(this){ BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream())); String fileName=null; while((fileName=br.readLine())!=null){ break; } System.out.println(fileName); File receivedFile=new File(fileName); ...
4
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for (int i = 0, N = parseInt(in.readLine().trim()); i < N; i++) { in.readLine(); StringTokenizer st = new StringTokenizer(in.readLine().trim()); ...
9
private OutputChannels(int channels) { outputChannels = channels; if (channels<0 || channels>3) throw new IllegalArgumentException("channels"); }
2
public static void printTable(double itemArray[][], int itemNumber[], double unitValue[], DecimalFormat df){ System.out.println("This is the current Item Set: "); System.out.println("Item " + itemNumber[0] + ": $"+itemArray[0][0]+" | "+itemArray[1][0]+" lbs"); System.out.println("Item " + itemNumber[1] + ": $"+it...
1
public int getRandom() { return this.random; }
0
private static Collection<Circle> filterFinalScoreCheck(ShortImageBuffer edgeImage, Collection<Circle> input) { Collection<Circle> output = new ArrayList<>(input.size()); for (Circle original : input) { List<Circle> permutations = new ArrayList<>(input.size()); for(in...
3
public State stateAtPoint(Point point) { State[] states = getAutomaton().getStates(); // Work backwards, since we want to select the "top" state, // and states are drawn forwards so later is on top. for (int i = states.length - 1; i >= 0; i--) if (point.distance(states[i].getPoint()) <= StateDrawer.STATE_RAD...
2
@Override public String howMuch(String item, String client, String market) { logger.info("Calculating expected time to delivery. " + "item " + item + ", client " + client + ", market " + market); // business rule: delivery date depends of the market last letter // business rule: delivery date depends of ...
8
public static void main(String[] args) { Scanner in = null; // for input PrintStream out = null; // for output BasicMapADT<String, Entry> concord = new BSTBasicMap<String, Entry>(); // the concordance File inFile = null; //store input fil...
9
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 void giveHint(String target, String hint) throws HanabiException { if (hintsLeft <= 0) { throw new HanabiException("No hints left; discard or play a card instead"); } int seatNumber = Integer.parseInt(target); if (seatNumber < 0 || seatNumber >= seats.size()) { throw new HanabiException("Invali...
9
public void affiche(Graphics g) { if (type == TYPE.HEAL) { g.setColor(Color.green); String text = "+" + Integer.toString(value); int width = g.getFont().getWidth(text); int height = g.getFont().getHeight(text); if (perso != null) g.draw...
7
private String getFormatString(TextureFormat _format) { switch(_format){ case PNG: { return "PNG"; } case JPG: { return "JPG"; } case GIF: { return "GIF"; } case TGA: { return "TGA"; } default: { //TODO: Error, texture type not supported. Return error texture. return...
4
public static synchronized ArrayList<Stock> addStock(String tickername, ArrayList<Stock> stocks) { stocks = DataReader.getStocks(); double price = 0; tickername = tickername.toUpperCase(); try { price = PriceUpdater.price(tickername); } catch (Exception e) { System.out.println("The tickername you ent...
3
public IVideo createVideo(String path) { if(getExtension(path).equals("wmv")) { return new VideoWMV(path); } else { return null; } }
1
public Font(String s){ location = new File(s); if(!location.exists()){ Util.ERRORCODE2();} else { File[] listOfFiles = location.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { try { String files = listOfFiles[i].getName(); if (files.length() > 4 && files.substring(files...
5
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: String usuario = tf_usuario.getText(); String pass = tf_pass.getText(); Usuario u = new Usuario(); u.setRut(Integer.parseI...
2
protected void read(File file) throws IOException{ String tempFile = ""; if(file.isDirectory()){ if(file.list().length==0){ }else{ String files[] = file.list(); for (String temp : files) { File fileDelete = new File(file, temp); read(fileDelete...
4
public boolean tieneSiguiente(){ boolean resp = false; if(siguiente != null) resp = true; return resp; }
1
public void unmutePlayer(Client c, String name){ if (!isOwner(c)) { c.sendMessage("You do not have the power to do that!"); return; } if (clans[c.clanId] != null) { for (int j = 0; j < clans[c.clanId].mutedMembers.length; j++) { for(int i = 0; j < Config.MAX_PLAYERS; i++) { if (Server.playerHand...
7
private void userTypeJComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_userTypeJComboBoxItemStateChanged // TODO add your handling code here: String selected_user_type = String.valueOf(userTypeJComboBox.getSelectedItem()); /** *If the the user type selected is a ...
2
public boolean interact(Level level, int x, int y, Player player, Item item, int attackDir) { if (item instanceof ToolItem) { ToolItem tool = (ToolItem) item; if (tool.type == ToolType.shovel) { if (player.payStamina(4 - tool.level)) { level.add(new ItemEntity(new ResourceItem(Resource.flower), x * 16 ...
3
@Override public void unInvoke() { if(canBeUninvoked()) { if(affected instanceof MOB) { final MOB mob=(MOB)affected; if((buildingI!=null)&&(!aborted)) { if(messedUp) { if(activity == CraftingActivity.LEARNING) commonEmote(mob,L("<S-NAME> fail(s) to learn how to make @x1.",...
7
@Override public synchronized void destroy() throws Exception { if (isActive()) doStop(); closeConnections(); doDestroy(); }
1
public static void main (String args[]) { boolean homefound = false; String localgame = ""; int na = 0; int move = 0; while (args.length > na) { if (args.length - na >= 2 && args[na].startsWith("-h")) { Global.home(args[na + 1]); na += 2; homefound = true; } else if (args[na].starts...
8
private int selectInvertColors(invertColorsAvailable chanelInvert, Color color){ int colorReturn=0; switch (chanelInvert){ case RGB: colorReturn=super.colorRGBtoSRGB(new Color(255-color.getRed(), 255-color.getGreen(), 255-color.getBlue(),color.getAlph...
4
@Override public boolean wipeTable(String table) { Connection connection = open(); Statement statement = null; String query = null; try { if (!this.checkTable(table)) { this.writeError("Error at Wipe Table: table, " + table + ", does not exist", true); return false; } statement = connection.cr...
5
private void gameKeyReleased(int key){ switch(key){ case KeyEvent.VK_W: //UP break; case KeyEvent.VK_S: //DOWN break; case KeyEvent.VK_A: //LEFT mainModel.wilbert.stopMoveLeft(); break; case KeyEvent.VK_D: //RIGHT break; case KeyEvent.VK_SPACE: //JUMP mainModel.wilbert.getBo...
9
public int size() { return N; }
0
private RequestDispatcher goSetting(HttpServletRequest request, HttpServletResponse response) throws ServletException{ if(request.getParameter("oldpwd")!=null&&request.getParameter("newpwd")!=null&&request.getParameter("newpwd2")!=null){ try { if(DB.passwordCorretta(((Utente)request....
6
public int converterParaInteiro(String romano) { int numeroConvertido = 0; int tamanhoString = romano.length(); int iteracao = 0; while(true){ if(romano.charAt(iteracao) == 'M') numeroConvertido += 1000; if(romano.charAt(iteracao) == 'D') numeroConvertido += 500; if(romano.charAt(iteraca...
8
public Node getNode() { return this.node; }
0
@Override public int insertOne(String strTabla) throws Exception { ResultSet oResultSet; java.sql.PreparedStatement oPreparedStatement; int id = 0; try { String strSQL = "INSERT INTO " + strTabla + " (id) VALUES (null) "; oPreparedStatement = oConexionMySQL.pr...
2
void savefile() { // FrontEnd.statuswindow.append("Saving File...\n"); FrontEnd.appendToPane(FrontEnd.statuswindow,"Saving File...\n",Color.BLACK); //frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length()); int id = FrontEnd.EditorPane.getS...
6
private static void winCondition() { // If the alien and the predator are on the same node if (ship.getAlienNode().equals(ship.getPredatorNode())) { // prints to the status bar uigui.changeWinStatus(" The Alien Wins"); ...
3
void printFrequency(String filename){ HashMap m=new HashMap(); char c[]=new FileReadHelper().readFile(filename); for(int count=0;count<c.length;count++){ if( m.containsKey(String.valueOf(c[count]))){ Integer value = (Integer) m.get(String.valueOf(c[count])); value=value+1; m.put(String.valueOf...
3
private boolean check() { if (N == 0) { if (first != null) return false; } else if (N == 1) { if (first == null) return false; if (first.next != null) return false; } else { if (first.next == null) return false; } ...
8
public int tapes() { return tapes; }
0
public static boolean isTypeCollection(Class<?> type) { return (type != null && isAssignable(type, Collection.class)); }
2
static int f(int p, boolean[] v, int c){ if(p==vis.length)return prim(v)+c; boolean[] cp=new boolean[v.length]; int min=MAX_VALUE; for(int i=0;i<v.length;i++) for(int j=0;j<v.length;j++) if(v[i]&&vis[p][j])min=Math.min(min,mAdy[i][j]); for(int i=0;i<v.length;i++)cp[i]=v[i]||vis[p][i]; return Math.min...
8
@Override public boolean isMine(String command) { if (super.isMine(command)) { if ((command.indexOf("[") == -1) || (command.indexOf("]") == -1)) { error = hint; return false; } jsonStr = command.substring(command.indexOf("["), command.lastI...
3
public static List<String> getFileNames(String prefix, String suffix, String language, String country, String variant) { List<String> result = new ArrayList<String>(4); if (!language.equals("")) { language = "_" + language; } if (...
6
public FileIOException(Exception e, String name) { super(e, name); }
0
public void run() { if (!mClient.connect()) { return; } Scanner scan = new Scanner(System.in); boolean running = true; while(running) { StringBuilder sb = new StringBuilder(); sb.append(sUserActions[0]); for(int i=1; i<sUserActions.length; i++) { sb.append(", "); sb.append(sUserActions[i...
9
public boolean checkIfHasSameName(String uuid, String metaname){ if(plugin.getAnimalData().getString("Farmer."+ uuid + ".Animals") == null){ return true; } Set<String> auuids = plugin.getAnimalData().getConfigurationSection("Farmer."+ uuid + ".Animals").getKeys(false); for(String auuid : auuids){ String c...
3
public void discoverChildren() { GsSong[] songs=null; if(album!=null) songs=album.getSongs(); if(artist!=null) songs=artist.getSongs(); if(playlist!=null) { File f=new File(playlist.saveFile()); if(useFile) songs=readFile(f); else { songs=playlist.getSongs(); savePlaylist(songs,f);...
5
@SuppressWarnings("unchecked") private List<List<Gate>> getLayersOfGates(List<Gate> gates) { List<List<Gate>> layersOfGates = new ArrayList<List<Gate>>(); initMaps(gates); int totalNumberOfInputs = circuitParser.getNumberOfInputs(); /* * Loop to run through each list in our MultiMap, first runs through all...
6
@Override public void actionPerformed(ActionEvent event) { if (!event.getSource().equals(back)) { try { Item item = (Item) inventory.getSelectedValue(); int indexNumber = inventory.getSelectedIndex(); int itemNumber = item.getIDNumber(); if...
7
private Mark makeMark0(HashMap table, int pos, boolean isBlockBegin, boolean isTarget) { Integer p = new Integer(pos); Mark m = (Mark)table.get(p); if (m == null) { m = new Mark(pos); table.put(p, m); } ...
4
public Connection createConnection() { if (use_MySQL) { try { Class.forName("com.mysql.jdbc.Driver"); cn = DriverManager.getConnection("jdbc:mysql://" + plugin.getConfig().getString("dbPath"), plugin.getConfig().getStri...
8
private void loadPositions(Path baseDir) throws IOException { Path provinceDefinitionsPath = getFilePath(MapFile.POSITIONS, baseDir); Pattern pattern = Pattern.compile("(\\d+)="); Map<Integer, Province> provincesById = getProvincesById(); try(BufferedReader reader = Files.newBufferedRea...
6
@Override public void mouseReleased(MouseEvent e) { isMouseDown = false; }
0
public OfflinePlayer getStoreOwner(Chest chest){ if(chest==null) return null; return stores.get(chest).getOwner(); }
1
public synchronized void init() throws IOException { int nPieces = new Double(Math.ceil((double)this.totalLength / this.pieceLength)).intValue(); this.pieces = new Piece[nPieces]; this.completedPieces = new BitSet(nPieces); this.piecesHashes.clear(); logger.debug("Analyzing local data for " + this.getN...
3
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { processRequest(request, response); } catch (Exception ex) { Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex); ...
1
public static int longestValidParentheses(String s) { int maxLen = 0, last = -1; Stack<Integer> lefts = new Stack<Integer>(); for (int i=0; i<s.length(); ++i) { if (s.charAt(i)=='(') { lefts.push(i); } else { if (lefts.isEmpty()) { ...
4
private File search(File current, FileFilter filter) { if (current.isDirectory()) { File[] expected = current.listFiles(filter); if (expected != null) { if (expected.length > 0) { // found return expected[0]; } else { for (File f : iterateOver(current)) { File found = search(f, fi...
5
private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) { int rounds, i, j; int cdata[] = (int[])bf_crypt_ciphertext.clone(); int clen = cdata.length; byte ret[]; if (log_rounds < 4 || log_rounds > 31) throw new IllegalArgumentException ("Bad number of rounds"); rounds = 1 << log_rounds; ...
7
/* */ public void handleDirection(int targetX, int targetY) /* */ { /* 75 */ double hitX = this.hitCheck.getX2(); /* 76 */ double hitY = this.hitCheck.getY2(); /* */ /* 78 */ if (this.y < hitY) { /* 79 */ if (this.x > hitX) { /* 80 */ if (Math.abs(this.x - hitX) > Math.ab...
7
private static long makelong(byte[] x) { long y = 0L; for(int i = 0; i < x.length; i++) { y += ((long)x[i]) << (8*i); } return y; }
1
public boolean deleteNode(E data) { BinaryTreeNode<E> node = findNode(data); if (node == null) { return false; } if (node.left == null && node.right == null) { // Deleting the leaf node replaceNodeWithChild(node, null); } else if (node.left == ...
6
int dinicDfs(int[] ptr, int[] dist, int dest, int u, int f) { if (u == dest) return f; for (; ptr[u] < ady[u].size(); ++ptr[u]) { Edge e = ady[u].get(ptr[u]); if (dist[e.t] == dist[u] + 1 && e.f < e.cap) { int df = dinicDfs(ptr, dist, dest, e.t, Math.min(f, e.cap - e.f)); if (df > 0) ...
5
private void dfs(EdgeWeightedDigraph G, int v) { onStack[v] = true; marked[v] = true; for (DirectedEdge e : G.adj(v)) { int w = e.to(); // short circuit if directed cycle found if (cycle != null) return; //found new vertex, so recur e...
5
public void loadFromFile() throws Exception{ String filename = "Girl.bin"; File file = new File(filename); FileInputStream fis = new FileInputStream(file); ObjectInputStream ois = new ObjectInputStream(fis); try{ Object temp = ois.readObject(); if(temp.getClass().getName().equals("Girl")){ ghead = (...
2
public void setRound(int round) { this.round = round; notifyListeners(); }
0
public void mouseReleased(MouseEvent e) { }
0
public boolean contains(E target) { DoubleLinkedListElement tmp = head; for (int i = 0; i < size(); i++) { if(tmp!=null && tmp.data.equals(target)) return true; tmp = tmp.nextElement; } return false; }
3
public Object scalar() //to fetch single value { ResultSet rs=null; Object s=null; try { rs=ps.executeQuery(); if(rs.next()) { s=rs.getObject(1); } }catch(Excepti...
8
public boolean addAll(Collection<? extends Car> c) { if((c.size() + list.size()) > maximum){ return false; } list.addAll(c); return true; }
2
public CheckResultMessage checkSum4(int i,int j){ return checkReport1.checkSum4(i,j); }
0
public boolean equals(Object _other) { if (_other == null) { return false; } if (_other == this) { return true; } if (!(_other instanceof BillDetailsPk)) { return false; } final BillDetailsPk _cast = (BillDetailsPk) _other; if (billId != _cast.billId) { return false; } if (u...
7
public boolean getBoolean(String key) throws JSONException { Object object = this.get(key); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String) object) .equalsIgnoreCase("false"))) { return false; } else if (object.equals...
6
private void AddTextElementToRulesList(TranscriptionRulesElement textElement) { //At first we need to validate whether the rule element has the minimum required data. if (textElement!=null && textElement._text.length()>0) { if (_rules==null) { //If this is the first rule in the list: _rules = textE...
7
@Override public void paintComponent(Graphics g) { // lancement de la musique de fond SoundEffect.MUSIC.playLoop(); super.paintComponent(g); g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), this); int nbLosers = 0; int winner = 0; for(int i = 0; i < p...
9
public void quickSort(Integer[] values, int start, int length) { // Check for empty or null array if (values == null || values.length == 0) { return; } if (length == 0 || (start - length) == 0) { return; } int p = pivot.ChoosePivot(values, start, length - 1); int i = partition(values, p, length); ...
6
public boolean rotate(Polyomino poly){ //Allows for wall kicks for (int i=0; i<=poly.getLength()/2; i=(i<=0)?(-i+1):(-i)){ boolean canRotate=true; for (Point loc:poly.getRotateAndTranslateLocs(i,0)){ if (loc.y<0 || loc.x<0 || loc.x>=fWidth || ...
8
public SignedInfoType getSignedInfo() { return signedInfo; }
0
private void SaveTimestampDiffsToFile(HashMap<Integer, String> hashMap) { try ( OutputStream file = new FileOutputStream("timestamps.ser"); OutputStream buffer = new BufferedOutputStream(file); ObjectOutput output = new ObjectOutputStream(buffer);) { o...
1
public static void process(String s, int durationInMillis) { if(!process) return; try { Thread.sleep(durationInMillis); } catch (InterruptedException e) { // ignore } }
2