public final class SingleValue extends ValueNode<Object>
ValueNode that holds a single scalar value (or null).
The value's type is tracked by a FieldType that is either explicitly specified or inferred
from the value's Java class at construction time.ValueNode,
ArrayValue,
Record,
Field,
FieldType,
Serialized FormNode.DuplicateNodeAction, Node.NodeTypeSession.SessionImpl| Modifier | Constructor and Description |
|---|---|
protected |
SingleValue(FieldType type,
Object value) |
protected |
SingleValue(Object value) |
| Modifier and Type | Method and Description |
|---|---|
SingleValue |
clone()
Returns a deep copy of this single value.
|
int |
compareTo(ValueNode<Object> o)
Compares this single value to another by their underlying values using natural ordering.
|
int |
compareTo(ValueNode<Object> o,
Collator collator)
Compares this single value to another by their underlying values, optionally using the specified
Collator for string comparisons. |
boolean |
equals(Object o)
Indicates whether the given object is a
SingleValue with an equal underlying value. |
Node.NodeType |
getNodeType()
Returns the concrete
Node.NodeType of this node. |
long |
getSizeInBytes()
Returns the estimated size of this value node in bytes, including object overhead.
|
FieldType |
getType()
Returns the
FieldType of this value node. |
Object |
getValue()
Returns the underlying value held by this node.
|
BigDecimal |
getValueAsBigDecimal()
Returns the value as a
BigDecimal. |
BigInteger |
getValueAsBigInteger()
Returns the value as a
BigInteger. |
boolean |
getValueAsBoolean()
Returns the value as a
boolean. |
byte |
getValueAsByte()
Returns the value as a
byte. |
byte[] |
getValueAsBytes()
Returns the value as a
byte[]. |
char |
getValueAsChar()
Returns the value as a
char. |
Date |
getValueAsDate()
Returns the value as a
Date. |
Date |
getValueAsDatetime()
Returns the value as a
Date (datetime). |
double |
getValueAsDouble()
Returns the value as a
double. |
float |
getValueAsFloat()
Returns the value as a
float. |
Instant |
getValueAsInstant()
Returns the value as an
Instant. |
int |
getValueAsInteger()
Returns the value as an
int. |
LocalDate |
getValueAsLocalDate()
Returns the value as a
LocalDate. |
LocalDateTime |
getValueAsLocalDateTime()
Returns the value as a
LocalDateTime using the system default time zone. |
LocalTime |
getValueAsLocalTime()
Returns the value as a
LocalTime. |
long |
getValueAsLong()
Returns the value as a
long. |
short |
getValueAsShort()
Returns the value as a
short. |
String |
getValueAsString()
Returns a string representation of the value held by this node.
|
Time |
getValueAsTime()
Returns the value as a
Time. |
UUID |
getValueAsUuid()
Returns the value as a
UUID. |
boolean |
hasChildNodes()
Returns
true if this node contains any sub nodes. |
boolean |
hasChildRecords()
Returns
true if this node contains any descendant, record nodes. |
int |
hashCode()
Returns a hash code based on the underlying value.
|
boolean |
isArray()
Returns
true if this value node is an ArrayValue. |
boolean |
isRecord()
Returns
true if this value node is a Record. |
boolean |
isSingleValue()
Returns
true if this value node is a SingleValue. |
protected void |
removeChildNode(Node child) |
String |
toJson()
Serializes this value node to a JSON string.
|
String |
toString()
Returns a string representation of this value, truncated to
Field.MAX_DISPLAY_STRING characters
if necessary. |
String |
toXml()
Serializes this value node to an XML string.
|
asArray, asArrayValue, asRecord, asSingleValue, from, from, getParentNode, isNotArray, isNotNull, isNotRecord, isNotSingleValue, isNull, isValueNode, nullValue, nullValue, setParentNodeassertNotAncestorOf, containsSessionProperty, containsSessionProperty, containsSessionProperty, copySessionPropertiesFrom, getNodeDepth, getParentField, getParentRecord, getSessionProperty, getSessionProperty, getSessionProperty, isAncestorOf, isChildNode, keySet, removeSessionProperties, setSessionProperty, setSessionProperty, setSessionPropertyprotected SingleValue(Object value)
public FieldType getType()
FieldType of this value node. For SingleValue, this is the type of the contained
value. For ArrayValue, the type is derived from its elements or its default type. For Record,
the type is always FieldType.RECORD.public Node.NodeType getNodeType()
Node.NodeType of this node.getNodeType in class NodeNodeType#SINGLE_VALUEpublic boolean hasChildNodes()
true if this node contains any sub nodes.
Always returns false since a single value has no child nodes.
hasChildNodes in class Nodepublic boolean hasChildRecords()
true if this node contains any descendant, record nodes.
Always returns false since a single value cannot contain records.
hasChildRecords in class Nodeprotected void removeChildNode(Node child)
removeChildNode in class Nodepublic boolean isArray()
isArray in class ValueNode<Object>true if this is an array, false otherwiseValueNode.asArrayValue()public boolean isRecord()
isRecord in class ValueNode<Object>true if this is a record, false otherwiseValueNode.asRecord()public boolean isSingleValue()
isSingleValue in class ValueNode<Object>true if this is a single value, false otherwiseValueNode.asSingleValue()public Object getValue()
SingleValue, this is the wrapped object.
For ArrayValue, this returns the array itself. For Record, this returns the record itself.public String getValueAsString()
getValueAsString in class ValueNode<Object>FieldTypepublic Date getValueAsDatetime()
Date (datetime).ClassCastException - if the value is not a Datepublic Date getValueAsDate()
Date. If the underlying type is FieldType.DATETIME,
the value is converted; otherwise the value is cast directly.null if the value is nullClassCastException - if the value cannot be converted to a Datepublic Time getValueAsTime()
Time. If the underlying type is FieldType.DATETIME,
the value is converted; otherwise the value is cast directly.null if the value is nullClassCastException - if the value cannot be converted to a Timepublic int getValueAsInteger()
int.ClassCastException - if the value is not a NumberNullPointerException - if the value is nullpublic long getValueAsLong()
long.ClassCastException - if the value is not a NumberNullPointerException - if the value is nullpublic short getValueAsShort()
short.ClassCastException - if the value is not a NumberNullPointerException - if the value is nullpublic byte getValueAsByte()
byte.ClassCastException - if the value is not a NumberNullPointerException - if the value is nullpublic boolean getValueAsBoolean()
boolean.ClassCastException - if the value is not a BooleanNullPointerException - if the value is nullpublic char getValueAsChar()
char.NullPointerException - if the value is nullpublic double getValueAsDouble()
double.ClassCastException - if the value is not a NumberNullPointerException - if the value is nullpublic float getValueAsFloat()
float.ClassCastException - if the value is not a NumberNullPointerException - if the value is nullpublic byte[] getValueAsBytes()
byte[].ClassCastException - if the value is not a byte[]public BigDecimal getValueAsBigDecimal()
BigDecimal.ClassCastException - if the value is not a Numberpublic BigInteger getValueAsBigInteger()
BigInteger.ClassCastException - if the value is not a Numberpublic Instant getValueAsInstant()
Instant.null if the value is nullpublic LocalDateTime getValueAsLocalDateTime()
LocalDateTime using the system default time zone.null if the value is nullpublic LocalDate getValueAsLocalDate()
LocalDate.null if the value is nullpublic LocalTime getValueAsLocalTime()
LocalTime.null if the value is nullpublic UUID getValueAsUuid()
UUID.null if the value is nullClassCastException - if the value is not a UUIDpublic long getSizeInBytes()
getSizeInBytes in class ValueNode<Object>public int compareTo(ValueNode<Object> o)
o - the other value node to compare topublic int compareTo(ValueNode<Object> o, Collator collator)
Collator for string comparisons.o - the other value node to compare tocollator - the collator to use for string comparisons, or null for natural orderingpublic boolean equals(Object o)
SingleValue with an equal underlying value.public int hashCode()
public SingleValue clone()
clone in class ValueNode<Object>SingleValue with the same type and valuepublic String toJson()
ValueNodepublic String toXml()
ValueNodepublic String toString()
Field.MAX_DISPLAY_STRING characters
if necessary.Copyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.