text
stringlengths
14
410k
label
int32
0
9
* @return the given api command string with the binding environment for bookkeeping assertions */ public String wrapBookkeeping(String command) { final String projectName = (project == null) ? "nil" : project.stringApiValue(); final String cyclistName = (cyclist == null) ? "nil" : cyclist.stringApiValue();...
2
public ArrayList<Token> tokenize(char[] array){ ArrayList<Token> tokens = new ArrayList<Token>(); StringBuilder cur = new StringBuilder(); for(int i=0;i<array.length;i++){ if(CharUtil.isNumber(array[i])){ cur.append(array[i]); } else { if(cur.length() > 0 ){ tokens.add(new Token(cur.toString())...
8
public static void main (String[] args) { int accumulator = 0; String choice = "y"; while (choice.equalsIgnoreCase("y")) { //Welcome statement to the user. System.out.println("Welcome to the Guess Number Game"); System.out.println("++++++++++++++...
6
public static void testThis(String[] args) { boolean decode = false; if (args.length == 0) { System.out.println("usage: java Base64 [-d[ecode]] filename"); System.exit(0); } for (int i=0; i<args.length; i++) { if ("-decode".equalsIgnoreCase(args[i])) decode = true; else if ("-d".equalsIgnoreCase(...
6
public static ArraysDataBase getStructureBase(){ return structuresBase; }
0
@Override public boolean execute(SimpleTowns plugin, CommandSender sender, String commandLabel, String[] args) { final Localisation localisation = plugin.getLocalisation(); if (!(sender instanceof Player)) { sender.sendMessage(localisation.get(LocalisationEntry.ERR_PLAYER_ONLY_COMMAND))...
9
public static Preferences creerPrefConsole(){ String[] basePrefs = {"Conversation", "Musique", "Animaux", "Fumeur"}; Preferences listePrefs = new Preferences(); Scanner sc = new Scanner(System.in); System.out.println("Répondez avec 'o' ou 'n'."); for(String s : basePrefs){ System.out.print(s+" ? "); ...
4
public void actionPerformed(ActionEvent e) { if (e.getSource() == Cancel) { this.dispose(); } else if (e.getSource() == Ok) { updateArgs(); this.dispose(); } }
2
@Action(name = "hcomponent.handler.onclick.param", args = {}) public void onClickAction(Updates updates, String param) { HComponent<?> html = (HComponent<?>) Session.getCurrent().get( "_hcomponent.object." + param); if (html.getOnClickListener() != null) ContentManager.requestParams( "hcomponent.handle...
3
private Response handleRequest(String url) { Response r = new Response(); try { URL u = new URL(url); HttpURLConnection conn = (HttpURLConnection) u.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/json"); if (conn.getResponseCode() != 200) { System....
5
private GlobalTimes() { }
0
private JTextArea getTextAreaMain() { if (textAreaMain == null) { textAreaMain = new JTextArea(); } return textAreaMain; }
1
public returnTypes deleteFile(byte[] fileID) { String recID = Packet.bytesToHex(fileID); for(BackupFile file : files) { String comID = Packet.bytesToHex(file.getFileID()); if(comID.equals(recID)) { new File (file.getFilename()).delete(); boolean success = files.remove(file); if(success) { upd...
3
public IPokemon getCorrectPokemon(boolean isPlayer) { return isPlayer ? getPlayer().getPokemon() : enemy; }
1
@Override public void propertyChange(PropertyChangeEvent pce) { String propName = pce.getPropertyName(); if (propName.equals("progress")){ int value = ((Integer)pce.getNewValue()).intValue(); if (value >= minValue && value <= maxValue){ setValue(value); label.setText(" Выполнено :" + value +...
6
public TasoTest() { }
0
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Save")) { finish(); } else if (e.getActionCommand().equals("Undo")) { undoredo(e.getActionCommand()); setFocusOnTxtArea(); } else if (e.getActionCommand().equals("Redo")) { undoredo(e.getActionCommand()); setFo...
6
public Book getBook(long id) { Book book = null; Connection con = null; Statement stmt = null; try { DBconnection dbCon = new DBconnection(); Class.forName(dbCon.getJDBC_DRIVER()); con = DriverManager.getConnection(dbCon.getDATABASE_URL(), ...
5
public void drawGrid(Graphics g) { g.setColor(Color.black); for (Point p: this.maze.cells) { p = this.imagify(p); g.drawRect(p.x, p.y, this.cellWidth, this.cellWidth); } }
1
private int getLargestList(List<ArrayList<CellState>> lists){ int i = -1; for(ArrayList<?> list: lists){ if(i == -1){ i = list.size(); }else{ if(i < list.size()) i = list.size(); } } return i; }
4
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed this.setVisible(false); }//GEN-LAST:event_okButtonActionPerformed
0
public Class getTypeClass() { switch (((IntegerType) getHint()).possTypes) { case IT_Z: return Boolean.TYPE; case IT_C: return Character.TYPE; case IT_B: return Byte.TYPE; case IT_S: return Short.TYPE; case IT_I: default: return Integer.TYPE; } }
5
private static int getStart( String string ) { for ( int i = 0; i < string.length(); ++i ) { if ( isBreaker( string.charAt( i ) ) == false ) { return i; } } return -1; }
2
@Override public void mouseClicked(MouseEvent arg0) { if( arg0.getSource()==botonJugar){ this.dispose(); vJuego juego= new vJuego(null,JTBlancas.getText(),JTNegras.getText()); juego.setVisible(true); } if(arg0.getSource()==botonVolver) { this.dispose(); vInicio inicio= new vInicio(); inic...
2
@Override public boolean allowSource( ConnectionableCapability item, ConnectionFlavor flavor ) { if( item == this ){ return false; } return isComment( flavor ); }
1
private JButton getBtnClear() { if (btnClear == null) { btnClear = new JButton("Clear"); btnClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { textAreaMain.setText(""); } }); btnClear.setBounds(10, 222, 89, 23); } return btnClear; }
1
public static void setPageSize(PrintService service, PrintRequestAttributeSet set, double[] size, LengthUnits units) { PageOrientation orientation = getPageOrientation(service, set); if (orientation == PageOrientation.LANDSCAPE || orientation == PageOrientation.REVERSE_LANDSCAPE) { size = new double[] { size[1]...
2
public String getCityCode() { return cityCode.get(); }
0
@Override public int compareTo(Object ob){ Event e = (Event) ob; if(this.time < e.getTime()){ return -1; } if(this.time > e.getTime()){ return 1; } return 0; }
2
public static String concatenateUsingStringBuffer(String[] stringArray, String delimiter) { if (delimiter == null || stringArray == null || stringArray.length == 0) { return null; } StringBuffer result = new StringBuffer().append(stringArray[0]); for (int i = 1; i < string...
4
public void test_convertText() { BaseDateTimeField field = new MockPreciseDurationDateTimeField(); assertEquals(0, field.convertText("0", null)); assertEquals(29, field.convertText("29", null)); try { field.convertText("2A", null); fail(); } catch (Illegal...
2
public void updateID() { if(ID == 0) { int x = 1; while(Item.validID(Integer.parseInt((itemTypeCombo.getSelectedIndex() + 1) + "" + x))) { x++; } IDText.setText((itemTypeCombo.getSelectedIndex() + 1) + "" + x); } }
2
public List<Aim> getDirections(Tile t1, Tile t2) { List<Aim> directions = new ArrayList<Aim>(); if (t1.getRow() < t2.getRow()) { if (t2.getRow() - t1.getRow() >= rows / 2) { directions.add(Aim.NORTH); } else { directions.add(Aim.SOUTH); ...
8
private static URI removeDotSegments(URI uri) { String path = uri.getPath(); if ((path == null) || (path.indexOf("/.") == -1)) { // No dot segments to remove return uri; } String[] inputSegments = path.split("/"); Stack<String> outputSegments = new Stack<S...
9
protected void keyTyped(char par1, int par2) { this.serverName.textboxKeyTyped(par1, par2); this.serverAddress.textboxKeyTyped(par1, par2); if (par1 == 9) { if (this.serverName.getIsFocused()) { this.serverName.setFocused(false); ...
7
private String indexToMsg(int i) { switch (i){ case 0: return "bid"; case 1: return "password"; case 2: return "name"; case 3: return "address"; case 4: return "phone"; case 5: return "email address"; case 6: return "sin or student #"; case 7: return "expiry date (yyyy/mm/dd)"; case 8: return "type...
9
public int pop() { while (!isEmpty()) { temp.push(super.pop()); } int ret = temp.pop(); while (!temp.isEmpty()) { push(temp.pop()); } return ret; }
2
public AudioInfo(DataInputStream f) throws Exception { byte [] buffer; if (f.readInt() != 779248125) //['.', 'r', 'a', 0xfd] throw new InvalidSequenceException("AudioCodec info has wrong header"); version = f.readShort(); //word Version (3, 4 or 5) if (version < 3 || version > 5) throw new Unsupported...
9
public void contract(Edge edge) { if (Debug.ON) { System.out.println("Contracting "); System.out.println("Choosing Edge " + edge.tail.id + " -- " + edge.head.id); } // THE FOLLOWING CODES MUST BE CHANGED WHEN DEALING WITH DIRECTED GRAPH int group = -1; if (edge.tail.gid != -1) { group = edge....
9
public void initPF() { int allowed_width = winwidth + crop_left + crop_right; int allowed_height = winheight + crop_top + crop_bottom; // these came from the canvas constructor viewnrtilesx=nrtilesx; viewnrtilesy=nrtilesy; if (prescale) { scaledtilex = allowed_width / nrtilesx; scaledtiley = allowed_h...
8
public int func_27371_a(StatCrafting var1, StatCrafting var2) { int var3 = var1.func_25072_b(); int var4 = var2.func_25072_b(); StatBase var5 = null; StatBase var6 = null; if(this.slotStatsItemGUI.field_27271_e == 0) { var5 = StatList.objectBreakStats[var3]; var6 = StatLi...
8
protected HttpParams getParams() { final HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, TIMEOUT); HttpConnectionParams.setSoTimeout(params, TIMEOUT); HttpConnectionParams.setSocketBufferSize(params, BUFFER_SIZE); ConnManagerParams.set...
3
static boolean fillEmptyCell (Cell[][] board) { boolean flag = false; for (int x = 0; x < 9; x++) { for (int y = 0; y < 9; y++) { if (board[x][y].getCellValue() == 0 && board[x][y].possibleValues.size() == 1) { board[x][y].setCellValue(board[x][y].possibleValues.get(0)); flag = true; } } }...
4
public final byte getBiomeID(){ if(currentChunk == null)return -1; return currentChunk.getBiomeID((int)getX(), (int)getZ()); }
1
@Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); spriteBatch.setProjectionMatrix(camera.combined); if (!assetManagerController.update()) { }else { if (once) { once = false; } ...
5
public JTextField getjTextFieldDateRapport() { return jTextFieldDateRapport; }
0
private void pickChecker(int player, int column) { if ((column < -1) || (column > NUM_POINTS)) { System.err.println("Error, out of range."); } else { // column -1 means the table! // So if a checker is transfered from the column -1, it is simply put in the game. ...
6
public static void main(String[] args) { BigInteger bi = new BigInteger("2"); bi = bi.pow(1000); String s = bi.toString(); ArrayList<Integer> arr = new ArrayList<Integer>(); for(int i = 0; i < s.length(); i++) { arr.add((int) (s.charAt(i) - '0')); } int res = 0; for(int i : arr) { ...
2
public String nextToken() throws JSONException { char c; char q; StringBuffer sb = new StringBuffer(); do { c = next(); } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; for (;;) { c = next(); ...
9
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; ...
5
public void update() { long time = System.currentTimeMillis(); float delta = time - lastupdate; lastupdate = time; if (position.getX() > GAME_WIDTH || position.getX() < 0 || position.getY() > GAME_HEIGHT || position.getY() < 0 || schritte >= projectileMaxDistace) { Server.pro...
5
private DataBase getDataBaseByKey(String key) throws DBUnavailabilityException { for (Pattern regexp : databases.keySet()) { Matcher matcher = regexp.matcher(key); if (matcher.find()) { return databases.get(regexp); } } throw new DBUnavailabili...
2
public boolean disconnect(){ try { con.close(); } catch( SQLException e ){ if( debug ) System.out.println("Error in DataBaseConnection.disconnect(): "+e.getMessage()); return false; } return true; }
2
@Override public void downloadPlaylist(final String playlistUrl, final String destinationFolder, final Mp3Metadata metadata) { String playlistString = null; try { final long setId = getApi().resolve(playlistUrl); final HttpResponse setResponse = getApi().get(new Request(String.format(Constants.PLAYLIST_URL, ...
2
@Override public void run() { synchronized (numberOfActiveProducersLock) { numberOfActiveProducers++; } Random rnd = new Random(); try { for (int i=1; i<=maxItemsToProduce; i++) { if (warehouse.isFull()) { break; //stop producing when warehouse is full } int producedItem = rnd.next...
3
public int getAttributeType(String name, String aname) { Object attribute[] = getAttribute(name, aname); if (attribute == null) { return ATTRIBUTE_UNDECLARED; } else { return ((Integer) attribute[0]).intValue(); } }
1
private void addToTextArea() { if (!(jTextField1.getText().equalsIgnoreCase("") || jTextField1.getText() == null)) { jTextArea1.append(jTextField1.getText() + "\n"); } control.sendMessage(jTextField1.getText()); jTextField1.setText(null); }
2
public void setGridSize(int rows, int columns, boolean preserveData) { if (rows > 0 && columns > 0) { Color[][] newGrid = new Color[rows][columns]; if (preserveData) { int rowMax = Math.min(rows,this.rows); int colMax = Math.min(columns,this.columns); ...
5
public void removeVertex(Vertex v) { vertices.delete(v); adjacencyList.removeVertex(v); }
0
private void maj_pos_robot(int x, int y, double teta) { //mm vers pixel -> *119/600 terrain.robot.X = x*119/600; terrain.robot.Y = y*119/600; terrain.robot.teta = teta; terrain.repaint(); }
0
public MainFrame(String username, String ip, int port) { super("Chat - " + username + " [" + ip + ":" + port + "]"); this.username = username; this.ip = ip; this.port = port; packetFactory = new PacketFactory(ip, port); doAesthetics(); setVisible(true); ...
0
@Override public boolean equals(final Object obj) { if(!(obj instanceof Edge)) { return false; } final Edge o = (Edge) obj; return start == o.start && end == o.end && dot == o.dot && lhs.equals(o.lhs) && Arrays.equals(rhs, o.rhs) && children.equals(o.children); ...
6
public IRegion getDamageRegion( ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged) { if (!documentPartitioningChanged) { try { IRegion info = fDocument.getLineInformationOfOffset(event.getOffset()); int start = Math.max(partition.getOffset(), info.getOffset()); ...
5
@Override public boolean equals(Object aObject) { if (this == aObject) return true; if (aObject == null || getClass() != aObject.getClass()) return false; Vector4d vector4d = (Vector4d) aObject; if (Double.compare(vector4d.w, w) != 0) return false; if (Double.compare(vector4d.x, x) != 0) return ...
7
public List<User> getFollowers(String email) { Connection connection = null; List<User> followerList = new ArrayList<User>(); String query = null; PreparedStatement statement = null; try { connection = dataSource.getConnection(); query = "SELECT users.email, users.username FROM follows INNE...
3
public void recieveCommand(Commands command) { if (command == null) { return; } switch (command.getType()) { case Commands.LOGIN: logon((LoginCommand)command); break; case Commands.LOGOUT: logout(); break; case Commands.WHISPER: whisper((WhisperCommand)command); break; case Commands....
7
public int getInitialHeight() { return initialHeight; }
0
public void pressbutton() { Timetable_main_RWRAF.read(Homework_database_edit_1.getn()); int ID = (Timetable_main_RWRAF.getID()); String subject = (String)Subject.getSelectedItem(); String desc = DescField.getText(); String difficulty = (String)DiffField.getSelectedItem(); int time = Integer.parseInt((String)Timef...
1
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 static boolean findPath(int[][] maze, int x, int y, int targetx, int targety) { // base case or exit condition : reached the target if(x == targetx && y == targety) { return true; } else { // check if x and y are in the limits && x,y does not hit a wall ...
8
private void quicksort(Integer menor, Integer maior) throws NaoOrdenavel { Integer i = menor, j = maior; Elemento pivo = elementos[menor + (maior - menor) / 2]; try { while (i <= j) { while (pivo.compareTo(elementos[i]) > 0) { i++; ...
7
protected static boolean checkResource(Resource resource) { boolean isValid; if (isValid = resource != null) { isValid = TYPES.contains(resource.getType()); isValid = isValid && resource.getProperty(HOST_PROPERTY) != null; isValid = isValid && resource.getProperty(USE...
4
@Override public Path compute(TSPInstance tsp, Path beginPath, ComputationCallback callback) { final int count = tsp.count(); if (count <= paramP) { throw new IllegalArgumentException( "Impossible to solve the tsp: tsp.count <= paramP! tsp.count = " ...
8
public static void loadImage(String url, String galleryName) { try { String src = prefixSrc; src += galleryName; src += "\\"; String imgName = getFileName(url); src += getFileName(url); addImgToXmlData(imgName, galleryName); Buf...
2
public InputStream stream(String url) throws IOException { int redirects = 0; URLConnection conn; do { conn = LLHttpClient.connect(proxy(), "GET", url, connectTimeOut, readTimeOut, headers()); url = check(cookies(conn)); redirects++; } while (follow && url != null && redirects < 5); ...
8
public List getAxiom() { return axiom; }
0
public static boolean initNetworkType(int networkType) { boolean result = true; switch(networkType) { case GridSimTags.NET_PACKET_LEVEL: GridSimCore.NETWORK_TYPE = GridSimTags.NET_PACKET_LEVEL; break; case GridSimTags.NET_FLOW_LEVEL: ...
3
private void cmd_take(final String arg, final Client client) { final Player player = getPlayer(client); final Room room = getRoom( player.getLocation() ); final String[] args = arg.split(" "); debug("" + args.length); // if there is no argument, report command syntax if (arg.equals("")) { send("Syntax...
9
public Obstacle(String key, int x, int y) { genObstacle tmp; try { tmp = (genObstacle) genObstacle.obsMapping.get(key); } catch (IllegalArgumentException e) { tmp = new genObstacle(-1,false,false,0); // ID = 0 collision, visible, hurting } if (tmp != null) { super.n = tmp.getID(); super.collision...
2
@Override public void restoreTemporaryToDefault() {tmp = def;}
0
@Override public void spring(MOB target) { if(target.location()!=null) { if((!invoker().mayIFight(target)) ||(isLocalExempt(target)) ||(invoker().getGroupMembers(new HashSet<MOB>()).contains(target)) ||(target==invoker()) ||(doesSaveVsTraps(target))) target.location().show(target,null,null,CMMs...
7
@Override public void mouseReleased(MouseEvent arg0) { this.drag = false; if(curTool == 3) { hp.apply(); } hp.setDrag(null); view.updateHeightmap(hp.getTexture()); }
1
public void setAccessToken(String accessToken) { this.accessToken = accessToken; }
0
public static void build() { Plugin larvikGaming = Bukkit.getServer().getPluginManager().getPlugin("LarvikGaming"); list.plugin = Bukkit.getServer().getPluginManager().getPlugins(); list.pos = Bukkit.getServer().getPluginManager().getPlugins().length; String fileDest = larvikGaming.getConfig().getString("FileDi...
5
public void send() { String msg = msg_box.getText(); if (msg == null || msg.equals("") || msg.equals("\n")){ msg_box.setText(""); return; } if(enterIsSend){ msg = msg.substring(0, msg.length()-1); } if (msg.startsWith("@")) { String to = msg.split(" ")[0].substring(1); msg = msg.substring(...
5
public String getGestureName() { return gestureName; }
0
@SuppressWarnings("resource") static Fraction[][] getMatrix ( String filename ){ int rowBuffer = 30; int columnBuffer = 30; Fraction[][] matrixBuffer = new Fraction[rowBuffer][columnBuffer]; int rowCt = 0; int columnCt = 0; try { Scanner sc = new Scanner( new File( filename...
8
public Double[] getYVal() { return yVal; }
0
List<byte[]> getPasswordBytes(boolean unicodeConversion) { // TODO - handle unicodeConversion when we support version 5 if (this.passwordBytes != null || this.passwordString == null) { return Collections.singletonList(this.passwordBytes); } else { if (isAlphaNum7BitString...
3
public void setBLXElement(BLXElement blxElement) { super.setBLXElement(blxElement); Element _myElement = blxElement.getDataElement(); //MasterTile Element not found set Defaults if(_myElement == null) { setGridLocation(TOP_LEFT); setClosed(false); setIsDirty(true); return; ...
9
private Method_GetDebugInfo(VirtualMachineImpl vm, PacketStream ps) { maxIndex = ps.readInt(); final SourceFile[] sourceFiles; if(vm.isAtLeastVersion(2, 13)) { int count = ps.readId(); sourceFiles = new SourceFile[count]; for(int i = 0; i < count; i++) { sourceFiles[i] = new SourceFile(); s...
8
private void PageRedirect(String itemID, String itemType, String query, boolean DisplayGO, boolean organismdependentquery) { if (applet == null || configuration == null) return; String wholeredirectionString = getRedirectionString(itemID, itemType, query, DisplayGO, organismdependentquery...
8
private void getParameters(Keyword method, String[] argument) throws Exception { parameters.put(Keyword.METHOD, method.toString().toLowerCase()); startType = TimeType.NONE; endType = TimeType.NONE; String key, value; Keyword argType; for (int i = 0; i < argument....
8
public ClientOutputThread(Socket socket) { this.socket = socket; }
0
@Override public String getHouseNumber() { return super.getHouseNumber(); }
0
private void JoinTuples (Tuple tuple1 ,Tuple tuple2) { //increase count outcome tuples because this join produces a tuple this.countOutcomeTuples++ ; //Constructing a new bitmap for new integrated tuple //==========================NEW READY BITS======================================= int newReadyBits ; in...
8
@Override public boolean matches(Object argument) { if (argument instanceof PropertyChangeEvent) { PropertyChangeEvent event = (PropertyChangeEvent) argument; return propertyName.equals(event.getPropertyName()) && ((oldValue == null && event.getOldValue() == null) || (old...
7
public void go() { int index = 0; try { while(index < 1330) { new Thread(new Crawler(index)).start(); index++; } } catch(Exception ex) {} }
2
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof IDs)) return false; IDs iDs = (IDs) o; if (!Arrays.equals(ids, iDs.ids)) return false; return true; }
3
public static void printLCS(int[][] c, int[] x, int i, int j) { if(i == 0 || j == 0){ return; } if(c[i][j] != c[i - 1][j] && c[i][j] != c[i][j - 1]){ printLCS(c, x, i - 1, j - 1); System.out.print(x[i - 1] +","); }else if(c[i][j] == c[i - 1][j]){ printLCS(c, x, i - 1, j); }else{ printLCS(c, ...
5