public abstract class DocumentElement
extends java.lang.Object
implements java.io.Serializable
Document
, a DocumentArray
, a
DocumentPrimitive
or a DocumentNull
.Constructor and Description |
---|
DocumentElement() |
Modifier and Type | Method and Description |
---|---|
abstract DocumentElement |
deepCopy()
Returns a deep copy of this element.
|
static DocumentElement |
fromJson(com.google.gson.JsonElement element)
Utility method to convert a Gson
JsonElement to an Ignition DocumentElement. |
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.
|
Document |
getAsDocument()
convenience method to get this element as a
Document . |
DocumentArray |
getAsDocumentArray()
convenience method to get this element as a
DocumentArray . |
DocumentNull |
getAsDocumentNull()
convenience method to get this element as a
DocumentNull . |
DocumentPrimitive |
getAsDocumentPrimitive()
convenience method to get this element as a
DocumentPrimitive . |
double |
getAsDouble()
convenience method to get this element as a primitive double value.
|
float |
getAsFloat()
convenience method to get this element as a primitive float value.
|
int |
getAsInt()
convenience method to get this element as a primitive integer value.
|
long |
getAsLong()
convenience method to get this element as a primitive long value.
|
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 value.
|
java.lang.String |
getAsString()
convenience method to get this element as a string value.
|
boolean |
isDocument()
provides check for verifying if this element is a Document object or not.
|
boolean |
isDocumentArray()
provides check for verifying if this element is an array or not.
|
boolean |
isDocumentNull()
provides check for verifying if this element represents a null value or not.
|
boolean |
isDocumentPrimitive()
provides check for verifying if this element is a primitive or not.
|
abstract com.google.gson.JsonElement |
toJsonElement() |
java.lang.String |
toString()
Returns a String representation of this element.
|
public static DocumentElement fromJson(com.google.gson.JsonElement element)
JsonElement
to an Ignition DocumentElement.public abstract DocumentElement deepCopy()
public abstract com.google.gson.JsonElement toJsonElement()
public boolean isDocumentArray()
DocumentArray
, false otherwise.public boolean isDocument()
Document
, false otherwise.public boolean isDocumentPrimitive()
DocumentPrimitive
, false otherwise.public boolean isDocumentNull()
DocumentNull
, false otherwise.public Document getAsDocument()
Document
. If the element is of some other type, a
IllegalStateException
will result. Hence it is best to use this method after ensuring that this element
is of the desired type by calling isDocument()
first.Document
.java.lang.IllegalStateException
- if the element is of another type.public DocumentArray getAsDocumentArray()
DocumentArray
. If the element is of some other type, a
IllegalStateException
will result. Hence it is best to use this method after ensuring that this element
is of the desired type by calling isDocumentArray()
first.DocumentArray
.java.lang.IllegalStateException
- if the element is of another type.public DocumentPrimitive getAsDocumentPrimitive()
DocumentPrimitive
. If the element is of some other type, a
IllegalStateException
will result. Hence it is best to use this method after ensuring that this element
is of the desired type by calling isDocumentPrimitive()
first.DocumentPrimitive
.java.lang.IllegalStateException
- if the element is of another type.public DocumentNull getAsDocumentNull()
DocumentNull
. If the element is of some other type, a
IllegalStateException
will result. Hence it is best to use this method after ensuring that this element
is of the desired type by calling isDocumentNull()
first.DocumentNull
.java.lang.IllegalStateException
- if the element is of another type.public boolean getAsBoolean()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid boolean value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public java.lang.Number getAsNumber()
Number
.Number
.java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid number.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public java.lang.String getAsString()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid string value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public double getAsDouble()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid double value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public float getAsFloat()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid float value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public long getAsLong()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid long value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public int getAsInt()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid integer value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public byte getAsByte()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid byte value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public char getAsCharacter()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid char value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public java.math.BigDecimal getAsBigDecimal()
BigDecimal
.BigDecimal
.java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
.java.lang.NumberFormatException
- if the element is
not a valid BigDecimal
.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public java.math.BigInteger getAsBigInteger()
BigInteger
.BigInteger
.java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
.java.lang.NumberFormatException
- if the element is not a valid BigInteger
.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public short getAsShort()
java.lang.ClassCastException
- if the element is of not a DocumentPrimitive
and is not a valid short value.java.lang.IllegalStateException
- if the element is of the type DocumentArray
but contains more than a single element.public java.lang.String toString()
toString
in class java.lang.Object