Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

[EAGLE-740]Fix eagle-query checkstyle warnings #647

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 14 additions & 0 deletions eagle-core/eagle-query/eagle-antlr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,18 @@
<artifactId>commons-lang</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<failOnViolation>true</failOnViolation>
<failsOnError>true</failsOnError>
<excludes>org/apache/eagle/query/antlr/generated/*</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@ public class EagleFilterLexer extends Lexer {
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
WHITESPACE=1, OP=2, AND=3, OR=4, ID=5, VALUE=6, SINGLE_VALUE=7, EXPR=8,
NUMBER=9, NULL=10, SET=11, DOUBLEQUOTED_STRING=12, LPAREN=13, RPAREN=14,
WHITESPACE=1, OP=2, AND=3, OR=4, ID=5, VALUE=6, SINGLE_VALUE=7, EXPR=8,
NUMBER=9, NULL=10, SET=11, DOUBLEQUOTED_STRING=12, LPAREN=13, RPAREN=14,
LBRACE=15, RBRACE=16;
public static String[] modeNames = {
"DEFAULT_MODE"
};

public static final String[] ruleNames = {
"WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE", "EXPR",
"NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "UNSIGN_INT", "STRING",
"WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE", "EXPR",
"NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "UNSIGN_INT", "STRING",
"LPAREN", "RPAREN", "LBRACE", "RBRACE"
};

private static final String[] _LITERAL_NAMES = {
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, "'('", "')'", "'{'", "'}'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE",
"EXPR", "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "LPAREN", "RPAREN",
null, "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE",
"EXPR", "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "LPAREN", "RPAREN",
"LBRACE", "RBRACE"
};
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class EagleFilterParser extends Parser {
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
WHITESPACE=1, OP=2, AND=3, OR=4, ID=5, VALUE=6, SINGLE_VALUE=7, EXPR=8,
NUMBER=9, NULL=10, SET=11, DOUBLEQUOTED_STRING=12, LPAREN=13, RPAREN=14,
WHITESPACE=1, OP=2, AND=3, OR=4, ID=5, VALUE=6, SINGLE_VALUE=7, EXPR=8,
NUMBER=9, NULL=10, SET=11, DOUBLEQUOTED_STRING=12, LPAREN=13, RPAREN=14,
LBRACE=15, RBRACE=16;
public static final int
RULE_filter = 0, RULE_combine = 1, RULE_equation = 2;
Expand All @@ -41,12 +41,12 @@ public class EagleFilterParser extends Parser {
};

private static final String[] _LITERAL_NAMES = {
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, "'('", "')'", "'{'", "'}'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE",
"EXPR", "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "LPAREN", "RPAREN",
null, "WHITESPACE", "OP", "AND", "OR", "ID", "VALUE", "SINGLE_VALUE",
"EXPR", "NUMBER", "NULL", "SET", "DOUBLEQUOTED_STRING", "LPAREN", "RPAREN",
"LBRACE", "RBRACE"
};
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
Expand Down Expand Up @@ -241,7 +241,7 @@ private CombineContext combine(int _p) throws RecognitionException {
}
break;
}
}
}
}
setState(27);
_errHandler.sync(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,40 @@
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 op;

private ComparisonOperator(String op) {
this.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);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,31 @@
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);
}
}
Loading