public class DefaultRecord extends LinkedHashMap<Field,Object> implements Record
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
DefaultRecord(Object source,
URI resource,
long position)
Creates an empty record.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
Set<Field> |
fields()
Returns a set containing all the fields in this record.
|
Object |
getFieldValue(Field field)
Returns the value associated with the given field.
|
long |
getPosition()
Returns the record's position inside its resource, typically the
line number if the resource is a file, or the row number, if the resource is a database table.
|
URI |
getResource()
Returns the record's resource location, typically the file or database table where it was
extracted from.
|
Object |
getSource()
Returns the record source, typically a line in a file or a row in a database table.
|
int |
hashCode() |
static DefaultRecord |
indexed(Object source,
URI resource,
long position,
Object... values)
Creates an indexed record with the given values.
|
static DefaultRecord |
mapped(Object source,
URI resource,
long position,
Field[] keys,
Object... values)
Creates a mapped record with the given keys and values.
|
static DefaultRecord |
mapped(Object source,
URI resource,
long position,
Map<? extends Field,?> values)
Creates a mapped record with the given map of keys and values.
|
void |
setFieldValue(Field field,
Object value)
Sets the value associated with the given field.
|
String |
toString() |
Collection<Object> |
values()
Returns a collection containing all the values in this record.
|
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAllclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizefinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizepublic DefaultRecord(@Nullable
Object source,
@NonNull
URI resource,
long position)
source - the record source (its original form); may be null if the source cannot be
determined or should not be retained.resource - the record resource (where it comes from: file, database, etc).position - the record position inside the resource (line number, etc.).public static DefaultRecord indexed(@Nullable Object source, @NonNull URI resource, long position, Object... values)
source - the record source (its original form); may be null if the source cannot be
determined or should not be retained.resource - the record resource (where it comes from: file, database, etc).position - the record position inside the resource (line number, etc.).values - the record values.public static DefaultRecord mapped(@Nullable Object source, @NonNull URI resource, long position, Field[] keys, Object... values)
source - the record source (its original form); may be null if the source cannot be
determined or should not be retained.resource - the record resource (where it comes from: file, database, etc).position - the record position inside the resource (line number, etc.).keys - the record keys.values - the record values.public static DefaultRecord mapped(@Nullable Object source, @NonNull URI resource, long position, Map<? extends Field,?> values)
source - the record source (its original form); may be null if the source cannot be
determined or should not be retained.resource - the record resource (where it comes from: file, database, etc).position - the record position inside the resource (line number, etc.).values - the record keys and values.@NonNull public Object getSource()
Record@NonNull public URI getResource()
RecordDetails about the returned URI, and in particular its scheme, are implementation-specific.
getResource in interface Recordpublic long getPosition()
RecordNote that in the case of a file, the record's position is not necessarily equal to the line number where it appears. First, if there is one or more header lines, the actual line number would be its position + the number of header lines. Moreover, it the resource contains multi-line records, then it is not possible to draw a direct relationship between the record's position and its line.
Positions should be 1-based, i.e., the first record in the resource has position 1, and so on. If the position cannot be determined, this method should return -1.
getPosition in interface Record@NonNull public Set<Field> fields()
Record@NonNull public Collection<Object> values()
RecordThe iteration order of this collection should match that of Record.fields().
public Object getFieldValue(@NonNull Field field)
RecordNote that a return value of null may indicate that the record contains no such
field, or that the field value was null.
getFieldValue in interface Recordfield - the field.public void setFieldValue(@NonNull
Field field,
Object value)
field - the field to set.value - The value to set.public String toString()
toString in class AbstractMap<Field,Object>public boolean equals(Object o)
Copyright © 2017–2021 DataStax. All rights reserved.