public final class Field extends Node implements ValueNodeContainer, Comparable<Field>, Serializable
FieldType)SingleValue,
Record,
ArrayValue,
FieldType,
Serialized FormNode.DuplicateNodeAction, Node.NodeTypeSession.SessionImpl| Modifier and Type | Field and Description |
|---|---|
static int |
JAVA_ARRAY_SIZE |
static int |
JAVA_OBJECT_SIZE |
static int |
MAX_DISPLAY_STRING |
| Modifier | Constructor and Description |
|---|---|
protected |
Field(Record record) |
| Modifier and Type | Method and Description |
|---|---|
Field |
addNull(FieldType type)
Adds a typed
null value to this container. |
Field |
addValue(FieldType type,
Object value)
Adds a value to this field, converting the value to the appropriate type if necessary.
|
Field |
addValue(Object value)
Adds a value to this container, inferring the
FieldType from the value's class. |
int |
compareTo(Field field)
Compares this field to another by their values using natural ordering.
|
int |
compareTo(Field field,
Collator collator)
Compares this field to another by their values, optionally using the specified
Collator
for string comparisons. |
Field |
copyFrom(Field field)
Copies all properties (name, value, and session properties) from the specified field into this one.
|
Field |
copyFrom(Field field,
boolean copyName)
Copies properties from the specified field into this one.
|
boolean |
equals(Object o)
Indicates whether the given object is a
Field with an equal value. |
boolean |
equals(Object o,
Collator collator)
|
Field |
forceValueAsArray()
Converts this field's value to an array if it's not already one, otherwise no change is made.
|
int |
getIndex()
Returns the position of this field within its record.
|
String |
getName()
Returns this field's name.
|
String |
getName(boolean nullToDefaultName)
Returns this field's name.
|
Node.NodeType |
getNodeType()
Returns the concrete
Node.NodeType of this node. |
Node |
getParentNode()
Returns the parent node that this node belongs to, or
null if this is a root node. |
Record |
getParentRecord()
Returns the closest parent record that this node is the child of, otherwise null if one does not exist.
|
Record |
getRecord()
Returns the record this field belongs to.
|
long |
getSizeInBytes()
Returns the estimated size of this field in bytes, including object overhead and value size.
|
long |
getSizeOfNameInBytes()
Returns the estimated size of this field's name in bytes, including object overhead.
|
FieldType |
getType()
Returns the
FieldType of this field's value. |
Object |
getValue()
Returns the raw value held by this field, or
null if the field has no value or is null. |
ArrayValue |
getValueAsArray()
Retrieve the field's value as an
ArrayValue. |
ArrayValue |
getValueAsArray(boolean force)
Retrieve the field's value as an
ArrayValue. |
BigDecimal |
getValueAsBigDecimal()
Returns this field's value as a
BigDecimal. |
BigInteger |
getValueAsBigInteger()
Returns this field's value as a
BigInteger. |
boolean |
getValueAsBoolean()
Returns this field's value as a
boolean. |
byte |
getValueAsByte()
Returns this field's value as a
byte. |
byte[] |
getValueAsBytes()
Returns this field's value as a
byte[]. |
char |
getValueAsChar()
Returns this field's value as a
char. |
Date |
getValueAsDate()
Returns this field's value as a
Date. |
Date |
getValueAsDatetime()
Returns this field's value as a
Date (datetime). |
double |
getValueAsDouble()
Returns this field's value as a
double. |
float |
getValueAsFloat()
Returns this field's value as a
float. |
Instant |
getValueAsInstant()
Returns this field's value as an
Instant. |
int |
getValueAsInteger()
Returns this field's value as an
int. |
<T> List<T> |
getValueAsList(boolean force,
Class<T> elementType)
Retrieve the field's value as a
List. |
LocalDate |
getValueAsLocalDate()
Returns this field's value as a
LocalDate. |
LocalDateTime |
getValueAsLocalDateTime()
Returns this field's value as a
LocalDateTime. |
LocalTime |
getValueAsLocalTime()
Returns this field's value as a
LocalTime. |
long |
getValueAsLong()
Returns this field's value as a
long. |
Record |
getValueAsRecord()
Returns this field's value cast to a
Record. |
short |
getValueAsShort()
Returns this field's value as a
short. |
SingleValue |
getValueAsSingleValue()
Returns this field's value cast to a
SingleValue. |
String |
getValueAsString()
Returns this field's value as a
String. |
Time |
getValueAsTime()
Returns this field's value as a
Time. |
UUID |
getValueAsUuid()
Returns this field's value as a
UUID. |
ValueNode<?> |
getValueNode()
Returns the
ValueNode backing this field's value, or null if no value has been set. |
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 this field's value.
|
boolean |
hasValue()
Returns
true if this field has been set to a value, including null. |
boolean |
isArray()
Returns
true if this field's value is an ArrayValue. |
boolean |
isNotArray()
Returns
true if this field's value is not an ArrayValue. |
boolean |
isNotNull()
Returns
true if this node does not contain a null value. |
boolean |
isNotRecord()
Returns
true if this field's value is not a Record. |
boolean |
isNotSingleValue()
Returns
true if this field's value is not a SingleValue. |
boolean |
isNull()
Returns
true if this node contains a null value. |
boolean |
isRecord()
Returns
true if this field's value is a Record. |
boolean |
isSingleValue()
Returns
true if this field's value is a SingleValue. |
boolean |
isValueNotSet()
Returns
true if this field has never had a value assigned. |
boolean |
isValueSet()
Returns
true if this field has had a value assigned (including a null value). |
boolean |
remove()
Removes this field from its parent record.
|
protected void |
removeChildNode(Node child) |
Field |
setName(String name)
Sets the name of this field.
|
Field |
setNull(FieldType type) |
Field |
setValue(BigDecimal value)
Sets this field's value to the specified
BigDecimal. |
Field |
setValue(BigInteger value)
Sets this field's value to the specified
BigInteger. |
Field |
setValue(boolean value)
Sets this field's value to the specified boolean.
|
Field |
setValue(byte value)
Sets this field's value to the specified byte.
|
Field |
setValue(byte[] value)
Sets this field's value to the specified byte array (blob).
|
Field |
setValue(char value)
Sets this field's value to the specified character.
|
Field |
setValue(Date value)
Sets this field's value to the specified datetime.
|
Field |
setValue(Date value)
Sets this field's value to the specified date.
|
Field |
setValue(double value)
Sets this field's value to the specified double.
|
Field |
setValue(float value)
Sets this field's value to the specified float.
|
Field |
setValue(Instant value)
|
Field |
setValue(int value)
Sets this field's value to the specified integer.
|
Field |
setValue(LocalDate value)
|
Field |
setValue(LocalDateTime value)
Sets this field's value to the specified
LocalDateTime, converting it to a Date
using the system default time zone. |
Field |
setValue(LocalTime value)
|
Field |
setValue(long value)
Sets this field's value to the specified long.
|
Field |
setValue(Object value)
Sets this field's value, inferring the
FieldType from the value's class. |
Field |
setValue(Record value)
Sets this field's value to the specified
Record. |
Field |
setValue(short value)
Sets this field's value to the specified short.
|
Field |
setValue(String value)
Sets this field's value to the specified string.
|
Field |
setValue(Time value)
Sets this field's value to the specified time.
|
Field |
setValue(UUID value)
Sets this field's value to the specified
UUID. |
String |
toString()
Returns a human-readable string representation of this field, including its name, type, and value.
|
assertNotAncestorOf, containsSessionProperty, containsSessionProperty, containsSessionProperty, copySessionPropertiesFrom, getNodeDepth, getParentField, getSessionProperty, getSessionProperty, getSessionProperty, isAncestorOf, isChildNode, isValueNode, keySet, removeSessionProperties, setSessionProperty, setSessionProperty, setSessionPropertypublic static final int MAX_DISPLAY_STRING
public static final int JAVA_OBJECT_SIZE
public static final int JAVA_ARRAY_SIZE
protected Field(Record record)
public Node.NodeType getNodeType()
Node.NodeType of this node.getNodeType in class NodeNodeType#FIELDpublic boolean hasChildNodes()
true if this node contains any sub nodes.
Returns true if this field has a non-null value that itself contains child nodes.
hasChildNodes in class Nodepublic boolean hasChildRecords()
true if this node contains any descendant, record nodes.
Returns true if this field's value is a Record or contains descendant records.
hasChildRecords in class Nodeprotected void removeChildNode(Node child)
removeChildNode in class Nodepublic Field copyFrom(Field field)
field - the source field to copy frompublic Field copyFrom(Field field, boolean copyName)
copyName is true,
the name is also copied; otherwise only the value and session properties are copied.field - the source field to copy fromcopyName - true to copy the field name as wellpublic String toString()
public boolean remove()
true if the record contained this field (i.e. the field hadn't already been removed).public int getIndex()
public String getName()
nullpublic String getName(boolean nullToDefaultName)
nullToDefaultName is true and the name has not been
explicitly set, a default name is generated based on the field's position. If false,
null may be returned when no name has been set.nullToDefaultName - whether to generate a default name when none has been setnull if no name is set and nullToDefaultName is falsepublic Field setName(String name)
name - the new field namepublic FieldType getType()
FieldType of this field's value. If no value has been set, returns FieldType.STRING
as the default.public boolean isArray()
true if this field's value is an ArrayValue.true if the value is an arraypublic boolean isNotArray()
true if this field's value is not an ArrayValue.true if the value is not an arraypublic boolean isRecord()
true if this field's value is a Record.true if the value is a recordpublic boolean isSingleValue()
true if this field's value is a SingleValue.true if the value is a single valuepublic boolean isNotSingleValue()
true if this field's value is not a SingleValue.true if the value is not a single valuepublic boolean isNotRecord()
true if this field's value is not a Record.true if the value is not a recordpublic Field forceValueAsArray()
public boolean isValueSet()
true if this field has had a value assigned (including a null value).
A field that has never been assigned returns false.true if a value has been setpublic boolean isValueNotSet()
true if this field has never had a value assigned.true if no value has been setpublic boolean hasValue()
true if this field has been set to a value, including null.
Otherwise, it returns false.
This method is an alias for isValueSet().hasValue in interface ValueNodeContainerpublic boolean isNull()
Nodetrue 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.public boolean isNotNull()
Nodetrue 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.public Field addValue(FieldType type, Object value)
addValue in interface ValueNodeContainertype - the expected type of the valuevalue - the value to addpublic Field setValue(Object value)
FieldType from the value's class.value - the value to set, may be nullpublic Field addValue(Object value)
FieldType from the value's class.addValue in interface ValueNodeContainervalue - the value to add, may be nullpublic Field addNull(FieldType type)
ValueNodeContainernull value to this container.addNull in interface ValueNodeContainertype - the field type of the null value to addpublic int compareTo(Field field)
compareTo in interface Comparable<Field>field - the other field to compare topublic int compareTo(Field field, Collator collator)
Collator
for string comparisons.field - the other field to compare tocollator - the collator for string comparisons, or null for natural orderingpublic boolean equals(Object o)
Field with an equal value.public boolean equals(Object o, Collator collator)
Field with an equal value,
using the specified Collator for string comparisons.o - the object to compare withcollator - the collator for string comparisons, or null for natural orderingtrue if the objects are equalpublic int hashCode()
public long getSizeOfNameInBytes()
public long getSizeInBytes()
public Record getRecord()
public Record getParentRecord()
NodegetParentRecord in class NodeNode.getParentField(),
Node.isChildNode(),
Node.hasChildRecords(),
Node.getNodeDepth(),
getValueAsRecord(),
Field#getValueAsRecords()public Node getParentNode()
Nodenull if this is a root node.getParentNode in class Nodenullpublic Object getValue()
null if the field has no value or is null.nullpublic ValueNode<?> getValueNode()
ValueNode backing this field's value, or null if no value has been set.nullpublic ArrayValue getValueAsArray()
ArrayValue.public ArrayValue getValueAsArray(boolean force)
ArrayValue. An exception will be thrown when typecasting if the value is not an ArrayValue.public <T> List<T> getValueAsList(boolean force, Class<T> elementType)
List.T - The list's parameterized element typeforce - indicates if a field containing a single value should be forced to become an ArrayValue of one element, otherwise, an exception will be thrown when the typecast to ArrayValue fails.elementType - the target Class of the list's elements. This is used internally to coerce the actual value into this desired type.public Record getValueAsRecord()
Record.ClassCastException - if the value is not a Recordpublic SingleValue getValueAsSingleValue()
SingleValue.ClassCastException - if the value is not a SingleValuepublic String getValueAsString()
String.null if the value is nullpublic Date getValueAsDatetime()
Date (datetime).null if the value is nullpublic Date getValueAsDate()
Date.null if the value is nullpublic Time getValueAsTime()
Time.null if the value is nullpublic int getValueAsInteger()
int.NullPointerException - if the value is nullpublic long getValueAsLong()
long.NullPointerException - if the value is nullpublic short getValueAsShort()
short.NullPointerException - if the value is nullpublic byte getValueAsByte()
byte.NullPointerException - if the value is nullpublic boolean getValueAsBoolean()
boolean.NullPointerException - if the value is nullpublic char getValueAsChar()
char.NullPointerException - if the value is nullpublic double getValueAsDouble()
double.NullPointerException - if the value is nullpublic float getValueAsFloat()
float.NullPointerException - if the value is nullpublic byte[] getValueAsBytes()
byte[].null if the value is nullpublic BigDecimal getValueAsBigDecimal()
BigDecimal.null if the value is nullpublic BigInteger getValueAsBigInteger()
BigInteger.null if the value is nullpublic Instant getValueAsInstant()
Instant.null if the value is nullpublic LocalDateTime getValueAsLocalDateTime()
LocalDateTime.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 nullpublic Field setValue(String value)
value - the string value, may be nullpublic Field setValue(Date value)
value - the datetime value, may be nullpublic Field setValue(Date value)
value - the date value, may be nullpublic Field setValue(Time value)
value - the time value, may be nullpublic Field setValue(int value)
value - the integer valuepublic Field setValue(long value)
value - the long valuepublic Field setValue(short value)
value - the short valuepublic Field setValue(byte value)
value - the byte valuepublic Field setValue(boolean value)
value - the boolean valuepublic Field setValue(char value)
value - the character valuepublic Field setValue(double value)
value - the double valuepublic Field setValue(float value)
value - the float valuepublic Field setValue(byte[] value)
value - the byte array value, may be nullpublic Field setValue(BigDecimal value)
BigDecimal.value - the big decimal value, may be nullpublic Field setValue(BigInteger value)
BigInteger.value - the big integer value, may be nullpublic Field setValue(Record value)
Record.value - the record value, may be nullpublic Field setValue(Instant value)
value - the instant value, may be nullpublic Field setValue(LocalDateTime value)
LocalDateTime, converting it to a Date
using the system default time zone.value - the local date-time value, may be nullpublic Field setValue(LocalDate value)
value - the local date value, may be nullpublic Field setValue(LocalTime value)
value - the local time value, may be nullCopyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.