JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.datasource.util
Class SqlStatement

java.lang.Object
  |
  +--java.util.Observable
        |
        +--com.klg.jclass.datasource.util.SqlStatement
All Implemented Interfaces:
Serializable

public class SqlStatement
extends Observable
implements Serializable

This is the model for an sql statement.

An sql statement has the form,

SELECT qualifier.column(s) [AS] alias(es)
FROM qualifier.table(s) [AS] alias(es)
WHERE joins between tables
AND more joins between tables
AND search arguments, such as table.col = 1

Columns in the select clause are automatically aliased. Duplicate aliases are not allowed.

See Also:
Serialized Form

Constructor Summary
SqlStatement()
           
SqlStatement(String s)
           
 
Method Summary
 void addColumn(String column)
          Add a column name to the SELECT clause of an SQL statement.
 com.klg.jclass.datasource.util.SqlStatementColumn addColumn(String column, String column_alias)
          Add a column name to the SELECT clause of an SQL statement.
 com.klg.jclass.datasource.util.SqlStatementColumn addColumn(String column, String table, String alias)
          Adds a column
 com.klg.jclass.datasource.util.SqlStatementColumn addColumn(String column, String column_alias, String table, String alias)
          Adds a column
 void addJoin(String parent_column, String child_column)
          Add a join between two columns.
 void addParameterColumn(String col)
          Add a parameter column to the WHERE clause of an SQL statement.
 com.klg.jclass.datasource.util.SqlStatementTable addTable(com.klg.jclass.datasource.util.SqlStatementTable t)
          Uniquely add a table name and its alias to the FROM clause of an SQL statement.
 com.klg.jclass.datasource.util.SqlStatementTable addTable(String table)
          Add a table name to the FROM clause of an SQL statement.
 com.klg.jclass.datasource.util.SqlStatementTable addTable(String table, String alias)
          Uniquely add a table name and its alias to the FROM clause of an SQL statement.
 void clear()
          Clear various vectors and user-defined clauses.
 Enumeration getColumns()
          Return list of columns associated with this statement.
 Enumeration getJoins()
          Return list of joins associated with this statement.
 Enumeration getTables()
          Return a list of tables associated with this statement.
 String getText()
          Return the sql statement for this level.
 boolean isExpertMode()
          Indicates if expert mode is used.
 void refreshText()
          The SQL statement has changed, show the statement with the new changes.
 void removeAllParameterColumns()
          Remove all parameter columns from the WHERE clause of an SQL statement.
 void removeColumn(String column_alias)
          Remove a column name from the SELECT clause of an SQL statement.
 void removeJoin(String alias)
          Remove all joins of a table.
 void removeJoin(String parent_column, String child_column)
          Remove a join between two columns.
 void removeParameterColumn(String col)
          Remove a parameter column from the WHERE clause of an SQL statement.
 void removeTable(String s)
          Remove a table name by its alias from the FROM clause of an SQL statement.
 void setExpertMode(boolean v)
          Sets to use expert mode or not.
 void setText(String s)
          Sets the text of the actual SQL statement.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlStatement

public SqlStatement()

SqlStatement

public SqlStatement(String s)
Method Detail

addColumn

public void addColumn(String column)
Add a column name to the SELECT clause of an SQL statement. If the table of the column does not exist in the FROM clause, the table is added and the alias of the table is the table name itself. Column alias is set to the column name. Alias is ensured to be unique. Thus, if column name already exists in the select clause as an alias, a new alias in the format of "column" + counter is created.

Parameters:
column - name of the column to be added in the format of [[schema.]table.]column or [qualifier.]column

addColumn

public com.klg.jclass.datasource.util.SqlStatementColumn addColumn(String column,
                                                                   String column_alias)
Add a column name to the SELECT clause of an SQL statement. If the table of the column does not exist in the FROM clause, the table is added and the alias of the table is the table name itself.

Parameters:
column - name of the column to be added in the format of [[schema.]table.]column or [qualifier.]column

addColumn

public com.klg.jclass.datasource.util.SqlStatementColumn addColumn(String column,
                                                                   String table,
                                                                   String alias)
Adds a column

Parameters:
column - column name
table - qualified name of the table
alias - alias or qualifed name of a table

addColumn

public com.klg.jclass.datasource.util.SqlStatementColumn addColumn(String column,
                                                                   String column_alias,
                                                                   String table,
                                                                   String alias)
Adds a column

Parameters:
column - column name
column_alias - alias of a column Alias is ensured to be unique. Thus, if the alias already exists in the select clause, a new alias in the format of "column_name" + counter is created.
table - qualified name of the table
alias - alias or qualifed name of a table

removeColumn

public void removeColumn(String column_alias)
Remove a column name from the SELECT clause of an SQL statement.

Parameters:
column_alias - alias name of the column

addTable

public com.klg.jclass.datasource.util.SqlStatementTable addTable(String table)
Add a table name to the FROM clause of an SQL statement. Its alias equals the table name.

Parameters:
table - name of the table
Returns:
SqlStatementTable or null if table already exists.

addTable

public com.klg.jclass.datasource.util.SqlStatementTable addTable(String table,
                                                                 String alias)
Uniquely add a table name and its alias to the FROM clause of an SQL statement. If the alias already exists, table is not added.

Parameters:
table - name of the table
Returns:
SqlStatementTable or null if table already exists.

addTable

public com.klg.jclass.datasource.util.SqlStatementTable addTable(com.klg.jclass.datasource.util.SqlStatementTable t)
Uniquely add a table name and its alias to the FROM clause of an SQL statement. If the alias already exists, table is not added.

Returns:
SqlStatementTable or null if table already exists.

removeTable

public void removeTable(String s)
Remove a table name by its alias from the FROM clause of an SQL statement. Also remove any columns in the column list and where clause that reference this alias table.


addJoin

public void addJoin(String parent_column,
                    String child_column)
Add a join between two columns.


removeJoin

public void removeJoin(String parent_column,
                       String child_column)
Remove a join between two columns.


removeJoin

public void removeJoin(String alias)
Remove all joins of a table.

Parameters:
alias - alias or qualifed name of the table

addParameterColumn

public void addParameterColumn(String col)
Add a parameter column to the WHERE clause of an SQL statement.


removeParameterColumn

public void removeParameterColumn(String col)
Remove a parameter column from the WHERE clause of an SQL statement.


removeAllParameterColumns

public void removeAllParameterColumns()
Remove all parameter columns from the WHERE clause of an SQL statement.


refreshText

public void refreshText()
The SQL statement has changed, show the statement with the new changes.


getText

public String getText()
Return the sql statement for this level.


setText

public void setText(String s)
Sets the text of the actual SQL statement. The SQL statement is not converted back to joins, columns and tables.


getTables

public Enumeration getTables()
Return a list of tables associated with this statement.

Returns:
a list of the tables this statement.

getColumns

public Enumeration getColumns()
Return list of columns associated with this statement.

Returns:
a list of the columns in this statement.

getJoins

public Enumeration getJoins()
Return list of joins associated with this statement.

Returns:
a list of the joins in this statement.

clear

public void clear()
Clear various vectors and user-defined clauses.


isExpertMode

public boolean isExpertMode()
Indicates if expert mode is used. No parsing is done in expert mode.


setExpertMode

public void setExpertMode(boolean v)
Sets to use expert mode or not. No parsing is done in expert mode.


Copyright © 2004 Quest Software Inc..
All rights reserved.