com.onewebsql.query
Class TableExpression

java.lang.Object
  extended by com.onewebsql.query.TableExpression
All Implemented Interfaces:
Expression, TableReference

public class TableExpression
extends Object
implements TableReference

Represents a table expression (a table or a view).


Field Summary
protected  List<Column> blobColumns
          The list of all BLOB columns of this table expression.
protected  List<Column> clobColumns
          The list of all CLOB columns of this table expression.
protected  List<Column> columns
          The list of all non-BLOB and non-CLOB columns of this table expression.
protected  String name
          Name of the table expression
protected  List<Column> primaryKeyColumns
          The list of primary key columns of this table expression.
protected  String schemaName
          Name of the schema this table expression belongs to, it takes priority over the schema name specified as a parameter of build(StringBuilder, String, List, DBAdapter) method.
static String SEQUENCE_SUFFIX
          Standard suffix appended to the name of the table to get the name of the corresponding sequence.
protected  String sequenceName
          Name of the sequence of this table expression.
 
Fields inherited from interface com.onewebsql.query.Expression
COMMA, DOT, LB, QUESTION_MARK, RB, SPACE
 
Constructor Summary
TableExpression(String name)
          Constructor.
TableExpression(String name, String sequenceName)
          Constructor.
 
Method Summary
 void addBlobColumn(Column column)
          Adds the specified column to the list of BLOB columns of this table expression.
 Column addBlobColumn(String columnName, int jdbcType)
          Adds a column with the specified name and JDBC type to the list of BLOB columns of this table expression.
 void addClobColumn(Column column)
          Adds a CLOB column to this table expression.
 Column addClobColumn(String columnName, int jdbcType)
          Adds a column with the specified name and JDBC type to the list of CLOB columns of this table expression.
 void addColumn(Column column)
          Adds a column to the list of this table expression columns.
 Column addColumn(String columnName, int jdbcType)
          Adds a column with the specified name and JDBC type to his table expression columns.
 void build(StringBuilder sb, String schemaName, List<Value> objs, DBAdapter adapter)
          Builds the text of the query (or a part of it) represented by this object.
 boolean equals(Object obj)
           
protected static Column findColumn(Collection<Column> collection, String name)
          Searches for a column of the specified name in the specified collection.
 List<Column> getBlobColumns()
          Returns the list of BLOB columns of this table expression.
 List<Column> getClobColumns()
          Returns the list of CLOB columns of this table expression.
 Column getColumn(String name)
          Returns the column with the specified name, it searches for the column among all columns, including BLOB and CLOB columns.
 List<Column> getColumns()
          Returns the list of columns of this table expression.
 String getName()
          Returns the name of the table expression
 List<Column> getPrimaryKeyColumns()
          Returns the list of columns of this table's primary key.
 String getSequenceName()
          Returns the name of the sequence associated with this table expression.
 int hashCode()
           
 void setBlobColumns(List<Column> blobColumns)
          Sets the list of all BLOB columns of this table expression.
 void setClobColumns(List<Column> clobColumns)
          Sets the list of all CLOB columns of this table expression.
 void setColumns(List<Column> columns)
          Sets the list of all non-BLOB and non-CLOB columns of this table expression
 void setName(String name)
          Sets the name of the table expression.
 void setPrimaryKeyColumns(List<Column> primaryKeyColumns)
          Sets the list of columns of this table's primary key.
 TableExpression setSchema(String schemaName)
          Sets the schema of the table expression.
 void setSequenceName(String sequenceName)
          Sets the name of the sequence associated with this table expression.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEQUENCE_SUFFIX

public static final String SEQUENCE_SUFFIX
Standard suffix appended to the name of the table to get the name of the corresponding sequence.

See Also:
Constant Field Values

name

protected String name
Name of the table expression


columns

protected List<Column> columns
The list of all non-BLOB and non-CLOB columns of this table expression.


blobColumns

protected List<Column> blobColumns
The list of all BLOB columns of this table expression.


clobColumns

protected List<Column> clobColumns
The list of all CLOB columns of this table expression.


sequenceName

protected String sequenceName
Name of the sequence of this table expression.


primaryKeyColumns

protected List<Column> primaryKeyColumns
The list of primary key columns of this table expression.


schemaName

protected String schemaName
Name of the schema this table expression belongs to, it takes priority over the schema name specified as a parameter of build(StringBuilder, String, List, DBAdapter) method.

Constructor Detail

TableExpression

public TableExpression(String name)
Constructor.

