コード例 #1
0
 public final int Modifiers() throws ParseException {
   int ret = MOD_NONE;
   switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
     case NOT:
     case PLUS:
     case MINUS:
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case PLUS:
           jj_consume_token(PLUS);
           ret = MOD_REQ;
           break;
         case MINUS:
           jj_consume_token(MINUS);
           ret = MOD_NOT;
           break;
         case NOT:
           jj_consume_token(NOT);
           ret = MOD_NOT;
           break;
         default:
           jj_la1[2] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
       }
       break;
     default:
       jj_la1[3] = jj_gen;
       ;
   }
   {
     if (true) return ret;
   }
   throw new Error("Missing return statement in function");
 }
コード例 #2
0
 // *   Query  ::= ( Clause )*
 // *   Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
 public final int Conjunction() throws ParseException {
   int ret = CONJ_NONE;
   switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
     case AND:
     case OR:
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case AND:
           jj_consume_token(AND);
           ret = CONJ_AND;
           break;
         case OR:
           jj_consume_token(OR);
           ret = CONJ_OR;
           break;
         default:
           jj_la1[0] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
       }
       break;
     default:
       jj_la1[1] = jj_gen;
       ;
   }
   {
     if (true) return ret;
   }
   throw new Error("Missing return statement in function");
 }
コード例 #3
0
 public final Query Clause(String field) throws ParseException {
   Query q;
   Token fieldToken = null, boost = null;
   if (jj_2_3(2)) {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case TERM:
         fieldToken = jj_consume_token(TERM);
         jj_consume_token(COLON);
         field = discardEscapeChar(fieldToken.image);
         break;
       case STAR:
         jj_consume_token(STAR);
         jj_consume_token(COLON);
         field = "*";
         break;
       default:
         jj_la1[7] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
     }
   } else {;
   }
   switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
     case BAREOPER:
     case STAR:
     case QUOTED:
     case TERM:
     case PREFIXTERM:
     case WILDTERM:
     case REGEXPTERM:
     case RANGEIN_START:
     case RANGEEX_START:
     case NUMBER:
       q = Term(field);
       break;
     case LPAREN:
       jj_consume_token(LPAREN);
       q = Query(field);
       jj_consume_token(RPAREN);
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case CARAT:
           jj_consume_token(CARAT);
           boost = jj_consume_token(NUMBER);
           break;
         default:
           jj_la1[8] = jj_gen;
           ;
       }
       break;
     default:
       jj_la1[9] = jj_gen;
       jj_consume_token(-1);
       throw new ParseException();
   }
   {
     if (true) return handleBoost(q, boost);
   }
   throw new Error("Missing return statement in function");
 }
コード例 #4
0
 // This makes sure that there is no garbage after the query string
 public final Query TopLevelQuery(String field) throws ParseException {
   Query q;
   q = Query(field);
   jj_consume_token(0);
   {
     if (true) return q;
   }
   throw new Error("Missing return statement in function");
 }
コード例 #5
0
  /** Returns the first query if splitOnWhitespace=true or otherwise the entire produced query */
  public final Query MultiTerm(String field, List<BooleanClause> clauses) throws ParseException {
    Token text, whitespace, followingText;
    Query firstQuery = null;
    text = jj_consume_token(TERM);
    if (splitOnWhitespace) {
      firstQuery = getFieldQuery(field, discardEscapeChar(text.image), false);
      addClause(clauses, CONJ_NONE, MOD_NONE, firstQuery);
    }
    if (getToken(1).kind == TERM && allowedPostMultiTerm(getToken(2).kind)) {

    } else {
      jj_consume_token(-1);
      throw new ParseException();
    }
    label_2:
    while (true) {
      followingText = jj_consume_token(TERM);
      if (splitOnWhitespace) {
        Query q = getFieldQuery(field, discardEscapeChar(followingText.image), false);
        addClause(clauses, CONJ_NONE, MOD_NONE, q);
      } else { // build up the text to send to analysis
        text.image += " " + followingText.image;
      }
      if (getToken(1).kind == TERM && allowedPostMultiTerm(getToken(2).kind)) {;
      } else {
        break label_2;
      }
    }
    if (splitOnWhitespace == false) {
      firstQuery = getFieldQuery(field, discardEscapeChar(text.image), false);
      addMultiTermClauses(clauses, firstQuery);
    }
    {
      if (true) return firstQuery;
    }
    throw new Error("Missing return statement in function");
  }
