Example usage for java.lang Integer MIN_VALUE

List of usage examples for java.lang Integer MIN_VALUE

Introduction

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

Prototype

int MIN_VALUE

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

Click Source Link

Document

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

Usage

From source file:com.ottogroup.bi.asap.operator.json.aggregator.JsonContentAggregatorResult.java

/**
 * Evaluates the referenced aggregated value against the provided value and saves the larger one
 * @param field/* w w w.  j a v a  2s  .  c o  m*/
 * @param fieldValue
 * @param value
 * @throws RequiredInputMissingException
 */
public void evalMaxAggregatedValue(final String field, final String fieldValue, final long value)
        throws RequiredInputMissingException {
    ///////////////////////////////////////////////////////////////////////////////////////////
    // validate provided input
    if (StringUtils.isBlank(field))
        throw new RequiredInputMissingException("Missing required input for parameter 'field'");
    if (StringUtils.isBlank(fieldValue))
        throw new RequiredInputMissingException("Missing required input for parameter 'fieldValue'");
    //
    ///////////////////////////////////////////////////////////////////////////////////////////

    String fieldKey = StringUtils.lowerCase(StringUtils.trim(field));
    String fieldValueKey = StringUtils.lowerCase(StringUtils.trim(fieldValue));
    Map<String, Long> fieldAggregationValues = this.aggregatedValues.get(fieldKey);
    if (fieldAggregationValues == null)
        fieldAggregationValues = new HashMap<>();
    long aggregationValue = (fieldAggregationValues.containsKey(fieldValueKey)
            ? fieldAggregationValues.get(fieldValueKey)
            : Integer.MIN_VALUE);
    if (value > aggregationValue) {
        fieldAggregationValues.put(fieldValue, value);
        this.aggregatedValues.put(fieldKey, fieldAggregationValues);
    }
}

From source file:com.hurence.logisland.serializer.KuraProtobufSerializer.java

private Position buildFromProtoBuf(final KuraPayloadProto.KuraPayload.KuraPosition protoPosition) {
    final Position position = Position.from(
            protoPosition.hasAltitude() ? protoPosition.getAltitude() : Double.MIN_VALUE,
            protoPosition.hasHeading() ? protoPosition.getHeading() : Double.MIN_VALUE,
            protoPosition.hasLatitude() ? protoPosition.getLatitude() : Double.MIN_VALUE,
            protoPosition.hasLongitude() ? protoPosition.getLongitude() : Double.MIN_VALUE,
            protoPosition.hasPrecision() ? protoPosition.getPrecision() : Double.MIN_VALUE,
            protoPosition.hasSatellites() ? protoPosition.getSatellites() : Integer.MIN_VALUE,
            protoPosition.hasStatus() ? protoPosition.getStatus() : Integer.MIN_VALUE,
            protoPosition.hasSpeed() ? protoPosition.getSpeed() : Double.MIN_VALUE,
            protoPosition.hasTimestamp() ? new Date(protoPosition.getTimestamp()) : new Date(0));

    return position;
}

From source file:com.milaboratory.core.alignment.KAlignerTest.java

