Class DocumentPrimitive
java.lang.Object
com.inductiveautomation.ignition.common.document.DocumentElement
com.inductiveautomation.ignition.common.document.DocumentPrimitive
- All Implemented Interfaces:
Serializable
A class representing a Json primitive value. A primitive value is either a String, a Java primitive, or a Java
primitive wrapper type.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDocumentPrimitive(Boolean bool) Create a primitive containing a boolean value.Create a primitive containing a character.DocumentPrimitive(Number number) Create a primitive containing aNumber.DocumentPrimitive(String string) Create a primitive containing a String value. -
Method Summary
Modifier and TypeMethodDescriptiondeepCopy()Returns the same value, as primitives are immutable.booleanconvenience method to get this element as aBigDecimal.convenience method to get this element as aBigInteger.booleanconvenience method to get this element as a boolean value.byteconvenience method to get this element as a primitive byte value.charconvenience method to get this element as a primitive character value.doubleconvenience method to get this element as a primitive double.floatconvenience method to get this element as a float.intgetAsInt()convenience method to get this element as a primitive integer.longconvenience method to get this element as a primitive long.convenience method to get this element as a Number.shortconvenience method to get this element as a primitive short.convenience method to get this element as a String.inthashCode()booleanCheck whether this primitive contains a boolean value.booleanisNumber()Check whether this primitive contains a Number.booleanisString()Check whether this primitive contains a String value.com.inductiveautomation.ignition.common.gson.JsonPrimitiveMethods inherited from class com.inductiveautomation.ignition.common.document.DocumentElement
fromJson, getAsDocument, getAsDocumentArray, getAsDocumentNull, getAsDocumentPrimitive, isDocument, isDocumentArray, isDocumentNull, isDocumentPrimitive, toString, toStringNoIndent
-
Constructor Details
-
DocumentPrimitive
Create a primitive containing a boolean value.- Parameters:
bool- the value to create the primitive with.
-
DocumentPrimitive
Create a primitive containing aNumber.- Parameters:
number- the value to create the primitive with.
-
DocumentPrimitive
Create a primitive containing a String value.- Parameters:
string- the value to create the primitive with.
-
DocumentPrimitive
Create a primitive containing a character. The character is turned into a one character String since Json only supports String.- Parameters:
c- the value to create the primitive with.
-
-
Method Details
-
toJsonElement
public com.inductiveautomation.ignition.common.gson.JsonPrimitive toJsonElement()- Specified by:
toJsonElementin classDocumentElement
-
deepCopy
Returns the same value, as primitives are immutable.- Specified by:
deepCopyin classDocumentElement
-
isBoolean
public boolean isBoolean()Check whether this primitive contains a boolean value.- Returns:
- true if this primitive contains a boolean value, false otherwise.
-
getAsBoolean
public boolean getAsBoolean()convenience method to get this element as a boolean value.- Overrides:
getAsBooleanin classDocumentElement- Returns:
- get this element as a primitive boolean value.
-
isNumber
public boolean isNumber()Check whether this primitive contains a Number.- Returns:
- true if this primitive contains a Number, false otherwise.
-
getAsNumber
convenience method to get this element as a Number.- Overrides:
getAsNumberin classDocumentElement- Returns:
- get this element as a Number.
- Throws:
NumberFormatException- if the value contained is not a valid Number.
-
isString
public boolean isString()Check whether this primitive contains a String value.- Returns:
- true if this primitive contains a String value, false otherwise.
-
getAsString
convenience method to get this element as a String.- Overrides:
getAsStringin classDocumentElement- Returns:
- get this element as a String.
-
getAsDouble
public double getAsDouble()convenience method to get this element as a primitive double.- Overrides:
getAsDoublein classDocumentElement- Returns:
- get this element as a primitive double.
- Throws:
NumberFormatException- if the value contained is not a valid double.
-
getAsBigDecimal
convenience method to get this element as aBigDecimal.- Overrides:
getAsBigDecimalin classDocumentElement- Returns:
- get this element as a
BigDecimal. - Throws:
NumberFormatException- if the value contained is not a validBigDecimal.
-
getAsBigInteger
convenience method to get this element as aBigInteger.- Overrides:
getAsBigIntegerin classDocumentElement- Returns:
- get this element as a
BigInteger. - Throws:
NumberFormatException- if the value contained is not a validBigInteger.
-
getAsFloat
public float getAsFloat()convenience method to get this element as a float.- Overrides:
getAsFloatin classDocumentElement- Returns:
- get this element as a float.
- Throws:
NumberFormatException- if the value contained is not a valid float.
-
getAsLong
public long getAsLong()convenience method to get this element as a primitive long.- Overrides:
getAsLongin classDocumentElement- Returns:
- get this element as a primitive long.
- Throws:
NumberFormatException- if the value contained is not a valid long.
-
getAsShort
public short getAsShort()convenience method to get this element as a primitive short.- Overrides:
getAsShortin classDocumentElement- Returns:
- get this element as a primitive short.
- Throws:
NumberFormatException- if the value contained is not a valid short value.
-
getAsInt
public int getAsInt()convenience method to get this element as a primitive integer.- Overrides:
getAsIntin classDocumentElement- Returns:
- get this element as a primitive integer.
- Throws:
NumberFormatException- if the value contained is not a valid integer.
-
getAsByte
public byte getAsByte()Description copied from class:DocumentElementconvenience method to get this element as a primitive byte value.- Overrides:
getAsBytein classDocumentElement- Returns:
- get this element as a primitive byte value.
-
getAsCharacter
public char getAsCharacter()Description copied from class:DocumentElementconvenience method to get this element as a primitive character value.- Overrides:
getAsCharacterin classDocumentElement- Returns:
- get this element as a primitive char value.
-
hashCode
public int hashCode() -
equals
-