public abstract class ValueNode<T> extends Node implements Comparable<ValueNode<T>>, Cloneable
FieldType)SingleValue,
Record,
ArrayValue,
Node,
Field,
FieldType,
Serialized FormNode.DuplicateNodeAction, Node.NodeTypeSession.SessionImpl| Modifier | Constructor and Description |
|---|---|
protected |
ValueNode() |
| Modifier and Type | Method and Description |
|---|---|
static ArrayValue |
asArray(FieldType type,
Object value)
Wraps the given value as an
ArrayValue. |
ArrayValue |
asArrayValue()
Casts this value node to an
ArrayValue. |
Record |
asRecord()
Casts this value node to a
Record. |
SingleValue |
asSingleValue()
Casts this value node to a
SingleValue. |
abstract ValueNode<T> |
clone()
Returns a deep copy of this value node.
|
static ValueNode<?> |
from(FieldType type,
Object value)
|
static ValueNode<?> |
from(Object value)
Converts the given object to the appropriate
ValueNode subtype. |
Node |
getParentNode()
Returns the parent node that this node belongs to, or
null if this is a root node. |
abstract long |
getSizeInBytes()
Returns the estimated size of this value node in bytes, including object overhead.
|
abstract FieldType |
getType()
Returns the
FieldType of this value node. |
abstract T |
getValue()
Returns the underlying value held by this node.
|
abstract String |
getValueAsString()
Returns a string representation of the value held by this node.
|
boolean |
isArray()
Returns
true if this value node is an ArrayValue. |
boolean |
isNotArray()
Returns
true if this value node is not an ArrayValue. |
boolean |
isNotNull()
Returns
true if this node does not contain a null value. |
boolean |
isNotRecord()
Returns
true if this value node is not a Record. |
boolean |
isNotSingleValue()
Returns
true if this value node is not a SingleValue. |
boolean |
isNull()
Returns
true if this node contains a null value. |
boolean |
isRecord()
Returns
true if this value node is a Record. |
boolean |
isSingleValue()
Returns
true if this value node is a SingleValue. |
boolean |
isValueNode()
Returns
true if this node is a ValueNode (Record, ArrayValue, or SingleValue). |
static SingleValue |
nullValue()
|
static SingleValue |
nullValue(FieldType type)
|
protected Node |
setParentNode(Node parentNode)
Sets the parent node of this value node.
|
abstract String |
toJson()
Serializes this value node to a JSON string.
|
abstract String |
toXml()
Serializes this value node to an XML string.
|
assertNotAncestorOf, containsSessionProperty, containsSessionProperty, containsSessionProperty, copySessionPropertiesFrom, getNodeDepth, getNodeType, getParentField, getParentRecord, getSessionProperty, getSessionProperty, getSessionProperty, hasChildNodes, hasChildRecords, isAncestorOf, isChildNode, keySet, removeChildNode, removeSessionProperties, setSessionProperty, setSessionProperty, setSessionProperty, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcompareTopublic abstract 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.nullpublic Node getParentNode()
null if this is a root node.getParentNode in class NodeNode that this value node belongs to, or null if this is a root nodeprotected Node setParentNode(Node parentNode)
DataException.parentNode - the new parent node, or null to detach from the current parentpublic boolean isValueNode()
true if this node is a ValueNode (Record, ArrayValue, or SingleValue).
Always returns true for all ValueNode subclasses (SingleValue, Record,
and ArrayValue).
isValueNode in class Nodetruepublic boolean isArray()
true if this value node is an ArrayValue.true if this is an array, false otherwiseasArrayValue()public boolean isNotArray()
true if this value node is not an ArrayValue.true if this is not an array, false otherwiseisArray()public boolean isRecord()
true if this value node is a Record.true if this is a record, false otherwiseasRecord()public boolean isNotRecord()
true if this value node is not a Record.true if this is not a record, false otherwiseisRecord()public boolean isSingleValue()
true if this value node is a SingleValue.true if this is a single value, false otherwiseasSingleValue()public boolean isNotSingleValue()
true if this value node is not a SingleValue.true if this is not a single value, false otherwiseisSingleValue()public abstract T getValue()
SingleValue, this is the wrapped object.
For ArrayValue, this returns the array itself. For Record, this returns the record itself.null if this node holds a null valuepublic abstract String getValueAsString()
"null" if the value is nullpublic boolean isNull()
true if this node contains a null value. In concrete terms, only Field and SingleValue can contain nulls while not
being null themselves. Both Record and ArrayValue will return false even if they have no values or null only values.
Returns true if getValue() returns null.
public boolean isNotNull()
true if this node does not contain a null value. In concrete terms, only Field and SingleValue can contain nulls
while not being null themselves. Both Record and ArrayValue will return true even if they have no values or null only
values.
Returns true if getValue() does not return null.
public abstract long getSizeInBytes()
public static SingleValue nullValue()
SingleValuepublic static SingleValue nullValue(FieldType type)
type - the field type to assign to the null valueSingleValue of the given typepublic static ValueNode<?> from(Object value)
ValueNode subtype. The conversion rules are:
null returns a null-valued SingleValue with an FieldType.UNDEFINED typeValueNode instances are returned as-isIterable instances are wrapped in an ArrayValuebyte[]) are wrapped in an ArrayValueSingleValuevalue - the object to convert, may be nullValueNode, never nullfrom(FieldType, Object)public static ValueNode<?> from(FieldType type, Object value)
ValueNode subtype with an explicit FieldType hint. The hint can be null to rely on automatic type detection.
The conversion rules are:
null returns a null-valued SingleValue of the given typeValueNode instances are returned as-isIterable instances are wrapped in an ArrayValue with the given default typebyte[]) are wrapped in an ArrayValue with the given default typeMoment, InputStream, Reader, LocalDateTime, LocalDate,
LocalTime, and Instant values are converted before being wrapped in a SingleValueSingleValuetype - the explicit field type hint, or null to infer the typevalue - the object to convert, may be nullValueNode, never nullDataException - if the value cannot be convertedpublic static ArrayValue asArray(FieldType type, Object value)
ArrayValue. If the value is already an ArrayValue, it is returned
as-is. If it is a different ValueNode, its underlying value is extracted first. A null value
produces a single-element array containing a typed null.type - the default field type for the resulting arrayvalue - the value to wrap, may be nullArrayValue containing the given valuepublic SingleValue asSingleValue()
SingleValue. This is a convenience method that avoids explicit casting
in client code.SingleValueClassCastException - if this value node is not a SingleValueisSingleValue()public Record asRecord()
Record. This is a convenience method that avoids explicit casting
in client code.RecordClassCastException - if this value node is not a RecordisRecord()public ArrayValue asArrayValue()
ArrayValue. This is a convenience method that avoids explicit casting
in client code.ArrayValueClassCastException - if this value node is not an ArrayValueisArray()public abstract String toJson()
public abstract String toXml()
Copyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.