2004.04.29


com.jdc.math
Class Integer

java.lang.Object
  |
  +--java.lang.Number
        |
        +--com.jdc.math.Number
              |
              +--com.jdc.math.Integer
All Implemented Interfaces:
DefaultLocale, Serializable

public class Integer
extends Number

Author:
n0119645 To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to Window>Preferences>Java>Code Generation.
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.jdc.util.DefaultLocale
DEFAULT_LOCALE
 
Constructor Summary
Integer()
          Constructs a new Integer object with a value of zero, i.e.
Integer(long value)
          Constructs a new Integer object for the specified long value.
Integer(String value)
          Constructs a new Integer object for the specified String value.
 
Method Summary
 Integer add(long value)
          Adds a long value to this Integer value.
 Integer add(Number number)
          Adds another Number value to this Integer value.
 Integer divide(long value)
          Divides a long value into to this Integer value.
 Integer divide(Number number)
          Divides another Number value into this Integer value.
 double doubleValue()
          Converts this Integer to a double.
 boolean equals(Object object)
          Compares this Integer with the specified Object for equality.
 float floatValue()
          Converts this Integer to a float.
 String format()
          Returns a formatted String representation of this Integer object.
 Locale getLocale()
          Returns the Locale object to be used when formatting this Integer object.
 int hashCode()
          Returns the hash code for this Integer object.
 int intValue()
          Converts this Integer to an int.
 boolean isNaN()
          Returns true if the value represented by this Integer object is Not-a-Number, i.e.
 long longValue()
          Converts this Integer to a long.
static void main(String[] args)
          Executes the unit tests for the Integer class.
 Integer multiply(long value)
          Multiplies this Integer value by long value.
 Integer multiply(Number number)
          Multiplies this Integer value by another Number value.
 Integer set(long value)
          Sets the value for this Integer object from a primitive long value.
 Integer set(String value)
          Sets the value for this Integer object.
 Integer setLocale(Locale locale)
          Sets the Locale object to be used when formatting this Integer object.
 Integer subtract(long value)
          Subtracts a long value from this Integer value..
 Integer subtract(Number number)
          Subtracts another Number value from this Integer value.
 BigInteger toBigInteger()
          Returns a BigInteger representation of this Integer object.
 String toString()
          Returns a String representation of this Integer object.
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Integer

public Integer()
Constructs a new Integer object with a value of zero, i.e. 0.


Integer

public Integer(long value)
Constructs a new Integer object for the specified long value.


Integer

public Integer(String value)
Constructs a new Integer object for the specified String value.

See Also:
BigInteger.BigInteger(String)
Method Detail

add

public Integer add(long value)
Adds a long value to this Integer value.

Returns:
ThisInteger object.

add

public Integer add(Number number)
Adds another Number value to this Integer value. A Number value may be a Integer or Integer object.

Returns:
ThisInteger object.

divide

public Integer divide(long value)
Divides a long value into to this Integer value.

Returns:
ThisInteger object.

divide

public Integer divide(Number number)
Divides another Number value into this Integer value. A Number value may be a Integer or Integer object.

Returns:
ThisInteger object.

doubleValue

public double doubleValue()
Converts this Integer to a double. Similar to the double-to-float narrowing primitive conversion defined in The Java Language Specification: if this Integer has too great a magnitude to represent as a double, it will be converted to DOUBLE.NEGATIVE_INFINITY or DOUBLE.POSITIVE_INFINITY as appropriate.

Overrides:
doubleValue in class Number
Returns:
The numeric value represented by this object after conversion to type double.

equals

public boolean equals(Object object)
Compares this Integer with the specified Object for equality. This method considers two Integer objectss equal only if they are equal in value and scale (thus 2.0 is not equal to 2.00 when compared by this method).

Overrides:
equals in class Object
Returns:
True if and only if the specified Object is a Integer whose value and scale are equal to this Integer object.

floatValue

public float floatValue()
Converts this Integer to a float. Similar to the double-to-float narrowing primitive conversion defined in The Java Language Specification: if this Integer has too great a magnitude to represent as a float, it will be converted to FLOAT.NEGATIVE_INFINITY or FLOAT.POSITIVE_INFINITY as appropriate.

Overrides:
floatValue in class Number
Returns:
The numeric value represented by this object after conversion to type float.

format

public String format()
Returns a formatted String representation of this Integer object.

Returns:
A formatted String representation of this Integer object.

getLocale

public Locale getLocale()
Returns the Locale object to be used when formatting this Integer object. If not specified, the locale object for the United States, i.e. Locale.US is used.

Returns:
The Locale object to be used when formatting this Integer object.

hashCode

public int hashCode()
Returns the hash code for this Integer object. Note that two Integer objects that are numerically equal but differ in scale, e.g. 2.0 and 2.00, will generally not have the same hash code.

Overrides:
hashCode in class Object
Returns:
The hash code for this Integer object.

intValue

public int intValue()
Converts this Integer to an int. Standard narrowing primitive conversion as defined in The Java Language Specification: any fractional part of this Integer will be discarded, and if the resulting Integer is too big to fit in an int, only the low-order 32 bits are returned.

Overrides:
intValue in class Number
Returns:
The numeric value represented by this object after conversion to type int

isNaN

public boolean isNaN()
Returns true if the value represented by this Integer object is Not-a-Number, i.e. NaN.

Specified by:
isNaN in class Number
Returns:
True if the value is Not-a-Number, i.e. NaN. False if the value is a valid decimal number.

longValue

public long longValue()
Converts this Integer to a long. Standard narrowing primitive conversion as defined in The Java Language Specification: any fractional part of this Integer will be discarded, and if the resulting Integer is too big to fit in a long, only the low-order 64 bits are returned.

Overrides:
longValue in class Number
Returns:
The numeric value represented by this object after conversion to type long.

multiply

public Integer multiply(long value)
Multiplies this Integer value by long value.

Returns:
ThisInteger object.

multiply

public Integer multiply(Number number)
Multiplies this Integer value by another Number value. A Number value may be a Integer or Integer object.

Returns:
ThisInteger object.

set

public Integer set(long value)
Sets the value for this Integer object from a primitive long value.

Returns:
ThisInteger object.

set

public Integer set(String value)
Sets the value for this Integer object.

Returns:
ThisInteger object.

setLocale

public Integer setLocale(Locale locale)
Sets the Locale object to be used when formatting this Integer object.

Returns:
ThisInteger object.

subtract

public Integer subtract(long value)
Subtracts a long value from this Integer value..

Returns:
ThisInteger object.

subtract

public Integer subtract(Number number)
Subtracts another Number value from this Integer value. A Number value may be a Integer or Integer object.

Returns:
ThisInteger object.

toBigInteger

public BigInteger toBigInteger()
Returns a BigInteger representation of this Integer object. If the value represented by this Integer object is Not-a-Number, null is returned.

Returns:
A BigInteger representation of this Integer object.

toString

public String toString()
Returns a String representation of this Integer object. The primitive double value represented by this object is converted to a String and returned.

Overrides:
toString in class Object
Returns:
A String representation of this Integer object.

main

public static void main(String[] args)
Executes the unit tests for the Integer class.


2004.04.29



Copyright © 2004 J. Damon & Co.; All Rights Reserved WorldWide.