public class DataTable
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
DataTable.AddRecordException
Exception thrown when attempting to add a record which causes an
inconsistency.
|
static class |
DataTable.NonUniqueRecordException
This exception is thrown when attempting to fetch a single record
with bindings and more than one record matches the criteria.
|
class |
DataTable.Schema
This class represents the schema of the table which specifies the attributes belonging to the table.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATA_LABEL
table label inside of a data adaptor
|
static java.lang.String |
NODE_KEY |
Constructor and Description |
---|
DataTable(DataAdaptor adaptor)
Constructor
|
DataTable(java.lang.String aName,
java.util.Collection<DataAttribute> attributes)
Constructor
|
DataTable(java.lang.String aName,
java.util.Collection<DataAttribute> attributes,
java.lang.Class<? extends GenericRecord> aRecordClass)
Primary constructor
|
Modifier and Type | Method and Description |
---|---|
void |
add(GenericRecord record)
Add the record to the table.
|
void |
addDataTableListener(DataTableListener listener)
Add the specified listener as a receiver of events from this data table.
|
java.util.Collection<DataAttribute> |
attributes()
Return the attributes of this table from the table's schema.
|
DataListener |
dataHandler()
Handle reading and writing from a data adaptor
|
java.lang.Class<? extends GenericRecord> |
getRecordClass()
convienience method for user to detect record class
|
<ValueType> |
getRecords(java.util.Map<java.lang.String,ValueType> bindings,
SortOrdering ordering)
Fetch the records with matching key/value pair bindings and sort them according to the sort ordering.
|
java.util.List<GenericRecord> |
getRecords(SortOrdering ordering)
Fetch all records held in the table and sort them according to the sort ordering.
|
java.util.List<GenericRecord> |
getRecords(java.lang.String key,
java.lang.Object value,
SortOrdering ordering)
Fetch the records with a matching key/value pair binding and sort them according to the sort ordering.
|
java.util.Collection<java.lang.Object> |
getUniquePrimaryKeyValues(java.lang.String key)
Get the unique values of the specified primary key column.
|
boolean |
hasRecord(GenericRecord record)
Determine if this table contains the specified record
|
java.util.Collection<java.lang.String> |
keys()
Get all keys for this table.
|
java.lang.String |
name()
Get the name of this table.
|
java.util.List<GenericRecord> |
orderRecords(java.util.Collection<GenericRecord> records,
SortOrdering ordering)
Order the records according to the specified sort ordering.
|
java.util.Collection<java.lang.String> |
primaryKeys()
Get the primary keys for the table.
|
<ValueType> |
record(java.util.Map<java.lang.String,ValueType> bindings)
Fetch the record with matching key/value pair bindings.
|
GenericRecord |
record(java.lang.String key,
java.lang.Object value)
Fetch the record with a matching key/value pair binding.
|
GenericRecord |
recordForNode(java.lang.String nodeId)
Fetch the record with a matching nodeId.
|
java.util.Collection<GenericRecord> |
records()
Fetch all records held in the table
|
<ValueType> |
records(java.util.Map<java.lang.String,ValueType> bindings)
Fetch the records with matching key/value pair bindings.
|
java.util.Collection<GenericRecord> |
records(java.lang.String key,
java.lang.Object value)
Fetch the records with a matching key/value pair binding.
|
java.util.Collection<GenericRecord> |
recordsForNode(java.lang.String nodeId)
Fetch the records with a matching nodeId.
|
void |
remove(GenericRecord record)
Remove the specified record from this table.
|
void |
removeDataTableListener(DataTableListener listener)
Remove the specified listener from receiving events from this data table.
|
public static final java.lang.String DATA_LABEL
public static final java.lang.String NODE_KEY
public DataTable(java.lang.String aName, java.util.Collection<DataAttribute> attributes)
public DataTable(java.lang.String aName, java.util.Collection<DataAttribute> attributes, java.lang.Class<? extends GenericRecord> aRecordClass)
public DataTable(DataAdaptor adaptor)
adaptor
- the adaptor from which to construct the data tablepublic void addDataTableListener(DataTableListener listener)
listener
- the listener to receive eventspublic void removeDataTableListener(DataTableListener listener)
listener
- the listener to remove from receiving eventspublic java.lang.Class<? extends GenericRecord> getRecordClass()
public DataListener dataHandler() throws MissingPrimaryKeyException
MissingPrimaryKeyException
public java.lang.String name()
public java.util.Collection<java.lang.String> keys()
public java.util.Collection<java.lang.String> primaryKeys()
public boolean hasRecord(GenericRecord record)
record
- The record to test for membership in this tablepublic void add(GenericRecord record) throws DataTable.AddRecordException
DataTable.AddRecordException
public void remove(GenericRecord record)
public java.util.Collection<DataAttribute> attributes()
public java.util.List<GenericRecord> orderRecords(java.util.Collection<GenericRecord> records, SortOrdering ordering)
records
- the records to sort.ordering
- the sort ordering used to sort the recordspublic java.util.Collection<GenericRecord> records()
public java.util.List<GenericRecord> getRecords(SortOrdering ordering)
ordering
- The sort ordering used to sort the records.public <ValueType> GenericRecord record(java.util.Map<java.lang.String,ValueType> bindings) throws DataTable.NonUniqueRecordException
public GenericRecord record(java.lang.String key, java.lang.Object value) throws DataTable.NonUniqueRecordException
public <ValueType> java.util.Collection<GenericRecord> records(java.util.Map<java.lang.String,ValueType> bindings)
bindings
- The map of key/value pairs where the keys correspond to a subset of primary keys and the values are the ones we want to match.public <ValueType> java.util.List<GenericRecord> getRecords(java.util.Map<java.lang.String,ValueType> bindings, SortOrdering ordering)
bindings
- The map of key/value pairs where the keys correspond to a subset of primary keys and the values are the ones we want to match.ordering
- The sort ordering used to sort the records.public java.util.Collection<GenericRecord> records(java.lang.String key, java.lang.Object value)
key
- A primary key to fetch against.value
- The value of the primary key to match.public java.util.List<GenericRecord> getRecords(java.lang.String key, java.lang.Object value, SortOrdering ordering)
key
- A primary key to fetch against.value
- The value of the primary key to match.ordering
- The sort ordering used to sort the records.public GenericRecord recordForNode(java.lang.String nodeId) throws DataTable.NonUniqueRecordException
public java.util.Collection<GenericRecord> recordsForNode(java.lang.String nodeId)
public final java.util.Collection<java.lang.Object> getUniquePrimaryKeyValues(java.lang.String key)
key
- The primary key column whose unique values we want to fetch.