Package uk.ac.starlink.table
Class BeanStarTable
- java.lang.Object
-
- uk.ac.starlink.table.AbstractStarTable
-
- uk.ac.starlink.table.RandomStarTable
-
- uk.ac.starlink.table.BeanStarTable
-
- All Implemented Interfaces:
StarTable
public class BeanStarTable extends RandomStarTable
StarTable which displays beans. The table is constructed to display beans of a particular class, and each of its rows displays one instance of this class. It has a column for each readable property. As usual, a bean is anything which has likely-looking getter methods, though since this class uses the java.beans package any cleverer stuff held in BeanInfos will get used as well/instead.- Since:
- 23 Dec 2004
- Author:
- Mark Taylor (Starlink)
-
-
Constructor Summary
Constructors Constructor Description BeanStarTable(java.lang.Class<?> clazz)Constructs a new table which will hold beans which are all instances of a given class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetCell(long irow, int icol)The AbstractStarTable implementation of this method throws an UnsupportedOperationException, since unless otherwise provided there is no random access.intgetColumnCount()Returns the number of columns in this table.ColumnInfogetColumnInfo(int icol)Returns the object describing the data in a given column.java.lang.String[]getColumnProperties()Returns an array of the property names which correspond to the columns of this table.java.lang.Object[]getData()Returns the array of objects which this model displays, one per row.longgetRowCount()The number of rows in this table.voidsetColumnInfo(java.lang.String name, ValueInfo info)Resets the metadata for a column representing a property with a given name.voidsetColumnProperties(java.lang.String[] propNames)Fixes the columns which are to be used for this table.voidsetData(java.lang.Object[] data)Populates this model with items.-
Methods inherited from class uk.ac.starlink.table.RandomStarTable
getRowSequence, isRandom
-
Methods inherited from class uk.ac.starlink.table.AbstractStarTable
checkedLongToInt, getColumnAuxDataInfos, getName, getParameterByName, getParameters, getRow, getURL, setName, setParameter, setParameters, setURL
-
-
-
-
Constructor Detail
-
BeanStarTable
public BeanStarTable(java.lang.Class<?> clazz) throws java.beans.IntrospectionExceptionConstructs a new table which will hold beans which are all instances of a given class.- Parameters:
clazz- class of which all beans held by this table are members- Throws:
java.beans.IntrospectionException
-
-
Method Detail
-
setData
public void setData(java.lang.Object[] data)
Populates this model with items.- Parameters:
data- array of items, one for each row. This array's runtime type must match that for which this model was constructed (on pain of ClassCastException)
-
getData
public java.lang.Object[] getData()
Returns the array of objects which this model displays, one per row. The runtime type of the returned array matches that of the bean class this model displays.- Returns:
- table data
-
getRowCount
public long getRowCount()
Description copied from class:RandomStarTableThe number of rows in this table. Implementations must supply a non-negative return value.- Specified by:
getRowCountin interfaceStarTable- Specified by:
getRowCountin classRandomStarTable- Returns:
- the number of rows in the table
-
getColumnCount
public int getColumnCount()
Description copied from interface:StarTableReturns the number of columns in this table.- Specified by:
getColumnCountin interfaceStarTable- Specified by:
getColumnCountin classAbstractStarTable- Returns:
- the number of columns
-
getColumnInfo
public ColumnInfo getColumnInfo(int icol)
Description copied from interface:StarTableReturns the object describing the data in a given column.- Specified by:
getColumnInfoin interfaceStarTable- Specified by:
getColumnInfoin classAbstractStarTable- Parameters:
icol- the column for which header information is required- Returns:
- a ValueInfo object for column icol
-
setColumnInfo
public void setColumnInfo(java.lang.String name, ValueInfo info)Resets the metadata for a column representing a property with a given name.- Parameters:
name- property's programmatic nameinfo- new column metadata
-
getColumnProperties
public java.lang.String[] getColumnProperties()
Returns an array of the property names which correspond to the columns of this table.- Returns:
- array of strings giving programmatic names of bean properties, one for each table column
-
setColumnProperties
public void setColumnProperties(java.lang.String[] propNames)
Fixes the columns which are to be used for this table.propNamesis an array of the programmatic names of each of the properties of this bean which is used to get a column value.- Parameters:
propNames- array of programmatic names of properties to be used as columns
-
getCell
public java.lang.Object getCell(long irow, int icol) throws java.io.IOExceptionDescription copied from class:AbstractStarTableThe AbstractStarTable implementation of this method throws an UnsupportedOperationException, since unless otherwise provided there is no random access.- Specified by:
getCellin interfaceStarTable- Overrides:
getCellin classAbstractStarTable- Parameters:
irow- the index of the cell's rowicol- the index of the cell's column- Returns:
- the contents of this cell
- Throws:
java.io.IOException- if there is an error reading the data
-
-