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:net.javacrumbs.smock.common.server.test.CalcEndpoint.java

@PayloadRoot(localPart = "plusRequest", namespace = "http://javacrumbs.net/calc")
public PlusResponse plus(PlusRequest plus) {
    if ((long) plus.getA() + (long) plus.getB() > Integer.MAX_VALUE) {
        throw new IllegalArgumentException("Values are too big.");
    }//www  .j  a v a 2  s.co m
    PlusResponse result = new PlusResponse();
    result.setResult(plus.getA() + plus.getB());
    return result;
}

From source file:org.kuali.maven.plugins.graph.util.Counter.java

public synchronized int increment() {
    Assert.state(value < Integer.MAX_VALUE, "Maximum counter value exceeded");
    return value++;
}

From source file:io.redlink.solrlib.SolrCoreDescriptor.java

@SuppressWarnings("squid:S3725")
static void unpackSolrCoreDir(Path solrCoreBundle, Path solrCoreDir) throws IOException {
    LoggerFactory.getLogger(SolrCoreDescriptor.class).debug("Unpacking SolrCore directory {} to {}",
            solrCoreBundle, solrCoreDir);
    try (Stream<Path> pathStream = Files.find(solrCoreBundle, Integer.MAX_VALUE,
            (p, a) -> Files.isRegularFile(p) && Files.isReadable(p)
                    && "core.properties".equals(String.valueOf(p.getFileName())))) {
        final Optional<Path> coreProperties = pathStream.min(Comparator.comparingInt(Path::getNameCount));
        final Path sourceDir = coreProperties
                .orElseThrow(() -> new IllegalArgumentException(
                        "Invalid solrCoreBundle '" + solrCoreBundle + "': no core.properties found"))
                .getParent();/*from   www . ja v a 2  s  .  com*/

        PathUtils.copyRecursive(sourceDir, solrCoreDir);
    }
}

From source file:eu.planets_project.pp.plato.util.FileUtils.java

public static byte[] getBytesFromFile(File file) throws IOException {
    InputStream is = new FileInputStream(file);
    byte[] bytes;
    try {//  w  ww.jav  a2s  .  c  om

        // Get the size of the file
        long length = file.length();

        if (length > Integer.MAX_VALUE) {
            // File is too large
        }

        // Create the byte array to hold the data
        bytes = new byte[(int) length];

        // Read in the bytes
        int offset = 0;
        int numRead = 0;
        while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
            offset += numRead;
        }

        // Ensure all the bytes have been read in
        if (offset < bytes.length) {
            throw new IOException("Could not completely read file " + file.getName());
        }

    } finally {
        // Close the input stream and return bytes
        is.close();
    }
    return bytes;
}

From source file:ch.aonyx.broker.ib.api.util.ByteArrayRequestBuilder.java

@Override
public RequestBuilder append(final int i) {
    if (i != Integer.MAX_VALUE) {
        bytes = Bytes.concat(bytes, String.valueOf(i).getBytes());
    }//from   w w  w.  j  av  a2s  . c o  m
    appendEol();
    return this;
}

From source file:cn.org.once.cstack.utils.CheckUtils.java

/**
 * Valid not empty input//from  ww  w  .ja v  a 2s  .co  m
 *
 * @param field
 * @param message
 * @throws CheckException
 */
public static void validateInputNotEmpty(String field, String message) throws CheckException {
    validateInputSizeMax(field, message, Integer.MAX_VALUE);
}

From source file:cu.uci.uengine.comparators.DataSetFileComparator.java

@Override
public int compare(File fileA, File fileB) {
    int fileANumber, fileBNumber;
    try {// w w  w.  j  av  a 2s.  c o m
        fileANumber = RegexUtils.getDataSetNumber(fileA);
    } catch (InvalidDataSetNameException ex) {
        log.error(String.format("Invalid dataSet Name: %s. %s", fileA.getAbsolutePath(), ex.getMessage()));
        fileANumber = Integer.MAX_VALUE;//Max value push filename to the end
    }
    try {
        fileBNumber = RegexUtils.getDataSetNumber(fileB);
    } catch (InvalidDataSetNameException ex) {
        log.error(String.format("Invalid dataSets Name: %s. %s", fileB.getAbsolutePath(), ex.getMessage()));
        if (fileANumber == Integer.MAX_VALUE) {
            //If both filename are wrong sort by estndar lexicografical order
            return FilenameUtils.getBaseName(fileA.getName())
                    .compareTo(FilenameUtils.getBaseName(fileB.getName()));
        } else {
            fileBNumber = Integer.MAX_VALUE;
        }
    }

    return fileANumber - fileBNumber;//Max value push filename to the end
}

From source file:net.darkmist.alib.io.Slurp.java

public static byte[] slurp(InputStream stream, long amount) throws IOException {
    if (amount > Integer.MAX_VALUE)
        throw new IOException("Size larger than max int");
    return slurp(stream, (int) amount);
}

From source file:br.com.manish.ahy.kernel.util.FileUtil.java

public static byte[] readFileAsBytes(String path) {

    byte[] fileArray = null;

    try {/* ww  w .j  a  v  a  2s.  c  o m*/
        File file = new File(path);
        if (file.length() > Integer.MAX_VALUE) {
            throw new OopsException("Oversized file :-( can't read it, sorry: " + path);
        }

        fileArray = new byte[(int) file.length()];
        DataInputStream dis;
        dis = new DataInputStream(new FileInputStream(file));
        dis.readFully(fileArray);
        dis.close();

    } catch (Exception e) {
        throw new OopsException(e, "Problems when reading: [" + path + "].");
    }

    return fileArray;
}

From source file:grails.plugin.cache.web.filter.gemfire.GemfirePageFragmentCachingFilter.java

@Override
protected int getTimeToLive(ValueWrapper wrapper) {
    // not applicable yet
    return Integer.MAX_VALUE;
}