Class DBFWriterSetup
DBFWriter
class can use the
specification created by this class to transform and format a new output
dataset based on the original source.
Use the constructor and the add and drop column methods to add or
remove columns from the specification. Once the specification has
been adjusted use the getDefinitions()
method to retrieve the
specification list. This can then be used with the
DBFWriter.export(String, AttributeStore, ArrayList, int[], int, String, Observer)
method to create a transformed copy of the
dataset. For more precise control use the getWriter(java.lang.String)
method to
create a DBFWriter
object, and write out selected rows using the
DBFWriter.write(int, int)
method.
See the DBFColumnSpec
object for a description of the
parameters for a column specification.
-
Constructor Summary
ConstructorsConstructorDescriptionDBFWriterSetup(AttributeStore source)
Provide a AttributeStore data source.DBFWriterSetup(AttributeStore source, int[] columns)
Provide a AttributeStore data source and a list of column numbers.DBFWriterSetup(AttributeStore source, String[] columns, String[] aliases)
Provide a AttributeStore data source and a list of column names and aliases. -
Method Summary
Modifier and TypeMethodDescriptionAdd a column based on an attribute formataddColumn(AttributeFormat f, String shortTableName)
Add a column based on an attribute format and a short table name.addColumn(DBFColumnSpec spec)
Add a single specification to the list.Add a single specification to the list.Add a single specification to the list.addColumns(String[] specs)
Add a list of specifications.dropColumn(String column)
Drop all columns whose aliases exactly match with the column name.Drop all column specifications from the listdropColumns(String[] columns)
Drop all columns whose aliases exactly match with any of the column names that are providedGet the column specification matching this aliasGet the list of column definitionsstatic DBFColumnSpec
getSpec(Expression ex)
Create a column specification from an Expression objectstatic DBFColumnSpec
Create a column specification from an AttributeFormat objectGet a DBFWriter object based on the current set of column specificationskeepColumns(String[] columns)
Prune out the list of definitions to keep only the definitions whose aliases exactly match the list of columns that are passed in.
-
Constructor Details
-
DBFWriterSetup
Provide a AttributeStore data source. All columns will be added to the initial list.- Parameters:
source
- the data source
-
DBFWriterSetup
Provide a AttributeStore data source and a list of column numbers. Only the columns in the input array will be added to the initial list.- Parameters:
source
- the data sourcecolumns
- an array of column numbers to include
-
DBFWriterSetup
Provide a AttributeStore data source and a list of column names and aliases. Only the columns in the input array will be added to the initial list, along with the aliases.- Parameters:
source
- the data sourcecolumns
- An array of column names to include. These may be column names or expression.aliases
- An array of names to use as column aliases
-
-
Method Details
-
getDefinitions
Get the list of column definitions -
getColumn
Get the column specification matching this alias- Parameters:
alias
- The column name to match
-
keepColumns
Prune out the list of definitions to keep only the definitions whose aliases exactly match the list of columns that are passed in.- Parameters:
columns
- a list of names to keep. These are tested for exact matches with the aliases in the column specifications.
-
dropColumn
Drop all columns whose aliases exactly match with the column name. -
dropColumns
Drop all columns whose aliases exactly match with any of the column names that are provided- Parameters:
columns
- an array of names that are tested against the aliases in the specification list.
-
dropColumns
Drop all column specifications from the list -
addColumn
Add a single specification to the list. The specification is parsed from the string as a comma separated list of name, alias, width, precision, typeSee the
DBFColumnSpec
object for a description of the parameters for a column specification.- Parameters:
spec
- a string have a comma separated list of name, alias, width, precision, type
-
addColumns
Add a list of specifications. The specifications are parsed from each string as a comma separated list of name, alias, width, precision, typeSee the
DBFColumnSpec
object for a description of the parameters for a column specification.- Parameters:
specs
- a array of strings have a comma separated list of name, alias, width, precision, type
-
addColumn
Add a single specification to the list.See the
DBFColumnSpec
object for a description of the parameters for a column specification.- Parameters:
name
- the column name or expressionalias
- the alias for the columnwidth
- the column widthdec
- the number of decimals of precisiontype
- the data type
-
addColumn
Add a single specification to the list.- Parameters:
spec
- The column specification
-
getSpec
Create a column specification from an AttributeFormat object -
getSpec
Create a column specification from an Expression object -
addColumn
Add a column based on an attribute format -
addColumn
Add a column based on an attribute format and a short table name. This is used to disambiguate duplicate column names formed as a result of joins. -
getWriter
Get a DBFWriter object based on the current set of column specifications- Throws:
IOException
ParseException
-