public class TableBuilder extends Object
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);
ColumnBuilder
,
IndexBuilder
,
RelationshipBuilder
Constructor and Description |
---|
TableBuilder(String name) |
TableBuilder(String name,
boolean escapeIdentifiers) |
Modifier and Type | Method and Description |
---|---|
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.
|
TableBuilder |
addIndexes(Collection<? extends IndexBuilder> indexes)
Adds the Indexes to the new table.
|
static String |
escapeIdentifier(String s) |
TableBuilder |
escapeName()
Escapes the new table's name using
escapeIdentifier(java.lang.String) . |
List<ColumnBuilder> |
getColumns() |
List<IndexBuilder> |
getIndexes() |
String |
getName() |
Map<String,PropertyMap.Property> |
getProperties() |
static boolean |
isReservedWord(String s) |
TableBuilder |
putProperty(String name,
DataType type,
Object value)
Sets the table property with the given name and type to the given value.
|
TableBuilder |
putProperty(String name,
Object value)
Sets the table property with the given name to the given value.
|
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.
|
public TableBuilder(String name)
public TableBuilder(String name, boolean escapeIdentifiers)
public String getName()
public TableBuilder addColumn(ColumnBuilder column)
public TableBuilder addColumns(Collection<? extends ColumnBuilder> columns)
public List<ColumnBuilder> getColumns()
public TableBuilder addIndex(IndexBuilder index)
public TableBuilder addIndexes(Collection<? extends IndexBuilder> indexes)
public List<IndexBuilder> getIndexes()
public TableBuilder setEscapeIdentifiers(boolean escapeIdentifiers)
public TableBuilder setPrimaryKey(String... colNames)
public TableBuilder escapeName()
escapeIdentifier(java.lang.String)
.public TableBuilder putProperty(String name, Object value)
PropertyMap.put(String,Object)
for details on determining the
property type).public TableBuilder putProperty(String name, DataType type, Object value)
public Map<String,PropertyMap.Property> getProperties()
public Table toTable(Database db) throws IOException
IOException
public static String escapeIdentifier(String s)
public static boolean isReservedWord(String s)
true
if the given string is a reserved word,
false
otherwiseCopyright © 2005–2024 OpenHMS. All rights reserved.