コード例 #6
0
 public final Query Term(String field) throws ParseException {
   Token term, boost = null, fuzzySlop = null, goop1, goop2;
   boolean prefix = false;
   boolean wildcard = false;
   boolean fuzzy = false;
   boolean regexp = false;
   boolean startInc = false;
   boolean endInc = false;
   Query q;
   switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
     case BAREOPER:
     case STAR:
     case TERM:
     case PREFIXTERM:
     case WILDTERM:
     case REGEXPTERM:
     case NUMBER:
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case TERM:
           term = jj_consume_token(TERM);
           break;
         case STAR:
           term = jj_consume_token(STAR);
           wildcard = true;
           break;
         case PREFIXTERM:
           term = jj_consume_token(PREFIXTERM);
           prefix = true;
           break;
         case WILDTERM:
           term = jj_consume_token(WILDTERM);
           wildcard = true;
           break;
         case REGEXPTERM:
           term = jj_consume_token(REGEXPTERM);
           regexp = true;
           break;
         case NUMBER:
           term = jj_consume_token(NUMBER);
           break;
         case BAREOPER:
           term = jj_consume_token(BAREOPER);
           term.image = term.image.substring(0, 1);
           break;
         default:
           jj_la1[10] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
       }
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case CARAT:
         case FUZZY_SLOP:
           switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
             case CARAT:
               jj_consume_token(CARAT);
               boost = jj_consume_token(NUMBER);
               switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                 case FUZZY_SLOP:
                   fuzzySlop = jj_consume_token(FUZZY_SLOP);
                   fuzzy = true;
                   break;
                 default:
                   jj_la1[11] = jj_gen;
                   ;
               }
               break;
             case FUZZY_SLOP:
               fuzzySlop = jj_consume_token(FUZZY_SLOP);
               fuzzy = true;
               switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                 case CARAT:
                   jj_consume_token(CARAT);
                   boost = jj_consume_token(NUMBER);
                   break;
                 default:
                   jj_la1[12] = jj_gen;
                   ;
               }
               break;
             default:
               jj_la1[13] = jj_gen;
               jj_consume_token(-1);
               throw new ParseException();
           }
           break;
         default:
           jj_la1[14] = jj_gen;
           ;
       }
       q = handleBareTokenQuery(field, term, fuzzySlop, prefix, wildcard, fuzzy, regexp);
       break;
     case RANGEIN_START:
     case RANGEEX_START:
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case RANGEIN_START:
           jj_consume_token(RANGEIN_START);
           startInc = true;
           break;
         case RANGEEX_START:
           jj_consume_token(RANGEEX_START);
           break;
         default:
           jj_la1[15] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
       }
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case RANGE_GOOP:
           goop1 = jj_consume_token(RANGE_GOOP);
           break;
         case RANGE_QUOTED:
           goop1 = jj_consume_token(RANGE_QUOTED);
           break;
         default:
           jj_la1[16] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
       }
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case RANGE_TO:
           jj_consume_token(RANGE_TO);
           break;
         default:
           jj_la1[17] = jj_gen;
           ;
       }
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case RANGE_GOOP:
           goop2 = jj_consume_token(RANGE_GOOP);
           break;
         case RANGE_QUOTED:
           goop2 = jj_consume_token(RANGE_QUOTED);
           break;
         default:
           jj_la1[18] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
       }
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case RANGEIN_END:
           jj_consume_token(RANGEIN_END);
           endInc = true;
           break;
         case RANGEEX_END:
           jj_consume_token(RANGEEX_END);
           break;
         default:
           jj_la1[19] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
       }
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case CARAT:
           jj_consume_token(CARAT);
           boost = jj_consume_token(NUMBER);
           break;
         default:
           jj_la1[20] = jj_gen;
           ;
       }
       boolean startOpen = false;
       boolean endOpen = false;
       if (goop1.kind == RANGE_QUOTED) {
         goop1.image = goop1.image.substring(1, goop1.image.length() - 1);
       } else if ("*".equals(goop1.image)) {
         startOpen = true;
       }
       if (goop2.kind == RANGE_QUOTED) {
         goop2.image = goop2.image.substring(1, goop2.image.length() - 1);
       } else if ("*".equals(goop2.image)) {
         endOpen = true;
       }
       q =
           getRangeQuery(
               field,
               startOpen ? null : discardEscapeChar(goop1.image),
               endOpen ? null : discardEscapeChar(goop2.image),
               startInc,
               endInc);
       break;
     case QUOTED:
       term = jj_consume_token(QUOTED);
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case CARAT:
         case FUZZY_SLOP:
           switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
             case CARAT:
               jj_consume_token(CARAT);
               boost = jj_consume_token(NUMBER);
               switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                 case FUZZY_SLOP:
                   fuzzySlop = jj_consume_token(FUZZY_SLOP);
                   fuzzy = true;
                   break;
                 default:
                   jj_la1[21] = jj_gen;
                   ;
               }
               break;
             case FUZZY_SLOP:
               fuzzySlop = jj_consume_token(FUZZY_SLOP);
               fuzzy = true;
               switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                 case CARAT:
                   jj_consume_token(CARAT);
                   boost = jj_consume_token(NUMBER);
                   break;
                 default:
                   jj_la1[22] = jj_gen;
                   ;
               }
               break;
             default:
               jj_la1[23] = jj_gen;
               jj_consume_token(-1);
               throw new ParseException();
           }
           break;
         default:
           jj_la1[24] = jj_gen;
           ;
       }
       q = handleQuotedTerm(field, term, fuzzySlop);
       break;
     default:
       jj_la1[25] = jj_gen;
       jj_consume_token(-1);
       throw new ParseException();
   }
   {
     if (true) return handleBoost(q, boost);
   }
   throw new Error("Missing return statement in function");
 }