@Test
public void testRandomCorrectness() throws Exception {
    KAlignerParameters p = gParams.clone().setMapperKValue(6).setAlignmentStopPenalty(Integer.MIN_VALUE)
            .setMapperAbsoluteMinScore(2.1f).setMapperMinSeedsDistance(4).setAbsoluteMinScore(100.0f)
            .setMapperRelativeMinScore(0.8f);
    p.setScoring(new LinearGapAlignmentScoring(NucleotideSequence.ALPHABET,
            ScoringUtils.getSymmetricMatrix(4, -4, 4), -5)).setMaxAdjacentIndels(2);

    KAlignerParameters[] params = new KAlignerParameters[] { p.clone(), p.clone().setFloatingLeftBound(true),
            p.clone().setFloatingRightBound(true),
            p.clone().setFloatingLeftBound(true).setFloatingRightBound(true) };

    RandomDataGenerator rdi = new RandomDataGenerator(new Well19937c(127368647891L));
    int baseSize = its(400, 2000);
    int total = its(3000, 30000);
    int i, id;//from ww w  .j ava 2 s. c o  m

    NucleotideMutationModel mutationModel = MutationModels.getEmpiricalNucleotideMutationModel()
            .multiplyProbabilities(2.0);
    mutationModel.reseed(12343L);

    for (KAlignerParameters parameters : params) {
        long time = 0, timestamp;
        KAligner aligner = new KAligner(parameters);

        int correct = 0, incorrect = 0, miss = 0, scoreError = 0, random = 0;

        List<NucleotideSequence> ncs = new ArrayList<>(baseSize);
        for (i = 0; i < baseSize; ++i) {
            NucleotideSequence reference = randomSequence(NucleotideSequence.ALPHABET, rdi, 100, 300);
            ncs.add(reference);
            aligner.addReference(reference);
        }

        for (i = 0; i < total; ++i) {
            id = rdi.nextInt(0, baseSize - 1);
            NucleotideSequence ref = ncs.get(id);
            int trimRight, trimLeft;
            boolean addLeft, addRight;

            if (parameters.isFloatingLeftBound()) {
                trimLeft = rdi.nextInt(0, ref.size() / 3);
                addLeft = true;
            } else {
                if (rdi.nextInt(0, 1) == 0) {
                    trimLeft = 0;
                    addLeft = true;
                } else {
                    trimLeft = rdi.nextInt(0, ref.size() / 3);
                    addLeft = false;
                }
            }

            if (parameters.isFloatingRightBound()) {
                trimRight = rdi.nextInt(0, ref.size() / 3);
                addRight = true;
            } else {
                if (rdi.nextInt(0, 1) == 0) {
                    trimRight = 0;
                    addRight = true;
                } else {
                    trimRight = rdi.nextInt(0, ref.size() / 3);
                    addRight = false;
                }
            }

            NucleotideSequence subSeq = ref.getRange(trimLeft, ref.size() - trimRight);
            NucleotideSequence left = addLeft ? randomSequence(NucleotideSequence.ALPHABET, rdi, 10, 30)
                    : EMPTY;
            NucleotideSequence right = addRight ? randomSequence(NucleotideSequence.ALPHABET, rdi, 10, 30)
                    : EMPTY;

            Mutations<NucleotideSequence> nucleotideSequenceMutations = generateMutations(subSeq,
                    mutationModel);
            int[] subSeqMutations = nucleotideSequenceMutations.getAllMutations();
            float actionScore = AlignmentUtils.calculateScore(parameters.getScoring(), subSeq.size(),
                    nucleotideSequenceMutations);

            int indels = 0;
            for (int mut : subSeqMutations)
                if (isDeletion(mut) || isInsertion(mut))
                    ++indels;

            NucleotideSequence target = left.concatenate(mutate(subSeq, subSeqMutations)).concatenate(right);

            timestamp = System.nanoTime();
            KAlignmentResult result = aligner.align(target);
            result.calculateAllAlignments();
            time += System.nanoTime() - timestamp;

            boolean found = false;
            for (KAlignmentHit hit : result.hits) {
                if (hit.getId() == id) {
                    //System.out.println(hit.getAlignmentScore());
                    found = true;
                    if (!parameters.isFloatingLeftBound())
                        Assert.assertTrue(hit.getAlignment().getSequence1Range().getFrom() == 0
                                || hit.getAlignment().getSequence2Range().getFrom() == 0);
                    if (!parameters.isFloatingRightBound())
                        Assert.assertTrue(hit.getAlignment().getSequence1Range().getTo() == ref.size()
                                || hit.getAlignment().getSequence2Range().getTo() == target.size());
                    if (hit.getAlignment().getScore() < actionScore
                            && indels <= parameters.getMaxAdjacentIndels()) {
                        ++scoreError;
                        //System.out.println(target);
                        //System.out.println(left);
                        //printAlignment(subSeq, subSeqMutations);
                        //System.out.println(right);
                        //printHitAlignment(hit);
                        ////printAlignment(ncs.get(hit.getId()).getRange(hit.getAlignment().getSequence1Range()),
                        ////        hit.getAlignment().getMutations());
                        //found = true;
                    }
                } else {
                    //printHitAlignment(hit);
                    //System.out.println(hit.getAlignmentScore());
                    ++incorrect;
                }
            }

            if (found)
                ++correct;
            else {
                if (indels <= parameters.getMaxAdjacentIndels()) {
                    ++miss;
                    //System.out.println(target);
                    //System.out.println(left);
                    //printAlignment(subSeq, subSeqMutations);
                    //System.out.println(right);
                }
            }

            NucleotideSequence randomSequence = randomSequence(NucleotideSequence.ALPHABET, rdi,
                    target.size() - 1, target.size());
            for (KAlignmentHit hit : aligner.align(randomSequence).hits) {
                hit.calculateAlignmnet();
                if (hit.getAlignment().getScore() >= 100.0)
                    ++random;
            }

            //if (aligner.align(randomSequence).hits.size() > 0)
            //    random++;
        }

        System.out.println("C=" + correct + ";I=" + incorrect + ";M=" + miss + ";ScE=" + scoreError + ";R="
                + (1.0 * random / baseSize / total) + " AlignmentTime = " + time(time / total));
        Assert.assertEquals(1.0, 1.0 * correct / total, 0.01);
        Assert.assertEquals(0.0, 1.0 * incorrect / total, 0.001);
        Assert.assertEquals(0.0, 1.0 * miss / total, 0.001);
        Assert.assertEquals(0.0, 1.0 * scoreError / total, 0.001);
        Assert.assertEquals(0.0, 1.0 * random / total / baseSize, 5E-6);
    }
}

