APIdia Launch Partner
Top Description Inners Fields Constructors Methods
io.github.spannm.jackcess

public Class TableBuilder

extends Object
Class Inheritance
Annotations
@SuppressWarnings:PMD.FieldDeclarationsShouldBeAtStartOfClass
Imports
io.github.spannm.jackcess.impl.DatabaseImpl, .PropertyMapImpl, .TableCreator, io.github.spannm.jackcess.util.ToStringBuilder, java.io.IOException, java.util.ArrayList, .Arrays, .Collection, .Collections, .HashMap, .HashSet, .List, .Locale, .Map, .Set

Builder style class for constructing a Table.

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);
See Also
ColumnBuilder, IndexBuilder, RelationshipBuilder

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final List<ColumnBuilder>
columns

columns for the new table

private static final String
ESCAPE_PREFIX

Prefix for column or table names that are reserved words

private boolean
escapeIdentifiers

whether or not table/column/index names are automatically escaped

private final List<IndexBuilder>
indexes

indexes for the new table

private String
name

name of the new table

private Map<String, PropertyMap.Property>
props

table properties (if any)

Constructor Summary

AccessConstructor and Description
public
public
TableBuilder(String name, boolean escapeIdentifiers)

Method Summary

Modifier and TypeMethod and Description
public TableBuilder
addColumn(ColumnBuilder column)

Adds a Column to the new table.

public TableBuilder
addColumns(Collection<? extends ColumnBuilder> newColumns)

Adds the Columns to the new table.

public TableBuilder
addIndex(IndexBuilder index)

Adds an IndexBuilder to the new table.

public TableBuilder
addIndexes(Collection<? extends IndexBuilder> newIndexes)

Adds the Indexes to the new table.

public static String

Returns:

A table or column name escaped for Access
escapeIdentifier
(String s)

Returns a table or column name escaped for Access.

public TableBuilder
escapeName()

Escapes the new table's name using TableBuilder#escapeIdentifier.

public List<ColumnBuilder>
public List<IndexBuilder>
public String
public Map<String, PropertyMap.Property>
public static boolean

Returns:

true if the given string is a reserved word, false otherwise
isReservedWord
(String s)

Returns true if the given string is a reserved word, false otherwise.

public TableBuilder
putProperty(String propName, Object value)

Sets the table property with the given name to the given value.

public TableBuilder
putProperty(String propName, DataType propType, Object value)

Sets the table property with the given name and type to the given value.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Table
toTable(Database db)

Creates a new Table in the given Database with the currently configured attributes.

public TableBuilder
withEscapeIdentifiers(boolean newEscapeIdentifiers)

Sets whether or not subsequently added columns will have their names automatically escaped

public TableBuilder
withPrimaryKey(String... colNames)

Sets the names of the primary key columns for this table.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

columnsback to summary
private final List<ColumnBuilder> columns

columns for the new table

ESCAPE_PREFIXback to summary
private static final String ESCAPE_PREFIX

Prefix for column or table names that are reserved words

escapeIdentifiersback to summary
private boolean escapeIdentifiers

whether or not table/column/index names are automatically escaped

indexesback to summary
private final List<IndexBuilder> indexes

indexes for the new table

nameback to summary
private String name

name of the new table

propsback to summary
private Map<String, PropertyMap.Property> props

table properties (if any)

Constructor Detail

TableBuilderback to summary
public TableBuilder(String name)
TableBuilderback to summary
public TableBuilder(String name, boolean escapeIdentifiers)

Method Detail

addColumnback to summary
public TableBuilder addColumn(ColumnBuilder column)

Adds a Column to the new table.

addColumnsback to summary
public TableBuilder addColumns(Collection<? extends ColumnBuilder> newColumns)

Adds the Columns to the new table.

addIndexback to summary
public TableBuilder addIndex(IndexBuilder index)

Adds an IndexBuilder to the new table.

addIndexesback to summary
public TableBuilder addIndexes(Collection<? extends IndexBuilder> newIndexes)

Adds the Indexes to the new table.

escapeIdentifierback to summary
public static String escapeIdentifier(String s)

Returns a table or column name escaped for Access.

Returns:String

A table or column name escaped for Access

escapeNameback to summary
public TableBuilder escapeName()

Escapes the new table's name using TableBuilder#escapeIdentifier.

getColumnsback to summary
public List<ColumnBuilder> getColumns()
getIndexesback to summary
public List<IndexBuilder> getIndexes()
getNameback to summary
public String getName()
getPropertiesback to summary
public Map<String, PropertyMap.Property> getProperties()
isReservedWordback to summary
public static boolean isReservedWord(String s)

Returns true if the given string is a reserved word, false otherwise.

Returns:boolean

true if the given string is a reserved word, false otherwise

putPropertyback to summary
public TableBuilder putProperty(String propName, Object value)

Sets the table property with the given name to the given value. Attempts to determine the type of the property (see PropertyMap#put(String, Object) for details on determining the property type).

putPropertyback to summary
public TableBuilder putProperty(String propName, DataType propType, Object value)

Sets the table property with the given name and type to the given value.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
toTableback to summary
public Table toTable(Database db) throws IOException

Creates a new Table in the given Database with the currently configured attributes.

withEscapeIdentifiersback to summary
public TableBuilder withEscapeIdentifiers(boolean newEscapeIdentifiers)

Sets whether or not subsequently added columns will have their names automatically escaped

withPrimaryKeyback to summary
public TableBuilder withPrimaryKey(String... colNames)

Sets the names of the primary key columns for this table. Convenience method for creating a primary key index on a table.

io.github.spannm.jackcess back to summary

private final Class TableBuilder.ReservedWords

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final Set<String>
VALUES

All of the reserved words in Access that should be escaped when creating table or column names

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

VALUESback to summary
private static final Set<String> VALUES

All of the reserved words in Access that should be escaped when creating table or column names

Constructor Detail

ReservedWordsback to summary
private ReservedWords()