Package uk.ac.starlink.table
Class ArrayColumn
java.lang.Object
uk.ac.starlink.table.ColumnData
uk.ac.starlink.table.ArrayColumn
- Direct Known Subclasses:
ObjectArrayColumn,PrimitiveArrayColumn
A column which provides data storage in java arrays.
This abstract class has separate implementations for primitive and
object arrays.
- Author:
- Mark Taylor (Starlink)
-
Method Summary
Modifier and TypeMethodDescriptiongetArray()Returns the array object which holds the array data for this column.booleanReturns true, since this class can store cell values.static ArrayColumnmakeColumn(String name, Object data) Constructs a new ArrayColumn based on a given data array.static ArrayColumnmakeColumn(ColumnInfo base, long rowCount) Obtains an ArrayColumn object based on a template object with a given number of rows.static ArrayColumnmakeColumn(ColumnInfo base, Object data) Constructs a new ArrayColumn based on a given data array.readValue(long lrow) Returns the value stored at a given row in this column.voidstoreValue(long lrow, Object val) Stores a given value in a given row for this column.Methods inherited from class uk.ac.starlink.table.ColumnData
getColumnInfo, setColumnInfo
-
Method Details
-
isWritable
public boolean isWritable()Returns true, since this class can store cell values.- Overrides:
isWritablein classColumnData- Returns:
- true
-
storeValue
Description copied from class:ColumnDataStores a given value in a given row for this column. Will only work if the isWritable method returns true. The implementation in the ColumnData class throws an UnsupportedOperationException.- Overrides:
storeValuein classColumnData- Parameters:
lrow- the row to store it inval- the object to store
-
readValue
Description copied from class:ColumnDataReturns the value stored at a given row in this column.- Specified by:
readValuein classColumnData- Parameters:
lrow- the row from which to retrieve the value- Returns:
- the value stored at irow
-
getArray
Returns the array object which holds the array data for this column.- Returns:
- data array
-
makeColumn
Obtains an ArrayColumn object based on a template object with a given number of rows. A new ColumnInfo object will be constructed based on the given one. It will return a PrimitiveArrayColumn if info describes a primitive type.- Parameters:
base- the template ColumnInfo - note this is not the actual ColumnInfo object which will be returned by the getColumnInfo method of the returned ArrayColumnrowCount- the number of rows it is to hold- Returns:
- a new ArrayColumn based on base with storage for rowCount elements
-
makeColumn
Constructs a new ArrayColumn based on a given data array. The contentClass of the given base column info must be compatible with the supplied data array; in the case of a primitive data array it should be that of the corresponding wrapper class, and for non-primitive classes it should be the class of what the array is an array of. Alternatively, the base column info may have a null content class, in which case the column info for the new column will be set appropriately from the data array.- Parameters:
base- the column info on which to base this column's infodata- an array of primitives or objects which will form the storage for this column- Throws:
IllegalArgumentException- if data isn't an array or base.getContentClass() is incompatible with data
-
makeColumn
Constructs a new ArrayColumn based on a given data array. This convenience method results in a column with no metadata other than the column name and its data type. The data type is inferred from the type of the array object supplied.- Parameters:
name- the name of the new columndata- an array of primitives or objects which will form the storage for this column
-