Example usage for java.lang Number intValue

List of usage examples for java.lang Number intValue

Introduction

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

Prototype

public abstract int intValue();

Source Link

Document

Returns the value of the specified number as an int .

Usage

From source file:gov.nih.nci.caarray.application.permissions.PermissionsManagementServiceTest.java

@Test
public void testGetUsers() {
    final Number count = (Number) hibernateHelper.getCurrentSession().createCriteria(User.class)
            .setProjection(Projections.rowCount()).uniqueResult();
    final List<User> users = this.permissionsManagementService.getUsers(null);
    assertNotNull(users);/*from  ww  w.j  ava  2 s  . c o m*/
    assertEquals(count.intValue(), users.size());
}

From source file:com.cloudant.sync.datastore.SavedHttpAttachment.java

/**
 * Creates a SavedHttpAttachment (a fully initialised attachment)
 * with the provided properties/*from   www  . j  a  v  a  2 s  . c  o m*/
 * @param name The name of the attachment eg bonsai-boston.jpg
 * @param attachmentData The json attachment data from a couchDB instance
 * @param attachmentURI The URI at which the attachment can be downloaded
 * @throws IOException if there is an error decoding the attachment data
 */
public SavedHttpAttachment(String name, Map<String, Object> attachmentData, URI attachmentURI)
        throws IOException {
    super(name, (String) attachmentData.get("content_type"), Encoding.Plain);
    Boolean stub = (Boolean) attachmentData.get("stub");
    Number length = (Number) attachmentData.get("length");
    String data = (String) attachmentData.get("data");
    String encoding = (String) attachmentData.get("encoding");
    this.encoding = Attachment.getEncodingFromString(encoding);
    if (!stub) {
        byte[] dataArray = data.getBytes();
        InputStream is = Base64InputStreamFactory.get(new ByteArrayInputStream(dataArray));
        this.data = IOUtils.toByteArray(is);
    }

    this.attachmentURI = attachmentURI;
    this.size = length.intValue();

}

From source file:com.prowidesoftware.swift.model.field.Field343.java

/**
 * Set the component1 from a Number object.
 * <br />/*from ww  w  .ja v  a  2 s  .  c o m*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent1(String) 
 * method.
 * 
 * @see #setComponent1(String)
 *
 * @param component1 the Number with the component1 content to set
 */