コード例 #7
0
 public final Query Query(String field) throws ParseException {
   List<BooleanClause> clauses = new ArrayList<BooleanClause>();
   Query q, firstQuery = null;
   int conj, mods;
   if (jj_2_1(2)) {
     firstQuery = MultiTerm(field, clauses);
   } else {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case NOT:
       case PLUS:
       case MINUS:
       case BAREOPER:
       case LPAREN:
       case STAR:
       case QUOTED:
       case TERM:
       case PREFIXTERM:
       case WILDTERM:
       case REGEXPTERM:
       case RANGEIN_START:
       case RANGEEX_START:
       case NUMBER:
         mods = Modifiers();
         q = Clause(field);
         addClause(clauses, CONJ_NONE, mods, q);
         if (mods == MOD_NONE) {
           firstQuery = q;
         }
         break;
       default:
         jj_la1[4] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
     }
   }
   label_1:
   while (true) {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case AND:
       case OR:
       case NOT:
       case PLUS:
       case MINUS:
       case BAREOPER:
       case LPAREN:
       case STAR:
       case QUOTED:
       case TERM:
       case PREFIXTERM:
       case WILDTERM:
       case REGEXPTERM:
       case RANGEIN_START:
       case RANGEEX_START:
       case NUMBER:;
         break;
       default:
         jj_la1[5] = jj_gen;
         break label_1;
     }
     if (jj_2_2(2)) {
       MultiTerm(field, clauses);
     } else {
       switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
         case AND:
         case OR:
         case NOT:
         case PLUS:
         case MINUS:
         case BAREOPER:
         case LPAREN:
         case STAR:
         case QUOTED:
         case TERM:
         case PREFIXTERM:
         case WILDTERM:
         case REGEXPTERM:
         case RANGEIN_START:
         case RANGEEX_START:
         case NUMBER:
           conj = Conjunction();
           mods = Modifiers();
           q = Clause(field);
           addClause(clauses, conj, mods, q);
           break;
         default:
           jj_la1[6] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
       }
     }
   }
   if (clauses.size() == 1 && firstQuery != null) {
     {
       if (true) return firstQuery;
     }
   } else {
     {
       if (true) return getBooleanQuery(clauses);
     }
   }
   throw new Error("Missing return statement in function");
 }