Example usage for java.lang Number longValue

List of usage examples for java.lang Number longValue

Introduction

In this page you can find the example usage for java.lang Number longValue.

Prototype

public abstract long longValue();

Source Link

Document

Returns the value of the specified number as a long .

Usage

From source file:org.osgp.adapter.protocol.dlms.domain.commands.AmrProfileStatusCodeHelperService.java

public Set<AmrProfileStatusCodeFlag> toAmrProfileStatusCodeFlags(final Number registerValue) {
    return BYTE_REGISTER_CONVERTER.toTypes(registerValue.longValue());
}

From source file:io.coala.random.impl.RandomNumberStreamFactoryMersenne.java

@Override
public RandomNumberStream create(final RandomNumberStreamID id, final Number seed) {
    final RandomGenerator rng = new MersenneTwister(seed.longValue());
    return RandomNumberStream.Util.asStream(id, rng);
}

From source file:routines.system.BigDataParserUtils.java

/**
 * Parse anything to Long//from  ww w.j  a  v a  2s  .co  m
 *
 * @param input
 * @return
 */
public static Long parseTo_Long(Number input) {
    if (input == null) {
        return null;
    }
    return input.longValue();
}

From source file:com.github.ukase.toolkit.helpers.FormatDateHelper.java

private CharSequence apply(Number context, Options options) {
    return format(new Date(context.longValue()), options);
}

From source file:routines.system.BigDataParserUtils.java

/**
 * Parse anything to long/*from   w  ww.  ja  v  a 2 s. co m*/
 *
 * @param input
 * @return
 */
public static long parseTo_long(Number input) {
    if (input == null) {
        return defaultValueLong;
    }
    return input.longValue();
}

From source file:org.kalypso.observation.result.TupleResultUtilities.java

public static void setNumberValue(final IRecord record, final IComponent component, final Number value) {
    final QName qname = component.getValueTypeName();
    if (XmlTypes.XS_DECIMAL.equals(qname))
        record.setValue(component, BigDecimal.valueOf(value.doubleValue()));
    else if (XmlTypes.XS_DOUBLE.equals(qname))
        record.setValue(component, Double.valueOf(value.doubleValue()));
    else if (XmlTypes.XS_FLOAT.equals(qname))
        record.setValue(component, Float.valueOf(value.floatValue()));
    else if (XmlTypes.XS_INT.equals(qname))
        record.setValue(component, Integer.valueOf(value.intValue()));
    else if (XmlTypes.XS_INTEGER.equals(qname))
        record.setValue(component, BigInteger.valueOf(value.longValue()));
    else if (XmlTypes.XS_LONG.equals(qname))
        record.setValue(component, Long.valueOf(value.longValue()));
    else if (XmlTypes.XS_SHORT.equals(qname))
        record.setValue(component, Short.valueOf(value.shortValue()));
    else/* w w  w .  j a v  a2 s . c  o m*/
        throw new UnsupportedOperationException();

}

From source file:ispok.dao.CashgameHibernateJpaDao.java

@Override
public Long getCount(Map<String, Object> filters) {

    Session session = getEntityManager().unwrap(Session.class);
    Criteria criteria = session.createCriteria(Cashgame.class);
    criteria.setProjection(Projections.property("id"));

    for (Map.Entry<String, Object> filter : filters.entrySet()) {

        if ("id".equals(filter.getKey())) {
            criteria.add(Restrictions.eq("id", Long.parseLong(filter.getValue().toString())));
        } else {/*from w w  w .  jav a 2  s . c o  m*/
            criteria.add(Restrictions.ilike(filter.getKey(), (String) filter.getValue(), MatchMode.START));
        }
    }

    criteria.setProjection(Projections.rowCount());
    Number number = (Number) criteria.uniqueResult();

    return number.longValue();
}

From source file:com.flexive.shared.FxFormatUtils.java

/**
 * Convert a String to Long/*from  w ww.  j  a  va  2s  .c  o m*/
 *
 * @param value value to convert
 * @return Long
 */
public static Long toLong(String value) {
    if (StringUtils.isBlank(value))
        return null;
    final ParsePosition pos = new ParsePosition(0);
    final String _value = value.trim();
    try {
        final Number parse = FxValueRendererFactory.getNumberFormatInstance().parse(unquote(_value), pos);
        if (pos.getErrorIndex() >= 0 || pos.getIndex() != _value.length()
                || parse.doubleValue() != (double) parse.longValue() /*truncation*/)
            throw new FxConversionException("ex.conversion.value.error", FxLargeNumber.class.getCanonicalName(),
                    value, "Failed to parse " + value).asRuntimeException();
        return parse.longValue();
    } catch (NumberFormatException e) {
        throw new FxConversionException("ex.conversion.value.error", FxLargeNumber.class.getCanonicalName(),
                value,
                "Failed to parse [" + value + "] using dec.sep. [" + FxContext.get().getDecimalSeparator()
                        + "] and grouping sep. [" + FxContext.get().getDecimalSeparator() + "]")
                                .asRuntimeException();
    }
}

From source file:org.apache.solr.client.solrj.io.eval.FrequencyTableEvaluator.java

@Override
public Object doWork(Object... values) throws IOException {
    if (Arrays.stream(values).anyMatch(item -> null == item)) {
        return null;
    }/*from   w w w.  ja v a  2s .  c om*/

    List<?> sourceValues;

    if (values.length == 1) {
        sourceValues = values[0] instanceof List<?> ? (List<?>) values[0] : Arrays.asList(values[0]);
    } else {
        throw new IOException(
                String.format(Locale.ROOT, "Invalid expression %s - expecting at least one value but found %d",
                        toExpression(constructingFactory), containedEvaluators.size()));
    }

    Frequency frequency = new Frequency();

    for (Object o : sourceValues) {
        Number number = (Number) o;
        frequency.addValue(number.longValue());
    }

    List<Tuple> histogramBins = new ArrayList<>();

    Iterator iterator = frequency.valuesIterator();

    while (iterator.hasNext()) {
        Long value = (Long) iterator.next();
        Map<String, Number> map = new HashMap<>();
        map.put("value", value.longValue());
        map.put("count", frequency.getCount(value));
        map.put("cumFreq", frequency.getCumFreq(value));
        map.put("cumPct", frequency.getCumPct(value));
        map.put("pct", frequency.getPct(value));
        histogramBins.add(new Tuple(map));
    }
    return histogramBins;
}

From source file:ca.travelagency.persistence.DaoSupportImpl.java

@Override
public Long count(DaoCriteria daoCriteria) {
    Query query = QuerySQL.count(daoCriteria.getCriteria(), entityManager).makeQuery();
    Number count = (Number) query.getSingleResult();
    return count.longValue();
}