Parameters:
name - name of the table expression

TableExpression

public TableExpression(String name,
                       String sequenceName)
Constructor.

Parameters:
name - name of the table expression
sequenceName - name of the sequence
Method Detail

getName

public String getName()
Returns the name of the table expression

Returns:
name of the table expression

setName

public void setName(String name)
Sets the name of the table expression.

Parameters:
name - name of the table expression

getColumns

public List<Column> getColumns()
Description copied from interface: TableReference
Returns the list of columns of this table expression.

Specified by:
getColumns in interface TableReference
Returns:
list of columns of this table expression

addColumn

public void addColumn(Column column)
Adds a column to the list of this table expression columns.

Parameters:
column - column

addColumn

public Column addColumn(String columnName,
                        int jdbcType)
Adds a column with the specified name and JDBC type to his table expression columns.

Parameters:
columnName - name of the column
jdbcType - JDBC type
Returns:
added column

setColumns

public void setColumns(List<Column> columns)
Sets the list of all non-BLOB and non-CLOB columns of this table expression

Parameters:
columns - list of columns of this table expression

getBlobColumns

public List<Column> getBlobColumns()
Returns the list of BLOB columns of this table expression.

Returns:
list of BLOB columns of this table expression.

addBlobColumn

public void addBlobColumn(Column column)
Adds the specified column to the list of BLOB columns of this table expression.

Parameters:
column - BLOB column

addBlobColumn

public Column addBlobColumn(String columnName,
                            int jdbcType)
Adds a column with the specified name and JDBC type to the list of BLOB columns of this table expression.

Parameters:
columnName - name of the column
jdbcType - JDBC type
Returns:
added column

setBlobColumns

public void setBlobColumns(List<Column> blobColumns)
Sets the list of all BLOB columns of this table expression.

Parameters:
blobColumns - list of all BLOB columns of this table expression

getClobColumns

public List<Column> getClobColumns()
Returns the list of CLOB columns of this table expression.

Returns:
list of CLOB columns of this table expression.

addClobColumn

public void addClobColumn(Column column)
Adds a CLOB column to this table expression.

Parameters:
column - CLOB column to add.

addClobColumn

public Column addClobColumn(String columnName,
                            int jdbcType)
Adds a column with the specified name and JDBC type to the list of CLOB columns of this table expression.

Parameters:
columnName - name of the column
jdbcType - JDBC type
Returns:
added column

setClobColumns

public void setClobColumns(List<Column> clobColumns)
Sets the list of all CLOB columns of this table expression.

Parameters:
clobColumns - list of all CLOB columns of this table expression

build

public void build(StringBuilder sb,
                  String schemaName,
                  List<Value> objs,
                  DBAdapter adapter)
Description copied from interface: Expression
Builds the text of the query (or a part of it) represented by this object.

Specified by:
build in interface Expression
Parameters:
sb - StringBuilder to build the query text
schemaName - name of the database schema used to build the query
objs - an accumulator list to which query parameters are appended
adapter - database adapter which builds builds query in a way specific to the database engine

getSequenceName

public String getSequenceName()
Returns the name of the sequence associated with this table expression.

Returns:
name of the sequence

setSequenceName

public void setSequenceName(String sequenceName)
Sets the name of the sequence associated with this table expression.

Parameters:
sequenceName - name of the sequence

getPrimaryKeyColumns

public List<Column> getPrimaryKeyColumns()
Returns the list of columns of this table's primary key.

Returns:
list of columns of this table's primary key.

setPrimaryKeyColumns

public void setPrimaryKeyColumns(List<Column> primaryKeyColumns)
Sets the list of columns of this table's primary key.

Parameters:
primaryKeyColumns - list of columns

getColumn

public Column getColumn(String name)
Returns the column with the specified name, it searches for the column among all columns, including BLOB and CLOB columns.

Parameters:
name - name of the column
Returns:
column with the specified name

setSchema

public TableExpression setSchema(String schemaName)
Sets the schema of the table expression. It creates and return a new table expression with the specified schema name. The columns of the new table expression (including BLOB and CLOB columns, and primary key columns) have the new table expression as its owner.

Parameters:
schemaName - name of the schema
Returns:
new table expression with the specified schema

findColumn

protected static Column findColumn(Collection<Column> collection,
                                   String name)
Searches for a column of the specified name in the specified collection.

Parameters:
collection - collection of Column objects
name - name of the column
Returns:
the column or null if the column was not found

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011-2013 e-point SA. All Rights Reserved.