Package uk.ac.starlink.table
Class ColumnStarTable
java.lang.Object
uk.ac.starlink.table.AbstractStarTable
uk.ac.starlink.table.RandomStarTable
uk.ac.starlink.table.ColumnStarTable
- All Implemented Interfaces:
Closeable
,AutoCloseable
,StarTable
- Direct Known Subclasses:
LoopStarTable
A random-access StarTable that manages its data in columns.
The data in each column
is managed by a
ColumnData
object which can be accessed
directly using the getColumnData(int)
method. Columns can be
added and substituted. If the columns permit it then table cells
can be written to as well as read from.
Concrete subclasses of this abstract class must implement
getRowCount()
.
If you just need a ColumnStarTable
with a fixed number of rows
you can use the static convenience method makeTableWithRows(long)
.
- Author:
- Mark Taylor (Starlink)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ColumnStarTable
(StarTable template) Initialises aColumnStarTable
using a templateStarTable
to provide per-table metadata. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addColumn
(ColumnData coldata) Appends a new column to the end of this model.getCell
(long lrow, int icol) Implementations of this method must be safe for concurrent calls from multiple threads.int
Returns the number of columns in this table.getColumnData
(int icol) Returns theColumnData
object for a given column.getColumnInfo
(int icol) Returns the object describing the data in a given column.abstract long
Gets the number of rows in the table (which must be applicable to all the columns).static ColumnStarTable
makeTableWithRows
(long nrow) Convenience method to return aColumnStarTable
with a fixed number of rows.void
Stores an object in a given cell of the table.void
setColumn
(int icol, ColumnData coldata) Substitutes a new column for the one which is currently in a given position.Methods inherited from class uk.ac.starlink.table.RandomStarTable
getRowAccess, getRowSequence, isRandom
Methods inherited from class uk.ac.starlink.table.AbstractStarTable
checkedLongToInt, close, getColumnAuxDataInfos, getName, getParameters, getRow, getRowSplittable, getURL, setName, setParameters, setURL
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface uk.ac.starlink.table.StarTable
getParameterByName, setParameter
-
Field Details
-
columns_
-
-
Constructor Details
-
ColumnStarTable
public ColumnStarTable()Default constructor. -
ColumnStarTable
Initialises aColumnStarTable
using a templateStarTable
to provide per-table metadata. The newly constructed object will have copies of thetemplate
's name, parameters etc.- Parameters:
template
- the template StarTable
-
-
Method Details
-
getRowCount
public abstract long getRowCount()Gets the number of rows in the table (which must be applicable to all the columns). Since this is aRandomStarTable
the return value must be non-negative.- Specified by:
getRowCount
in interfaceStarTable
- Specified by:
getRowCount
in classRandomStarTable
- Returns:
- number of rows
-
getColumnCount
public int getColumnCount()Description copied from interface:StarTable
Returns the number of columns in this table.- Specified by:
getColumnCount
in interfaceStarTable
- Specified by:
getColumnCount
in classAbstractStarTable
- Returns:
- the number of columns
-
getColumnInfo
Description copied from interface:StarTable
Returns the object describing the data in a given column.- Specified by:
getColumnInfo
in interfaceStarTable
- Specified by:
getColumnInfo
in classAbstractStarTable
- Parameters:
icol
- the column for which header information is required- Returns:
- a ValueInfo object for column
icol
-
getCell
Description copied from class:RandomStarTable
Implementations of this method must be safe for concurrent calls from multiple threads.- Specified by:
getCell
in interfaceStarTable
- Specified by:
getCell
in classRandomStarTable
- Parameters:
lrow
- the index of the cell's rowicol
- the index of the cell's column- Returns:
- the contents of this cell
- Throws:
IOException
- if there is an error reading the data
-
setCell
Stores an object in a given cell of the table.- Parameters:
lrow
- the row indexicol
- the column indexvalue
- the value to store- Throws:
IOException
- if an I/O error occursUnsupportedOperationException
- if columnicol
is not writable (!getColumnData(icol).isWritable()
);
-
getColumnData
Returns theColumnData
object for a given column.- Parameters:
icol
- the index of the column for which the result is required- Returns:
- the ColumnData for column
icol
-
addColumn
Appends a new column to the end of this model.- Parameters:
coldata
- the new column object to add
-
setColumn
Substitutes a new column for the one which is currently in a given position. The old one is discarded.- Parameters:
icol
- the column index to changecoldata
- the new column data object
-
makeTableWithRows
Convenience method to return aColumnStarTable
with a fixed number of rows.- Parameters:
nrow
- the number of rows this table will have
-