java.lang

Class Number

Implemented Interfaces:
Serializable
Known Direct Subclasses:
AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, Float, Fraction, Fraction, Integer, Long, MutableByte, MutableDouble, MutableFloat, MutableInt, MutableLong, MutableShort, Short

public abstract class Number
extends Object
implements Serializable

The abstract class Number is the superclass of classes BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, and Short.

Subclasses of Number must provide methods to convert the represented numeric value to byte, double, float, int, long, and short.

Since:
JDK1.0
See Also:
Byte, Double, Float, Integer, Long, Short, Serialized Form

Method Summary

byte
byteValue()
Returns the value of the specified number as a byte.
abstract double
doubleValue()
Returns the value of the specified number as a double.
abstract float
floatValue()
Returns the value of the specified number as a float.
abstract int
intValue()
Returns the value of the specified number as an int.
abstract long
longValue()
Returns the value of the specified number as a long.
short
shortValue()
Returns the value of the specified number as a short.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

byteValue

public byte byteValue()
Returns the value of the specified number as a byte. This may involve rounding or truncation.
Returns:
the numeric value represented by this object after conversion to type byte.
Since:
JDK1.1
Usages and Demos :

View More Examples of byteValue()
   1:         } else {
   2:             if (val instanceof Number) {
   3:         ...
   4:                 Number number = (Number) val;
   5:                 if (number instanceof Integer) {
   6:         ...
   7:                 } else if (number instanceof Byte) {
   8:                     preparedStmt.setByte(index, number.byteValue());
   9:                 } else if (number instanceof Double) {

View Full Code Here
   1:    {
   2:       Number n = (Number) o.getProperty(property);
   3:       if (n == null)
   4:         ...
   5:          return defaultValue;
   6:       return n.byteValue();
   7:    }
   8:         ...
   9:    {
  10:       Number n = (Number) o.getProperty(property);
  11:       if (n == null)

View Full Code Here
   1:         fieldTypeMapping.put(java.math.BigDecimal.class, new FieldTypeDefinition("DECIMAL",38));
   2:         fieldTypeMapping.put(Number.class, new FieldTypeDefinition("DECIMAL",38));
   3: 
   4:         ...
   5:             final Object parameter) throws SQLException {
   6:        if (parameter instanceof Number) {
   7:         ...
   8:             Number number = (Number) parameter;
   9:             if (number instanceof Integer) {
  10:         ...
  11:             } else if (number instanceof Byte) {
  12:                 statement.setByte(index, number.byteValue());

View Full Code Here
   1:         }
   2:         return p.invoke(((Number)l).doubleValue(), ((Number)r).doubleValue())
   3:             ? Boolean.TRUE : Boolean.FALSE;
   4:         ...
   5:         return new Integer
   6:         (o.invoke(((Number)l).intValue(), ((Number)r).intValue()));
   7:     } else if (c == long.class) {
   8:         ...
   9:         return new Long
  10:         (o.invoke(((Number)l).longValue(), ((Number)r).longValue()));
  11:     } else if (c == float.class) {
  12:         ...
  13:                         Number n = (Number)val;
  14:             return n.intValue() == n.byteValue();

View Full Code Here
   1:                         {
   2:                             Number elem = (Number) Array.get(array, i);
   3:                             if (elem != null)
   4:         ...
   5:                         {
   6:                             Number elem = (Number) Array.get(array, i);
   7:                             if (elem != null)
   8:         ...
   9:                             {
  10:                                 Array.setByte(parray, i, elem.byteValue());
  11:                             }

View Full Code Here

doubleValue

public abstract double doubleValue()
Returns the value of the specified number as a double. This may involve rounding.
Returns:
the numeric value represented by this object after conversion to type double.
Usages and Demos :

View More Examples of doubleValue()
   1:     }
   2:     if (value instanceof Number)
   3:     {
   4:         ...
   5:       Number numValue = (Number) value;
   6:         ...
   7:       return numValue.doubleValue() != 0;
   8:     }

View Full Code Here
   1: 
   2:     public Number getValue(Comparable rowKey, Comparable columnKey)
   3:     {
   4:         ...
   5: 
   6:     public Number getValue(int rowIndex, int columnIndex)
   7:     {
   8:         ...
   9:         return (Number) getModel().getValueAt(rowIndex, columnIndex);
  10:     }
  11:         ...
  12:         Number value = getX(series, item);
  13:         return value != null ? value.doubleValue() : 0.0;

View Full Code Here
   1: 
   2:         Number valueNumber = intervalData.getYValue(series, item);
   3:         if (valueNumber == null)
   4:         ...
   5:             rangeAxis.valueToJava2D(
   6:                 valueNumber.doubleValue() + ph,
   7:                 dataArea,
   8:         ...
   9:         RectangleEdge location = plot.getDomainAxisEdge();
  10:         Number startXNumber = intervalData.getStartXValue(series, item);
  11:         if (startXNumber == null)
  12:         ...
  13:         double translatedStartX =
  14:             domainAxis.valueToJava2D(startXNumber.doubleValue(), dataArea, location);

View Full Code Here
   1: 
   2:         Number value = dataset.getValue(row, column);
   3:         if (value == null) {
   4:         ...
   5:         double y1 = rangeAxis.valueToJava2D(
   6:             value.doubleValue(), dataArea, plot.getRangeAxisEdge()
   7:         );
   8:         ...
   9:         if (column != 0) {
  10:             Number previousValue = dataset.getValue(row, column - 1);
  11:             if (previousValue != null) {
  12:         ...
  13:                 double previous = previousValue.doubleValue();

View Full Code Here
   1: 
   2:         Number x = signalData.getXValue(series, item);
   3:         ...
   4:         Number y = signalData.getYValue(series, item);
   5:         int type = signalData.getType(series, item);
   6:         ...
   7:         double xx = horizontalAxis.valueToJava2D(
   8:             x.doubleValue(), dataArea, plot.getDomainAxisEdge()
   9:         );
  10:         ...
  11:         double yy = verticalAxis.valueToJava2D(
  12:             y.doubleValue(), dataArea, plot.getRangeAxisEdge()

View Full Code Here

floatValue

public abstract float floatValue()
Returns the value of the specified number as a float. This may involve rounding.
Returns:
the numeric value represented by this object after conversion to type float.
Usages and Demos :

View More Examples of floatValue()
   1:     public float getMin() {
   2:         Number min = (Number) getMinRestriction().getValue();
   3:         ...
   4:         return min == null ? Float.NEGATIVE_INFINITY : min.floatValue();
   5:     }
   6:         ...
   7:     public float getMax() {
   8:         Number max = (Number) getMaxRestriction().getValue();
   9:         ...
  10:         return max == null ? Float.POSITIVE_INFINITY : max.floatValue();

View Full Code Here
   1:             return nullValue;
   2:         if (value instanceof Number)
   3:         ...
   4:             return ((Number)value).intValue();
   5:         else
   6:         ...
   7:             return nullValue;
   8:         if (value instanceof Number)
   9:             return ((Number)value).doubleValue();
  10:         ...
  11:         else
  12:             return n.floatValue();

View Full Code Here
   1: 
   2:     private final Number m_number;
   3:     private final Class  m_type;
   4:         ...
   5:     public NumericLiteral(Object x) {
   6:         if ( x instanceof Number ) {
   7:         ...
   8:             m_number = (Number)x;
   9:             m_type = TypeLib.getPrimitiveType(m_number.getClass());
  10:         ...
  11:     public float getFloat(Tuple t) {
  12:         return m_number.floatValue();

View Full Code Here
   1:         Object value = getValue();
   2:         if (value instanceof Number) {
   3:         ...
   4:             Number number = (Number) value;
   5:             return number.intValue();
   6:         ...
   7:             Number number = (Number) value;
   8:             return number.floatValue();
   9:         } else {

View Full Code Here
   1: 
   2:         return new Float(value.floatValue() / divider);        
   3:     }
   4:         ...
   5:     
   6:     public float multiply(Number first, Number second)
   7:     {
   8:         ...
   9:         return first.floatValue() * second.floatValue();
  10:     }
  11:         ...
  12:     
  13:     public float divide(Number first, Number second)

View Full Code Here

intValue

public abstract int intValue()
Returns the value of the specified number as an int. This may involve rounding or truncation.
Returns:
the numeric value represented by this object after conversion to type int.
Usages and Demos :

View More Examples of intValue()
   1: 
   2:     private final Number m_number;
   3:     private final Class  m_type;
   4:         ...
   5:     public NumericLiteral(Object x) {
   6:         if ( x instanceof Number ) {
   7:         ...
   8:             m_number = (Number)x;
   9:             m_type = TypeLib.getPrimitiveType(m_number.getClass());
  10:         ...
  11:     public int getInt(Tuple t) {
  12:         return m_number.intValue();

View Full Code Here
   1: 
   2:     protected Number cell;
   3: 
   4:         ...
   5:     }
   6:     cell = (Number)o;
   7:         ...
   8:     return Array.get(array, cell.intValue());
   9:     }
  10:         ...
  11:     try {
  12:         Array.set(array, cell.intValue(), value);

View Full Code Here
   1: 
   2:     private Number value;
   3: 
   4:         ...
   5:     public ValueConstraint(Number value) {
   6:         this.value = value;
   7:         ...
   8:         } else {
   9:             return value.intValue();
  10:         }

View Full Code Here
   1:     {
   2:         if (_index != null) return _index.intValue();
   3:         ValueBinding vb = getValueBinding("index");
   4:         ...
   5:         Number v = vb != null ? (Number)vb.getValue(getFacesContext()) : null;
   6:         ...
   7:         return v != null ? v.intValue() : Integer.MIN_VALUE;
   8:     }

View Full Code Here
   1:     {
   2:         if (_index != null) return _index.intValue();
   3:         ValueBinding vb = getValueBinding("index");
   4:         ...
   5:         Number v = vb != null ? (Number)vb.getValue(getFacesContext()) : null;
   6:         ...
   7:         return v != null ? v.intValue() : Integer.MIN_VALUE;
   8:     }

View Full Code Here

longValue

public abstract long longValue()
Returns the value of the specified number as a long. This may involve rounding or truncation.
Returns:
the numeric value represented by this object after conversion to type long.
Usages and Demos :

View More Examples of longValue()
   1: 
   2:     private final Number m_number;
   3:     private final Class  m_type;
   4:         ...
   5:     public NumericLiteral(Object x) {
   6:         if ( x instanceof Number ) {
   7:         ...
   8:             m_number = (Number)x;
   9:             m_type = TypeLib.getPrimitiveType(m_number.getClass());
  10:         ...
  11:     public long getLong(Tuple t) {
  12:         return m_number.longValue();

View Full Code Here
   1:     protected long asLong(Object value) {
   2:         if (value instanceof Number) {
   3:         ...
   4:             Number n = (Number) value;
   5:         ...
   6:             return n.longValue();
   7:         }

View Full Code Here
   1:         Object value = getValue();
   2:         if (value instanceof Number) {
   3:         ...
   4:             Number number = (Number) value;
   5:             return number.intValue();
   6:         ...
   7:             Number number = (Number) value;
   8:             return number.longValue();
   9:         } else {

View Full Code Here
   1: 
   2:         Number number = (Number) fromObject;
   3:         String result = null;
   4:         ...
   5:             synchronized (numberFormat) {
   6:                 result = numberFormat.format(number.longValue());
   7:             }
   8:         ...
   9:             synchronized (numberFormat) {
  10:                 result = numberFormat.format(number.doubleValue());
  11:             }

View Full Code Here
   1:         {
   2:             Number s1 = (Number) objOne;
   3:         ...
   4:             Number s2 = (Number) objTwo;
   5:         ...
   6:             return s1.longValue() > s2.longValue();
   7:         }
   8:         ...
   9:             Number s2 = (Number) objTwo;
  10:             return s1.longValue() >= s2.longValue();

View Full Code Here

shortValue

public short shortValue()
Returns the value of the specified number as a short. This may involve rounding or truncation.
Returns:
the numeric value represented by this object after conversion to type short.
Since:
JDK1.1
Usages and Demos :

View More Examples of shortValue()
   1: 
   2:     protected Number doConvert(Number number) {
   3:         if (StringToNumberParser.inShortRange(number)) {
   4:         ...
   5:             return new Short(number.shortValue());
   6:         }
   7: 
   8:         return null;

View Full Code Here
   1: 
   2:     public Number getValue(Number value)
   3:     {
   4:         ...
   5:         Number ret = null;
   6: 
   7:         ...
   8:         else if ("short".equals(getName()))
   9:             ret = new Short(value.shortValue());
  10: 
  11:         ...
  12:         else if ("short".equals(getName()))
  13:             ret = new Short((short)-value.shortValue());

View Full Code Here
   1:         Class targetClass = targetType.getEType().getInstanceClass();
   2:         if (value != null && value instanceof Number) {
   3:         ...
   4:             Number num = (Number) value;
   5:             Class valClass = value.getClass();
   6:         ...
   7:                 if (targetWrapperClass.equals(Short.class))
   8:                     return new Short(num.shortValue());
   9:                 if (targetWrapperClass.equals(Long.class))

View Full Code Here
   1: 
   2:         if (Number.class.isAssignableFrom(cls)) 
   3:         {
   4:         ...
   5:             Number asNumber = null;
   6:         ...
   7:             if (o instanceof Number) 
   8:             {
   9:         ...
  10:             else if (cls.equals(Short.class))
  11:                 return new Short(asNumber.shortValue());

View Full Code Here
   1: 
   2:     public static Number convertNumberToTargetClass(Number number, Class targetClass)
   3:             throws IllegalArgumentException {
   4:         ...
   5:         else if (targetClass.equals(Short.class)) {
   6:             return new Short(number.shortValue());
   7:         }
   8:         else if (targetClass.equals(Integer.class)) {
   9:             return new Integer(number.intValue());

View Full Code Here