Class DocumentElement
java.lang.Object
com.inductiveautomation.ignition.common.document.DocumentElement
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Document
,DocumentArray
,DocumentNull
,DocumentPrimitive
A class representing an element of Document. It could either be a
Document
, a DocumentArray
, a
DocumentPrimitive
or a DocumentNull
.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract DocumentElement
deepCopy()
Returns a deep copy of this element.static DocumentElement
fromJson
(com.inductiveautomation.ignition.common.gson.JsonElement element) Utility method to convert a GsonJsonElement
to an Ignition DocumentElement.convenience method to get this element as aBigDecimal
.convenience method to get this element as aBigInteger
.boolean
convenience method to get this element as a boolean value.byte
convenience method to get this element as a primitive byte value.char
convenience method to get this element as a primitive character value.convenience method to get this element as aDocument
.convenience method to get this element as aDocumentArray
.convenience method to get this element as aDocumentNull
.convenience method to get this element as aDocumentPrimitive
.double
convenience method to get this element as a primitive double value.float
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
convenience method to get this element as a primitive long value.convenience method to get this element as aNumber
.short
convenience method to get this element as a primitive short value.convenience method to get this element as a string value.boolean
provides check for verifying if this element is a Document object or not.boolean
provides check for verifying if this element is an array or not.boolean
provides check for verifying if this element represents a null value or not.boolean
provides check for verifying if this element is a primitive or not.abstract com.inductiveautomation.ignition.common.gson.JsonElement
toString()
Returns a String representation of this element.
-
Constructor Details
-
DocumentElement
public DocumentElement()
-
-
Method Details
-
fromJson
public static DocumentElement fromJson(com.inductiveautomation.ignition.common.gson.JsonElement element) Utility method to convert a GsonJsonElement
to an Ignition DocumentElement. -
deepCopy
Returns a deep copy of this element. Immutable elements like primitives and nulls are not copied.- Since:
- 2.8.2
-
toJsonElement
public abstract com.inductiveautomation.ignition.common.gson.JsonElement toJsonElement() -
isDocumentArray
public boolean isDocumentArray()provides check for verifying if this element is an array or not.- Returns:
- true if this element is of type
DocumentArray
, false otherwise.
-
isDocument
public boolean isDocument()provides check for verifying if this element is a Document object or not.- Returns:
- true if this element is of type
Document
, false otherwise.
-
isDocumentPrimitive
public boolean isDocumentPrimitive()provides check for verifying if this element is a primitive or not.- Returns:
- true if this element is of type
DocumentPrimitive
, false otherwise.
-
isDocumentNull
public boolean isDocumentNull()provides check for verifying if this element represents a null value or not.- Returns:
- true if this element is of type
DocumentNull
, false otherwise. - Since:
- 1.2
-
getAsDocument
convenience method to get this element as aDocument
. If the element is of some other type, aIllegalStateException
will result. Hence it is best to use this method after ensuring that this element is of the desired type by callingisDocument()
first.- Returns:
- get this element as a
Document
. - Throws:
IllegalStateException
- if the element is of another type.
-
getAsDocumentArray
convenience method to get this element as aDocumentArray
. If the element is of some other type, aIllegalStateException
will result. Hence it is best to use this method after ensuring that this element is of the desired type by callingisDocumentArray()
first.- Returns:
- get this element as a
DocumentArray
. - Throws:
IllegalStateException
- if the element is of another type.
-
getAsDocumentPrimitive
convenience method to get this element as aDocumentPrimitive
. If the element is of some other type, aIllegalStateException
will result. Hence it is best to use this method after ensuring that this element is of the desired type by callingisDocumentPrimitive()
first.- Returns:
- get this element as a
DocumentPrimitive
. - Throws:
IllegalStateException
- if the element is of another type.
-
getAsDocumentNull
convenience method to get this element as aDocumentNull
. If the element is of some other type, aIllegalStateException
will result. Hence it is best to use this method after ensuring that this element is of the desired type by callingisDocumentNull()
first.- Returns:
- get this element as a
DocumentNull
. - Throws:
IllegalStateException
- if the element is of another type.- Since:
- 1.2
-
getAsBoolean
public boolean getAsBoolean()convenience method to get this element as a boolean value.- Returns:
- get this element as a primitive boolean value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid boolean value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.
-
getAsNumber
convenience method to get this element as aNumber
.- Returns:
- get this element as a
Number
. - Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid number.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.
-
getAsString
convenience method to get this element as a string value.- Returns:
- get this element as a string value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid string value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.
-
getAsDouble
public double getAsDouble()convenience method to get this element as a primitive double value.- Returns:
- get this element as a primitive double value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid double value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.
-
getAsFloat
public float getAsFloat()convenience method to get this element as a primitive float value.- Returns:
- get this element as a primitive float value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid float value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.
-
getAsLong
public long getAsLong()convenience method to get this element as a primitive long value.- Returns:
- get this element as a primitive long value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid long value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.
-
getAsInt
public int getAsInt()convenience method to get this element as a primitive integer value.- Returns:
- get this element as a primitive integer value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid integer value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.
-
getAsByte
public byte getAsByte()convenience method to get this element as a primitive byte value.- Returns:
- get this element as a primitive byte value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid byte value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.- Since:
- 1.3
-
getAsCharacter
public char getAsCharacter()convenience method to get this element as a primitive character value.- Returns:
- get this element as a primitive char value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid char value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.- Since:
- 1.3
-
getAsBigDecimal
convenience method to get this element as aBigDecimal
.- Returns:
- get this element as a
BigDecimal
. - Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
.NumberFormatException
- if the element is not a validBigDecimal
.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.- Since:
- 1.2
-
getAsBigInteger
convenience method to get this element as aBigInteger
.- Returns:
- get this element as a
BigInteger
. - Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
.NumberFormatException
- if the element is not a validBigInteger
.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.- Since:
- 1.2
-
getAsShort
public short getAsShort()convenience method to get this element as a primitive short value.- Returns:
- get this element as a primitive short value.
- Throws:
ClassCastException
- if the element is of not aDocumentPrimitive
and is not a valid short value.IllegalStateException
- if the element is of the typeDocumentArray
but contains more than a single element.
-
toString
Returns a String representation of this element. -
toStringNoIndent
-