oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfos...@apache.org
Subject svn commit: r1002752 [3/9] - in /incubator/oodt/trunk/catalog: ./ .externalToolBuilders/ .settings/ src/ src/main/ src/main/assembly/ src/main/bin/ src/main/java/ src/main/java/gov/ src/main/java/gov/nasa/ src/main/java/gov/nasa/jpl/ src/main/java/gov/...
Date Wed, 29 Sep 2010 17:19:15 GMT
Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/JJTQueryParserState.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/JJTQueryParserState.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/JJTQueryParserState.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/JJTQueryParserState.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,123 @@
+/* Generated By:JavaCC: Do not edit this line. JJTQueryParserState.java Version 5.0 */
+package org.apache.oodt.cas.catalog.query.parser;
+
+public class JJTQueryParserState {
+  private java.util.List<Node> nodes;
+  private java.util.List<Integer> marks;
+
+  private int sp;        // number of nodes on stack
+  private int mk;        // current mark
+  private boolean node_created;
+
+  public JJTQueryParserState() {
+    nodes = new java.util.ArrayList<Node>();
+    marks = new java.util.ArrayList<Integer>();
+    sp = 0;
+    mk = 0;
+  }
+
+  /* Determines whether the current node was actually closed and
+     pushed.  This should only be called in the final user action of a
+     node scope.  */
+  public boolean nodeCreated() {
+    return node_created;
+  }
+
+  /* Call this to reinitialize the node stack.  It is called
+     automatically by the parser's ReInit() method. */
+  public void reset() {
+    nodes.clear();
+    marks.clear();
+    sp = 0;
+    mk = 0;
+  }
+
+  /* Returns the root node of the AST.  It only makes sense to call
+     this after a successful parse. */
+  public Node rootNode() {
+    return nodes.get(0);
+  }
+
+  /* Pushes a node on to the stack. */
+  public void pushNode(Node n) {
+    nodes.add(n);
+    ++sp;
+  }
+
+  /* Returns the node on the top of the stack, and remove it from the
+     stack.  */
+  public Node popNode() {
+    if (--sp < mk) {
+      mk = marks.remove(marks.size()-1);
+    }
+    return nodes.remove(nodes.size()-1);
+  }
+
+  /* Returns the node currently on the top of the stack. */
+  public Node peekNode() {
+    return nodes.get(nodes.size()-1);
+  }
+
+  /* Returns the number of children on the stack in the current node
+     scope. */
+  public int nodeArity() {
+    return sp - mk;
+  }
+
+
+  public void clearNodeScope(Node n) {
+    while (sp > mk) {
+      popNode();
+    }
+    mk = marks.remove(marks.size()-1);
+  }
+
+
+  public void openNodeScope(Node n) {
+    marks.add(mk);
+    mk = sp;
+    n.jjtOpen();
+  }
+
+
+  /* A definite node is constructed from a specified number of
+     children.  That number of nodes are popped from the stack and
+     made the children of the definite node.  Then the definite node
+     is pushed on to the stack. */
+  public void closeNodeScope(Node n, int num) {
+    mk = marks.remove(marks.size()-1);
+    while (num-- > 0) {
+      Node c = popNode();
+      c.jjtSetParent(n);
+      n.jjtAddChild(c, num);
+    }
+    n.jjtClose();
+    pushNode(n);
+    node_created = true;
+  }
+
+
+  /* A conditional node is constructed if its condition is true.  All
+     the nodes that have been pushed since the node was opened are
+     made children of the conditional node, which is then pushed
+     on to the stack.  If the condition is false the node is not
+     constructed and they are left on the stack. */
+  public void closeNodeScope(Node n, boolean condition) {
+    if (condition) {
+      int a = nodeArity();
+      mk = marks.remove(marks.size()-1);
+      while (a-- > 0) {
+        Node c = popNode();
+        c.jjtSetParent(n);
+        n.jjtAddChild(c, a);
+      }
+      n.jjtClose();
+      pushNode(n);
+      node_created = true;
+    } else {
+      mk = marks.remove(marks.size()-1);
+      node_created = false;
+    }
+  }
+}
+/* JavaCC - OriginalChecksum=a225ad3a5c4857e9f64392e47d6acfb8 (do not edit this line) */

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/Node.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/Node.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/Node.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/Node.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,36 @@
+/* Generated By:JJTree: Do not edit this line. Node.java Version 4.3 */
+/* JavaCCOptions:MULTI=false,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
+package org.apache.oodt.cas.catalog.query.parser;
+
+/* All AST nodes must implement this interface.  It provides basic
+   machinery for constructing the parent and child relationships
+   between nodes. */
+
+public
+interface Node {
+
+  /** This method is called after the node has been made the current
+    node.  It indicates that child nodes can now be added to it. */
+  public void jjtOpen();
+
+  /** This method is called after all the child nodes have been
+    added. */
+  public void jjtClose();
+
+  /** This pair of methods are used to inform the node of its
+    parent. */
+  public void jjtSetParent(Node n);
+  public Node jjtGetParent();
+
+  /** This method tells the node to add its argument to the node's
+    list of children.  */
+  public void jjtAddChild(Node n, int i);
+
+  /** This method returns a child node.  The children are numbered
+     from zero, left to right. */
+  public Node jjtGetChild(int i);
+
+  /** Return the number of children the node has. */
+  public int jjtGetNumChildren();
+}
+/* JavaCC - OriginalChecksum=d803b99b9dbe9f48568711ddba598d1d (do not edit this line) */

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/ParseException.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/ParseException.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/ParseException.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/ParseException.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,187 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
+/* JavaCCOptions:KEEP_LINE_COL=null */
+package org.apache.oodt.cas.catalog.query.parser;
+
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends Exception {
+
+  /**
+   * The version identifier for this Serializable class.
+   * Increment only if the <i>serialized</i> form of the
+   * class changes.
+   */
+  private static final long serialVersionUID = 1L;
+
+  /**
+   * This constructor is used by the method "generateParseException"
+   * in the generated parser.  Calling this constructor generates
+   * a new object of this type with the fields "currentToken",
+   * "expectedTokenSequences", and "tokenImage" set.
+   */
+  public ParseException(Token currentTokenVal,
+                        int[][] expectedTokenSequencesVal,
+                        String[] tokenImageVal
+                       )
+  {
+    super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
+    currentToken = currentTokenVal;
+    expectedTokenSequences = expectedTokenSequencesVal;
+    tokenImage = tokenImageVal;
+  }
+
+  /**
+   * The following constructors are for use by you for whatever
+   * purpose you can think of.  Constructing the exception in this
+   * manner makes the exception behave in the normal way - i.e., as
+   * documented in the class "Throwable".  The fields "errorToken",
+   * "expectedTokenSequences", and "tokenImage" do not contain
+   * relevant information.  The JavaCC generated code does not use
+   * these constructors.
+   */
+
+  public ParseException() {
+    super();
+  }
+
+  /** Constructor with message. */
+  public ParseException(String message) {
+    super(message);
+  }
+
+
+  /**
+   * This is the last token that has been consumed successfully.  If
+   * this object has been created due to a parse error, the token
+   * followng this token will (therefore) be the first error token.
+   */
+  public Token currentToken;
+
+  /**
+   * Each entry in this array is an array of integers.  Each array
+   * of integers represents a sequence of tokens (by their ordinal
+   * values) that is expected at this point of the parse.
+   */
+  public int[][] expectedTokenSequences;
+
+  /**
+   * This is a reference to the "tokenImage" array of the generated
+   * parser within which the parse error occurred.  This array is
+   * defined in the generated ...Constants interface.
+   */
+  public String[] tokenImage;
+
+  /**
+   * It uses "currentToken" and "expectedTokenSequences" to generate a parse
+   * error message and returns it.  If this object has been created
+   * due to a parse error, and you do not catch it (it gets thrown
+   * from the parser) the correct error message
+   * gets displayed.
+   */
+  private static String initialise(Token currentToken,
+                           int[][] expectedTokenSequences,
+                           String[] tokenImage) {
+    String eol = System.getProperty("line.separator", "\n");
+    StringBuffer expected = new StringBuffer();
+    int maxSize = 0;
+    for (int i = 0; i < expectedTokenSequences.length; i++) {
+      if (maxSize < expectedTokenSequences[i].length) {
+        maxSize = expectedTokenSequences[i].length;
+      }
+      for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+        expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
+      }
+      if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+        expected.append("...");
+      }
+      expected.append(eol).append("    ");
+    }
+    String retval = "Encountered \"";
+    Token tok = currentToken.next;
+    for (int i = 0; i < maxSize; i++) {
+      if (i != 0) retval += " ";
+      if (tok.kind == 0) {
+        retval += tokenImage[0];
+        break;
+      }
+      retval += " " + tokenImage[tok.kind];
+      retval += " \"";
+      retval += add_escapes(tok.image);
+      retval += " \"";
+      tok = tok.next;
+    }
+    retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+    retval += "." + eol;
+    if (expectedTokenSequences.length == 1) {
+      retval += "Was expecting:" + eol + "    ";
+    } else {
+      retval += "Was expecting one of:" + eol + "    ";
+    }
+    retval += expected.toString();
+    return retval;
+  }
+
+  /**
+   * The end of line string for this machine.
+   */
+  protected String eol = System.getProperty("line.separator", "\n");
+
+  /**
+   * Used to convert raw characters to their escaped version
+   * when these raw version cannot be used as part of an ASCII
+   * string literal.
+   */
+  static String add_escapes(String str) {
+      StringBuffer retval = new StringBuffer();
+      char ch;
+      for (int i = 0; i < str.length(); i++) {
+        switch (str.charAt(i))
+        {
+           case 0 :
+              continue;
+           case '\b':
+              retval.append("\\b");
+              continue;
+           case '\t':
+              retval.append("\\t");
+              continue;
+           case '\n':
+              retval.append("\\n");
+              continue;
+           case '\f':
+              retval.append("\\f");
+              continue;
+           case '\r':
+              retval.append("\\r");
+              continue;
+           case '\"':
+              retval.append("\\\"");
+              continue;
+           case '\'':
+              retval.append("\\\'");
+              continue;
+           case '\\':
+              retval.append("\\\\");
+              continue;
+           default:
+              if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+                 String s = "0000" + Integer.toString(ch, 16);
+                 retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+              } else {
+                 retval.append(ch);
+              }
+              continue;
+        }
+      }
+      return retval.toString();
+   }
+
+}
+/* JavaCC - OriginalChecksum=2dc94ec6e6c4be52e333891b220b8ef1 (do not edit this line) */

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,971 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. QueryParser.java */
+        package org.apache.oodt.cas.catalog.query.parser;
+
+        import java.io.ByteArrayInputStream;
+        import java.util.Arrays;
+        import java.util.HashSet;
+        import java.util.Vector;
+        import java.util.Properties;
+        import org.apache.oodt.cas.catalog.query.QueryExpression;
+        import org.apache.oodt.cas.catalog.query.QueryLogicalGroup;
+        import org.apache.oodt.cas.catalog.query.StdQueryExpression;
+        import org.apache.oodt.cas.catalog.query.ComparisonQueryExpression;
+        import org.apache.oodt.cas.catalog.query.CustomQueryExpression;
+        import org.apache.oodt.cas.catalog.term.Term;
+
+    public class QueryParser/*@bgen(jjtree)*/implements QueryParserTreeConstants, QueryParserConstants {/*@bgen(jjtree)*/
+  protected JJTQueryParserState jjtree = new JJTQueryParserState();
+        public static QueryExpression parseQueryExpression(String queryExpressionString) throws ParseException, TokenMgrError {
+                return new QueryParser(new ByteArrayInputStream(queryExpressionString.getBytes())).parseInput();
+        }
+
+        public static void main( String[] args ) throws ParseException, TokenMgrError {
+                System.out.println(new QueryParser( System.in ).parseInput());
+        }
+
+  final public QueryExpression parseInput() throws ParseException {
+ /*@bgen(jjtree) parseInput */
+        SimpleNode jjtn000 = new SimpleNode(JJTPARSEINPUT);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);QueryExpression qe = null;
+    try {
+      qe = Query(null);
+      jj_consume_token(0);
+          jjtree.closeNodeScope(jjtn000, true);
+          jjtc000 = false;
+          {if (true) return qe;}
+    } catch (Throwable jjte000) {
+          if (jjtc000) {
+            jjtree.clearNodeScope(jjtn000);
+            jjtc000 = false;
+          } else {
+            jjtree.popNode();
+          }
+          if (jjte000 instanceof RuntimeException) {
+            {if (true) throw (RuntimeException)jjte000;}
+          }
+          if (jjte000 instanceof ParseException) {
+            {if (true) throw (ParseException)jjte000;}
+          }
+          {if (true) throw (Error)jjte000;}
+    } finally {
+          if (jjtc000) {
+            jjtree.closeNodeScope(jjtn000, true);
+          }
+    }
+    throw new Error("Missing return statement in function");
+  }
+
+  final public QueryExpression Query(Vector<String> bucketNames) throws ParseException {
+ /*@bgen(jjtree) Query */
+        SimpleNode jjtn000 = new SimpleNode(JJTQUERY);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);QueryExpression qe1 = null;
+        QueryExpression qe2 = null;
+        Token operator = null;
+    try {
+      qe1 = QueryExpression(bucketNames);
+      label_1:
+      while (true) {
+        if (jj_2_1(2147483647)) {
+          ;
+        } else {
+          break label_1;
+        }
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case AND:
+          operator = jj_consume_token(AND);
+          break;
+        case OR:
+          operator = jj_consume_token(OR);
+          break;
+        default:
+          jj_la1[0] = jj_gen;
+          jj_consume_token(-1);
+          throw new ParseException();
+        }
+        qe2 = Query(bucketNames);
+      }
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+        if (qe2 == null) {
+                {if (true) return qe1;}
+        }else {
+                QueryLogicalGroup queryLogicalGroup = new QueryLogicalGroup();
+                if (bucketNames != null)
+                        queryLogicalGroup.setBucketNames(new HashSet<String>(bucketNames));
+                queryLogicalGroup.setOperator(QueryLogicalGroup.Operator.valueOf(operator.image.trim().toUpperCase()));
+                queryLogicalGroup.addExpression(qe1);
+                queryLogicalGroup.addExpression(qe2);
+                {if (true) return queryLogicalGroup;}
+        }
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        {if (true) throw (RuntimeException)jjte000;}
+      }
+      if (jjte000 instanceof ParseException) {
+        {if (true) throw (ParseException)jjte000;}
+      }
+      {if (true) throw (Error)jjte000;}
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+    throw new Error("Missing return statement in function");
+  }
+
+  final public QueryExpression QueryExpression(Vector<String> bucketNames) throws ParseException {
+ /*@bgen(jjtree) QueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);QueryExpression qe = null;
+    try {
+      if (jj_2_2(2147483647)) {
+        qe = PriorityQueryExpression(bucketNames);
+      } else if (jj_2_3(2147483647)) {
+        qe = StdQueryExpression();
+      } else if (jj_2_4(2147483647)) {
+        qe = CustomQueryExpression(bucketNames);
+      } else if (jj_2_5(2147483647)) {
+        qe = ComparisonQueryExpression(bucketNames);
+      } else {
+        jj_consume_token(-1);
+        throw new ParseException();
+      }
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+      {if (true) return qe;}
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        {if (true) throw (RuntimeException)jjte000;}
+      }
+      if (jjte000 instanceof ParseException) {
+        {if (true) throw (ParseException)jjte000;}
+      }
+      {if (true) throw (Error)jjte000;}
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+    throw new Error("Missing return statement in function");
+  }
+
+  final public QueryExpression StdQueryExpression() throws ParseException {
+ /*@bgen(jjtree) StdQueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTSTDQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);QueryExpression qe = null;
+        Vector<String> bucketNames = new Vector<String>();
+    try {
+      jj_consume_token(OPEN_BRACES);
+      label_2:
+      while (true) {
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[1] = jj_gen;
+          break label_2;
+        }
+        jj_consume_token(SPACE);
+      }
+      jj_consume_token(BUCKET_NAME_KEY);
+      label_3:
+      while (true) {
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[2] = jj_gen;
+          break label_3;
+        }
+        jj_consume_token(SPACE);
+      }
+      jj_consume_token(EQUALS);
+      label_4:
+      while (true) {
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[3] = jj_gen;
+          break label_4;
+        }
+        jj_consume_token(SPACE);
+      }
+      jj_consume_token(QUOTE);
+      getValues(bucketNames);
+      jj_consume_token(QUOTE);
+      label_5:
+      while (true) {
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[4] = jj_gen;
+          break label_5;
+        }
+        jj_consume_token(SPACE);
+      }
+      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+      case SEMI_COLON:
+        jj_consume_token(SEMI_COLON);
+        qe = Query(bucketNames);
+        break;
+      default:
+        jj_la1[5] = jj_gen;
+        ;
+      }
+      jj_consume_token(CLOSE_BRACES);
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+        if (qe == null) {
+                {if (true) return new StdQueryExpression(new HashSet<String>(bucketNames));}
+        }else {
+                {if (true) return qe;}
+        }
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        {if (true) throw (RuntimeException)jjte000;}
+      }
+      if (jjte000 instanceof ParseException) {
+        {if (true) throw (ParseException)jjte000;}
+      }
+      {if (true) throw (Error)jjte000;}
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+    throw new Error("Missing return statement in function");
+  }
+
+  final public QueryExpression ComparisonQueryExpression(Vector<String> bucketNames) throws ParseException {
+ /*@bgen(jjtree) ComparisonQueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTCOMPARISONQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);Token termName = null;
+        Token operator = null;
+        Vector<String> values = new Vector<String>();
+    try {
+      termName = jj_consume_token(TERM);
+      label_6:
+      while (true) {
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[6] = jj_gen;
+          break label_6;
+        }
+        jj_consume_token(SPACE);
+      }
+      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+      case EQ:
+        operator = jj_consume_token(EQ);
+        break;
+      case GT:
+        operator = jj_consume_token(GT);
+        break;
+      case GE:
+        operator = jj_consume_token(GE);
+        break;
+      case LT:
+        operator = jj_consume_token(LT);
+        break;
+      case LE:
+        operator = jj_consume_token(LE);
+        break;
+      default:
+        jj_la1[7] = jj_gen;
+        jj_consume_token(-1);
+        throw new ParseException();
+      }
+      label_7:
+      while (true) {
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[8] = jj_gen;
+          break label_7;
+        }
+        jj_consume_token(SPACE);
+      }
+      getValues(values);
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+        Term term = new Term(termName.image);
+        term.setValues(values); //Arrays.asList(termValues.image.split(",")));
+        ComparisonQueryExpression comparisonQueryExpression = new ComparisonQueryExpression();
+        if (bucketNames != null)
+                comparisonQueryExpression.setBucketNames(new HashSet<String>(bucketNames));
+        comparisonQueryExpression.setTerm(term);
+        comparisonQueryExpression.setOperator(ComparisonQueryExpression.Operator.getOperatorBySign(operator.image));
+        {if (true) return comparisonQueryExpression;}
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        {if (true) throw (RuntimeException)jjte000;}
+      }
+      if (jjte000 instanceof ParseException) {
+        {if (true) throw (ParseException)jjte000;}
+      }
+      {if (true) throw (Error)jjte000;}
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+    throw new Error("Missing return statement in function");
+  }
+
+  final public QueryExpression PriorityQueryExpression(Vector<String> bucketNames) throws ParseException {
+ /*@bgen(jjtree) PriorityQueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTPRIORITYQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);QueryExpression qe = null;
+    try {
+      jj_consume_token(OPEN_PARENS);
+      qe = Query(bucketNames);
+      jj_consume_token(CLOSE_PARENS);
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+      {if (true) return qe;}
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        {if (true) throw (RuntimeException)jjte000;}
+      }
+      if (jjte000 instanceof ParseException) {
+        {if (true) throw (ParseException)jjte000;}
+      }
+      {if (true) throw (Error)jjte000;}
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+    throw new Error("Missing return statement in function");
+  }
+
+  final public QueryExpression CustomQueryExpression(Vector<String> bucketNames) throws ParseException {
+ /*@bgen(jjtree) CustomQueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTCUSTOMQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);Token customNameToken = null;
+        Properties p = new Properties();
+    try {
+      jj_consume_token(OPEN_BRACES);
+      label_8:
+      while (true) {
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[9] = jj_gen;
+          break label_8;
+        }
+        jj_consume_token(SPACE);
+      }
+      jj_consume_token(CUSTOM_NAME_KEY);
+      label_9:
+      while (true) {
+        jj_consume_token(SPACE);
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[10] = jj_gen;
+          break label_9;
+        }
+      }
+      jj_consume_token(EQUALS);
+      label_10:
+      while (true) {
+        jj_consume_token(SPACE);
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[11] = jj_gen;
+          break label_10;
+        }
+      }
+      jj_consume_token(QUOTE);
+      customNameToken = jj_consume_token(TERM);
+      jj_consume_token(QUOTE);
+      if (jj_2_6(2147483647)) {
+        jj_consume_token(SEMI_COLON);
+        getProperties(p);
+      } else {
+        ;
+      }
+      jj_consume_token(CLOSE_BRACES);
+          jjtree.closeNodeScope(jjtn000, true);
+          jjtc000 = false;
+                CustomQueryExpression cqe = new CustomQueryExpression(customNameToken.image, p);
+        if (bucketNames != null)
+                cqe.setBucketNames(new HashSet<String>(bucketNames));
+        {if (true) return cqe;}
+    } catch (Throwable jjte000) {
+          if (jjtc000) {
+            jjtree.clearNodeScope(jjtn000);
+            jjtc000 = false;
+          } else {
+            jjtree.popNode();
+          }
+          if (jjte000 instanceof RuntimeException) {
+            {if (true) throw (RuntimeException)jjte000;}
+          }
+          if (jjte000 instanceof ParseException) {
+            {if (true) throw (ParseException)jjte000;}
+          }
+          {if (true) throw (Error)jjte000;}
+    } finally {
+          if (jjtc000) {
+            jjtree.closeNodeScope(jjtn000, true);
+          }
+    }
+    throw new Error("Missing return statement in function");
+  }
+
+  final public void getValues(Vector<String> values) throws ParseException {
+ /*@bgen(jjtree) getValues */
+        SimpleNode jjtn000 = new SimpleNode(JJTGETVALUES);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);Token value = null;
+    try {
+      value = jj_consume_token(VALUE);
+      label_11:
+      while (true) {
+        if (jj_2_7(2147483647)) {
+          ;
+        } else {
+          break label_11;
+        }
+        jj_consume_token(COMMA);
+        getValues(values);
+      }
+          jjtree.closeNodeScope(jjtn000, true);
+          jjtc000 = false;
+                values.add(0, value.image.replaceAll("'", ""));
+    } catch (Throwable jjte000) {
+          if (jjtc000) {
+            jjtree.clearNodeScope(jjtn000);
+            jjtc000 = false;
+          } else {
+            jjtree.popNode();
+          }
+          if (jjte000 instanceof RuntimeException) {
+            {if (true) throw (RuntimeException)jjte000;}
+          }
+          if (jjte000 instanceof ParseException) {
+            {if (true) throw (ParseException)jjte000;}
+          }
+          {if (true) throw (Error)jjte000;}
+    } finally {
+          if (jjtc000) {
+            jjtree.closeNodeScope(jjtn000, true);
+          }
+    }
+  }
+
+  final public void getProperties(Properties p) throws ParseException {
+ /*@bgen(jjtree) getProperties */
+        SimpleNode jjtn000 = new SimpleNode(JJTGETPROPERTIES);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);Token propertyKey = null;
+        Token propertyVal = null;
+    try {
+      propertyKey = jj_consume_token(P_KEY);
+      label_12:
+      while (true) {
+        jj_consume_token(SPACE);
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[12] = jj_gen;
+          break label_12;
+        }
+      }
+      jj_consume_token(EQUALS);
+      label_13:
+      while (true) {
+        jj_consume_token(SPACE);
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+        case SPACE:
+          ;
+          break;
+        default:
+          jj_la1[13] = jj_gen;
+          break label_13;
+        }
+      }
+      propertyVal = jj_consume_token(VALUE);
+      label_14:
+      while (true) {
+        if (jj_2_8(2147483647)) {
+          ;
+        } else {
+          break label_14;
+        }
+        jj_consume_token(COMMA);
+        getProperties(p);
+      }
+          jjtree.closeNodeScope(jjtn000, true);
+          jjtc000 = false;
+                p.put(propertyKey.image.substring(2), propertyVal.image.replaceAll("'", ""));
+    } catch (Throwable jjte000) {
+          if (jjtc000) {
+            jjtree.clearNodeScope(jjtn000);
+            jjtc000 = false;
+          } else {
+            jjtree.popNode();
+          }
+          if (jjte000 instanceof RuntimeException) {
+            {if (true) throw (RuntimeException)jjte000;}
+          }
+          if (jjte000 instanceof ParseException) {
+            {if (true) throw (ParseException)jjte000;}
+          }
+          {if (true) throw (Error)jjte000;}
+    } finally {
+          if (jjtc000) {
+            jjtree.closeNodeScope(jjtn000, true);
+          }
+    }
+  }
+
+  private boolean jj_2_1(int xla) {
+    jj_la = xla; jj_lastpos = jj_scanpos = token;
+    try { return !jj_3_1(); }
+    catch(LookaheadSuccess ls) { return true; }
+    finally { jj_save(0, xla); }
+  }
+
+  private boolean jj_2_2(int xla) {
+    jj_la = xla; jj_lastpos = jj_scanpos = token;
+    try { return !jj_3_2(); }
+    catch(LookaheadSuccess ls) { return true; }
+    finally { jj_save(1, xla); }
+  }
+
+  private boolean jj_2_3(int xla) {
+    jj_la = xla; jj_lastpos = jj_scanpos = token;
+    try { return !jj_3_3(); }
+    catch(LookaheadSuccess ls) { return true; }
+    finally { jj_save(2, xla); }
+  }
+
+  private boolean jj_2_4(int xla) {
+    jj_la = xla; jj_lastpos = jj_scanpos = token;
+    try { return !jj_3_4(); }
+    catch(LookaheadSuccess ls) { return true; }
+    finally { jj_save(3, xla); }
+  }
+
+  private boolean jj_2_5(int xla) {
+    jj_la = xla; jj_lastpos = jj_scanpos = token;
+    try { return !jj_3_5(); }
+    catch(LookaheadSuccess ls) { return true; }
+    finally { jj_save(4, xla); }
+  }
+
+  private boolean jj_2_6(int xla) {
+    jj_la = xla; jj_lastpos = jj_scanpos = token;
+    try { return !jj_3_6(); }
+    catch(LookaheadSuccess ls) { return true; }
+    finally { jj_save(5, xla); }
+  }
+
+  private boolean jj_2_7(int xla) {
+    jj_la = xla; jj_lastpos = jj_scanpos = token;
+    try { return !jj_3_7(); }
+    catch(LookaheadSuccess ls) { return true; }
+    finally { jj_save(6, xla); }
+  }
+
+  private boolean jj_2_8(int xla) {
+    jj_la = xla; jj_lastpos = jj_scanpos = token;
+    try { return !jj_3_8(); }
+    catch(LookaheadSuccess ls) { return true; }
+    finally { jj_save(7, xla); }
+  }
+
+  private boolean jj_3_8() {
+    if (jj_scan_token(COMMA)) return true;
+    return false;
+  }
+
+  private boolean jj_3_3() {
+    if (jj_scan_token(OPEN_BRACES)) return true;
+    if (jj_scan_token(BUCKET_NAME_KEY)) return true;
+    return false;
+  }
+
+  private boolean jj_3_2() {
+    if (jj_scan_token(OPEN_PARENS)) return true;
+    return false;
+  }
+
+  private boolean jj_3_7() {
+    if (jj_scan_token(COMMA)) return true;
+    return false;
+  }
+
+  private boolean jj_3_1() {
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_scan_token(5)) {
+    jj_scanpos = xsp;
+    if (jj_scan_token(6)) return true;
+    }
+    return false;
+  }
+
+  private boolean jj_3_5() {
+    if (jj_scan_token(TERM)) return true;
+    return false;
+  }
+
+  private boolean jj_3_6() {
+    if (jj_scan_token(SEMI_COLON)) return true;
+    return false;
+  }
+
+  private boolean jj_3_4() {
+    if (jj_scan_token(OPEN_BRACES)) return true;
+    if (jj_scan_token(CUSTOM_NAME_KEY)) return true;
+    return false;
+  }
+
+  /** Generated Token Manager. */
+  public QueryParserTokenManager token_source;
+  SimpleCharStream jj_input_stream;
+  /** Current token. */
+  public Token token;
+  /** Next token. */
+  public Token jj_nt;
+  private int jj_ntk;
+  private Token jj_scanpos, jj_lastpos;
+  private int jj_la;
+  private int jj_gen;
+  final private int[] jj_la1 = new int[14];
+  static private int[] jj_la1_0;
+  static {
+      jj_la1_init_0();
+   }
+   private static void jj_la1_init_0() {
+      jj_la1_0 = new int[] {0x60,0x10,0x10,0x10,0x10,0x200,0x10,0x7c0000,0x10,0x10,0x10,0x10,0x10,0x10,};
+   }
+  final private JJCalls[] jj_2_rtns = new JJCalls[8];
+  private boolean jj_rescan = false;
+  private int jj_gc = 0;
+
+  /** Constructor with InputStream. */
+  public QueryParser(java.io.InputStream stream) {
+     this(stream, null);
+  }
+  /** Constructor with InputStream and supplied encoding */
+  public QueryParser(java.io.InputStream stream, String encoding) {
+    try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+    token_source = new QueryParserTokenManager(jj_input_stream);
+    token = new Token();
+    jj_ntk = -1;
+    jj_gen = 0;
+    for (int i = 0; i < 14; i++) jj_la1[i] = -1;
+    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+  }
+
+  /** Reinitialise. */
+  public void ReInit(java.io.InputStream stream) {
+     ReInit(stream, null);
+  }
+  /** Reinitialise. */
+  public void ReInit(java.io.InputStream stream, String encoding) {
+    try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
+    token_source.ReInit(jj_input_stream);
+    token = new Token();
+    jj_ntk = -1;
+    jjtree.reset();
+    jj_gen = 0;
+    for (int i = 0; i < 14; i++) jj_la1[i] = -1;
+    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+  }
+
+  /** Constructor. */
+  public QueryParser(java.io.Reader stream) {
+    jj_input_stream = new SimpleCharStream(stream, 1, 1);
+    token_source = new QueryParserTokenManager(jj_input_stream);
+    token = new Token();
+    jj_ntk = -1;
+    jj_gen = 0;
+    for (int i = 0; i < 14; i++) jj_la1[i] = -1;
+    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+  }
+
+  /** Reinitialise. */
+  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;
+    jjtree.reset();
+    jj_gen = 0;
+    for (int i = 0; i < 14; i++) jj_la1[i] = -1;
+    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+  }
+
+  /** Constructor with generated Token Manager. */
+  public QueryParser(QueryParserTokenManager tm) {
+    token_source = tm;
+    token = new Token();
+    jj_ntk = -1;
+    jj_gen = 0;
+    for (int i = 0; i < 14; i++) jj_la1[i] = -1;
+    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+  }
+
+  /** Reinitialise. */
+  public void ReInit(QueryParserTokenManager tm) {
+    token_source = tm;
+    token = new Token();
+    jj_ntk = -1;
+    jjtree.reset();
+    jj_gen = 0;
+    for (int i = 0; i < 14; i++) jj_la1[i] = -1;
+    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
+  }
+
+  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();
+  }
+
+  static private final class LookaheadSuccess extends java.lang.Error { }
+  final private LookaheadSuccess jj_ls = new LookaheadSuccess();
+  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);
+    }
+    if (jj_scanpos.kind != kind) return true;
+    if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
+    return false;
+  }
+
+
+/** Get the next Token. */
+  final public Token getNextToken() {
+    if (token.next != null) token = token.next;
+    else token = token.next = token_source.getNextToken();
+    jj_ntk = -1;
+    jj_gen++;
+    return token;
+  }
+
+/** Get the specific Token. */
+  final public Token getToken(int index) {
+    Token t = token;
+    for (int i = 0; i < index; i++) {
+      if (t.next != null) t = t.next;
+      else t = t.next = token_source.getNextToken();
+    }
+    return t;
+  }
+
+  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);
+  }
+
+  private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
+  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];
+      }
+      jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {
+        int[] oldentry = (int[])(it.next());
+        if (oldentry.length == jj_expentry.length) {
+          for (int i = 0; i < jj_expentry.length; i++) {
+            if (oldentry[i] != jj_expentry[i]) {
+              continue jj_entries_loop;
+            }
+          }
+          jj_expentries.add(jj_expentry);
+          break jj_entries_loop;
+        }
+      }
+      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
+    }
+  }
+
+  /** Generate ParseException. */
+  public ParseException generateParseException() {
+    jj_expentries.clear();
+    boolean[] la1tokens = new boolean[28];
+    if (jj_kind >= 0) {
+      la1tokens[jj_kind] = true;
+      jj_kind = -1;
+    }
+    for (int i = 0; i < 14; i++) {
+      if (jj_la1[i] == jj_gen) {
+        for (int j = 0; j < 32; j++) {
+          if ((jj_la1_0[i] & (1<<j)) != 0) {
+            la1tokens[j] = true;
+          }
+        }
+      }
+    }
+    for (int i = 0; i < 28; i++) {
+      if (la1tokens[i]) {
+        jj_expentry = new int[1];
+        jj_expentry[0] = i;
+        jj_expentries.add(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] = jj_expentries.get(i);
+    }
+    return new ParseException(token, exptokseq, tokenImage);
+  }
+
+  /** Enable tracing. */
+  final public void enable_tracing() {
+  }
+
+  /** Disable tracing. */
+  final public void disable_tracing() {
+  }
+
+  private void jj_rescan_token() {
+    jj_rescan = true;
+    for (int i = 0; i < 8; i++) {
+    try {
+      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;
+            case 6: jj_3_7(); break;
+            case 7: jj_3_8(); break;
+          }
+        }
+        p = p.next;
+      } while (p != null);
+      } catch(LookaheadSuccess ls) { }
+    }
+    jj_rescan = false;
+  }
+
+  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 class JJCalls {
+    int gen;
+    Token first;
+    int arg;
+    JJCalls next;
+  }
+
+    }

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.jj
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.jj?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.jj (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.jj Wed Sep 29 17:19:09 2010
@@ -0,0 +1,497 @@
+/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. QueryParser.jj */
+/*@egen*//*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+options {
+  JDK_VERSION = "1.5";
+  STATIC = false;
+}
+
+PARSER_BEGIN(QueryParser)
+	package org.apache.oodt.cas.catalog.query.parser;
+
+	import java.io.ByteArrayInputStream;
+	import java.util.Arrays;
+	import java.util.HashSet;
+	import java.util.Vector;
+	import java.util.Properties;
+	import org.apache.oodt.cas.catalog.query.QueryExpression;
+	import org.apache.oodt.cas.catalog.query.QueryLogicalGroup;
+	import org.apache.oodt.cas.catalog.query.StdQueryExpression;
+	import org.apache.oodt.cas.catalog.query.ComparisonQueryExpression;
+	import org.apache.oodt.cas.catalog.query.CustomQueryExpression;
+	import org.apache.oodt.cas.catalog.term.Term;
+	
+    public class QueryParser/*@bgen(jjtree)*/implements QueryParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
+  protected JJTQueryParserState jjtree = new JJTQueryParserState();
+
+/*@egen*/
+    	
+    	public static QueryExpression parseQueryExpression(String queryExpressionString) throws ParseException, TokenMgrError {
+    		return new QueryParser(new ByteArrayInputStream(queryExpressionString.getBytes())).parseInput();
+    	}
+    	
+       	public static void main( String[] args ) throws ParseException, TokenMgrError {
+          	System.out.println(new QueryParser( System.in ).parseInput());
+       	} 
+       	
+    }
+PARSER_END(QueryParser)
+
+SKIP : { "\r" | "\n" | "\r\n" }
+TOKEN: { < SPACE : " " > }
+TOKEN: { < AND : " AND " > }
+TOKEN: { < OR : " OR " > }
+TOKEN: { < QUOTE : "'" > }
+TOKEN: { < EQUALS : "=" > }
+TOKEN: { < SEMI_COLON : ";" > }
+TOKEN: { < COMMA : "," > }
+TOKEN: { < OPEN_BRACES : "{" > }
+TOKEN: { < CLOSE_BRACES : "}" > }
+TOKEN: { < OPEN_PARENS : "(" > }
+TOKEN: { < CLOSE_PARENS : ")" > }
+TOKEN: { < BUCKET_NAME_KEY : "bucketNames" > }
+TOKEN: { < CUSTOM_NAME_KEY : "name" > }
+TOKEN: { < P_KEY : "p:" <TERM> > }
+TOKEN: {
+      < EQ : "==" >
+    | < GE : ">=" >
+    | < GT : ">" >
+    | < LE : "<=" >
+    | < LT : "<" >
+}
+TOKEN: { < TERM: (["a"-"z","A"-"Z"])+ (<STRING_LITERAL>)* > }
+TOKEN: { < VALUE : "'" ( <TERM> | <NON_TERM> ) "'" > }
+TOKEN: { < #NON_TERM: (<STRING_LITERAL> | <SPECIAL_CHARS>)+ (<STRING_LITERAL> | " "<STRING_LITERAL> | " "<SPECIAL_CHARS> | <SPECIAL_CHARS>)* > }
+TOKEN: { < #STRING_LITERAL: (["0"-"9","a"-"z","A"-"Z","-","_",".",":","/"]) > }
+TOKEN: { < #SPECIAL_CHARS: (["/","\\","?","<",">","~","`","*","#","&","!","@","$","%","^","(",")","{","}","[","]"]) > }
+
+QueryExpression parseInput() : 
+{/*@bgen(jjtree) parseInput */
+        SimpleNode jjtn000 = new SimpleNode(JJTPARSEINPUT);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	QueryExpression qe = null;
+}
+{/*@bgen(jjtree) parseInput */
+        try {
+/*@egen*/
+   	qe = Query(null) <EOF>/*@bgen(jjtree)*/
+        {
+          jjtree.closeNodeScope(jjtn000, true);
+          jjtc000 = false;
+        }
+/*@egen*/
+   	{ return qe; }/*@bgen(jjtree)*/
+        } catch (Throwable jjte000) {
+          if (jjtc000) {
+            jjtree.clearNodeScope(jjtn000);
+            jjtc000 = false;
+          } else {
+            jjtree.popNode();
+          }
+          if (jjte000 instanceof RuntimeException) {
+            throw (RuntimeException)jjte000;
+          }
+          if (jjte000 instanceof ParseException) {
+            throw (ParseException)jjte000;
+          }
+          throw (Error)jjte000;
+        } finally {
+          if (jjtc000) {
+            jjtree.closeNodeScope(jjtn000, true);
+          }
+        }
+/*@egen*/
+}
+
+QueryExpression Query(Vector<String> bucketNames) : 
+{/*@bgen(jjtree) Query */
+        SimpleNode jjtn000 = new SimpleNode(JJTQUERY);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	QueryExpression qe1 = null;
+	QueryExpression qe2 = null;
+	Token operator = null;
+}
+{/*@bgen(jjtree) Query */
+    try {
+/*@egen*/
+    qe1 = QueryExpression(bucketNames) ( LOOKAHEAD( <AND> | <OR> ) ( operator = <AND> | operator = <OR> ) qe2 = Query(bucketNames) )*/*@bgen(jjtree)*/
+    {
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+    }
+/*@egen*/
+    { 
+    	if (qe2 == null) {
+    		return qe1;
+    	}else {
+    		QueryLogicalGroup queryLogicalGroup = new QueryLogicalGroup();
+    		if (bucketNames != null)
+    			queryLogicalGroup.setBucketNames(new HashSet<String>(bucketNames));
+    		queryLogicalGroup.setOperator(QueryLogicalGroup.Operator.valueOf(operator.image.trim().toUpperCase()));
+    		queryLogicalGroup.addExpression(qe1);
+    		queryLogicalGroup.addExpression(qe2);
+    		return queryLogicalGroup;
+    	}
+    }/*@bgen(jjtree)*/
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        throw (RuntimeException)jjte000;
+      }
+      if (jjte000 instanceof ParseException) {
+        throw (ParseException)jjte000;
+      }
+      throw (Error)jjte000;
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+/*@egen*/
+}
+
+QueryExpression QueryExpression(Vector<String> bucketNames) :
+{/*@bgen(jjtree) QueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	QueryExpression qe = null;
+}
+{/*@bgen(jjtree) QueryExpression */
+    try {
+/*@egen*/
+    ( 
+    	LOOKAHEAD ( <OPEN_PARENS> ) 
+    	qe = PriorityQueryExpression(bucketNames)
+    | 
+    	LOOKAHEAD ( <OPEN_BRACES> <BUCKET_NAME_KEY> ) 
+    	qe = StdQueryExpression()
+    | 
+    	LOOKAHEAD ( <OPEN_BRACES> <CUSTOM_NAME_KEY> ) 
+    	qe = CustomQueryExpression(bucketNames)
+    | 
+        LOOKAHEAD ( <TERM> ) 
+    	qe = ComparisonQueryExpression(bucketNames) 
+    )/*@bgen(jjtree)*/
+    {
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+    }
+/*@egen*/
+    
+    { return qe; }/*@bgen(jjtree)*/
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        throw (RuntimeException)jjte000;
+      }
+      if (jjte000 instanceof ParseException) {
+        throw (ParseException)jjte000;
+      }
+      throw (Error)jjte000;
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+/*@egen*/
+}
+
+QueryExpression StdQueryExpression() : 
+{/*@bgen(jjtree) StdQueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTSTDQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	QueryExpression qe = null;
+	Vector<String> bucketNames = new Vector<String>();
+}
+{/*@bgen(jjtree) StdQueryExpression */
+    try {
+/*@egen*/
+    <OPEN_BRACES> (<SPACE>)* <BUCKET_NAME_KEY> (<SPACE>)* <EQUALS> (<SPACE>)* <QUOTE> getValues(bucketNames) <QUOTE> (<SPACE>)* [<SEMI_COLON> qe = Query(bucketNames)] <CLOSE_BRACES>/*@bgen(jjtree)*/
+    {
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+    }
+/*@egen*/
+    { 
+    	if (qe == null) {
+    		return new StdQueryExpression(new HashSet<String>(bucketNames));
+    	}else {
+    		return qe; 
+    	}
+    }/*@bgen(jjtree)*/
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        throw (RuntimeException)jjte000;
+      }
+      if (jjte000 instanceof ParseException) {
+        throw (ParseException)jjte000;
+      }
+      throw (Error)jjte000;
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+/*@egen*/
+}
+
+QueryExpression ComparisonQueryExpression(Vector<String> bucketNames) : 
+{/*@bgen(jjtree) ComparisonQueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTCOMPARISONQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	Token termName = null;
+	Token operator = null;
+	Vector<String> values = new Vector<String>();
+}
+{/*@bgen(jjtree) ComparisonQueryExpression */
+    try {
+/*@egen*/
+    termName = <TERM> (<SPACE>)* ( operator = <EQ> | operator = <GT> | operator = <GE> | operator = <LT> | operator = <LE> ) (<SPACE>)* getValues(values)/*@bgen(jjtree)*/
+    {
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+    }
+/*@egen*/
+    { 
+    	Term term = new Term(termName.image);
+    	term.setValues(values); //Arrays.asList(termValues.image.split(",")));
+    	ComparisonQueryExpression comparisonQueryExpression = new ComparisonQueryExpression();
+    	if (bucketNames != null)
+    		comparisonQueryExpression.setBucketNames(new HashSet<String>(bucketNames));
+    	comparisonQueryExpression.setTerm(term);
+    	comparisonQueryExpression.setOperator(ComparisonQueryExpression.Operator.getOperatorBySign(operator.image));
+    	return comparisonQueryExpression; 
+    }/*@bgen(jjtree)*/
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        throw (RuntimeException)jjte000;
+      }
+      if (jjte000 instanceof ParseException) {
+        throw (ParseException)jjte000;
+      }
+      throw (Error)jjte000;
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+/*@egen*/
+}
+
+QueryExpression PriorityQueryExpression(Vector<String> bucketNames) :
+{/*@bgen(jjtree) PriorityQueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTPRIORITYQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	QueryExpression qe = null;
+}
+{/*@bgen(jjtree) PriorityQueryExpression */
+    try {
+/*@egen*/
+    <OPEN_PARENS> qe = Query(bucketNames) <CLOSE_PARENS>/*@bgen(jjtree)*/
+    {
+      jjtree.closeNodeScope(jjtn000, true);
+      jjtc000 = false;
+    }
+/*@egen*/
+    { return qe; }/*@bgen(jjtree)*/
+    } catch (Throwable jjte000) {
+      if (jjtc000) {
+        jjtree.clearNodeScope(jjtn000);
+        jjtc000 = false;
+      } else {
+        jjtree.popNode();
+      }
+      if (jjte000 instanceof RuntimeException) {
+        throw (RuntimeException)jjte000;
+      }
+      if (jjte000 instanceof ParseException) {
+        throw (ParseException)jjte000;
+      }
+      throw (Error)jjte000;
+    } finally {
+      if (jjtc000) {
+        jjtree.closeNodeScope(jjtn000, true);
+      }
+    }
+/*@egen*/
+}
+
+QueryExpression CustomQueryExpression(Vector<String> bucketNames) :
+{/*@bgen(jjtree) CustomQueryExpression */
+        SimpleNode jjtn000 = new SimpleNode(JJTCUSTOMQUERYEXPRESSION);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	Token customNameToken = null;
+	Properties p = new Properties();
+}
+{/*@bgen(jjtree) CustomQueryExpression */
+        try {
+/*@egen*/
+	<OPEN_BRACES> (<SPACE>)* <CUSTOM_NAME_KEY> (<SPACE>)+ <EQUALS> (<SPACE>)+ <QUOTE> customNameToken = <TERM> <QUOTE> [ LOOKAHEAD (<SEMI_COLON>) <SEMI_COLON> getProperties(p) ] <CLOSE_BRACES>/*@bgen(jjtree)*/
+        {
+          jjtree.closeNodeScope(jjtn000, true);
+          jjtc000 = false;
+        }
+/*@egen*/
+	{ 
+		CustomQueryExpression cqe = new CustomQueryExpression(customNameToken.image, p);
+    	if (bucketNames != null)
+    		cqe.setBucketNames(new HashSet<String>(bucketNames));
+    	return cqe;
+	}/*@bgen(jjtree)*/
+        } catch (Throwable jjte000) {
+          if (jjtc000) {
+            jjtree.clearNodeScope(jjtn000);
+            jjtc000 = false;
+          } else {
+            jjtree.popNode();
+          }
+          if (jjte000 instanceof RuntimeException) {
+            throw (RuntimeException)jjte000;
+          }
+          if (jjte000 instanceof ParseException) {
+            throw (ParseException)jjte000;
+          }
+          throw (Error)jjte000;
+        } finally {
+          if (jjtc000) {
+            jjtree.closeNodeScope(jjtn000, true);
+          }
+        }
+/*@egen*/
+}
+
+void getValues(Vector<String> values) : 
+{/*@bgen(jjtree) getValues */
+        SimpleNode jjtn000 = new SimpleNode(JJTGETVALUES);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	Token value = null;
+}
+{/*@bgen(jjtree) getValues */
+        try {
+/*@egen*/
+	value = <VALUE> ( LOOKAHEAD (<COMMA>) <COMMA> getValues(values) ) */*@bgen(jjtree)*/
+        {
+          jjtree.closeNodeScope(jjtn000, true);
+          jjtc000 = false;
+        }
+/*@egen*/
+	{ 
+		values.add(0, value.image.replaceAll("'", ""));
+	}/*@bgen(jjtree)*/
+        } catch (Throwable jjte000) {
+          if (jjtc000) {
+            jjtree.clearNodeScope(jjtn000);
+            jjtc000 = false;
+          } else {
+            jjtree.popNode();
+          }
+          if (jjte000 instanceof RuntimeException) {
+            throw (RuntimeException)jjte000;
+          }
+          if (jjte000 instanceof ParseException) {
+            throw (ParseException)jjte000;
+          }
+          throw (Error)jjte000;
+        } finally {
+          if (jjtc000) {
+            jjtree.closeNodeScope(jjtn000, true);
+          }
+        }
+/*@egen*/
+}
+
+void getProperties(Properties p) : 
+{/*@bgen(jjtree) getProperties */
+        SimpleNode jjtn000 = new SimpleNode(JJTGETPROPERTIES);
+        boolean jjtc000 = true;
+        jjtree.openNodeScope(jjtn000);
+/*@egen*/
+	Token propertyKey = null;
+	Token propertyVal = null;
+}
+{/*@bgen(jjtree) getProperties */
+        try {
+/*@egen*/
+	propertyKey = <P_KEY> (<SPACE>)+ <EQUALS> (<SPACE>)+ propertyVal = <VALUE> ( LOOKAHEAD (<COMMA>) <COMMA> getProperties(p) ) */*@bgen(jjtree)*/
+        {
+          jjtree.closeNodeScope(jjtn000, true);
+          jjtc000 = false;
+        }
+/*@egen*/
+	{ 
+		p.put(propertyKey.image.substring(2), propertyVal.image.replaceAll("'", ""));
+	}/*@bgen(jjtree)*/
+        } catch (Throwable jjte000) {
+          if (jjtc000) {
+            jjtree.clearNodeScope(jjtn000);
+            jjtc000 = false;
+          } else {
+            jjtree.popNode();
+          }
+          if (jjte000 instanceof RuntimeException) {
+            throw (RuntimeException)jjte000;
+          }
+          if (jjte000 instanceof ParseException) {
+            throw (ParseException)jjte000;
+          }
+          throw (Error)jjte000;
+        } finally {
+          if (jjtc000) {
+            jjtree.closeNodeScope(jjtn000, true);
+          }
+        }
+/*@egen*/
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.jjt
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.jjt?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.jjt (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParser.jjt Wed Sep 29 17:19:09 2010
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+options {
+  JDK_VERSION = "1.5";
+  STATIC = false;
+}
+
+PARSER_BEGIN(QueryParser)
+	package org.apache.oodt.cas.catalog.query.parser;
+
+	import java.io.ByteArrayInputStream;
+	import java.util.Arrays;
+	import java.util.HashSet;
+	import java.util.Vector;
+	import java.util.Properties;
+	import org.apache.oodt.cas.catalog.query.QueryExpression;
+	import org.apache.oodt.cas.catalog.query.QueryLogicalGroup;
+	import org.apache.oodt.cas.catalog.query.StdQueryExpression;
+	import org.apache.oodt.cas.catalog.query.ComparisonQueryExpression;
+	import org.apache.oodt.cas.catalog.query.CustomQueryExpression;
+	import org.apache.oodt.cas.catalog.term.Term;
+	
+    public class QueryParser {
+    	
+    	public static QueryExpression parseQueryExpression(String queryExpressionString) throws ParseException, TokenMgrError {
+    		return new QueryParser(new ByteArrayInputStream(queryExpressionString.getBytes())).parseInput();
+    	}
+    	
+       	public static void main( String[] args ) throws ParseException, TokenMgrError {
+          	System.out.println(new QueryParser( System.in ).parseInput());
+       	} 
+       	
+    }
+PARSER_END(QueryParser)
+
+SKIP : { "\r" | "\n" | "\r\n" }
+TOKEN: { < SPACE : " " > }
+TOKEN: { < AND : " AND " > }
+TOKEN: { < OR : " OR " > }
+TOKEN: { < QUOTE : "'" > }
+TOKEN: { < EQUALS : "=" > }
+TOKEN: { < SEMI_COLON : ";" > }
+TOKEN: { < COMMA : "," > }
+TOKEN: { < OPEN_BRACES : "{" > }
+TOKEN: { < CLOSE_BRACES : "}" > }
+TOKEN: { < OPEN_PARENS : "(" > }
+TOKEN: { < CLOSE_PARENS : ")" > }
+TOKEN: { < BUCKET_NAME_KEY : "bucketNames" > }
+TOKEN: { < CUSTOM_NAME_KEY : "name" > }
+TOKEN: { < P_KEY : "p:" <TERM> > }
+TOKEN: {
+      < EQ : "==" >
+    | < GE : ">=" >
+    | < GT : ">" >
+    | < LE : "<=" >
+    | < LT : "<" >
+}
+TOKEN: { < TERM: (["a"-"z","A"-"Z"])+ (<STRING_LITERAL>)* > }
+TOKEN: { < VALUE : "'" ( <TERM> | <NON_TERM> ) "'" > }
+TOKEN: { < #NON_TERM: (<STRING_LITERAL> | <SPECIAL_CHARS>)+ (<STRING_LITERAL> | " "<STRING_LITERAL> | " "<SPECIAL_CHARS> | <SPECIAL_CHARS>)* > }
+TOKEN: { < #STRING_LITERAL: (["0"-"9","a"-"z","A"-"Z","-","_",".",":","/"]) > }
+TOKEN: { < #SPECIAL_CHARS: (["/","\\","?","<",">","~","`","*","#","&","!","@","$","%","^","(",")","{","}","[","]"]) > }
+
+QueryExpression parseInput() : 
+{
+	QueryExpression qe = null;
+}
+{
+   	qe = Query(null) <EOF>
+   	{ return qe; }
+}
+
+QueryExpression Query(Vector<String> bucketNames) : 
+{
+	QueryExpression qe1 = null;
+	QueryExpression qe2 = null;
+	Token operator = null;
+}
+{
+    qe1 = QueryExpression(bucketNames) ( LOOKAHEAD( <AND> | <OR> ) ( operator = <AND> | operator = <OR> ) qe2 = Query(bucketNames) )*
+    { 
+    	if (qe2 == null) {
+    		return qe1;
+    	}else {
+    		QueryLogicalGroup queryLogicalGroup = new QueryLogicalGroup();
+    		if (bucketNames != null)
+    			queryLogicalGroup.setBucketNames(new HashSet<String>(bucketNames));
+    		queryLogicalGroup.setOperator(QueryLogicalGroup.Operator.valueOf(operator.image.trim().toUpperCase()));
+    		queryLogicalGroup.addExpression(qe1);
+    		queryLogicalGroup.addExpression(qe2);
+    		return queryLogicalGroup;
+    	}
+    }
+}
+
+QueryExpression QueryExpression(Vector<String> bucketNames) :
+{
+	QueryExpression qe = null;
+}
+{
+    ( 
+    	LOOKAHEAD ( <OPEN_PARENS> ) 
+    	qe = PriorityQueryExpression(bucketNames)
+    | 
+    	LOOKAHEAD ( <OPEN_BRACES> <BUCKET_NAME_KEY> ) 
+    	qe = StdQueryExpression()
+    | 
+    	LOOKAHEAD ( <OPEN_BRACES> <CUSTOM_NAME_KEY> ) 
+    	qe = CustomQueryExpression(bucketNames)
+    | 
+        LOOKAHEAD ( <TERM> ) 
+    	qe = ComparisonQueryExpression(bucketNames) 
+    )
+    
+    { return qe; }
+}
+
+QueryExpression StdQueryExpression() : 
+{
+	QueryExpression qe = null;
+	Vector<String> bucketNames = new Vector<String>();
+}
+{
+    <OPEN_BRACES> (<SPACE>)* <BUCKET_NAME_KEY> (<SPACE>)* <EQUALS> (<SPACE>)* <QUOTE> getValues(bucketNames) <QUOTE> (<SPACE>)* [<SEMI_COLON> qe = Query(bucketNames)] <CLOSE_BRACES>
+    { 
+    	if (qe == null) {
+    		return new StdQueryExpression(new HashSet<String>(bucketNames));
+    	}else {
+    		return qe; 
+    	}
+    }
+}
+
+QueryExpression ComparisonQueryExpression(Vector<String> bucketNames) : 
+{
+	Token termName = null;
+	Token operator = null;
+	Vector<String> values = new Vector<String>();
+}
+{
+    termName = <TERM> (<SPACE>)* ( operator = <EQ> | operator = <GT> | operator = <GE> | operator = <LT> | operator = <LE> ) (<SPACE>)* getValues(values)
+    { 
+    	Term term = new Term(termName.image);
+    	term.setValues(values); //Arrays.asList(termValues.image.split(",")));
+    	ComparisonQueryExpression comparisonQueryExpression = new ComparisonQueryExpression();
+    	if (bucketNames != null)
+    		comparisonQueryExpression.setBucketNames(new HashSet<String>(bucketNames));
+    	comparisonQueryExpression.setTerm(term);
+    	comparisonQueryExpression.setOperator(ComparisonQueryExpression.Operator.getOperatorBySign(operator.image));
+    	return comparisonQueryExpression; 
+    }
+}
+
+QueryExpression PriorityQueryExpression(Vector<String> bucketNames) :
+{
+	QueryExpression qe = null;
+}
+{
+    <OPEN_PARENS> qe = Query(bucketNames) <CLOSE_PARENS>
+    { return qe; }
+}
+
+QueryExpression CustomQueryExpression(Vector<String> bucketNames) :
+{
+	Token customNameToken = null;
+	Properties p = new Properties();
+}
+{
+	<OPEN_BRACES> (<SPACE>)* <CUSTOM_NAME_KEY> (<SPACE>)+ <EQUALS> (<SPACE>)+ <QUOTE> customNameToken = <TERM> <QUOTE> [ LOOKAHEAD (<SEMI_COLON>) <SEMI_COLON> getProperties(p) ] <CLOSE_BRACES>
+	{ 
+		CustomQueryExpression cqe = new CustomQueryExpression(customNameToken.image, p);
+    	if (bucketNames != null)
+    		cqe.setBucketNames(new HashSet<String>(bucketNames));
+    	return cqe;
+	}
+}
+
+void getValues(Vector<String> values) : 
+{
+	Token value = null;
+}
+{
+	value = <VALUE> ( LOOKAHEAD (<COMMA>) <COMMA> getValues(values) ) *
+	{ 
+		values.add(0, value.image.replaceAll("'", ""));
+	}
+}
+
+void getProperties(Properties p) : 
+{
+	Token propertyKey = null;
+	Token propertyVal = null;
+}
+{
+	propertyKey = <P_KEY> (<SPACE>)+ <EQUALS> (<SPACE>)+ propertyVal = <VALUE> ( LOOKAHEAD (<COMMA>) <COMMA> getProperties(p) ) *
+	{ 
+		p.put(propertyKey.image.substring(2), propertyVal.image.replaceAll("'", ""));
+	}
+}

Added: incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParserConstants.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParserConstants.java?rev=1002752&view=auto
==============================================================================
--- incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParserConstants.java (added)
+++ incubator/oodt/trunk/catalog/src/main/java/org/apache/oodt/cas/catalog/query/parser/QueryParserConstants.java Wed Sep 29 17:19:09 2010
@@ -0,0 +1,97 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. QueryParserConstants.java */
+package org.apache.oodt.cas.catalog.query.parser;
+
+
+/**
+ * Token literal values and constants.
+ * Generated by org.javacc.parser.OtherFilesGen#start()
+ */
+public interface QueryParserConstants {
+
+  /** End of File. */
+  int EOF = 0;
+  /** RegularExpression Id. */
+  int SPACE = 4;
+  /** RegularExpression Id. */
+  int AND = 5;
+  /** RegularExpression Id. */
+  int OR = 6;
+  /** RegularExpression Id. */
+  int QUOTE = 7;
+  /** RegularExpression Id. */
+  int EQUALS = 8;
+  /** RegularExpression Id. */
+  int SEMI_COLON = 9;
+  /** RegularExpression Id. */
+  int COMMA = 10;
+  /** RegularExpression Id. */
+  int OPEN_BRACES = 11;
+  /** RegularExpression Id. */
+  int CLOSE_BRACES = 12;
+  /** RegularExpression Id. */
+  int OPEN_PARENS = 13;
+  /** RegularExpression Id. */
+  int CLOSE_PARENS = 14;
+  /** RegularExpression Id. */
+  int BUCKET_NAME_KEY = 15;
+  /** RegularExpression Id. */
+  int CUSTOM_NAME_KEY = 16;
+  /** RegularExpression Id. */
+  int P_KEY = 17;
+  /** RegularExpression Id. */
+  int EQ = 18;
+  /** RegularExpression Id. */
+  int GE = 19;
+  /** RegularExpression Id. */
+  int GT = 20;
+  /** RegularExpression Id. */
+  int LE = 21;
+  /** RegularExpression Id. */
+  int LT = 22;
+  /** RegularExpression Id. */
+  int TERM = 23;
+  /** RegularExpression Id. */
+  int VALUE = 24;
+  /** RegularExpression Id. */
+  int NON_TERM = 25;
+  /** RegularExpression Id. */
+  int STRING_LITERAL = 26;
+  /** RegularExpression Id. */
+  int SPECIAL_CHARS = 27;
+
+  /** Lexical state. */
+  int DEFAULT = 0;
+
+  /** Literal token values. */
+  String[] tokenImage = {
+    "<EOF>",
+    "\"\\r\"",
+    "\"\\n\"",
+    "\"\\r\\n\"",
+    "\" \"",
+    "\" AND \"",
+    "\" OR \"",
+    "\"\\\'\"",
+    "\"=\"",
+    "\";\"",
+    "\",\"",
+    "\"{\"",
+    "\"}\"",
+    "\"(\"",
+    "\")\"",
+    "\"bucketNames\"",
+    "\"name\"",
+    "<P_KEY>",
+    "\"==\"",
+    "\">=\"",
+    "\">\"",
+    "\"<=\"",
+    "\"<\"",
+    "<TERM>",
+    "<VALUE>",
+    "<NON_TERM>",
+    "<STRING_LITERAL>",
+    "<SPECIAL_CHARS>",
+  };
+
+}



Mime
View raw message