eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yonzhang2...@apache.org
Subject [2/2] eagle git commit: EAGLE-1079 - Fix checkstyle issues in antlr module fix checkstyle in eagle-antlr module
Date Thu, 01 Feb 2018 23:01:51 GMT
EAGLE-1079 - Fix checkstyle issues in antlr module
fix checkstyle in eagle-antlr module

https://issues.apache.org/jira/browse/EAGLE-1079

Author: @coheigea coheigea@apache.org
Reviewer: @yonzhang2012 yonzhang2012@apache.org

Closes #982


Project: http://git-wip-us.apache.org/repos/asf/eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/e256503d
Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/e256503d
Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/e256503d

Branch: refs/heads/master
Commit: e256503d3d240158589a3b2271ad4b0d7651d22f
Parents: 52edcd1
Author: yonzhang <yonzhang2012@gmail.com>
Authored: Thu Feb 1 15:00:24 2018 -0800
Committer: yonzhang <yonzhang2012@gmail.com>
Committed: Thu Feb 1 15:00:24 2018 -0800

----------------------------------------------------------------------
 .../eagle/query/parser/ANDExpression.java       |   16 +-
 .../eagle/query/parser/AtomicExpression.java    |   92 +-
 .../eagle/query/parser/ComparisonOperator.java  |   64 +-
 .../query/parser/EagleANTLRErrorStrategy.java   |   49 +-
 .../parser/EagleQueryFilterListenerImpl.java    |  298 ++--
 .../query/parser/EagleQueryParseException.java  |   16 +-
 .../eagle/query/parser/EagleQueryParser.java    |   53 +-
 .../eagle/query/parser/LogicalOperator.java     |    6 +-
 .../apache/eagle/query/parser/ORExpression.java |   70 +-
 .../eagle/query/parser/TokenConstant.java       |   28 +-
 .../UnsupportedExpressionOperatorException.java |   10 +-
 .../query/parser/test/TestEagleQueryParser.java | 1612 +++++++++---------
 .../eagle/query/parser/test/TestValueType.java  |   76 +-
 13 files changed, 1206 insertions(+), 1184 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java
