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:com.bdb.weather.display.summary.WindSummary.java

@Override
public void chartMouseClicked(ChartMouseEventFX event) {
    ChartEntity entity = event.getEntity();
    ///*w w  w . java  2  s .  c  o m*/
    // Was a point on the plot selected?
    //
    if (entity instanceof XYItemEntity) {
        XYItemEntity itemEntity = (XYItemEntity) entity;
        XYDataset dataset = itemEntity.getDataset();
        Number x = dataset.getXValue(itemEntity.getSeriesIndex(), itemEntity.getItem());
        LocalDate date = LocalDate.from(Instant.ofEpochMilli(x.longValue()));

        if (event.getTrigger().getClickCount() == 2)
            supporter.launchView(launcher, date);
    }
}

From source file:edu.scripps.fl.pubchem.web.entrez.ELinkWebSession.java

protected List<Object> getParams() throws Exception {
    List<Object> params = new ArrayList();
    params.add("db");
    params.add(getDb());//from   www  . j a  v  a  2  s . c o  m

    if (null != getLinkName() && !"".equals(getLinkName())) {
        params.add("linkname");
        params.add(getLinkName());
    }

    if (null != getKey()) {
        //         params.add("dbfrom");
        //         params.add(key.getDatabase());
        params.add("WebEnv");
        params.add(getKey().getWebEnv());
        params.add("query_key");
        params.add(getKey().getQueryKey());
    } else if (ids.size() > 0) {
        params.add("dbfrom");
        params.add(getDbFrom());
        for (Number id : ids) {
            params.add("id");
            params.add(id.longValue());
        }
    } else
        throw new Exception("ELink: must provide either a List of Ids or an Entrez History Key");

    if (null != getTerm() && !"".equals(getTerm())) {
        params.add("term");
        params.add(getTerm());
    }
    params.add("version");
    params.add("2.0");
    return params;
}

From source file:com.daugherty.e2c.persistence.data.jdbc.JdbcSupplierDao.java

private void executePartyAuditInsert(Party party, SqlParameterSource partyAuditUpdateParameterSource) {
    Number partyAuditKey = partyAuditInsert.executeAndReturnKey(partyAuditUpdateParameterSource);
    party.setSnapshotId(partyAuditKey.longValue());
}

From source file:com.tuplejump.stargate.lucene.query.function.AggregateFunction.java

private void load(Tuple tuple, IndexEntryCollector.IndexEntry entry, String field, Type validator) {
    if (validator != null) {
        if (validator.isNumeric()) {
            tuple.tuple[this.positions.get(field)] = entry.getNumber(field);
        } else if (validator == Type.date) {
            Number number = entry.getNumber(field);
            tuple.tuple[this.positions.get(field)] = new Date(number.longValue());
        } else {// w ww .j  a  v a 2s.c o  m
            tuple.tuple[this.positions.get(field)] = entry.getString(field);
        }
    }
}

From source file:ubc.pavlab.aspiredb.server.dao.DaoBaseImpl.java

/**
 * //from  ww  w  .ja va2 s  .c  om
 * 
 */
@Override
@Transactional(readOnly = true)
public long getCountAll() {
    Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
    Number totalSize = (Number) session.createCriteria(this.elementClass).setProjection(Projections.rowCount())
            .uniqueResult();
    return totalSize.longValue();
}

From source file:MutableLong.java

/**
 * Constructs a new MutableLong with the specified value.
 * //w ww  . ja  v a2 s.co m
 * @param value
 *            a value.
 * @throws NullPointerException
 *             if the object is null
 */
public MutableLong(Number value) {
    super();
    this.value = value.longValue();
}

From source file:ca.nrc.cadc.vos.server.NodeMapper.java

/**
 * Map the row to the appropriate type of node object.
 * @param rs/*from w w w.jav  a 2s.  c o  m*/
 * @param row
 * @return a Node
 * @throws SQLException
 */
