|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.torque.om.ObjectKey org.apache.torque.om.SimpleKey org.apache.torque.om.NumberKey
public class NumberKey
This class can be used as an ObjectKey to uniquely identify an object within an application where the id consists of a single entity such a GUID or the value of a db row's primary key.
Field Summary |
---|
Fields inherited from class org.apache.torque.om.ObjectKey |
---|
key |
Constructor Summary | |
---|---|
NumberKey()
Creates a NumberKey whose internal representation will be set later, through a set method |
|
NumberKey(java.math.BigDecimal key)
Creates a NumberKey equivalent to key . |
|
NumberKey(double key)
Creates a NumberKey equivalent to key . |
|
NumberKey(int key)
Creates a NumberKey equivalent to key . |
|
NumberKey(long key)
Creates a NumberKey equivalent to key . |
|
NumberKey(java.lang.Number key)
Creates a NumberKey equivalent to key . |
|
NumberKey(NumberKey key)
Creates a NumberKey equivalent to key . |
|
NumberKey(java.lang.String key)
Creates a NumberKey equivalent to key . |
Method Summary | |
---|---|
byte |
byteValue()
Returns the value of this NumberKey as a byte. |
int |
compareTo(java.lang.Object o)
Implements the compareTo method. |
double |
doubleValue()
Returns the value of this NumberKey as a double. |
boolean |
equals(java.lang.Object keyObj)
Two ObjectKeys that both contain null values are not considered equal. |
float |
floatValue()
Returns the value of this NumberKey as a float. |
java.math.BigDecimal |
getBigDecimal()
Access the underlying BigDecimal object. |
int |
hashCode()
Returns the hashcode of the underlying value (key), if key is not null. |
int |
intValue()
Returns the value of this NumberKey as an int. |
long |
longValue()
Returns the value of this NumberKey as a long. |
void |
setValue(java.math.BigDecimal key)
Sets the underlying object |
void |
setValue(NumberKey key)
Sets the internal representation to the same object used by key. |
void |
setValue(java.lang.String key)
Sets the internal representation using a String representation of a number |
short |
shortValue()
Returns the value of this NumberKey as a short. |
java.lang.String |
toString()
Invokes the toString() method on the object. |
Methods inherited from class org.apache.torque.om.SimpleKey |
---|
keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor |
Methods inherited from class org.apache.torque.om.ObjectKey |
---|
appendTo, getValue |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NumberKey()
public NumberKey(java.lang.String key)
key
.
key
- the key valuepublic NumberKey(java.math.BigDecimal key)
key
.
key
- the key valuepublic NumberKey(NumberKey key)
key
.
key
- the key valuepublic NumberKey(long key)
key
.
key
- the key valuepublic NumberKey(double key)
key
.
key
- the key valuepublic NumberKey(int key)
key
.
Convenience only.
key
- the key valuepublic NumberKey(java.lang.Number key)
key
.
Convenience only.
key
- the key valueMethod Detail |
---|
public void setValue(java.lang.String key) throws java.lang.NumberFormatException
setValue
in class ObjectKey
key
- the key value
java.lang.NumberFormatException
- if key is not a valid numberpublic void setValue(java.math.BigDecimal key)
key
- the key valuepublic void setValue(NumberKey key)
key
- the key valuepublic java.math.BigDecimal getBigDecimal()
BigDecimal
valuepublic boolean equals(java.lang.Object keyObj)
equals
in class java.lang.Object
keyObj
- the key to compare values to
public int hashCode()
ObjectKey
hashCode
in class ObjectKey
public int compareTo(java.lang.Object o)
ObjectKey
compareTo
in interface java.lang.Comparable
compareTo
in class ObjectKey
o
- the comparison value
public java.lang.String toString()
toString
in class java.lang.Object
public byte byteValue()
Number.byteValue()
public int intValue()
BigDecimal.intValue()
, importantly any fractional part
will be discarded and if the underlying value is too big to fit in an
int, only the low-order 32 bits are returned. Note that this
conversion can lose information about the overall magnitude and
precision of the NumberKey value as well as return a result with the
opposite sign.
public short shortValue()
BigDecimal.intValue()
, importantly any fractional part
will be discarded and if the underlying value is too big to fit
in a long, only the low-order 64 bits are returned. Note that this
conversion can lose information about the overall magnitude and
precision of the NumberKey value as well as return a result with the
opposite sign.
public long longValue()
BigDecimal.intValue()
public float floatValue()
BigDecimal.floatValue()
, most importantly if the
underlying value has too great a magnitude to represent as a
float, it will be converted to Float.NEGATIVE_INFINITY
or Float.POSITIVE_INFINITY as appropriate.
public double doubleValue()
BigDecimal.doubleValue()
, most importantly if the
underlying value has too great a magnitude to represent as a
double, it will be converted to Double.NEGATIVE_INFINITY
or Double.POSITIVE_INFINITY as appropriate.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |