Package ca.spatial.table
Class AppendStoreBuilder
java.lang.Object
ca.spatial.table.AppendStoreBuilder
This class provides a simpler way to set up an
AppendStore
than by using the ApendStore constructor.
Use this class by first repeatedly calling the addColumn(java.lang.String, java.lang.String, int, int)
method to define the columns of interest. Then repeatedly call
the addTable(ca.spatial.table.AttributeStore, java.lang.String, int, java.lang.String[])
method to add the tables to be appended
as well as the way the columns should be populated with data
from each table. Finally, call the build()
method to
generate the table.
An example of using this class is as follows:
appendStores = new AppendStoreBuilder(); /* Add the column definitions */ appendStores.addColumn("Scenario", "C", 6, 0); appendStores.addColumn("PLANFU", "C", 6, 0); appendStores.addColumn("SI", "C", 8, 0); appendStores.addColumn("HECTARES", "N", 8, 2); appendStores.addColumn("AV_STKG", "N", 6, 4); appendStores.addColumn("AV_SC", "N", 6, 4); /* * Add the definition for the first table to be appended. * The definition consists of a reference to the source table, * a reselect expression, the period of interest, * and a list of expressions that will be used to calculate * the column data for this table. */ appendStores.addTable(table1, "true", 0, new String[] { "'Scenario1'", "PLANFU", "Scenario", "Shape_Area/10000", "STKG/Shape_Area", "SC/Shape_Area" }); /* Add the definition for the second table to be appended. */ appendStores.addTable(table2, "true", 0, new String[] { "'Scenario2'", "FU", "ScenName", "Area/10000", "STKG/Area", "SC/Area" }); /* Build the appended table */ appData = appendStores.build(); /* Show the appended table */ appData.showTable(true);The above example will create a new virtual table that refects the appended inputs. The output table will show 6 columns, and the values in the output will be transformed from the input according to expressions in each of the addTable methods.
Note that the data in the resulting append store is reflected from the source tables. The orginal tables must remain open and accessible so long as the AppendStore is being used.
- See Also:
AppendStore
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor does not require any argumentsAppendStoreBuilder(AttributeStore prototype)
This contstructor will copy the attribute structure from the prototype table -
Method Summary
Modifier and TypeMethodDescriptionaddColumn(AttributeFormat af)
Add a column definition.Add a column definition.addTable(AttributeStore store, String[] exprs)
Add a table definition.addTable(AttributeStore store, String reselect, int period, String[] exprs)
Add a table definition.build()
This method will construct an AppendStore object based on the columns and tables that have been specified.int
Return the number of defined columnsgetColumnSpec(int i)
Return a column definitiongetTable(int i)
Return a table definitionString[]
getTableColumns(int i)
Return the column expressions for a tableint
Return the number of defined tablesint
getTablePeriod(int i)
Return the period of interest a tablegetTableReselect(int i)
Return the reselect expression used for a table
-
Constructor Details
-
AppendStoreBuilder
public AppendStoreBuilder()The default constructor does not require any arguments -
AppendStoreBuilder
This contstructor will copy the attribute structure from the prototype table- Parameters:
prototype
- A reference to a table that will provide the colummns to be used
-
-
Method Details
-
addColumn
Add a column definition. All column definitions must be completed prior to adding table definitions.- Parameters:
name
- the name to be used for the columntype
- the data type, which may be C, I, N or L (String, Integer, Number, Boolean)width
- the field width to be used on outputdec
- the number of digits of precision after the decimal place, used on output
-
addColumn
Add a column definition. All column definitions must be completed prior to adding table definitions.- Parameters:
name
- the name to be used for the columntype
- the data type, as taken from theAttributeFormat
class. Valid types are INTEGER, NUMBER, BOOLEAN and STRING.width
- the field width to be used on outputdec
- the number of digits of precision after the decimal place, used on output
-
addColumn
-
getColumnCount
public int getColumnCount()Return the number of defined columns -
getColumnSpec
Return a column definition -
addTable
public AppendStoreBuilder addTable(AttributeStore store, String reselect, int period, String[] exprs)Add a table definition. All column definitions must be completed prior to adding table definitions.- Parameters:
store
- A reference to the atttribute store for this tablereselect
- A reselect expression to limit the number of records included from the table. This may be null to include all records.period
- The period to evaluate the expression in.exprs
- An array of expressions represent the data to populate in to the columns of the AppendStore. The expression may use any of the columns from the input table. This parameter amy be null, or any of the array values may be null, in which case the corresponding colymn name will be used as the expression.
-
addTable
Add a table definition. All column definitions must be completed prior to adding table definitions.- Parameters:
store
- A reference to the atttribute store for this tableexprs
- An array of expressions represent the data to populate in to the columns of the AppendStore. The expression may use any of the columns from the input table. This parameter amy be null, or any of the array values may be null, in which case the corresponding colymn name will be used as the expression.
-
getTableCount
public int getTableCount()Return the number of defined tables -
getTable
Return a table definition- Parameters:
i
- The table number of interest
-
getTableColumns
Return the column expressions for a table- Parameters:
i
- The table number of interest
-
getTablePeriod
public int getTablePeriod(int i)Return the period of interest a table- Parameters:
i
- The table number of interest
-
getTableReselect
Return the reselect expression used for a table- Parameters:
i
- The table number of interest
-
build
This method will construct an AppendStore object based on the columns and tables that have been specified.
-