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:edu.ku.brc.specify.toycode.mexconabio.CopyPlantsFromGBIF.java

/**
 * @param server//w  w  w  . ja  va  2s  . c om
 * @param port
 * @param dbName
 * @param username
 * @param pwd
 * @throws SQLException 
 */
public void connectToCOLTaxa(final String server, final String port, final String dbName, final String username,
        final String pwd) throws SQLException {
    colConn = connect(server, port, dbName, username, pwd);

    colStmtGNSP = dstConn.prepareStatement(TAXSEARCH_GNSP_SQL);
    colStmtGNSP.setFetchSize(Integer.MIN_VALUE);

    colStmtGN = dstConn.prepareStatement(TAXSEARCH_GN_SQL);
    colStmtGN.setFetchSize(Integer.MIN_VALUE);
}

From source file:com.jeeframework.util.validate.GenericTypeValidator.java

/**
 *  Checks if the value can safely be converted to an int primitive.
 *
 *@param  value   The value validation is being performed on.
 *@param  locale  The locale to use to parse the number (system default if
 *      null)// w  w w  .ja v a 2 s. c om
 *@return the converted Integer value.
 */
public static Integer formatInt(String value, Locale locale) {
    Integer result = null;

    if (value != null) {
        NumberFormat formatter = null;
        if (locale != null) {
            formatter = NumberFormat.getNumberInstance(locale);
        } else {
            formatter = NumberFormat.getNumberInstance(Locale.getDefault());
        }
        formatter.setParseIntegerOnly(true);
        ParsePosition pos = new ParsePosition(0);
        Number num = formatter.parse(value, pos);

        // If there was no error      and we used the whole string
        if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) {
            if (num.doubleValue() >= Integer.MIN_VALUE && num.doubleValue() <= Integer.MAX_VALUE) {
                result = new Integer(num.intValue());
            }
        }
    }

    return result;
}

From source file:eu.stratosphere.pact.runtime.task.util.OutputEmitterTest.java

@Test
public void testPartitionHash() {
    // Test for IntValue
    @SuppressWarnings("unchecked")
    final TypeComparator<Record> intComp = new RecordComparatorFactory(new int[] { 0 },
            new Class[] { IntValue.class }).createComparator();
    final ChannelSelector<SerializationDelegate<Record>> oe1 = new OutputEmitter<Record>(
            ShipStrategyType.PARTITION_HASH, intComp);
    final SerializationDelegate<Record> delegate = new SerializationDelegate<Record>(
            new RecordSerializerFactory().getSerializer());

    int numChans = 100;
    int numRecs = 50000;
    int[] hit = new int[numChans];

    for (int i = 0; i < numRecs; i++) {
        IntValue k = new IntValue(i);
        Record rec = new Record(k);

        delegate.setInstance(rec);/*  w  w w  .  j a  va2  s .  c  o  m*/

        int[] chans = oe1.selectChannels(delegate, hit.length);
        for (int j = 0; j < chans.length; j++) {
            hit[chans[j]]++;
        }
    }

    int cnt = 0;
    for (int i = 0; i < hit.length; i++) {
        assertTrue(hit[i] > 0);
        cnt += hit[i];
    }
    assertTrue(cnt == numRecs);

    // Test for StringValue
    @SuppressWarnings("unchecked")
    final TypeComparator<Record> stringComp = new RecordComparatorFactory(new int[] { 0 },
            new Class[] { StringValue.class }).createComparator();
    final ChannelSelector<SerializationDelegate<Record>> oe2 = new OutputEmitter<Record>(
            ShipStrategyType.PARTITION_HASH, stringComp);

    numChans = 100;
    numRecs = 10000;

    hit = new int[numChans];

    for (int i = 0; i < numRecs; i++) {
        StringValue k = new StringValue(i + "");
        Record rec = new Record(k);
        delegate.setInstance(rec);

        int[] chans = oe2.selectChannels(delegate, hit.length);
        for (int j = 0; j < chans.length; j++) {
            hit[chans[j]]++;
        }
    }

    cnt = 0;
    for (int i = 0; i < hit.length; i++) {
        assertTrue(hit[i] > 0);
        cnt += hit[i];
    }
    assertTrue(cnt == numRecs);

    // test hash corner cases
    final TestIntComparator testIntComp = new TestIntComparator();
    final ChannelSelector<SerializationDelegate<Integer>> oe3 = new OutputEmitter<Integer>(
            ShipStrategyType.PARTITION_HASH, testIntComp);
    final SerializationDelegate<Integer> intDel = new SerializationDelegate<Integer>(new IntSerializer());

    numChans = 100;

    // MinVal hash
    intDel.setInstance(Integer.MIN_VALUE);
    int[] chans = oe3.selectChannels(intDel, numChans);
    assertTrue(chans.length == 1);
    assertTrue(chans[0] >= 0 && chans[0] <= numChans - 1);

    // -1 hash
    intDel.setInstance(-1);
    chans = oe3.selectChannels(intDel, hit.length);
    assertTrue(chans.length == 1);
    assertTrue(chans[0] >= 0 && chans[0] <= numChans - 1);

    // 0 hash
    intDel.setInstance(0);
    chans = oe3.selectChannels(intDel, hit.length);
    assertTrue(chans.length == 1);
    assertTrue(chans[0] >= 0 && chans[0] <= numChans - 1);

    // 1 hash
    intDel.setInstance(1);
    chans = oe3.selectChannels(intDel, hit.length);
    assertTrue(chans.length == 1);
    assertTrue(chans[0] >= 0 && chans[0] <= numChans - 1);

    // MaxVal hash
    intDel.setInstance(Integer.MAX_VALUE);
    chans = oe3.selectChannels(intDel, hit.length);
    assertTrue(chans.length == 1);
    assertTrue(chans[0] >= 0 && chans[0] <= numChans - 1);
}

