Example usage for java.lang Integer MAX_VALUE

List of usage examples for java.lang Integer MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Integer MAX_VALUE.

Prototype

int MAX_VALUE

To view the source code for java.lang Integer MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value an int can have, 231-1.

Usage

From source file:com.example.RestTemplateStoreGatherer.java

@RequestMapping
public CompletableFuture<List<Store>> gather() {
    Scheduler scheduler = Schedulers.elastic();
    return Flux.range(0, Integer.MAX_VALUE) // <1>
            .flatMap(page -> Flux.defer(() -> page(page)).subscribeOn(scheduler), 2) // <2>
            .flatMap(store -> Mono.fromCallable(() -> meta(store)).subscribeOn(scheduler), 4) // <3>
            .take(50) // <4>
            .collectList() // <5>
            .toFuture();//  w w  w  . jav  a2 s . co  m
}

From source file:RWNode.java

private int firstWriter() {
    Enumeration e;/*from  ww w  .  ja  va2s . c  o m*/
    int index;
    for (index = 0, e = waiters.elements(); e.hasMoreElements(); index++) {
        RWNode node = (RWNode) e.nextElement();
        if (node.state == RWNode.WRITER)
            return index;
    }
    return Integer.MAX_VALUE;
}

From source file:cz.alej.michalik.totp.client.OtpPanel.java

/**
 * Pid jeden panel se zznamem/*  w  ww  .  j ava 2 s .c  om*/
 * 
 * @param raw_data
 *            Data z Properties
 * @param p
 *            Properties
 * @param index
 *            Index zznamu - pro vymazn
 */
public OtpPanel(String raw_data, final Properties p, final int index) {
    // Data jsou oddlena stednkem
    final String[] data = raw_data.split(";");

    // this.setBackground(App.COLOR);
    this.setLayout(new GridBagLayout());
    // Mkov rozloen prvk
    GridBagConstraints c = new GridBagConstraints();
    this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100));

    // Tla?tko pro zkoprovn hesla
    final JButton passPanel = new JButton("");
    passPanel.setFont(passPanel.getFont().deriveFont(App.FONT_SIZE));
    passPanel.setBackground(App.COLOR);
    // Zabere celou ku
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 100;
    this.add(passPanel, c);
    passPanel.setText(data[0]);

    // Tla?tko pro smazn
    JButton delete = new JButton("X");
    try {
        String path = "/material-design-icons/action/drawable-xhdpi/ic_delete_black_24dp.png";
        Image img = ImageIO.read(App.class.getResource(path));
        delete.setIcon(new ImageIcon(img));
        delete.setText("");
    } catch (Exception e) {
        System.out.println("Icon not found");
    }
    delete.setFont(delete.getFont().deriveFont(App.FONT_SIZE));
    delete.setBackground(App.COLOR);
    // Zabere kousek vpravo
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.anchor = GridBagConstraints.EAST;
    this.add(delete, c);

    // Akce pro vytvoen a zkoprovn hesla do schrnky
    passPanel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("Generuji kod pro " + data[1]);
            System.out.println(new Base32().decode(data[1].getBytes()).length);
            clip.set(new TOTP(new Base32().decode(data[1].getBytes())).toString());
            System.out.printf("Kd pro %s je ve schrnce\n", data[0]);
            passPanel.setText("Zkoprovno");
            // Zobraz zprvu na 1 vteinu
            int time = 1000;
            // Animace zobrazen zprvy po zkoprovn
            final Timer t = new Timer(time, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    passPanel.setText(data[0]);
                }
            });
            t.start();
            t.setRepeats(false);
        }
    });

    // Akce pro smazn panelu a uloen zmn
    delete.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.printf("Odstrann %s s indexem %d\n", data[0], index);
            p.remove(String.valueOf(index));
            App.saveProperties();
            App.loadProperties();
        }
    });

}

From source file:com.amalto.core.storage.hibernate.InstanceScrollOptimization.java

@Override
public StorageResults visit(Select select) {
    ComplexTypeMetadata mainType = select.getTypes().get(0);
    Paging paging = select.getPaging();// w w w  . ja v  a 2s .c  o  m
    int start = paging.getStart();
    if (start != 0) {
        throw new IllegalStateException(
                "This optimization is only use for iterating over all instances (start is not supported).");
    }
    if (paging.getLimit() != Integer.MAX_VALUE) {
        // Optimization *could* work when page size is set... however it also means the analysis of the query is
        // redirecting to the wrong optimization, and this is an issue.
        throw new UnsupportedOperationException();
    }
    // Perform same query as input *but* adds an order by clause 'by id' that allows efficient filtering (iterator
    // should
    // only return unique results).
    Select copy = select.copy();
    Collection<FieldMetadata> keyFields = mainType.getKeyFields();
    for (FieldMetadata keyField : keyFields) {
        copy.addOrderBy(new OrderBy(new Field(keyField), OrderBy.Direction.ASC));
    }
    Criteria criteria = createCriteria(copy); // Perform the query with order by id.
    // Create the filtered result iterator
    CloseableIterator<DataRecord> nonFilteredIterator = new ScrollableIterator(mappings, storageClassLoader,
            criteria.scroll(), callbacks);
    Predicate isUniqueFilter = new UniquePredicate(); // Unique filter returns only different instances
    Iterator filteredIterator = IteratorUtils.filteredIterator(nonFilteredIterator, isUniqueFilter);
    FilteredIteratorWrapper uniqueIterator = new FilteredIteratorWrapper(nonFilteredIterator, filteredIterator,
            select);
    return new HibernateStorageResults(storage, select, uniqueIterator);
}

From source file:com.elemenopy.backupcopy.filesystem.WatcherManager.java