index f575e0f..7136343 100644
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ANDExpression.java
@@ -20,14 +20,14 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class ANDExpression {
-	// TODO use Set data structure to dedupe for optimization?
-	private List<AtomicExpression> atomicExpressionList = new ArrayList<AtomicExpression>();
+    // TODO use Set data structure to dedupe for optimization?
+    private List<AtomicExpression> atomicExpressionList = new ArrayList<AtomicExpression>();
 
-	public List<AtomicExpression> getAtomicExprList() {
-		return atomicExpressionList;
-	}
+    public List<AtomicExpression> getAtomicExprList() {
+        return atomicExpressionList;
+    }
 
-	public void setAtomicExprList(List<AtomicExpression> list) {
-		this.atomicExpressionList = list;
-	}
+    public void setAtomicExprList(List<AtomicExpression> list) {
+        this.atomicExpressionList = list;
+    }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java
index f831ede..391755c 100755
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/AtomicExpression.java
@@ -17,51 +17,57 @@
 package org.apache.eagle.query.parser;
 
 public class AtomicExpression {
-	private String key;
-	private ComparisonOperator op;
-	private String value;
-	private TokenType keyType;
-	private TokenType valueType;
+    private String key;
+    private ComparisonOperator op;
+    private String value;
+    private TokenType keyType;
+    private TokenType valueType;
 
-	public String getKey() {
-		return key;
-	}
-	public void setKey(String key) {
-		this.key = key;
-	}
-	public ComparisonOperator getOp() {
-		return op;
-	}
-	public void setOp(ComparisonOperator op) {
-		this.op = op;
-	}
-	public String getValue() {
-		return value;
-	}
-	public void setValue(String value) {
-		this.value = value;
-	}
-	public String toString(){
-		if(this.valueType == TokenType.STRING){
-			return key + op + "\"" + value + "\"";
-		}else{
-			return key + op + value;
-		}
-	}
+    public String getKey() {
+        return key;
+    }
 
-	public TokenType getKeyType() {
-		return keyType;
-	}
+    public void setKey(String key) {
+        this.key = key;
+    }
 
-	public void setKeyType(TokenType keyType) {
-		this.keyType = keyType;
-	}
-	
-	public TokenType getValueType() {
-		return valueType;
-	}
+    public ComparisonOperator getOp() {
+        return op;
+    }
 
-	public void setValueType(TokenType type) {
-		this.valueType = type;
-	}
+    public void setOp(ComparisonOperator op) {
+        this.op = op;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String toString() {
+        if (this.valueType == TokenType.STRING) {
+            return key + op + "\"" + value + "\"";
+        } else {
+            return key + op + value;
+        }
+    }
+
+    public TokenType getKeyType() {
+        return keyType;
+    }
+
+    public void setKeyType(TokenType keyType) {
+        this.keyType = keyType;
+    }
+
+    public TokenType getValueType() {
+        return valueType;
+    }
+
+    public void setValueType(TokenType type) {
+        this.valueType = type;
+    }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java
index 3a1be37..e789fa8 100755
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ComparisonOperator.java
@@ -17,39 +17,39 @@
 package org.apache.eagle.query.parser;
 
 public enum ComparisonOperator {
-	EQUAL("="),
-	LIKE("=~"),
-	IN("IN"),
-	NOT_IN("NOT IN"),
-	LESS("<"),
-	LESS_OR_EQUAL("<="),
-	GREATER(">"),
-	GREATER_OR_EQUAL(">="),
-	NOT_EQUAL("!="),
-	NOT_LIKE("!=~"),
-	CONTAINS("CONTAINS"),
-	NOT_CONTAINS("NOT CONTAINS"),
-	IS("IS"),
-	IS_NOT("IS NOT");
+    EQUAL("="),
+    LIKE("=~"),
+    IN("IN"),
+    NOT_IN("NOT IN"),
+    LESS("<"),
+    LESS_OR_EQUAL("<="),
+    GREATER(">"),
+    GREATER_OR_EQUAL(">="),
+    NOT_EQUAL("!="),
+    NOT_LIKE("!=~"),
+    CONTAINS("CONTAINS"),
+    NOT_CONTAINS("NOT CONTAINS"),
+    IS("IS"),
+    IS_NOT("IS NOT");
 
-	private final String _op;
-	private ComparisonOperator(String op){
-		_op = op;
-	}
-	
-	public String toString(){
-		return _op;
-	}
-	
-	public static ComparisonOperator locateOperator(String op){
-		op = op.replaceAll("\\s+"," ");
-		for(ComparisonOperator o : ComparisonOperator.values()){
-			if(op.toUpperCase().equals(o._op)){
-				return o;
-			}
-		}
-		throw new UnsupportedExpressionOperatorException(op);
-	}
+    private final String storedOp;
+    private ComparisonOperator(String op) {
+        storedOp = op;
+    }
+
+    public String toString() {
+        return storedOp;
+    }
+
+    public static ComparisonOperator locateOperator(String op) {
+        op = op.replaceAll("\\s+"," ");
+        for (ComparisonOperator o : ComparisonOperator.values()) {
+            if (op.toUpperCase().equals(o.storedOp)) {
+                return o;
+            }
+        }
+        throw new UnsupportedExpressionOperatorException(op);
+    }
 }
 
 

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java
index e016ea9..f06ff57 100644
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleANTLRErrorStrategy.java
@@ -19,30 +19,29 @@ package org.apache.eagle.query.parser;
 import org.antlr.v4.runtime.*;
 
 public class EagleANTLRErrorStrategy extends DefaultErrorStrategy {
-	/** Instead of recovering from exception {@code e}, re-throw it wrapped
-	 *  in a {@link org.antlr.v4.runtime.misc.ParseCancellationException} so it is not caught
by the
-	 *  rule function catches.  Use {@link Exception#getCause()} to get the
-	 *  original {@link org.antlr.v4.runtime.RecognitionException}.
-	 */
-	@Override
-	public void recover(Parser recognizer, RecognitionException e) {
-		for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent())
{
-			context.exception = e;
-		}
-		super.recover(recognizer,e);
-	}
+    /** Instead of recovering from exception {@code e}, re-throw it wrapped
+     *  in a {@link org.antlr.v4.runtime.misc.ParseCancellationException} so it is not caught
by the
+     *  rule function catches.  Use {@link Exception#getCause()} to get the
+     *  original {@link org.antlr.v4.runtime.RecognitionException}.
+     */
+    @Override
+    public void recover(Parser recognizer, RecognitionException e) {
+        for (ParserRuleContext context = recognizer.getContext(); context != null; context
= context.getParent()) {
+            context.exception = e;
+        }
+        super.recover(recognizer,e);
+    }
 
-	/** Make sure we don't attempt to recover inline; if the parser
-	 *  successfully recovers, it won't throw an exception.
-	 */
-	@Override
-	public Token recoverInline(Parser recognizer)
-			throws RecognitionException
-	{
-		InputMismatchException e = new InputMismatchException(recognizer);
-		for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent())
{
-			context.exception = e;
-		}
-		return super.recoverInline(recognizer);
-	}
+    /** Make sure we don't attempt to recover inline; if the parser
+     *  successfully recovers, it won't throw an exception.
+     */
+    @Override
+    public Token recoverInline(Parser recognizer)
+        throws RecognitionException {
+        InputMismatchException e = new InputMismatchException(recognizer);
+        for (ParserRuleContext context = recognizer.getContext(); context != null; context
= context.getParent()) {
+            context.exception = e;
+        }
+        return super.recoverInline(recognizer);
+    }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java
index a631e53..23fa3d5 100755
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryFilterListenerImpl.java
@@ -29,148 +29,162 @@ import java.util.List;
 import java.util.Stack;
 import java.util.regex.Matcher;
 
-public class EagleQueryFilterListenerImpl implements EagleFilterListener{
-	private final static Logger LOG = LoggerFactory.getLogger(EagleQueryFilterListenerImpl.class);
-	private Stack<ORExpression> _stack = new Stack<ORExpression>();
-	
-	public ORExpression result(){
-		return _stack.pop();
-	}
-	
-	public void enterEquation(EagleFilterParser.EquationContext ctx){
-	}
-	
-	public void exitEquation(EagleFilterParser.EquationContext ctx){
-		TerminalNode id = ctx.ID();
-		TerminalNode op = ctx.OP();
-		List<TerminalNode> values = ctx.VALUE();
-		TerminalNode value = values.get(0);
-
-		if(values.size() == 2){
-			// value op value
-			id = values.get(0);
-			value = values.get(1);
-		}
-
-		if(LOG.isDebugEnabled()) LOG.debug("ID:" + id.getText() + ", OP:" + op.getText() + ", VALUE:"
+ value);
-
-		AtomicExpression kv = new AtomicExpression();
-		kv.setKey(id.getText());
-		kv.setOp(ComparisonOperator.locateOperator(op.getText()));
-
-		try{
-			kv.setValueType(TokenType.locate(value.getText()));
-		}catch (Exception ex){
-			LOG.error("Failed to locate value type for: " + value.getText() + " due to exception:
" + ex.getMessage(), ex);
-		}
-
-		try{
-			kv.setKeyType(TokenType.locate(id.getText()));
-		}catch (Exception ex){
-			LOG.error("Failed to locate id type for: " + id.getText() + " due to exception: " + ex.getMessage(),
ex);
-		}
-
-//		if(id != null){
-			kv.setKey(postProcessNode(id.getText(),kv.getKeyType()));
-//		}
-
-//		if(value != null){
-			kv.setValue(postProcessNode(value.getText(),kv.getValueType()));
-			// As to List value, it will escape in List parser but not here
-			if(kv.getValueType() != TokenType.LIST) kv.setValue(StringEscapeUtils.unescapeJava(kv.getValue()));
-//		}
-
-		// push to stack
-		ORExpression orExpr = new ORExpression();
-		ANDExpression andExpr = new ANDExpression();
-		andExpr.getAtomicExprList().add(kv);
-		orExpr.getANDExprList().add(andExpr);
-		_stack.push(orExpr);
-	}
-
-	private String postProcessNode(String text,TokenType type){
-		int len = text.length();
-		int start=0,end = len;
-		if(text.startsWith("\"")) start=1;
-		if(text.endsWith("\"")) end = len -1;
-		text = text.substring(start, end);
-		if(type == TokenType.EXP){
-			Matcher matcher = TokenConstant.EXP_PATTERN.matcher(text);
-			if(matcher.find()){
-				text = matcher.group(1);
-			}
-			text = text.replace(TokenConstant.ID_PREFIX,TokenConstant.WHITE_SPACE);
-		}
-		return text;
-	}
-
-	public void enterCombine(EagleFilterParser.CombineContext ctx){
-		
-	}
-	
-	public void exitCombine(EagleFilterParser.CombineContext ctx){
-		int numChild = ctx.getChildCount();
-		if(numChild == 1){
-			if(LOG.isDebugEnabled()) LOG.debug("Only one child, skip ...");
-			return; // does nothing for a combine which has only one equation
-		}
-		
-		if((ctx.LPAREN() != null) && (ctx.RPAREN() != null)){
-			if(LOG.isDebugEnabled()) LOG.debug("LPAREN + RPAREN rule matched, skip ...");
-			return; // does nothing for a combine which is within parenthesis
-		}
-		ORExpression orExprRight = _stack.pop();
-		ORExpression orExprLeft = _stack.pop();
-		TerminalNode node = ctx.AND();
-		if(node != null){
-			ORExpression newORExpr = new ORExpression();
-			for(ANDExpression left : orExprLeft.getANDExprList()){
-				for(ANDExpression right : orExprRight.getANDExprList()){
-					ANDExpression tmp = new ANDExpression();
-					tmp.getAtomicExprList().addAll(left.getAtomicExprList());
-					tmp.getAtomicExprList().addAll(right.getAtomicExprList());
-					newORExpr.getANDExprList().add(tmp);
-				}
-			}
-			_stack.push(newORExpr);
-			return;
-		}
-		
-		node = ctx.OR();
-		if(node != null){
-			ORExpression newORExpr = new ORExpression();
-			for(ANDExpression andExpr : orExprLeft.getANDExprList()){
-				newORExpr.getANDExprList().add(andExpr);
-			}
-			for(ANDExpression andExpr : orExprRight.getANDExprList()){
-				newORExpr.getANDExprList().add(andExpr);
-			}
-			_stack.push(newORExpr);
-			return;
-		}
-		LOG.warn("Should never come here!");
-	}
-
-	public void enterFilter(EagleFilterParser.FilterContext ctx){
-		
-	}
-	
-	public void exitFilter(EagleFilterParser.FilterContext ctx){
-		// print all relations (KeyValueFilter AND KeyValueFilter) OR (KeyValueFilter AND KeyValueFilter)
OR (KeyValueFilter AND KeyValueFilter)"
-		ORExpression orExpr = _stack.peek();
-		if(LOG.isDebugEnabled()) LOG.debug(orExpr.toString());
-	}
-	
-	public void visitTerminal(TerminalNode node){
-		
-	}
-	public void visitErrorNode(ErrorNode node){
-
-	}
-    public void enterEveryRule(ParserRuleContext ctx){
+public class EagleQueryFilterListenerImpl implements EagleFilterListener {
+    private static final Logger LOG = LoggerFactory.getLogger(EagleQueryFilterListenerImpl.class);
+    private Stack<ORExpression> stack = new Stack<ORExpression>();
+
+    public ORExpression result() {
+        return stack.pop();
+    }
+
+    public void enterEquation(EagleFilterParser.EquationContext ctx) {
+    }
+
+    public void exitEquation(EagleFilterParser.EquationContext ctx) {
+        TerminalNode id = ctx.ID();
+        TerminalNode op = ctx.OP();
+        List<TerminalNode> values = ctx.VALUE();
+        TerminalNode value = values.get(0);
+
+        if (values.size() == 2) {
+            // value op value
+            id = values.get(0);
+            value = values.get(1);
+        }
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("ID:" + id.getText() + ", OP:" + op.getText() + ", VALUE:" + value);
+        }
+
+        AtomicExpression kv = new AtomicExpression();
+        kv.setKey(id.getText());
+        kv.setOp(ComparisonOperator.locateOperator(op.getText()));
+
+        try {
+            kv.setValueType(TokenType.locate(value.getText()));
+        } catch (Exception ex) {
+            LOG.error("Failed to locate value type for: " + value.getText() + " due to exception:
" + ex.getMessage(), ex);
+        }
+
+        try {
+            kv.setKeyType(TokenType.locate(id.getText()));
+        } catch (Exception ex) {
+            LOG.error("Failed to locate id type for: " + id.getText() + " due to exception:
" + ex.getMessage(), ex);
+        }
+
+        //    if (id != null) {
+        kv.setKey(postProcessNode(id.getText(),kv.getKeyType()));
+        //    }
+
+        //    if (value != null) {
+        kv.setValue(postProcessNode(value.getText(),kv.getValueType()));
+        // As to List value, it will escape in List parser but not here
+        if (kv.getValueType() != TokenType.LIST) {
+            kv.setValue(StringEscapeUtils.unescapeJava(kv.getValue()));
+        }
+        //    }
+
+        // push to stack
+        ORExpression orExpr = new ORExpression();
+        ANDExpression andExpr = new ANDExpression();
+        andExpr.getAtomicExprList().add(kv);
+        orExpr.getANDExprList().add(andExpr);
+        stack.push(orExpr);
+    }
+
+    private String postProcessNode(String text,TokenType type) {
+        int len = text.length();
+        int start = 0;
+        int end = len;
+        if (text.startsWith("\"")) {
+            start = 1;
+        }
+        if (text.endsWith("\"")) {
+            end = len - 1;
+        }
+        text = text.substring(start, end);
+        if (type == TokenType.EXP) {
+            Matcher matcher = TokenConstant.EXP_PATTERN.matcher(text);
+            if (matcher.find()) {
+                text = matcher.group(1);
+            }
+            text = text.replace(TokenConstant.ID_PREFIX,TokenConstant.WHITE_SPACE);
+        }
+        return text;
+    }
+
+    public void enterCombine(EagleFilterParser.CombineContext ctx) {
+
+    }
+
+    public void exitCombine(EagleFilterParser.CombineContext ctx) {
+        int numChild = ctx.getChildCount();
+        if (numChild == 1) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Only one child, skip ...");
+            }
+            return; // does nothing for a combine which has only one equation
+        }
+
+        if ((ctx.LPAREN() != null) && (ctx.RPAREN() != null)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("LPAREN + RPAREN rule matched, skip ...");
+            }
+            return; // does nothing for a combine which is within parenthesis
+        }
+        ORExpression orExprRight = stack.pop();
+        ORExpression orExprLeft = stack.pop();
+        TerminalNode node = ctx.AND();
+        if (node != null) {
+            ORExpression newORExpr = new ORExpression();
+            for (ANDExpression left : orExprLeft.getANDExprList()) {
+                for (ANDExpression right : orExprRight.getANDExprList()) {
+                    ANDExpression tmp = new ANDExpression();
+                    tmp.getAtomicExprList().addAll(left.getAtomicExprList());
+                    tmp.getAtomicExprList().addAll(right.getAtomicExprList());
+                    newORExpr.getANDExprList().add(tmp);
+                }
+            }
+            stack.push(newORExpr);
+            return;
+        }
+
+        node = ctx.OR();
+        if (node != null) {
+            ORExpression newORExpr = new ORExpression();
+            for (ANDExpression andExpr : orExprLeft.getANDExprList()) {
+                newORExpr.getANDExprList().add(andExpr);
+            }
+            for (ANDExpression andExpr : orExprRight.getANDExprList()) {
+                newORExpr.getANDExprList().add(andExpr);
+            }
+            stack.push(newORExpr);
+            return;
+        }
+        LOG.warn("Should never come here!");
     }
-    
-    public void exitEveryRule(ParserRuleContext ctx){
-    	
+
+    public void enterFilter(EagleFilterParser.FilterContext ctx) {
+
+    }
+
+    public void exitFilter(EagleFilterParser.FilterContext ctx) {
+        // print all relations (KeyValueFilter AND KeyValueFilter) OR (KeyValueFilter AND
KeyValueFilter) OR (KeyValueFilter AND KeyValueFilter)"
+        ORExpression orExpr = stack.peek();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(orExpr.toString());
+        }
+    }
+
+    public void visitTerminal(TerminalNode node) {
+    }
+
+    public void visitErrorNode(ErrorNode node) {
+    }
+
+    public void enterEveryRule(ParserRuleContext ctx) {
+    }
+
+    public void exitEveryRule(ParserRuleContext ctx) {
     }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java
index 48fc694..c8321ca 100755
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParseException.java
@@ -16,14 +16,14 @@
  */
 package org.apache.eagle.query.parser;
 
-public class EagleQueryParseException extends Exception{
-	private static final long serialVersionUID = -8440811651318471641L;
+public class EagleQueryParseException extends Exception {
+    private static final long serialVersionUID = -8440811651318471641L;
 
-	public EagleQueryParseException(String message){
-		super(message);
-	}
+    public EagleQueryParseException(String message) {
+        super(message);
+    }
 
-	public EagleQueryParseException(String message, Throwable cause) {
-		super(message, cause);
-	}
+    public EagleQueryParseException(String message, Throwable cause) {
+        super(message, cause);
+    }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java
index f2315b2..7ef5721 100755
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/EagleQueryParser.java
@@ -24,31 +24,32 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class EagleQueryParser {
-	private static final Logger LOG = LoggerFactory.getLogger(EagleQueryParser.class);
-	private String _query;
-	public EagleQueryParser(String query){
-		_query = query;
-	}
+    private static final Logger LOG = LoggerFactory.getLogger(EagleQueryParser.class);
+    private String query;
 
-	public ORExpression parse() throws EagleQueryParseException{
-		try{
-			EagleFilterLexer lexer = new EagleFilterLexer(new ANTLRInputStream(_query));
-			CommonTokenStream tokens = new CommonTokenStream(lexer);
-			tokens.fill();
-			EagleFilterParser p = new EagleFilterParser(tokens);
-			p.setErrorHandler(new EagleANTLRErrorStrategy());
-			p.setBuildParseTree(true);
-			EagleQueryFilterListenerImpl listener = new EagleQueryFilterListenerImpl(); 
-			p.addParseListener(listener);
-			EagleFilterParser.FilterContext fc = p.filter();
-			if(fc.exception != null){
-				LOG.error("Can not successfully parse the query:" + _query, fc.exception);
-				throw fc.exception;
-			}
-			return listener.result();
-		}catch(Exception ex){
-			LOG.error("Can not successfully parse the query:", ex);
-			throw new EagleQueryParseException("can not successfully parse the query:" + _query);
-		}
-	}
+    public EagleQueryParser(String query) {
+        this.query = query;
+    }
+
+    public ORExpression parse() throws EagleQueryParseException {
+        try {
+            EagleFilterLexer lexer = new EagleFilterLexer(new ANTLRInputStream(query));
+            CommonTokenStream tokens = new CommonTokenStream(lexer);
+            tokens.fill();
+            EagleFilterParser p = new EagleFilterParser(tokens);
+            p.setErrorHandler(new EagleANTLRErrorStrategy());
+            p.setBuildParseTree(true);
+            EagleQueryFilterListenerImpl listener = new EagleQueryFilterListenerImpl();
+            p.addParseListener(listener);
+            EagleFilterParser.FilterContext fc = p.filter();
+            if (fc.exception != null) {
+                LOG.error("Can not successfully parse the query:" + query, fc.exception);
+                throw fc.exception;
+            }
+            return listener.result();
+        } catch (Exception ex) {
+            LOG.error("Can not successfully parse the query:", ex);
+            throw new EagleQueryParseException("can not successfully parse the query:" +
query);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java
index 374186e..8c95991 100644
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/LogicalOperator.java
@@ -17,7 +17,7 @@
 package org.apache.eagle.query.parser;
 
 public enum LogicalOperator {
-	AND,
-	OR,
-	NOT
+    AND,
+    OR,
+    NOT
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java
index 3a43a6d..2c414f4 100644
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/ORExpression.java
@@ -20,41 +20,41 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class ORExpression {
-	private List<ANDExpression> andExprList = new ArrayList<ANDExpression>();
+    private List<ANDExpression> andExprList = new ArrayList<ANDExpression>();
 
-	public List<ANDExpression> getANDExprList() {
-		return andExprList;
-	}
+    public List<ANDExpression> getANDExprList() {
+        return andExprList;
+    }
 
-	public void setANDExprList(List<ANDExpression> list) {
-		this.andExprList = list;
-	}
-	
-	public String toString(){
-		StringBuffer sb = new StringBuffer();
-		boolean first = true;
-		for(ANDExpression andRel : andExprList){
-			if(first)
-				first = false;
-			else{
-				sb.append(" ");
-				sb.append(LogicalOperator.OR);
-				sb.append(" ");
-			}
-			sb.append("(");
-			boolean firstAND = true;
-			for(AtomicExpression kv : andRel.getAtomicExprList()){
-				if(firstAND)
-					firstAND = false;
-				else{
-					sb.append(" ");
-					sb.append(LogicalOperator.AND);
-					sb.append(" ");
-				}
-				sb.append(kv);
-			}
-			sb.append(")");
-		}
-		return sb.toString();
-	}
+    public void setANDExprList(List<ANDExpression> list) {
+        this.andExprList = list;
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer();
+        boolean first = true;
+        for (ANDExpression andRel : andExprList) {
+            if (first) {
+                first = false;
+            } else {
+                sb.append(" ");
+                sb.append(LogicalOperator.OR);
+                sb.append(" ");
+            }
+            sb.append("(");
+            boolean firstAND = true;
+            for (AtomicExpression kv : andRel.getAtomicExprList()) {
+                if (firstAND) {
+                    firstAND = false;
+                } else {
+                    sb.append(" ");
+                    sb.append(LogicalOperator.AND);
+                    sb.append(" ");
+                }
+                sb.append(kv);
+            }
+            sb.append(")");
+        }
+        return sb.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java
index f93a63e..79cef21 100755
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/TokenConstant.java
@@ -20,31 +20,33 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public final class TokenConstant {
-    public final static Pattern EXP_PATTERN= Pattern.compile("^EXP\\{(.+)\\}(\\s+AS\\s+)?\\s*(.+)?\\s*$",Pattern.CASE_INSENSITIVE);
-    public final static Pattern STRING_PATTERN= Pattern.compile("^(\"(.*?\n)*.*\")$");
-    public final static Pattern ARRAY_PATTERN= Pattern.compile("^(\\(.*\\))$");
-    public final static Pattern NUMBER_PATTERN= Pattern.compile("^((-|\\+)?\\s*[0-9]+(\\.[0-9]+)?)$");
-    public final static Pattern NULL_PATTERN= Pattern.compile("^(NULL|null)$");
-    public final static Pattern ID_PATTERN= Pattern.compile("^@(.+)$");
+    public static final Pattern EXP_PATTERN = Pattern.compile("^EXP\\{(.+)\\}(\\s+AS\\s+)?\\s*(.+)?\\s*$",Pattern.CASE_INSENSITIVE);
+    public static final Pattern STRING_PATTERN = Pattern.compile("^(\"(.*?\n)*.*\")$");
+    public static final Pattern ARRAY_PATTERN = Pattern.compile("^(\\(.*\\))$");
+    public static final Pattern NUMBER_PATTERN = Pattern.compile("^((-|\\+)?\\s*[0-9]+(\\.[0-9]+)?)$");
+    public static final Pattern NULL_PATTERN = Pattern.compile("^(NULL|null)$");
+    public static final Pattern ID_PATTERN = Pattern.compile("^@(.+)$");
 
-    public final static String ID_PREFIX = "@";
-    public final static String WHITE_SPACE = "";
+    public static final String ID_PREFIX = "@";
+    public static final String WHITE_SPACE = "";
 
-    public static boolean isExpression(String query){
-        if(query == null) return false;
+    public static boolean isExpression(String query) {
+        if (query == null) {
+            return false;
+        }
         Matcher matcher = EXP_PATTERN.matcher(query);
         return matcher.matches();
     }
 
     /**
-     * EXP{ expression } AS alias  => expression
+     * EXP{ expression } AS alias  => expression.
      *
      * @param expression
      * @return
      */
-    public static String parseExpressionContent(String expression){
+    public static String parseExpressionContent(String expression) {
         Matcher matcher = EXP_PATTERN.matcher(expression);
-        if(matcher.find()){
+        if (matcher.find()) {
             expression = matcher.group(1);
         }
         return expression;

http://git-wip-us.apache.org/repos/asf/eagle/blob/e256503d/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java
b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java
index 40997c9..de30b8b 100644
--- a/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java
+++ b/eagle-core/eagle-query/eagle-antlr/src/main/java/org/apache/eagle/query/parser/UnsupportedExpressionOperatorException.java
@@ -16,10 +16,10 @@
  */
 package org.apache.eagle.query.parser;
 
-public class UnsupportedExpressionOperatorException extends RuntimeException{
-	private static final long serialVersionUID = 565210592983703093L;
+public class UnsupportedExpressionOperatorException extends RuntimeException {
+    private static final long serialVersionUID = 565210592983703093L;
 
-	public UnsupportedExpressionOperatorException(String message){
-		super(message);
-	}
+    public UnsupportedExpressionOperatorException(String message) {
+        super(message);
+    }
 }


Mime
View raw message