uk.ac.starlink.table
Class Tables

java.lang.Object
  |
  +--uk.ac.starlink.table.Tables

public class Tables
extends Object

Utility class for miscellaneous table-related functionality.


Constructor Summary
Tables()
           
 
Method Summary
static void checkTable(StarTable table)
          Diagnostic method which tests the invariants of a StarTable.
static StarTable deleteColumn(StarTable startab, int icol)
          Returns a table equivalent to the original but with a given column deleted.
static ColumnInfo[] getColumnInfos(StarTable startab)
          Convenience method to return an array of all the column headers in a given table.
static StarTable randomTable(StarTable startab)
          Returns a table based on a given table and guaranteed to have random access.
static void streamStarTable(StarTable source, TableSink sink)
          Copies the data and metadata from a StarTable into a table sink.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tables

public Tables()
Method Detail

randomTable

public static StarTable randomTable(StarTable startab)
                             throws IOException
Returns a table based on a given table and guaranteed to have random access. If the original table stab has random access then it is returned, otherwise a new random access table is built using its data.

Returns:
a table with the same data as startab and with isRandom()==true
IOException

getColumnInfos

public static ColumnInfo[] getColumnInfos(StarTable startab)
Convenience method to return an array of all the column headers in a given table. Modifying this array will not affect the table.

Parameters:
startab - the table being enquired about
Returns:
an array of all the column headers

deleteColumn

public static StarTable deleteColumn(StarTable startab,
                                     int icol)
Returns a table equivalent to the original but with a given column deleted. The result may or may not be the same object as the input table.

Parameters:
startab - the table from which to delete a column
icol - the index of the column to be deleted
Throws:
IndexOutOfBoundsException - if startab has no column at icol

streamStarTable

public static void streamStarTable(StarTable source,
                                   TableSink sink)
                            throws IOException
Copies the data and metadata from a StarTable into a table sink. This method is supplied for convenience; its implementation is very straightforward.

Parameters:
source - table to be copied
sink - table destination
IOException

checkTable

public static void checkTable(StarTable table)
                       throws IOException
Diagnostic method which tests the invariants of a StarTable. This method returns no value, and throws an exception if a table is illegal in some way. If this method throws an exception when called on a given StarTable, that table is deemed to be bad in some way (buggy implementation or I/O trouble during access). This method is provided for convenience and diagnostics because there are a number of ways, some of them subtle, in which a StarTable can fail to fulfil its general contract.

That a table passes this test does not guarantee that the table has no bugs. This method should not generally be used in production code, since it may be expensive in time and/or memory.

Parameters:
table - table to test
Throws:
AssertionError - if an invariant is violated
IOException - if there is an I/O error

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