JavaXT

Parser Class

Used to parse and modify SQL Select Statements ("Select * from MyTable"). Other SQL commands are not supported (insert, update, create, etc.).
Note that this implementation is incomplete and needs a lot more testing. For example, the parser does not yet handle unions, subselects, and having clauses. Other potential problems include arithmetic operators in the where clause ("where posting_time + 60 > sysdate").

Constructors

public Parser( String sql )

Methods

debug( ) returns void
getFromString( ) returns String
getGroupByStatements( ) returns javaxt.sql.Parser.GroupByStatement[]
Used to break down the "GROUP BY" clause into individual statements.
getGroupByString( ) returns String
getHavingString( ) returns String
getOrderByStatements( ) returns javaxt.sql.Parser.OrderByStatement[]
Used to break down the "ORDER BY" clause into individual statements.
getOrderByString( ) returns String
getSelectStatements( ) returns javaxt.sql.Parser.SelectStatement[]
Used to break down the select clause into individual elements. For example, "Select FirstName, LastName from Contacts" would return an array with 2 entries: "FirstName" and "LastName".
getSelectString( ) returns String
getTables( ) returns String[]
Returns an array of Tables Found in the SQL String
getWhereStatements( ) returns javaxt.sql.Parser.WhereStatement[]
Used to retrieve a list of where statements found in the where clause. Returns an empty array if no where statements are found.
getWhereString( ) returns String
setSelect( String selectClause ) returns String
Used to update the select clause. The input select clause is accepted "AS IS". Returns an updated SQL statement.
setWhere( String whereClause ) returns String
Used to update the where clause in the SQL String. The entire where clause will be replaced with the given string. The input select clause is accepted "AS IS". Returns an updated SQL statement.
toString( ) returns String
Returns an sql String, including any updates