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
public abstract class ArrayColumn extends ColumnData
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getArray()
Returns the array object which holds the array data for this column.boolean
isWritable()
Returns true, since this class can store cell values.static ArrayColumn
makeColumn(java.lang.String name, java.lang.Object data)
Constructs a new ArrayColumn based on a given data array.static ArrayColumn
makeColumn(ColumnInfo base, long rowCount)
Obtains an ArrayColumn object based on a template object with a given number of rows.static ArrayColumn
makeColumn(ColumnInfo base, java.lang.Object data)
Constructs a new ArrayColumn based on a given data array.java.lang.Object
readValue(long lrow)
Returns the value stored at a given row in this column.void
storeValue(long lrow, java.lang.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 Detail
-
isWritable
public boolean isWritable()
Returns true, since this class can store cell values.- Overrides:
isWritable
in classColumnData
- Returns:
- true
-
storeValue
public void storeValue(long lrow, java.lang.Object val)
Description copied from class:ColumnData
Stores 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:
storeValue
in classColumnData
- Parameters:
lrow
- the row to store it inval
- the object to store
-
readValue
public java.lang.Object readValue(long lrow)
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
public java.lang.Object getArray()
Returns the array object which holds the array data for this column.- Returns:
- data array
-
makeColumn
public static ArrayColumn makeColumn(ColumnInfo base, long rowCount)
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
public static ArrayColumn makeColumn(ColumnInfo base, java.lang.Object data)
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:
java.lang.IllegalArgumentException
- if data isn't an array or base.getContentClass() is incompatible with data
-
makeColumn
public static ArrayColumn makeColumn(java.lang.String name, java.lang.Object data)
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
-
-