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.boolean
Returns true, since this class can store cell values.static ArrayColumn
makeColumn
(String name, Object data) Constructs a new ArrayColumn based on a given data array.static ArrayColumn
makeColumn
(ColumnInfo base, long rowCount) Obtains anArrayColumn
object based on a template object with a given number of rows.static ArrayColumn
makeColumn
(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.void
storeValue
(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:
isWritable
in classColumnData
- Returns:
- true
-
storeValue
Description copied from class:ColumnData
Stores a given value in a given row for this column. Will only work if theisWritable
method returns true. The implementation in theColumnData
class throws anUnsupportedOperationException
.- Overrides:
storeValue
in classColumnData
- Parameters:
lrow
- the row to store it inval
- the object to store
-
readValue
Description copied from class:ColumnData
Returns the value stored at a given row in this column.- Specified by:
readValue
in 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 anArrayColumn
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 ifinfo
describes a primitive type.- Parameters:
base
- the templateColumnInfo
- note this is not the actual ColumnInfo object which will be returned by thegetColumnInfo
method of the returnedArrayColumn
rowCount
- the number of rows it is to hold- Returns:
- a new
ArrayColumn
based onbase
with storage forrowCount
elements
-
makeColumn
Constructs a new ArrayColumn based on a given data array. ThecontentClass
of the given base column info must be compatible with the supplied data array; in the case of a primitivedata
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, thebase
column info may have anull
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
- ifdata
isn't an array orbase.getContentClass()
is incompatible withdata
-
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
-