public final class Record extends ValueNode<Record> implements RecordContainer, Cloneable, Serializable, Iterable<Field>
FieldType)SingleValue,
ArrayValue,
Field,
FieldType,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
Record.State
Lists the lifecycle states of a record as it flows through the pipeline.
|
Node.DuplicateNodeAction, Node.NodeTypeSession.SessionImpl| Constructor and Description |
|---|
Record()
Creates a new empty record with no fields.
|
Record(FieldList fieldNames)
Creates a new record with the specified field names.
|
Record(Record record)
Creates a new record by copying the fields from another.
|
Record(String... fieldNames)
Creates a new record with the specified field names.
|
| Modifier and Type | Method and Description |
|---|---|
Field |
addField()
Adds a new, unnamed field to this record and returns it for further configuration.
|
Field |
addField(String fieldName,
Object value)
Adds a new field with the specified value to this record.
|
Field |
addField(String fieldName,
Object value,
boolean arrayField)
Adds a new field with the specified value to this record.
|
Record |
clone()
Returns a deep copy of this value node.
|
int |
compareTo(Record o)
Compares this record to another using the default
RecordComparator. |
int |
compareTo(Record o,
RecordComparator comparator)
Compares this record to another using the specified
RecordComparator, or the default if null. |
int |
compareTo(ValueNode<Record> o)
Compares this record to another value node by delegating to
compareTo(Record). |
boolean |
contains(FieldPath path)
Deprecated.
|
boolean |
containsField(FieldList fieldNamePath)
Returns true if all fields and sub fields in a nested path exists.
|
boolean |
containsField(FieldPath path)
Indicates if this record contains a matching field for the specified path.
|
boolean |
containsField(String fieldName)
Returns
true if this record contains a field with the given name. |
boolean |
containsNonNull(FieldPath path)
Deprecated.
|
boolean |
containsNonNullField(FieldPath path)
Indicates if this record contains a field at the specified path that is not null.
|
boolean |
containsNonNullField(String fieldPathExpression)
Indicates if this record contains a field at the specified path with a non-null value.
|
boolean |
containsNonNullValue(FieldPath path)
Indicates if this record contains a field or value at the specified path where the value is not null.
|
boolean |
containsValue(FieldPath path)
Indicates if this record contains a matching field or value for the specified path.
|
Record |
copyFrom(Record record)
Copy all the fields and child fields from the specified record into this one, creating new unique fields when target fields with the same name already exists (
DuplicateNodeAction#APPEND). |
Record |
copyFrom(Record record,
boolean overwriteFields)
Copy all the fields and child fields from the specified record into this one.
|
Record |
copyFrom(Record sourceRecord,
Node.DuplicateNodeAction fieldExistsAction)
Copy all the fields and child fields from the specified record into this one.
|
void |
delete()
Marks this record as
Record.State.DELETED. |
void |
ensureFields(Collection<String> fieldNames)
Ensures that all specified field names exist in this record, creating any missing ones.
|
void |
ensureFields(String... fieldNames)
Ensures that all specified field names exist in this record, creating any missing ones.
|
boolean |
equals(Object o)
Indicates whether the given object is a
Record with equal fields. |
boolean |
equals(Record o,
RecordComparator comparator)
Indicates whether this record is equal to another using the specified
RecordComparator. |
<T> T |
evaluate(String expressionString)
Evaluates the given expression string against this record and returns the result.
|
Record |
excludeFields(FieldList fields)
Removes all fields whose names appear in the given list.
|
Record |
excludeFields(Iterable<FieldPath> fieldPaths)
Removes all fields matching the given
FieldPath iterable that exist in this record. |
Record |
excludeFields(Set<String> fields)
Removes all fields whose names appear in the given set.
|
void |
forEach(Consumer<? super Field> consumer)
Performs the given action for each field in this list.
|
static <T extends ValueNode<?>> |
fromBinary(byte[] bytes)
Deserializes a record or array from a binary byte array.
|
static <T extends ValueNode<?>> |
fromBinary(DataInput input)
Deserializes a record or array from a binary data input.
|
static <T extends ValueNode<?>> |
fromBinary(InputStream inputStream)
Deserializes a record or array from a binary input stream.
|
static <T extends ValueNode<?>> |
fromJson(Reader reader)
Deserializes a record or array from a JSON reader.
|
static <T extends ValueNode<?>> |
fromJson(String json)
Deserializes a record or array from a JSON string.
|
static <T extends ValueNode<?>> |
fromXml(Reader reader)
Deserializes a record or array from an XML reader.
|
static <T extends ValueNode<?>> |
fromXml(String xml)
Deserializes a record or array from an XML string.
|
long |
getCreatedOn()
Returns the time in milliseconds when this record was created.
|
Field |
getField(FieldList fieldNamePath,
boolean createField)
Retrieves a nested child field.
|
Field |
getField(FieldPath path)
Returns the field at the specified
FieldPath. |
Field |
getField(FieldPath path,
boolean createField)
Returns the field at the specified
FieldPath, optionally creating intermediate fields. |
Field |
getField(FieldPath path,
boolean createField,
boolean throwException)
Returns the field at the specified
FieldPath, optionally creating intermediate fields. |
Field |
getField(int index)
Returns the field at the specified index (for zero or positive indexes) or from the end of the list (for negative indexes by adding index to the size of the list).
|
Field |
getField(int index,
boolean createField)
Returns the field at the specified index, creating new fields as needed if
createField is true. |
Field |
getField(String fieldName)
Returns the first field with the given name or throws an exception if none are found.
|
Field |
getField(String fieldName,
boolean createField)
Returns the first field with the given name.
|
int |
getFieldCount()
Returns the number of fields in this record.
|
FieldList |
getFieldNameList()
Returns a
FieldList containing the names of all fields in this record. |
List<String> |
getFieldNames()
Returns a list of the field names in this record in order.
|
Field |
getFieldOrNull(String fieldName)
Returns the first field with the given name or null if none are found.
|
ArrayList<Field> |
getFields()
Returns a new collection of the fields in this record.
|
List<FieldType> |
getFieldTypes()
Returns the field types for all fields in this record.
|
List<FieldType> |
getFieldTypes(FieldList fieldList)
Returns the field types for the fields matching the given
FieldList, or all fields if the list is null or empty. |
<T> T |
getFieldValue(FieldPath fieldPath,
T defaultValue)
Gets the value at the specified field path, returning a default value if the field is null or not found.
|
<T> T |
getFieldValue(String fieldPath,
T defaultValue) |
ArrayValue |
getFieldValueAsArray(String fieldPath,
ArrayValue defaultValue)
Returns the field's value as array if the field exists and its value is not null, otherwise, it returns the default value.
|
BigDecimal |
getFieldValueAsBigDecimal(String fieldPath,
BigDecimal defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
BigInteger |
getFieldValueAsBigInteger(String fieldPath,
BigInteger defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Boolean |
getFieldValueAsBoolean(String fieldPath,
Boolean defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Byte |
getFieldValueAsByte(String fieldPath,
Byte defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
byte[] |
getFieldValueAsBytes(String fieldPath,
byte[] defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Character |
getFieldValueAsChar(String fieldPath,
Character defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Date |
getFieldValueAsDate(String fieldPath,
Date defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Date |
getFieldValueAsDatetime(String fieldPath,
Date defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Double |
getFieldValueAsDouble(String fieldPath,
Double defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Float |
getFieldValueAsFloat(String fieldPath,
Float defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Instant |
getFieldValueAsInstant(String fieldPath,
Instant defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Integer |
getFieldValueAsInteger(String fieldPath,
Integer defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
<T> List<T> |
getFieldValueAsList(String fieldPath,
List<T> defaultValue,
Class<T> elementType)
Returns the field's value as a
List if the field exists and its value is not null, otherwise, it returns the default value (even if the list contains no values). |
LocalDate |
getFieldValueAsLocalDate(String fieldPath,
LocalDate defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
LocalDateTime |
getFieldValueAsLocalDatetime(String fieldPath,
LocalDateTime defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
LocalTime |
getFieldValueAsLocalTime(String fieldPath,
LocalTime defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Long |
getFieldValueAsLong(String fieldPath,
Long defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Record |
getFieldValueAsRecord(String fieldPath,
Record defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Short |
getFieldValueAsShort(String fieldPath,
Short defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
String |
getFieldValueAsString(String fieldPath,
String defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Time |
getFieldValueAsTime(String fieldPath,
Time defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
UUID |
getFieldValueAsUUID(String fieldPath,
UUID defaultValue)
Returns the field's value if the field exists and its value is not null, otherwise, it returns the default value.
|
Node.NodeType |
getNodeType()
Returns the concrete
Node.NodeType of this node. |
Record |
getRecord()
Returns the
Record associated with this container. |
SingleValue |
getSingleValue(FieldPath path,
boolean createField,
boolean throwException)
Returns the
SingleValue at the specified FieldPath, optionally creating intermediate fields. |
long |
getSizeInBytes()
Returns the estimated size of this value node in bytes, including object overhead.
|
long |
getSizeInBytesOfFieldNames()
Returns the estimated total size of all field names in bytes, including object overhead.
|
Record.State |
getState()
Returns the current lifecycle state of this record.
|
FieldType |
getType()
Returns the
FieldType of this value node. |
Record |
getValue()
Returns the underlying value held by this node.
|
ValueNode<?> |
getValue(FieldPath path)
Returns the value node at the specified
FieldPath. |
ValueNode<?> |
getValue(FieldPath path,
boolean createField)
Returns the value node at the specified
FieldPath, optionally creating intermediate fields. |
ValueNode<?> |
getValue(FieldPath path,
boolean createField,
boolean throwException)
Returns the value node at the specified
FieldPath, optionally creating intermediate fields. |
String |
getValueAsString()
Returns a string representation of the value held by this node.
|
List<?> |
getValues()
Returns all the field values in this record as a
List. |
List<?> |
getValues(FieldList fieldList)
Returns the field values in this record as a
List for the fields matching the supplied FieldList. |
ArrayValue |
getValuesAsArray()
Returns all the field values in this record as an
ArrayValue. |
boolean |
hasArrayFields()
Returns
true if any field in this record contains an ArrayValue. |
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 all fields in this record.
|
int |
hashCode(FieldList fieldList)
Returns a hash code based on the fields matching the given
FieldList, or all fields if null. |
protected int |
indexOfField(Field field) |
int |
indexOfField(String fieldName,
boolean throwExceptionOnFailure)
Returns the index of the first field with the given name, or
-1 if not found. |
boolean |
isDeleted()
Returns
true if this record has been marked for deletion. |
boolean |
isEmpty()
Returns true if this record has no fields or all field values are null.
|
boolean |
isNotEmpty()
Returns true if this record has at least one non-null field value.
|
boolean |
isRecord()
Returns
true if this value node is a Record. |
Iterator<Field> |
iterator()
Returns an iterator over the fields in this record.
|
void |
moveField(int oldIndex,
int newIndex)
Moves a field from one position to another within this record.
|
void |
moveField(String fieldName,
int newIndex)
Moves the field with the specified name to a new position within this record.
|
void |
moveFieldAfter(FieldPath fieldPath,
FieldPath afterFieldPath)
Moves the field at the specified path to the position immediately after another field path.
|
void |
moveFieldAfter(String fieldName,
String afterFieldName)
Moves the named field to the position immediately after another named field.
|
void |
moveFieldBefore(FieldPath fieldPath,
FieldPath beforeFieldPath)
Moves the field at the specified path to the position immediately before another field path.
|
void |
moveFieldBefore(String fieldName,
String beforeFieldName)
Moves the named field to the position immediately before another named field.
|
Stream<Field> |
parallelStream()
Returns a parallel Stream of the fields in this record.
|
protected void |
removeChildNode(Node child) |
protected boolean |
removeField(Field field) |
Field |
removeField(FieldList fieldNamePath)
Removes a sub-field matching the specified path.
|
Field |
removeField(FieldPath fieldPath)
Deletes the field at the specified path or throws an exception if it doesn't exist.
|
Field |
removeField(int index)
Removes and returns the field at the specified index.
|
Field |
removeField(String columnName)
Removes and returns the field with the specified name.
|
Record |
removeFields(Collection<FieldPath> fieldPaths)
Removes all fields matching the given collection of
FieldPath expressions. |
Record |
selectFields(FieldList fields)
Retains only the fields specified in the given list, removing all others and reordering
to match the list's order.
|
Record |
selectFields(FieldList fields,
boolean lenient)
Retains only the fields specified in the given list, removing all others.
|
void |
setAlive()
Resets this record's state to
Record.State.ALIVE. |
Record |
setField(FieldPath fieldPath,
boolean createField,
boolean throwException,
Object value)
Sets the value at the specified
FieldPath. |
Record |
setField(FieldPath fieldPath,
Object value)
Sets the value at the specified
FieldPath, creating intermediate fields as needed. |
Record |
setField(String fieldName,
Object value)
Sets the value of the field with the given name, creating the field if necessary.
|
Record |
setFieldNull(FieldPath fieldPath,
FieldType type)
Sets the field at the specified
FieldPath to a typed null value, creating intermediate fields as needed. |
Record |
setFieldNull(String fieldName,
FieldType type)
Sets the field with the given name to a typed
null value, creating the field if necessary. |
protected Record |
setParentNode(Node parentNode)
Sets the parent node of this value node.
|
Record |
sortFieldsByName()
Sorts the fields in this record alphabetically by name.
|
Stream<Field> |
stream()
Returns a sequential Stream of the fields in this record.
|
byte[] |
toBinary()
Serializes this record to a binary byte array.
|
static byte[] |
toBinary(ValueNode<?> recordOrArray)
Serializes the given record or array to a binary byte array.
|
static void |
toBinary(ValueNode<?> recordOrArray,
DataOutput output)
Serializes the given record or array as binary data to the specified data output.
|
static void |
toBinary(ValueNode<?> recordOrArray,
OutputStream outputStream)
Serializes the given record or array as binary data to the specified output stream.
|
String |
toJson()
Serializes this record to a JSON string.
|
String |
toJson(boolean pretty)
Serializes this record to a JSON string, optionally pretty-printed.
|
static String |
toJson(ValueNode<?> recordOrArray)
Serializes the given record or array to a JSON string.
|
static String |
toJson(ValueNode<?> recordOrArray,
boolean pretty)
Serializes the given record or array to a JSON string, optionally pretty-printed.
|
static void |
toJson(ValueNode<?> recordOrArray,
Writer writer)
Serializes the given record or array as JSON to the specified writer.
|
static void |
toJson(ValueNode<?> recordOrArray,
Writer writer,
boolean pretty)
Serializes the given record or array as JSON to the specified writer, optionally pretty-printed.
|
String |
toString()
Returns a human-readable string representation of this node and its contents.
|
String |
toXml()
Serializes this record to an XML string.
|
String |
toXml(boolean writeRootDocument,
boolean pretty)
Serializes this record to an XML string with control over the root document and formatting.
|
static String |
toXml(ValueNode<?> recordOrArray)
Serializes the given record or array to an XML string.
|
static String |
toXml(ValueNode<?> recordOrArray,
boolean writeRootDocument,
boolean pretty)
Serializes the given record or array to an XML string with control over the root document and formatting.
|
static void |
toXml(ValueNode<?> recordOrArray,
Writer writer) |
static void |
toXml(ValueNode<?> recordOrArray,
Writer writer,
boolean writeRootDocument,
boolean pretty) |
asArray, asArrayValue, asRecord, asSingleValue, from, from, getParentNode, isArray, isNotArray, isNotNull, isNotRecord, isNotSingleValue, isNull, isSingleValue, isValueNode, nullValue, nullValueassertNotAncestorOf, containsSessionProperty, containsSessionProperty, containsSessionProperty, copySessionPropertiesFrom, getNodeDepth, getParentField, getParentRecord, getSessionProperty, getSessionProperty, getSessionProperty, isAncestorOf, isChildNode, keySet, removeSessionProperties, setSessionProperty, setSessionProperty, setSessionPropertyfinalize, getClass, notify, notifyAll, wait, wait, waitspliteratorpublic Record(Record record)
record - the record to copy from.public Record()
public Record(String... fieldNames)
fieldNames - public Record(FieldList fieldNames)
fieldNames - public Record getRecord()
Record associated with this container.getRecord in interface RecordContainerpublic 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.getType in class ValueNode<Record>FieldType.RECORDpublic Node.NodeType getNodeType()
Node.NodeType of this node.getNodeType in class NodeNodeType#RECORDpublic boolean hasChildNodes()
true if this node contains any sub nodes.hasChildNodes in class Nodepublic boolean hasChildRecords()
true if this node contains any descendant, record nodes.hasChildRecords in class Nodeprotected void removeChildNode(Node child)
removeChildNode in class Nodepublic boolean isRecord()
isRecord in class ValueNode<Record>true if this is a record, false otherwiseValueNode.asRecord()public boolean hasArrayFields()
true if any field in this record contains an ArrayValue.true if at least one field is an arraypublic Record getValue()
SingleValue, this is the wrapped object.
For ArrayValue, this returns the array itself. For Record, this returns the record itself.
Returns this Record instance (records are self-referencing values).
public String getValueAsString()
getValueAsString in class ValueNode<Record>"null" if the value is nullpublic Record copyFrom(Record sourceRecord, Node.DuplicateNodeAction fieldExistsAction)
sourceRecord - the record to copy from.fieldExistsAction - the action to take if a field with the same name already exists in this record.public Record copyFrom(Record record, boolean overwriteFields)
record - the record to copy from.overwriteFields - indicates if existing target fields should be replaced (DuplicateNodeAction#OVERWRITE)
or a new unique field created (DuplicateNodeAction#APPEND).public Record copyFrom(Record record)
DuplicateNodeAction#APPEND).record - the record to copy from.public Record clone()
ValueNodepublic Record.State getState()
nullpublic boolean isDeleted()
true if this record has been marked for deletion.true if the state is Record.State.DELETEDpublic void setAlive()
Record.State.ALIVE.public void delete()
Record.State.DELETED. Deleted records are typically filtered out
by the pipeline and not written to the output.public long getCreatedOn()
public Field getField(int index)
public Field getField(int index, boolean createField)
createField is true.index - the field indexcreateField - if true, empty fields are appended until the index is validpublic Field getField(String fieldName)
public Field getFieldOrNull(String fieldName)
public Field getField(String fieldName, boolean createField)
createField is true and no matching
field exists, a new field with the specified name is created and returned.fieldName - the field name to look upcreateField - if true, create the field when not foundDataException - if createField is false and no matching field existspublic Field getField(FieldPath path)
FieldPath.path - the path expression identifying the fieldDataException - if the path does not resolve to a fieldpublic Field getField(FieldPath path, boolean createField)
FieldPath, optionally creating intermediate fields.path - the path expression identifying the fieldcreateField - if true, intermediate fields and records are created as neededDataException - if the path does not resolve and createField is falsepublic Field getField(FieldPath path, boolean createField, boolean throwException)
FieldPath, optionally creating intermediate fields.path - the path expression identifying the fieldcreateField - if true, intermediate fields and records are created as neededthrowException - if true, an exception is thrown when the path does not resolvenull if not found and throwException is falsepublic ValueNode<?> getValue(FieldPath path)
FieldPath.path - the path expressionDataException - if the path does not resolvepublic ValueNode<?> getValue(FieldPath path, boolean createField)
FieldPath, optionally creating intermediate fields.path - the path expressioncreateField - if true, intermediate fields and records are created as neededDataException - if the path does not resolve and creation is not requestedpublic ValueNode<?> getValue(FieldPath path, boolean createField, boolean throwException)
FieldPath, optionally creating intermediate fields.path - the path expression identifying the fieldcreateField - if true, intermediate fields and records are created as neededthrowException - if true, an exception is thrown when the path does not resolvenull if not found and throwException is falsepublic SingleValue getSingleValue(FieldPath path, boolean createField, boolean throwException)
SingleValue at the specified FieldPath, optionally creating intermediate fields.path - the path expressioncreateField - if true, intermediate fields and records are created as neededthrowException - if true, an exception is thrown when the path does not resolvenull if not found and throwException is falsepublic Field getField(FieldList fieldNamePath, boolean createField)
createField is true, all missing intermediate records will be created, otherwise an exception will be thrown.
This method will fail if an intermediate field has a non-record, non-null value.public Record setField(String fieldName, Object value)
fieldName - the field namevalue - the value to setpublic Record setField(FieldPath fieldPath, boolean createField, boolean throwException, Object value)
FieldPath.fieldPath - the path expressioncreateField - if true, intermediate fields and records are created as neededthrowException - if true, an exception is thrown when the path does not resolvevalue - the value to setpublic Record setField(FieldPath fieldPath, Object value)
FieldPath, creating intermediate fields as needed.fieldPath - the path expressionvalue - the value to setpublic Record setFieldNull(String fieldName, FieldType type)
null value, creating the field if necessary.fieldName - the field nametype - the field type of the null valuepublic Record setFieldNull(FieldPath fieldPath, FieldType type)
FieldPath to a typed null value, creating intermediate fields as needed.fieldPath - the path expressiontype - the field type of the null valuepublic Field addField(String fieldName, Object value, boolean arrayField)
arrayField determines
if the existing field should be promoted to an array and the new value added to it, otherwise, a unique name is created for the new value by
appending a number to the name starting with 1 until an unused name is found.public Field addField(String fieldName, Object value)
public int getFieldCount()
public Field addField()
public ArrayList<Field> getFields()
public void forEach(Consumer<? super Field> consumer)
public Stream<Field> parallelStream()
public List<String> getFieldNames()
public FieldList getFieldNameList()
FieldList containing the names of all fields in this record.public List<FieldType> getFieldTypes(FieldList fieldList)
FieldList, or all fields if the list is null or empty.fieldList - the fields to include, or null for allpublic List<FieldType> getFieldTypes()
public List<?> getValues(FieldList fieldList)
List for the fields matching the supplied FieldList. This method does not traverse nested records and nested arrays.public List<?> getValues()
List. This method does not traverse nested records and nested arrays.public ArrayValue getValuesAsArray()
ArrayValue. This method does not traverse nested records and nested arrays.protected Record setParentNode(Node parentNode)
ValueNodeDataException.setParentNode in class ValueNode<Record>parentNode - the new parent node, or null to detach from the current parentpublic int compareTo(ValueNode<Record> o)
compareTo(Record).compareTo in interface Comparable<ValueNode<Record>>o - the other value nodepublic int compareTo(Record o)
RecordComparator.o - the other recordpublic int compareTo(Record o, RecordComparator comparator)
RecordComparator, or the default if null.o - the other recordcomparator - the comparator to use, or null for the defaultpublic boolean equals(Object o)
Record with equal fields.public boolean equals(Record o, RecordComparator comparator)
RecordComparator.o - the other recordcomparator - the comparator to use, or null for the defaulttrue if the records are equalpublic int hashCode()
public int hashCode(FieldList fieldList)
FieldList, or all fields if null.fieldList - the fields to include in the hash, or null for allprotected int indexOfField(Field field)
public int indexOfField(String fieldName, boolean throwExceptionOnFailure)
-1 if not found.fieldName - the field name to search forthrowExceptionOnFailure - if true, throws a DataException when the field is not found-1 if not found and throwExceptionOnFailure is falseDataException - if the field is not found and throwExceptionOnFailure is truepublic boolean containsField(String fieldName)
true if this record contains a field with the given name.fieldName - the field name to checktrue if the field existspublic boolean containsField(FieldPath path)
city[2] or customer.address[0].city[2]) instead of a field.public boolean containsNonNullField(FieldPath path)
public boolean containsNonNullField(String fieldPathExpression)
FieldPath for supported field name
expressions.public boolean containsField(FieldList fieldNamePath)
@Deprecated public boolean contains(FieldPath path)
containsValue(FieldPath) instead.@Deprecated public boolean containsNonNull(FieldPath path)
containsNonNullValue(FieldPath) instead.public boolean containsValue(FieldPath path)
public boolean containsNonNullValue(FieldPath path)
protected boolean removeField(Field field)
public Field removeField(int index)
index - the index of the field to removeIndexOutOfBoundsException - if the index is out of rangepublic Field removeField(String columnName)
columnName - the name of the field to removeDataException - if no field with the given name existspublic Field removeField(FieldList fieldNamePath)
public Field removeField(FieldPath fieldPath)
fieldPath - public void moveField(int oldIndex,
int newIndex)
oldIndex - the current index of the fieldnewIndex - the desired new indexpublic void moveField(String fieldName, int newIndex)
fieldName - the name of the field to movenewIndex - the desired new indexpublic void moveFieldBefore(String fieldName, String beforeFieldName)
fieldName - the name of the field to movebeforeFieldName - the name of the field to move beforepublic void moveFieldAfter(String fieldName, String afterFieldName)
fieldName - the name of the field to moveafterFieldName - the name of the field to move afterpublic void moveFieldBefore(FieldPath fieldPath, FieldPath beforeFieldPath)
fieldPath - the path of the field to movebeforeFieldPath - the path of the field to move beforepublic void moveFieldAfter(FieldPath fieldPath, FieldPath afterFieldPath)
fieldPath - the path of the field to moveafterFieldPath - the path of the field to move afterpublic Record selectFields(FieldList fields)
selectFields(fields, false).fields - the fields to retainpublic Record selectFields(FieldList fields, boolean lenient)
lenient is
true, missing fields are silently ignored; otherwise an exception is thrown.fields - the fields to retainlenient - if true, silently skip fields not found in this recordpublic Record excludeFields(FieldList fields)
fields - the field names to removepublic Record excludeFields(Set<String> fields)
fields - the field names to removepublic Record excludeFields(Iterable<FieldPath> fieldPaths)
FieldPath iterable that exist in this record.fieldPaths - the field paths to removepublic Record removeFields(Collection<FieldPath> fieldPaths)
FieldPath expressions.fieldPaths - the field paths to removeDataException - if a path does not resolvepublic long getSizeInBytesOfFieldNames()
public long getSizeInBytes()
getSizeInBytes in class ValueNode<Record>public String toString()
public <T> T evaluate(String expressionString)
T - the expected result typeexpressionString - the expression to evaluatepublic String toJson()
public static String toJson(ValueNode<?> recordOrArray)
recordOrArray - the value node to serializepublic static void toJson(ValueNode<?> recordOrArray, Writer writer)
recordOrArray - the value node to serializewriter - the target writerpublic String toJson(boolean pretty)
pretty - if true, the output is indented for readabilitypublic static String toJson(ValueNode<?> recordOrArray, boolean pretty)
recordOrArray - the value node to serializepretty - if true, the output is indented for readabilitypublic static void toJson(ValueNode<?> recordOrArray, Writer writer, boolean pretty)
recordOrArray - the value node to serializewriter - the target writerpretty - if true, the output is indented for readabilitypublic static <T extends ValueNode<?>> T fromJson(String json)
T - the expected return type (Record or ArrayValue)json - the JSON stringDataException - if the JSON cannot be parsedpublic static <T extends ValueNode<?>> T fromJson(Reader reader)
T - the expected return type (Record or ArrayValue)reader - the JSON sourcepublic String toXml()
public static String toXml(ValueNode<?> recordOrArray)
recordOrArray - the value node to serializepublic String toXml(boolean writeRootDocument, boolean pretty)
writeRootDocument - if true, includes the XML declarationpretty - if true, the output is indented for readabilitypublic static String toXml(ValueNode<?> recordOrArray, boolean writeRootDocument, boolean pretty)
recordOrArray - the value node to serializewriteRootDocument - if true, includes the XML declarationpretty - if true, the output is indented for readabilitypublic static void toXml(ValueNode<?> recordOrArray, Writer writer, boolean writeRootDocument, boolean pretty)
public static <T extends ValueNode<?>> T fromXml(String xml)
T - the expected return type (Record or ArrayValue)xml - the XML stringDataException - if the XML cannot be parsedpublic static <T extends ValueNode<?>> T fromXml(Reader reader)
T - the expected return type (Record or ArrayValue)reader - the XML sourcepublic byte[] toBinary()
public static byte[] toBinary(ValueNode<?> recordOrArray)
recordOrArray - the value node to serializepublic static void toBinary(ValueNode<?> recordOrArray, OutputStream outputStream)
recordOrArray - the value node to serializeoutputStream - the target output streampublic static void toBinary(ValueNode<?> recordOrArray, DataOutput output)
recordOrArray - the value node to serializeoutput - the target data outputpublic static <T extends ValueNode<?>> T fromBinary(byte[] bytes)
T - the expected return type (Record or ArrayValue)bytes - the binary datanull if the data is emptyDataException - if the binary data cannot be parsedpublic static <T extends ValueNode<?>> T fromBinary(InputStream inputStream)
T - the expected return type (Record or ArrayValue)inputStream - the binary sourcepublic static <T extends ValueNode<?>> T fromBinary(DataInput input)
T - the expected return type (Record or ArrayValue)input - the binary sourcenull if no records were readDataException - if the binary data cannot be parsedpublic boolean isEmpty()
public boolean isNotEmpty()
public String getFieldValueAsString(String fieldPath, String defaultValue)
FieldPath for supported fieldPath expressions.public Date getFieldValueAsDatetime(String fieldPath, Date defaultValue)
FieldPath for supported fieldPath expressions.public Date getFieldValueAsDate(String fieldPath, Date defaultValue)
FieldPath for supported fieldPath expressions.public Time getFieldValueAsTime(String fieldPath, Time defaultValue)
FieldPath for supported fieldPath expressions.public Integer getFieldValueAsInteger(String fieldPath, Integer defaultValue)
FieldPath for supported fieldPath expressions.public Long getFieldValueAsLong(String fieldPath, Long defaultValue)
FieldPath for supported fieldPath expressions.public Short getFieldValueAsShort(String fieldPath, Short defaultValue)
FieldPath for supported fieldPath expressions.public Byte getFieldValueAsByte(String fieldPath, Byte defaultValue)
FieldPath for supported fieldPath expressions.public byte[] getFieldValueAsBytes(String fieldPath, byte[] defaultValue)
FieldPath for supported fieldPath expressions.public Boolean getFieldValueAsBoolean(String fieldPath, Boolean defaultValue)
FieldPath for supported fieldPath expressions.public Character getFieldValueAsChar(String fieldPath, Character defaultValue)
FieldPath for supported fieldPath expressions.public Double getFieldValueAsDouble(String fieldPath, Double defaultValue)
FieldPath for supported fieldPath expressions.public Float getFieldValueAsFloat(String fieldPath, Float defaultValue)
FieldPath for supported fieldPath expressions.public BigDecimal getFieldValueAsBigDecimal(String fieldPath, BigDecimal defaultValue)
FieldPath for supported fieldPath expressions.public BigInteger getFieldValueAsBigInteger(String fieldPath, BigInteger defaultValue)
FieldPath for supported fieldPath expressions.public Record getFieldValueAsRecord(String fieldPath, Record defaultValue)
FieldPath for supported fieldPath expressions.public ArrayValue getFieldValueAsArray(String fieldPath, ArrayValue defaultValue)
FieldPath for supported fieldPath expressions.public <T> List<T> getFieldValueAsList(String fieldPath, List<T> defaultValue, Class<T> elementType)
public Instant getFieldValueAsInstant(String fieldPath, Instant defaultValue)
FieldPath for supported fieldPath expressions.public LocalDateTime getFieldValueAsLocalDatetime(String fieldPath, LocalDateTime defaultValue)
FieldPath for supported fieldPath expressions.public LocalDate getFieldValueAsLocalDate(String fieldPath, LocalDate defaultValue)
FieldPath for supported fieldPath expressions.public LocalTime getFieldValueAsLocalTime(String fieldPath, LocalTime defaultValue)
FieldPath for supported fieldPath expressions.public UUID getFieldValueAsUUID(String fieldPath, UUID defaultValue)
FieldPath for supported fieldPath expressions.public <T> T getFieldValue(String fieldPath, T defaultValue)
public <T> T getFieldValue(FieldPath fieldPath, T defaultValue)
T - the expected type of the valuefieldPath - the path to the fielddefaultValue - the value to return if the field is null or not foundpublic void ensureFields(String... fieldNames)
fieldNames - the field names to ensure existpublic void ensureFields(Collection<String> fieldNames)
fieldNames - the collection of field names to ensure existpublic Record sortFieldsByName()
Copyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.