org.apache.beehive.controls.system.jdbc.parser
Class SqlParser

Object
  extended by SqlParser

public final class SqlParser
extends Object

The SqlParser class is a thread-safe class which parses a string containing a SQL statement with JdbcControl substitituion delimiters. It is important to note that the SQL is not parsed/validated - only the sections within the SQL string which are delimited by '{' and '}' are parsed.

Parsing is accomplished using the JavaCC grammar file SqlGrammer.jj. As the string is parsed it is broken into fragments by the parser. Any portion of the string which is not between '{' and '}' delimiters becomes a LiteralFragment. The portions of the SQL string which fall between the start and end delimiters are categorized as either JdbcFragment, ReflectionFragment, or SqlSubstitutionFragment.

Fragments which subclass SqlFragmentContainer may contain other fragments as children. Fragements subclassed from SqlFragment my not contain child fragments. Upon completion of parsing a SqlStatement is returned to the caller. The SqlStatement contains the heirarchary of fragments which have been derived from the orignal SQL string.

The parser will also cache all SqlStatements which contain non-volitale SQL. Only SqlEscapeFragments contain volitile SQL at this point.


Constructor Summary
SqlParser()
          Create a new instance of the SqlParser.
 
Method Summary
 SqlStatement parse(String sql)
          Parse the sql and return an SqlStatement.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlParser

public SqlParser()
Create a new instance of the SqlParser.

Method Detail

parse

public SqlStatement parse(String sql)
Parse the sql and return an SqlStatement.

Parameters:
sql - A String contianing the sql to parse.
Returns:
A SqlStatement instance.