com.healthmarketscience.jackcess
Class TableBuilder

java.lang.Object
  extended by com.healthmarketscience.jackcess.TableBuilder

public class TableBuilder
extends Object

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);
 

Author:
James Ahlborn
Usage:
General: This class is general use.

Constructor Summary
TableBuilder(String name)
           
TableBuilder(String name, boolean escapeIdentifiers)
           
 
Method Summary
 TableBuilder addColumn(ColumnBuilder column)
          Adds a Column to the new table.
 TableBuilder addColumns(Collection<? extends ColumnBuilder> columns)
          Adds the Columns to the new table.
 TableBuilder addIndex(IndexBuilder index)
          Adds an IndexBuilder to the new table.
static String escapeIdentifier(String s)
           
 TableBuilder escapeName()
          Escapes the new table's name using escapeIdentifier(java.lang.String).
static boolean isReservedWord(String s)
           
 TableBuilder setEscapeIdentifiers(boolean escapeIdentifiers)
          Sets whether or not subsequently added columns will have their names automatically escaped
 TableBuilder setPrimaryKey(String... colNames)
          Sets the names of the primary key columns for this table.
 Table toTable(Database db)
          Creates a new Table in the given Database with the currently configured attributes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableBuilder

public TableBuilder(String name)

TableBuilder

public TableBuilder(String name,
                    boolean escapeIdentifiers)
Method Detail

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.


addIndex

public TableBuilder addIndex(IndexBuilder index)
Adds an IndexBuilder to the new table.


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 using escapeIdentifier(java.lang.String).


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:
true if the given string is a reserved word, false otherwise
Usage:
General: This method is general use.


Copyright © 2005-2013 Health Market Science. All Rights Reserved.