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:dk.netarkivet.common.utils.warc.WARCUtilsInTest.java

/**
 * Read the contents (payload) of an WARC record into a byte array.
 *
 * @param record An WARC record to read from. After reading, the WARC Record will no longer have its own data
 * available for reading.//from  w w  w  . j a  v a  2 s. c o m
 * @return A byte array containing the payload of the WARC record. Note that the size of the payload is calculated
 * by subtracting the contentBegin value from the length of the record (both values included in the record header).
 * @throws IOFailure If there is an error reading the data, or if the record is longer than Integer.MAX_VALUE (since
 * we can't make bigger arrays).
 */
public static byte[] readWARCRecord(WARCRecord record) throws IOFailure {
    ArgumentNotValid.checkNotNull(record, "WARCRecord record");
    if (record.getHeader().getLength() > Integer.MAX_VALUE) {
        throw new IOFailure("WARC Record too long to fit in array: " + record.getHeader().getLength() + " > "
                + Integer.MAX_VALUE);
    }
    // Calculate the length of the payload.
    // the size of the payload is calculated by subtracting
    // the contentBegin value from the length of the record.

    ArchiveRecordHeader header = record.getHeader();
    long length = header.getLength();

    int payloadLength = (int) (length - header.getContentBegin());

    // read from stream
    byte[] tmpbuffer = new byte[payloadLength];
    byte[] buffer = new byte[Constants.IO_BUFFER_SIZE];
    int bytesRead;
    int totalBytes = 0;
    try {
        for (; (totalBytes < payloadLength)
                && ((bytesRead = record.read(buffer)) != -1); totalBytes += bytesRead) {
            System.arraycopy(buffer, 0, tmpbuffer, totalBytes, bytesRead);
        }
    } catch (IOException e) {
        throw new IOFailure("Failure when reading the WARC-record", e);
    }

    // Check if the number of bytes read (= totalbytes) matches the
    // size of the buffer.
    if (tmpbuffer.length != totalBytes) {
        // make sure we only return an array with bytes we actualy read
        byte[] truncateBuffer = new byte[totalBytes];
        System.arraycopy(tmpbuffer, 0, truncateBuffer, 0, totalBytes);
        log.debug("Storing " + totalBytes + " bytes. Expected to store: " + tmpbuffer.length);
        return truncateBuffer;
    } else {
        return tmpbuffer;
    }

}

From source file:io.github.GoldenDeveloper79.TheBasics.Commands.MuteCMD.java

public MuteCMD() {
    super(new String[] { "mute" }, 2, Integer.MAX_VALUE, MultiPlayer.ALWAYS);
}

From source file:fr.aliasource.webmail.ldap.BookSource.java

@Override
public List<MinigContact> findAll(String userId, String userPassword) {
    return find(userId, userPassword, "", Integer.MAX_VALUE);
}

From source file:com.yanzhenjie.andserver.upload.HttpUploadContext.java

@Override
public int getContentLength() {
    long contentLength = contentLength();
    return contentLength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) contentLength;
}

From source file:hu.petabyte.redflags.engine.gear.indicator.hu.NumberOfOffersLowIndicator.java

@Override
protected IndicatorResult flagImpl(Notice notice) {
    if (fetchProcedureType(notice).matches("PR-[TV]")) {
        return irrelevantData();
    }//  w  w w  .j a v  a  2 s . c  o  m

    int minNOO = Integer.MAX_VALUE;
    for (Award a : notice.getAwards()) {
        if (a.getNumberOfOffers() > 0) {
            minNOO = Math.min(minNOO, a.getNumberOfOffers());
        }
    }

    if (minNOO < minOffers) {
        if (1 == minNOO) {
            return returnFlag("info1");
        }
        if (2 == minNOO) {
            return returnFlag("info2");
        }
    }

    return null;
}

From source file:com.fusesource.forge.jmstest.tests.simple.SimpleConsumer.java

protected void run() {
    Connection con = null;/*from  w  ww  . j  a  va  2s.  c  o m*/
    Session session = null;
    final CountDownLatch latch = new CountDownLatch(Integer.MAX_VALUE);
    try {
        con = getConnection();
        session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination dest = getDestinationProvider().getDestination(session, "queue:TEST");
        MessageConsumer consumer = session.createConsumer(dest);
        consumer.setMessageListener(new MessageListener() {
            public void onMessage(Message msg) {
                String grp = null;
                long nr = 0L;
                try {
                    grp = msg.getStringProperty("JMSXGroupID");
                    nr = msg.getLongProperty("MsgNr");
                } catch (JMSException jme) {
                }
                log().info("Received Message Group=(" + grp + ") MsgNr=" + nr);
                latch.countDown();
            }
        });
        con.start();
        latch.await();
        con.close();
    } catch (Exception e) {
    } finally {
        if (con != null) {
            try {
                con.close();
            } catch (Exception e) {
            }
        }
    }
}

From source file:edu.berkeley.compbio.sequtils.sequencereader.RandomSectionList.java

public SequenceFragmentMetadata next()//throws IOException, NotEnoughSequenceException
{
    return new SequenceFragmentMetadata(null, randomName(), null,
            MersenneTwisterFast.randomInt(Integer.MAX_VALUE));
}

From source file:com.cloudera.oryx.common.math.VectorsTest.java

@Test
public void testSparse() {
    RealVector sparse = Vectors.sparse(Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, sparse.getDimension());
    assertEquals(0.0, sparse.getEntry(0));
}

From source file:at.tuwien.minimee.migration.MigrationService.java

public static byte[] getBytesFromFile(File file) throws IOException {
    InputStream is = new FileInputStream(file);

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

    if (length > Integer.MAX_VALUE) {
        // File is too large
    }// w w w  . ja v a 2 s .  c  o  m

    // Create the byte array to hold the data
    byte[] 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());
    }

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

From source file:com.asakusafw.yaess.tools.GenerateExecutionId.java

static int execute(String[] args) {
    assert args != null;
    Configuration conf;//from w  w  w. j a v  a 2  s . c  om
    try {
        conf = parseConfiguration(args);
    } catch (Exception e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(Integer.MAX_VALUE);
        formatter.printHelp(
                MessageFormat.format("java -classpath ... {0}", GenerateExecutionId.class.getName()), OPTIONS,
                true);
        e.printStackTrace(System.out);
        return 1;
    }
    try {
        String executionId = computeExecutionId(conf);
        System.out.print(executionId);
    } catch (Exception e) {
        e.printStackTrace();
        return 1;
    }
    return 0;
}