Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/rxm.git

Files for parsing the rxm WHERE expression.

Author Dave Jarvis <email>
Date 2015-03-15 19:00:14 GMT-0700
Commit e80cec50a3800e752de9a3d78619473264e77b44
Parent 38434d8
Delta 77 lines added, 0 lines removed, 77-line increase
source/java/com/whitemagicsoftware/rxm/tree/xml/WhereClauseList.java
+package com.whitemagicsoftware.rxm.tree.xml;
+
+import com.whitemagicsoftware.rxm.tree.Payload;
+
+import org.antlr.v4.runtime.Token;
+
+/**
+ * <p>
+ * Stores a list of Payload instances. This is instantiated by the parser
+ * to create a transformation list capable of generating SQL/XML WHERE
+ * expressions. The payload dynamically determines the set of wrapper classes
+ * using the package for name of class.
+ * </p>
+ * <p>
+ * The tree is being re-used as a list. (A list is simply a tree with
+ * one branch and many siblings.)
+ * </p>
+ */
+public class WhereClauseList<T extends Payload> extends JoinClauseList<T> {
+ /**
+ * Constructs a list capable of transforming itself into a SQL/XML
+ * FROM clause.
+ *
+ * @param payload The data associated with this list (must not be null).
+ */
+ public WhereClauseList( T payload ) {
+ super( payload );
+ }
+}
+
source/java/com/whitemagicsoftware/rxm/tree/xml/WhereContext.java
+package com.whitemagicsoftware.rxm.tree.xml;
+
+import com.whitemagicsoftware.rxm.grammar.QueryParser;
+import com.whitemagicsoftware.rxm.tree.Payload;
+import com.whitemagicsoftware.rxm.tree.Token;
+import com.whitemagicsoftware.rxm.tree.Tree;
+
+import org.antlr.v4.runtime.ParserRuleContext;
+
+/**
+ * Transforms a where <b>rxm</b> expression into a SQL <code>WHERE</code>
+ * expression.
+ */
+public class WhereContext extends PayloadParserRuleContext {
+ /**
+ * Default constructor (calls super).
+ *
+ * @param ctx The payload that associates the parser rule context with
+ * the abstract syntax tree.
+ */
+ public WhereContext( Payload ctx ) {
+ super( ctx );
+ }
+
+ /**
+ * Returns the starting text for an OUTER JOIN clause.
+ */
+ @Override
+ public Token getStart() {
+ QueryParser.ExpressionContext expression = expression();
+
+ return new Token( expression.getText() );
+ }
+
+ /**
+ * Returns the ending text for an OUTER JOIN clause.
+ */
+ @Override
+ public Token getStop() {
+ return new Token( "" );
+ }
+
+ private QueryParser.ExpressionContext expression() {
+ return ((QueryParser.WhereContext)getParserRuleContext()).expression();
+ }
+}
+