public Object mapRow(ResultSet rs, int row) throws SQLException {

    long nodeID = rs.getLong("nodeID");
    String name = rs.getString("name");
    String type = rs.getString("type");
    String busyString = rs.getString("busyState");
    String groupRead = rs.getString("groupRead");
    String groupWrite = rs.getString("groupWrite");
    boolean isPublic = rs.getBoolean("isPublic");
    boolean isLocked = rs.getBoolean("isLocked");

    Object ownerObject = rs.getObject("ownerID");
    String contentType = rs.getString("contentType");
    String contentEncoding = rs.getString("contentEncoding");
    String link = null;

    Long contentLength = null;
    Object o = rs.getObject("contentLength");
    if (o != null) {
        Number n = (Number) o;
        contentLength = new Long(n.longValue());
    }
    log.debug("readNode: contentLength = " + contentLength);

    Object contentMD5 = rs.getObject("contentMD5");
    Date lastModified = rs.getTimestamp("lastModified", cal);

    String path = basePath + "/" + name;
    VOSURI vos;
    try {
        vos = new VOSURI(new URI("vos", authority, path, null, null));
    } catch (URISyntaxException bug) {
        throw new RuntimeException("BUG - failed to create vos URI", bug);
    }

    Node node;
    if (NodeDAO.NODE_TYPE_CONTAINER.equals(type)) {
        node = new ContainerNode(vos);
    } else if (NodeDAO.NODE_TYPE_DATA.equals(type)) {
        node = new DataNode(vos);
        ((DataNode) node).setBusy(NodeBusyState.getStateFromValue(busyString));
    } else if (NodeDAO.NODE_TYPE_LINK.equals(type)) {
        link = rs.getString("link");
        try {
            node = new LinkNode(vos, new URI(link));
        } catch (URISyntaxException bug) {
            throw new RuntimeException("BUG - failed to create link URI", bug);
        }
    } else {
        throw new IllegalStateException("Unknown node database type: " + type);
    }

    NodeID nid = new NodeID();
    nid.id = nodeID;
    nid.ownerObject = ownerObject;
    node.appData = nid;

    if (contentType != null && contentType.trim().length() > 0) {
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_TYPE, contentType));
    }

    if (contentEncoding != null && contentEncoding.trim().length() > 0) {
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_CONTENTENCODING, contentEncoding));
    }

    if (contentLength != null)
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_CONTENTLENGTH, contentLength.toString()));
    else
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_CONTENTLENGTH, "0"));

    if (contentMD5 != null && contentMD5 instanceof byte[]) {
        byte[] md5 = (byte[]) contentMD5;
        if (md5.length < 16) {
            byte[] tmp = md5;
            md5 = new byte[16];
            System.arraycopy(tmp, 0, md5, 0, tmp.length);
            // extra space is init with 0
        }
        String contentMD5String = HexUtil.toHex(md5);
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_CONTENTMD5, contentMD5String));
    }
    if (lastModified != null) {
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_DATE, dateFormat.format(lastModified)));
    }
    if (groupRead != null && groupRead.trim().length() > 0) {
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_GROUPREAD, groupRead));
    }
    if (groupWrite != null && groupWrite.trim().length() > 0) {
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_GROUPWRITE, groupWrite));
    }
    node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_ISPUBLIC, isPublic ? "true" : "false"));

    if (isLocked)
        node.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_ISLOCKED, isLocked ? "true" : "false"));

    // set the read-only flag on the properties
    for (String propertyURI : VOS.READ_ONLY_PROPERTIES) {
        int propertyIndex = node.getProperties().indexOf(new NodeProperty(propertyURI, ""));
        if (propertyIndex != -1) {
            node.getProperties().get(propertyIndex).setReadOnly(true);
        }
    }
    log.debug("read: " + node.getUri() + "," + node.appData);
    return node;
}

From source file:com.zimbra.cs.service.admin.VerifyStoreManager.java

private void assertEquals(String message, Object o1, Object o2) throws Exception {
    if (o1 == null && o2 == null) {
        return;/*from  w  ww  .ja  va2  s  .  c  o  m*/
    } else if (o1 == null && o2 != null) {
        throw new Exception("verification failed checking " + message);
    } else if (!o1.equals(o2)) {
        if (o1 instanceof Number && o2 instanceof Number) {
            Number num1 = (Number) o1;
            Number num2 = (Number) o2;
            if (num1.longValue() == num2.longValue()) {
                return;
            }
        }
        throw new Exception("verification failed checking " + message);
    }
}

From source file:com.hortonworks.streamline.streams.metrics.storm.graphite.GraphiteWithStormQuerier.java

private Map<Long, Double> formatDataPointsFromGraphiteToMap(List<List<Number>> dataPoints) {
    Map<Long, Double> pointsForOutput = new HashMap<>();

    if (dataPoints != null && dataPoints.size() > 0) {
        for (List<Number> dataPoint : dataPoints) {
            // ex. [2940.0, 1465803540] -> 1465803540000, 2940.0
            Number valueNum = dataPoint.get(0);
            Number timestampNum = dataPoint.get(1);
            if (valueNum == null) {
                continue;
            }//from  w w  w.  j a  v a  2 s .c  o m
            pointsForOutput.put(timestampNum.longValue() * 1000, valueNum.doubleValue());
        }
    }
    return pointsForOutput;
}

From source file:com.sinosoft.one.data.jade.dataaccess.DataAccessImpl.java

/**
 *  2012-08-16/*  w  w w . j ava 2  s  .  c  o  m*/
 */
public <T> Page<T> selectByPage(Pageable pageable, String sql, String countSql, Object[] args,
        RowMapper<?> rowMapper) {
    Session session = em.unwrap(Session.class);
    SingleColumnRowMapper<BigDecimal> scrm = new SingleColumnRowMapper<BigDecimal>();
    List<BigDecimal> totals = select(countSql, args, scrm);
    RenderSqlWork psw = new RenderSqlWork(sql, pageable, null);
    session.doWork(psw);
    sql = psw.getSql();
    List<T> content = select(sql, args, rowMapper);
    if (content == null) {
        content = new ArrayList<T>();
    }
    Object o = totals.get(0);
    Number num = (Number) o;
    Page<T> page = new PageImpl<T>(content, pageable, num.longValue());
    return page;
}