uk.ac.starlink.table
Class WrapperStarTable

java.lang.Object
  |
  +--uk.ac.starlink.table.WrapperStarTable
All Implemented Interfaces:
StarTable
Direct Known Subclasses:
ColumnPermutedStarTable, ConcatStarTable, EmptyStarTable, ProgressBarStarTable, ProgressLineStarTable, RandomWrapperStarTable, RowPermutedStarTable, RowSubsetStarTable

public class WrapperStarTable
extends Object
implements StarTable

StarTable which wraps another StarTable. This class acts as a wrapper around an existing 'base' StarTable object; almost all its methods are implemented by forwarding to the corresponding methods of that base table. The exception is the getURL() method which returns null as an indication that the actual table is not a persistent one (though it may be based on, and even identical to, a persistent one).

This class is provided so that it can be extended by subclasses which modify the view of the base table in useful ways.

See Also:
WrapperRowSequence

Field Summary
protected  StarTable baseTable
           
 
Constructor Summary
WrapperStarTable(StarTable baseTable)
          Constructs a new WrapperStarTable from a given base table.
 
Method Summary
static int checkedLongToInt(long lval)
          Convenience method to get an int value from a long.
 StarTable getBaseTable()
          Returns the base table underlying this wrapper table.
 Object getCell(long irow, int icol)
          Returns the contents of a given table cell.
 List getColumnAuxDataInfos()
          Returns an ordered list of ValueInfo objects representing the auxiliary metadata returned by getColumnInfo(int).getAuxData() calls.
 int getColumnCount()
          Returns the number of columns in this table.
 ColumnInfo getColumnInfo(int icol)
          Returns the object describing the data in a given column.
 String getName()
          Returns the name of this table, if it has one.
 DescribedValue getParameterByName(String parname)
          Returns a parameter (table-wide metadata item) of this table located by its name.
 List getParameters()
          Returns a list of table parameters, that is items which pertain to the entire table.
 Object[] getRow(long irow)
          Returns the contents of a given table row.
 long getRowCount()
          Returns the number of rows in this table, if known.
 RowSequence getRowSequence()
          Returns an object which can iterate over all the rows in the table sequentially.
 URL getURL()
          Initially returns null to indicate that this table itself is not persistent.
 boolean isRandom()
          Indicates whether random access is provided by this table.
 void setName(String name)
          Sets the name of this table.
 void setURL(URL url)
          Sets the URL of this table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseTable

protected StarTable baseTable
Constructor Detail

WrapperStarTable

public WrapperStarTable(StarTable baseTable)
Constructs a new WrapperStarTable from a given base table.

Parameters:
baseTable - the table to which methods invoked upon the new wrapper table will be forwarded
Method Detail

getBaseTable

public StarTable getBaseTable()
Returns the base table underlying this wrapper table.

Returns:
the table to which methods invoked upon this wrappter table are forwarded

getColumnCount

public int getColumnCount()
Description copied from interface: StarTable
Returns the number of columns in this table.

Specified by:
getColumnCount in interface StarTable
Returns:
the number of columns

getRowCount

public long getRowCount()
Description copied from interface: StarTable
Returns the number of rows in this table, if known. If the number of rows cannot be (easily) determined, a value of -1 will be returned.

Specified by:
getRowCount in interface StarTable
Returns:
the number of rows, or -1

getURL

public URL getURL()
Initially returns null to indicate that this table itself is not persistent.

Specified by:
getURL in interface StarTable
Returns:
the URL of this table, or null if none is known

setURL

public void setURL(URL url)
Description copied from interface: StarTable
Sets the URL of this table. It ought to be possible in principle to reconstruct this table by reading the resource at url. If called, the supplied url should provide the return value for subsequent calls of StarTable.getURL().

Specified by:
setURL in interface StarTable
Parameters:
url - table URL

getName

