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:org.zenoss.app.consumer.metric.impl.MetricServicePoster.java

private static final DefaultHttpClient newHttpClient() {
    DefaultHttpClient httpClient = new DefaultHttpClient();
    httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(Integer.MAX_VALUE, true));
    return httpClient;
}

From source file:com.lleps.jsamp.world.NoStreamingWorld.java

public NoStreamingWorld(Interior interior) {
    this.interior = Preconditions.checkNotNull(interior);
    this.worldId = RandomUtils.nextInt(0, Integer.MAX_VALUE);
    entities = new HashSet<>();
    players = new HashSet<>();
}

From source file:de.tudarmstadt.ukp.dkpro.c4corpus.hadoop.statistics.vocabulary.TopNWordsCorrelation.java

/**
 * Computes Spearman correlation by comparing order of two corpora vocabularies
 *
 * @param goldCorpus  gold corpus//from w ww.  j av  a2 s  .co  m
 * @param otherCorpus other corpus
 * @param topN        how many entries from the gold corpus should be taken
 * @throws IOException I/O exception
 */
public static void spearmanCorrelation(File goldCorpus, File otherCorpus, int topN) throws IOException {
    LinkedHashMap<String, Integer> gold = loadCorpusToRankedVocabulary(new FileInputStream(goldCorpus));
    LinkedHashMap<String, Integer> other = loadCorpusToRankedVocabulary(new FileInputStream(otherCorpus));

    double[][] matrix = new double[topN][];

    if (gold.size() < topN) {
        throw new IllegalArgumentException(
                "topN (" + topN + ") cannot be greater than vocabulary size (" + gold.size() + ")");
    }

    Iterator<Map.Entry<String, Integer>> iterator = gold.entrySet().iterator();
    int counter = 0;
    while (counter < topN) {
        Map.Entry<String, Integer> next = iterator.next();
        String goldWord = next.getKey();
        Integer goldValue = next.getValue();

        // look-up position in other corpus
        Integer otherValue = other.get(goldWord);
        if (otherValue == null) {
            //                System.err.println("Word " + goldWord + " not found in the other corpus");
            otherValue = Integer.MAX_VALUE;
        }

        matrix[counter] = new double[2];
        matrix[counter][0] = goldValue;
        matrix[counter][1] = otherValue;

        counter++;
    }

    RealMatrix realMatrix = new Array2DRowRealMatrix(matrix);

    SpearmansCorrelation spearmansCorrelation = new SpearmansCorrelation(realMatrix);
    double pValue = spearmansCorrelation.getRankCorrelation().getCorrelationPValues().getEntry(0, 1);
    double correlation = spearmansCorrelation.getRankCorrelation().getCorrelationMatrix().getEntry(0, 1);

    System.out.println("Gold: " + goldCorpus.getName());
    System.out.println("Other: " + otherCorpus.getName());
    System.out.printf(Locale.ENGLISH, "Top N:\n%d\nCorrelation\n%.3f\np-value\n%.3f\n", topN, correlation,
            pValue);
}

From source file:info.mikaelsvensson.devtools.analysis.shared.AbstractLog.java

public static <T extends AbstractSample> int calculateMin(Collection<T> samples) {
    int min = Integer.MAX_VALUE;
    for (T sample : samples) {
        min = sample.getResponseTime() < min ? sample.getResponseTime() : min;
    }//from   ww  w . j  av a  2  s  .c om
    return min;
}

From source file:com.dianping.avatar.cache.util.CacheAnnotationUtils.java

/**
 * Retrieve the cache key values from entity instance
 *//*from www  .j  ava 2  s.c om*/
public static Object[] getCacheKeyValues(Object entity) {
    if (entity == null) {
        throw new IllegalArgumentException("Entity is null.");
    }

    Class<?> cz = entity.getClass();

    Cache cache = cz.getAnnotation(Cache.class);

    if (cache == null) {
        throw new SystemException("The entity must be annotated by Cache.");
    }

    Field[] fields = ClassUtils.getDeclaredFields(cz);

    final List<OrderedField> cacheFields = new ArrayList<OrderedField>();

    // Extract annotated fields
    for (int i = 0; i < fields.length; i++) {
        Field f = fields[i];
        CacheParam fCache = f.getAnnotation(CacheParam.class);
        if (fCache != null) {
            cacheFields.add(new OrderedField(f, i, fCache.order()));
        }
    }

    // Extract declared fields
    for (int i = 0; i < cache.fields().length; i++) {
        String fieldName = cache.fields()[i];
        if (fieldName.isEmpty()) {
            continue;
        }
        Field f = ReflectionUtils.findField(cz, fieldName);
        if (f == null) {
            throw new IllegalArgumentException(
                    "Invalid cahce parameter " + fieldName + ", the filed is not exists.");
        }

        cacheFields.add(new OrderedField(f, i, -Integer.MAX_VALUE + i));
    }

    Collections.sort(cacheFields);

    Object[] values = new Object[cacheFields.size()];

    for (int i = 0; i < cacheFields.size(); i++) {
        OrderedField oField = cacheFields.get(i);

        ReflectionUtils.makeAccessible((Field) oField.field);

        values[i] = ReflectionUtils.getField((Field) oField.field, entity);
    }

    return values;
}

