Example usage for java.lang Long valueOf

List of usage examples for java.lang Long valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Long valueOf(long l) 

Source Link

Document

Returns a Long instance representing the specified long value.

Usage

From source file:org.homiefund.test.dao.InvitationDAOTest.java

@Test
public void getById() {
    Assert.assertEquals(Long.valueOf(1L), invitationDAO.getById(1L).getId());
}

From source file:com.redhat.lightblue.metadata.types.IntegerType.java

@Override
public Object cast(Object obj) {
    Long value = null;//from  w ww.j  av  a 2 s  .  com
    if (obj != null) {
        if (obj instanceof Number) {
            value = ((Number) obj).longValue();
        } else if (obj instanceof Boolean) {
            value = ((Boolean) obj) ? Long.valueOf(1) : Long.valueOf(0);
        } else if (obj instanceof String) {
            try {
                value = Long.valueOf((String) obj);
            } catch (NumberFormatException e) {
                throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString());
            }
        } else {
            throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString());
        }
    }
    return value;
}

From source file:com.amazonaws.util.TimingInfo.java

/**
 * Captures the current wall clock time (since epoch in millisecond)
 * and the current time (in nanosecond) used for timing measurement.
 * For more info, see://  w ww  .j a v a 2  s  .  co m
 * https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks
 */
public static TimingInfo startTiming() {
    return new TimingInfo(Long.valueOf(System.currentTimeMillis()), System.nanoTime(), null);
}

From source file:net.ripe.ipresource.Asn.java

public static Asn parse(String text) {
    if (text == null) {
        return null;
    }//w w w  . j  ava  2  s  .c om

    text = text.trim();

    Matcher matcher = ASN_TEXT_PATTERN.matcher(text);

    if (!matcher.matches()) {
        throw new IllegalArgumentException("not a legal ASN: " + text);
    }

    long high = 0L;
    long low;

    if (matcher.group(3) != null) {
        low = Long.valueOf(matcher.group(3));
        high = Long.valueOf(matcher.group(1));

        checkRange(high, ASN16_MAX_VALUE);
        checkRange(low, ASN16_MAX_VALUE);
    } else {
        low = Long.valueOf(matcher.group(1));

        checkRange(low, ASN32_MAX_VALUE);
    }

    return new Asn((high << 16) | low);
}

From source file:com.shuffle.bitcoin.blockchain.BlockCypherDotCom.java

/**
 *
 * Given a wallet address, this function looks up the address' balance using Blockchain.info's
 * API. The amount returned is of type long and represents the number of satoshis.
 *///w w w .  j  ava2s  .co m
