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:games.stendhal.server.entity.npc.condition.TextHasNumberCondition.java

/**
 * Creates a new TextHasNumberCondition which checks for a positive integer.
 *//*from w ww  . j ava 2  s.c  o  m*/
public TextHasNumberCondition() {
    this.min = 0;
    this.max = Integer.MAX_VALUE;
}

From source file:grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter.java

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

From source file:com.mirth.connect.server.util.FileUtil.java

/**
 * Returns the contents of the file in a byte array.
 * //w w  w .  ja  va  2s .c om
 * @deprecated
 * @see org.apache.commons.io.FileUtils#readFileToByteArray(File)
 * @param fileName
 * @return
 * @throws IOException
 */
public static byte[] readBytes(String fileName) throws IOException {
    File file = new File(fileName);
    InputStream is = new FileInputStream(file);

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

    // You cannot create an array using a long type.
    // It needs to be an int type.
    // Before converting to an int type, check
    // to ensure that file is not larger than Integer.MAX_VALUE.
    if (length > Integer.MAX_VALUE) {
        // File is too large
        throw new IOException("File too large " + file.getName());
    }

    // 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:org.eclipse.swt.examples.paint.SolidPolygonFigure.java

@Override
public void addDamagedRegion(FigureDrawContext fdc, Region region) {
    int xmin = Integer.MAX_VALUE, ymin = Integer.MAX_VALUE;
    int xmax = Integer.MIN_VALUE, ymax = Integer.MIN_VALUE;

    for (int i = 0; i < points.length; i += 2) {
        if (points[i] < xmin)
            xmin = points[i];//from   w ww  .j  a v a 2 s.  c o m
        if (points[i] > xmax)
            xmax = points[i];
        if (points[i + 1] < ymin)
            ymin = points[i + 1];
        if (points[i + 1] > ymax)
            ymax = points[i + 1];
    }
    region.add(fdc.toClientRectangle(xmin, ymin, xmax, ymax));
}

From source file:com.github.fge.jsonschema.core.keyword.syntax.checkers.helpers.PositiveIntegerSyntaxChecker.java

@Override
protected void checkValue(final Collection<JsonPointer> pointers, final MessageBundle bundle,
        final ProcessingReport report, final SchemaTree tree) throws ProcessingException {
    final JsonNode node = getNode(tree);

    if (!node.canConvertToInt()) {
        report.error(newMsg(tree, bundle, "common.integerTooLarge").put("max", Integer.MAX_VALUE));
        return;//from   w ww  .  jav  a  2 s .com
    }

    if (node.intValue() < 0)
        report.error(newMsg(tree, bundle, "common.integerIsNegative"));
}

From source file:com.google.uzaygezen.core.BoundedRollupTest.java

@Test
public void empty() {
    BoundedRollup<Integer, LongContent> rollup = BoundedRollup.create(TestUtils.ZERO_LONG_CONTENT,
            Integer.MAX_VALUE);
    Assert.assertNull(rollup.finish());//  w  ww.j a va2s  . c o m
}

From source file:grails.plugin.cache.web.filter.ehcache.EhcachePageFragmentCachingFilter.java

@Override
protected int getTimeToLive(ValueWrapper wrapper) {
    if (wrapper instanceof GrailsValueWrapper) {
        Element e = (Element) ((GrailsValueWrapper) wrapper).getNativeWrapper();
        return e.getTimeToLive();
    }//ww w.jav a2s .  co m
    return Integer.MAX_VALUE;
}

From source file:com.streamsets.datacollector.util.TestConfiguration.java

@Test
public void testBasicMethods() {
    Configuration conf = new Configuration();

    Assert.assertTrue(conf.getNames().isEmpty());

    conf.set("s", "S");
    conf.set("b", true);
    conf.set("i", Integer.MAX_VALUE);
    conf.set("l", Long.MAX_VALUE);

    Assert.assertTrue(conf.hasName("s"));

    Assert.assertEquals(ImmutableSet.of("s", "b", "i", "l"), conf.getNames());
    Assert.assertEquals("S", conf.get("s", "D"));
    Assert.assertEquals(true, conf.get("b", false));
    Assert.assertEquals(Integer.MAX_VALUE, conf.get("i", 1));
    Assert.assertEquals(Long.MAX_VALUE, conf.get("l", 2l));

    Assert.assertEquals("D", conf.get("x", "D"));
    Assert.assertEquals(false, conf.get("x", false));
    Assert.assertEquals(1, conf.get("x", 1));
    Assert.assertEquals(2l, conf.get("x", 2l));

    conf.unset("s");
    Assert.assertFalse(conf.hasName("s"));
    Assert.assertEquals(null, conf.get("s", null));
}

From source file:cloudfoundry.norouter.Main.java

@Bean
@Order(Integer.MAX_VALUE)
@Qualifier("boss")
NettyEventLoopGroupFactoryBean bossGroup() {
    return new NettyEventLoopGroupFactoryBean(1);
}

From source file:org.nuxeo.client.api.objects.blob.Blob.java

@JsonIgnore
public int getLength() {
    long length = file.length();
    if (length > (long) Integer.MAX_VALUE) {
        return -1;
    }/*from w w w .  ja v a  2  s .  c  o m*/
    return (int) length;
}