If you want to store tabular data in memory,
possibly to output it using STIL's output facilities,
the easiest way to do it is to use a
RowListStarTable object.
You construct it with information about the kind of value which
will be in each column, and then populate it with data by adding rows.
Normal read/write access is provided via a number of methods,
so you can insert and delete rows, set and get table cells,
and so on.
The following code creates and populates a table containing some information about some astronomical objects:
// Set up information about the columns.
ColumnInfo[] colInfos = new ColumnInfo[ 3 ];
colInfos[ 0 ] = new ColumnInfo( "Name", String.class, "Object name" );
colInfos[ 1 ] = new ColumnInfo( "RA", Double.class, "Right Ascension" );
colInfos[ 2 ] = new ColumnInfo( "Dec", Double.class, "Declination" );
// Construct a new, empty table with these columns.
RowListStarTable astro = new RowListStarTable( colInfos );
// Populate the rows of the table with actual data.
astro.addRow( new Object[] { "Owl nebula",
new Double( 168.63 ), new Double( 55.03 ) } );
astro.addRow( new Object[] { "Whirlpool galaxy",
new Double( 202.43 ), new Double( 47.22 ) } );
astro.addRow( new Object[] { "M108",
new Double( 167.83 ), new Double( 55.68 ) } );