public Field343 setComponent1(java.lang.Number component1) {
    if (component1 != null) {
        setComponent(1, "" + component1.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field343.java

/**
 * Set the component2 from a Number object.
 * <br />//from  ww w . j a  v  a  2  s  .co  m
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent2(String) 
 * method.
 * 
 * @see #setComponent2(String)
 *
 * @param component2 the Number with the component2 content to set
 */
public Field343 setComponent2(java.lang.Number component2) {
    if (component2 != null) {
        setComponent(2, "" + component2.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field343.java

/**
 * Set the component3 from a Number object.
 * <br />/*from ww  w .  j a va  2s  .c o m*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent3(String) 
 * method.
 * 
 * @see #setComponent3(String)
 *
 * @param component3 the Number with the component3 content to set
 */
public Field343 setComponent3(java.lang.Number component3) {
    if (component3 != null) {
        setComponent(3, "" + component3.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field343.java

/**
 * Set the component4 from a Number object.
 * <br />//w w w.j a  v  a2  s.  c  o  m
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent4(String) 
 * method.
 * 
 * @see #setComponent4(String)
 *
 * @param component4 the Number with the component4 content to set
 */
public Field343 setComponent4(java.lang.Number component4) {
    if (component4 != null) {
        setComponent(4, "" + component4.intValue());
    }
    return this;
}

From source file:dk.statsbiblioteket.netark.dvenabler.wrapper.NumericDocValuesWrapper.java

@Override
public long get(int docID) {
    tracker.ping(docID);/*w w w .j av  a 2 s  .  co  m*/
    try {
        IndexableField iField = reader.document(docID, FIELDS).getField(dvConfig.getName());
        if (iField == null) {
            log.warn("No stored value for field '" + dvConfig.getName() + "' in doc " + docID
                    + ". Returning -1");
            // This should have been handled by {@link DVAtomicReader#getDocsWithField}
            return -1;
        }
        Number number = iField.numericValue();
        if (number == null) {
            throw new RuntimeException("No numeric value '" + iField.stringValue() + "' for field '"
                    + dvConfig.getName() + "' in doc " + docID + ". This looks like a non-numeric field!");
        }
        // TODO: Determine correct method to call from field info
        switch (dvConfig.getNumericType()) {
        case LONG:
            return number.longValue();
        case INT:
            return number.intValue();
        case DOUBLE:
            return Double.doubleToLongBits(number.doubleValue());
        case FLOAT:
            return Float.floatToIntBits(number.longValue());
        default:
            throw new IllegalStateException(
                    "Unknown NumericType " + dvConfig.getNumericType() + " for field " + dvConfig.getName());
        }
    } catch (IOException e) {
        throw new RuntimeException("Unable to get field '" + dvConfig.getName() + "' from docID " + docID, e);
    }
}

From source file:main.java.edu.isistan.genCom.redSocial.RedSocial.java

/**
 * Obtiene la distancia del shortest path entre dos nodos
 * //from   w ww.j  ava2 s.  c o  m
 * @param investigador
 * @param investigador2
 * @return 0 si no hay relacin
 */
public int getDistancias(Investigador investigador, Investigador investigador2) {
    Number distancia;
    UnweightedShortestPath<Investigador, String> uWSP = new UnweightedShortestPath(red);

    distancia = uWSP.getDistance(investigador, investigador2);

    return distancia.intValue();
}

From source file:com.opengamma.financial.analytics.volatility.surface.BloombergEquityFuturePriceCurveInstrumentProvider.java

@Override
/**/*  www  .jav  a 2 s. co  m*/
 * Provides an ExternalID for Bloomberg ticker,
 * given a reference date and an integer offset, the n'th subsequent option <p>
 * The format is prefix + postfix <p>
 * e.g. AAPL=G3 OC Equity
 * <p>
 * @param futureOptionNumber n'th future following curve date, not null
 * @param curveDate date of future validity; valuation date, not null
 * @return the id of the Bloomberg ticker
 */
public ExternalId getInstrument(final Number futureNumber, final LocalDate curveDate) {
    ArgumentChecker.notNull(futureNumber, "futureOptionNumber");
    ArgumentChecker.notNull(curveDate, "curve date");
    final StringBuffer ticker = new StringBuffer();
    ticker.append(getFuturePrefix());
    final ExchangeTradedInstrumentExpiryCalculator expiryRule = getExpiryRuleCalculator();
    final LocalDate expiryDate = expiryRule.getExpiryDate(futureNumber.intValue(), curveDate, WEEKDAYS);
    final String expiryCode = BloombergFutureUtils.getShortExpiryCode(expiryDate);
    ticker.append(expiryCode);
    ticker.append(" ");
    if (getExchange() != null) {
        ticker.append(getExchange());
        ticker.append(" ");
    }
    ticker.append(getPostfix());
    return ExternalId.of(getTickerScheme(), ticker.toString());
}

From source file:net.solarnetwork.node.power.modbus.ModbusPowerDatumDataSource.java

private void setRegisterAddressValue(final PropertyAccessor bean, final Integer addr, final String propertyName,
        final Integer propertyValue) {
    if (bean.isWritableProperty(propertyName)) {
        Number value = propertyValue;
        if (registerScaleFactor != null && registerScaleFactor.containsKey(addr)) {
            value = Double.valueOf(value.intValue() * registerScaleFactor.get(addr));
        }/*  ww w  . j a va  2 s . c om*/
        log.trace("Setting property {} for address 0x{} to [{}]", propertyName, Integer.toHexString(addr),
                value);
        try {
            bean.setPropertyValue(propertyName, value);
        } catch (PropertyAccessException e) {
            log.warn("Unable to set property {} to {} for address 0x{}: {}", propertyName, value,
                    Integer.toHexString(addr), e.getMostSpecificCause().getMessage());
        }
    } else {
        log.warn("Property {} not available; bad configuration", propertyName);
    }
}