Logo Search packages:      
Sourcecode: henplus version File versions  Download package

henplus::SQLStatementSeparator Class Reference

List of all members.


Detailed Description

Simple parser that separates SQLStatements. Example.
-----------------------
 statementSeparator.append("select * from foo; echo $foobar \n");
 while (statementSeparator.hasNext()) {
      String stmt = statementSeparator.next();
      if (stmt.startsWith("echo")) {
is ok, this command works always without ';'
	  statementSeparator.consumed();
	  System.err.println(stmt.substring("echo ".length());
      }
      else {  // SQL-command. we require a semicolon at the end.
         if (!stmt.charAt(stmt.length()-1) == ';') {
	    statementSeparator.cont(); // continue.
         }
         else {
            statementSeparator.consumed();
	    SQLExecute(stmt);
         }
      }
 }
----------------------- 

FIXME: this is a bit rough and accummulated some ideas. Should be cleaned up.

Author:
Henner Zeller <H.Zeller@acm.org>

Definition at line 45 of file SQLStatementSeparator.java.


Public Member Functions

void append (String s)
void consumed ()
void cont ()
void discard ()
PropertyHolder getRemoveCommentsProperty ()
boolean hasNext () throws IllegalStateException
String next () throws IllegalStateException
void pop ()
void push ()
void removeComments (boolean b)

Private Member Functions

void parsePartialInput ()

Private Attributes

ParseState _currentState
boolean _removeComments
Stack _stateStack

Static Private Attributes

static final byte COMMENT = 4
static final byte ENDLINE_COMMENT = 7
static final byte FIRST_SEMICOLON_ON_LINE_SEEN = 13
static final byte NEW_STATEMENT = 0
static final byte POTENTIAL_END_FOUND = 14
static final byte PRE_END_COMMENT = 5
static final byte SQLSTRING = 10
static final byte SQLSTRING_QUOTE = 11
static final byte START = 1
static final byte START_ANSI = 6
static final byte START_COMMENT = 3
static final byte STATEMENT = 1
static final byte STATEMENT_QUOTE = 12
static final byte STRING = 8
static final byte STRING_QUOTE = 9

Classes

class  ParseState
class  RemoveCommentsProperty

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index