jimm.datavision.source
Class Table

java.lang.Object
  extended by jimm.datavision.source.Table
All Implemented Interfaces:
Identity, Nameable
Direct Known Subclasses:
NCTable, SQLTable, TestTable

public class Table
extends java.lang.Object
implements Identity, Nameable

Represents a table that contains columns. Not all data sources will use tables. For those that don't, their columns' getTable method will return null.

Author:
Jim Menard, jimm@io.com
See Also:
Column, DataSource

Field Summary
protected  java.util.TreeMap columns
           
protected  DataSource dataSource
           
protected  java.lang.String name
           
 
Constructor Summary
Table(DataSource dataSource, java.lang.String name)
          Constructor.
 
Method Summary
 void addColumn(Column col)
          Adds a column to the collection, using the column's id as the key.
 java.util.Iterator columns()
          Returns an iterator over the columns in this table.
 Column findColumn(java.lang.Object id)
          Given a column id, returns the column that has that id.
 java.lang.Object getId()
          Returns the table id.
 java.lang.String getName()
          Returns the table name.
 void setName(java.lang.String name)
          A table's name is immutable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSource

protected DataSource dataSource

name

protected java.lang.String name

columns

protected java.util.TreeMap columns
Constructor Detail

Table

public Table(DataSource dataSource,
             java.lang.String name)
Constructor.

Parameters:
dataSource - the data source in which this table resides
name - the table's name
Method Detail

findColumn

public Column findColumn(java.lang.Object id)
Given a column id, returns the column that has that id. If no column with the specified id exists, returns null.

Returns:
a column, or null if no column with the specified id exists

getId

public java.lang.Object getId()
Returns the table id. By default, it's the same as the table name.

Specified by:
getId in interface Identity
Returns:
the table id

getName

public java.lang.String getName()
Returns the table name.

Specified by:
getName in interface Nameable
Returns:
the table name

setName

public void setName(java.lang.String name)
A table's name is immutable.

Specified by:
setName in interface Nameable
Parameters:
name - the new name

addColumn

public void addColumn(Column col)
Adds a column to the collection, using the column's id as the key.

Parameters:
col - a column

columns

public java.util.Iterator columns()
Returns an iterator over the columns in this table.

Returns:
an iterator over the columns in this table