From source file:com.baidu.oped.apm.common.buffer.AutomaticBufferTest.java

@Test
public void testPutSVarInt() throws Exception {
    Buffer buffer = new AutomaticBuffer(32);
    buffer.putSVar(Integer.MAX_VALUE);
    buffer.putSVar(Integer.MIN_VALUE);
    buffer.putSVar(0);/*  w  w w .j  ava  2  s.  com*/
    buffer.putSVar(1);
    buffer.putSVar(12345);

    buffer.setOffset(0);
    Assert.assertEquals(buffer.readSVarInt(), Integer.MAX_VALUE);
    Assert.assertEquals(buffer.readSVarInt(), Integer.MIN_VALUE);
    Assert.assertEquals(buffer.readSVarInt(), 0);
    Assert.assertEquals(buffer.readSVarInt(), 1);
    Assert.assertEquals(buffer.readSVarInt(), 12345);
}

From source file:edu.cornell.med.icb.goby.modes.SampleQualityScoresMode.java

/**
 * Before each file, reset the state, report the filename about to be processed.
 * @param inputFilename the filename to be processed.
 *///from   w  w w  . j a v  a2  s  . c  om
private void processingStart(final String inputFilename) {
    System.out.printf("Processing %s%n", inputFilename);
    numQualScoresSampled = 0;
    sumQualScores = 0;
    minQualScore = Integer.MAX_VALUE;
    maxQualScore = Integer.MIN_VALUE;
    qualityScoresFound = false;
}

From source file:edu.ku.brc.specify.toycode.mexconabio.CopyPlantsFromGBIF.java

/**
 * /*  ww  w . j  av a 2s  . c  o  m*/
 */
public void processNullKingdom() {
    PrintWriter pw = null;
    try {
        pw = new PrintWriter("gbif_plants_from_null.log");

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    System.out.println("----------------------- Searching NULL ----------------------- ");

    String gbifWhereStr = "FROM raw WHERE kingdom IS NULL";

    long startTime = System.currentTimeMillis();

    String cntGBIFSQL = "SELECT COUNT(*) " + gbifWhereStr;// + " LIMIT 0,1000";
    String gbifSQL = gbifSQLBase + gbifWhereStr;

    System.out.println(cntGBIFSQL);

    long totalRecs = BasicSQLUtils.getCount(srcConn, cntGBIFSQL);
    long procRecs = 0;
    int secsThreshold = 0;

    String msg = String.format("Query: %8.2f secs", (double) (System.currentTimeMillis() - startTime) / 1000.0);
    System.out.println(msg);
    pw.println(msg);
    pw.flush();

    startTime = System.currentTimeMillis();

    Statement gStmt = null;
    PreparedStatement pStmt = null;

    try {
        pw = new PrintWriter("gbif_plants_from_null.log");

        pStmt = dstConn.prepareStatement(pSQL);

        System.out.println("Total Records: " + totalRecs);
        pw.println("Total Records: " + totalRecs);

        gStmt = srcConn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        gStmt.setFetchSize(Integer.MIN_VALUE);

        ResultSet rs = gStmt.executeQuery(gbifSQL);
        ResultSetMetaData rsmd = rs.getMetaData();

        while (rs.next()) {
            String genus = rs.getString(16);
            if (genus == null)
                continue;

            String species = rs.getString(17);

            if (isPlant(colStmtGN, colStmtGNSP, genus, species)
                    || isPlant(colDstStmtGN, colDstStmtGNSP, genus, species)) {

                for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                    Object obj = rs.getObject(i);
                    pStmt.setObject(i, obj);
                }

                try {
                    pStmt.executeUpdate();

                } catch (Exception ex) {
                    System.err.println("For Old ID[" + rs.getObject(1) + "]");
                    ex.printStackTrace();
                    pw.print("For Old ID[" + rs.getObject(1) + "] " + ex.getMessage());
                    pw.flush();
                }

                procRecs++;
                if (procRecs % 10000 == 0) {
                    long endTime = System.currentTimeMillis();
                    long elapsedTime = endTime - startTime;

                    double avergeTime = (double) elapsedTime / (double) procRecs;

                    double hrsLeft = (((double) elapsedTime / (double) procRecs) * (double) totalRecs
                            - procRecs) / HRS;

                    int seconds = (int) (elapsedTime / 60000.0);
                    if (secsThreshold != seconds) {
                        secsThreshold = seconds;

                        msg = String.format(
                                "Elapsed %8.2f hr.mn   Ave Time: %5.2f    Percent: %6.3f  Hours Left: %8.2f ",
                                ((double) (elapsedTime)) / HRS, avergeTime,
                                100.0 * ((double) procRecs / (double) totalRecs), hrsLeft);
                        System.out.println(msg);
                        pw.println(msg);
                        pw.flush();
                    }
                }
            }
        }

    } catch (Exception ex) {
        ex.printStackTrace();

    } finally {
        try {
            if (gStmt != null) {
                gStmt.close();
            }
            if (pStmt != null) {
                pStmt.close();
            }
            pw.close();

        } catch (Exception ex) {

        }
    }
    System.out.println("Done transferring.");
    pw.println("Done transferring.");
}

