Projects STRLCPY LoggerPlusPlus Commits 49d373fc
🤬
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/BooleanOperator.java src/main/java/com/nccgroup/loggerplusplus/filter/ComparisonOperator.java
    1 1  package com.nccgroup.loggerplusplus.filter;
    2 2   
    3  -public enum BooleanOperator {
     3 +public enum ComparisonOperator {
    4 4   EQUAL("=="), NOT_EQUAL("!="), GREATER_THAN(">"), LESS_THAN("<"),
    5 5   GREATER_THAN_EQUAL(">="), LESS_THAN_EQUAL("<="), CONTAINS("CONTAINS"), IN("IN"), MATCHES("MATCHES");
    6 6   
    7 7   private final String label;
    8 8   
    9  - BooleanOperator(String label){
     9 + ComparisonOperator(String label) {
    10 10   this.label = label;
    11 11   }
    12 12   
    skipped 10 lines
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/logfilter/LogFilter.java
    skipped 1 lines
    2 2   
    3 3  import com.google.gson.*;
    4 4  import com.nccgroup.loggerplusplus.LoggerPlusPlus;
    5  -import com.nccgroup.loggerplusplus.filter.BooleanOperator;
     5 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;
    6 6  import com.nccgroup.loggerplusplus.filter.LogicalOperator;
    7 7  import com.nccgroup.loggerplusplus.filter.parser.ASTExpression;
    8 8  import com.nccgroup.loggerplusplus.filter.parser.FilterEvaluationVisitor;
    skipped 22 lines
    31 31   }
    32 32   
    33 33   public String addConditionToFilter(LogicalOperator logicalOperator, LogEntryField field,
    34  - BooleanOperator booleanOperator, String value) {
     34 + ComparisonOperator booleanOperator, String value) {
    35 35   //TODO Move functionality to LogFilter itself.
    36 36   String existing;
    37  - if(this.getAST().getLogicalOperator() != null && !this.getAST().getLogicalOperator().equals(logicalOperator)){
     37 + if (this.getAST().getLogicalOperator() != null && !this.getAST().getLogicalOperator().equals(logicalOperator)) {
    38 38   existing = "(" + this.filter.getFilterString() + ")";
    39  - }else{
     39 + } else {
    40 40   existing = this.filter.getFilterString();
    41 41   }
    42 42   
    skipped 48 lines
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/ASTComparison.java
    skipped 1 lines
    2 2  /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
    3 3  package com.nccgroup.loggerplusplus.filter.parser;
    4 4   
    5  -import com.nccgroup.loggerplusplus.filter.BooleanOperator;
     5 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;
    6 6  import com.nccgroup.loggerplusplus.logentry.LogEntryField;
    7 7  import com.nccgroup.loggerplusplus.logview.processor.LogProcessor;
    8 8  import org.apache.commons.text.StringEscapeUtils;
    skipped 7 lines
    16 16  class ASTComparison extends SimpleNode {
    17 17   
    18 18   Object left, right;
    19  - BooleanOperator booleanOperator;
     19 + ComparisonOperator comparisonOperator;
    20 20   
    21 21   public ASTComparison(int id) {
    22 22   super(id);
    skipped 3 lines
    26 26   super(p, id);
    27 27   }
    28 28   
    29  - /** Accept the visitor. **/
     29 + /**
     30 + * Accept the visitor.
     31 + **/
    30 32   public Object jjtAccept(FilterParserVisitor visitor, VisitorData data) {
    31 33   
    32 34   return visitor.visit(this, data);
    33 35   }
    34 36   
    35  - public BooleanOperator getBooleanOperator() {
    36  - return booleanOperator;
     37 + public ComparisonOperator getComparisonOperator() {
     38 + return comparisonOperator;
    37 39   }
    38 40   
    39 41   public Object getLeft() {
    skipped 8 lines
    48 50   public String toString() {
    49 51   Class<?> leftClass = left instanceof LogEntryField ? ((LogEntryField) left).getType() : left.getClass();
    50 52   Class<?> rightClass = right instanceof LogEntryField ? ((LogEntryField) right).getType() : right.getClass();
    51  - return String.format("ASTComparison[left=%s (%s), op=%s, right=%s (%s)]", left, leftClass, booleanOperator, right, rightClass);
     53 + return String.format("ASTComparison[left=%s (%s), op=%s, right=%s (%s)]", left, leftClass, comparisonOperator, right, rightClass);
    52 54   }
    53 55   
    54 56   @Override
    55 57   public String getFilterString() {
    56  - return String.format("%s %s %s", convertObjectToString(left), booleanOperator.getLabel(), convertObjectToString(right));
     58 + return String.format("%s %s %s", convertObjectToString(left), comparisonOperator.getLabel(), convertObjectToString(right));
    57 59   }
    58 60   
    59 61   private String convertObjectToString(Object obj){
    60  - if(obj instanceof Pattern){
    61  - if(booleanOperator == BooleanOperator.MATCHES) return "\"" + obj + "\"";
     62 + if(obj instanceof Pattern) {
     63 + if (comparisonOperator == ComparisonOperator.MATCHES) return "\"" + obj + "\"";
    62 64   else return "/" + obj + "/";
    63 65   }else if(obj instanceof String){
    64 66   return "\"" + StringEscapeUtils.escapeJava((String) obj) + "\"";
    skipped 18 lines
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/Filter.jj
    skipped 11 lines
    12 12   
    13 13  PARSER_BEGIN(FilterParser)
    14 14  package com.nccgroup.loggerplusplus.filter.parser;
    15  -import com.nccgroup.loggerplusplus.filter.LogicalOperator;
    16  -import com.nccgroup.loggerplusplus.filter.BooleanOperator;
     15 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;import com.nccgroup.loggerplusplus.filter.LogicalOperator;
     16 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;
    17 17  import com.nccgroup.loggerplusplus.filterlibrary.FilterLibraryController;
    18 18  import java.io.StringReader;
    19 19  import java.math.BigDecimal;
    skipped 181 lines
    201 201   boolean jjtc000 = true;
    202 202   jjtree.openNodeScope(jjtn000);
    203 203  /*@egen*/
    204  - BooleanOperator op = BooleanOperator.EQUAL;
     204 + ComparisonOperator op = ComparisonOperator.EQUAL;
    205 205   Object left, right = true;
    206 206  }
    207 207  {/*@bgen(jjtree) Comparison */
    208 208   try {
    209 209  /*@egen*/
    210  - (left = Identifier() | {throw new ParseException("The left side of a comparison must be a field identifier.");})
    211  - 
    212  - (
    213  - op = EqualityOperator() {
    214  - if(((LogEntryField) left).getType().isAssignableFrom(Date.class)){
    215  - right = Date();
    216  - }else{
    217  - try{
    218  - right = Value();
    219  - }catch (Exception e){
    220  - throw new ParseException("Invalid right hand value for comparison \"" + op + "\"");
     210 + (left = Identifier()
     211 + (
     212 + op = EqualityOperator() {
     213 + if(((LogEntryField) left).getType().isAssignableFrom(Date.class)){
     214 + right = Date();
     215 + }else{
     216 + try{
     217 + right = Value();
     218 + }catch (Exception e){
     219 + throw new ParseException("Invalid right hand value for comparison \"" + op + "\"");
     220 + }
    221 221   }
    222  - }
    223 222   
    224  - if(right instanceof Pattern && !String.class.isAssignableFrom(((LogEntryField) left).getType())){
    225  - throw new ParseException(String.format("Regex patterns can only be used on fields which can be converted to a string. Field \"%s\" of type \"%s\" cannot be converted.", left, ((LogEntryField) left).getType()));
    226  - }
    227  - }
    228  - |
    229  - op = NumericOperator()
    230  - {
    231  - if(!Number.class.isAssignableFrom(((LogEntryField) left).getType()) && !Date.class.isAssignableFrom(((LogEntryField) left).getType())){
    232  - throw new ParseException(String.format("Numeric operators cannot be used for field \"%s\" of type \"%s\"", left, ((LogEntryField) left).getType()));
     223 + if(right instanceof Pattern && !String.class.isAssignableFrom(((LogEntryField) left).getType())){
     224 + throw new ParseException(String.format("Regex patterns can only be used on fields which can be converted to a string. Field \"%s\" of type \"%s\" cannot be converted.", left, ((LogEntryField) left).getType()));
     225 + }
    233 226   }
    234  - }
    235  - (
    236  - right = Number()
    237 227   |
    238  - right = Identifier()
     228 + op = NumericOperator()
    239 229   {
    240  - if(!Number.class.isAssignableFrom(((LogEntryField) right).getType())){
    241  - throw new ParseException(String.format("Numeric operators cannot be used for field \"%s\" of type \"%s\"", right, ((LogEntryField) right).getType()));
     230 + if(!Number.class.isAssignableFrom(((LogEntryField) left).getType()) && !Date.class.isAssignableFrom(((LogEntryField) left).getType())){
     231 + throw new ParseException(String.format("Numeric operators cannot be used for field \"%s\" of type \"%s\"", left, ((LogEntryField) left).getType()));
    242 232   }
    243 233   }
     234 + (
     235 + right = Number()
     236 + |
     237 + right = Identifier()
     238 + {
     239 + if(!Number.class.isAssignableFrom(((LogEntryField) right).getType())){
     240 + throw new ParseException(String.format("Numeric operators cannot be used for field \"%s\" of type \"%s\"", right, ((LogEntryField) right).getType()));
     241 + }
     242 + }
     243 + |
     244 + right = Date()
     245 + {
     246 + if(!Date.class.isAssignableFrom(((LogEntryField) left).getType())){
     247 + throw new ParseException(String.format("Value of type Date cannot be compared against field \"%s\" of type \"%s\"", left, ((LogEntryField)left).getType()));
     248 + }
     249 + }
     250 + |
     251 + {throw new ParseException("Invalid right hand value for comparison \"" + op + "\"");}
     252 + )
    244 253   |
    245  - right = Date()
     254 + op = ContainsOperator() (
     255 + right = String()
     256 + |
     257 + right = Number()
     258 + |
     259 + right = Identifier()
     260 + |
     261 + {throw new ParseException("The contains operator can only be used on string and numeric values and identifiers.");}
     262 + )
     263 + 
     264 + |
     265 + op = InOperator() (
     266 + right = Array()
     267 + |
     268 + {throw new ParseException("The in operator must be used on an array. E.g. \"Response.status IN [200, 302, 500]\"");}
     269 + )
     270 + | op = MatchesOperator() (
     271 + right = RegexInString()
     272 + |
     273 + right = RegexInForwardSlashes()
     274 + |
     275 + {throw new ParseException("The matches operator must have a pattern as its right hand value."); }
     276 + )
     277 + | //NO OPERATOR OR RIGHT VALUE Default to EQ TRUE
    246 278   {
    247  - if(!Date.class.isAssignableFrom(((LogEntryField) left).getType())){
    248  - throw new ParseException(String.format("Value of type Date cannot be compared against field \"%s\" of type \"%s\"", left, ((LogEntryField)left).getType()));
     279 + if(!(left instanceof Boolean || (left instanceof LogEntryField && ((LogEntryField) left).getType().isAssignableFrom(Boolean.class)))){
     280 + //If left isn't a boolean value or field with boolean type
     281 + throw new ParseException(left + " cannot be evaluated as a boolean.");
    249 282   }
    250 283   }
    251  - |
    252  - {throw new ParseException("Invalid right hand value for comparison \"" + op + "\"");}
    253 284   )
    254 285   |
    255  - op = ContainsOperator() (
    256  - right = String()
    257  - |
    258  - right = Number()
    259  - |
    260  - right = Identifier()
    261  - |
    262  - {throw new ParseException("The contains operator can only be used on string and numeric values and identifiers.");}
    263  - )
    264  - 
    265  - |
    266  - op = InOperator() (
    267  - right = Array()
    268  - |
    269  - {throw new ParseException("The in operator must be used on an array. E.g. \"Response.status IN [200, 302, 500]\"");}
    270  - )
    271  - | op = MatchesOperator() (
    272  - right = RegexInString()
    273  - |
    274  - right = RegexInForwardSlashes()
    275  - |
    276  - {throw new ParseException("The matches operator must have a pattern as its right hand value."); }
    277  - )
    278  - | //NO OPERATOR OR RIGHT VALUE Default to EQ TRUE
    279  - {
    280  - if(!(left instanceof Boolean || (left instanceof LogEntryField && ((LogEntryField) left).getType().isAssignableFrom(Boolean.class)))){
    281  - //If left isn't a boolean value or field with boolean type
    282  - throw new ParseException(left + " cannot be evaluated as a boolean.");
    283  - }
    284  - }
     286 + (left = String() (op = InOperator() | {throw new ParseException("Only the IN operator is currently supported for arrays.");}) (right = Identifier() | right = Array() ))
    285 287   )/*@bgen(jjtree)*/
    286 288   {
    287 289   jjtree.closeNodeScope(jjtn000, true);
    skipped 2 lines
    290 292  /*@egen*/
    291 293   
    292 294   {
    293  - jjtn000.left = left;
    294  - jjtn000.right = right;
    295  - jjtn000.booleanOperator = op;
    296  - }/*@bgen(jjtree)*/
     295 + jjtn000.left = left;
     296 + jjtn000.right = right;
     297 + jjtn000.comparisonOperator = op;
     298 +}/*@bgen(jjtree)*/
    297 299   } catch (Throwable jjte000) {
    298 300   if (jjtc000) {
    299 301   jjtree.clearNodeScope(jjtn000);
    skipped 226 lines
    526 528   
    527 529  //BASIC OPERATORS
    528 530   
    529  -BooleanOperator EqualityOperator() :
     531 +ComparisonOperator EqualityOperator() :
    530 532  {}
    531 533  {
    532  - <EQ> {return BooleanOperator.EQUAL;}
    533  - | <NEQ> {return BooleanOperator.NOT_EQUAL;}
     534 + <EQ> {return ComparisonOperator.EQUAL;}
     535 + | <NEQ> {return ComparisonOperator.NOT_EQUAL;}
    534 536  }
    535 537   
    536  -BooleanOperator NumericOperator() :
     538 +ComparisonOperator NumericOperator() :
    537 539  {}
    538 540  {
    539  - <GT> {return BooleanOperator.GREATER_THAN;}
    540  - | <LT> {return BooleanOperator.LESS_THAN;}
    541  - | <GEQ> {return BooleanOperator.GREATER_THAN_EQUAL;}
    542  - | <LEQ> {return BooleanOperator.LESS_THAN_EQUAL;}
     541 + <GT> {return ComparisonOperator.GREATER_THAN;}
     542 + | <LT> {return ComparisonOperator.LESS_THAN;}
     543 + | <GEQ> {return ComparisonOperator.GREATER_THAN_EQUAL;}
     544 + | <LEQ> {return ComparisonOperator.LESS_THAN_EQUAL;}
    543 545  }
    544 546   
    545  -BooleanOperator ContainsOperator() :
     547 +ComparisonOperator ContainsOperator() :
    546 548  {}
    547 549  {
    548  - <CONTAINS> {return BooleanOperator.CONTAINS;}
     550 + <CONTAINS> {return ComparisonOperator.CONTAINS;}
    549 551  }
    550 552   
    551  -BooleanOperator MatchesOperator() :
     553 +ComparisonOperator MatchesOperator() :
    552 554  {}
    553 555  {
    554  - <MATCHES> {return BooleanOperator.MATCHES;}
     556 + <MATCHES> {return ComparisonOperator.MATCHES;}
    555 557  }
    556 558   
    557  -BooleanOperator InOperator() :
     559 +ComparisonOperator InOperator() :
    558 560  {}
    559 561  {
    560  - <IN> {return BooleanOperator.IN;}
     562 + <IN> {return ComparisonOperator.IN;}
    561 563  }
    562 564   
    563 565  boolean Inverse() :
    skipped 22 lines
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/Filter.jjt
    skipped 10 lines
    11 11   
    12 12  PARSER_BEGIN(FilterParser)
    13 13  package com.nccgroup.loggerplusplus.filter.parser;
    14  -import com.nccgroup.loggerplusplus.filter.LogicalOperator;
    15  -import com.nccgroup.loggerplusplus.filter.BooleanOperator;
     14 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;import com.nccgroup.loggerplusplus.filter.LogicalOperator;
     15 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;
    16 16  import com.nccgroup.loggerplusplus.filterlibrary.FilterLibraryController;
    17 17  import java.io.StringReader;
    18 18  import java.math.BigDecimal;
    skipped 143 lines
    162 162  //To make interpretation easier, we convert (Value) to (Value operation value) by means of (Value EQUALS TRUE)
    163 163  void Comparison() #Comparison:
    164 164  {
    165  - BooleanOperator op = BooleanOperator.EQUAL;
     165 + ComparisonOperator op = ComparisonOperator.EQUAL;
    166 166   Object left, right = true;
    167 167  }
    168 168  {
    169  - (left = Identifier() | {throw new ParseException("The left side of a comparison must be a field identifier.");})
    170  - 
    171  - (
    172  - op = EqualityOperator() {
    173  - if(((LogEntryField) left).getType().isAssignableFrom(Date.class)){
    174  - right = Date();
    175  - }else{
    176  - try{
    177  - right = Value();
    178  - }catch (Exception e){
    179  - throw new ParseException("Invalid right hand value for comparison \"" + op + "\"");
     169 + (left = Identifier()
     170 + (
     171 + op = EqualityOperator() {
     172 + if(((LogEntryField) left).getType().isAssignableFrom(Date.class)){
     173 + right = Date();
     174 + }else{
     175 + try{
     176 + right = Value();
     177 + }catch (Exception e){
     178 + throw new ParseException("Invalid right hand value for comparison \"" + op + "\"");
     179 + }
    180 180   }
    181  - }
    182 181   
    183  - if(right instanceof Pattern && !String.class.isAssignableFrom(((LogEntryField) left).getType())){
    184  - throw new ParseException(String.format("Regex patterns can only be used on fields which can be converted to a string. Field \"%s\" of type \"%s\" cannot be converted.", left, ((LogEntryField) left).getType()));
    185  - }
    186  - }
    187  - |
    188  - op = NumericOperator()
    189  - {
    190  - if(!Number.class.isAssignableFrom(((LogEntryField) left).getType()) && !Date.class.isAssignableFrom(((LogEntryField) left).getType())){
    191  - throw new ParseException(String.format("Numeric operators cannot be used for field \"%s\" of type \"%s\"", left, ((LogEntryField) left).getType()));
     182 + if(right instanceof Pattern && !String.class.isAssignableFrom(((LogEntryField) left).getType())){
     183 + throw new ParseException(String.format("Regex patterns can only be used on fields which can be converted to a string. Field \"%s\" of type \"%s\" cannot be converted.", left, ((LogEntryField) left).getType()));
     184 + }
    192 185   }
    193  - }
    194  - (
    195  - right = Number()
    196 186   |
    197  - right = Identifier()
     187 + op = NumericOperator()
    198 188   {
    199  - if(!Number.class.isAssignableFrom(((LogEntryField) right).getType())){
    200  - throw new ParseException(String.format("Numeric operators cannot be used for field \"%s\" of type \"%s\"", right, ((LogEntryField) right).getType()));
     189 + if(!Number.class.isAssignableFrom(((LogEntryField) left).getType()) && !Date.class.isAssignableFrom(((LogEntryField) left).getType())){
     190 + throw new ParseException(String.format("Numeric operators cannot be used for field \"%s\" of type \"%s\"", left, ((LogEntryField) left).getType()));
    201 191   }
    202 192   }
     193 + (
     194 + right = Number()
     195 + |
     196 + right = Identifier()
     197 + {
     198 + if(!Number.class.isAssignableFrom(((LogEntryField) right).getType())){
     199 + throw new ParseException(String.format("Numeric operators cannot be used for field \"%s\" of type \"%s\"", right, ((LogEntryField) right).getType()));
     200 + }
     201 + }
     202 + |
     203 + right = Date()
     204 + {
     205 + if(!Date.class.isAssignableFrom(((LogEntryField) left).getType())){
     206 + throw new ParseException(String.format("Value of type Date cannot be compared against field \"%s\" of type \"%s\"", left, ((LogEntryField)left).getType()));
     207 + }
     208 + }
     209 + |
     210 + {throw new ParseException("Invalid right hand value for comparison \"" + op + "\"");}
     211 + )
    203 212   |
    204  - right = Date()
     213 + op = ContainsOperator() (
     214 + right = String()
     215 + |
     216 + right = Number()
     217 + |
     218 + right = Identifier()
     219 + |
     220 + {throw new ParseException("The contains operator can only be used on string and numeric values and identifiers.");}
     221 + )
     222 + 
     223 + |
     224 + op = InOperator() (
     225 + right = Array()
     226 + |
     227 + {throw new ParseException("The in operator must be used on an array. E.g. \"Response.status IN [200, 302, 500]\"");}
     228 + )
     229 + | op = MatchesOperator() (
     230 + right = RegexInString()
     231 + |
     232 + right = RegexInForwardSlashes()
     233 + |
     234 + {throw new ParseException("The matches operator must have a pattern as its right hand value."); }
     235 + )
     236 + | //NO OPERATOR OR RIGHT VALUE Default to EQ TRUE
    205 237   {
    206  - if(!Date.class.isAssignableFrom(((LogEntryField) left).getType())){
    207  - throw new ParseException(String.format("Value of type Date cannot be compared against field \"%s\" of type \"%s\"", left, ((LogEntryField)left).getType()));
     238 + if(!(left instanceof Boolean || (left instanceof LogEntryField && ((LogEntryField) left).getType().isAssignableFrom(Boolean.class)))){
     239 + //If left isn't a boolean value or field with boolean type
     240 + throw new ParseException(left + " cannot be evaluated as a boolean.");
    208 241   }
    209 242   }
    210  - |
    211  - {throw new ParseException("Invalid right hand value for comparison \"" + op + "\"");}
    212 243   )
    213 244   |
    214  - op = ContainsOperator() (
    215  - right = String()
    216  - |
    217  - right = Number()
    218  - |
    219  - right = Identifier()
    220  - |
    221  - {throw new ParseException("The contains operator can only be used on string and numeric values and identifiers.");}
    222  - )
    223  - 
    224  - |
    225  - op = InOperator() (
    226  - right = Array()
    227  - |
    228  - {throw new ParseException("The in operator must be used on an array. E.g. \"Response.status IN [200, 302, 500]\"");}
    229  - )
    230  - | op = MatchesOperator() (
    231  - right = RegexInString()
    232  - |
    233  - right = RegexInForwardSlashes()
    234  - |
    235  - {throw new ParseException("The matches operator must have a pattern as its right hand value."); }
    236  - )
    237  - | //NO OPERATOR OR RIGHT VALUE Default to EQ TRUE
    238  - {
    239  - if(!(left instanceof Boolean || (left instanceof LogEntryField && ((LogEntryField) left).getType().isAssignableFrom(Boolean.class)))){
    240  - //If left isn't a boolean value or field with boolean type
    241  - throw new ParseException(left + " cannot be evaluated as a boolean.");
    242  - }
    243  - }
     245 + (left = String() (op = InOperator() | {throw new ParseException("Only the IN operator is currently supported for arrays.");}) (right = Identifier() | right = Array() ))
    244 246   )
    245 247   
    246 248   {
    247  - jjtThis.left = left;
    248  - jjtThis.right = right;
    249  - jjtThis.booleanOperator = op;
    250  - }
     249 + jjtThis.left = left;
     250 + jjtThis.right = right;
     251 + jjtThis.comparisonOperator = op;
     252 +}
    251 253  }
    252 254   
    253 255  void Alias() #Alias:
    skipped 189 lines
    443 445   
    444 446  //BASIC OPERATORS
    445 447   
    446  -BooleanOperator EqualityOperator() #void :
     448 +ComparisonOperator EqualityOperator() #void :
    447 449  {}
    448 450  {
    449  - <EQ> {return BooleanOperator.EQUAL;}
    450  - | <NEQ> {return BooleanOperator.NOT_EQUAL;}
     451 + <EQ> {return ComparisonOperator.EQUAL;}
     452 + | <NEQ> {return ComparisonOperator.NOT_EQUAL;}
    451 453  }
    452 454   
    453  -BooleanOperator NumericOperator() #void :
     455 +ComparisonOperator NumericOperator() #void :
    454 456  {}
    455 457  {
    456  - <GT> {return BooleanOperator.GREATER_THAN;}
    457  - | <LT> {return BooleanOperator.LESS_THAN;}
    458  - | <GEQ> {return BooleanOperator.GREATER_THAN_EQUAL;}
    459  - | <LEQ> {return BooleanOperator.LESS_THAN_EQUAL;}
     458 + <GT> {return ComparisonOperator.GREATER_THAN;}
     459 + | <LT> {return ComparisonOperator.LESS_THAN;}
     460 + | <GEQ> {return ComparisonOperator.GREATER_THAN_EQUAL;}
     461 + | <LEQ> {return ComparisonOperator.LESS_THAN_EQUAL;}
    460 462  }
    461 463   
    462  -BooleanOperator ContainsOperator() #void :
     464 +ComparisonOperator ContainsOperator() #void :
    463 465  {}
    464 466  {
    465  - <CONTAINS> {return BooleanOperator.CONTAINS;}
     467 + <CONTAINS> {return ComparisonOperator.CONTAINS;}
    466 468  }
    467 469   
    468  -BooleanOperator MatchesOperator() #void :
     470 +ComparisonOperator MatchesOperator() #void :
    469 471  {}
    470 472  {
    471  - <MATCHES> {return BooleanOperator.MATCHES;}
     473 + <MATCHES> {return ComparisonOperator.MATCHES;}
    472 474  }
    473 475   
    474  -BooleanOperator InOperator() #void :
     476 +ComparisonOperator InOperator() #void :
    475 477  {}
    476 478  {
    477  - <IN> {return BooleanOperator.IN;}
     479 + <IN> {return ComparisonOperator.IN;}
    478 480  }
    479 481   
    480 482  boolean Inverse() #void :
    skipped 22 lines
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/FilterEvaluationVisitor.java
    1 1  /* Generated By:JavaCC: Do not edit this line. FilterParserDefaultVisitor.java Version 7.0.2 */
    2 2  package com.nccgroup.loggerplusplus.filter.parser;
    3 3   
     4 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;
     5 +import com.nccgroup.loggerplusplus.filter.LogicalOperator;
    4 6  import com.nccgroup.loggerplusplus.filter.savedfilter.SavedFilter;
    5 7  import com.nccgroup.loggerplusplus.filterlibrary.FilterLibraryController;
    6 8  import com.nccgroup.loggerplusplus.logentry.LogEntry;
    7 9  import com.nccgroup.loggerplusplus.logentry.LogEntryField;
    8  -import com.nccgroup.loggerplusplus.filter.LogicalOperator;
    9  -import com.nccgroup.loggerplusplus.filter.BooleanOperator;
    10 10  import org.apache.commons.lang3.time.DateUtils;
    11 11   
    12 12  import java.math.BigDecimal;
    13 13  import java.util.Calendar;
     14 +import java.util.Collection;
    14 15  import java.util.Date;
    15  -import java.util.Set;
    16 16  import java.util.regex.Matcher;
    17 17  import java.util.regex.Pattern;
    18 18   
    skipped 60 lines
    79 79   left = node.left instanceof LogEntryField ? getValueForField(visitorData, (LogEntryField) node.left) : node.left;
    80 80   right = node.right instanceof LogEntryField ? getValueForField(visitorData, (LogEntryField) node.right) : node.right;
    81 81   
    82  - return compare(node.booleanOperator, left, right);
     82 + return compare(node.comparisonOperator, left, right);
    83 83   }
    84 84   
    85 85   private Object getValueForField(VisitorData visitorData, LogEntryField field){
    skipped 20 lines
    106 106   }
    107 107   }
    108 108   
    109  - private boolean compare(BooleanOperator op, Object left, Object right){
    110  - if(left == null) left = "";
    111  - if(right == null) right = "";
    112  - try{
    113  - if(Number.class.isAssignableFrom(left.getClass()) && Number.class.isAssignableFrom(right.getClass())) {
     109 + private boolean compare(ComparisonOperator op, Object left, Object right) {
     110 + if (left == null) left = "";
     111 + if (right == null) right = "";
     112 + try {
     113 + if (Number.class.isAssignableFrom(left.getClass()) && Number.class.isAssignableFrom(right.getClass())) {
    114 114   //Numerical Comparison
    115 115   BigDecimal leftBigDecimal = new BigDecimal(String.valueOf(left));
    116 116   BigDecimal rightBigDecimal = new BigDecimal(String.valueOf(right));
    skipped 11 lines
    128 128   case LESS_THAN_EQUAL:
    129 129   return leftBigDecimal.compareTo(rightBigDecimal) <= 0;
    130 130   }
    131  - }else if(op == BooleanOperator.MATCHES){
     131 + } else if (op == ComparisonOperator.MATCHES) {
    132 132   Matcher m = ((Pattern) right).matcher(String.valueOf(left));
    133 133   return m.matches();
    134  - }else if(right instanceof Pattern) {
     134 + } else if (right instanceof Pattern) {
    135 135   Matcher m = ((Pattern) right).matcher(String.valueOf(left));
    136  - return m.find() ^ op == BooleanOperator.NOT_EQUAL;
    137  - }else if (left instanceof Date) {
     136 + return m.find() ^ op == ComparisonOperator.NOT_EQUAL;
     137 + } else if (left instanceof Date) {
    138 138   try {
    139 139   Date rightDate = DateUtils.truncate(right, Calendar.SECOND);
    140  - switch (op){
    141  - case EQUAL: return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) == 0;
    142  - case NOT_EQUAL: return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) != 0;
    143  - case GREATER_THAN: return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) > 0;
    144  - case LESS_THAN: return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) < 0;
    145  - case GREATER_THAN_EQUAL: return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) >= 0;
    146  - case LESS_THAN_EQUAL: return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) <= 0;
     140 + switch (op) {
     141 + case EQUAL:
     142 + return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) == 0;
     143 + case NOT_EQUAL:
     144 + return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) != 0;
     145 + case GREATER_THAN:
     146 + return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) > 0;
     147 + case LESS_THAN:
     148 + return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) < 0;
     149 + case GREATER_THAN_EQUAL:
     150 + return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) >= 0;
     151 + case LESS_THAN_EQUAL:
     152 + return DateUtils.truncate((Date) left, Calendar.SECOND).compareTo(rightDate) <= 0;
    147 153   }
    148  - }catch (Exception e){
     154 + } catch (Exception e) {
    149 155   return false;
    150 156   }
    151  - }else if(op == BooleanOperator.IN){
    152  - if(!(right instanceof Set)) return false;
    153  - String leftString = String.valueOf(left);
    154  - for (Object item : ((Set) right)) {
    155  - if(leftString.equalsIgnoreCase(String.valueOf(item))) return true;
    156  - }
    157  - return false;
    158  - }else if(left instanceof String || right instanceof String){ //String comparison last.
    159  - switch (op){
    160  - case EQUAL: return String.valueOf(left).equalsIgnoreCase(String.valueOf(right));
    161  - case NOT_EQUAL: return !String.valueOf(left).equalsIgnoreCase(String.valueOf(right));
    162  - case CONTAINS: return (String.valueOf(left).toLowerCase()).contains(String.valueOf(right).toLowerCase());
     157 + } else if (op == ComparisonOperator.IN) {
     158 + //Request.Host IN ["https://twitter.com", "https://google.com"]
     159 + String leftString = String.valueOf(left);
     160 + for (Object item : (Collection) right) {
     161 + if (leftString.equalsIgnoreCase(String.valueOf(item))) return true;
    163 162   }
    164  - }else{
    165  - switch (op){
    166  - case EQUAL: return left.equals(right);
    167  - case NOT_EQUAL: return !left.equals(right);
     163 + return false;
     164 + } else if (op == ComparisonOperator.CONTAINS && Collection.class.isAssignableFrom(left.getClass())) {
     165 + //Request.Parameters CONTAINS "A"
     166 + Object finalRight = right;
     167 + return ((Collection) left).stream().anyMatch(o -> String.valueOf(o).equalsIgnoreCase(String.valueOf(finalRight)));
     168 + } else if (left instanceof String || right instanceof String) { //String comparison last.
     169 + switch (op) {
     170 + case EQUAL:
     171 + return String.valueOf(left).equalsIgnoreCase(String.valueOf(right));
     172 + case NOT_EQUAL:
     173 + return !String.valueOf(left).equalsIgnoreCase(String.valueOf(right));
     174 + case CONTAINS:
     175 + return (String.valueOf(left).toLowerCase()).contains(String.valueOf(right).toLowerCase());
     176 + }
     177 + } else {
     178 + switch (op) {
     179 + case EQUAL:
     180 + return left.equals(right);
     181 + case NOT_EQUAL:
     182 + return !left.equals(right);
    168 183   }
    169 184   }
    170 185   
    skipped 10 lines
  • src/main/java/com/nccgroup/loggerplusplus/filter/parser/FilterParser.java
    Diff is too large to be displayed.
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/FilterParserTokenManager.java
    1  -/* FilterParserTokenManager.java */
    2 1  /* Generated By:JJTree&JavaCC: Do not edit this line. FilterParserTokenManager.java */
    3 2  package com.nccgroup.loggerplusplus.filter.parser;
    4  -import com.nccgroup.loggerplusplus.filter.LogicalOperator;
    5  -import com.nccgroup.loggerplusplus.filter.BooleanOperator;
    6  -import com.nccgroup.loggerplusplus.filterlibrary.FilterLibraryController;
    7  -import java.io.StringReader;
    8  -import java.math.BigDecimal;
    9  -import java.util.Arrays;
    10  -import java.util.LinkedHashSet;
    11  -import java.util.Set;
    12  -import java.util.Date;
    13  -import java.util.ArrayList;
    14  -import java.util.regex.Pattern;
    15  -import com.nccgroup.loggerplusplus.logentry.LogEntryField;
    16  -import com.nccgroup.loggerplusplus.logentry.FieldGroup;
    17  -import static com.nccgroup.loggerplusplus.logentry.LogEntryField.getFieldsInGroup;
    18  -import com.nccgroup.loggerplusplus.logview.processor.LogProcessor;
    19 3   
    20  -/** Token Manager. */
     4 +/**
     5 + * Token Manager.
     6 + */
    21 7  public class FilterParserTokenManager implements FilterParserConstants {
    22 8   
    23  - /** Debug output. */
    24  - public java.io.PrintStream debugStream = System.out;
    25  - /** Set debug output. */
    26  - public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
    27  -private int jjStopAtPos(int pos, int kind)
    28  -{
    29  - jjmatchedKind = kind;
    30  - jjmatchedPos = pos;
    31  - return pos + 1;
    32  -}
    33  -private int jjMoveStringLiteralDfa0_0(){
    34  - switch(curChar)
    35  - {
    36  - case 32:
    37  - jjmatchedKind = 1;
    38  - return jjMoveNfa_0(0, 0);
    39  - case 33:
    40  - return jjMoveStringLiteralDfa1_0(0x8L);
    41  - case 34:
    42  - jjmatchedKind = 29;
    43  - return jjMoveNfa_0(0, 0);
     9 + /** Debug output. */
     10 + public java.io.PrintStream debugStream = System.out;
     11 + 
     12 + /** Set debug output. */
     13 + public void setDebugStream(java.io.PrintStream ds) {
     14 + debugStream = ds;
     15 + }
     16 + 
     17 + private int jjStopAtPos(int pos, int kind) {
     18 + jjmatchedKind = kind;
     19 + jjmatchedPos = pos;
     20 + return pos + 1;
     21 + }
     22 + 
     23 + private int jjMoveStringLiteralDfa0_0() {
     24 + switch (curChar) {
     25 + case 32:
     26 + jjmatchedKind = 1;
     27 + return jjMoveNfa_0(0, 0);
     28 + case 33:
     29 + return jjMoveStringLiteralDfa1_0(0x8L);
     30 + case 34:
     31 + jjmatchedKind = 29;
     32 + return jjMoveNfa_0(0, 0);
    44 33   case 35:
    45 34   jjmatchedKind = 27;
    46 35   return jjMoveNfa_0(0, 0);
    skipped 30 lines
    77 66   case 93:
    78 67   jjmatchedKind = 25;
    79 68   return jjMoveNfa_0(0, 0);
    80  - case 99:
    81  - return jjMoveStringLiteralDfa1_0(0x800L);
    82  - case 105:
    83  - return jjMoveStringLiteralDfa1_0(0x1000L);
    84  - case 109:
    85  - return jjMoveStringLiteralDfa1_0(0x40000L);
    86  - default :
    87  - return jjMoveNfa_0(0, 0);
    88  - }
    89  -}
    90  -private int jjMoveStringLiteralDfa1_0(long active0){
    91  - try { curChar = input_stream.readChar(); }
    92  - catch(java.io.IOException e) {
    93  - return jjMoveNfa_0(0, 0);
     69 + case 99:
     70 + return jjMoveStringLiteralDfa1_0(0x800L);
     71 + case 105:
     72 + return jjMoveStringLiteralDfa1_0(0x1000L);
     73 + case 109:
     74 + return jjMoveStringLiteralDfa1_0(0x40000L);
     75 + default:
     76 + return jjMoveNfa_0(0, 0);
     77 + }
    94 78   }
    95  - switch(curChar)
    96  - {
    97  - case 61:
    98  - if ((active0 & 0x8L) != 0L)
    99  - {
    100  - jjmatchedKind = 3;
     79 + 
     80 + private int jjMoveStringLiteralDfa1_0(long active0) {
     81 + try {
     82 + curChar = input_stream.readChar();
     83 + } catch (java.io.IOException e) {
     84 + return jjMoveNfa_0(0, 0);
     85 + }
     86 + switch (curChar) {
     87 + case 61:
     88 + if ((active0 & 0x8L) != 0L) {
     89 + jjmatchedKind = 3;
    101 90   jjmatchedPos = 1;
    102 91   }
    103 92   else if ((active0 & 0x40L) != 0L)
    skipped 27 lines
    131 120   jjmatchedPos = 1;
    132 121   }
    133 122   break;
    134  - case 111:
    135  - return jjMoveStringLiteralDfa2_0(active0, 0x800L);
    136  - default :
    137  - break;
    138  - }
    139  - return jjMoveNfa_0(0, 1);
    140  -}
    141  -private int jjMoveStringLiteralDfa2_0(long old0, long active0){
    142  - if (((active0 &= old0)) == 0L)
     123 + case 111:
     124 + return jjMoveStringLiteralDfa2_0(active0, 0x800L);
     125 + default:
     126 + break;
     127 + }
    143 128   return jjMoveNfa_0(0, 1);
    144  - try { curChar = input_stream.readChar(); }
    145  - catch(java.io.IOException e) {
    146  - return jjMoveNfa_0(0, 1);
    147 129   }
    148  - switch(curChar)
    149  - {
    150  - case 78:
    151  - return jjMoveStringLiteralDfa3_0(active0, 0x800L);
     130 + 
     131 + private int jjMoveStringLiteralDfa2_0(long old0, long active0) {
     132 + if (((active0 &= old0)) == 0L)
     133 + return jjMoveNfa_0(0, 1);
     134 + try {
     135 + curChar = input_stream.readChar();
     136 + } catch (java.io.IOException e) {
     137 + return jjMoveNfa_0(0, 1);
     138 + }
     139 + switch (curChar) {
     140 + case 78:
     141 + return jjMoveStringLiteralDfa3_0(active0, 0x800L);
    152 142   case 84:
    153 143   return jjMoveStringLiteralDfa3_0(active0, 0x40000L);
    154  - case 110:
    155  - return jjMoveStringLiteralDfa3_0(active0, 0x800L);
    156  - case 116:
    157  - return jjMoveStringLiteralDfa3_0(active0, 0x40000L);
    158  - default :
    159  - break;
    160  - }
    161  - return jjMoveNfa_0(0, 2);
    162  -}
    163  -private int jjMoveStringLiteralDfa3_0(long old0, long active0){
    164  - if (((active0 &= old0)) == 0L)
     144 + case 110:
     145 + return jjMoveStringLiteralDfa3_0(active0, 0x800L);
     146 + case 116:
     147 + return jjMoveStringLiteralDfa3_0(active0, 0x40000L);
     148 + default:
     149 + break;
     150 + }
    165 151   return jjMoveNfa_0(0, 2);
    166  - try { curChar = input_stream.readChar(); }
    167  - catch(java.io.IOException e) {
    168  - return jjMoveNfa_0(0, 2);
    169 152   }
    170  - switch(curChar)
    171  - {
    172  - case 67:
    173  - return jjMoveStringLiteralDfa4_0(active0, 0x40000L);
     153 + 
     154 + private int jjMoveStringLiteralDfa3_0(long old0, long active0) {
     155 + if (((active0 &= old0)) == 0L)
     156 + return jjMoveNfa_0(0, 2);
     157 + try {
     158 + curChar = input_stream.readChar();
     159 + } catch (java.io.IOException e) {
     160 + return jjMoveNfa_0(0, 2);
     161 + }
     162 + switch (curChar) {
     163 + case 67:
     164 + return jjMoveStringLiteralDfa4_0(active0, 0x40000L);
    174 165   case 84:
    175 166   return jjMoveStringLiteralDfa4_0(active0, 0x800L);
    176  - case 99:
    177  - return jjMoveStringLiteralDfa4_0(active0, 0x40000L);
    178  - case 116:
    179  - return jjMoveStringLiteralDfa4_0(active0, 0x800L);
    180  - default :
    181  - break;
    182  - }
    183  - return jjMoveNfa_0(0, 3);
    184  -}
    185  -private int jjMoveStringLiteralDfa4_0(long old0, long active0){
    186  - if (((active0 &= old0)) == 0L)
     167 + case 99:
     168 + return jjMoveStringLiteralDfa4_0(active0, 0x40000L);
     169 + case 116:
     170 + return jjMoveStringLiteralDfa4_0(active0, 0x800L);
     171 + default:
     172 + break;
     173 + }
    187 174   return jjMoveNfa_0(0, 3);
    188  - try { curChar = input_stream.readChar(); }
    189  - catch(java.io.IOException e) {
    190  - return jjMoveNfa_0(0, 3);
    191 175   }
    192  - switch(curChar)
    193  - {
    194  - case 65:
    195  - return jjMoveStringLiteralDfa5_0(active0, 0x800L);
     176 + 
     177 + private int jjMoveStringLiteralDfa4_0(long old0, long active0) {
     178 + if (((active0 &= old0)) == 0L)
     179 + return jjMoveNfa_0(0, 3);
     180 + try {
     181 + curChar = input_stream.readChar();
     182 + } catch (java.io.IOException e) {
     183 + return jjMoveNfa_0(0, 3);
     184 + }
     185 + switch (curChar) {
     186 + case 65:
     187 + return jjMoveStringLiteralDfa5_0(active0, 0x800L);
    196 188   case 72:
    197 189   return jjMoveStringLiteralDfa5_0(active0, 0x40000L);
    198  - case 97:
    199  - return jjMoveStringLiteralDfa5_0(active0, 0x800L);
    200  - case 104:
    201  - return jjMoveStringLiteralDfa5_0(active0, 0x40000L);
    202  - default :
    203  - break;
    204  - }
    205  - return jjMoveNfa_0(0, 4);
    206  -}
    207  -private int jjMoveStringLiteralDfa5_0(long old0, long active0){
    208  - if (((active0 &= old0)) == 0L)
     190 + case 97:
     191 + return jjMoveStringLiteralDfa5_0(active0, 0x800L);
     192 + case 104:
     193 + return jjMoveStringLiteralDfa5_0(active0, 0x40000L);
     194 + default:
     195 + break;
     196 + }
    209 197   return jjMoveNfa_0(0, 4);
    210  - try { curChar = input_stream.readChar(); }
    211  - catch(java.io.IOException e) {
    212  - return jjMoveNfa_0(0, 4);
    213 198   }
    214  - switch(curChar)
    215  - {
    216  - case 69:
    217  - return jjMoveStringLiteralDfa6_0(active0, 0x40000L);
     199 + 
     200 + private int jjMoveStringLiteralDfa5_0(long old0, long active0) {
     201 + if (((active0 &= old0)) == 0L)
     202 + return jjMoveNfa_0(0, 4);
     203 + try {
     204 + curChar = input_stream.readChar();
     205 + } catch (java.io.IOException e) {
     206 + return jjMoveNfa_0(0, 4);
     207 + }
     208 + switch (curChar) {
     209 + case 69:
     210 + return jjMoveStringLiteralDfa6_0(active0, 0x40000L);
    218 211   case 73:
    219 212   return jjMoveStringLiteralDfa6_0(active0, 0x800L);
    220  - case 101:
    221  - return jjMoveStringLiteralDfa6_0(active0, 0x40000L);
    222  - case 105:
    223  - return jjMoveStringLiteralDfa6_0(active0, 0x800L);
    224  - default :
    225  - break;
    226  - }
    227  - return jjMoveNfa_0(0, 5);
    228  -}
    229  -private int jjMoveStringLiteralDfa6_0(long old0, long active0){
    230  - if (((active0 &= old0)) == 0L)
     213 + case 101:
     214 + return jjMoveStringLiteralDfa6_0(active0, 0x40000L);
     215 + case 105:
     216 + return jjMoveStringLiteralDfa6_0(active0, 0x800L);
     217 + default:
     218 + break;
     219 + }
    231 220   return jjMoveNfa_0(0, 5);
    232  - try { curChar = input_stream.readChar(); }
    233  - catch(java.io.IOException e) {
    234  - return jjMoveNfa_0(0, 5);
    235 221   }
    236  - switch(curChar)
    237  - {
    238  - case 78:
    239  - return jjMoveStringLiteralDfa7_0(active0, 0x800L);
     222 + 
     223 + private int jjMoveStringLiteralDfa6_0(long old0, long active0) {
     224 + if (((active0 &= old0)) == 0L)
     225 + return jjMoveNfa_0(0, 5);
     226 + try {
     227 + curChar = input_stream.readChar();
     228 + } catch (java.io.IOException e) {
     229 + return jjMoveNfa_0(0, 5);
     230 + }
     231 + switch (curChar) {
     232 + case 78:
     233 + return jjMoveStringLiteralDfa7_0(active0, 0x800L);
    240 234   case 83:
    241 235   if ((active0 & 0x40000L) != 0L)
    242 236   {
    skipped 4 lines
    247 241   case 110:
    248 242   return jjMoveStringLiteralDfa7_0(active0, 0x800L);
    249 243   case 115:
    250  - if ((active0 & 0x40000L) != 0L)
    251  - {
     244 + if ((active0 & 0x40000L) != 0L) {
    252 245   jjmatchedKind = 18;
    253 246   jjmatchedPos = 6;
    254 247   }
    255 248   break;
    256  - default :
    257  - break;
    258  - }
    259  - return jjMoveNfa_0(0, 6);
    260  -}
    261  -private int jjMoveStringLiteralDfa7_0(long old0, long active0){
    262  - if (((active0 &= old0)) == 0L)
     249 + default:
     250 + break;
     251 + }
    263 252   return jjMoveNfa_0(0, 6);
    264  - try { curChar = input_stream.readChar(); }
    265  - catch(java.io.IOException e) {
    266  - return jjMoveNfa_0(0, 6);
    267 253   }
    268  - switch(curChar)
    269  - {
    270  - case 83:
    271  - if ((active0 & 0x800L) != 0L)
     254 + 
     255 + private int jjMoveStringLiteralDfa7_0(long old0, long active0) {
     256 + if (((active0 &= old0)) == 0L)
     257 + return jjMoveNfa_0(0, 6);
     258 + try {
     259 + curChar = input_stream.readChar();
     260 + } catch (java.io.IOException e) {
     261 + return jjMoveNfa_0(0, 6);
     262 + }
     263 + switch (curChar) {
     264 + case 83:
     265 + if ((active0 & 0x800L) != 0L)
    272 266   {
    273 267   jjmatchedKind = 11;
    274 268   jjmatchedPos = 7;
    skipped 47 lines
    322 316   {
    323 317   if (kind > 14)
    324 318   kind = 14;
    325  - { jjCheckNAddTwoStates(27, 28); }
     319 + jjCheckNAddTwoStates(27, 28);
    326 320   }
    327 321   else if ((0x280000000000L & l) != 0L)
    328  - { jjCheckNAdd(27); }
     322 + jjCheckNAdd(27);
    329 323   else if (curChar == 33)
    330 324   {
    331 325   if (kind > 21)
    332 326   kind = 21;
    333 327   }
    334 328   else if (curChar == 47)
    335  - { jjCheckNAddTwoStates(40, 42); }
     329 + jjCheckNAddTwoStates(40, 42);
    336 330   else if (curChar == 38)
    337 331   jjstateSet[jjnewStateCnt++] = 9;
    338 332   else if (curChar == 61)
    skipped 2 lines
    341 335   {
    342 336   if (kind > 23)
    343 337   kind = 23;
    344  - { jjCheckNAdd(48); }
     338 + jjCheckNAdd(48);
    345 339   }
    346 340   else if (curChar == 47)
    347 341   jjstateSet[jjnewStateCnt++] = 37;
    skipped 27 lines
    375 369   break;
    376 370   case 26:
    377 371   if ((0x280000000000L & l) != 0L)
    378  - { jjCheckNAdd(27); }
     372 + jjCheckNAdd(27);
    379 373   break;
    380 374   case 27:
    381 375   if ((0x3ff000000000000L & l) == 0L)
    382 376   break;
    383 377   if (kind > 14)
    384 378   kind = 14;
    385  - { jjCheckNAddTwoStates(27, 28); }
     379 + jjCheckNAddTwoStates(27, 28);
    386 380   break;
    387 381   case 28:
    388 382   if (curChar == 46)
    389  - { jjCheckNAdd(29); }
     383 + jjCheckNAdd(29);
    390 384   break;
    391 385   case 29:
    392 386   if ((0x3ff000000000000L & l) == 0L)
    393 387   break;
    394 388   if (kind > 14)
    395 389   kind = 14;
    396  - { jjCheckNAdd(29); }
     390 + jjCheckNAdd(29);
    397 391   break;
    398 392   case 32:
    399 393   case 33:
    400  - { jjCheckNAddStates(0, 2); }
     394 + jjCheckNAddStates(0, 2);
    401 395   break;
    402 396   case 34:
    403 397   if (curChar == 47 && kind > 16)
    skipped 5 lines
    409 403   break;
    410 404   case 39:
    411 405   if (curChar == 47)
    412  - { jjCheckNAddTwoStates(40, 42); }
     406 + jjCheckNAddTwoStates(40, 42);
    413 407   break;
    414 408   case 41:
    415  - { jjCheckNAddStates(3, 5); }
     409 + jjCheckNAddStates(3, 5);
    416 410   break;
    417 411   case 42:
    418 412   if ((0xffff7fffffffffffL & l) != 0L)
    419  - { jjCheckNAddStates(3, 5); }
     413 + jjCheckNAddStates(3, 5);
    420 414   break;
    421 415   case 43:
    422 416   if (curChar == 47 && kind > 17)
    skipped 8 lines
    431 425   break;
    432 426   if (kind > 23)
    433 427   kind = 23;
    434  - { jjCheckNAdd(48); }
     428 + jjCheckNAdd(48);
    435 429   break;
    436 430   default : break;
    437 431   }
    skipped 11 lines
    449 443   {
    450 444   if (kind > 23)
    451 445   kind = 23;
    452  - { jjCheckNAdd(48); }
     446 + jjCheckNAdd(48);
    453 447   }
    454 448   else if (curChar == 94)
    455 449   {
    skipped 71 lines
    527 521   break;
    528 522   case 19:
    529 523   if ((0x20000000200000L & l) != 0L)
    530  - { jjCheckNAdd(18); }
     524 + jjCheckNAdd(18);
    531 525   break;
    532 526   case 20:
    533 527   if ((0x4000000040000L & l) != 0L)
    skipped 5 lines
    539 533   break;
    540 534   case 22:
    541 535   if ((0x8000000080000L & l) != 0L)
    542  - { jjCheckNAdd(18); }
     536 + jjCheckNAdd(18);
    543 537   break;
    544 538   case 23:
    545 539   if ((0x100000001000L & l) != 0L)
    skipped 9 lines
    555 549   break;
    556 550   case 30:
    557 551   if ((0x2000000020000L & l) != 0L)
    558  - { jjCheckNAddStates(0, 2); }
     552 + jjCheckNAddStates(0, 2);
    559 553   break;
    560 554   case 31:
    561 555   if (curChar == 92)
    skipped 1 lines
    563 557   break;
    564 558   case 32:
    565 559   if ((0xffffffdfffffffdfL & l) != 0L)
    566  - { jjCheckNAddStates(0, 2); }
     560 + jjCheckNAddStates(0, 2);
    567 561   break;
    568 562   case 33:
    569 563   if ((0xffffffffefffffffL & l) != 0L)
    570  - { jjCheckNAddStates(0, 2); }
     564 + jjCheckNAddStates(0, 2);
    571 565   break;
    572 566   case 35:
    573 567   if ((0x2000000020L & l) != 0L)
    skipped 12 lines
    586 580   jjstateSet[jjnewStateCnt++] = 41;
    587 581   break;
    588 582   case 41:
    589  - { jjCheckNAddStates(3, 5); }
     583 + jjCheckNAddStates(3, 5);
    590 584   break;
    591 585   case 42:
    592 586   if ((0xffffffffefffffffL & l) != 0L)
    593  - { jjCheckNAddStates(3, 5); }
     587 + jjCheckNAddStates(3, 5);
    594 588   break;
    595 589   case 45:
    596 590   if ((0x10000000100000L & l) != 0L && kind > 21)
    skipped 12 lines
    609 603   break;
    610 604   if (kind > 23)
    611 605   kind = 23;
    612  - { jjCheckNAdd(48); }
     606 + jjCheckNAdd(48);
    613 607   break;
    614 608   default : break;
    615 609   }
    skipped 1 lines
    617 611   }
    618 612   else
    619 613   {
    620  - int hiByte = (curChar >> 8);
     614 + int hiByte = (int) (curChar >> 8);
    621 615   int i1 = hiByte >> 6;
    622 616   long l1 = 1L << (hiByte & 077);
    623 617   int i2 = (curChar & 0xff) >> 6;
    624 618   long l2 = 1L << (curChar & 077);
    625 619   do
    626 620   {
    627  - switch(jjstateSet[--i])
    628  - {
     621 + switch(jjstateSet[--i]) {
    629 622   case 32:
    630 623   case 33:
    631 624   if (jjCanMove_0(hiByte, i1, i2, l1, l2))
    632  - { jjCheckNAddStates(0, 2); }
     625 + jjCheckNAddStates(0, 2);
    633 626   break;
    634 627   case 41:
    635 628   case 42:
    636 629   if (jjCanMove_0(hiByte, i1, i2, l1, l2))
    637  - { jjCheckNAddStates(3, 5); }
     630 + jjCheckNAddStates(3, 5);
    638 631   break;
    639  - default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
     632 + default:
     633 + break;
    640 634   }
    641 635   } while(i != startsAt);
    642 636   }
    skipped 17 lines
    660 654   if (curPos < toRet)
    661 655   for (i = toRet - Math.min(curPos, seenUpto); i-- > 0; )
    662 656   try { curChar = input_stream.readChar(); }
    663  - catch(java.io.IOException e) { throw new Error("Internal Error : Please send a bug report."); }
     657 + catch(java.io.IOException e) { throw new Error("Internal Error : Please send a bug report.");
     658 + }
    664 659   
    665  - if (jjmatchedPos < strPos)
    666  - {
     660 + if (jjmatchedPos < strPos) {
    667 661   jjmatchedKind = strKind;
    668 662   jjmatchedPos = strPos;
    669  - }
    670  - else if (jjmatchedPos == strPos && jjmatchedKind > strKind)
     663 + } else if (jjmatchedPos == strPos && jjmatchedKind > strKind)
    671 664   jjmatchedKind = strKind;
    672 665   
    673 666   return toRet;
    674 667  }
    675  -private final int jjStopStringLiteralDfa_1(int pos, long active0){
    676  - switch (pos)
    677  - {
    678  - default :
    679  - return -1;
     668 + 
     669 + private final int jjStopStringLiteralDfa_1(int pos, long active0) {
     670 + switch (pos) {
     671 + default:
     672 + return -1;
     673 + }
     674 + }
     675 + 
     676 + private final int jjStartNfa_1(int pos, long active0) {
     677 + return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
    680 678   }
    681  -}
    682  -private final int jjStartNfa_1(int pos, long active0){
    683  - return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
    684  -}
    685  -private int jjMoveStringLiteralDfa0_1(){
    686  - switch(curChar)
    687  - {
    688  - case 39:
    689  - return jjStopAtPos(0, 31);
    690  - default :
    691  - return jjMoveNfa_1(3, 0);
     679 + 
     680 + private int jjMoveStringLiteralDfa0_1() {
     681 + switch (curChar) {
     682 + case 39:
     683 + return jjStopAtPos(0, 31);
     684 + default:
     685 + return jjMoveNfa_1(3, 0);
     686 + }
    692 687   }
    693  -}
    694  -private int jjMoveNfa_1(int startState, int curPos)
     688 + 
     689 + private int jjMoveNfa_1(int startState, int curPos)
    695 690  {
    696 691   int startsAt = 0;
    697 692   jjnewStateCnt = 3;
    skipped 17 lines
    715 710   break;
    716 711   if (kind > 30)
    717 712   kind = 30;
    718  - { jjCheckNAddTwoStates(0, 2); }
     713 + jjCheckNAddTwoStates(0, 2);
    719 714   break;
    720 715   case 1:
    721 716   if (kind > 30)
    722 717   kind = 30;
    723  - { jjCheckNAddTwoStates(0, 2); }
     718 + jjCheckNAddTwoStates(0, 2);
    724 719   break;
    725 720   default : break;
    726 721   }
    skipped 11 lines
    738 733   {
    739 734   if (kind > 30)
    740 735   kind = 30;
    741  - { jjCheckNAddTwoStates(0, 2); }
     736 + jjCheckNAddTwoStates(0, 2);
    742 737   }
    743 738   else if (curChar == 92)
    744 739   jjstateSet[jjnewStateCnt++] = 1;
    skipped 5 lines
    750 745   case 1:
    751 746   if (kind > 30)
    752 747   kind = 30;
    753  - { jjCheckNAddTwoStates(0, 2); }
     748 + jjCheckNAddTwoStates(0, 2);
    754 749   break;
    755 750   case 2:
    756 751   if ((0xffffffffefffffffL & l) == 0L)
    757 752   break;
    758 753   if (kind > 30)
    759 754   kind = 30;
    760  - { jjCheckNAddTwoStates(0, 2); }
     755 + jjCheckNAddTwoStates(0, 2);
    761 756   break;
    762 757   default : break;
    763 758   }
    skipped 1 lines
    765 760   }
    766 761   else
    767 762   {
    768  - int hiByte = (curChar >> 8);
     763 + int hiByte = (int) (curChar >> 8);
    769 764   int i1 = hiByte >> 6;
    770 765   long l1 = 1L << (hiByte & 077);
    771 766   int i2 = (curChar & 0xff) >> 6;
    772 767   long l2 = 1L << (curChar & 077);
    773 768   do
    774 769   {
    775  - switch(jjstateSet[--i])
    776  - {
     770 + switch(jjstateSet[--i]) {
    777 771   case 3:
    778 772   case 2:
    779 773   case 1:
    skipped 1 lines
    781 775   break;
    782 776   if (kind > 30)
    783 777   kind = 30;
    784  - { jjCheckNAddTwoStates(0, 2); }
     778 + jjCheckNAddTwoStates(0, 2);
     779 + break;
     780 + default:
    785 781   break;
    786  - default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
    787 782   }
    788 783   } while(i != startsAt);
    789 784   }
    skipped 6 lines
    796 791   ++curPos;
    797 792   if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
    798 793   return curPos;
    799  - try { curChar = input_stream.readChar(); }
    800  - catch(java.io.IOException e) { return curPos; }
     794 + try {
     795 + curChar = input_stream.readChar();
     796 + } catch (java.io.IOException e) {
     797 + return curPos;
     798 + }
    801 799   }
    802 800  }
    803  -private final int jjStopStringLiteralDfa_2(int pos, long active0){
    804  - switch (pos)
    805  - {
    806  - default :
    807  - return -1;
     801 + 
     802 + private final int jjStopStringLiteralDfa_2(int pos, long active0) {
     803 + switch (pos) {
     804 + default:
     805 + return -1;
     806 + }
    808 807   }
    809  -}
    810  -private final int jjStartNfa_2(int pos, long active0){
    811  - return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
    812  -}
    813  -private int jjMoveStringLiteralDfa0_2(){
    814  - switch(curChar)
    815  - {
    816  - case 34:
    817  - return jjStopAtPos(0, 33);
    818  - default :
    819  - return jjMoveNfa_2(3, 0);
     808 + 
     809 + private final int jjStartNfa_2(int pos, long active0) {
     810 + return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
    820 811   }
    821  -}
    822  -private int jjMoveNfa_2(int startState, int curPos)
     812 + 
     813 + private int jjMoveStringLiteralDfa0_2() {
     814 + switch (curChar) {
     815 + case 34:
     816 + return jjStopAtPos(0, 33);
     817 + default:
     818 + return jjMoveNfa_2(3, 0);
     819 + }
     820 + }
     821 + 
     822 + private int jjMoveNfa_2(int startState, int curPos)
    823 823  {
    824 824   int startsAt = 0;
    825 825   jjnewStateCnt = 3;
    826 826   int i = 1;
    827 827   jjstateSet[0] = startState;
    828 828   int kind = 0x7fffffff;
    829  - for (;;)
    830  - {
     829 + for (;;) {
    831 830   if (++jjround == 0x7fffffff)
    832 831   ReInitRounds();
    833  - if (curChar < 64)
    834  - {
     832 + if (curChar < 64) {
    835 833   long l = 1L << curChar;
    836  - do
    837  - {
    838  - switch(jjstateSet[--i])
    839  - {
     834 + do {
     835 + switch(jjstateSet[--i]) {
    840 836   case 3:
    841 837   case 2:
    842 838   if ((0xfffffffbffffffffL & l) == 0L)
    843 839   break;
    844 840   if (kind > 32)
    845 841   kind = 32;
    846  - { jjCheckNAddTwoStates(0, 2); }
     842 + jjCheckNAddTwoStates(0, 2);
    847 843   break;
    848 844   case 1:
    849 845   if (kind > 32)
    850 846   kind = 32;
    851  - { jjCheckNAddTwoStates(0, 2); }
     847 + jjCheckNAddTwoStates(0, 2);
    852 848   break;
    853 849   default : break;
    854 850   }
    855 851   } while(i != startsAt);
    856  - }
    857  - else if (curChar < 128)
    858  - {
     852 + } else if (curChar < 128) {
    859 853   long l = 1L << (curChar & 077);
    860  - do
    861  - {
    862  - switch(jjstateSet[--i])
    863  - {
     854 + do {
     855 + switch(jjstateSet[--i]) {
    864 856   case 3:
    865  - if ((0xffffffffefffffffL & l) != 0L)
    866  - {
     857 + if ((0xffffffffefffffffL & l) != 0L) {
    867 858   if (kind > 32)
    868 859   kind = 32;
    869  - { jjCheckNAddTwoStates(0, 2); }
    870  - }
    871  - else if (curChar == 92)
     860 + jjCheckNAddTwoStates(0, 2);
     861 + } else if (curChar == 92)
    872 862   jjstateSet[jjnewStateCnt++] = 1;
    873 863   break;
    874 864   case 0:
    skipped 3 lines
    878 868   case 1:
    879 869   if (kind > 32)
    880 870   kind = 32;
    881  - { jjCheckNAddTwoStates(0, 2); }
     871 + jjCheckNAddTwoStates(0, 2);
    882 872   break;
    883 873   case 2:
    884 874   if ((0xffffffffefffffffL & l) == 0L)
    885 875   break;
    886 876   if (kind > 32)
    887 877   kind = 32;
    888  - { jjCheckNAddTwoStates(0, 2); }
     878 + jjCheckNAddTwoStates(0, 2);
    889 879   break;
    890 880   default : break;
    891 881   }
    892 882   } while(i != startsAt);
    893  - }
    894  - else
    895  - {
    896  - int hiByte = (curChar >> 8);
     883 + } else {
     884 + int hiByte = (int) (curChar >> 8);
    897 885   int i1 = hiByte >> 6;
    898 886   long l1 = 1L << (hiByte & 077);
    899 887   int i2 = (curChar & 0xff) >> 6;
    900 888   long l2 = 1L << (curChar & 077);
    901  - do
    902  - {
    903  - switch(jjstateSet[--i])
    904  - {
     889 + do {
     890 + switch(jjstateSet[--i]) {
    905 891   case 3:
    906 892   case 2:
    907 893   case 1:
    skipped 1 lines
    909 895   break;
    910 896   if (kind > 32)
    911 897   kind = 32;
    912  - { jjCheckNAddTwoStates(0, 2); }
     898 + jjCheckNAddTwoStates(0, 2);
    913 899   break;
    914  - default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
     900 + default:
     901 + break;
    915 902   }
    916 903   } while(i != startsAt);
    917 904   }
    918  - if (kind != 0x7fffffff)
    919  - {
     905 + if (kind != 0x7fffffff) {
    920 906   jjmatchedKind = kind;
    921 907   jjmatchedPos = curPos;
    922 908   kind = 0x7fffffff;
    skipped 1 lines
    924 910   ++curPos;
    925 911   if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
    926 912   return curPos;
    927  - try { curChar = input_stream.readChar(); }
    928  - catch(java.io.IOException e) { return curPos; }
     913 + try {
     914 + curChar = input_stream.readChar();
     915 + } catch (java.io.IOException e) {
     916 + return curPos;
     917 + }
    929 918   }
    930 919  }
    931 920   
    932  -/** Token literal values. */
    933  -public static final String[] jjstrLiteralImages = {
    934  -"", null, null, "\41\75", "\76", "\74", "\76\75", "\74\75", null, null, null,
    935  -null, null, null, null, null, null, null, null, "\50", "\51", null, "\56", null,
    936  -"\133", "\135", "\54", "\43", "\47", "\42", null, "\47", null, "\42", null, };
    937  -protected Token jjFillToken()
    938  -{
    939  - final Token t;
    940  - final String curTokenImage;
    941  - final int beginLine;
    942  - final int endLine;
    943  - final int beginColumn;
    944  - final int endColumn;
    945  - String im = jjstrLiteralImages[jjmatchedKind];
     921 + static final int[] jjnextStates = {
     922 + 31, 33, 36, 40, 42, 43,
     923 + };
     924 + 
     925 + private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) {
     926 + switch (hiByte) {
     927 + case 0:
     928 + return ((jjbitVec2[i2] & l2) != 0L);
     929 + default:
     930 + if ((jjbitVec0[i1] & l1) != 0L)
     931 + return true;
     932 + return false;
     933 + }
     934 + }
     935 + 
     936 + /**
     937 + * Token literal values.
     938 + */
     939 + public static final String[] jjstrLiteralImages = {
     940 + "", null, null, "\41\75", "\76", "\74", "\76\75", "\74\75", null, null, null,
     941 + null, null, null, null, null, null, null, null, "\50", "\51", null, "\56", null,
     942 + "\133", "\135", "\54", "\43", "\47", "\42", null, "\47", null, "\42", null,};
     943 + 
     944 + /**
     945 + * Lexer state names.
     946 + */
     947 + public static final String[] lexStateNames = {
     948 + "DEFAULT",
     949 + "SINGLE_QUOTED_STRING",
     950 + "DOUBLE_QUOTED_STRING",
     951 + };
     952 + 
     953 + /**
     954 + * Lex State array.
     955 + */
     956 + public static final int[] jjnewLexState = {
     957 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
     958 + -1, -1, -1, 1, 2, -1, 0, -1, 0, -1,
     959 + };
     960 + static final long[] jjtoToken = {
     961 + 0x7fffffffdL,
     962 + };
     963 + static final long[] jjtoSkip = {
     964 + 0x2L,
     965 + };
     966 + protected SimpleCharStream input_stream;
     967 + private final int[] jjrounds = new int[49];
     968 + private final int[] jjstateSet = new int[98];
     969 + protected char curChar;
     970 + 
     971 + /**
     972 + * Constructor.
     973 + */
     974 + public FilterParserTokenManager(SimpleCharStream stream) {
     975 + if (SimpleCharStream.staticFlag)
     976 + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
     977 + input_stream = stream;
     978 + }
     979 + 
     980 + /**
     981 + * Constructor.
     982 + */
     983 + public FilterParserTokenManager(SimpleCharStream stream, int lexState) {
     984 + this(stream);
     985 + SwitchTo(lexState);
     986 + }
     987 + 
     988 + /**
     989 + * Reinitialise parser.
     990 + */
     991 + public void ReInit(SimpleCharStream stream) {
     992 + jjmatchedPos = jjnewStateCnt = 0;
     993 + curLexState = defaultLexState;
     994 + input_stream = stream;
     995 + ReInitRounds();
     996 + }
     997 + 
     998 + private void ReInitRounds() {
     999 + int i;
     1000 + jjround = 0x80000001;
     1001 + for (i = 49; i-- > 0; )
     1002 + jjrounds[i] = 0x80000000;
     1003 + }
     1004 + 
     1005 + /**
     1006 + * Reinitialise parser.
     1007 + */
     1008 + public void ReInit(SimpleCharStream stream, int lexState) {
     1009 + ReInit(stream);
     1010 + SwitchTo(lexState);
     1011 + }
     1012 + 
     1013 + /**
     1014 + * Switch to specified lex state.
     1015 + */
     1016 + public void SwitchTo(int lexState) {
     1017 + if (lexState >= 3 || lexState < 0)
     1018 + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
     1019 + else
     1020 + curLexState = lexState;
     1021 + }
     1022 + 
     1023 + protected Token jjFillToken() {
     1024 + final Token t;
     1025 + final String curTokenImage;
     1026 + final int beginLine;
     1027 + final int endLine;
     1028 + final int beginColumn;
     1029 + final int endColumn;
     1030 + String im = jjstrLiteralImages[jjmatchedKind];
    946 1031   curTokenImage = (im == null) ? input_stream.GetImage() : im;
    947 1032   beginLine = input_stream.getBeginLine();
    948 1033   beginColumn = input_stream.getBeginColumn();
    skipped 8 lines
    957 1042   
    958 1043   return t;
    959 1044  }
    960  -static final int[] jjnextStates = {
    961  - 31, 33, 36, 40, 42, 43,
    962  -};
    963  -private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
    964  -{
    965  - switch(hiByte)
    966  - {
    967  - case 0:
    968  - return ((jjbitVec2[i2] & l2) != 0L);
    969  - default :
    970  - if ((jjbitVec0[i1] & l1) != 0L)
    971  - return true;
    972  - return false;
    973  - }
    974  -}
    975 1045   
    976 1046  int curLexState = 0;
    977 1047  int defaultLexState = 0;
    skipped 8 lines
    986 1056   Token matchedToken;
    987 1057   int curPos = 0;
    988 1058   
    989  - EOFLoop :
    990  - for (;;)
    991  - {
    992  - try
    993  - {
    994  - curChar = input_stream.BeginToken();
    995  - }
    996  - catch(Exception e)
     1059 + EOFLoop:
     1060 + for (; ; ) {
     1061 + try {
     1062 + curChar = input_stream.BeginToken();
     1063 + } catch (java.io.IOException e)
    997 1064   {
    998 1065   jjmatchedKind = 0;
    999  - jjmatchedPos = -1;
    1000 1066   matchedToken = jjFillToken();
    1001 1067   return matchedToken;
    1002 1068   }
    skipped 69 lines
    1072 1138   }
    1073 1139  }
    1074 1140   
    1075  -void SkipLexicalActions(Token matchedToken)
    1076  -{
    1077  - switch(jjmatchedKind)
    1078  - {
    1079  - default :
    1080  - break;
    1081  - }
    1082  -}
    1083  -void MoreLexicalActions()
    1084  -{
    1085  - jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
    1086  - switch(jjmatchedKind)
    1087  - {
    1088  - default :
    1089  - break;
    1090  - }
    1091  -}
    1092  -void TokenLexicalActions(Token matchedToken)
    1093  -{
    1094  - switch(jjmatchedKind)
    1095  - {
    1096  - default :
    1097  - break;
    1098  - }
    1099  -}
    1100 1141  private void jjCheckNAdd(int state)
    1101 1142  {
    1102 1143   if (jjrounds[state] != jjround)
    skipped 21 lines
    1124 1165   } while (start++ != end);
    1125 1166  }
    1126 1167   
    1127  - /** Constructor. */
    1128  - public FilterParserTokenManager(SimpleCharStream stream){
    1129  - 
    1130  - if (SimpleCharStream.staticFlag)
    1131  - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
    1132  - 
    1133  - input_stream = stream;
    1134  - }
    1135  - 
    1136  - /** Constructor. */
    1137  - public FilterParserTokenManager (SimpleCharStream stream, int lexState){
    1138  - ReInit(stream);
    1139  - SwitchTo(lexState);
    1140  - }
    1141  - 
    1142  - /** Reinitialise parser. */
    1143  -
    1144  - public void ReInit(SimpleCharStream stream)
    1145  - {
    1146  - 
    1147  - 
    1148  - jjmatchedPos =
    1149  - jjnewStateCnt =
    1150  - 0;
    1151  - curLexState = defaultLexState;
    1152  - input_stream = stream;
    1153  - ReInitRounds();
    1154  - }
    1155  - 
    1156  - private void ReInitRounds()
    1157  - {
    1158  - int i;
    1159  - jjround = 0x80000001;
    1160  - for (i = 49; i-- > 0;)
    1161  - jjrounds[i] = 0x80000000;
    1162  - }
    1163  - 
    1164  - /** Reinitialise parser. */
    1165  - public void ReInit(SimpleCharStream stream, int lexState)
    1166  -
    1167  - {
    1168  - ReInit(stream);
    1169  - SwitchTo(lexState);
    1170  - }
    1171  - 
    1172  - /** Switch to specified lex state. */
    1173  - public void SwitchTo(int lexState)
    1174  - {
    1175  - if (lexState >= 3 || lexState < 0)
    1176  - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
    1177  - else
    1178  - curLexState = lexState;
    1179  - }
    1180  - 
    1181  - 
    1182  -/** Lexer state names. */
    1183  -public static final String[] lexStateNames = {
    1184  - "DEFAULT",
    1185  - "SINGLE_QUOTED_STRING",
    1186  - "DOUBLE_QUOTED_STRING",
    1187  -};
    1188  - 
    1189  -/** Lex State array. */
    1190  -public static final int[] jjnewLexState = {
    1191  - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    1192  - -1, -1, -1, 1, 2, -1, 0, -1, 0, -1,
    1193  -};
    1194  -static final long[] jjtoToken = {
    1195  - 0x7fffffffdL,
    1196  -};
    1197  -static final long[] jjtoSkip = {
    1198  - 0x2L,
    1199  -};
    1200  -static final long[] jjtoSpecial = {
    1201  - 0x0L,
    1202  -};
    1203  -static final long[] jjtoMore = {
    1204  - 0x0L,
    1205  -};
    1206  - protected SimpleCharStream input_stream;
    1207  - 
    1208  - private final int[] jjrounds = new int[49];
    1209  - private final int[] jjstateSet = new int[2 * 49];
    1210  - private final StringBuilder jjimage = new StringBuilder();
    1211  - private StringBuilder image = jjimage;
    1212  - private int jjimageLen;
    1213  - private int lengthOfMatch;
    1214  - protected int curChar;
    1215 1168  }
    1216 1169   
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/FilterParserTreeConstants.java
    1  -/* Generated By:JavaCC: Do not edit this line. FilterParserTreeConstants.java Version 7.0.2 */
     1 +/* Generated By:JavaCC: Do not edit this line. FilterParserTreeConstants.java Version 5.0 */
    2 2  package com.nccgroup.loggerplusplus.filter.parser;
    3 3   
    4 4  public interface FilterParserTreeConstants
    skipped 11 lines
    16 16   "Alias",
    17 17   };
    18 18  }
    19  -/* JavaCC - OriginalChecksum=b03fa3e64accc9245d958e2ed2a55041 (do not edit this line) */
     19 +/* JavaCC - OriginalChecksum=a8f71270ce0cb112d3284149dfad33e2 (do not edit this line) */
    20 20   
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/FilterParserVisitor.java
    1  -/* Generated By:JavaCC: Do not edit this line. FilterParserVisitor.java Version 7.0.2 */
     1 +/* Generated By:JavaCC: Do not edit this line. FilterParserVisitor.java Version 5.0 */
    2 2  package com.nccgroup.loggerplusplus.filter.parser;
    3 3   
    4 4  public interface FilterParserVisitor
    skipped 3 lines
    8 8   public Object visit(ASTComparison node, VisitorData data);
    9 9   public Object visit(ASTAlias node, VisitorData data);
    10 10  }
    11  -/* JavaCC - OriginalChecksum=6fc9bf0937c416fc04e99e70768a04f7 (do not edit this line) */
     11 +/* JavaCC - OriginalChecksum=1d4b7dd7f55608a77745498f1be093dd (do not edit this line) */
    12 12   
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/JJTFilterParserState.java
    1  -/* Generated By:JavaCC: Do not edit this line. JJTFilterParserState.java Version 7.0.2 */
     1 +/* Generated By:JavaCC: Do not edit this line. JJTFilterParserState.java Version 5.0 */
    2 2  package com.nccgroup.loggerplusplus.filter.parser;
    3 3   
    4 4  public class JJTFilterParserState {
    skipped 115 lines
    120 120   }
    121 121   }
    122 122  }
    123  -/* JavaCC - OriginalChecksum=bbfdb2a9022752fd7f673fdca576c37c (do not edit this line) */
     123 +/* JavaCC - OriginalChecksum=4bd4e2bc0a8feefbb219e6f891cd825b (do not edit this line) */
    124 124   
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/filter/parser/SanityCheckVisitor.java
    1 1  /* Generated By:JavaCC: Do not edit this line. FilterParserDefaultVisitor.java Version 7.0.2 */
    2 2  package com.nccgroup.loggerplusplus.filter.parser;
    3 3   
    4  -import com.nccgroup.loggerplusplus.filter.BooleanOperator;
     4 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;
    5 5  import com.nccgroup.loggerplusplus.logentry.LogEntryField;
    6 6   
     7 +import java.util.Collection;
    7 8  import java.util.Date;
    8 9  import java.util.regex.Pattern;
    9 10   
    skipped 14 lines
    24 25   public VisitorData visit(ASTExpression node, VisitorData data){
    25 26   return defaultVisit(node, data);
    26 27   }
    27  - public VisitorData visit(ASTComparison node, VisitorData visitorData){
     28 + public VisitorData visit(ASTComparison node, VisitorData visitorData) {
    28 29   defaultVisit(node, visitorData);
    29 30   
    30 31   Class leftType, rightType;
    31 32   leftType = (node.left instanceof LogEntryField) ? ((LogEntryField) node.left).getType() : node.left.getClass();
    32 33   rightType = (node.right instanceof LogEntryField) ? ((LogEntryField) node.right).getType() : node.right.getClass();
    33  - if(leftType == null || rightType == null) return visitorData;
     34 + if (leftType == null || rightType == null) return visitorData;
    34 35   
    35  - if(node.booleanOperator == BooleanOperator.LESS_THAN || node.booleanOperator == BooleanOperator.LESS_THAN_EQUAL
    36  - || node.booleanOperator == BooleanOperator.GREATER_THAN || node.booleanOperator == BooleanOperator.GREATER_THAN_EQUAL) {
     36 + if (node.comparisonOperator == ComparisonOperator.LESS_THAN || node.comparisonOperator == ComparisonOperator.LESS_THAN_EQUAL
     37 + || node.comparisonOperator == ComparisonOperator.GREATER_THAN || node.comparisonOperator == ComparisonOperator.GREATER_THAN_EQUAL) {
    37 38   boolean valid = (Date.class.isAssignableFrom(leftType) || Date.class.isAssignableFrom(rightType))
    38 39   || (Number.class.isAssignableFrom(leftType) && Number.class.isAssignableFrom(rightType));
    39 40   if (!valid) {
    40 41   visitorData.addError(String.format("Operator %s cannot be used to compare groups of type %s and %s.",
    41  - node.booleanOperator, leftType.getTypeName(), rightType.getTypeName()));
     42 + node.comparisonOperator, leftType.getTypeName(), rightType.getTypeName()));
    42 43   }
    43  - }else if(node.left instanceof Pattern){
     44 + } else if (node.left instanceof Pattern) {
    44 45   visitorData.addError("The left operand of a comparison cannot be a pattern.");
    45  - }else if(node.right instanceof Pattern && !String.class.isAssignableFrom(leftType)){
     46 + } else if (node.right instanceof Pattern && !String.class.isAssignableFrom(leftType)) {
    46 47   visitorData.addError("Regular expressions can only be used on string elements.");
    47  - }else if(node.booleanOperator == BooleanOperator.CONTAINS && !(String.class.isAssignableFrom(leftType) && String.class.isAssignableFrom(leftType))){
    48  - visitorData.addError("The contains operator can only be used on string elements.");
     48 + } else if (node.comparisonOperator == ComparisonOperator.CONTAINS && !(String.class.isAssignableFrom(leftType) && String.class.isAssignableFrom(leftType))) {
     49 + visitorData.addError("The CONTAINS operator can only be used on string elements.");
     50 + } else if (node.comparisonOperator == ComparisonOperator.IN && Collection.class.isAssignableFrom(rightType)) {
     51 + visitorData.addError("The IN operator requires the right-hand object of the comparison to be a collection (e.g. list, set)!");
    49 52   }
    50 53   
    51 54   return visitorData;
    skipped 9 lines
  • ■ ■ ■ ■ ■ ■
    src/main/java/com/nccgroup/loggerplusplus/logview/SingleLogEntryMenu.java
    skipped 3 lines
    4 4  import com.nccgroup.loggerplusplus.exports.ContextMenuExportProvider;
    5 5  import com.nccgroup.loggerplusplus.exports.ExportController;
    6 6  import com.nccgroup.loggerplusplus.exports.LogExporter;
    7  -import com.nccgroup.loggerplusplus.filter.BooleanOperator;
     7 +import com.nccgroup.loggerplusplus.filter.ComparisonOperator;
    8 8  import com.nccgroup.loggerplusplus.filter.LogicalOperator;
    9 9  import com.nccgroup.loggerplusplus.filter.colorfilter.ColorFilter;
    10 10  import com.nccgroup.loggerplusplus.filter.logfilter.LogFilter;
    skipped 56 lines
    67 67   JMenuItem andFilter = new JMenuItem(new AbstractAction(LogicalOperator.AND.getLabel()) {
    68 68   @Override
    69 69   public void actionPerformed(ActionEvent actionEvent) {
    70  - String newFilter = logTable.getCurrentFilter().addConditionToFilter(LogicalOperator.AND, selectedField, BooleanOperator.EQUAL, columnValueString);
     70 + String newFilter = logTable.getCurrentFilter().addConditionToFilter(LogicalOperator.AND, selectedField, ComparisonOperator.EQUAL, columnValueString);
    71 71   logTableController.getLogViewController().getLogFilterController().setFilter(newFilter);
    72 72   }
    73 73   });
    74 74   JMenuItem orFilter = new JMenuItem(new AbstractAction(LogicalOperator.OR.getLabel()) {
    75 75   @Override
    76 76   public void actionPerformed(ActionEvent actionEvent) {
    77  - String newFilter = logTable.getCurrentFilter().addConditionToFilter(LogicalOperator.OR, selectedField, BooleanOperator.EQUAL, columnValueString);
     77 + String newFilter = logTable.getCurrentFilter().addConditionToFilter(LogicalOperator.OR, selectedField, ComparisonOperator.EQUAL, columnValueString);
    78 78   logTableController.getLogViewController().getLogFilterController().setFilter(newFilter);
    79 79   }
    80 80   });
    skipped 159 lines
Please wait...
Page is in error, reload to recover