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:com.prowidesoftware.swift.model.field.Field259.java

/**
 * Set the component3 from a Number object.
 * <br />//from   w ww  .  ja  va2  s  .  com
 * <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 Field259 setComponent3(java.lang.Number component3) {
    if (component3 != null) {
        setComponent(3, "" + component3.intValue());
    }
    return this;
}

From source file:com.itelis.worker.dev.template.service.JRXmlDataSource.java

protected Object convertNumber(Number number, Class valueClass) throws JRException {
    Number value = null;//w  ww . jav a2s  .  c  o m
    if (valueClass.equals(Byte.class)) {
        value = new Byte(number.byteValue());
    } else if (valueClass.equals(Short.class)) {
        value = new Short(number.shortValue());
    } else if (valueClass.equals(Integer.class)) {
        value = new Integer(number.intValue());
    } else if (valueClass.equals(Long.class)) {
        value = new Long(number.longValue());
    } else if (valueClass.equals(Float.class)) {
        value = new Float(number.floatValue());
    } else if (valueClass.equals(Double.class)) {
        value = new Double(number.doubleValue());
    } else if (valueClass.equals(BigInteger.class)) {
        value = BigInteger.valueOf(number.longValue());
    } else if (valueClass.equals(BigDecimal.class)) {
        value = new BigDecimal(Double.toString(number.doubleValue()));
    } else {
        throw new JRException("Unknown number class " + valueClass.getName());
    }
    return value;
}

From source file:com.jkoolcloud.tnt4j.streams.utils.Utils.java

/**
 * Casts provided number value to desired number type.
 *
 * @param num/* www.  j ava2 s  .c o  m*/
 *            number value to cast
 * @param clazz
 *            number class to cast number to
 * @param <T>
 *            desired number type
 * @return number value cast to desired numeric type
 */
@SuppressWarnings("unchecked")
public static <T extends Number> T castNumber(Number num, Class<T> clazz) {
    Number cNum = 0;

    if (clazz.isAssignableFrom(Long.class)) {
        cNum = num.longValue();
    } else if (clazz.isAssignableFrom(Integer.class)) {
        cNum = num.intValue();
    } else if (clazz.isAssignableFrom(Byte.class)) {
        cNum = num.byteValue();
    } else if (clazz.isAssignableFrom(Float.class)) {
        cNum = num.floatValue();
    } else if (clazz.isAssignableFrom(Double.class)) {
        cNum = num.doubleValue();
    } else if (clazz.isAssignableFrom(Short.class)) {
        cNum = num.shortValue();
    }

    return (T) cNum;
}

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

/**
 * Set the component2 from a Number object.
 * <br />/*  w ww. j a  va2  s.  c  om*/
 * <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 Field255 setComponent2(java.lang.Number component2) {
    if (component2 != null) {
        setComponent(2, "" + component2.intValue());
    }
    return this;
}

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

/**
 * Set the component3 from a Number object.
 * <br />//w  ww . j  a  v a2s  . c  om
 * <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 Field255 setComponent3(java.lang.Number component3) {
    if (component3 != null) {
        setComponent(3, "" + component3.intValue());
    }
    return this;
}

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

/**
 * Set the component2 from a Number object.
 * <br />//from  ww  w.j  av a2  s .com
 * <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 Field256 setComponent2(java.lang.Number component2) {
    if (component2 != null) {
        setComponent(2, "" + component2.intValue());
    }
    return this;
}

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

/**
 * Set the component3 from a Number object.
 * <br />//from  w w w .j av  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 setComponent3(String) 
 * method.
 * 
 * @see #setComponent3(String)
 *
 * @param component3 the Number with the component3 content to set
 */
public Field256 setComponent3(java.lang.Number component3) {
    if (component3 != null) {
        setComponent(3, "" + component3.intValue());
    }
    return this;
}

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

/**
 * Set the component2 from a Number object.
 * <br />//ww w .  ja v a2s .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 setComponent2(String) 
 * method.
 * 
 * @see #setComponent2(String)
 *
 * @param component2 the Number with the component2 content to set
 */
public Field258 setComponent2(java.lang.Number component2) {
    if (component2 != null) {
        setComponent(2, "" + component2.intValue());
    }
    return this;
}

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

/**
 * Set the component3 from a Number object.
 * <br />/*  w w w .  j  av  a  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 Field258 setComponent3(java.lang.Number component3) {
    if (component3 != null) {
        setComponent(3, "" + component3.intValue());
    }
    return this;
}

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

/**
 * Set the component1 from a Number object.
 * <br />/* ww  w. java 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 setComponent1(String) 
 * method.
 * 
 * @see #setComponent1(String)
 *
 * @param component1 the Number with the component1 content to set
 */
public Field330 setComponent1(java.lang.Number component1) {
    if (component1 != null) {
        setComponent(1, "" + component1.intValue());
    }
    return this;
}