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 anArrayColumnobject 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 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 theisWritablemethod returns true. The implementation in theColumnDataclass throws anUnsupportedOperationException.- 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 anArrayColumnobject 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 ifinfodescribes a primitive type.- Parameters:
base- the templateColumnInfo- note this is not the actual ColumnInfo object which will be returned by thegetColumnInfomethod of the returnedArrayColumnrowCount- the number of rows it is to hold- Returns:
- a new
ArrayColumnbased onbasewith storage forrowCountelements
-
makeColumn
Constructs a new ArrayColumn based on a given data array. ThecontentClassof the given base column info must be compatible with the supplied data array; in the case of a primitivedataarray 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, thebasecolumn info may have anullcontent 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- ifdataisn'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
-