|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectxv.json.JSONVariant
xv.json.JSONNumber
public class JSONNumber
A JSON number. Wraps a Java Number
object.
If Java supported multiple inheritance, this would also extend Number
.
An interface for numeric-like objects would be nice too.
Constructor Summary | |
---|---|
JSONNumber(Number number)
Wraps the given Java Number . |
Method Summary | |
---|---|
byte |
byteValue()
Returns the value as a byte . |
double |
doubleValue()
Returns the value as a double . |
boolean |
equals(Object object)
|
float |
floatValue()
Returns the value as a float . |
Number |
getNumber()
Gets the wrapped Java Number . |
String |
getType()
Returns "number" . |
int |
hashCode()
|
int |
intValue()
Returns the value as an int . |
long |
longValue()
Returns the value as a long . |
short |
shortValue()
Returns the value as a short . |
String |
toString()
Returns the string value of the number. |
static JSONNumber |
valueOf(String s)
Parses the given string as if it were a JSON number, returning an appropriately wrapped Number . |
Methods inherited from class xv.json.JSONVariant |
---|
toJSON, write |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JSONNumber(Number number)
Number
.
number
- the number to wrapMethod Detail |
---|
public Number getNumber()
Number
.
public byte byteValue()
byte
.
byte
Number.byteValue()
public short shortValue()
short
.
short
Number.shortValue()
public int intValue()
int
.
int
Number.intValue()
,
BigInteger.intValue()
public long longValue()
long
.
long
Number.longValue()
,
BigInteger.longValue()
public float floatValue()
float
.
float
Number.floatValue()
,
BigInteger.floatValue()
public double doubleValue()
double
.
double
Number.doubleValue()
,
BigInteger.doubleValue()
public String toString()
JSONNumber
via
valueOf(String)
.
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object object)
equals
in class Object
public String getType()
"number"
.
getType
in class JSONVariant
public static JSONNumber valueOf(String s)
Number
.
s
- the string to parse
NullPointerException
- if the given string is null
NumberFormatException
- if the number cannot be parsed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |