avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From froehl...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql BasicSQLInsertRowsHandler.java BasicSQLCreateTableHandler.java BasicSQLSelectSimpleHandler.java BasicSQLParserTokenManager.java BasicSQLParserConstants.java BasicSQLParser.java BasicSQLHandler.java
Date Sat, 15 Dec 2001 18:49:56 GMT
froehlich    01/12/15 10:49:56

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/handlers/sql
                        BasicSQLSelectSimpleHandler.java
                        BasicSQLParserTokenManager.java
                        BasicSQLParserConstants.java BasicSQLParser.java
                        BasicSQLHandler.java
  Added:       apps/db/src/java/org/apache/avalon/db/basic/handlers/sql
                        BasicSQLInsertRowsHandler.java
                        BasicSQLCreateTableHandler.java
  Log:
  further work on the SQL parser
  
  Revision  Changes    Path
  1.2       +30 -9     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLSelectSimpleHandler.java
  
  Index: BasicSQLSelectSimpleHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLSelectSimpleHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicSQLSelectSimpleHandler.java	2001/12/03 17:36:50	1.1
  +++ BasicSQLSelectSimpleHandler.java	2001/12/15 18:49:55	1.2
  @@ -59,24 +59,45 @@
       public Reply handleRequest(DBRequestContext context, Request request) throws ActionException {
   
           System.out.println("BasicSQLSelectSimpleHandler");
  -        initBasicSQLPaser(((SelectRequest)request).getSql());
  +        BasicSQLParser parser = initBasicSQLPaser(((SelectRequest)request).getSql());
           try {
  -            BasicSQLParser.Select();
  +            parser.ParseSelect();
           } catch (ParseException pe) {
               getLogger().error("handleRequest(..): ParseException:",pe);
           }
           // TODO - not perfect.
  +        String[] tables = parser.getTables();
  +        
  +        AbstractQueryable queryable = (AbstractQueryable) mDatabasePersistor.getQueryable(tables[0]);
  +
  +        String[] cols = parser.getColumns();
  +        Column[] columns = null;
  +
  +        // TODO - not perfect.
  +        if (cols.length != 0 && cols[0].equals("*")) {
  +            columns = queryable.getColumns();
  +        } else {
  +            columns = convertColumns(queryable, cols);
  +        }
   
  -        /*
           Select action = new BasicSelectSimple(tables,
  -        convertColumns(queryable, getColumns(rootElement)),
  -        new BasicCriteria(criteriaHelper.getCriteria()));
  +                            columns,
  +                            new BasicCriteria(parser.getCriteria()));
           
  -        mParser.initializeAction(action);
  +        mParserMgr.initializeAction(action);
           action.execute();
  -        */
   
  -        //return new ResultSetReply(action.getRowSet());
  -        return null;
  +        return new ResultSetReply(action.getRowSet());
  +    }
  +
  +    protected Column[] convertColumns(AbstractQueryable queryable, String[] columnNames) {
  +
  +        //TODO * could be with other contrived columns
  +
  +        Column[] columns = new Column[columnNames.length];
  +        for ( int i = 0; i < columnNames.length; i++ ) {
  +            columns[i] = queryable.getColumn(columnNames[i], false);
  +        }
  +        return columns;
       }
   }
  
  
  
  1.2       +208 -150  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLParserTokenManager.java
  
  Index: BasicSQLParserTokenManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLParserTokenManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicSQLParserTokenManager.java	2001/12/03 17:36:50	1.1
  +++ BasicSQLParserTokenManager.java	2001/12/15 18:49:55	1.2
  @@ -1,25 +1,34 @@
   /* Generated By:JavaCC: Do not edit this line. BasicSQLParserTokenManager.java */
   package org.apache.avalon.db.basic.handlers.sql;
  +import org.apache.avalon.db.data.Column;
  +import org.apache.avalon.db.data.impl.DefaultVarCharColumn;
  +import org.apache.avalon.db.data.impl.DefaultIntegerColumn;
  +import org.apache.avalon.db.data.impl.DefaultDateColumn;
  +import org.apache.avalon.db.data.impl.DefaultTimeColumn;
  +import org.apache.avalon.db.data.impl.DefaultTimestampColumn;
  +import org.apache.avalon.db.data.impl.DefaultSmallIntColumn;
  +import org.apache.avalon.db.data.impl.DefaultRealColumn;
  +import org.apache.avalon.db.data.impl.DefaultBigIntColumn;
  +import org.apache.avalon.db.data.impl.DefaultDecimalColumn;
   import org.apache.avalon.db.server.AbstractRequestHandler;
   import org.apache.avalon.db.server.sql.ParseException;
  +import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.server.sql.SimpleCharStream;
   import org.apache.avalon.db.server.sql.Token;
   import org.apache.avalon.db.server.sql.TokenMgrError;
  -import java.util.ArrayList;
  -import java.io.InputStream;
  -import java.io.ByteArrayInputStream;
  +import java.util.Vector;
   
   public class BasicSQLParserTokenManager implements BasicSQLParserConstants
   {
  -  public static  java.io.PrintStream debugStream = System.out;
  -  public static  void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
  -static private final int jjStopAtPos(int pos, int kind)
  +  public  java.io.PrintStream debugStream = System.out;
  +  public  void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
  +private final int jjStopAtPos(int pos, int kind)
   {
      jjmatchedKind = kind;
      jjmatchedPos = pos;
      return pos + 1;
   }
  -static private final int jjMoveStringLiteralDfa0_0()
  +private final int jjMoveStringLiteralDfa0_0()
   {
      switch(curChar)
      {
  @@ -36,29 +45,29 @@
            jjmatchedKind = 1;
            return jjMoveNfa_0(5, 0);
         case 40:
  -         jjmatchedKind = 61;
  +         jjmatchedKind = 64;
            return jjMoveNfa_0(5, 0);
         case 41:
  -         jjmatchedKind = 62;
  +         jjmatchedKind = 65;
            return jjMoveNfa_0(5, 0);
         case 42:
  -         jjmatchedKind = 63;
  +         jjmatchedKind = 66;
            return jjMoveNfa_0(5, 0);
         case 44:
  -         jjmatchedKind = 60;
  +         jjmatchedKind = 63;
            return jjMoveNfa_0(5, 0);
         case 59:
  -         jjmatchedKind = 59;
  +         jjmatchedKind = 62;
            return jjMoveNfa_0(5, 0);
         case 60:
  -         jjmatchedKind = 48;
  -         return jjMoveStringLiteralDfa1_0(0x4000000000000L);
  +         jjmatchedKind = 50;
  +         return jjMoveStringLiteralDfa1_0(0x10000000000000L);
         case 61:
  -         jjmatchedKind = 46;
  +         jjmatchedKind = 48;
            return jjMoveNfa_0(5, 0);
         case 62:
  -         jjmatchedKind = 47;
  -         return jjMoveStringLiteralDfa1_0(0x2000000000000L);
  +         jjmatchedKind = 49;
  +         return jjMoveStringLiteralDfa1_0(0x8000000000000L);
         case 65:
            return jjMoveStringLiteralDfa1_0(0x80016000000L);
         case 66:
  @@ -76,7 +85,7 @@
         case 73:
            return jjMoveStringLiteralDfa1_0(0x1080081000L);
         case 78:
  -         return jjMoveStringLiteralDfa1_0(0x200000000000L);
  +         return jjMoveStringLiteralDfa1_0(0xe00000000000L);
         case 79:
            return jjMoveStringLiteralDfa1_0(0x120000000000L);
         case 82:
  @@ -108,9 +117,9 @@
         case 105:
            return jjMoveStringLiteralDfa1_0(0x1080081000L);
         case 108:
  -         return jjMoveStringLiteralDfa1_0(0x8000000000000L);
  +         return jjMoveStringLiteralDfa1_0(0x20000000000000L);
         case 110:
  -         return jjMoveStringLiteralDfa1_0(0x200000000000L);
  +         return jjMoveStringLiteralDfa1_0(0xe00000000000L);
         case 111:
            return jjMoveStringLiteralDfa1_0(0x120000000000L);
         case 114:
  @@ -129,7 +138,7 @@
            return jjMoveNfa_0(5, 0);
      }
   }
  -static private final int jjMoveStringLiteralDfa1_0(long active0)
  +private final int jjMoveStringLiteralDfa1_0(long active0)
   {
      try { curChar = input_stream.readChar(); }
      catch(java.io.IOException e) {
  @@ -138,14 +147,14 @@
      switch(curChar)
      {
         case 61:
  -         if ((active0 & 0x2000000000000L) != 0L)
  +         if ((active0 & 0x8000000000000L) != 0L)
            {
  -            jjmatchedKind = 49;
  +            jjmatchedKind = 51;
               jjmatchedPos = 1;
            }
  -         else if ((active0 & 0x4000000000000L) != 0L)
  +         else if ((active0 & 0x10000000000000L) != 0L)
            {
  -            jjmatchedKind = 50;
  +            jjmatchedKind = 52;
               jjmatchedPos = 1;
            }
            break;
  @@ -164,7 +173,7 @@
         case 78:
            return jjMoveStringLiteralDfa2_0(active0, 0x81080081000L);
         case 79:
  -         return jjMoveStringLiteralDfa2_0(active0, 0x200201040000L);
  +         return jjMoveStringLiteralDfa2_0(active0, 0xa00201040000L);
         case 80:
            return jjMoveStringLiteralDfa2_0(active0, 0x10000L);
         case 82:
  @@ -181,6 +190,8 @@
               jjmatchedPos = 1;
            }
            return jjMoveStringLiteralDfa2_0(active0, 0x10000000L);
  +      case 85:
  +         return jjMoveStringLiteralDfa2_0(active0, 0x400000000000L);
         case 97:
            return jjMoveStringLiteralDfa2_0(active0, 0x6800004080L);
         case 101:
  @@ -188,7 +199,7 @@
         case 104:
            return jjMoveStringLiteralDfa2_0(active0, 0x400000000L);
         case 105:
  -         return jjMoveStringLiteralDfa2_0(active0, 0x8040100008300L);
  +         return jjMoveStringLiteralDfa2_0(active0, 0x20040100008300L);
         case 108:
            return jjMoveStringLiteralDfa2_0(active0, 0x2000000L);
         case 109:
  @@ -196,7 +207,7 @@
         case 110:
            return jjMoveStringLiteralDfa2_0(active0, 0x81080081000L);
         case 111:
  -         return jjMoveStringLiteralDfa2_0(active0, 0x200201040000L);
  +         return jjMoveStringLiteralDfa2_0(active0, 0xa00201040000L);
         case 112:
            return jjMoveStringLiteralDfa2_0(active0, 0x10000L);
         case 114:
  @@ -213,12 +224,14 @@
               jjmatchedPos = 1;
            }
            return jjMoveStringLiteralDfa2_0(active0, 0x10000000L);
  +      case 117:
  +         return jjMoveStringLiteralDfa2_0(active0, 0x400000000000L);
         default :
            break;
      }
      return jjMoveNfa_0(5, 1);
   }
  -static private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
  +private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
   {
      if (((active0 &= old0)) == 0L)
         return jjMoveNfa_0(5, 1);
  @@ -251,7 +264,7 @@
         case 71:
            return jjMoveStringLiteralDfa3_0(active0, 0x8000L);
         case 76:
  -         return jjMoveStringLiteralDfa3_0(active0, 0x2000460000L);
  +         return jjMoveStringLiteralDfa3_0(active0, 0x402000460000L);
         case 77:
            return jjMoveStringLiteralDfa3_0(active0, 0x1000300L);
         case 79:
  @@ -271,7 +284,7 @@
               jjmatchedKind = 45;
               jjmatchedPos = 2;
            }
  -         return jjMoveStringLiteralDfa3_0(active0, 0x8082005000L);
  +         return jjMoveStringLiteralDfa3_0(active0, 0x808082005000L);
         case 85:
            return jjMoveStringLiteralDfa3_0(active0, 0x200000000L);
         case 86:
  @@ -299,9 +312,9 @@
         case 103:
            return jjMoveStringLiteralDfa3_0(active0, 0x8000L);
         case 107:
  -         return jjMoveStringLiteralDfa3_0(active0, 0x8000000000000L);
  +         return jjMoveStringLiteralDfa3_0(active0, 0x20000000000000L);
         case 108:
  -         return jjMoveStringLiteralDfa3_0(active0, 0x2000460000L);
  +         return jjMoveStringLiteralDfa3_0(active0, 0x402000460000L);
         case 109:
            return jjMoveStringLiteralDfa3_0(active0, 0x1000300L);
         case 111:
  @@ -321,7 +334,7 @@
               jjmatchedKind = 45;
               jjmatchedPos = 2;
            }
  -         return jjMoveStringLiteralDfa3_0(active0, 0x8082005000L);
  +         return jjMoveStringLiteralDfa3_0(active0, 0x808082005000L);
         case 117:
            return jjMoveStringLiteralDfa3_0(active0, 0x200000000L);
         case 118:
  @@ -331,7 +344,7 @@
      }
      return jjMoveNfa_0(5, 2);
   }
  -static private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
  +private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
   {
      if (((active0 &= old0)) == 0L)
         return jjMoveNfa_0(5, 2);
  @@ -341,6 +354,8 @@
      }
      switch(curChar)
      {
  +      case 32:
  +         return jjMoveStringLiteralDfa4_0(active0, 0x800000000000L);
         case 65:
            return jjMoveStringLiteralDfa4_0(active0, 0x810000L);
         case 67:
  @@ -370,6 +385,11 @@
               jjmatchedKind = 11;
               jjmatchedPos = 3;
            }
  +         else if ((active0 & 0x400000000000L) != 0L)
  +         {
  +            jjmatchedKind = 46;
  +            jjmatchedPos = 3;
  +         }
            return jjMoveStringLiteralDfa4_0(active0, 0x800040400L);
         case 77:
            if ((active0 & 0x20000000L) != 0L)
  @@ -427,9 +447,9 @@
               jjmatchedKind = 14;
               jjmatchedPos = 3;
            }
  -         else if ((active0 & 0x8000000000000L) != 0L)
  +         else if ((active0 & 0x20000000000000L) != 0L)
            {
  -            jjmatchedKind = 51;
  +            jjmatchedKind = 53;
               jjmatchedPos = 3;
            }
            return jjMoveStringLiteralDfa4_0(active0, 0x210024a1100L);
  @@ -441,6 +461,11 @@
               jjmatchedKind = 11;
               jjmatchedPos = 3;
            }
  +         else if ((active0 & 0x400000000000L) != 0L)
  +         {
  +            jjmatchedKind = 46;
  +            jjmatchedPos = 3;
  +         }
            return jjMoveStringLiteralDfa4_0(active0, 0x800040400L);
         case 109:
            if ((active0 & 0x20000000L) != 0L)
  @@ -483,7 +508,7 @@
      }
      return jjMoveNfa_0(5, 3);
   }
  -static private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
  +private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
   {
      if (((active0 &= old0)) == 0L)
         return jjMoveNfa_0(5, 3);
  @@ -520,7 +545,7 @@
         case 77:
            return jjMoveStringLiteralDfa5_0(active0, 0x2000L);
         case 78:
  -         return jjMoveStringLiteralDfa5_0(active0, 0x4000008000L);
  +         return jjMoveStringLiteralDfa5_0(active0, 0x804000008000L);
         case 80:
            return jjMoveStringLiteralDfa5_0(active0, 0x10000000000L);
         case 82:
  @@ -578,7 +603,7 @@
         case 109:
            return jjMoveStringLiteralDfa5_0(active0, 0x2000L);
         case 110:
  -         return jjMoveStringLiteralDfa5_0(active0, 0x4000008000L);
  +         return jjMoveStringLiteralDfa5_0(active0, 0x804000008000L);
         case 112:
            return jjMoveStringLiteralDfa5_0(active0, 0x10000000000L);
         case 114:
  @@ -614,7 +639,7 @@
      }
      return jjMoveNfa_0(5, 4);
   }
  -static private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
  +private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
   {
      if (((active0 &= old0)) == 0L)
         return jjMoveNfa_0(5, 4);
  @@ -685,6 +710,8 @@
               jjmatchedPos = 5;
            }
            return jjMoveStringLiteralDfa6_0(active0, 0x100L);
  +      case 85:
  +         return jjMoveStringLiteralDfa6_0(active0, 0x800000000000L);
         case 97:
            return jjMoveStringLiteralDfa6_0(active0, 0x42080L);
         case 101:
  @@ -744,12 +771,14 @@
               jjmatchedPos = 5;
            }
            return jjMoveStringLiteralDfa6_0(active0, 0x100L);
  +      case 117:
  +         return jjMoveStringLiteralDfa6_0(active0, 0x800000000000L);
         default :
            break;
      }
      return jjMoveNfa_0(5, 5);
   }
  -static private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
  +private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
   {
      if (((active0 &= old0)) == 0L)
         return jjMoveNfa_0(5, 5);
  @@ -771,7 +800,7 @@
               jjmatchedKind = 13;
               jjmatchedPos = 6;
            }
  -         break;
  +         return jjMoveStringLiteralDfa7_0(active0, 0x800000000000L);
         case 78:
            if ((active0 & 0x8000000000L) != 0L)
            {
  @@ -803,7 +832,7 @@
               jjmatchedKind = 13;
               jjmatchedPos = 6;
            }
  -         break;
  +         return jjMoveStringLiteralDfa7_0(active0, 0x800000000000L);
         case 110:
            if ((active0 & 0x8000000000L) != 0L)
            {
  @@ -828,7 +857,7 @@
      }
      return jjMoveNfa_0(5, 6);
   }
  -static private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
  +private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
   {
      if (((active0 &= old0)) == 0L)
         return jjMoveNfa_0(5, 6);
  @@ -845,6 +874,13 @@
               jjmatchedPos = 7;
            }
            break;
  +      case 76:
  +         if ((active0 & 0x800000000000L) != 0L)
  +         {
  +            jjmatchedKind = 47;
  +            jjmatchedPos = 7;
  +         }
  +         break;
         case 77:
            return jjMoveStringLiteralDfa8_0(active0, 0x100L);
         case 84:
  @@ -878,6 +914,13 @@
               jjmatchedPos = 7;
            }
            break;
  +      case 108:
  +         if ((active0 & 0x800000000000L) != 0L)
  +         {
  +            jjmatchedKind = 47;
  +            jjmatchedPos = 7;
  +         }
  +         break;
         case 109:
            return jjMoveStringLiteralDfa8_0(active0, 0x100L);
         case 116:
  @@ -909,7 +952,7 @@
      }
      return jjMoveNfa_0(5, 7);
   }
  -static private final int jjMoveStringLiteralDfa8_0(long old0, long active0)
  +private final int jjMoveStringLiteralDfa8_0(long old0, long active0)
   {
      if (((active0 &= old0)) == 0L)
         return jjMoveNfa_0(5, 7);
  @@ -938,7 +981,7 @@
      }
      return jjMoveNfa_0(5, 8);
   }
  -static private final void jjCheckNAdd(int state)
  +private final void jjCheckNAdd(int state)
   {
      if (jjrounds[state] != jjround)
      {
  @@ -946,24 +989,24 @@
         jjrounds[state] = jjround;
      }
   }
  -static private final void jjAddStates(int start, int end)
  +private final void jjAddStates(int start, int end)
   {
      do {
         jjstateSet[jjnewStateCnt++] = jjnextStates[start];
      } while (start++ != end);
   }
  -static private final void jjCheckNAddTwoStates(int state1, int state2)
  +private final void jjCheckNAddTwoStates(int state1, int state2)
   {
      jjCheckNAdd(state1);
      jjCheckNAdd(state2);
   }
  -static private final void jjCheckNAddStates(int start, int end)
  +private final void jjCheckNAddStates(int start, int end)
   {
      do {
         jjCheckNAdd(jjnextStates[start]);
      } while (start++ != end);
   }
  -static private final void jjCheckNAddStates(int start)
  +private final void jjCheckNAddStates(int start)
   {
      jjCheckNAdd(jjnextStates[start]);
      jjCheckNAdd(jjnextStates[start + 1]);
  @@ -971,7 +1014,7 @@
   static final long[] jjbitVec0 = {
      0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
   };
  -static private final int jjMoveNfa_0(int startState, int curPos)
  +private final int jjMoveNfa_0(int startState, int curPos)
   {
      int strKind = jjmatchedKind;
      int strPos = jjmatchedPos;
  @@ -982,7 +1025,7 @@
      curPos = 0;
      int[] nextStates;
      int startsAt = 0;
  -   jjnewStateCnt = 42;
  +   jjnewStateCnt = 45;
      int i = 1;
      jjstateSet[0] = startState;
      int j, kind = 0x7fffffff;
  @@ -1000,13 +1043,15 @@
                  case 5:
                     if ((0x3ff000000000000L & l) != 0L)
                     {
  -                     if (kind > 55)
  -                        kind = 55;
  +                     if (kind > 58)
  +                        kind = 58;
                        jjCheckNAddStates(0, 6);
                     }
                     else if (curChar == 39)
                        jjCheckNAddStates(7, 9);
                     else if (curChar == 46)
  +                     jjCheckNAdd(19);
  +                  else if (curChar == 40)
                        jjCheckNAdd(16);
                     else if (curChar == 47)
                        jjstateSet[jjnewStateCnt++] = 6;
  @@ -1064,128 +1109,140 @@
                  case 14:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 52)
  -                     kind = 52;
  +                  if (kind > 54)
  +                     kind = 54;
                     jjstateSet[jjnewStateCnt++] = 14;
                     break;
                  case 15:
  -                  if (curChar == 46)
  +                  if (curChar == 40)
                        jjCheckNAdd(16);
                     break;
                  case 16:
  -                  if ((0x3ff000000000000L & l) == 0L)
  -                     break;
  -                  if (kind > 56)
  -                     kind = 56;
  -                  jjCheckNAddTwoStates(16, 17);
  +                  if ((0x3ff000000000000L & l) != 0L)
  +                     jjCheckNAddTwoStates(16, 17);
  +                  break;
  +               case 17:
  +                  if (curChar == 41 && kind > 57)
  +                     kind = 57;
                     break;
                  case 18:
  -                  if ((0x280000000000L & l) != 0L)
  +                  if (curChar == 46)
                        jjCheckNAdd(19);
                     break;
                  case 19:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 56)
  -                     kind = 56;
  -                  jjCheckNAdd(19);
  +                  if (kind > 59)
  +                     kind = 59;
  +                  jjCheckNAddTwoStates(19, 20);
                     break;
  -               case 20:
  +               case 21:
  +                  if ((0x280000000000L & l) != 0L)
  +                     jjCheckNAdd(22);
  +                  break;
  +               case 22:
  +                  if ((0x3ff000000000000L & l) == 0L)
  +                     break;
  +                  if (kind > 59)
  +                     kind = 59;
  +                  jjCheckNAdd(22);
  +                  break;
  +               case 23:
                     if (curChar == 39)
                        jjCheckNAddStates(7, 9);
                     break;
  -               case 21:
  +               case 24:
                     if ((0xffffff7fffffffffL & l) != 0L)
                        jjCheckNAddStates(7, 9);
                     break;
  -               case 22:
  +               case 25:
                     if (curChar == 39)
                        jjCheckNAddStates(16, 18);
                     break;
  -               case 23:
  +               case 26:
                     if (curChar == 39)
  -                     jjstateSet[jjnewStateCnt++] = 22;
  +                     jjstateSet[jjnewStateCnt++] = 25;
                     break;
  -               case 24:
  +               case 27:
                     if ((0xffffff7fffffffffL & l) != 0L)
                        jjCheckNAddStates(16, 18);
                     break;
  -               case 25:
  -                  if (curChar == 39 && kind > 58)
  -                     kind = 58;
  +               case 28:
  +                  if (curChar == 39 && kind > 61)
  +                     kind = 61;
                     break;
  -               case 26:
  +               case 29:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 55)
  -                     kind = 55;
  +                  if (kind > 58)
  +                     kind = 58;
                     jjCheckNAddStates(0, 6);
                     break;
  -               case 27:
  +               case 30:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 55)
  -                     kind = 55;
  -                  jjCheckNAdd(27);
  +                  if (kind > 58)
  +                     kind = 58;
  +                  jjCheckNAdd(30);
                     break;
  -               case 28:
  +               case 31:
                     if ((0x3ff000000000000L & l) != 0L)
  -                     jjCheckNAddTwoStates(28, 29);
  +                     jjCheckNAddTwoStates(31, 32);
                     break;
  -               case 29:
  +               case 32:
                     if (curChar == 46)
  -                     jjCheckNAdd(30);
  +                     jjCheckNAdd(33);
                     break;
  -               case 30:
  +               case 33:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 56)
  -                     kind = 56;
  -                  jjCheckNAddTwoStates(30, 31);
  +                  if (kind > 59)
  +                     kind = 59;
  +                  jjCheckNAddTwoStates(33, 34);
                     break;
  -               case 32:
  +               case 35:
                     if ((0x280000000000L & l) != 0L)
  -                     jjCheckNAdd(33);
  +                     jjCheckNAdd(36);
                     break;
  -               case 33:
  +               case 36:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 56)
  -                     kind = 56;
  -                  jjCheckNAdd(33);
  +                  if (kind > 59)
  +                     kind = 59;
  +                  jjCheckNAdd(36);
                     break;
  -               case 34:
  +               case 37:
                     if ((0x3ff000000000000L & l) != 0L)
  -                     jjCheckNAddTwoStates(34, 35);
  +                     jjCheckNAddTwoStates(37, 38);
                     break;
  -               case 36:
  +               case 39:
                     if ((0x280000000000L & l) != 0L)
  -                     jjCheckNAdd(37);
  +                     jjCheckNAdd(40);
                     break;
  -               case 37:
  +               case 40:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 56)
  -                     kind = 56;
  -                  jjCheckNAdd(37);
  +                  if (kind > 59)
  +                     kind = 59;
  +                  jjCheckNAdd(40);
                     break;
  -               case 38:
  +               case 41:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 56)
  -                     kind = 56;
  -                  jjCheckNAddTwoStates(38, 39);
  +                  if (kind > 59)
  +                     kind = 59;
  +                  jjCheckNAddTwoStates(41, 42);
                     break;
  -               case 40:
  +               case 43:
                     if ((0x280000000000L & l) != 0L)
  -                     jjCheckNAdd(41);
  +                     jjCheckNAdd(44);
                     break;
  -               case 41:
  +               case 44:
                     if ((0x3ff000000000000L & l) == 0L)
                        break;
  -                  if (kind > 56)
  -                     kind = 56;
  -                  jjCheckNAdd(41);
  +                  if (kind > 59)
  +                     kind = 59;
  +                  jjCheckNAdd(44);
                     break;
                  default : break;
               }
  @@ -1202,8 +1259,8 @@
                  case 14:
                     if ((0x7fffffe87fffffeL & l) == 0L)
                        break;
  -                  if (kind > 52)
  -                     kind = 52;
  +                  if (kind > 54)
  +                     kind = 54;
                     jjCheckNAdd(14);
                     break;
                  case 1:
  @@ -1216,25 +1273,25 @@
                  case 10:
                     jjCheckNAddTwoStates(10, 8);
                     break;
  -               case 17:
  +               case 20:
                     if ((0x2000000020L & l) != 0L)
                        jjAddStates(19, 20);
                     break;
  -               case 21:
  +               case 24:
                     jjCheckNAddStates(7, 9);
                     break;
  -               case 24:
  +               case 27:
                     jjCheckNAddStates(16, 18);
                     break;
  -               case 31:
  +               case 34:
                     if ((0x2000000020L & l) != 0L)
                        jjAddStates(21, 22);
                     break;
  -               case 35:
  +               case 38:
                     if ((0x2000000020L & l) != 0L)
                        jjAddStates(23, 24);
                     break;
  -               case 39:
  +               case 42:
                     if ((0x2000000020L & l) != 0L)
                        jjAddStates(25, 26);
                     break;
  @@ -1263,11 +1320,11 @@
                     if ((jjbitVec0[i2] & l2) != 0L)
                        jjCheckNAddTwoStates(10, 8);
                     break;
  -               case 21:
  +               case 24:
                     if ((jjbitVec0[i2] & l2) != 0L)
                        jjCheckNAddStates(7, 9);
                     break;
  -               case 24:
  +               case 27:
                     if ((jjbitVec0[i2] & l2) != 0L)
                        jjCheckNAddStates(16, 18);
                     break;
  @@ -1282,7 +1339,7 @@
            kind = 0x7fffffff;
         }
         ++curPos;
  -      if ((i = jjnewStateCnt) == (startsAt = 42 - (jjnewStateCnt = startsAt)))
  +      if ((i = jjnewStateCnt) == (startsAt = 45 - (jjnewStateCnt = startsAt)))
            break;
         try { curChar = input_stream.readChar(); }
         catch(java.io.IOException e) { break; }
  @@ -1308,32 +1365,33 @@
      return toRet;
   }
   static final int[] jjnextStates = {
  -   27, 28, 29, 34, 35, 38, 39, 21, 23, 25, 1, 2, 4, 8, 9, 11, 
  -   23, 24, 25, 18, 19, 32, 33, 36, 37, 40, 41, 
  +   30, 31, 32, 37, 38, 41, 42, 24, 26, 28, 1, 2, 4, 8, 9, 11, 
  +   26, 27, 28, 21, 22, 35, 36, 39, 40, 43, 44, 
   };
   public static final String[] jjstrLiteralImages = {
   "", null, null, null, null, null, null, null, null, null, null, null, null, 
   null, null, null, null, null, null, null, null, null, null, null, null, null, null, 
   null, null, null, null, null, null, null, null, null, null, null, null, null, null, 
  -null, null, null, null, null, "\75", "\76", "\74", "\76\75", "\74\75", 
  -"\154\151\153\145", null, null, null, null, null, null, null, "\73", "\54", "\50", "\51", "\52", };
  +null, null, null, null, null, null, null, "\75", "\76", "\74", "\76\75", "\74\75", 
  +"\154\151\153\145", null, null, null, null, null, null, null, null, "\73", "\54", "\50", "\51", 
  +"\52", };
   public static final String[] lexStateNames = {
      "DEFAULT", 
   };
   static final long[] jjtoToken = {
  -   0xfd9fffffffffff81L, 0x0L, 
  +   0xee7fffffffffff81L, 0x7L, 
   };
   static final long[] jjtoSkip = {
      0x7eL, 0x0L, 
   };
  -static private SimpleCharStream input_stream;
  -static private final int[] jjrounds = new int[42];
  -static private final int[] jjstateSet = new int[84];
  -static protected char curChar;
  +private SimpleCharStream input_stream;
  +private final int[] jjrounds = new int[45];
  +private final int[] jjstateSet = new int[90];
  +protected char curChar;
   public BasicSQLParserTokenManager(SimpleCharStream stream)
   {
  -   if (input_stream != null)
  -      throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
  +   if (SimpleCharStream.staticFlag)
  +      throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
      input_stream = stream;
   }
   public BasicSQLParserTokenManager(SimpleCharStream stream, int lexState)
  @@ -1341,26 +1399,26 @@
      this(stream);
      SwitchTo(lexState);
   }
  -static public void ReInit(SimpleCharStream stream)
  +public void ReInit(SimpleCharStream stream)
   {
      jjmatchedPos = jjnewStateCnt = 0;
      curLexState = defaultLexState;
      input_stream = stream;
      ReInitRounds();
   }
  -static private final void ReInitRounds()
  +private final void ReInitRounds()
   {
      int i;
      jjround = 0x80000001;
  -   for (i = 42; i-- > 0;)
  +   for (i = 45; i-- > 0;)
         jjrounds[i] = 0x80000000;
   }
  -static public void ReInit(SimpleCharStream stream, int lexState)
  +public void ReInit(SimpleCharStream stream, int lexState)
   {
      ReInit(stream);
      SwitchTo(lexState);
   }
  -static public void SwitchTo(int lexState)
  +public void SwitchTo(int lexState)
   {
      if (lexState >= 1 || lexState < 0)
         throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
  @@ -1368,7 +1426,7 @@
         curLexState = lexState;
   }
   
  -static private final Token jjFillToken()
  +private final Token jjFillToken()
   {
      Token t = Token.newToken(jjmatchedKind);
      t.kind = jjmatchedKind;
  @@ -1381,14 +1439,14 @@
      return t;
   }
   
  -static int curLexState = 0;
  -static int defaultLexState = 0;
  -static int jjnewStateCnt;
  -static int jjround;
  -static int jjmatchedPos;
  -static int jjmatchedKind;
  +int curLexState = 0;
  +int defaultLexState = 0;
  +int jjnewStateCnt;
  +int jjround;
  +int jjmatchedPos;
  +int jjmatchedKind;
   
  -public static final Token getNextToken() 
  +public final Token getNextToken() 
   {
     int kind;
     Token specialToken = null;
  
  
  
  1.2       +19 -13    jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLParserConstants.java
  
  Index: BasicSQLParserConstants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLParserConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicSQLParserConstants.java	2001/12/03 17:36:50	1.1
  +++ BasicSQLParserConstants.java	2001/12/15 18:49:55	1.2
  @@ -45,19 +45,22 @@
     int AND = 43;
     int OR = 44;
     int NOT = 45;
  -  int EQUAL = 46;
  -  int GREATERTHAN = 47;
  -  int SMALLERTHAN = 48;
  -  int GREATERTHANOREQUAL = 49;
  -  int SMALLERTHANOREQUAL = 50;
  -  int LIKE = 51;
  -  int IDENTIFIER = 52;
  -  int LETTER = 53;
  -  int DIGIT = 54;
  -  int INTEGER_LITERAL = 55;
  -  int FLOATING_POINT_LITERAL = 56;
  -  int EXPONENT = 57;
  -  int STRING_LITERAL = 58;
  +  int NULL = 46;
  +  int NOTNULL = 47;
  +  int EQUAL = 48;
  +  int GREATERTHAN = 49;
  +  int SMALLERTHAN = 50;
  +  int GREATERTHANOREQUAL = 51;
  +  int SMALLERTHANOREQUAL = 52;
  +  int LIKE = 53;
  +  int IDENTIFIER = 54;
  +  int LETTER = 55;
  +  int DIGIT = 56;
  +  int MAXVARCHAR = 57;
  +  int INTEGER_LITERAL = 58;
  +  int FLOATING_POINT_LITERAL = 59;
  +  int EXPONENT = 60;
  +  int STRING_LITERAL = 61;
   
     int DEFAULT = 0;
   
  @@ -108,6 +111,8 @@
       "\"and\"",
       "\"or\"",
       "\"not\"",
  +    "\"null\"",
  +    "\"not null\"",
       "\"=\"",
       "\">\"",
       "\"<\"",
  @@ -117,6 +122,7 @@
       "<IDENTIFIER>",
       "<LETTER>",
       "<DIGIT>",
  +    "<MAXVARCHAR>",
       "<INTEGER_LITERAL>",
       "<FLOATING_POINT_LITERAL>",
       "<EXPONENT>",
  
  
  
  1.2       +659 -165  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLParser.java
  
  Index: BasicSQLParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLParser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicSQLParser.java	2001/12/03 17:36:50	1.1
  +++ BasicSQLParser.java	2001/12/15 18:49:55	1.2
  @@ -1,15 +1,25 @@
   /* Generated By:JavaCC: Do not edit this line. BasicSQLParser.java */
   package org.apache.avalon.db.basic.handlers.sql;
   
  +import org.apache.avalon.db.data.Column;
  +import org.apache.avalon.db.data.impl.DefaultVarCharColumn;
  +import org.apache.avalon.db.data.impl.DefaultIntegerColumn;
  +import org.apache.avalon.db.data.impl.DefaultDateColumn;
  +import org.apache.avalon.db.data.impl.DefaultTimeColumn;
  +import org.apache.avalon.db.data.impl.DefaultTimestampColumn;
  +import org.apache.avalon.db.data.impl.DefaultSmallIntColumn;
  +import org.apache.avalon.db.data.impl.DefaultRealColumn;
  +import org.apache.avalon.db.data.impl.DefaultBigIntColumn;
  +import org.apache.avalon.db.data.impl.DefaultDecimalColumn;
   import org.apache.avalon.db.server.AbstractRequestHandler;
   import org.apache.avalon.db.server.sql.ParseException;
  +import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.server.sql.SimpleCharStream;
   import org.apache.avalon.db.server.sql.Token;
   import org.apache.avalon.db.server.sql.TokenMgrError;
   
  -import java.util.ArrayList;
  -import java.io.InputStream;
  -import java.io.ByteArrayInputStream;
  +import java.util.Vector;
  +import java.util.Collection;
   
   /**
    * This class is responsible for parsing SQL Statements
  @@ -21,6 +31,12 @@
    * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
    */
   public class BasicSQLParser implements BasicSQLParserConstants {
  +    private String[] mColumns;
  +    private String[] mTables;
  +    private String[] mInsertValues;
  +    private StringBuffer mCriteriaBuffer;
  +    private Column[] mCols;
  +    private String mTableName;
   
       public static void main(String args[]) {
           BasicSQLParser parser = new BasicSQLParser(System.in);
  @@ -31,35 +47,87 @@
           }
       }
   
  -    public BasicSQLParser(String sql) {
  -        InputStream is = new ByteArrayInputStream(sql.getBytes());
  -        BasicSQLParser parser = new BasicSQLParser(is);
  +    public String[] getColumns() {
  +        return mColumns;
       }
   
  +    public String[] getTables() {
  +        return mTables;
  +    }
  +
  +    public String getCriteria() {
  +        return mCriteriaBuffer.toString();
  +    }
  +
  +    public Column[] getCols() {
  +        return mCols;
  +    }
  +
  +    public String getTableName() {
  +        return mTableName;
  +    }
  +
  +    public String[] getInsertValues() {
  +        return mInsertValues;
  +    }
  +
  +    private Column createColumn(Token name, Token type, Token length, Token notnull, Token index) throws ActionException {
  +
  +
  +        Column column = null;
  +        if (type.image.equals("varchar")) {
  +            column= new DefaultVarCharColumn(name.image,
  +                                    new Integer(length.image).intValue());
  +        } else if (type.image.equals("integer")) {
  +            column= new DefaultIntegerColumn(name.image);
  +        } else if (type.image.equals("date")) {
  +            column= new DefaultDateColumn(name.image);
  +        } else if (type.image.equals("time")) {
  +            column= new DefaultTimeColumn(name.image);
  +        } else if (type.image.equals("timestamp")) {
  +            column= new DefaultTimestampColumn(name.image);
  +        } else if (type.image.equals("smallint")) {
  +            column= new DefaultSmallIntColumn(name.image);
  +        } else if (type.image.equals("real")) {
  +            column= new DefaultRealColumn(name.image);
  +        } else if (type.image.equals("bigint")) {
  +            column= new DefaultBigIntColumn(name.image);
  +        } else if (type.image.equals("decimal")) {
  +            column= new DefaultDecimalColumn(name.image);
  +        } else {
  +            throw new ActionException("Column type " + type.image + " not recognised");
  +        }
  +        //column.setIndex(ix);
  +        return column;
  +    }
  +
   /**
    * Test Method for command line input
    */
  -  static final public void Test() throws ParseException {
  -    parseSQLString();
  +  final public void Test() throws ParseException {
  +    ParseSQLString();
     }
   
  -  static final public String parseSQLString() throws ParseException {
  +  final public String ParseSQLString() throws ParseException {
       String stm;
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case SELECT:
  -      stm = Select();
  +      stm = ParseSelect();
         break;
       case UPDATE:
  -      stm = Update();
  +      stm = ParseUpdate();
         break;
       case INSERT:
  -      stm = Insert();
  +      stm = ParseInsert();
         break;
       case DROP:
  -      stm = Drop();
  +      stm = ParseDrop();
         break;
       case DELETE:
  -      stm = Delete();
  +      stm = ParseDelete();
  +      break;
  +    case CREATE:
  +      stm = ParseCreateTable();
         break;
       default:
         jj_la1[0] = jj_gen;
  @@ -67,8 +135,8 @@
         throw new ParseException();
       }
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -    case 59:
  -      jj_consume_token(59);
  +    case 62:
  +      jj_consume_token(62);
         break;
       case 0:
         jj_consume_token(0);
  @@ -82,16 +150,24 @@
       throw new Error("Missing return statement in function");
     }
   
  -  static final public String Select() throws ParseException {
  +  final public String ParseSelect() throws ParseException {
       String stm;
  +    Vector columns;
  +    Vector tables;
       jj_consume_token(SELECT);
             stm = "SELECT";
  -    getColumns();
  +    columns = ParseColumns();
  +                mColumns = new String[columns.size()];
  +                columns.toArray(mColumns);
  +                System.out.println("mColumns.length=" + mColumns.length);
       jj_consume_token(FROM);
  -    getTables();
  +    tables = ParseTables();
  +                mTables = new String[tables.size()];
  +                columns.toArray(mTables);
  +                System.out.println("mTables.length=" + mTables.length);
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case WHERE:
  -      Where();
  +      ParseWhere();
         break;
       default:
         jj_la1[2] = jj_gen;
  @@ -101,20 +177,20 @@
       throw new Error("Missing return statement in function");
     }
   
  -  static final public String Update() throws ParseException {
  +  final public String ParseUpdate() throws ParseException {
        String stm;
       jj_consume_token(UPDATE);
             stm = "UPDATE";
  -    getTables();
  +    ParseTables();
       jj_consume_token(SET);
       label_1:
       while (true) {
         jj_consume_token(IDENTIFIER);
         jj_consume_token(EQUAL);
  -      ExprValue();
  +      ParseExprValue();
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -      case 60:
  -        jj_consume_token(60);
  +      case 63:
  +        jj_consume_token(63);
                     System.out.println(",");
           break;
         default:
  @@ -132,7 +208,7 @@
       }
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case WHERE:
  -      Where();
  +      ParseWhere();
         break;
       default:
         jj_la1[5] = jj_gen;
  @@ -143,25 +219,32 @@
       throw new Error("Missing return statement in function");
     }
   
  -  static final public void Rollback() throws ParseException {
  +  final public void ParseRollback() throws ParseException {
       jj_consume_token(0);
     }
   
  -  static final public String Insert() throws ParseException {
  +  final public String ParseInsert() throws ParseException {
       String stm;
  +    Token name;
  +    Vector columns = new Vector();
  +    Vector values = new Vector();
       jj_consume_token(INSERT);
       jj_consume_token(INTO);
                        stm = "INSERT";
  -    jj_consume_token(IDENTIFIER);
  +    name = jj_consume_token(IDENTIFIER);
  +        mTableName = name.image;
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -    case 61:
  +    case 64:
         label_2:
         while (true) {
  -        jj_consume_token(61);
  -        getColumns();
  -        jj_consume_token(62);
  +        jj_consume_token(64);
  +        columns = ParseColumns();
  +           mColumns = new String[columns.size()];
  +           columns.toArray(mColumns);
  +           System.out.println("mColumns.length=" + mColumns.length);
  +        jj_consume_token(65);
           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -        case 61:
  +        case 64:
             ;
             break;
           default:
  @@ -177,9 +260,12 @@
       label_3:
       while (true) {
         jj_consume_token(VALUES);
  -      jj_consume_token(61);
  -      getValues();
  -      jj_consume_token(62);
  +      jj_consume_token(64);
  +      values = ParseValues();
  +               mInsertValues = new String[values.size()];
  +               values.toArray(mInsertValues);
  +               System.out.println("mInsertValues.length=" + mColumns.length);
  +      jj_consume_token(65);
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
         case VALUES:
           ;
  @@ -193,11 +279,11 @@
       throw new Error("Missing return statement in function");
     }
   
  -  static final public void Grant() throws ParseException {
  +  final public void ParseGrant() throws ParseException {
       jj_consume_token(0);
     }
   
  -  static final public String Drop() throws ParseException {
  +  final public String ParseDrop() throws ParseException {
       String stm;
       jj_consume_token(DROP);
             stm = "DROP";
  @@ -207,7 +293,7 @@
       throw new Error("Missing return statement in function");
     }
   
  -  static final public String Delete() throws ParseException {
  +  final public String ParseDelete() throws ParseException {
       String stm;
       jj_consume_token(DELETE);
       jj_consume_token(FROM);
  @@ -215,7 +301,7 @@
       jj_consume_token(IDENTIFIER);
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case WHERE:
  -      Where();
  +      ParseWhere();
         break;
       default:
         jj_la1[9] = jj_gen;
  @@ -226,21 +312,44 @@
       throw new Error("Missing return statement in function");
     }
   
  -  static final public void Commit() throws ParseException {
  +  final public void ParseCommit() throws ParseException {
       jj_consume_token(0);
     }
   
  -  static final public void Alter() throws ParseException {
  +  final public void ParseAlter() throws ParseException {
       jj_consume_token(0);
     }
   
  -  static final public void Where() throws ParseException {
  +  final public String ParseCreateTable() throws ParseException {
  +    String stm;
  +    Vector columns;
  +    Token name;
  +    jj_consume_token(CREATE);
  +    jj_consume_token(TABLE);
  +        stm="CREATETABLE";
  +    name = jj_consume_token(IDENTIFIER);
  +                        mTableName = name.image;
  +    jj_consume_token(64);
  +    columns = ParseCreateTblValues();
  +            mCols = new Column[columns.size()];
  +            columns.toArray(mCols);
  +    jj_consume_token(65);
  +      {if (true) return stm;}
  +    throw new Error("Missing return statement in function");
  +  }
  +
  +  final public void ParseWhere() throws ParseException {
       jj_consume_token(WHERE);
  -          OrExpr();
  +            System.out.println("Parse where");
  +            mCriteriaBuffer = new StringBuffer();
  +            mCriteriaBuffer.append("if ( ");
  +            ParseOrExpr();
  +            mCriteriaBuffer.append(" )");
  +            System.out.println("mCriteriaBuffer=" + mCriteriaBuffer);
     }
   
  -  static final public void OrExpr() throws ParseException {
  -    AndExpr();
  +  final public void ParseOrExpr() throws ParseException {
  +    ParseAndExpr();
       label_4:
       while (true) {
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  @@ -252,13 +361,13 @@
           break label_4;
         }
         jj_consume_token(OR);
  -             System.out.println("in or");
  -      AndExpr();
  +            mCriteriaBuffer.append(" || ");
  +      ParseAndExpr();
       }
     }
   
  -  static final public void AndExpr() throws ParseException {
  -    NotExpr();
  +  final public void ParseAndExpr() throws ParseException {
  +    ParseNotExpr();
       label_5:
       while (true) {
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  @@ -270,12 +379,12 @@
           break label_5;
         }
         jj_consume_token(AND);
  -          System.out.println("in and");
  -      NotExpr();
  +            mCriteriaBuffer.append(" && ");
  +      ParseNotExpr();
       }
     }
   
  -  static final public void NotExpr() throws ParseException {
  +  final public void ParseNotExpr() throws ParseException {
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case NOT:
         jj_consume_token(NOT);
  @@ -288,18 +397,22 @@
       CompareExpr();
     }
   
  -  static final public void CompareExpr() throws ParseException {
  +  final public void CompareExpr() throws ParseException {
  +    String rs_comp;
  +    String rs_right;
  +    String rs_left;
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case IDENTIFIER:
       case INTEGER_LITERAL:
       case FLOATING_POINT_LITERAL:
       case STRING_LITERAL:
  -      ExprValue();
  -      CompareOps();
  -      ExprValue();
  +      rs_left = ParseExprValue();
  +      rs_comp = CompareOps();
  +      rs_right = ParseRightExprValue();
  +        mCriteriaBuffer.append(rs_comp + rs_left + "," +  rs_right + " )");
         break;
  -    case 61:
  -      Term();
  +    case 64:
  +      ParseTerm();
         break;
       default:
         jj_la1[13] = jj_gen;
  @@ -308,240 +421,517 @@
       }
     }
   
  -  static final public void ExprValue() throws ParseException {
  +  final public String ParseExprValue() throws ParseException {
  +    Token token;
  +    String rs = new String();
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case IDENTIFIER:
  -      jj_consume_token(IDENTIFIER);
  -                   System.out.println("expr is <INDENTIFIER>");
  +      token = jj_consume_token(IDENTIFIER);
  +                               rs = " columnCheckLeft.getColumn(row,\""
  +                                    + token.image + "\") ";
         break;
       case STRING_LITERAL:
  -      jj_consume_token(STRING_LITERAL);
  -                         System.out.println("expr is <STRING_LITERAL>");
  +      token = jj_consume_token(STRING_LITERAL);
  +                                      System.out.println("expr is <STRING_LITERAL>"); rs="bla";
         break;
       case INTEGER_LITERAL:
  -      jj_consume_token(INTEGER_LITERAL);
  -                          System.out.println("expr is <INTEGER_LITERAL>");
  +      token = jj_consume_token(INTEGER_LITERAL);
  +                                       System.out.println("expr is <INTEGER_LITERAL>"); rs="bla";
         break;
       case FLOATING_POINT_LITERAL:
  -      jj_consume_token(FLOATING_POINT_LITERAL);
  -                                 System.out.println("expr is <FLOATING_POINT_LITERAL>");
  +      token = jj_consume_token(FLOATING_POINT_LITERAL);
  +                System.out.println("expr is <FLOATING_POINT_LITERAL>"); rs="bla";
         break;
       default:
         jj_la1[14] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
  +      {if (true) return rs;}
  +    throw new Error("Missing return statement in function");
     }
   
  -  static final public void UpdateValue() throws ParseException {
  +  final public String ParseRightExprValue() throws ParseException {
  +    Token token;
  +    String rs = new String();
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +    case IDENTIFIER:
  +      token = jj_consume_token(IDENTIFIER);
  +                               System.out.println("expr is <INDENTIFIER>");
  +      break;
       case STRING_LITERAL:
  -      jj_consume_token(STRING_LITERAL);
  -                       System.out.println("value is <STRING_LITERAL>");
  +      token = jj_consume_token(STRING_LITERAL);
  +                                      rs = " columnCheckRight.getColumn(row,\""
  +                                           + token.image + "\") ";
         break;
       case INTEGER_LITERAL:
  -      jj_consume_token(INTEGER_LITERAL);
  -                          System.out.println("value is <INTEGER_LITERAL>");
  +      token = jj_consume_token(INTEGER_LITERAL);
  +                                       System.out.println("expr is <INTEGER_LITERAL>");
         break;
       case FLOATING_POINT_LITERAL:
  -      jj_consume_token(FLOATING_POINT_LITERAL);
  -                                 System.out.println("value expr is <FLOATING_POINT_LITERAL>");
  +      token = jj_consume_token(FLOATING_POINT_LITERAL);
  +                                              System.out.println("expr is <FLOATING_POINT_LITERAL>");
         break;
       default:
         jj_la1[15] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
  +      {if (true) return rs;}
  +    throw new Error("Missing return statement in function");
     }
   
  -  static final public void CompareOps() throws ParseException {
  +  final public String ParseUpdateValue() throws ParseException {
  +    Token value;
  +    String stringval;
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +    case STRING_LITERAL:
  +      value = jj_consume_token(STRING_LITERAL);
  +                                   stringval = value.image;
  +      break;
  +    case INTEGER_LITERAL:
  +      value = jj_consume_token(INTEGER_LITERAL);
  +                                      stringval = value.image;
  +      break;
  +    case FLOATING_POINT_LITERAL:
  +      value = jj_consume_token(FLOATING_POINT_LITERAL);
  +                                             stringval = value.image;
  +      break;
  +    default:
  +      jj_la1[16] = jj_gen;
  +      jj_consume_token(-1);
  +      throw new ParseException();
  +    }
  +      {if (true) return stringval;}
  +    throw new Error("Missing return statement in function");
  +  }
  +
  +  final public String CompareOps() throws ParseException {
  +    String rs = new String();
  +    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
       case EQUAL:
         jj_consume_token(EQUAL);
  -              System.out.println("EQUAL");
  +                  rs = " testHelper.equal( ";
         break;
       case GREATERTHAN:
         jj_consume_token(GREATERTHAN);
  -                       System.out.println("GREATERTHAN");
  +                           System.out.println("GREATERTHAN");
         break;
       case SMALLERTHAN:
         jj_consume_token(SMALLERTHAN);
  -                       System.out.println("SMALLERTHAN");
  +                           System.out.println("SMALLERTHAN");
         break;
       case GREATERTHANOREQUAL:
         jj_consume_token(GREATERTHANOREQUAL);
  -                              System.out.println("GREATERTHANOREQUAL");
  +                                  System.out.println("GREATERTHANOREQUAL");
         break;
       case SMALLERTHANOREQUAL:
         jj_consume_token(SMALLERTHANOREQUAL);
  -                              System.out.println("SMALLERTHANOREQUAL");
  +                                  System.out.println("SMALLERTHANOREQUAL");
         break;
       case LIKE:
         jj_consume_token(LIKE);
  -                System.out.println("LIKE");
  +                    System.out.println("LIKE");
         break;
       default:
  -      jj_la1[16] = jj_gen;
  +      jj_la1[17] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
  +      {if (true) return rs;}
  +    throw new Error("Missing return statement in function");
     }
   
  -  static final public void Term() throws ParseException {
  -    jj_consume_token(61);
  -             System.out.println("(");
  -    OrExpr();
  -    jj_consume_token(62);
  -             System.out.println(")");
  +  final public void ParseTerm() throws ParseException {
  +    jj_consume_token(64);
  +             mCriteriaBuffer.append("(");
  +    ParseOrExpr();
  +    jj_consume_token(65);
  +             mCriteriaBuffer.append(")");
     }
   
  -  static final public void getColumns() throws ParseException {
  +  final public Vector ParseColumns() throws ParseException {
       String col;
  +    Vector vector = new Vector();
       Token column;
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -    case 63:
  -      jj_consume_token(63);
  +    case 66:
  +      jj_consume_token(66);
               System.out.println("all columns");
         break;
       case IDENTIFIER:
         column = jj_consume_token(IDENTIFIER);
  -                           System.out.println("column=" + column.image);
  +                            vector.add(column.image);
         label_6:
         while (true) {
           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -        case 60:
  +        case 63:
             ;
             break;
           default:
  -          jj_la1[17] = jj_gen;
  +          jj_la1[18] = jj_gen;
             break label_6;
           }
  -        jj_consume_token(60);
  +        jj_consume_token(63);
               System.out.println(",");
           column = jj_consume_token(IDENTIFIER);
  -                               System.out.println("column=" + column.image);
  +                                vector.add(column.image);
         }
  +      {if (true) return vector;}
         break;
       default:
  -      jj_la1[18] = jj_gen;
  +      jj_la1[19] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
       }
  +    throw new Error("Missing return statement in function");
     }
   
  -  static final public void getTables() throws ParseException {
  +  final public Vector ParseTables() throws ParseException {
       String tab;
  +    Vector tables = new Vector();
       Token table;
       table = jj_consume_token(IDENTIFIER);
  -                          System.out.println("table=" + table.image);
  +                           tables.add(table.image);
       label_7:
       while (true) {
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -      case 60:
  +      case 63:
           ;
           break;
         default:
  -        jj_la1[19] = jj_gen;
  +        jj_la1[20] = jj_gen;
           break label_7;
         }
  -      jj_consume_token(60);
  -            System.out.println(",");
  +      jj_consume_token(63);
         table = jj_consume_token(IDENTIFIER);
  -                              System.out.println("table=" + table.image);
  +                             tables.add(table.image);
       }
  +      {if (true) return tables;}
  +    throw new Error("Missing return statement in function");
     }
   
  -  static final public void getValues() throws ParseException {
  -    UpdateValue();
  +  final public Vector ParseValues() throws ParseException {
  +    Vector values = new Vector();
  +    String value;
  +    value = ParseUpdateValue();
  +                                 values.add(value);
       label_8:
       while (true) {
  -      jj_consume_token(60);
  +      jj_consume_token(63);
               System.out.println(",");
  -      UpdateValue();
  +      value = ParseUpdateValue();
  +                                     values.add(value);
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  -      case 60:
  +      case 63:
           ;
           break;
         default:
  -        jj_la1[20] = jj_gen;
  +        jj_la1[21] = jj_gen;
           break label_8;
         }
       }
  +      {if (true) return values;}
  +    throw new Error("Missing return statement in function");
     }
   
  -  static private boolean jj_initialized_once = false;
  -  static public BasicSQLParserTokenManager token_source;
  -  static SimpleCharStream jj_input_stream;
  -  static public Token token, jj_nt;
  -  static private int jj_ntk;
  -  static private int jj_gen;
  -  static final private int[] jj_la1 = new int[21];
  -  static final private int[] jj_la1_0 = {0x6b0000,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
  -  static final private int[] jj_la1_1 = {0x0,0x8000000,0x4,0x10000000,0x100000,0x4,0x20000000,0x20000000,0x20,0x4,0x1000,0x800,0x2000,0x25900000,0x5900000,0x5800000,0xfc000,0x10000000,0x80100000,0x10000000,0x10000000,};
  +  final public Vector ParseCreateTblValues() throws ParseException {
  +    Vector columns = new Vector();
  +    Column column;
  +    column = ParseCreateColumn();
  +        columns.add(column);
  +    label_9:
  +    while (true) {
  +      jj_consume_token(63);
  +      column = ParseCreateColumn();
  +            columns.add(column);
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case 63:
  +        ;
  +        break;
  +      default:
  +        jj_la1[22] = jj_gen;
  +        break label_9;
  +      }
  +    }
  +     {if (true) return columns;}
  +    throw new Error("Missing return statement in function");
  +  }
   
  -  public BasicSQLParser(java.io.InputStream stream) {
  -    if (jj_initialized_once) {
  -      System.out.println("ERROR: Second call to constructor of static parser.  You must");
  -      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
  -      System.out.println("       during parser generation.");
  -      throw new Error();
  +  final public Column ParseCreateColumn() throws ParseException {
  +    Token ident;
  +    Token type;
  +    Token length;
  +    Token notnull = null;
  +    Column column = null;
  +    int iLength;
  +    boolean bNotnull;
  +    if (jj_2_1(2)) {
  +      ident = jj_consume_token(IDENTIFIER);
  +      type = jj_consume_token(VARCHAR);
  +      length = jj_consume_token(MAXVARCHAR);
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case NOTNULL:
  +        notnull = jj_consume_token(NOTNULL);
  +        break;
  +      default:
  +        jj_la1[23] = jj_gen;
  +        ;
  +      }
  +            try {
  +                column = createColumn(ident,type,length,notnull,null);
  +            } catch (ActionException ae) {}
  +    } else if (jj_2_2(2)) {
  +      ident = jj_consume_token(IDENTIFIER);
  +      type = jj_consume_token(TIMESTAMP);
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case NOTNULL:
  +        notnull = jj_consume_token(NOTNULL);
  +        break;
  +      default:
  +        jj_la1[24] = jj_gen;
  +        ;
  +      }
  +            try {
  +                column = createColumn(ident,type,null,notnull,null);
  +            } catch (ActionException ae) {}
  +    } else if (jj_2_3(2)) {
  +      ident = jj_consume_token(IDENTIFIER);
  +      type = jj_consume_token(SMALLINT);
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case NOTNULL:
  +        notnull = jj_consume_token(NOTNULL);
  +        break;
  +      default:
  +        jj_la1[25] = jj_gen;
  +        ;
  +      }
  +            try {
  +                column = createColumn(ident,type,null,notnull,null);
  +            } catch (ActionException ae) {}
  +    } else if (jj_2_4(2)) {
  +      ident = jj_consume_token(IDENTIFIER);
  +      type = jj_consume_token(REAL);
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case NOTNULL:
  +        notnull = jj_consume_token(NOTNULL);
  +        break;
  +      default:
  +        jj_la1[26] = jj_gen;
  +        ;
  +      }
  +            try {
  +                column = createColumn(ident,type,null,notnull,null);
  +            } catch (ActionException ae) {}
  +    } else if (jj_2_5(2)) {
  +      ident = jj_consume_token(IDENTIFIER);
  +      type = jj_consume_token(INTEGER);
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case NOTNULL:
  +        notnull = jj_consume_token(NOTNULL);
  +        break;
  +      default:
  +        jj_la1[27] = jj_gen;
  +        ;
  +      }
  +            try {
  +                column = createColumn(ident,type,null,notnull,null);
  +            } catch (ActionException ae) {}
  +    } else if (jj_2_6(2)) {
  +      ident = jj_consume_token(IDENTIFIER);
  +      type = jj_consume_token(DECIMAL);
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case NOTNULL:
  +        notnull = jj_consume_token(NOTNULL);
  +        break;
  +      default:
  +        jj_la1[28] = jj_gen;
  +        ;
  +      }
  +            try {
  +                column = createColumn(ident,type,null,notnull,null);
  +            } catch (ActionException ae) {}
  +    } else {
  +      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +      case IDENTIFIER:
  +        ident = jj_consume_token(IDENTIFIER);
  +        type = jj_consume_token(DATE);
  +        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  +        case NOTNULL:
  +          notnull = jj_consume_token(NOTNULL);
  +          break;
  +        default:
  +          jj_la1[29] = jj_gen;
  +          ;
  +        }
  +            try {
  +                column = createColumn(ident,type,null,notnull,null);
  +            } catch (ActionException ae) {}
  +        break;
  +      default:
  +        jj_la1[30] = jj_gen;
  +        jj_consume_token(-1);
  +        throw new ParseException();
  +      }
       }
  -    jj_initialized_once = true;
  +      {if (true) return column;}
  +    throw new Error("Missing return statement in function");
  +  }
  +
  +  final private boolean jj_2_1(int xla) {
  +    jj_la = xla; jj_lastpos = jj_scanpos = token;
  +    boolean retval = !jj_3_1();
  +    jj_save(0, xla);
  +    return retval;
  +  }
  +
  +  final private boolean jj_2_2(int xla) {
  +    jj_la = xla; jj_lastpos = jj_scanpos = token;
  +    boolean retval = !jj_3_2();
  +    jj_save(1, xla);
  +    return retval;
  +  }
  +
  +  final private boolean jj_2_3(int xla) {
  +    jj_la = xla; jj_lastpos = jj_scanpos = token;
  +    boolean retval = !jj_3_3();
  +    jj_save(2, xla);
  +    return retval;
  +  }
  +
  +  final private boolean jj_2_4(int xla) {
  +    jj_la = xla; jj_lastpos = jj_scanpos = token;
  +    boolean retval = !jj_3_4();
  +    jj_save(3, xla);
  +    return retval;
  +  }
  +
  +  final private boolean jj_2_5(int xla) {
  +    jj_la = xla; jj_lastpos = jj_scanpos = token;
  +    boolean retval = !jj_3_5();
  +    jj_save(4, xla);
  +    return retval;
  +  }
  +
  +  final private boolean jj_2_6(int xla) {
  +    jj_la = xla; jj_lastpos = jj_scanpos = token;
  +    boolean retval = !jj_3_6();
  +    jj_save(5, xla);
  +    return retval;
  +  }
  +
  +  final private boolean jj_3_3() {
  +    if (jj_scan_token(IDENTIFIER)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_scan_token(SMALLINT)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3_1() {
  +    if (jj_scan_token(IDENTIFIER)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_scan_token(VARCHAR)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3_6() {
  +    if (jj_scan_token(IDENTIFIER)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_scan_token(DECIMAL)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3_4() {
  +    if (jj_scan_token(IDENTIFIER)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_scan_token(REAL)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3_2() {
  +    if (jj_scan_token(IDENTIFIER)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_scan_token(TIMESTAMP)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  final private boolean jj_3_5() {
  +    if (jj_scan_token(IDENTIFIER)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    if (jj_scan_token(INTEGER)) return true;
  +    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
  +    return false;
  +  }
  +
  +  public BasicSQLParserTokenManager token_source;
  +  SimpleCharStream jj_input_stream;
  +  public Token token, jj_nt;
  +  private int jj_ntk;
  +  private Token jj_scanpos, jj_lastpos;
  +  private int jj_la;
  +  public boolean lookingAhead = false;
  +  private boolean jj_semLA;
  +  private int jj_gen;
  +  final private int[] jj_la1 = new int[31];
  +  final private int[] jj_la1_0 = {0xeb0000,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
  +  final private int[] jj_la1_1 = {0x0,0x40000000,0x4,0x80000000,0x400000,0x4,0x0,0x0,0x20,0x4,0x1000,0x800,0x2000,0x2c400000,0x2c400000,0x2c400000,0x2c000000,0x3f0000,0x80000000,0x400000,0x80000000,0x80000000,0x80000000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x400000,};
  +  final private int[] jj_la1_2 = {0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
  +  final private JJCalls[] jj_2_rtns = new JJCalls[6];
  +  private boolean jj_rescan = false;
  +  private int jj_gc = 0;
  +
  +  public BasicSQLParser(java.io.InputStream stream) {
       jj_input_stream = new SimpleCharStream(stream, 1, 1);
       token_source = new BasicSQLParserTokenManager(jj_input_stream);
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 31; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
     }
   
  -  static public void ReInit(java.io.InputStream stream) {
  +  public void ReInit(java.io.InputStream stream) {
       jj_input_stream.ReInit(stream, 1, 1);
       token_source.ReInit(jj_input_stream);
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 31; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
     }
   
     public BasicSQLParser(java.io.Reader stream) {
  -    if (jj_initialized_once) {
  -      System.out.println("ERROR: Second call to constructor of static parser.  You must");
  -      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
  -      System.out.println("       during parser generation.");
  -      throw new Error();
  -    }
  -    jj_initialized_once = true;
       jj_input_stream = new SimpleCharStream(stream, 1, 1);
       token_source = new BasicSQLParserTokenManager(jj_input_stream);
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 31; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
     }
   
  -  static public void ReInit(java.io.Reader stream) {
  +  public void ReInit(java.io.Reader stream) {
       jj_input_stream.ReInit(stream, 1, 1);
       token_source.ReInit(jj_input_stream);
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 31; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
     }
   
     public BasicSQLParser(BasicSQLParserTokenManager tm) {
  -    if (jj_initialized_once) {
  -      System.out.println("ERROR: Second call to constructor of static parser.  You must");
  -      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
  -      System.out.println("       during parser generation.");
  -      throw new Error();
  -    }
  -    jj_initialized_once = true;
       token_source = tm;
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 31; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
     }
   
     public void ReInit(BasicSQLParserTokenManager tm) {
  @@ -549,24 +939,54 @@
       token = new Token();
       jj_ntk = -1;
       jj_gen = 0;
  -    for (int i = 0; i < 21; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < 31; i++) jj_la1[i] = -1;
  +    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
     }
   
  -  static final private Token jj_consume_token(int kind) throws ParseException {
  +  final private Token jj_consume_token(int kind) throws ParseException {
       Token oldToken;
       if ((oldToken = token).next != null) token = token.next;
       else token = token.next = token_source.getNextToken();
       jj_ntk = -1;
       if (token.kind == kind) {
         jj_gen++;
  +      if (++jj_gc > 100) {
  +        jj_gc = 0;
  +        for (int i = 0; i < jj_2_rtns.length; i++) {
  +          JJCalls c = jj_2_rtns[i];
  +          while (c != null) {
  +            if (c.gen < jj_gen) c.first = null;
  +            c = c.next;
  +          }
  +        }
  +      }
         return token;
       }
       token = oldToken;
       jj_kind = kind;
       throw generateParseException();
     }
  +
  +  final private boolean jj_scan_token(int kind) {
  +    if (jj_scanpos == jj_lastpos) {
  +      jj_la--;
  +      if (jj_scanpos.next == null) {
  +        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
  +      } else {
  +        jj_lastpos = jj_scanpos = jj_scanpos.next;
  +      }
  +    } else {
  +      jj_scanpos = jj_scanpos.next;
  +    }
  +    if (jj_rescan) {
  +      int i = 0; Token tok = token;
  +      while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
  +      if (tok != null) jj_add_error_token(kind, i);
  +    }
  +    return (jj_scanpos.kind != kind);
  +  }
   
  -  static final public Token getNextToken() {
  +  final public Token getNextToken() {
       if (token.next != null) token = token.next;
       else token = token.next = token_source.getNextToken();
       jj_ntk = -1;
  @@ -574,8 +994,8 @@
       return token;
     }
   
  -  static final public Token getToken(int index) {
  -    Token t = token;
  +  final public Token getToken(int index) {
  +    Token t = lookingAhead ? jj_scanpos : token;
       for (int i = 0; i < index; i++) {
         if (t.next != null) t = t.next;
         else t = t.next = token_source.getNextToken();
  @@ -583,28 +1003,58 @@
       return t;
     }
   
  -  static final private int jj_ntk() {
  +  final private int jj_ntk() {
       if ((jj_nt=token.next) == null)
         return (jj_ntk = (token.next=token_source.getNextToken()).kind);
       else
         return (jj_ntk = jj_nt.kind);
     }
   
  -  static private java.util.Vector jj_expentries = new java.util.Vector();
  -  static private int[] jj_expentry;
  -  static private int jj_kind = -1;
  +  private java.util.Vector jj_expentries = new java.util.Vector();
  +  private int[] jj_expentry;
  +  private int jj_kind = -1;
  +  private int[] jj_lasttokens = new int[100];
  +  private int jj_endpos;
  +
  +  private void jj_add_error_token(int kind, int pos) {
  +    if (pos >= 100) return;
  +    if (pos == jj_endpos + 1) {
  +      jj_lasttokens[jj_endpos++] = kind;
  +    } else if (jj_endpos != 0) {
  +      jj_expentry = new int[jj_endpos];
  +      for (int i = 0; i < jj_endpos; i++) {
  +        jj_expentry[i] = jj_lasttokens[i];
  +      }
  +      boolean exists = false;
  +      for (java.util.Enumeration enum = jj_expentries.elements(); enum.hasMoreElements();) {
  +        int[] oldentry = (int[])(enum.nextElement());
  +        if (oldentry.length == jj_expentry.length) {
  +          exists = true;
  +          for (int i = 0; i < jj_expentry.length; i++) {
  +            if (oldentry[i] != jj_expentry[i]) {
  +              exists = false;
  +              break;
  +            }
  +          }
  +          if (exists) break;
  +        }
  +      }
  +      if (!exists) jj_expentries.addElement(jj_expentry);
  +      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
  +    }
  +  }
   
  -  static final public ParseException generateParseException() {
  +  final public ParseException generateParseException() {
       jj_expentries.removeAllElements();
  -    boolean[] la1tokens = new boolean[64];
  -    for (int i = 0; i < 64; i++) {
  +    boolean[] la1tokens = new boolean[67];
  +    for (int i = 0; i < 67; i++) {
         la1tokens[i] = false;
       }
       if (jj_kind >= 0) {
         la1tokens[jj_kind] = true;
         jj_kind = -1;
       }
  -    for (int i = 0; i < 21; i++) {
  +    for (int i = 0; i < 31; i++) {
         if (jj_la1[i] == jj_gen) {
           for (int j = 0; j < 32; j++) {
             if ((jj_la1_0[i] & (1<<j)) != 0) {
  @@ -613,27 +1063,71 @@
             if ((jj_la1_1[i] & (1<<j)) != 0) {
               la1tokens[32+j] = true;
             }
  +          if ((jj_la1_2[i] & (1<<j)) != 0) {
  +            la1tokens[64+j] = true;
  +          }
           }
         }
       }
  -    for (int i = 0; i < 64; i++) {
  +    for (int i = 0; i < 67; i++) {
         if (la1tokens[i]) {
           jj_expentry = new int[1];
           jj_expentry[0] = i;
           jj_expentries.addElement(jj_expentry);
         }
       }
  +    jj_endpos = 0;
  +    jj_rescan_token();
  +    jj_add_error_token(0, 0);
       int[][] exptokseq = new int[jj_expentries.size()][];
       for (int i = 0; i < jj_expentries.size(); i++) {
         exptokseq[i] = (int[])jj_expentries.elementAt(i);
       }
       return new ParseException(token, exptokseq, tokenImage);
     }
  +
  +  final public void enable_tracing() {
  +  }
   
  -  static final public void enable_tracing() {
  +  final public void disable_tracing() {
  +  }
  +
  +  final private void jj_rescan_token() {
  +    jj_rescan = true;
  +    for (int i = 0; i < 6; i++) {
  +      JJCalls p = jj_2_rtns[i];
  +      do {
  +        if (p.gen > jj_gen) {
  +          jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
  +          switch (i) {
  +            case 0: jj_3_1(); break;
  +            case 1: jj_3_2(); break;
  +            case 2: jj_3_3(); break;
  +            case 3: jj_3_4(); break;
  +            case 4: jj_3_5(); break;
  +            case 5: jj_3_6(); break;
  +          }
  +        }
  +        p = p.next;
  +      } while (p != null);
  +    }
  +    jj_rescan = false;
  +  }
  +
  +  final private void jj_save(int index, int xla) {
  +    JJCalls p = jj_2_rtns[index];
  +    while (p.gen > jj_gen) {
  +      if (p.next == null) { p = p.next = new JJCalls(); break; }
  +      p = p.next;
  +    }
  +    p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
     }
   
  -  static final public void disable_tracing() {
  +  static final class JJCalls {
  +    int gen;
  +    Token first;
  +    int arg;
  +    JJCalls next;
     }
   
   }
  
  
  
  1.2       +9 -4      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLHandler.java
  
  Index: BasicSQLHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicSQLHandler.java	2001/12/03 17:36:50	1.1
  +++ BasicSQLHandler.java	2001/12/15 18:49:55	1.2
  @@ -12,6 +12,9 @@
   import org.apache.avalon.db.basic.handlers.sql.BasicSQLParser;
   import org.apache.avalon.db.services.DatabasePersistor;
   
  +import java.io.InputStream;
  +import java.io.ByteArrayInputStream;
  +
   /**
    * Class BasicSQLHandler
    *
  @@ -21,7 +24,7 @@
    */
   public abstract class BasicSQLHandler extends AbstractRequestHandler {
   
  -    protected final BasicSQLParserManager mParser;
  +    protected final BasicSQLParserManager mParserMgr;
   
       /**
        * Constructor BasicSQLHandler
  @@ -32,10 +35,12 @@
       public BasicSQLHandler(BasicSQLParserManager parser, 
                              DatabasePersistor databasePersistor) {
           super(databasePersistor);
  -        mParser = parser;
  +        mParserMgr = parser;
       }
   
  -    public void initBasicSQLPaser(String sql) {
  -        BasicSQLParser parser = new BasicSQLParser(sql);
  +    public BasicSQLParser initBasicSQLPaser(String sql) {
  +        InputStream is = new ByteArrayInputStream(sql.getBytes());
  +        BasicSQLParser parser = new BasicSQLParser(is);
  +        return parser;
       }
   }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLInsertRowsHandler.java
  
  Index: BasicSQLInsertRowsHandler.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.db.basic.handlers.sql;
  
  import org.apache.avalon.db.basic.parser.BasicSQLParserManager;
  import org.apache.avalon.db.basic.data.BasicTable;
  import org.apache.avalon.db.basic.data.BasicRow;
  import org.apache.avalon.db.basic.actions.BasicInsertRows;
  import org.apache.avalon.db.services.DatabasePersistor;
  import org.apache.avalon.db.transport.Reply;
  import org.apache.avalon.db.transport.Request;
  import org.apache.avalon.db.transport.InsertRowsRequest;
  import org.apache.avalon.db.transport.WriteReply;
  import org.apache.avalon.db.actions.ActionException;
  import org.apache.avalon.db.actions.InsertRows;
  import org.apache.avalon.db.data.Queryable;
  import org.apache.avalon.db.data.ValidationException;
  import org.apache.avalon.db.data.Column;
  import org.apache.avalon.db.data.WritableColumn;
  import org.apache.avalon.db.server.DBRequestContext;
  import org.apache.avalon.db.server.sql.ParseException;
  
  import java.util.Vector;
  import java.util.Collection;
  
  
  /**
   * Class BasicSQLInsertRowsHandler
   *
   *
   * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
   * @version $Revision: 1.1 $
   */
  public class BasicSQLInsertRowsHandler extends BasicSQLHandler {
  
      public BasicSQLInsertRowsHandler(BasicSQLParserManager parser,
                                       DatabasePersistor databasePersistor) {
          super(parser, databasePersistor);
      }
  
      
      public Reply handleRequest(DBRequestContext context, Request request) throws ActionException {
          Collection rows = null;
  
          BasicSQLParser parser = initBasicSQLPaser(((InsertRowsRequest)request).getSql());
          try {
              parser.ParseInsert();
          } catch (ParseException pe) {
              getLogger().error("handleRequest(..): ParseException:",pe);
          }
          Queryable queryable = (Queryable) mDatabasePersistor.getQueryable(parser.getTableName());
          String[] columns = parser.getColumns();
          String[] values = parser.getInsertValues();
  
          try {
              rows = processRow((BasicTable)queryable, values, columns);
          } catch (ValidationException e) { }
      
           //TOTO should be able to work with views and indexes.
          InsertRows action = new BasicInsertRows((BasicTable) queryable, rows);
  
          mParserMgr.initializeAction(action);
          action.execute();
  
          return new WriteReply(action.getRecordCount());
      }
  
      private Collection processRow(BasicTable table, String[] values, String[] columns) throws ValidationException {
          Vector rows = new Vector();
          Object[] convValues = new Object[values.length];
  
          /** test column, value cnt */
          if(columns.length > 0) {
              if(values.length != columns.length) {
                  throw new ValidationException("Column count does not macht value count");
              }
  
              for (int i=0;i < columns.length; i++) {
                  Column col = table.getColumn(columns[i]);
                  if (col instanceof WritableColumn) {
                      WritableColumn wCol = (WritableColumn) col;
                      convValues[i] = wCol.convertFromObject(values[i]);
                  }
              }
          } else {
              //TODO: Implementation without columns
              throw new ValidationException("Not yet implemented");
          }
  
          Vector pendingRow = new Vector();
          for (int j = 0; j < convValues.length; j++) {
              if (convValues[j] == null) {
                  pendingRow.add(BasicRow.NOVALUE);
              } else {
                  pendingRow.add(convValues[j]);
              }
          }
          rows.add(new BasicRow(table,pendingRow));
          return rows;
      }
  }
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/sql/BasicSQLCreateTableHandler.java
  
  Index: BasicSQLCreateTableHandler.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.db.basic.handlers.sql;
  
  import org.apache.avalon.db.basic.parser.BasicSQLParserManager;
  import org.apache.avalon.db.basic.actions.BasicCreateTable;
  import org.apache.avalon.db.services.DatabasePersistor;
  import org.apache.avalon.db.transport.Reply;
  import org.apache.avalon.db.transport.Request;
  import org.apache.avalon.db.transport.CreateTableRequest;
  import org.apache.avalon.db.transport.WriteReply;
  import org.apache.avalon.db.actions.ActionException;
  import org.apache.avalon.db.actions.CreateTable;
  import org.apache.avalon.db.data.Column;
  import org.apache.avalon.db.server.DBRequestContext;
  import org.apache.avalon.db.server.sql.ParseException;
  
  
  /**
   * Class BasicSQLCreateTableHandler
   *
   * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
   * @version $Revision: 1.1 $
   */
  public class BasicSQLCreateTableHandler extends BasicSQLHandler {
  
      /**
       * Constructor BasicLXSQLCreateTableHandler
       *
       *
       * @param parser
       * @param databasePersistor
       *
       */
      public BasicSQLCreateTableHandler(BasicSQLParserManager parser,
                                          DatabasePersistor databasePersistor) {
          super(parser, databasePersistor);
      }
  
      /**
       * Method handleRequest
       *
       *
       * @param request
       *
       * @return
       *
       * @throws ActionException
       *
       */
      public Reply handleRequest(DBRequestContext context, Request request) throws ActionException {
          BasicSQLParser parser = initBasicSQLPaser(((CreateTableRequest)request).getSql());
          try {
              parser.ParseCreateTable();
          } catch (ParseException pe) {
              getLogger().error("handleRequest(..): ParseException:",pe);
          }
          if (mDatabasePersistor.queryableExists(parser.getTableName())) {
              throw new ActionException("Table " + parser.getTableName() + " already exists as a Table/View/Index");
          } else {
              Column[] columns = null;
              columns = parser.getCols();
              CreateTable action = new BasicCreateTable(parser.getTableName(), columns);
  
              mParserMgr.initializeAction(action);
              action.execute();
  
              return new WriteReply(action.getRecordCount());
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message