public static void init(BackupConfig config) throws IOException {
    backupConfig = config;/*  ww w.java 2s.  c o  m*/

    for (RootFolder rootFolder : config.getRootFolders()) {

        WatchService watcher = fileSystem.newWatchService();

        //start monitoring the source folder
        TaskManager.runTask(new WatcherTask(rootFolder, watcher));

        TaskManager.runTask(() -> {
            //traverse the source folder tree, registering subfolders on the watcher
            final WatcherRegisteringFileVisitor visitor = new WatcherRegisteringFileVisitor(rootFolder,
                    watcher);

            try {
                EnumSet<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS);
                Files.walkFileTree(fileSystem.getPath(rootFolder.getPath()), opts, Integer.MAX_VALUE, visitor);
            } catch (IOException ex) {
                logger.error("Error while setting up directory watchers", ex);
            }
        });
    }

}

From source file:org.biopax.validator.rules.ClonedUtilityClassRule.java

public void check(final Validation validation, Model model) {
    Cluster<UtilityClass> algorithm = new Cluster<UtilityClass>() {
        @Override//  w ww  .  j ava2s .  c  om
        public boolean match(UtilityClass a, UtilityClass b) {
            return !a.equals(b) && a.isEquivalent(b);
        }
    };

    Set<Set<UtilityClass>> clusters = algorithm.cluster(model.getObjects(UtilityClass.class),
            Integer.MAX_VALUE);

    Map<UtilityClass, UtilityClass> replacementMap = new HashMap<UtilityClass, UtilityClass>();

    // report the error once for each cluster
    for (Set<UtilityClass> clones : clusters) {
        if (clones.size() < 2)
            continue; //skip unique individuals

        UtilityClass first = clones.iterator().next();
        clones.remove(first); // pop the first element from the clones collection

        if (validation.isFix()) {
            // set "fixed" in advance... fix below
            error(validation, first, "cloned.utility.class", true, clones,
                    first.getModelInterface().getSimpleName());

            for (UtilityClass clone : clones)
                replacementMap.put(clone, first);

        } else {
            // report the problem (not fixed)
            error(validation, first, "cloned.utility.class", false, clones,
                    first.getModelInterface().getSimpleName());
        }
    }

    if (validation.isFix())
        ModelUtils.replace(model, replacementMap);

}

From source file:strat.mining.stratum.proxy.json.JsonRpcRequest.java

protected JsonRpcRequest() {
    Long nextId = nextRequestId.getAndIncrement();
    // Use an integer as id instead of a long when possible. Else, it is
    // harder to match a response with a request since Jackson will parse
    // response with Integer when needed, and long if the value overflow an
    // integer. (Thus, in request maps, Long of the request will never match
    // with the Integer id of the response, even if values are the same).
    if (Integer.MAX_VALUE >= nextId) {
        id = nextId.intValue();//from   ww  w.  ja  va 2  s .co  m
    } else {
        id = nextId;
    }
}

From source file:com.interface21.transaction.interceptor.RuleBasedTransactionAttribute.java

/**
 * Winning rule is the shallowest rule (that is, the closest
 * in the inheritance hierarchy to the exception). If no rule applies (-1),
 * return false./*from w  w  w  .  j a  v a2 s  .  c o  m*/
 * @see com.interface21.transaction.interceptor.TransactionAttribute#rollbackOn(java.lang.Throwable)
 */
public boolean rollbackOn(Throwable t) {
    logger.debug("Applying rules to determine whether transaction should rollback on " + t);
    RollbackRuleAttribute winner = null;
    int deepest = Integer.MAX_VALUE;

    if (this.rollbackRules != null) {
        for (Iterator iter = this.rollbackRules.iterator(); iter.hasNext();) {
            Object next = iter.next();
            // Ignore elements of unknown type
            if (next instanceof RollbackRuleAttribute) {
                RollbackRuleAttribute rule = (RollbackRuleAttribute) next;
                int depth = rule.getDepth(t);
                if (depth >= 0 && depth < deepest) {
                    deepest = depth;
                    winner = rule;
                }
            }
        }
    }
    logger.debug("Winning rollback rule is: " + winner);

    // User superclass behaviour (rollback on unchecked)
    // if no rule matches
    if (winner == null) {
        logger.debug("No relevant rollback rule found: applying superclass default");
        return super.rollbackOn(t);
    }

    return !(winner instanceof NoRollbackRuleAttribute);
}

From source file:au.edu.uq.cmm.paul.servlet.FileView.java

@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
        HttpServletResponse response) throws IOException {
    File file = (File) model.get("file");
    String contentType = (String) model.get("contentType");
    try (FileInputStream fis = new FileInputStream(file)) {
        response.setContentType(contentType);
        long length = file.length();
        if (length <= Integer.MAX_VALUE) {
            response.setContentLength((int) length);
        }//ww  w.jav a  2  s  .c o m
        response.setStatus(HttpServletResponse.SC_OK);
        try (OutputStream os = response.getOutputStream()) {
            byte[] buffer = new byte[8192];
            int nosRead;
            while ((nosRead = fis.read(buffer)) > 0) {
                os.write(buffer, 0, nosRead);
            }
        }
    } catch (FileNotFoundException ex) {
        LOG.info("Cannot access file: " + ex.getLocalizedMessage());
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    }
}

From source file:eu.cloudwave.wp5.feedbackhandler.repositories.aggregations.AggregatedMicroserviceClientRequest.java

private int toInt(long myLong) {
    if (myLong < (long) Integer.MAX_VALUE) {
        return (int) myLong;
    } else {//from   w  w  w .  j av  a2s  . c  o  m
        return Integer.MAX_VALUE;
    }
}