text
stringlengths
14
410k
label
int32
0
9
public FTPItemList(String hostname, String username, String password, String workingDirectory) throws IOException { super(workingDirectory); fTPConnector = new FTPConnector(hostname, username, password, workingDirectory); this.workingDirectory = workingDirectory; for (String item : fTPCo...
3
@Override public int filterRGB(int x, int y, int rgb) { g = 0x0000FF00; r = 0x00FF0000; a = rgb & 0xFF000000; if(percent >= 50) { r = 0; if(percent < 80) { ...
3
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String nonce = req.getParameter("nonce"); String echostr = req.getParameter("echostr"); String remoteSig = req.getParameter("signature"); String timestamp = req.getPa...
8
@Override public boolean equals(Object obj) { OBJIndex index = (OBJIndex) obj; return vertexIndex == index.vertexIndex && texCoordIndex == index.texCoordIndex && normalIndex == index.normalIndex && tangentIndex == index.tangentIndex; }
3
public void add(String gram) { if (name == null || gram == null) return; // Illegal int len = gram.length(); if (len < 1 || len > NGram.N_GRAM) return; // Illegal ++n_words[len - 1]; if (freq.containsKey(gram)) { freq.put(gram, freq.get(gram) + 1); } else {...
5
public static void main(String[] args) { MenuTest frame = new MenuTest(); frame.MenuFrame(); }
0
public void wallSound() { try { Clip hit = AudioSystem.getClip(); hit.open(AudioSystem.getAudioInputStream (Ball.class.getResource("Hit.wav"))); hit.start(); } catch (LineUnavailableException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (UnsupportedAudioFile...
3
public static double lorentzianInverseCDF(double mu, double gamma, double prob) { if (prob < 0.0 || prob > 1.0) throw new IllegalArgumentException("Entered cdf value, " + prob + ", must lie between 0 and 1 inclusive"); double icdf = 0.0D; if (prob == 0.0) { icdf = Double.NEGATIVE_INFINITY; } else { if (p...
4
public void test_add_long_int() { assertEquals(567L, iField.add(567L, 0)); assertEquals(567L + 1234L * 90L, iField.add(567L, 1234)); assertEquals(567L - 1234L * 90L, iField.add(567L, -1234)); try { iField.add(LONG_MAX, 1); fail(); } catch (ArithmeticExcept...
1
public static void main(String[] args) throws ClientProtocolException, IOException, ParseException { ConfModel confModel = null; try { confModel = readConf(args[0]); } catch (Exception e) { System.out.println("設定ファイルの読み込みに失敗しました。" + e.toString()); } System.out.println("set OK"); String affiliate_...
1
public static SeverityEnumeration fromString(String v) { if (v != null) { for (SeverityEnumeration c : SeverityEnumeration.values()) { if (v.equalsIgnoreCase(c.toString())) { return c; } } } throw new IllegalArgumentException(v); }
3
private void update() { if (game_started) { try { //pass player rectangles to pong this.pong.update(this.playerA.getPlayerRectangle(), this.playerB.getPlayerRectangle()); this.notifyAll("pongUpdate", this.pong.getPongCoordinates()); //now ...
6
@Override public void destroy() { undoable = null; node = null; }
0
public List<Monitor.Stats.Stat.Validate> getValidate() { if (validate == null) { validate = new ArrayList<Monitor.Stats.Stat.Validate>(); } return this.validate; }
1
public void writeBits(long value, int n) throws IOException { // Note: As this method is called quite frequently, I'm // optimizing for speed instead of code readability. Consult // your local C, Assembler or other bit fiddling wizard if you // have trouble understanding it. value = (value & (-1L >>> (6...
9
public void quickSort(int start, int end) { int i = start, j = end; // find pivot, middle element int pivot = numbers[start + (end - start) / 2]; //iterate till we are left with values which need //to be exchanged while (i <= j) { while (numbers[i] < pivot) { i++; } while (numbers[j] > pi...
6
public boolean isLeft() { return left; }
0
public void checkCollisions() { // Check for collisions with walls. if (objects.isWallAtPosition(x, y)) { x = oldX; y = oldY; inputDelay = 0; // Bounce off of any walls that the player runs into. switch (facing) ...
8
void copy (TextPosition Start, TextPosition End) { if (Start == null || End == null) return; TextPosition P1, P2; if (Start.before(End)) { P1 = Start; P2 = End; } else if (End.before(Start)) { P1 = End; P2 = Start; } else return; String s = ""; ListElement e = P1.L; while (e != null...
7
public boolean isDone() { if (line.contains("|")) { String connect = line.split("\\|")[1]; String[] parameter = connect.split(","); if (parameter[0].equals("ACTIVATE")) { level.connect(parameter[1]).active = true; } return true; } else { if (count < line.length()) { fnt.drawString(200, 550...
5
public void saveControle() { facesContext = FacesContext.getCurrentInstance(); try { if(valorTotal.equals("")){ valorTotal = "0"; } if(valorUnitario.equals("")){ valorUnitario = "0"; } controle.setCtrl_limiteUnitario(Integer.parseInt(valorUnitario)); controle....
7
@Override public List<Study> getStudies() { if(studies != null) return studies; File[] imageFiles = directory.listFiles(); Arrays.sort(imageFiles); studies = new ArrayList<Study>(); for(File f : imageFiles) if(f.isDirectory()...
3
public void clickBlock(int var1, int var2, int var3, int var4) { this.mc.theWorld.onBlockHit(this.mc.thePlayer, var1, var2, var3, var4); int var5 = this.mc.theWorld.getBlockId(var1, var2, var3); if(var5 > 0 && this.curBlockDamage == 0.0F) { Block.blocksList[var5].onBlockClicked(this.mc.theWor...
4
protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) { int b,c; int remaining = in.remaining(); while (remaining-- > 0) { if (out.remaining() < 1) return CoderResult.OVERFLOW; b = in.get(); if (b == ESCAPE...
5
public static void main(String[] args) { if(args.length > 0){ String IP; if(args.length == 2){ FloodlightProvider.setPort(args[1]); } IP = args[0]; try { if (InetAddress.getByName(IP).isReachable(5000)) { ...
6
public void filledSquare(double x, double y, double r) { if (r < 0) throw new RuntimeException("square side length can't be negative"); double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2*r); double hs = factorY(2*r); if (ws <= 1 && hs <= 1) pixel(x, y); ...
3
private synchronized void processEvent(Sim_event ev) { double currentTime = GridSim.clock(); boolean success = false; if(ev.get_src() == myId_) { if (ev.get_tag() == UPT_SCHEDULE) { if(currentTime > lastSchedUpt) { // updates the schedule, finish jobs, etc. updateSchedule();...
4
public int[][][] getCubes() { int[][][] copy = new int[length][width][height - SAFE_HEIGHT]; for(int x = 0; x < length; x++) { for(int y = 0; y < width; y++) { for(int z = 0; z < height - SAFE_HEIGHT; z++) { copy[x][y][z] = cubes[x][y][z]; } } } if(fallingPiece != null) { for(int i = 0; i ...
6
public static int getSize(){ return size; }
0
void setStyle(Widget widget) { Point sel = text.getSelectionRange(); if ((sel == null) || (sel.y == 0)) return; StyleRange style; for (int i = sel.x; i<sel.x+sel.y; i++) { StyleRange range = text.getStyleRangeAtOffset(i); if (range != null) { style = (StyleRange)range.clone(); style.start = i; style.le...
8
@Override public List<Point> startPathfinder(boolean diagonalAllowed) { begin.setWaveNum(0); setWaveNums(); // System.out.println("----------------"); // for (int i = 0; i < cells.length; i++) { // for (int j = 0; j < cells.length; j++) { // if (begin.getX() =...
8
private void start() { new Thread(this).start(); }
0
public ReplacingInputStream( InputStream in, Map<byte[],byte[]> replacementMap ) throws NullPointerException { super(); if( in == null ) throw new NullPointerException( "Cannot create ReplacingInputStreams from null-streams." ); if( replacementMap == null ) throw new NullPointerException( "C...
5
void register_init(IFCModel __model) throws Exception { JButton[] buttons; JMenuItem[] items; JMenu menu; int _MAX; _model = __model; _persistence = new HashMap(); _objectfile = new File(_CDEFAULT_OBJECT_FILE); _message = new Mess...
8
private int startReservations() { double refTime = GridSim.clock(); LinkedList<ScheduleItem> startedRes = new LinkedList<ScheduleItem>(); int numStartRes = 0; for (ServerReservation sRes : reservTable.values()) { if(sRes.getStartTime() <= refTime && sRes.getReservationStatus() == Res...
4
public void firemaking_process() { for(int i = 0; i < MaxObjects; i++) { if (ObjectFireID[i] > -1) { if (ObjectFireDelay[i] < ObjectFireMaxDelay[i]) { ObjectFireDelay[i]++; } else { for (int j = 1; j < server.playerHandler.maxPlayers; j++) { if (server.playerHandler.players[j] != null) { ...
5
public static void add(AObject object) throws Exception // add an object to the stage { if (object instanceof FailBox) { endZone = (FailBox) object; } else { if(object instanceof Pinball) { pinball = (Pinball) object; ...
2
public void run() { info("Route-" + hashCode() + " entering run()"); try { while (!stopped()) { try { if (serverSocket == null) { info("Thread-" + Thread.currentThread().hashCode() + " Route-" + hashCode() + " constructing new ServerSocket on port " + local_port); ...
4
public void run(){ output.println("Connected"); String inputLine; try { while ((inputLine = input.readLine()) != null) { if (inputLine.equals("Combine file.")){ System.out.println("Combining file."); ShamirShare fileShares = getAllFileSlice(); ShamirShare toCombine = new ShamirSha...
7
protected int findPrototypeId(String s) { int id; // #generated# Last update: 2007-05-09 08:15:24 EDT L0: { id = 0; String X = null; int c; int s_length = s.length(); if (s_length==11) { c=s.charAt(0); if (c=='c') { X="constructor";id=Id_constr...
7
static String getCharsetFromContentType(String contentType) { if (contentType == null) return null; Matcher m = charsetPattern.matcher(contentType); if (m.find()) { String charset = m.group(1).trim(); charset = charset.replace("charset=", ""); if (charset.isEm...
6
private boolean hasFFmpegArgumentsName(String name) { boolean ret = false; if (connection == null || name == null) return ret; PreparedStatement pstat = null; try { pstat = connection.prepareStatement("SELECT COUNT(*) FROM " + FFmpegArgumentsTableName + " WHERE Name = ?"); pstat.setString(1, name);...
7
private void clearBuffer(){ if (isFirstLine && document.getLength() != 0){ buffer.insert(0, "\n"); } isFirstLine = false; String line = buffer.toString(); try{ if (isAppend){ int offset = document.getLength(); document.insertString(offset, line, attributes); textComponent.setC...
5
private static boolean check(World world, int x0, int y0, int z0) { for(int y = 0; y < _blocks.length; y++) { for(int z = 0; z < _blocks[y].length; z++) { for(int x = 0; x < _blocks[y][z].length; x++) { if(_blocks[y][z][x] =...
5
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void registerSuccMsg(Map<String, String> record, int type) { // ***@LiWei***以下为解决超过4000字符,保存异常添加代码***// // 如果消息内容过长,截取一部分保存 String body = record.get("body"); if (body == null) { body = ""; } else { try { byte[] bytes = body.getByte...
7
private void breakUp(final EntityHandler handler) { this.kill(); // smallest asteroids don't break anymore if (this.size <= 2) return; // if EntityLimit is reached no more new asteroids if (!handler.isUnderEntityLimit()) return; // FIXME: causes game to freeze handler.getFactory().addLater().creat...
2
public static int kthSmallest(int[][] matrix, int k) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return 0; } int m = matrix.length; int n = matrix[0].length; PriorityQueue<Integer> pq = new PriorityQueue<Integer>(new Comparator<Integer>() { public int compare(Integer a, Inte...
9
public static DNSRecord Parse(ByteBuffer aBuffer) throws IOException { DNSRecord record = null; DNSEntry internalEntry = DNSEntry.Parse(aBuffer); int ttl = aBuffer.getInt(); int len = DNSEntry.getUnsignedShort(aBuffer); assert(len != 0); switch(internalEntry._eType) { case...
8
public void del() { try { mesh.delTriangles( triangles ); } catch ( Exception e ) { e.printStackTrace(); System.exit( 0 ); } }
1
public void test_set_RP_int_intarray_String_Locale() { BaseDateTimeField field = new MockPreciseDurationDateTimeField(); int[] values = new int[] {10, 20, 30, 40}; int[] expected = new int[] {10, 20, 30, 40}; int[] result = field.set(new TimeOfDay(), 2, values, "30", null); asser...
2
public Set<String> getGroups() throws DataLoadFailedException { return dataHolder.getGroups(); }
0
private void jButtonConstruction_CreateLevelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConstruction_CreateLevelActionPerformed String tag = jTextFieldUID.getText(); if (tag.length() == 0) { JOptionPane.showMessageDialog(null, "UID tag required for level\n", "ED...
7
@Override public void characters(char[] ch, int start, int length) throws SAXException { String namet = stack.peek(); if("姓名".equals(namet)) { name = new String(ch,start,length); }if("性别".equals(namet)){ sex = new String(ch,start,length); } if("年龄".equals(namet)) { age = new String(ch,star...
3
public boolean anvilReady() { if (!ctx.skillingInterface.getAction().equalsIgnoreCase("Smith")) { if (ctx.skillingInterface.opened() && ctx.skillingInterface.close()) { return false; } if (ctx.skillingInterface.isProductionInterfaceOpen()) { ctx.skillingInterface.cancelProduction(); return false...
4
public Account removeAccount(Account account) { getAccounts().remove(account); account.setClient(null); return account; }
0
@Override public void run() { while (true) { try { Thread.sleep(20); } catch (Exception e) { } if (creator != null && !creator.acceptingUserInput()) { // bg.clearSelection(); creator = null; } repaint(); } }
4
private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec2[i2] & l2) != 0L); case 48: return ((jjbitVec3[i2] & l2) != 0L); case 49: return ((jjbitVec4[i2] & l2) != 0L); case 51: re...
6
public Item buildFungus(MOB mob, Room room) { final Item newItem=CMClass.getItem("GenFoodResource"); newItem.setMaterial(RawMaterial.RESOURCE_MUSHROOMS); switch(CMLib.dice().roll(1,6,0)) { case 1: newItem.setName(L("a mushroom")); newItem.setDisplayText(L("a mushroom is here.")); newItem.setDescript...
7
public String getClipboardData() { Transferable clip = null; try { Clipboard cp = Toolkit.getDefaultToolkit().getSystemClipboard(); clip = cp.getContents(this); } catch (Exception e) { } if (clip == null) { return ""; ...
4
public static PlayersConnectedMessage createPlayersConnectedMessage(String playerNames) { if (playerNames == null) throw new IllegalArgumentException("PlayerName is null"); return new PlayersConnectedMessage(playerNames); }
1
private synchronized void incrementLSN() { FileWriter writer = null; try { writer = new FileWriter("logSequenceNumber"); writer.write(Integer.toString(logSequenceNumber + 1)); } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close();...
3
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Map<String, String[]> param = request.getParameterMap(); if (param != null) { Path logfile = FileSystems.getDefault().getPath("G:\\workspace\\TelephoneBook-v2\\file.l...
2
public boolean validate(SkiPass sp) { int id = sp.getID(); if (id < 0 || id >= skiPassIDCounter) { return false; } else { return true; } }
2
public WebElement getElementByAttribute(String Attribute, String AttributeType) { try { if (AttributeType.equalsIgnoreCase("css")) { testObjects = driver.findElements(By.cssSelector(Attribute)); } else if (AttributeType.equalsIgnoreCase("id")) { testObjects = driver.findElements(By.id(Attribute...
9
public void setPos4(int val){ if (val == 1){p4 = true;} else { p4 = false; }}
1
@Override public void removeItem( GraphItem item ) { if( graph == null ){ throw new IllegalStateException( "cannot remove items because there is no graph set" ); } graph.removeItem( item ); }
1
public void move(){ super.move(); if (x < 50){ x = 1180; } if (y < 50){ y = 840; } if (x > 1180){ x = 50; } if (y > 840){ y = 50; } }
4
public void run(){ if (time!=0){time=time-1;} GosLink.dw.append("HeartBeat Started."); while (true){ try { Thread.sleep(60000); checkserver(1); checkserver(2); if (Boolean.valueOf(GosLink.prps("bot"))){gosbot.enterchk();} } catch (Exception e) {e.printStackTrace();} } }
4
public void putAll( Map<? extends Long, ? extends Integer> map ) { Iterator<? extends Entry<? extends Long,? extends Integer>> it = map.entrySet().iterator(); for ( int i = map.size(); i-- > 0; ) { Entry<? extends Long,? extends Integer> e = it.next(); this.put( e.get...
8
public DefaultItemContextCapability( DefaultUmlDiagram diagram, DefaultItem<?> item ){ this.diagram = diagram; this.item = item; }
1
@Override public void keyPressed(KeyEvent e) { switch(e.getKeyCode()) { case KeyEvent.VK_W: case KeyEvent.VK_UP: maincanvas.vport.scroll(Directions.N); break; case KeyEvent.VK_S: case KeyEvent.VK_DOWN: mainc...
9
public void onEnable() { playerListener.loadPlayers(); inventoryManager.load(); pm = new PluginManager(this); pm.registerEvents(creatureListener); pm.registerEvents(entityListener); pm.registerEvents(playerListener); pm.registerEvents(pluginListener); pm.registerEvents(weatherListener); pm.reg...
5
public void append(String msg) { if (win==true){textarea.append(msg+"\n");} else{System.out.println(msg);} }
1
public char value(int level) { if (path_.length() < level) { throw new IndexOutOfBoundsException(); } return path_.charAt(level); }
1
public static void main(String[] args) throws Exception { InputStream isInput = new FileInputStream("D:/aaa/221.txt"); byte[] buffer = new byte[200]; int length = 0; while(-1 != (length = isInput.read(buffer,0,200))) { String str = new String(buffer,0,length); System.out.println(str);...
1
public boolean getDead(){ return dead; }
0
private void dfs(Digraph G, int v) { marked[v] = true; onStack[v] = true; for (int w : G.adj(v)) { if (hasCycle()) return; else if (!marked[w]) { edgeTo[w] = v; dfs(G, w); } else if (onStack[w]) { cycle = new Stack<Integer>(); for (int x = v; x != w; x = edgeTo[x]) cy...
5
public Enemies(Transform transform) { if (textures == null) { textures = new ArrayList<Texture>(); textures.add(new Texture("SSWVA1.png")); // Walking textures.add(new Texture("SSWVB1.png")); textures.add(new Texture("SSWVC1.png")); textu...
2
private static ListNode buildList(int[] arr) { ListNode head = new ListNode(0); ListNode curr = head; for (int i : arr) { curr.next = new ListNode(i); curr = curr.next; } curr = head; while (curr.next != null) { curr = curr.next; if (curr.next == null) { curr.next = head.next.next.next.next;...
3
public void updatePatient(int health_care_no, String field, String value) { // UPDATE table_name // SET column1=value1,column2=value2,... // WHERE some_column=some_value; String patientUpdate = ""; if (field.equals("name") || field.equals("address") || field.equals("phone")) { patientUpdate = "UPDATE...
5
@Override boolean startSamples(int loopCount, float leftGain, float rightGain, int leftDelay, int rightDelay) { // loop count is ignored for Stream and MIDI // TODO: loop count isn't implemented for MIDI yet // left and rightDelay parameters are in terms of...
9
public int compareTo(Object object) { if (!(object instanceof CycVariable)) { throw new ClassCastException("Must be a CycVariable object"); } return this.name.compareTo(((CycVariable) object).name); }
1
public static void addLibrary( Class libraryClass ) throws SoundSystemException { if( libraryClass == null ) throw new SoundSystemException( "Parameter null in method 'addLibrary'", ...
4
public String longestCommonPrefix(String[] strs) { if (strs.length == 0) return ""; if (strs.length == 1) return strs[0]; for (int j = 0; j < strs.length; j++) if(strs[j].length() == 0) return ""; for (int i = 0; i < strs[0]...
8
private PDFObject readObjectDescription( ByteBuffer buf, int objNum, int objGen, PDFDecrypter decrypter) throws IOException { // we've already read the 4 0 obj bit. Next thing up is the object. // object descriptions end with the keyword endobj long debugpos = buf.position(); PDFOb...
6
public boolean initHouse(House house, int floor) { try { loadImages(); } catch (MissingResourceException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return changeHouse(house, floor); }
2
public void update() { input.update(player); Cinput.update(creature); if(mousey.buttonDown(MouseEvent.BUTTON1)) System.out.println(String.format("Mouse Down: (X:%f, Y:%f)",mousey.getPosition().getX(),mousey.getPosition().getY())); }
1
public static Method findSuperMethod(Object self, String name, String desc) { Class clazz = self.getClass(); Method m = findSuperMethod2(clazz.getSuperclass(), name, desc); if (m == null) m = searchInterfaces(clazz, name, desc); if (m == null) error(self, name, d...
2
public void disable() throws IOException { // This has to be synchronized or it can collide with the check in the task. synchronized (optOutLock) { // Check if the server owner has already set opt-out, if not, set it. if (!isOptOut()) { configuration.set("opt-out"...
2
public static int search2(int[] A, int target) { if (A.length == 0) return -1; int l = 0; int r = A.length - 1; int m; while (l <= r) { m = (l + r) / 2; if (target == A[m]) { return m; } else if (A[l] <= A[m] && A[m] >= A[r]) { // left sorted, right unsorted if (target < A[m] && target...
9
public void eat(ArrayList<ParkerPaulChicken> chickens) { /// guard clause - no chickens to eat if (chickens.isEmpty()) { return; } // guard clause - didn't catch a chicken if (!canCatchChicken()) { return; } // select a chicken to eat and...
2
public boolean removeModerator(User user){ if (moderators.size() <= 1) return false; moderators.remove(user); save(); return true; }
1
private void completeTabFrequence () { for (final int code : this.encoding) { boolean write = false; for (ArrayList<Integer> tabFreq : this.tabFrequence) { if (tabFreq.get(0) == code) { tabFreq.set(1, tabFreq.get(1) + 1); write = ...
4
public short[] decodeShorts() { short[] res = new short[decodeInt()]; for (int i = 0; i < res.length; i++) { res[i] = decodeShort(); } return res; }
1
private static <T extends Comparable<? super T>> T[] merge(T[] front, T[] rear) { T[] result = Arrays.copyOf(front, front.length + rear.length); int i = 0; int j = 0; int k = 0; for(; j < front.length && k < rear.length; i++) { T first = front[j]; ...
7
private void desenhaProximaPeca(GL gl, IntBuffer idsTextura) { if (proximaPeca != null) { // desenha a próxima peça double[][] matrizProximaPeca = proximaPeca.getMatrizAtual(); if (proximaPeca.getTipoPeca() == TipoPeca.T) { matrizProximaPeca = proximaPeca.getMatrizRotacao(); matrizProximaPeca = ne...
9
public void stop_run() { try { open_port = false; ssocket.close(); } catch (IOException e) { } }
1
double kernel_function(int i, int j) { switch(kernel_type) { case svm_parameter.LINEAR: return dot(x[i],x[j]); case svm_parameter.POLY: return powi(gamma*dot(x[i],x[j])+coef0,degree); case svm_parameter.RBF: return Math.exp(-gamma*(x_square[i]+x_square[j]-2*dot(x[i],x[j]))); case svm_parame...
5
public void moveDown(boolean isUserTriggered) { if (freezing || !isGameOn) { return; } if (!checkMovable("DOWN")) { for (int i = 0; i < currentTokens.length; i++) { int x = currentTokens[i][0]; int y = currentTokens[i][1]; t...
7
public void onDisable() { saveUsers(); }
0