public long getAddressBalance(String address) throws IOException {
    rateLimiter.acquire();
    try {
        if (Address.getParametersFromAddress(address) == NetworkParameters
                .fromID(NetworkParameters.ID_TESTNET)) {
            rateLimiter.acquire();
            String url = "https://api.blockcypher.com/v1/btc/test3/addrs/" + address;
            URL obj = new URL(url);
            JSONTokener tokener;
            rateLimiter.acquire();
            tokener = new JSONTokener(obj.openStream());
            JSONObject root = new JSONObject(tokener);
            return Long.valueOf(root.get("final_balance").toString());
        }
        //if not testnet likely mainnet
        else {
            rateLimiter.acquire();
            String url = "https://api.blockcypher.com/v1/btc/main/addrs/" + address;
            URL obj = new URL(url);
            JSONTokener tokener = new JSONTokener(obj.openStream());
            JSONObject root = new JSONObject(tokener);
            return Long.valueOf(root.get("final_balance").toString());
        }

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

    return 0;
}

From source file:fr.certu.chouette.gui.command.ValidateCommand.java

/**
 * validate command from database : -c validation -id ZZZ
 * /* www.  j  a  v  a  2s .c o  m*/
 * @param parameters
 * @return
 * @throws ChouetteException
 */
public int executeValidate(EntityManager session, Map<String, List<String>> parameters)
        throws ChouetteException {
    INeptuneManager<NeptuneIdentifiedObject> manager = managers.get("line");
    Long validationId = Long.valueOf(getSimpleString(parameters, "id"));
    if (!validationDao.exists(validationId)) {
        // error validation not found
        logger.error("compilanceCheckTask not found " + validationId);
        return 1;
    }
    CompilanceCheckTask compilanceCheckTask = validationDao.get(validationId);
    startProcess(session, compilanceCheckTask);

    // read parameters
    JSONObject validationParameters = compilanceCheckTask.getParameters();

    // read object type
    String objectType = extractObjectType(compilanceCheckTask.getReferencesType().toLowerCase());

    List<NeptuneIdentifiedObject> beans = new ArrayList<NeptuneIdentifiedObject>();
    String idstring = compilanceCheckTask.getReferenceIds();
    if (idstring == null || idstring.isEmpty()) {
        beans = manager.getAll(null);
    } else {
        String[] ids = idstring.split(",");
        List<Long> checkIds = new ArrayList<>();
        for (String id : ids) {
            checkIds.add(Long.valueOf(id));
        }

        if (!objectType.startsWith("line")) {
            INeptuneManager<NeptuneIdentifiedObject> loadManager = managers.get(objectType);
            if (loadManager == null) {
                logger.error("object type " + objectType + " not found " + validationId);
                return 1;
            }
            Filter filter = Filter.getNewInFilter("id", checkIds);
            List<NeptuneIdentifiedObject> containerBeans = loadManager.getAll(null, filter);
            Set<NeptuneIdentifiedObject> beanSet = new HashSet<NeptuneIdentifiedObject>();
            for (NeptuneIdentifiedObject container : containerBeans) {
                if (objectType.equals("network")) {
                    PTNetwork network = (PTNetwork) container;
                    beanSet.addAll(network.getLines());
                } else if (objectType.equals("company")) {
                    Company company = (Company) container;
                    beanSet.addAll(company.getLines());
                } else if (objectType.equals("groupofline")) {
                    GroupOfLine group = (GroupOfLine) container;
                    beanSet.addAll(group.getLines());
                } else {
                    logger.error("object type " + objectType + " not managed " + validationId);
                }
            }
            beans.addAll(beanSet);
        } else {
            Filter filter = Filter.getNewInFilter("id", checkIds);
            beans = manager.getAll(null, filter);

        }
    }

    PhaseReportItem valReport = new PhaseReportItem(PhaseReportItem.PHASE.THREE);
    if (beans != null && !beans.isEmpty()) {
        manager.validate(null, beans, validationParameters, valReport, null, true);
    }

    // save report
    if (valReport != null) {
        saveValidationReport(session, compilanceCheckTask, valReport);
    }

    return 0;
}

From source file:facebook4j.auth.AccessToken.java

private void parseQueryString(String string) {
    if (string.contains("access_token=")) {
        this.responseStr = string.split("&");
        this.token = getParameter("access_token");
        if (this.responseStr.length > 1) {
            this.expires = Long.valueOf(getParameter("expires"));
        }/* w  w  w .ja  v  a2s  .c o m*/
    } else {
        this.token = string;
        this.expires = null;
    }
}

From source file:cherry.foundation.numbering.SimpleNumberingStore.java

@Override
public void saveAndUnlock(String numberName, long current) {
    currentValueMap.put(numberName, Long.valueOf(current));
    lockMap.get(numberName).unlock();
}

From source file:controllers.FeatureController.java

@RequestMapping("/show")
public String showParseForm(Map<String, Object> model) throws Exception {
    List<Feature> featList = featureService.getGroupOfFeatures(Long.valueOf("0"), Long.valueOf("0"));
    model.put("featList", featList);
    return "FeatureShow";
}

From source file:net.solarnetwork.central.dras.dao.ibatis.test.IbatisCapabilityDaoTest.java

@Test
public void getCapabilityById() {
    setupTestCapability();/*from   w  w w .j  ava 2 s  .co  m*/
    Capability capability = capabilityDao.get(TEST_CAPABILITY_ID);
    assertNotNull(capability);
    assertNotNull(capability.getId());
    assertEquals(TEST_CAPABILITY_ID, capability.getId());
    assertEquals("Test", capability.getDemandResponseKind());
    assertEquals(Long.valueOf(11L), capability.getShedCapacityWatts());
    assertEquals(Long.valueOf(12L), capability.getShedCapacityWattHours());
    assertEquals(Long.valueOf(13L), capability.getVarCapacityVoltAmps());
}