public final class DocumentPrimitive extends DocumentElement
Constructor and Description |
---|
DocumentPrimitive(java.lang.Boolean bool)
Create a primitive containing a boolean value.
|
DocumentPrimitive(java.lang.Character c)
Create a primitive containing a character.
|
DocumentPrimitive(java.lang.Number number)
Create a primitive containing a
Number . |
DocumentPrimitive(java.lang.String string)
Create a primitive containing a String value.
|
Modifier and Type | Method and Description |
---|---|
DocumentPrimitive |
deepCopy()
Returns the same value, as primitives are immutable.
|
boolean |
equals(java.lang.Object obj) |
java.math.BigDecimal |
getAsBigDecimal()
convenience method to get this element as a
BigDecimal . |
java.math.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.
|
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.
|
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.
|
com.google.gson.JsonPrimitive |
toJsonElement() |
fromJson, getAsDocument, getAsDocumentArray, getAsDocumentNull, getAsDocumentPrimitive, isDocument, isDocumentArray, isDocumentNull, isDocumentPrimitive, toString
public DocumentPrimitive(java.lang.Boolean bool)
bool
- the value to create the primitive with.public DocumentPrimitive(java.lang.Number number)
Number
.number
- the value to create the primitive with.public DocumentPrimitive(java.lang.String string)
string
- the value to create the primitive with.public DocumentPrimitive(java.lang.Character c)
c
- the value to create the primitive with.public com.google.gson.JsonPrimitive toJsonElement()
toJsonElement
in class DocumentElement
public DocumentPrimitive deepCopy()
deepCopy
in class DocumentElement
public boolean isBoolean()
public boolean getAsBoolean()
getAsBoolean
in class DocumentElement
public boolean isNumber()
public java.lang.Number getAsNumber()
getAsNumber
in class DocumentElement
java.lang.NumberFormatException
- if the value contained is not a valid Number.public boolean isString()
public java.lang.String getAsString()
getAsString
in class DocumentElement
public double getAsDouble()
getAsDouble
in class DocumentElement
java.lang.NumberFormatException
- if the value contained is not a valid double.public java.math.BigDecimal getAsBigDecimal()
BigDecimal
.getAsBigDecimal
in class DocumentElement
BigDecimal
.java.lang.NumberFormatException
- if the value contained is not a valid BigDecimal
.public java.math.BigInteger getAsBigInteger()
BigInteger
.getAsBigInteger
in class DocumentElement
BigInteger
.java.lang.NumberFormatException
- if the value contained is not a valid BigInteger
.public float getAsFloat()
getAsFloat
in class DocumentElement
java.lang.NumberFormatException
- if the value contained is not a valid float.public long getAsLong()
getAsLong
in class DocumentElement
java.lang.NumberFormatException
- if the value contained is not a valid long.public short getAsShort()
getAsShort
in class DocumentElement
java.lang.NumberFormatException
- if the value contained is not a valid short value.public int getAsInt()
getAsInt
in class DocumentElement
java.lang.NumberFormatException
- if the value contained is not a valid integer.public byte getAsByte()
DocumentElement
getAsByte
in class DocumentElement
public char getAsCharacter()
DocumentElement
getAsCharacter
in class DocumentElement
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object