org.jboss.dna.graph.query.validate
Class ImmutableSchemata.Builder

java.lang.Object
  extended by org.jboss.dna.graph.query.validate.ImmutableSchemata.Builder
Enclosing class:
ImmutableSchemata

@NotThreadSafe
public static class ImmutableSchemata.Builder
extends Object

A builder of immutable Schemata objects.


Method Summary
 ImmutableSchemata.Builder addColumn(String tableName, String columnName, String type)
          Add a column with the supplied name and type to the named table.
 ImmutableSchemata.Builder addColumn(String tableName, String columnName, String type, boolean fullTextSearchable)
          Add a column with the supplied name and type to the named table.
 ImmutableSchemata.Builder addKey(String tableName, String... columnNames)
          Add to the specified table a key that references the existing named columns.
 ImmutableSchemata.Builder addTable(String name, String... columnNames)
          Add a table with the supplied name and column names.
 ImmutableSchemata.Builder addTable(String name, String[] columnNames, String[] types)
          Add a table with the supplied name and column names and types.
 ImmutableSchemata.Builder addView(String name, QueryCommand definition)
          Add a view with the supplied name and definition.
 ImmutableSchemata.Builder addView(String name, String definition)
          Add a view with the supplied name and SQL string definition.
 Schemata build()
          Build the Schemata instance, using the current state of the builder.
 ImmutableSchemata.Builder makeSearchable(String tableName, String columnName)
          Make sure the column on the named table is searchable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addTable

public ImmutableSchemata.Builder addTable(String name,
                                          String... columnNames)
Add a table with the supplied name and column names. Each column will be given a default type. The table will also overwrite any existing table definition with the same name.

Parameters:
name - the name of the new table
columnNames - the names of the columns.
Returns:
this builder, for convenience in method chaining; never null
Throws:
IllegalArgumentException - if the table name is null or empty, any column name is null or empty, or if no column names are given

addTable

public ImmutableSchemata.Builder addTable(String name,
                                          String[] columnNames,
                                          String[] types)
Add a table with the supplied name and column names and types. The table will also overwrite any existing table definition with the same name.

Parameters:
name - the name of the new table
columnNames - the names of the columns
types - the types for the columns
Returns:
this builder, for convenience in method chaining; never null
Throws:
IllegalArgumentException - if the table name is null or empty, any column name is null or empty, if no column names are given, or if the number of types does not match the number of columns

addView

public ImmutableSchemata.Builder addView(String name,
                                         String definition)
Add a view with the supplied name and SQL string definition. The column names and types will be inferred from the source table(s) and views(s) used in the definition.

Parameters:
name - the name of the new view
definition - the SQL definition of the view
Returns:
this builder, for convenience in method chaining; never null
Throws:
IllegalArgumentException - if the view name is null or empty or the definition is null
ParsingException - if the supplied definition is cannot be parsed as a SQL query

addView

public ImmutableSchemata.Builder addView(String name,
                                         QueryCommand definition)
Add a view with the supplied name and definition. The column names and types will be inferred from the source table(s) used in the definition.

Parameters:
name - the name of the new view
definition - the definition of the view
Returns:
this builder, for convenience in method chaining; never null
Throws:
IllegalArgumentException - if the view name is null or empty or the definition is null

addColumn

public ImmutableSchemata.Builder addColumn(String tableName,
                                           String columnName,
                                           String type)
Add a column with the supplied name and type to the named table. Any existing column with that name will be replaced with the new column. If the table does not yet exist, it will be added.

Parameters:
tableName - the name of the new table
columnName - the names of the column
type - the type for the column
Returns:
this builder, for convenience in method chaining; never null
Throws:
IllegalArgumentException - if the table name is null or empty, any column name is null or empty, if no column names are given, or if the number of types does not match the number of columns

addColumn

public ImmutableSchemata.Builder addColumn(String tableName,
                                           String columnName,
                                           String type,
                                           boolean fullTextSearchable)
Add a column with the supplied name and type to the named table. Any existing column with that name will be replaced with the new column. If the table does not yet exist, it will be added.

Parameters:
tableName - the name of the new table
columnName - the names of the column
type - the type for the column
fullTextSearchable - true if the column should be full-text searchable, or false if not
Returns:
this builder, for convenience in method chaining; never null
Throws:
IllegalArgumentException - if the table name is null or empty, the column name is null or empty, or if the property type is null

makeSearchable

public ImmutableSchemata.Builder makeSearchable(String tableName,
                                                String columnName)
Make sure the column on the named table is searchable.

Parameters:
tableName - the name of the new table
columnName - the names of the column
Returns:
this builder, for convenience in method chaining; never null
Throws:
IllegalArgumentException - if the table name is null or empty or if the column name is null or empty

addKey

public ImmutableSchemata.Builder addKey(String tableName,
                                        String... columnNames)
Add to the specified table a key that references the existing named columns.

Parameters:
tableName - the name of the new table
columnNames - the names of the (existing) columns that make up the key
Returns:
this builder, for convenience in method chaining; never null
Throws:
IllegalArgumentException - if the table name is null or empty, the array of column names is null or empty, or if the column names do not reference existing columns in the table

build

public Schemata build()
Build the Schemata instance, using the current state of the builder. This method creates a snapshot of the tables (with their columns) as they exist at the moment this method is called.

Returns:
the new Schemata; never null
Throws:
InvalidQueryException - if any of the view definitions is invalid and cannot be resolved


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.