Class TableSpec
- Direct Known Subclasses:
TableSpec.AppendSpec
,TableSpec.CoverageSpec
,TableSpec.CrosstabSpec
,TableSpec.CSVSpec
,TableSpec.DBaseSpec
,TableSpec.ExcelSpec
,TableSpec.FlattenSpec
,TableSpec.InfoSpec
,TableSpec.JDBCSpec
,TableSpec.RamAttributeStoreSpec
,TableSpec.RelationSpec
,TableSpec.ShapefileSpec
,TableSpec.SnapshotSpec
,TableSpec.SummarySpec
,TableSpec.TransposePeriodSpec
,TableSpec.TransposeRowSpec
,TableSpec.TransposeSpec
,TableSpec.VirtualSpec
A TableSpec is string that describes how to open a dataset. The
open()
method will parse the TableSpec string and return the
opened table.
The thing that makes TableSpec's interesting is that they can be used to compose several tables in ways that otherwise would have to be done with executable script code. For example, the configuration of a relation of several joined tables can be captured as a TableSpec string, and the string can later be used to exactly reconstitute the original configuration.
In addition, TableSpec string can capture optional values, such as the
character encoding. For complex tables, such as CrosstabStore
and
AppendStore
, the TableSpec captures the complete set of parameters
that define the table.
In many case TableSpec strings are not required: the Patchworks code generation wizards will provde BeanShell code that uses the Patchworks API to create the tables. There are some situations, such as providing files to the <curvetable> and <table> elements in the ForestModel where the BeanShell environment is not available, and TableSpec strings make a great replacement.
Usage
Obtain a TableSpec string from any open table:
spec = myTable.getTablespec().toString();
Open a file using a TabeSpec string:
newTable = TableSpec.open(spec);
See the for documentation of each sub classes fo the syntax details of the TableSpec strings. The syntax format used in these sections is
- bare word are required as is
- words in braces are to be substituted with the appropriate value
- symbols followed by a question mark are optional and may be excluded
- symbols followed by ... may be repeated as neccesary
- values that have embedded blanks must be enclosed in double quotes
- the [] characters enclose another TableSpec string, and in this way tables can be composed of other tables. The [] characters are a required part of the syntax.
Relate [blocks.shp] StdID [../analysis/BRU001_initialSchedule_yr1_6.csv] BLOCK
In the above, the keyword Relate identifies the TableSpec type. The first
element within [] characters represents the primary table, StdID represents the
foreign key, the second element within [] represents the secondary table,
and BLOCK represents the primary key.
This relate expression could itself be enclosed within [] characters, and composed in to another TableSpec, and so on.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This specification will describe aAppendStore
tablestatic class
This specification will describe a CoverageGeoRelationalStore
static class
This specification will describe aCrosstabStore
tablestatic class
This specification will describe aCSVStore
table.static class
This specification will describe aDBaseAttributeStore
table.static class
This specification will describe anExcelStore
table.static class
This specification will describe aPeriodFlattenedStore
.static class
This specification will describe anInfoFile
.static class
This specification will describe anJDBCStore
table.static class
This specification will describe a RamAttributeStore that was programmtically created and cannot be instantiated.static class
This specification will describe aRelationalStore
.static class
This specification will describe a ShapefileGeoRelationalStore
.static class
This specification will describe a Snapshot of a table.static class
This specification will describe a Summary tablestatic class
This specification will describe aTransposePeriodTable
table.static class
This specification will describe aTransposeRowTable
.static class
This specification will describe aTransposeTable
.static class
This specification will describe a virtual table that is provided by the software and cannot be instantiated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TableSpec
boolean
Get the unique and unequivocal identifier for thisTableSpec
.abstract String
Get the type of table described by thisTableSpec
.abstract String
Get the name of the table described by thisTableSpec
.static boolean
isDefaultEncoding(String encoding)
boolean
Does this specification describeGeoRelationalStore
data?boolean
isPlain()
Does this specification describe a plain file?abstract AttributeStore
open()
Open the data table described by thisTableSpec
.static AttributeStore
static AttributeStore
Try to find a data set that matches this description in the cache.static String
quoteExprIfRequired(String value)
static String
quoteIfRequired(String value)
toString()
-
Constructor Details
-
TableSpec
public TableSpec()
-
-
Method Details
-
open
Open the data table described by thisTableSpec
.- Throws:
Exception
-
getTableName
Get the name of the table described by thisTableSpec
. -
getFlavour
Get the type of table described by thisTableSpec
. -
isPlain
public boolean isPlain()Does this specification describe a plain file? -
isGeoRelational
public boolean isGeoRelational()Does this specification describeGeoRelationalStore
data? -
getCanonicalName
Get the unique and unequivocal identifier for thisTableSpec
. -
open
Try to find a data set that matches this description in the cache. If it exists then return the handle to the cached version, If it is not already open and in the cache, then try to open it. Don't automatically add it to the cache.- Parameters:
spec
- A file name or table specification.encoding
- The encoding type to be used to open this file. This only applies to some file types (e.g.DBaseAttributeStore
,ShapeStore
,CSVStore
).- Returns:
- A handle to the opened file.
- Throws:
Exception
- An exception if the file cannot be opened.
-
open
- Throws:
Exception
-
decode
- Throws:
Exception
-
isDefaultEncoding
-
equals
-
toString
-
quoteIfRequired
-
quoteExprIfRequired
-