|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gson.JsonElement
com.google.gson.JsonPrimitive
public final class JsonPrimitive
A class representing a Json primitive value. A primitive value is either a String, a Java primitive, or a Java primitive wrapper type.
| Constructor Summary | |
|---|---|
JsonPrimitive(java.lang.Boolean bool)
Create a primitive containing a boolean value. |
|
JsonPrimitive(char c)
Create a primitive containing a character. |
|
JsonPrimitive(java.lang.Character c)
Create a primitive containing a character. |
|
JsonPrimitive(java.lang.Number number)
Create a primitive containing a Number. |
|
JsonPrimitive(java.lang.String string)
Create a primitive containing a String value. |
|
| Method Summary | |
|---|---|
boolean |
getAsBoolean()
convenience method to get this element as a boolean 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. |
java.lang.Number |
getAsNumber()
convenience method to get this element as a Number. |
short |
getAsShort()
convenience method to get this element as a primitive short. |
java.lang.String |
getAsString()
convenience method to get this element as a String. |
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. |
| Methods inherited from class com.google.gson.JsonElement |
|---|
getAsJsonArray, getAsJsonObject, getAsJsonPrimitive, isJsonArray, isJsonObject, isJsonPrimitive, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JsonPrimitive(java.lang.Boolean bool)
bool - the value to create the primitive with.public JsonPrimitive(java.lang.Number number)
Number.
number - the value to create the primitive with.public JsonPrimitive(java.lang.String string)
string - the value to create the primitive with.public JsonPrimitive(java.lang.Character c)
c - the value to create the primitive with.public JsonPrimitive(char c)
c - the value to create the primitive with.| Method Detail |
|---|
public boolean isBoolean()
public boolean getAsBoolean()
getAsBoolean in class JsonElementjava.lang.ClassCastException - if the value contained is not a valid boolean value.public boolean isNumber()
public java.lang.Number getAsNumber()
getAsNumber in class JsonElementjava.lang.ClassCastException - if the value contained is not a valid Number.public boolean isString()
public java.lang.String getAsString()
getAsString in class JsonElementjava.lang.ClassCastException - if the value contained is not a valid String.public double getAsDouble()
getAsDouble in class JsonElementjava.lang.ClassCastException - if the value contained is not a valid double.public float getAsFloat()
getAsFloat in class JsonElementjava.lang.ClassCastException - if the value contained is not a valid float.public long getAsLong()
getAsLong in class JsonElementjava.lang.ClassCastException - if the value contained is not a valid long.public short getAsShort()
getAsShort in class JsonElementjava.lang.ClassCastException - if the value contained is not a valid short value.public int getAsInt()
getAsInt in class JsonElementjava.lang.ClassCastException - if the value contained is not a valid integer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||