Package uk.ac.starlink.table
Class AbstractStarTable
java.lang.Object
uk.ac.starlink.table.AbstractStarTable
- All Implemented Interfaces:
Closeable
,AutoCloseable
,StarTable
- Direct Known Subclasses:
CalcStarTable
,JDBCStarTable
,JoinStarTable
,MetadataStarTable
,RandomStarTable
,SequentialResultSetStarTable
,StreamStarTable
Abstract base class providing an implementation of the generic and
straightforward parts of the StarTable interface.
This implementation assumes that random access is not available;
subclasses which provide random access should override
the isRandom, getCell and perhaps getRow methods.
- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
checkedLongToInt
(long lval) Convenience method to get an int value from a long.void
close()
The AbstractStarTable implementation of this method does nothing.getCell
(long irow, int icol) The AbstractStarTable implementation of this method throws an UnsupportedOperationException, since unless otherwise provided there is no random access.Goes through the table columns (ColumnInfo objects) and picks out all the AuxData items which exist, generalising where necessary and returning a union of them in alphabetical order by name.abstract int
Returns the number of columns in this table.abstract ColumnInfo
getColumnInfo
(int icol) Returns the object describing the data in a given column.getName()
Returns the name of this table, if it has one.Returns a list of table parameters, that is metadata items which pertain to the entire table.Object[]
getRow
(long irow) The AbstractStarTable implementation of this method constructs a row by repeated invocation ofgetCell(long, int)
.Returns an object which can provide random access to this table's data, if random access is implemented.abstract long
Returns the number of rows in this table, if known.abstract RowSequence
Returns an object which can iterate over all the rows in the table sequentially.Returns a default splittable which relies on table random access if available, or otherwise provides only sequential access (no splits).getURL()
Returns the URL of this table, if it has one.boolean
isRandom()
The AbstractStarTable implementation of this method returns false.void
Sets the name for this table.void
setParameters
(List<DescribedValue> parameters) Sets the list of table parameters, that is items which pertain to the entire table.void
Sets the URL for this table.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
-
Constructor Details
-
AbstractStarTable
public AbstractStarTable()
-
-
Method Details
-
getColumnAuxDataInfos
Goes through the table columns (ColumnInfo objects) and picks out all the AuxData items which exist, generalising where necessary and returning a union of them in alphabetical order by name. Subclasses should override this if they can do better, for instance providing an order for the keys.- Specified by:
getColumnAuxDataInfos
in interfaceStarTable
- Returns:
- a list of all the auxiliary metadata ValueInfo items which in fact crop up in column metadata
- See Also:
-
getParameters
Description copied from interface:StarTable
Returns a list of table parameters, that is metadata items which pertain to the entire table.- Specified by:
getParameters
in interfaceStarTable
- Returns:
- a List of DescribedValue objects constituting table-wide metadata not covered elsewhere in this interface
-
setParameters
Sets the list of table parameters, that is items which pertain to the entire table. Each element of the provided list parameters should be aDescribedValue
object.- Parameters:
parameters
- a List of DescribedValues pertaining to this table
-
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. -
setName
Sets the name for this table. -
getURL
Description copied from interface:StarTable
Returns the URL of this table, if it has one. A non-null return from this method indicates that this table is in some sense persistent. -
setURL
Sets the URL for this table. -
checkedLongToInt
public static int checkedLongToInt(long lval) Convenience method to get an int value from a long. InvokesTables.checkedLongToInt(long)
. -
isRandom
public boolean isRandom()The AbstractStarTable implementation of this method returns false. -
getRowAccess
Description copied from interface:StarTable
Returns an object which can provide random access to this table's data, if random access is implemented. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.- Specified by:
getRowAccess
in interfaceStarTable
- Returns:
- new RowAccess
- Throws:
IOException
- if there is an error setting up access
-
getRowSplittable
Returns a default splittable which relies on table random access if available, or otherwise provides only sequential access (no splits).It is often possible to provide a better implementation than this.
- Specified by:
getRowSplittable
in interfaceStarTable
- Returns:
Tables.getDefaultRowSplittable(this)
- Throws:
IOException
- See Also:
-
getCell
The AbstractStarTable implementation of this method throws an UnsupportedOperationException, since unless otherwise provided there is no random access.- Specified by:
getCell
in interfaceStarTable
- Parameters:
irow
- 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
-
getRow
The AbstractStarTable implementation of this method constructs a row by repeated invocation ofgetCell(long, int)
.- Specified by:
getRow
in interfaceStarTable
- 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
-
close
The AbstractStarTable implementation of this method does nothing.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceStarTable
- Throws:
IOException
-
getColumnInfo
Description copied from interface:StarTable
Returns the object describing the data in a given column.- Specified by:
getColumnInfo
in interfaceStarTable
- Parameters:
icol
- the column for which header information is required- Returns:
- a ValueInfo object for column icol
-
getColumnCount
public abstract int getColumnCount()Description copied from interface:StarTable
Returns the number of columns in this table.- Specified by:
getColumnCount
in interfaceStarTable
- Returns:
- the number of columns
-
getRowCount
public abstract 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 interfaceStarTable
- Returns:
- the number of rows, or -1
-
getRowSequence
Description copied from interface:StarTable
Returns an object which can iterate over all the rows in the table sequentially. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.- Specified by:
getRowSequence
in interfaceStarTable
- Returns:
- new RowSequence
- Throws:
IOException
- if there is an error providing access
-