From source file:com.zimbra.cs.db.MySQL.java

@Override
public void enableStreaming(Statement stmt) throws SQLException {
    if (LC.jdbc_results_streaming_enabled.booleanValue()) {
        stmt.setFetchSize(Integer.MIN_VALUE);
    }/*from w  w  w . j  av  a2  s . c  om*/
}

From source file:com.facebook.presto.operator.scalar.MathFunctions.java

@Description("absolute value")
@ScalarFunction("abs")
@SqlType(StandardTypes.INTEGER)/*w  ww.ja  v a  2 s .  c om*/
public static long absInteger(@SqlType(StandardTypes.INTEGER) long num) {
    checkCondition(num != Integer.MIN_VALUE, NUMERIC_VALUE_OUT_OF_RANGE,
            "Value -2147483648 is out of range for abs(integer)");
    return Math.abs(num);
}

From source file:com.icesoft.faces.component.dataexporter.DataExporter.java

public UIData getUIData() {
    String forStr = getFor();//from   ww w.  ja va2s .  c  o m
    UIData forComp = (UIData) CoreComponentUtils.findComponent(forStr, this);

    if (forComp == null) {
        throw new IllegalArgumentException(
                "could not find UIData referenced by attribute @for = '" + forStr + "'");
    } else if (!(forComp instanceof UIData)) {
        throw new IllegalArgumentException("uiComponent referenced by attribute @for = '" + forStr
                + "' must be of type " + UIData.class.getName() + ", not type " + forComp.getClass().getName());
    }
    //compare with cached DataModel to check for updates
    if (_origDataModelHash != 0 && _origDataModelHash != forComp.getValue().hashCode()) {
        reset();
    }
    if (!isIgnorePagination() && ((first != Integer.MIN_VALUE && first != forComp.getFirst())
            || (rows != Integer.MIN_VALUE && rows != forComp.getRows()))) {
        reset();
    }

    Object value = forComp.getValue();
    if (null != value) {
        _origDataModelHash = forComp.getValue().hashCode();
    }
    return forComp;
}

From source file:org.eclipse.swt.examples.browser.demos.Pawns.java

static int eval(byte[] g) {
    int cntWhite = 0, cntBlack = 0, cntEmpty = 0;
    int cntWhiteWallAdvantage = 0, cntBlackWallAdvantage = 0;
    for (int i = 0; i < 64; i++) {
        if (g[i] == WHITE) {
            cntWhite++;/*  w  w  w  .  ja  v  a2s . c o  m*/
            cntWhiteWallAdvantage += gameWallWeight[i];
        } else if (g[i] == BLACK) {
            cntBlack++;
            cntBlackWallAdvantage += gameWallWeight[i];
        } else if (g[i] == EMPTY)
            cntEmpty++;
    }
    if (cntEmpty == 0) {
        if (cntWhite > cntBlack)
            return Integer.MAX_VALUE; /* White wins */
        if (cntWhite < cntBlack)
            return Integer.MIN_VALUE; /* Black wins */
        return 0; /* Stalemate */
    }
    return cntWhite + cntWhiteWallAdvantage - cntBlack - cntBlackWallAdvantage;
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEPD201xxDataImpl.java

public EEPD201xxDataImpl(int EEPType, Mode mode) {
    this(EEPType, null, -1, null, Integer.MIN_VALUE, MeasurementUnit.UNKNOWN, null, mode);
}

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

/**
 * Reset the input file lists and cumulative statistics to default values.
 *//*from w w  w  .  ja  v a2s  .  c  o  m*/
public void reset() {
    inputFiles.clear();
    minReadLength = Integer.MAX_VALUE;
    maxReadLength = Integer.MIN_VALUE;
    numberOfReads = 0;
    cumulativeReadLength = 0;
}

From source file:com.rapidminer.operator.preprocessing.filter.InfiniteValueReplenishment.java

/**
 * Replaces the values//from   w  ww.  j a v a 2s .c o m
 *
 * @throws UndefinedParameterError
 */
@Override
public double getReplenishmentValue(int functionIndex, ExampleSet exampleSet, Attribute attribute)
        throws UndefinedParameterError {
    int chosen = getParameterAsInt(PARAMETER_REPLENISHMENT_WHAT);
    switch (functionIndex) {
    case NONE:
        return Double.POSITIVE_INFINITY;
    case ZERO:
        return 0.0;
    case MAX_BYTE:
        return (chosen == 0) ? Byte.MAX_VALUE : Byte.MIN_VALUE;
    case MAX_INT:
        return (chosen == 0) ? Integer.MAX_VALUE : Integer.MIN_VALUE;
    case MAX_DOUBLE:
        return (chosen == 0) ? Double.MAX_VALUE : -Double.MAX_VALUE;
    case MISSING:
        return Double.NaN;
    case VALUE:
        return getParameterAsDouble(PARAMETER_REPLENISHMENT_VALUE);
    default:
        throw new RuntimeException("Illegal value functionIndex: " + functionIndex);
    }
}