Package com.healthmarketscience.jackcess
Class TableBuilder
- java.lang.Object
-
- com.healthmarketscience.jackcess.TableBuilder
-
public class TableBuilder extends Object
Builder style class for constructing aTable.Example:
Table table = new TableBuilder("Test") .addColumn(new ColumnBuilder("ID", DataType.LONG) .setAutoNumber(true)) .addColumn(new ColumnBuilder("Name", DataType.TEXT)) .addIndex(new IndexBuilder(IndexBuilder.PRIMARY_KEY_NAME) .addColumns("ID").setPrimaryKey()) .toTable(db);- Author:
- James Ahlborn
- See Also:
ColumnBuilder,IndexBuilder,RelationshipBuilder- Usage:
- General: This class is general use.
-
-
Constructor Summary
Constructors Constructor Description TableBuilder(String name)TableBuilder(String name, boolean escapeIdentifiers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TableBuilderaddColumn(ColumnBuilder column)Adds a Column to the new table.TableBuilderaddColumns(Collection<? extends ColumnBuilder> columns)Adds the Columns to the new table.TableBuilderaddIndex(IndexBuilder index)Adds an IndexBuilder to the new table.TableBuilderaddIndexes(Collection<? extends IndexBuilder> indexes)Adds the Indexes to the new table.static StringescapeIdentifier(String s)TableBuilderescapeName()Escapes the new table's name usingescapeIdentifier(java.lang.String).List<ColumnBuilder>getColumns()List<IndexBuilder>getIndexes()StringgetName()Map<String,PropertyMap.Property>getProperties()static booleanisReservedWord(String s)TableBuilderputProperty(String name, DataType type, Object value)Sets the table property with the given name and type to the given value.TableBuilderputProperty(String name, Object value)Sets the table property with the given name to the given value.TableBuildersetEscapeIdentifiers(boolean escapeIdentifiers)Sets whether or not subsequently added columns will have their names automatically escapedTableBuildersetPrimaryKey(String... colNames)Sets the names of the primary key columns for this table.StringtoString()TabletoTable(Database db)Creates a new Table in the given Database with the currently configured attributes.
-
-
-
Method Detail
-
getName
public String getName()
-
addColumn
public TableBuilder addColumn(ColumnBuilder column)
Adds a Column to the new table.
-
addColumns
public TableBuilder addColumns(Collection<? extends ColumnBuilder> columns)
Adds the Columns to the new table.
-
getColumns
public List<ColumnBuilder> getColumns()
-
addIndex
public TableBuilder addIndex(IndexBuilder index)
Adds an IndexBuilder to the new table.
-
addIndexes
public TableBuilder addIndexes(Collection<? extends IndexBuilder> indexes)
Adds the Indexes to the new table.
-
getIndexes
public List<IndexBuilder> getIndexes()
-
setEscapeIdentifiers
public TableBuilder setEscapeIdentifiers(boolean escapeIdentifiers)
Sets whether or not subsequently added columns will have their names automatically escaped
-
setPrimaryKey
public TableBuilder setPrimaryKey(String... colNames)
Sets the names of the primary key columns for this table. Convenience method for creating a primary key index on a table.
-
escapeName
public TableBuilder escapeName()
Escapes the new table's name usingescapeIdentifier(java.lang.String).
-
putProperty
public TableBuilder putProperty(String name, Object value)
Sets the table property with the given name to the given value. Attempts to determine the type of the property (seePropertyMap.put(String,Object)for details on determining the property type).
-
putProperty
public TableBuilder putProperty(String name, DataType type, Object value)
Sets the table property with the given name and type to the given value.
-
getProperties
public Map<String,PropertyMap.Property> getProperties()
-
toTable
public Table toTable(Database db) throws IOException
Creates a new Table in the given Database with the currently configured attributes.- Throws:
IOException
-
escapeIdentifier
public static String escapeIdentifier(String s)
- Returns:
- A table or column name escaped for Access
- Usage:
- General: This method is general use.
-
isReservedWord
public static boolean isReservedWord(String s)
- Returns:
trueif the given string is a reserved word,falseotherwise- Usage:
- General: This method is general use.
-
-