public String getName()
Description copied from interface: StarTable
Returns the name of this table, if it has one. The meaning of the name is not defined, but it will typically be a short string of text indicating the identity of this table.

Specified by:
getName in interface StarTable
Returns:
a name for this table, or null if no suitable one exists

setName

public void setName(String name)
Description copied from interface: StarTable
Sets the name of this table. If called, the supplied name should provide the return value for subsequent calls of StarTable.getName().

Specified by:
setName in interface StarTable
Parameters:
name - table name

getParameters

public List getParameters()
Description copied from interface: StarTable
Returns a list of table parameters, that is items which pertain to the entire table. Each element of this list must be a DescribedValue object.

Specified by:
getParameters in interface StarTable
Returns:
a List of DescribedValue objects constituting table-wide metadata not covered elsewhere in this interface

getParameterByName

public DescribedValue getParameterByName(String parname)
Description copied from interface: StarTable
Returns a parameter (table-wide metadata item) of this table located by its name. If more than one parameter with the given name exists, an arbitrary one will be returned. If no parameter with the given name exists, null will be returned.

Specified by:
getParameterByName in interface StarTable
Parameters:
parname - the name of the table parameter required

getColumnInfo

public ColumnInfo getColumnInfo(int icol)
Description copied from interface: StarTable
Returns the object describing the data in a given column.

Specified by:
getColumnInfo in interface StarTable
Parameters:
icol - the column for which header information is required
Returns:
a ValueInfo object for column icol

getColumnAuxDataInfos

public List getColumnAuxDataInfos()
Description copied from interface: StarTable
Returns an ordered list of ValueInfo objects representing the auxiliary metadata returned by getColumnInfo(int).getAuxData() calls. The idea is that the resulting list can be used to find out the kind of per-column metadata which can be expected to be found in some or all columns of this table. Each item in the returned list should have a unique name, and other characteristics which are applicable to auxData items which may be returned from any of the columns in this table.

The order of the list may indicate some sort of natural ordering of these keys. The returned list is not guaranteed to be complete; it is legal to return an empty list if nothing is known about auxiliary metadata. The list ought not to contain duplicate elements.

Specified by:
getColumnAuxDataInfos in interface StarTable
Returns:
an unmodifiable ordered set of known metadata keys
See Also:
ColumnInfo.getAuxData()

getRowSequence

public RowSequence getRowSequence()
                           throws IOException
Description copied from interface: StarTable
Returns an object which can iterate over all the rows in the table sequentially.

Specified by:
getRowSequence in interface StarTable
Returns:
an object providing sequential access to the table data
Throws:
IOException - if there is an error providing access

isRandom

public boolean isRandom()
Description copied from interface: StarTable
Indicates whether random access is provided by this table. Only if the result is true may the StarTable.getRow(long) and StarTable.getCell(long, int) methods be used.

Specified by:
isRandom in interface StarTable
Returns:
true if table random access methods are available

getCell

public Object getCell(long irow,
                      int icol)
               throws IOException
Description copied from interface: StarTable
Returns the contents of a given table cell. The class of the returned object should be the same as, or a subclass of, the class returned by getColumnInfo(icol).getContentClass().

Specified by:
getCell in interface StarTable
Parameters:
irow - the index of the cell's row
icol - the index of the cell's column
Returns:
the contents of this cell
Throws:
IOException - if there is an error reading the data

getRow

public Object[] getRow(long irow)
                throws IOException
Description copied from interface: StarTable
Returns the contents of a given table row. The returned value is equivalent to an array formed of all the objects returned by getCell(irow,icol) for all the columns icol in sequence.

Specified by:
getRow in interface StarTable
Parameters:
irow - the index of the row to retrieve
Returns:
an array of the objects in each cell in row irow
Throws:
IOException - if there is an error reading the data

checkedLongToInt

public static int checkedLongToInt(long lval)
Convenience method to get an int value from a long. Invokes Tables.checkedLongToInt(long).


Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.