org.eobjects.metamodel.data
Class AbstractDataSet

java.lang.Object
  extended by org.eobjects.metamodel.util.BaseObject
      extended by org.eobjects.metamodel.data.AbstractDataSet
All Implemented Interfaces:
Closeable, Iterable<Row>, DataSet
Direct Known Subclasses:
EmptyDataSet, FilteredDataSet, FirstRowDataSet, InMemoryDataSet, MaxRowsDataSet, RowPublisherDataSet, SubSelectionDataSet

public abstract class AbstractDataSet
extends BaseObject
implements DataSet

Abstract DataSet implementation. Provides convenient implementations of trivial method and reusable parts of non-trivial methods of a DataSet.

Author:
Kasper Sørensen

Constructor Summary
AbstractDataSet()
          Deprecated. use one of the other constructors, to provide header information.
AbstractDataSet(Column[] columns)
           
AbstractDataSet(DataSet dataSet)
          Constructor appropriate for dataset implementations that wrap other datasets, such as the MaxRowsDataSet, FilteredDataSet and more.
AbstractDataSet(DataSetHeader header)
           
AbstractDataSet(List<SelectItem> selectItems)
           
AbstractDataSet(SelectItem[] selectItems)
           
 
Method Summary
 void close()
          Closes the DataSet and any resources it may be holding.
protected  void decorateIdentity(List<Object> identifiers)
          Subclasses should implement this method and add all fields to the list that are to be included in equals(...) and hashCode() evaluation
protected  DataSetHeader getHeader()
           
 SelectItem[] getSelectItems()
          
 int indexOf(SelectItem item)
          Finds the index of a given SelectItem
 Iterator<Row> iterator()
          Converts the DataSet into an Iterator.
 List<Object[]> toObjectArrays()
          Converts the DataSet into a list of object arrays (will load all values into memory)
 List<Row> toRows()
          Converts the DataSet into a list of rows (will load all rows into memory)
 String toString()
          
 TableModel toTableModel()
          Converts the DataSet into a TableModel (will load all values into memory).
 
Methods inherited from class org.eobjects.metamodel.util.BaseObject
classEquals, equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eobjects.metamodel.data.DataSet
getRow, next
 

Constructor Detail

AbstractDataSet

@Deprecated
public AbstractDataSet()
Deprecated. use one of the other constructors, to provide header information.


AbstractDataSet

public AbstractDataSet(SelectItem[] selectItems)

AbstractDataSet

public AbstractDataSet(List<SelectItem> selectItems)

AbstractDataSet

public AbstractDataSet(DataSet dataSet)
Constructor appropriate for dataset implementations that wrap other datasets, such as the MaxRowsDataSet, FilteredDataSet and more.

Parameters:
dataSet -

AbstractDataSet

public AbstractDataSet(DataSetHeader header)

AbstractDataSet

public AbstractDataSet(Column[] columns)
Method Detail

getSelectItems

public SelectItem[] getSelectItems()

Specified by:
getSelectItems in interface DataSet
Returns:
the SelectItems that represent the columns of this DataSet

getHeader

protected DataSetHeader getHeader()

indexOf

public final int indexOf(SelectItem item)
Finds the index of a given SelectItem

Specified by:
indexOf in interface DataSet
Returns:
the index (0-based) of the SelectItem or -1 if the SelectItem doesn't exist in this DataSet.

close

public void close()
Closes the DataSet and any resources it may be holding.

Specified by:
close in interface Closeable
Specified by:
close in interface DataSet

toTableModel

public final TableModel toTableModel()
Converts the DataSet into a TableModel (will load all values into memory).

Specified by:
toTableModel in interface DataSet

toObjectArrays

public final List<Object[]> toObjectArrays()
Converts the DataSet into a list of object arrays (will load all values into memory)

Specified by:
toObjectArrays in interface DataSet

toString

public String toString()

Overrides:
toString in class BaseObject

decorateIdentity

protected void decorateIdentity(List<Object> identifiers)
Description copied from class: BaseObject
Subclasses should implement this method and add all fields to the list that are to be included in equals(...) and hashCode() evaluation

Specified by:
decorateIdentity in class BaseObject

toRows

public List<Row> toRows()
Description copied from interface: DataSet
Converts the DataSet into a list of rows (will load all rows into memory)

Specified by:
toRows in interface DataSet

iterator

public Iterator<Row> iterator()
Converts the DataSet into an Iterator. Note that unlike many Iterable objects, DataSets are unlikely to allow creation of multiple iterators without risking loss of data in each individual iteration loop.

Specified by:
iterator in interface Iterable<Row>
Specified by:
iterator in interface DataSet


Copyright © 2007-2013. All Rights Reserved.