text
stringlengths
14
410k
label
int32
0
9
public void setName(String name) { this.name = name; setDirty(); }
0
public static void main(String[] args) throws IOException { Library stopWordDictionary = new StopWordLibrary(new Settings().getStopWordLibrary()); File directory = new File("dataSource/samples/Teste/comp.os.ms-windows.misc"); String[] arquivos = directory.list(); if (arquivos != null) { for (int i = 0; i < a...
9
private void drawLine(Graphics g, int x, int y, int xMax, int xLen, FontMetrics fm, int alignment) { if (y > getHeight() - 3) return; StringBuffer s = new StringBuffer(); String str1; int xx = x; while (true) { int m = random.nextInt(10) + 1; str1 = dummy.substring(0, m) + " "; int len = ...
8
public Data serverMsg() { Object obj; try { try { obj = input.readObject(); } catch (ClassNotFoundException ex) { setDef("No connection to the server! Don't run Server.java" + ex.getMessage(), 1); return null; } ...
4
protected void setupTempInventory(Clan doer) { for (int i = 0; i < tmpInventory.length; i++) {tmpInventory[i] = 0;} QStack qs = doer.MB.QuestStack; if (qs.isEmpty()) {return;} Quest q = qs.peek(); if (!(q instanceof LaborQuest)) {return;} LaborQuest lq = (LaborQuest) q; int[] wm = lq.getWM(); int[]wmx =...
5
public static MovieData parseMovieFileName(File fileEntry) throws Exception { String fileName = fileEntry.getName(); System.out.println(fileName); MovieData data = null; if (data == null) { // Rule1: Braveheart.1995.1080p.BrRip.x264.YIFY+HI // ^^^^^^^^^^ ^^...
8
@Override public void update() { if (this.lastAlphaUpdate == 0) { this.lastAlphaUpdate = Timer.getTime(); } if (Timer.getTime() - this.lastAlphaUpdate >= 75) { if (this.increaseAlpha) { this.alpha += 0.04f; if (this.alpha >= 1.0f) { ...
6
FileType(String type) { this.type = type; }
0
public static void main(String[] args) { try { workDir=new File(ModManager.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath().replace("McLauncher.jar", "")); System.out.println("Running McLauncher from " + workDir); } catch (URISyntaxException e1) { workDir=new File(""); e1.prin...
5
public boolean isInArea(Area checkArea) { if (x <= checkArea.getLocation1().getX() || x >= checkArea.getLocation2().getX() || y <= checkArea.getLocation1().getY() || y >= checkArea.getLocation2().getY()) return false; else return tr...
4
@SuppressWarnings("static-access") private void ROUND8() { enemises.clear(); System.out.println("Round8!!!!!!"); for (int i = 0; i < level.getWidth(); i++) { for (int j = 0; j < level.getHeight(); j++) { if ((level.getPixel(i, j) & 0x0000FF) == 2) { ...
3
private Widget creerCreateRoomPanel() { setWidth("100%"); setHeight("100%"); addSallePan.isVisible(); addSallePan.setTitle("Ajouter une salle"); // Create a table to layout the form options FlexTable layout = new FlexTable(); layout.setCellSpacing(6); layout.setWidth("350px"); layout.setHeight("450px...
5
private boolean checkForNakedQuads(LinkedList<NakedCandidates> pool, NakedCandidates comparator) { LinkedList<String> candidates = new LinkedList<String>(); for (int index=0; index < pool.size(); index++) { for (int i=0; i < pool.get(index).values.size(); i++) { if (!passOver(candidates, pool.get(index)....
5
@Override public String getText() { String res = ""; res = res + this.text + " "; Iterator<Integer> it_operands = this.operands.iterator(); Iterator<Character> it_operators = this.operators.iterator(); Iterator<Integer> it_unknowns = this.unknowns.iterator(); res = re...
5
@Override public void addCandidate(Route route) { if (route.getNumberOfStops() == limit) { routes.add(route); } }
1
public void testParseStandardFail2() { PeriodFormatter parser = ISOPeriodFormat.standard(); try { parser.parsePeriod("PS"); fail(); } catch (IllegalArgumentException ex) {} }
1
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((k == null) ? 0 : k.hashCode()); return result; }
1
private void drawGrid(){ //indicate the intervals between vertical lines int vertDist = APPLICATION_WIDTH/NDECADES; //window fit int fit = 60; //a buffer for everything int buffer =5; bottomLineY = APPLICATION_HEIGHT-GRAPH_MARGIN_SIZE-fit; for(int i=0;i<NDECADES;i++){ decadeArray[i] = START_...
2
protected boolean isElementoEnListas(String elemento) { if (isElementoEnHechosInicio(elemento)) { return true; } if (isElementoEnHechosInferidos(elemento)) { return true; } if (isElementoEnHechosPreguntados(elemento)) { return true; ...
3
public void draw(Object obj, Component comp, Graphics2D g2) { Color color; if (obj == null) color = null; else color = (Color) getProperty(obj, "color"); String imageSuffix = (String) getProperty(obj, "imageSuffix"); if (imageSuffix == null) ...
7
public void completeRows() { int count = 0; for (int i = 0; i < NUM_ROWS; i++) // Loop through rows { for (int j = 1; j < NUM_COLUMNS - 1; j++) // Loop through columns { // Check each column in the row to see if it is occupied by an INACTIVE_BLOCK if(gameBoard[i][j] == INACTIVE_BLOCK) { ...
8
private void decodeParameters(String parameters) { StringTokenizer tokenizer = new StringTokenizer(parameters, "&"); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); int index = token.indexOf('='); String name = decodePercent(index == -1 ? token : token.substring(0, index)).trim();...
5
public static void showFrame () { /* 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://download.or...
6
@Test(expected = ParkException.class) public void in_a_car_when_all_park_is_full() { for(int i = 0; i <= 15; i ++) { parkBoy.in(new Car(String.valueOf(i))); } }
1
public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("Exit")) { JOptionPane.showMessageDialog(null, "Are you Sure you want to exit?"); System.exit(0); } else if(e.getActionCommand().equals("About")) { JOptionPane.showMessageDialog(null, "Medical Application Integr...
2
public Voiture ajouterVoiture(VoieEnum depart, VoieEnum destination) { VoieExterne entree, sortie; entree = voiesExternes.get(depart.ordinal()); sortie = voiesExternes.get(destination.ordinal()); Voiture voiture = new Voiture(sortie); if (statistiques != null) { voiture.addObserver(statistiques); } en...
1
public void visit_baload(final Instruction inst) { stackHeight -= 2; if (stackHeight < minStackHeight) { minStackHeight = stackHeight; } stackHeight += 1; }
1
@Override public void removeDefi(long id) { em.clear(); try { Defi defiToRemove = em.find(Defi.class, id); em.remove(defiToRemove); } catch(Exception e) {} }
1
public static String getMIME(String str){ //This method gets the MIME according to the extension. if(str.endsWith("/")) return "text/html"; String extension = str.substring(str.lastIndexOf(".")+1); switch (extension){ case "html": return "text/html"; case "htm": return "text/html"; case "jpeg": ...
8
public int getIndex() { return this.index; }
0
private boolean insertStrict(T model, Long oldUpdatedAt) throws JackException, IOException { PreparedStatement insertStmt = conn.getPreparedStatement(getInsertWithIdStatement(fieldNames)); try { setAttrs(model, insertStmt); insertStmt.setLong(fieldNames.size() + 1, model.getId()); insertStmt.e...
4
protected AutomatonPane getView() { return view; }
0
private Animation createPlayerAnim(Image player1, Image player2, Image player3, Image player4, Image player5, Image player6, Image player7, Image player8, Image player9, Image player10) { Animation anim = new Animation(); anim.addFrame(player1, 80); anim.addFrame(play...
0
@RequestMapping(value="/edit.do", method=RequestMethod.GET) public String editProfile(@RequestParam(value="userId", required = false) Long userId, Model model) { if(userId == null) { model.addAttribute("user", new User()); } else { model.addAttribute("user", new User() ); //...
1
* @throws IOException * if there is a low-level IO error */ public void updateDocValues(Term term, Field... updates) throws IOException { ensureOpen(); DocValuesUpdate[] dvUpdates = new DocValuesUpdate[updates.length]; for (int i = 0; i < updates.length; i++) { final Field f = update...
8
public void clear() { this.data = new int[DEFAULT_SIZE]; size = 0; }
0
private void moveNewZipFiles(String zipPath) { File[] list = listFilesOrError(new File(zipPath)); for (final File dFile : list) { if (dFile.isDirectory() && this.pluginExists(dFile.getName())) { // Current dir final File oFile = new File(this.plugin.getDataFol...
7
public void keyPressed(KeyEvent e) { if(!credits) { input.set(e.getKeyCode(), true); } else if (credits) { System.exit(0); } }
2
public int findFirstOccurrence(int [] arrA, int x, int start, int end){ if(end>=start){ int mid = (start+end)/2; if((mid==0||(arrA[mid-1]<x)) && arrA[mid]==x){ return mid; }else if(arrA[mid]<x){ return findFirstOccurrence(arrA, x, mid+1, end); }else{ return findFirstOccurrence(arrA, x, star...
5
public ListNode rotateRight(ListNode head, int n) { if (null == head || null == head.next) return head; ListNode p = head; int len = 0; while (p != null) { len++; p = p.next; } n %= len; if (n == 0) r...
8
@Override public void handlePieceAvailability(SharingPeer peer, Piece piece) { /* Do nothing */ }
0
public void splitAndInsert(String value, long split_ts) { for (Map.Entry<String, String> entry : optimizedData.entrySet()) { String times = entry.getValue(); String[] timespan = times.split(","); Long firstTime = Long.parseLong(timespan[0]); if (split_ts < firstTime) continue; Long secondTime = Lon...
8
private static int getASMModifiers(Modifiers modifiers) { int mods = 0; if (modifiers == null) { return mods; } if (modifiers.hasModifier("public")) { mods += ACC_PUBLIC; } if (modifiers.hasModifier("protected")) { mods += ACC_PROTECTED; } if (modifiers.hasModifier("static")) { mods += ACC_...
6
public static IRCCommand getResponse(String command){ if (requiresResponse(command)){ IRCCommand cmd; try { cmd = IRCCommand.valueOf(command.toUpperCase()).response; return cmd; } catch (IllegalArgumentException e){System.out.println("Unkown command: " + command);} } return null; }
2
public TreeDrawer getTreeDrawer() { return treeDrawer; }
0
public static int minPathSum(int[][] grid) { int m = grid.length; int n = grid[0].length; int[][] pathsum = new int[m][n]; for (int i = m - 1; i >= 0; i--) { for (int j = n - 1; j >= 0; j--) { if (i == m - 1 && j == n - 1) pathsum[i][j] = grid[i][j]; else if (i ...
7
public boolean equals(Object object) { return object == null || object == this; }
1
Result tryRule( TotalisticRule r, int fieldSize ){ double p = 0.5; ArrayField field = new ArrayField(); field.setCells( Util.randomField( fieldSize, p) ); Path[] soup = field.getAliveCellsArray(); //it returns reference sortCells( soup ); int initialPopulation = soup.length; int limitPopulaion = ...
8
public Polynomial modPow(long e, Polynomial p) throws Exception { Polynomial x = this; Polynomial r = one(); while (e > 0) { if ((e & 1L) != 0) r = r.mul(x).div(p)[1]; // r *= x mod p e >>= 1; x = x.mul(x).div(p)[1]; // x = x^2 mod p } return ...
2
@Override public String[] getHelp() { return new String[]{ "ttp debug <username> [on/off]", "Toggles the debug state of a user" }; }
0
@Test public void testSingleReaderManyWriters() { final int MESSAGES = 10000; final int WRITERS = 10; final int MESSAGES_PER_WRITER = MESSAGES / WRITERS; final AtomicInteger nullCounter = new AtomicInteger(); final BlockableQueue<Integer> q = new BlockableQueue<Integer>(); q.setBlocking(true); Run...
3
public static void main (String[] args) { int i = 1; for (; ; i++) { if (i % 20 == 0 && i % 19 == 0 && i % 18 == 0 && i % 17 == 0 && i % 16 == 0 && i % 14 == 0 && i % 13 == 0 & i % 11 == 0) { break; } } System.out.println(i); }
8
private void waitTime () { if (isFirstTimeToDisplay) { isFirstTimeToDisplay = false; // Wait a little time for gui initial display. try { Thread.sleep(INPUT_WAITING_TIME_LONG); } catch (final InterruptedException e) { e.printStackTr...
5
private void autoSelectListBox(List<String> headers) { String loc; if ((loc = Utils.getBestMatch(controller.getLocationKeywords(), headers)) != null) { locationHeaderCB.setSelectedItem(loc); } String category; if ((category = Utils.getBestMatch(controller.getCategoryKeywords(), headers)) != null) { ca...
8
public void mouseExited(MouseEvent e) { mouseMoved(e); }
0
public void setMenuIcons(ImageIcon normal, ImageIcon selected) { if (normal != null) { for (AccordionRootItem menu : getMenus()) { menu.setNormalIcon(normal); } } if (selected != null) { for (AccordionRootItem menu : getMenus()) { ...
4
public static void main(String args[]) throws ClassNotFoundException { /* * Load core config */ ConfigLoaderCore cf = new ConfigLoaderCore(); cf.LoadCoreConfig(); // Load core properties // Проверяем обновление и качаем если надо jmc.minecraft.utils.LauncherUpdater.UpdateLauncher(); //TODO обновылен...
9
@Override public void setUp() { mapping = new HashMap<>(); final List<ColumnMetaData> listColumns = new ArrayList<>(); for (final String column : new String[] { "Id", "Description" }) { final ColumnMetaData columnMetadata = new ColumnMetaData(); columnMetadata.setColN...
1
@Override public void execute() { Variables.status = "Looting nest"; if(Inventory.getItem(Variables.seedNest_ID) != null) Inventory.getItem(Variables.seedNest_ID).getWidgetChild().interact("Search"); sleep(1000,1200); if(Inventory.contains(Variables.seed_IDs)) System.out.println("yo"); if(Inventory.con...
4
public void visit_idiv(final Instruction inst) { stackHeight -= 2; if (stackHeight < minStackHeight) { minStackHeight = stackHeight; } stackHeight += 1; }
1
private void checkEvictionOrder(boolean lifo) throws Exception { SimpleFactory factory = new SimpleFactory(); GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory); pool.setNumTestsPerEvictionRun(2); pool.setMinEvictableIdleTimeMillis(100); pool.setLifo(lifo); ...
9
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); while ((line = in.readLine()) != null && line.length() != 0) { int nSet = Integer.parseInt(line.trim()); for (int...
6
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub }
0
public static void adjustComponentBounds(Component comp, Component parentComp){ if(parentComp == null){ int x = Math.max(comp.getX(), 12); int y = Math.max(comp.getY(), 12); int width = Math.min(comp.getWidth(), Toolkit.getDefaultToolkit().getScreenSize().width-1...
5
public void addTime(String playerName, int time, DB_Timers timer) { String message, bmessage; Integer timerID = timer.getId(); String st_time = this.plugin.util.formatTime(Integer.valueOf(time)); DB_Times data = this.plugin.database.getDatabase().find(DB_Times.class).where().ieq("Playername", playerName).where(...
4
public int[] getPosition() { return this.position; }
0
public double visibleNode(int index) { if(index < 0 || index >= m) throw new RuntimeException("given m=" + m + ", illegal value for index: " + index); return _visibleNodes[index]; }
2
public void add(E element) { if (root == null && element != null) { root = new Node<E>(element); size++; } else if (element != null) { root = insert(root, element); } }
3
public boolean pass(int[] bowl, int bowlId, int round, boolean canPick, boolean musTake) { counter++; if(counter==1){ for(int i=0;i<12;i++){ bowSize+=bowl[i]; } //update(bowSize*6); } update(bowl,bowlId,round); ...
8
public int characterAt(int at) throws JSONException { int c = get(at); if ((c & 0x80) == 0) { return c; } int character; int c1 = get(at + 1); if ((c1 & 0x80) == 0) { character = ((c & 0x7F) << 7) | c1; if (character > 0x7F) { ...
8
public void save() throws IOException { try { // Generate XML builder // (thanks to // http://www.mkyong.com/java/how-to-create-xml-file-in-java-dom/) DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder ...
4
public RepairGUI() { setBounds(100, 100, 537, 393); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JPanel panel = new JPanel(); panel.setBounds(0, 0, 535, 364); contentPane.add(panel); panel.setLayout(null);...
7
protected void end() { Robot.tilter.stop(); }
0
public static void main(String[] args) { JSAP jsap = initParameters(); JSAPResult jsapResult = jsap.parse(args); if(!jsapResult.success()) { printHelp(jsap); } boolean withShortedPath = jsapResult.getBoolean("shortedPath"); //Boolean reduced = jsapResult.getBoolean("reduced"); File inputFile = new ...
4
public void writeAttributeList(Writer writer, Iterable<? extends Iterable<Tuple2<?, ?>>> attributes) throws IOException { if (attributes != null) { for (Iterable<Tuple2<?, ?>> alist : attributes) { writeAList(writer, alist); } } }
7
public static Surrogate coerceToBoundOrLocalSurrogate(GeneralizedSymbol self) { { Surrogate surrogate = null; if (Logic.explicitlyQualifiedLogicObjectNameP(self, ((Module)(Stella.$MODULE$.get())))) { { Object old$Module$000 = Stella.$MODULE$.get(); Object old$Context$000 = Stella.$CONTEXT$....
7
public PartnerRole(final String name) { super(name); }
0
private void jbtnValiderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnValiderActionPerformed if (modeCMS.equals("C")) { if (JOptionPane.showConfirmDialog(this, "Etes-vous sûr de vouloir créer ce livre ?", "Confirmation", YES_NO_OPTION)==YES_OPTION){ creer(); ...
9
public FileStorage() { super(); File citationsFile = new File(serializationFilename); ObjectInputStream objectInputStream = null; try { if (!citationsFile.exists()) { return; } FileInputStream fileInputStream = new FileInputStream(citat...
6
public T getById(int id) throws SQLException { Session session = null; T t = null; try { session = HibernateUtil.getSessionFactory().openSession(); t = (T) session.load(this.getRealClass(), id); } catch (Exception e) { JOptionPane.showMessageDialog(nul...
3
@Override public void setPerPage(int per_page) { this.per_page = (per_page > 0) ? per_page : 1; this.pages = (int) Math.ceil((double) this.rows / (double) this.per_page); }
1
public String search() { ProductService productService = new ProductService(); try { if (this.item.getQuantity() != 0) { this.searchList = productService.searchProduct( item.getCategory(), item.getTitle(), item.getLeadSinger(), item.getQuantity(), searchList); if (this.searchList.size() == ...
4
public void keyPressed(KeyEvent e){ int key = e.getKeyCode(); switch(key){ case KeyEvent.VK_D : br = true; break; case KeyEvent.VK_A : bl = true; break; case KeyEvent.VK_W : bu = true; break; case KeyEvent.VK_S : bd = true; break; } locateDirection(); }
4
public boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { DecoderState state = (DecoderState) session.getAttribute(DECODER_STATE_KEY); if (state == null) { state = new DecoderState(); session.setAttribute(DECODER_STATE_KEY, state); } if (sta...
5
private void menuItemNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemNuevoActionPerformed int change=-1; if (changed){ change= JOptionPane.showOptionDialog(rootPane, ((currentFile==null)? "El Archivo nuevo": (currentFile.getName() )) ...
7
@Override public boolean handleRightClick(Point clickPoint) { if (this.isActivated()) { Point mapPoint = new Point( placeableManager.panelToMapX(clickPoint.x), placeableManager.panelToMapY(clickPoint.y)); if (currentState == State.Placed) { ...
4
public static void main(String[] args) { System.out.println("Task 5 - Smallest Multiple.\n" + "\n2520 is the smallest number that can be divided by each of " + "the numbers from 1 to 10 without any remainder.\n" + "What is the smallest positive number t...
4
public void updateTicket() { Database db = dbconnect(); String noEmployee = null; try { String query = "UPDATE ticket SET customer_CID = ?, " + "employee_EID = ?, CategoryID = ?, " + "StatusID = ?, Topic = ?, " + "Problem = ?, Note = ?...
2
public static String convertJavaStyletoDBConvention( String name ) { char[] chars = name.toCharArray(); StringBuffer buf = new StringBuffer(); for( int i = 0; i < chars.length; i++ ) { // if there is a single upper-case letter, then it's a case-word if( Character.isUpperCase( chars[i] ) ) { if( (i...
5
public static void main(String[] args) { Test test=new Test(); }
0
String order(double x, double y, double z ){ String classify = null; double []store = new double[3]; store[0] = x; store[1] = y; store[2] = z; classify = (store[0] < store[1] && store[1] < store[2] || store[2] < store[1] && store[1] < store[0]) ? store[0] < store[1] && s...
6
protected void newGame(MouseEvent e, int nx, int nw, int ny, int nh, TicTacToeBoard tb, TicTacToePlayer tp, Main m, LinkedList<Square> SquareStore) { // new game button if (tb.getGameOver()) { if (e.getX() > nx && e.getX() < nx + nw) { if (e.getY() > ny && e.getY() < ny + nh)...
6
public void selectCell(int r, int c) { if (this.stateTable && c > this.stateColumn || !this.stateTable && c >= this.inPinCount) { if (this.cells[r][c].equals("0")) { this.cells[r][c] = "1"; } else { this.cells[r][c] = "0"; } } }
5
private String prepareConfigString(String configString) { int lastLine = 0; int headerLine = 0; String[] lines = configString.split("\n"); StringBuilder config = new StringBuilder(""); for(String line : lines) { if(line.startsWith(this.getPluginName() + "_COMM...
8
public void componentResized(ComponentEvent e) { if (adapt) transformNeedsReform = true; repaint(); }
1
public void addUpdatedFilesData(List<String> updatedFiles) { for (int i = 0; i < updatedFiles.size(); i++) { try { Map<String, Set<Flight>> flightCSVData = readCsvAddData(updatedFiles .get(i)); /* * Sends every set related to a particular location along with * the Departure-Arrival key to ...
3
public void setDates(String start, String end) { this.dates = start + " - " + ((end == null || end.equalsIgnoreCase("null")) ? "no end" : end); }
2
private String readFileAsString(String filename) throws Exception { StringBuilder source = new StringBuilder(); FileInputStream in = new FileInputStream(filename); Exception exception = null; BufferedReader reader; try { reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); Exception inne...
9
public void run() { while (true) { // cambio de colision y actualiza actualiza(); checaColision(); repaint(); // Se actualiza el <code>JFrame</code> repintando el contenido. try { // El thread se duerme. Thread.sleep(80...
2
private String setParam(int columnType) { if (columnType == java.sql.Types.INTEGER) { return "Int"; } else if (columnType == java.sql.Types.VARCHAR || columnType == java.sql.Types.CHAR) { return "String"; } else if (columnType == java.sql.Types.TIMESTAMP) { re...
8