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

Parser( String sql )

Public Methods

getSelectString( ) returns String
getFromString( ) returns String
getWhereString( ) returns String
getOrderByString( ) returns String
getGroupByString( ) returns String
getHavingString( ) returns String
getOffsetString( ) returns String
getLimitString( ) returns String
clone( ) returns Parser
setSelect( String selectClause ) returns String
Used to update the select clause. Returns an updated SQL statement.
setFrom( String fromClause ) returns String
Used to update the from clause in the SQL String. The entire from clause will be replaced with the given string. 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. Returns an updated SQL statement.
setOrderBy( String orderByClause ) returns String
Used to update the order by clause in the SQL String. The entire order by clause will be replaced with the given string. Returns an updated SQL statement.
setGroupBy( String groupByClause ) returns String
Used to update the group by clause in the SQL String. The entire group by clause will be replaced with the given string. Returns an updated SQL statement.
setOffset( Integer offset ) returns String
Used to update the offset clause in the SQL String. Returns an updated SQL statement.
setLimit( Integer limit ) returns String
Used to update the limit clause in the SQL String. Returns an updated SQL statement.
toString( ) returns String
Returns an sql String, including any updates
getSelectStatements( ) returns 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".
getTables( ) returns String[]
Returns an array of Tables Found in the SQL String
getWhereStatements( ) returns WhereStatement[]
Used to retrieve a list of where statements found in the where clause. Returns an empty array if no where statements are found.
getOrderByStatements( ) returns OrderByStatement[]
Used to break down the "ORDER BY" clause into individual statements.
getGroupByStatements( ) returns GroupByStatement[]
Used to break down the "GROUP BY" clause into individual statements.
debug( ) returns void

Public Classes