Example usage for java.lang Long MIN_VALUE

List of usage examples for java.lang Long MIN_VALUE

Introduction

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

Prototype

long MIN_VALUE

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

Click Source Link

Document

A constant holding the minimum value a long can have, -263.

Usage

From source file:com.tilab.fiware.metaware.service.AlgorithmServiceTest.java

/**
 * Test of createAlgorithm method, of class AlgorithmService.
 *//*from w  w w  .j  ava 2  s. c  o  m*/
@Test
public void testCreateAlgorithm() {
    System.out.println("createAlgorithm");
    Algorithm algorithm = new Algorithm("algorithm test name", "algorithm test description", "test",
            Long.MIN_VALUE, Long.MIN_VALUE, null, null, "private", "model test", "sub-model test",
            "hive query test", Long.MIN_VALUE, 42, "algo.test.com"); // perm list and owner id are inserted after;
    AlgorithmService instance = new AlgorithmService();
    algorithm.setPermissions(Arrays.asList(perm1));
    algorithm.setOwner(userId2);
    Algorithm expResult = algorithm;
    String algoId = instance.createAlgorithm(algorithm);
    Algorithm result = instance.getAlgorithm(algoId);
    assertEquals(expResult, result);
    instance.deleteAlgorithm(algoId);
}

From source file:com.thinkbiganalytics.spark.validation.HCatDataTypeTest.java

@Test
public void testIsValueConvertibleToBigInteger() throws Exception {

    HCatDataType type = HCatDataType.getDataTypes().get("bigint");

    assertTrue(type.isValueConvertibleToType("0"));
    assertTrue(type.isValueConvertibleToType(Long.MAX_VALUE + ""));
    assertTrue(type.isValueConvertibleToType(Long.MIN_VALUE + ""));

    assertTrue(type.isValueConvertibleToType(null));
    assertTrue(type.isValueConvertibleToType(""));

    assertFalse(type.isValueConvertibleToType("21.1"));
    assertFalse(type.isValueConvertibleToType("-20.001"));

}

From source file:it.doqui.index.ecmengine.business.personalization.multirepository.node.index.FullIndexRecoveryComponent.java

@Override
protected void reindexImpl() {
    logger.debug("[FullIndexRecoveryComponent::reindexImpl] BEGIN");

    try {/*w  w  w . ja va  2  s  . co m*/
        final String currentRepository = RepositoryManager.getCurrentRepository();
        String recoveryModeString = RepositoryManager.getInstance().getRepository(currentRepository)
                .getIndexRecoveryMode();
        if (recoveryModeString == null) { // Default: validate
            recoveryModeString = "VALIDATE";
        }
        RecoveryMode recoveryMode = RecoveryMode.valueOf(recoveryModeString);
        if (logger.isDebugEnabled()) {
            logger.debug("[FullIndexRecoveryComponent::reindexImpl] " + "Repository '" + currentRepository
                    + "' -- " + "Performing index recovery for type: " + recoveryMode);
        }
        // Ignore when NONE
        if (recoveryMode == RecoveryMode.NONE) {
            return;
        }

        // put the server into read-only mode for the duration
        boolean allowWrite = !transactionService.isReadOnly();
        try {
            if (lockServer) {
                // set the server into read-only mode
                transactionService.setAllowWrite(false);
            }

            // do we need to perform a full recovery
            // Check that the first and last meaningful transactions are indexed 
            List<Transaction> startTxns = nodeDaoService.getTxnsByCommitTimeAscending(Long.MIN_VALUE,
                    Long.MAX_VALUE, 10, null);
            boolean startAllPresent = areTxnsInIndex(startTxns);
            List<Transaction> endTxns = nodeDaoService.getTxnsByCommitTimeDescending(Long.MIN_VALUE,
                    Long.MAX_VALUE, 10, null);
            boolean endAllPresent = areTxnsInIndex(endTxns);

            // check the level of cover required
            switch (recoveryMode) {
            case AUTO:
                if (!startAllPresent) {
                    // Initial transactions are missing - rebuild
                    performFullRecovery();
                } else if (!endAllPresent) {
                    // Trigger the tracker, which will top up the indexes
                    indexTracker.reindex();
                }
                break;
            case VALIDATE:
                // Check
                if (!startAllPresent || !endAllPresent) {
                    // Index is out of date
                    logger.warn(I18NUtil.getMessage(ERR_INDEX_OUT_OF_DATE));
                }
                break;
            case FULL:
                performFullRecovery();
                break;
            }
        } finally {
            // restore read-only state
            transactionService.setAllowWrite(allowWrite);
        }
    } finally {
        logger.debug("[FullIndexRecoveryComponent::reindexImpl] END");
    }
}

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

/**
 *  Checks if the value can safely be converted to a long primitive.
 *
 *@param  value   The value validation is being performed on.
 *@param  locale  The locale to use to parse the number (system default if
 *      null)//from ww  w  . j a v  a 2 s.  c om
 *@return the converted Long value.
 */
public static Long formatLong(String value, Locale locale) {
    Long 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() >= Long.MIN_VALUE && num.doubleValue() <= Long.MAX_VALUE) {
                result = new Long(num.longValue());
            }
        }
    }

    return result;
}

