JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.datasource.util
Class SqlParser

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

public class SqlParser
extends Object
implements Serializable

Parse a sql-92 select statement into its various clauses.

See Also:
Serialized Form

Field Summary
static int FROM
           
static int REST
           
static int SELECT
           
static int WHERE
           
 
Constructor Summary
SqlParser(String query)
          Parse a sql 92 select statement into it component clauses: SELECT, FROM, WHERE, REST.
 
Method Summary
 String getClause(int clause)
          Return indicated clause.
 String getClause(int clause, boolean include_clause_word)
          Return indicated clause.
 Vector getColumns()
          Gets a list of SqlStatementColumns
 Vector getColumnsForTable(String table)
          Return a Vector of SqlStatementColumns for a table
 Vector getJoins()
          Gets a list of ColumnMaps
 String getNonJoinWhereClause()
          Gets text of non-join where clause
 Vector getParameterColumns()
          Gets a list of parameter columns
 com.klg.jclass.datasource.util.SqlStatementColumn getSqlStatementColumn(String table, String column)
          Return the SqlStatementColumn object for this table column combination.
 com.klg.jclass.datasource.util.SqlStatementTable getSqlStatementTable(String table)
          Given an unqualified table name, return the SqlStatementTable object
 Vector getTables()
          Gets a list of SqlStatementTables
static boolean isColumn(String s)
          A string is a column if it is not a number and it is not in quotes.
static boolean isParameter(String s)
          A string is a parameter if it contains a question mark "?" (without quotes).
static com.klg.jclass.datasource.util.SqlStatementColumn parseColumn(String text)
          Parse a string into a SqlStatementColumn.
static com.klg.jclass.datasource.util.SqlStatementTable parseTable(String text)
          Parse a string into a SqlStatementTable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT

public static final int SELECT
See Also:
Constant Field Values

FROM

public static final int FROM
See Also:
Constant Field Values

WHERE

public static final int WHERE
See Also:
Constant Field Values

REST

public static final int REST
See Also:
Constant Field Values
Constructor Detail

SqlParser

public SqlParser(String query)
Parse a sql 92 select statement into it component clauses: SELECT, FROM, WHERE, REST.

Method Detail

getClause

public String getClause(int clause)
Return indicated clause.

Parameters:
clause - an int one of SELECT, FROM, WHERE, REST.
Returns:
the clause, or "" if non-existent.

getClause

public String getClause(int clause,
                        boolean include_clause_word)
Return indicated clause.

Parameters:
clause - an int one of SELECT, FROM, WHERE, REST.
include_clause_word - indicates if the word "SELECT", "FROM" or "WHERE" is included in the returned string.
Returns:
the clause, or "" if non-existent.

getColumns

public Vector getColumns()
Gets a list of SqlStatementColumns


getTables

public Vector getTables()
Gets a list of SqlStatementTables


getJoins

public Vector getJoins()
Gets a list of ColumnMaps


getParameterColumns

public Vector getParameterColumns()
Gets a list of parameter columns


getNonJoinWhereClause

public String getNonJoinWhereClause()
Gets text of non-join where clause


parseTable

public static com.klg.jclass.datasource.util.SqlStatementTable parseTable(String text)
Parse a string into a SqlStatementTable.

Returns:
SqlStatementTable

parseColumn

public static com.klg.jclass.datasource.util.SqlStatementColumn parseColumn(String text)
Parse a string into a SqlStatementColumn.

Returns:
SqlStatementColumn

isColumn

public static boolean isColumn(String s)
A string is a column if it is not a number and it is not in quotes.


isParameter

public static boolean isParameter(String s)
A string is a parameter if it contains a question mark "?" (without quotes).


getSqlStatementTable

public com.klg.jclass.datasource.util.SqlStatementTable getSqlStatementTable(String table)
Given an unqualified table name, return the SqlStatementTable object

Returns:
SqlStatementTable, or null if not found

getSqlStatementColumn

public com.klg.jclass.datasource.util.SqlStatementColumn getSqlStatementColumn(String table,
                                                                               String column)
Return the SqlStatementColumn object for this table column combination. Returns null if not found.

Parameters:
column - a String, the unqualified column name
Returns:
the SqlStatementColumn for this table/column combination

getColumnsForTable

public Vector getColumnsForTable(String table)
Return a Vector of SqlStatementColumns for a table

Returns:
a Vector of SqlStatementColumns for this table

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