public class NumberKey extends SimpleKey<BigDecimal>
Constructor and Description |
---|
NumberKey()
Initializes the internal key value to
null . |
NumberKey(BigDecimal key)
Creates an NumberKey and set its internal representation
|
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(Number key)
Creates a NumberKey equivalent to
key . |
NumberKey(NumberKey key)
Creates a NumberKey that is equivalent to key.
|
NumberKey(String key)
Creates an NumberKey and set its internal representation
|
Modifier and Type | Method and Description |
---|---|
byte |
byteValue()
Returns the value of this NumberKey as a byte.
|
int |
compareTo(Object o)
Implements the compareTo method.
|
double |
doubleValue()
Returns the value of this NumberKey as a double.
|
float |
floatValue()
Returns the value of this NumberKey as a float.
|
int |
getJdbcType()
Returns the JDBC type of the key
as defined in
java.sql.Types . |
int |
intValue()
Returns the value of this NumberKey as an int.
|
long |
longValue()
Returns the value of this NumberKey as a long.
|
void |
setValue(String key)
Sets the internal representation using a String representation
of a number.
|
short |
shortValue()
Returns the value of this NumberKey as a short.
|
keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor, keyFor
public NumberKey()
null
.public NumberKey(String key)
key
- the key value as Stringpublic NumberKey(BigDecimal key)
key
- the key valuepublic NumberKey(NumberKey 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(Number key)
key
.
Convenience only.key
- the key valuepublic void setValue(String key)
key
- the key valueNumberFormatException
- if key is not a valid numberpublic int getJdbcType()
java.sql.Types
.getJdbcType
in class ObjectKey<BigDecimal>
Types.NUMERIC
.public int compareTo(Object o)
ObjectKey
compareTo
in interface Comparable<Object>
compareTo
in class ObjectKey<BigDecimal>
o
- the comparison valuepublic 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.Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.