From source file:com.google.sample.castcompanionlibrary.utils.Utils.java

/**
 * Saves a long value under the provided key in the preference manager. If <code>value</code>
 * is <code>Long.MIN_VALUE</code>, then the provided key will be removed from the preferences.
 *
 * @param context//from   ww  w . java2s.  c o  m
 * @param key
 * @param value
 */
public static void saveLongToPreference(Context context, String key, long value) {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    if (Long.MIN_VALUE == value) {
        // we want to remove
        pref.edit().remove(key).apply();
    } else {
        pref.edit().putLong(key, value).apply();
    }

}

From source file:com.alfaariss.oa.engine.session.memory.MemorySessionFactory.java

/**
 * @see com.alfaariss.oa.api.poll.IPollable#poll()
 *///from w  w w.  j a  v  a 2 s  . c o  m
public long poll() throws OAException {
    if (_htSession != null) {
        return _htSession.size();
    }
    return Long.MIN_VALUE;
}

From source file:com.amazonaws.mobileconnectors.pinpoint.analytics.Session.java

@Override
public JSONObject toJSONObject() {
    Long stopT = this.stopTime;
    if (stopT == null) {
        stopT = Long.MIN_VALUE;
    }//from w  ww.  j  a  v  a 2s . c  om

    final JSONBuilder builder = new JSONBuilder(this);
    builder.withAttribute(JSON_SESSION_ID_ATTR, getSessionID());
    builder.withAttribute(JSON_START_TIME_ATTR, getStartTime());
    builder.withAttribute(JSON_STOP_TIME_ATTR, stopT);
    return builder.toJSONObject();
}

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

@Test
public void testPutVarLong() throws Exception {
    Buffer buffer = new AutomaticBuffer(0);
    buffer.putVar(Long.MAX_VALUE);
    buffer.putVar(Long.MIN_VALUE);
    buffer.putVar(0L);// w ww  .  j  a  v  a2s .c o m
    buffer.putVar(1L);
    buffer.putVar(12345L);

    buffer.setOffset(0);
    Assert.assertEquals(buffer.readVarLong(), Long.MAX_VALUE);
    Assert.assertEquals(buffer.readVarLong(), Long.MIN_VALUE);
    Assert.assertEquals(buffer.readVarLong(), 0L);
    Assert.assertEquals(buffer.readVarLong(), 1L);
    Assert.assertEquals(buffer.readVarLong(), 12345L);
}

From source file:org.waarp.openr66.protocol.http.rest.handler.HttpRestInformationR66Handler.java

protected ArrayNode getDetailedAllow() {
    ArrayNode node = JsonHandler.createArrayNode();

    if (this.methods.contains(METHOD.GET)) {
        InformationJsonPacket node3 = new InformationJsonPacket(
                (byte) InformationPacket.ASKENUM.ASKEXIST.ordinal(),
                "The rule name associated with the remote repository", "The filename to look for if any");
        node3.setComment("Information request (GET)");
        ObjectNode node2;//from   w ww  . java  2s  . c  o m
        ArrayNode node1 = JsonHandler.createArrayNode().add("path");
        try {
            node2 = RestArgument.fillDetailedAllow(METHOD.GET, this.path, ACTIONS_TYPE.GetInformation.name(),
                    node3.createObjectNode(), node1);
            node.add(node2);
        } catch (OpenR66ProtocolPacketException e1) {
        }

        node3 = new InformationJsonPacket(Long.MIN_VALUE, false, "remoteHost");
        node3.setComment("Information on Transfer request (GET)");
        node1 = JsonHandler.createArrayNode();
        ObjectNode node1b = JsonHandler.createObjectNode();
        node1b.put(DbTaskRunner.JSON_MODEL, DbTaskRunner.class.getSimpleName());
        DbValue[] values = DbTaskRunner.getAllType();
        for (DbValue dbValue : values) {
            node1b.put(dbValue.column, dbValue.getType());
        }
        node1.add(node1b);
        try {
            node2 = RestArgument.fillDetailedAllow(METHOD.GET, this.path, ACTIONS_TYPE.GetInformation.name(),
                    node3.createObjectNode(), node1);
            node.add(node2);
        } catch (OpenR66ProtocolPacketException e1) {
        }
    }

    ObjectNode node2 = RestArgument.fillDetailedAllow(METHOD.OPTIONS, this.path, COMMAND_TYPE.OPTIONS.name(),
            null, null);
    node.add(node2);

    return node;
}

From source file:easyJ.common.validate.GenericTypeValidator.java

/**
 * Checks if the value can safely be converted to a long primitive.
 * /*from ww  w .  j  ava2 s.c om*/
 * @param value
 *                The value validation is being performed on.
 * @param locale
 *                The locale to use to parse the number (system default if
 *                null)
 * @return the converted Long value.
 */
public static Long formatLong(String value, Locale locale) {
    Long 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() >= Long.MIN_VALUE && num.doubleValue() <= Long.MAX_VALUE) {
                result = new Long(num.longValue());
            }
        }
    }

    return result;
}