uk.ac.starlink.table
Class ArrayColumn

java.lang.Object
  extended by uk.ac.starlink.table.ColumnData
      extended by 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
 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(ColumnInfo base, long rowCount)
          Obtains an ArrayColumn 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.
static ArrayColumn makeColumn(String name, Object data)
          Constructs a new ArrayColumn based on a given data array.
 Object 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isWritable

public boolean isWritable()
Returns true, since this class can store cell values.

Overrides:
isWritable in class ColumnData
Returns:
true

storeValue

public void storeValue(long lrow,
                       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 class ColumnData
Parameters:
lrow - the row to store it in
val - the object to store

readValue

public Object readValue(long lrow)
Description copied from class: ColumnData
Returns the value stored at a given row in this column.

Specified by:
readValue in class ColumnData
Parameters:
lrow - the row from which to retrieve the value
Returns:
the value stored at irow

getArray

public 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 ArrayColumn
rowCount - 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,
                                     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 info
data - 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

public static ArrayColumn makeColumn(String name,
                                     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 column
data - an array of primitives or objects which will form the storage for this column


Copyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.