public final class Record extends ValueNode<Record> implements RecordContainer, Cloneable, Serializable, Iterable<Field>
FieldType
)SingleValue
,
ArrayValue
,
Field
,
FieldType
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
Record.State |
Node.DuplicateNodeAction, Node.NodeType
Session.SessionImpl
Constructor and Description |
---|
Record() |
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() |
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() |
int |
compareTo(Record o) |
int |
compareTo(Record o,
RecordComparator comparator) |
int |
compareTo(ValueNode<Record> o) |
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) |
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() |
void |
ensureFields(Collection<String> fieldNames) |
void |
ensureFields(String... fieldNames) |
boolean |
equals(Object o) |
boolean |
equals(Record o,
RecordComparator comparator) |
<T> T |
evaluate(String expressionString) |
Record |
excludeFields(FieldList fields) |
Record |
excludeFields(Iterable<FieldPath> fieldPaths) |
Record |
excludeFields(Set<String> fields) |
void |
forEach(Consumer<? super Field> consumer)
Performs the given action for each field in this list.
|
static <T extends ValueNode<?>> |
fromBinary(byte[] bytes) |
static <T extends ValueNode<?>> |
fromBinary(DataInput input) |
static <T extends ValueNode<?>> |
fromBinary(InputStream inputStream) |
static <T extends ValueNode<?>> |
fromJson(Reader reader) |
static <T extends ValueNode<?>> |
fromJson(String json) |
static <T extends ValueNode<?>> |
fromXml(Reader reader) |
static <T extends ValueNode<?>> |
fromXml(String xml) |
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) |
Field |
getField(FieldPath path,
boolean createField) |
Field |
getField(FieldPath path,
boolean createField,
boolean throwException) |
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) |
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) |
int |
getFieldCount() |
FieldList |
getFieldNameList() |
List<String> |
getFieldNames() |
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() |
List<FieldType> |
getFieldTypes(FieldList fieldList) |
<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() |
Record |
getRecord() |
SingleValue |
getSingleValue(FieldPath path,
boolean createField,
boolean throwException) |
long |
getSizeInBytes() |
long |
getSizeInBytesOfFieldNames() |
Record.State |
getState() |
FieldType |
getType() |
Record |
getValue() |
ValueNode<?> |
getValue(FieldPath path) |
ValueNode<?> |
getValue(FieldPath path,
boolean createField) |
ValueNode<?> |
getValue(FieldPath path,
boolean createField,
boolean throwException) |
String |
getValueAsString() |
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() |
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() |
int |
hashCode(FieldList fieldList) |
protected int |
indexOfField(Field field) |
int |
indexOfField(String fieldName,
boolean throwExceptionOnFailure) |
boolean |
isArray() |
boolean |
isDeleted() |
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() |
boolean |
isSingleValue() |
Iterator<Field> |
iterator()
Returns an iterator over the fields in this record.
|
void |
moveField(int oldIndex,
int newIndex) |
void |
moveField(String fieldName,
int newIndex) |
void |
moveFieldAfter(FieldPath fieldPath,
FieldPath afterFieldPath) |
void |
moveFieldAfter(String fieldName,
String afterFieldName) |
void |
moveFieldBefore(FieldPath fieldPath,
FieldPath beforeFieldPath) |
void |
moveFieldBefore(String fieldName,
String beforeFieldName) |
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) |
Field |
removeField(String columnName) |
Record |
removeFields(Collection<FieldPath> fieldPaths) |
Record |
selectFields(FieldList fields) |
Record |
selectFields(FieldList fields,
boolean lenient) |
void |
setAlive() |
Record |
setField(String fieldName,
Object value) |
Record |
setFieldNull(String fieldName,
FieldType type) |
protected Record |
setParentNode(Node parentNode) |
Record |
sortFieldsByName() |
Stream<Field> |
stream()
Returns a sequential Stream of the fields in this record.
|
byte[] |
toBinary() |
static byte[] |
toBinary(ValueNode<?> recordOrArray) |
static void |
toBinary(ValueNode<?> recordOrArray,
DataOutput output) |
static void |
toBinary(ValueNode<?> recordOrArray,
OutputStream outputStream) |
String |
toJson() |
String |
toJson(boolean pretty) |
static String |
toJson(ValueNode<?> recordOrArray) |
static String |
toJson(ValueNode<?> recordOrArray,
boolean pretty) |
static void |
toJson(ValueNode<?> recordOrArray,
Writer writer) |
static void |
toJson(ValueNode<?> recordOrArray,
Writer writer,
boolean pretty) |
String |
toString() |
String |
toXml() |
String |
toXml(boolean writeRootDocument,
boolean pretty) |
static String |
toXml(ValueNode<?> recordOrArray) |
static String |
toXml(ValueNode<?> recordOrArray,
boolean writeRootDocument,
boolean pretty) |
static void |
toXml(ValueNode<?> recordOrArray,
Writer writer) |
static void |
toXml(ValueNode<?> recordOrArray,
Writer writer,
boolean writeRootDocument,
boolean pretty) |
asArray, from, getParentNode, isNotArray, isNotNull, isNotRecord, isNotSingleValue, isNull, isValueNode, nullValue, nullValue
assertNotAncestorOf, containsSessionProperty, containsSessionProperty, containsSessionProperty, copySessionPropertiesFrom, getNodeDepth, getParentField, getParentRecord, getSessionProperty, getSessionProperty, getSessionProperty, isAncestorOf, isChildNode, keySet, setSessionProperty, setSessionProperty, setSessionProperty
finalize, getClass, notify, notifyAll, wait, wait, wait
spliterator
public Record(Record record)
record
- the record to copy from.public Record()
public Record(String... fieldNames)
fieldNames
- public Record(FieldList fieldNames)
fieldNames
- public Record getRecord()
getRecord
in interface RecordContainer
public Node.NodeType getNodeType()
getNodeType
in class Node
public boolean hasChildNodes()
Node
true
if this node contains any sub nodes.hasChildNodes
in class Node
public boolean hasChildRecords()
Node
true
if this node contains any descendant, record nodes.hasChildRecords
in class Node
protected void removeChildNode(Node child)
removeChildNode
in class Node
public boolean isSingleValue()
isSingleValue
in class ValueNode<Record>
public boolean hasArrayFields()
public String getValueAsString()
getValueAsString
in class ValueNode<Record>
public 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.State getState()
public boolean isDeleted()
public void setAlive()
public void delete()
public long getCreatedOn()
public Field getField(int index)
public Field getField(int index, boolean createField)
public Field getField(String fieldName)
public Field getFieldOrNull(String fieldName)
public SingleValue getSingleValue(FieldPath path, boolean createField, boolean throwException)
public 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 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 FieldList getFieldNameList()
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)
setParentNode
in class ValueNode<Record>
public int compareTo(ValueNode<Record> o)
compareTo
in interface Comparable<ValueNode<Record>>
public int compareTo(Record o)
public int compareTo(Record o, RecordComparator comparator)
public boolean equals(Record o, RecordComparator comparator)
public int hashCode(FieldList fieldList)
protected int indexOfField(Field field)
public int indexOfField(String fieldName, boolean throwExceptionOnFailure)
public boolean containsField(String fieldName)
public 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)
public Field removeField(FieldList fieldNamePath)
public Field removeField(FieldPath fieldPath)
fieldPath
- public void moveField(int oldIndex, int newIndex)
public void moveField(String fieldName, int newIndex)
public Record removeFields(Collection<FieldPath> fieldPaths)
public long getSizeInBytesOfFieldNames()
public long getSizeInBytes()
getSizeInBytes
in class ValueNode<Record>
public <T> T evaluate(String expressionString)
public String toJson()
public String toJson(boolean pretty)
public String toXml()
public String toXml(boolean writeRootDocument, boolean pretty)
public static String toXml(ValueNode<?> recordOrArray, boolean writeRootDocument, boolean pretty)
public static void toXml(ValueNode<?> recordOrArray, Writer writer, boolean writeRootDocument, boolean pretty)
public byte[] toBinary()
public static byte[] toBinary(ValueNode<?> recordOrArray)
public static void toBinary(ValueNode<?> recordOrArray, OutputStream outputStream)
public static void toBinary(ValueNode<?> recordOrArray, DataOutput output)
public static <T extends ValueNode<?>> T fromBinary(byte[] bytes)
public static <T extends ValueNode<?>> T fromBinary(InputStream inputStream)
public 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 void ensureFields(String... fieldNames)
public void ensureFields(Collection<String> fieldNames)
public Record sortFieldsByName()
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.