From source file:com.dtz.plugins.azurehubnotification.AzureHubNotification.java

/**
 * Gets the current registration ID for application on GCM service.
 * <p>//from  w  w w.j a  v  a2s . com
 * If result is empty, the app needs to register.
 *
 * @return registration ID, or empty string if there is no existing
 *         registration ID.
 */
private String getRegistrationId(Context context) {
    final SharedPreferences prefs = getGCMPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId.isEmpty()) {
        Log.i(TAG, "Registration not found.");
        return "";
    }
    // Check if app was updated; if so, it must clear the registration ID
    // since the existing regID is not guaranteed to work with the new
    // app version.
    int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion) {
        Log.i(TAG, "App version changed.");
        return "";
    }
    return registrationId;
}

From source file:LayeredPaneDemo4.java

protected void setupCapturePanel() {
    CapturePanel mouseTrap = new CapturePanel();
    m_rootPane.getLayeredPane().add(mouseTrap, new Integer(Integer.MIN_VALUE));
    mouseTrap.setBounds(0, 0, 10000, 10000);
    setGlassPane(new GlassCapturePanel());
    getGlassPane().setVisible(true);/*from   w  w  w .  ja  v  a2 s.  c o m*/
}

From source file:com.navercorp.pinpoint.common.buffer.AutomaticBufferTest.java

@Test
public void testPutSVInt() throws Exception {
    Buffer buffer = new AutomaticBuffer(32);
    buffer.putSVInt(Integer.MAX_VALUE);
    buffer.putSVInt(Integer.MIN_VALUE);
    buffer.putSVInt(0);/* w  ww  .  j a v  a2s .  co m*/
    buffer.putSVInt(1);
    buffer.putSVInt(12345);

    buffer.setOffset(0);
    Assert.assertEquals(buffer.readSVInt(), Integer.MAX_VALUE);
    Assert.assertEquals(buffer.readSVInt(), Integer.MIN_VALUE);
    Assert.assertEquals(buffer.readSVInt(), 0);
    Assert.assertEquals(buffer.readSVInt(), 1);
    Assert.assertEquals(buffer.readSVInt(), 12345);
}

From source file:net.rptools.tokentool.client.TokenTool.java

/**
 * // ww w  .j  a v a  2 s  .  c  om
 * @author Jamz
 * @throws IOException
 * @since 2.0
 * 
 *        This method loads and processes all the overlays found in user.home/overlays and it can take a minute to load as it creates thumbnail versions for the comboBox so we call this during the
 *        init and display progress in the preLoader (splash screen).
 * 
 */
private TreeItem<Path> cacheOverlays(File dir, TreeItem<Path> parent, int THUMB_SIZE) throws IOException {
    TreeItem<Path> root = new TreeItem<>(dir.toPath());
    root.setExpanded(false);

    log.debug("caching " + dir.getAbsolutePath());

    File[] files = dir.listFiles();
    for (File file : files) {
        if (file.isDirectory()) {
            cacheOverlays(file, root, THUMB_SIZE);
        } else {
            Path filePath = file.toPath();
            TreeItem<Path> imageNode = new TreeItem<>(filePath,
                    ImageUtil.getOverlayThumb(new ImageView(), filePath));
            root.getChildren().add(imageNode);

            notifyPreloader(new Preloader.ProgressNotification((double) loadCount++ / overlayCount));
        }
    }

    if (parent != null) {
        // When we show the overlay image, the TreeItem value is "" so we need to
        // sort those to the bottom for a cleaner look and keep sub dir's at the top.
        // If a node has no children then it's an overlay, otherwise it's a directory...
        root.getChildren().sort(new Comparator<TreeItem<Path>>() {
            @Override
            public int compare(TreeItem<Path> o1, TreeItem<Path> o2) {
                if (o1.getChildren().size() == 0 && o2.getChildren().size() == 0)
                    return 0;
                else if (o1.getChildren().size() == 0)
                    return Integer.MAX_VALUE;
                else if (o2.getChildren().size() == 0)
                    return Integer.MIN_VALUE;
                else
                    return o1.getValue().compareTo(o2.getValue());
            }
        });

        parent.getChildren().add(root);
    }

    return root;
}