de.erichseifert.gral.data
Class DataAccessor

java.lang.Object
  extended by de.erichseifert.gral.data.DataAccessor
All Implemented Interfaces:
Iterable<Number>
Direct Known Subclasses:
Column, Row

public abstract class DataAccessor
extends Object
implements Iterable<Number>

Abstract base for classes that access a substructure of a data source, e.g. columns or rows.


Constructor Summary
DataAccessor(DataSource source, int index)
          Initializes a new instance with the specified data source and a acess index index.
 
Method Summary
 boolean equals(Object obj)
           
abstract  Number get(int index)
          Returns the value of the data source for the specified index.
 int getIndex()
          Returns the index to access the data source.
 DataSource getSource()
          Returns the data source containing this column.
abstract  double getStatistics(String key)
          Returns the specified statistical information for this data.
 int hashCode()
           
 Iterator<Number> iterator()
           
abstract  int size()
          Returns the number of elements in this column.
 Number[] toArray(Number[] data)
          Converts the data column to an array.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataAccessor

public DataAccessor(DataSource source,
                    int index)
Initializes a new instance with the specified data source and a acess index index.

Parameters:
source - Data source.
index - Column index.
Method Detail

getSource

public DataSource getSource()
Returns the data source containing this column.

Returns:
Data source containing this column.

getIndex

public int getIndex()
Returns the index to access the data source.

Returns:
Data index.

get

public abstract Number get(int index)
Returns the value of the data source for the specified index.

Parameters:
index - Index.
Returns:
Value of the accessed cell.

size

public abstract int size()
Returns the number of elements in this column.

Returns:
Number of elements

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

toArray

public Number[] toArray(Number[] data)
Converts the data column to an array.

Parameters:
data - Optional array as data sink. If array is null a new array will be created.
Returns:
Array with row data;

getStatistics

public abstract double getStatistics(String key)
Returns the specified statistical information for this data.

Parameters:
key - Requested Statistical information.
Returns:
Calculated value.

iterator

public Iterator<Number> iterator()
Specified by:
iterator in interface Iterable<Number>


Copyright © 2009-2010. All Rights Reserved.