org.expasy.jpl.commons.base.record
Class DataTable

java.lang.Object
  extended by org.expasy.jpl.commons.base.record.DataTable
All Implemented Interfaces:
Serializable, Iterable<DataTable.Record>

public final class DataTable
extends Object
implements Iterable<DataTable.Record>, Serializable

DataTable is a kind of naive relational database table. It handles Records (a set of data elements) satisfying a signature model (with typed fields).

Version:
1.0
Author:
nikitin
See Also:
DataTableFactory, Serialized Form

Nested Class Summary
 class DataTable.Record
          Data table record internal class (immutable).
 
Method Summary
 DataTable.Record addNewRecord(Properties fieldValues)
          Create and add a new instance of internal class Record with values.
 Map<String,DataTableFactory.TypeManager.IType> getFields()
          Get the field names of this table.
 DataTableFactory.TypeManager.IType getFieldType(String field)
          Get the field type of the given field of this table.
 DataTable.Record getRecord(int id)
          Get the record identified by the given id.
<T> org.apache.commons.collections15.Transformer<DataTable.Record,T>
getTypeAccessor(String fieldName)
          Access field String value from Record.
 boolean hasField(String name)
          Return true if this table has the given field.
 Iterator<DataTable.Record> iterator()
          Get an iterator over the records.
 Set<DataTable.Record> select(Condition<DataTable.Record> condition)
          Select every Records that satisfy the given condition.
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getTypeAccessor

public <T> org.apache.commons.collections15.Transformer<DataTable.Record,T> getTypeAccessor(String fieldName)
Access field String value from Record.

Type Parameters:
T - the field type.
Parameters:
fieldName - the field name.
Returns:
the accessor to T.

addNewRecord

public DataTable.Record addNewRecord(Properties fieldValues)
Create and add a new instance of internal class Record with values.

Parameters:
fieldValues - the field values of the brand new Record.
Returns:
a new record filled with given values.

getRecord

public DataTable.Record getRecord(int id)
Get the record identified by the given id.

Parameters:
id - the record unique identifier.
Returns:
an identified record.

hasField

public boolean hasField(String name)
Return true if this table has the given field.

Parameters:
name - the name of the queried field.
Returns:
true if this table has the field.

getFields

public final Map<String,DataTableFactory.TypeManager.IType> getFields()
Get the field names of this table.

Returns:
field names.

getFieldType

public DataTableFactory.TypeManager.IType getFieldType(String field)
Get the field type of the given field of this table.

Parameters:
field - the field name to get the type from.
Returns:
the field type.

iterator

public Iterator<DataTable.Record> iterator()
Get an iterator over the records.

Specified by:
iterator in interface Iterable<DataTable.Record>
Returns:
the records.

select

public Set<DataTable.Record> select(Condition<DataTable.Record> condition)
Select every Records that satisfy the given condition.

Parameters:
condition - the condition to test records.
Returns:
the selected records.

size

public int size()

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.