Package uk.ac.starlink.table
Class AbstractStarTable
- java.lang.Object
-
- uk.ac.starlink.table.AbstractStarTable
-
- All Implemented Interfaces:
StarTable
- Direct Known Subclasses:
CalcStarTable,JDBCStarTable,JoinStarTable,MetadataStarTable,RandomStarTable,SequentialResultSetStarTable,StreamStarTable
public abstract class AbstractStarTable extends java.lang.Object implements StarTable
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 Constructor Description AbstractStarTable()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static intcheckedLongToInt(long lval)Convenience method to get an int value from a long.java.lang.ObjectgetCell(long irow, int icol)The AbstractStarTable implementation of this method throws an UnsupportedOperationException, since unless otherwise provided there is no random access.java.util.List<ValueInfo>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.abstract intgetColumnCount()Returns the number of columns in this table.abstract ColumnInfogetColumnInfo(int icol)Returns the object describing the data in a given column.java.lang.StringgetName()Returns the name of this table, if it has one.DescribedValuegetParameterByName(java.lang.String parname)Returns a parameter (table-wide metadata item) of this table located by its name.java.util.List<DescribedValue>getParameters()Returns a list of table parameters, that is metadata items which pertain to the entire table.java.lang.Object[]getRow(long irow)The AbstractStarTable implementation of this method constructs a row by repeated invocation ofgetCell(long, int).abstract longgetRowCount()Returns the number of rows in this table, if known.abstract RowSequencegetRowSequence()Returns an object which can iterate over all the rows in the table sequentially.java.net.URLgetURL()Returns the URL of this table, if it has one.booleanisRandom()The AbstractStarTable implementation of this method returns false.voidsetName(java.lang.String name)Sets the name for this table.voidsetParameter(DescribedValue dval)Adds the given DescribedValue to the list of parameter metadata objects associated with this table.voidsetParameters(java.util.List<DescribedValue> parameters)Sets the list of table parameters, that is items which pertain to the entire table.voidsetURL(java.net.URL url)Sets the URL for this table.
-
-
-
Method Detail
-
getColumnAuxDataInfos
public java.util.List<ValueInfo> 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:
getColumnAuxDataInfosin interfaceStarTable- Returns:
- a list of all the auxiliary metadata ValueInfo items which in fact crop up in column metadata
- See Also:
ColumnInfo.getAuxData()
-
getParameters
public java.util.List<DescribedValue> getParameters()
Description copied from interface:StarTableReturns a list of table parameters, that is metadata items which pertain to the entire table.- Specified by:
getParametersin interfaceStarTable- Returns:
- a List of DescribedValue objects constituting table-wide metadata not covered elsewhere in this interface
-
setParameters
public void setParameters(java.util.List<DescribedValue> parameters)
Sets the list of table parameters, that is items which pertain to the entire table. Each element of the provided list parameters should be aDescribedValueobject.- Parameters:
parameters- a List of DescribedValues pertaining to this table
-
setParameter
public void setParameter(DescribedValue dval)
Description copied from interface:StarTableAdds the given DescribedValue to the list of parameter metadata objects associated with this table. If an item in the parameter list with the same name as the supplied value already exists, it is removed from the list.- Specified by:
setParameterin interfaceStarTable- Parameters:
dval- the new parameter datum to add
-
getName
public java.lang.String getName()
Description copied from interface:StarTableReturns 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
public void setName(java.lang.String name)
Sets the name for this table.
-
getURL
public java.net.URL getURL()
Description copied from interface:StarTableReturns 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
public void setURL(java.net.URL url)
Sets the URL for this table.
-
getParameterByName
public DescribedValue getParameterByName(java.lang.String parname)
Description copied from interface:StarTableReturns 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:
getParameterByNamein interfaceStarTable- Parameters:
parname- the name of the table parameter required
-
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.
-
getCell
public java.lang.Object getCell(long irow, int icol) throws java.io.IOExceptionThe AbstractStarTable implementation of this method throws an UnsupportedOperationException, since unless otherwise provided there is no random access.
-
getRow
public java.lang.Object[] getRow(long irow) throws java.io.IOExceptionThe AbstractStarTable implementation of this method constructs a row by repeated invocation ofgetCell(long, int).
-
getColumnInfo
public abstract ColumnInfo getColumnInfo(int icol)
Description copied from interface:StarTableReturns the object describing the data in a given column.- Specified by:
getColumnInfoin 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:StarTableReturns the number of columns in this table.- Specified by:
getColumnCountin interfaceStarTable- Returns:
- the number of columns
-
getRowCount
public abstract long getRowCount()
Description copied from interface:StarTableReturns 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:
getRowCountin interfaceStarTable- Returns:
- the number of rows, or -1
-
getRowSequence
public abstract RowSequence getRowSequence() throws java.io.IOException
Description copied from interface:StarTableReturns an object which can iterate over all the rows in the table sequentially.- Specified by:
getRowSequencein interfaceStarTable- Returns:
- an object providing sequential access to the table data
- Throws:
java.io.IOException- if there is an error providing access
-
-