From source file:com.microsoft.windowsazure.services.core.RetryPolicyFilter.java

@Override
public Response handle(Request request, Next next) throws Exception {
    // Only the last added retry policy should be active
    if (request.getProperties().containsKey("RetryPolicy"))
        return next.handle(request);
    request.getProperties().put("RetryPolicy", this);

    // Retry the operation as long as retry policy tells us to do so
    for (int retryCount = 0;; ++retryCount) {
        // Mark the stream before passing the request through
        if (getEntityStream(request) != null) {
            getEntityStream(request).mark(Integer.MAX_VALUE);
        }//w  w w . ja v  a  2 s  . co  m

        // Pass the request to the next handler
        Response response = null;
        Exception error = null;
        try {
            response = next.handle(request);
        } catch (Exception e) {
            error = e;
        }

        // Determine if we should retry according to retry policy
        boolean shouldRetry = retryPolicy.shouldRetry(retryCount, response, error);
        if (!shouldRetry) {
            if (error != null)
                throw error;
            return response;
        }

        // Reset the stream before retrying
        if (getEntityStream(request) != null) {
            getEntityStream(request).reset();
        }

        // Backoff for some time according to retry policy
        int backoffTime = retryPolicy.calculateBackoff(retryCount, response, error);
        log.info(String.format(
                "Request failed. Backing off for %1s milliseconds before retrying (retryCount=%2d)",
                backoffTime, retryCount));
        backoff(backoffTime);
    }
}

From source file:eu.transkribus.swt_canvas.util.GeomUtils.java

/**
 * Returns the distance and the closest segment of a point (x,y) to a polygon given as a series of points
 * @param isClosedShape True if this is a closes polygon or false if its a polyline
 *///  w  w w  .ja v  a  2  s.co m
public static Pair<Double, java.awt.geom.Line2D.Double> getDistToPolygonAndClosestSegment(List<Point> pts,
        double x, double y, boolean isClosedShape) {
    double minDist = Integer.MAX_VALUE;
    java.awt.geom.Line2D.Double minLine = new java.awt.geom.Line2D.Double(0, 0, 0, 0);

    int N = isClosedShape ? pts.size() : pts.size() - 1;

    for (int i = 0; i < N; ++i) {
        java.awt.geom.Line2D.Double line = new java.awt.geom.Line2D.Double(pts.get(i),
                pts.get((i + 1) % pts.size()));
        double d = line.ptSegDistSq(x, y);
        //         logger.debug("d = "+d);
        if (d < minDist) {
            minDist = d;
            minLine = line;
        }
    }

    return Pair.of(minDist, minLine);
}

From source file:com.github.mavenplugins.doctest.OrderDoctest.java

/**
 * the last test method./*from   ww w.  j  a v  a 2s. c  o  m*/
 */
@SimpleDoctest("http://localhost:12345/order")
@DoctestOrder(Integer.MAX_VALUE)
public void last(HttpResponse response, byte[] entity) throws Exception {
    assertEquals("65", new String(entity));
}

From source file:com.cooksys.httpserver.IncomingHttpHandler.java

@Override
public void handle(final HttpRequest request, final HttpResponse response, HttpContext context)
        throws HttpException, IOException {
    //put the entity stream into a string - sending this object to JavaFX runlater
    //queue causes the stream to close, so we will have to do it here
    final String messageBody;
    if (request instanceof BasicHttpEntityEnclosingRequest) {
        HttpEntity entity = ((BasicHttpEntityEnclosingRequest) request).getEntity();
        if (entity.getContentLength() < Integer.MAX_VALUE / 2) {
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            entity.writeTo(stream);/*from  w  ww  .j a v a  2 s.  com*/
            messageBody = stream.toString();
        } else {
            messageBody = "Data too large";
        }
    } else {
        messageBody = "";
    }

    //Print the raw request message to the message console
    rawMessage = "\n\n";
    rawMessage += request.getRequestLine().toString() + "\n";

    Header[] headers = request.getAllHeaders();
    for (Header header : headers) {
        rawMessage += header.getName() + ": " + header.getValue() + "\n";
    }
    rawMessage += "\n";
    rawMessage += messageBody;

    //get the default response from the model, and copy it to the already provided HttpResponse parameter
    HttpResponse defaultResponse = serverModel.getResponseList().get(serverModel.getDefaultResponseIndex())
            .encodeResponse();

    response.setStatusLine(defaultResponse.getStatusLine());
    response.setEntity(defaultResponse.getEntity());
    response.setHeaders(defaultResponse.getAllHeaders());

    System.out.println("sending response -> " + response.toString());
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            //update the model with the console message
            String originalConsole = serverModel.getMessageConsole().getValue();
            serverModel.getMessageConsole()
                    .set(originalConsole == null ? rawMessage : originalConsole + rawMessage);
        }
    });

    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            //update the model with the new message
            serverModel.incomingRequest(request, messageBody);
        }
    });
    System.out.println("handle() end");
}

From source file:craterdog.collections.Stack.java

/**
 * This constructor creates a new stack of unlimited capacity.
 */
public Stack() {
    logger.entry();
    this.capacity = Integer.MAX_VALUE;
    logger.exit();
}