public final class JsonPrimitive extends JsonElement
Constructor and Description |
---|
JsonPrimitive(Boolean bool)
Create a primitive containing a boolean value.
|
JsonPrimitive(Character c)
Create a primitive containing a character.
|
JsonPrimitive(Number number)
Create a primitive containing a
Number . |
JsonPrimitive(String string)
Create a primitive containing a String value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
BigDecimal |
getAsBigDecimal()
convenience method to get this element as a
BigDecimal . |
BigInteger |
getAsBigInteger()
convenience method to get this element as a
BigInteger . |
boolean |
getAsBoolean()
convenience method to get this element as a boolean value.
|
byte |
getAsByte()
convenience method to get this element as a primitive byte value.
|
char |
getAsCharacter()
convenience method to get this element as a primitive character value.
|
double |
getAsDouble()
convenience method to get this element as a primitive double.
|
float |
getAsFloat()
convenience method to get this element as a float.
|
int |
getAsInt()
convenience method to get this element as a primitive integer.
|
long |
getAsLong()
convenience method to get this element as a primitive long.
|
Number |
getAsNumber()
convenience method to get this element as a Number.
|
short |
getAsShort()
convenience method to get this element as a primitive short.
|
String |
getAsString()
convenience method to get this element as a String.
|
int |
hashCode() |
boolean |
isBoolean()
Check whether this primitive contains a boolean value.
|
boolean |
isNumber()
Check whether this primitive contains a Number.
|
boolean |
isString()
Check whether this primitive contains a String value.
|
getAsJsonArray, getAsJsonNull, getAsJsonObject, getAsJsonPrimitive, isJsonArray, isJsonNull, isJsonObject, isJsonPrimitive, toString
public JsonPrimitive(Boolean bool)
bool
- the value to create the primitive with.public JsonPrimitive(Number number)
Number
.number
- the value to create the primitive with.public JsonPrimitive(String string)
string
- the value to create the primitive with.public JsonPrimitive(Character c)
c
- the value to create the primitive with.public boolean isBoolean()
public boolean getAsBoolean()
getAsBoolean
in class JsonElement
public boolean isNumber()
public Number getAsNumber()
getAsNumber
in class JsonElement
NumberFormatException
- if the value contained is not a valid Number.public boolean isString()
public String getAsString()
getAsString
in class JsonElement
public double getAsDouble()
getAsDouble
in class JsonElement
NumberFormatException
- if the value contained is not a valid double.public BigDecimal getAsBigDecimal()
BigDecimal
.getAsBigDecimal
in class JsonElement
BigDecimal
.NumberFormatException
- if the value contained is not a valid BigDecimal
.public BigInteger getAsBigInteger()
BigInteger
.getAsBigInteger
in class JsonElement
BigInteger
.NumberFormatException
- if the value contained is not a valid BigInteger
.public float getAsFloat()
getAsFloat
in class JsonElement
NumberFormatException
- if the value contained is not a valid float.public long getAsLong()
getAsLong
in class JsonElement
NumberFormatException
- if the value contained is not a valid long.public short getAsShort()
getAsShort
in class JsonElement
NumberFormatException
- if the value contained is not a valid short value.public int getAsInt()
getAsInt
in class JsonElement
NumberFormatException
- if the value contained is not a valid integer.public byte getAsByte()
JsonElement
getAsByte
in class JsonElement
public char getAsCharacter()
JsonElement
getAsCharacter
in class JsonElement
Copyright © 2016. All Rights Reserved.