search/engine/api/src/main/java/net/sf/mmm/search/engine/base/AbstractSearchQueryBuilder.java
/**
   * @see #parseStandardQuery(String, SearchQueryBuilderOptions)
   *
   * @param parser is the scanner of the query-string.
   * @param options are the {@link SearchQueryBuilderOptions}.
   * @param defaultProperty is the property to use as default for unqualified search-terms.
   * @param depth is the depth of the query expression (number of open parenthesis).
   * @return the parsed query or <code>null</code> if this a call with a depth greater than <code>0</code> and
   *         the parsed query segment was void.
   */
@see #parseStandardQuery(String, SearchQueryBuilderOptions)
@param parser is the scanner of the query-string.
@param options are the  SearchQueryBuilderOptions.
@param defaultProperty is the property to use as default for unqualified search-terms.
@param depth is the depth of the query expression (number of open parenthesis).
@return the parsed query or null if this a call with a depth greater than 0 and
the parsed query segment was void.
@see #parseStandardQuery ( String SearchQueryBuilderOptions ) @param parser is the scanner of the query - string . @param options are the SearchQueryBuilderOptions . @param defaultProperty is the property to use as default for unqualified search - terms . @param depth is the depth of the query expression ( number of open parenthesis ) . @return the parsed query or null if this a call with a depth greater than 0 and the parsed query segment was void .
private SearchQuery parseStandardQuery(CharSequenceScanner parser, SearchQueryBuilderOptions options,
      String defaultProperty, int depth) {
    ComplexSearchQuery complexQuery = createComplexQuery();
    SearchQuery subQuery = null;
    boolean todo = true;
    while (todo) {
      parser.skipWhile(CharFilter.WHITESPACE_FILTER);
      char conjunction = 0;
      while (parser.hasNext()) {
        char c = parser.peek();
        if ((c == '+') || (c == '-')) {
          parser.next();
          conjunction = c;
        } else {
          break;
        }
      }
      subQuery = parseStandardClause(parser, defaultProperty, depth, options);
      if (subQuery != null) {
        if (conjunction == '+') {
          complexQuery.addRequiredQuery(subQuery);
        } else if (conjunction == '-') {
          complexQuery.addExcludingQuery(subQuery);
        } else if (options.isRequireTerms() && (depth == 0)) {
          complexQuery.addRequiredQuery(subQuery);
        } else {
          complexQuery.addOptionalQuery(subQuery);
        }
      }
      if (parser.hasNext()) {
        if (parser.peek() == ')') {
          parser.next();
          if (depth > 0) {
            todo = false;
          }
        }
      } else {
        todo = false;
      }
    }
    int size = complexQuery.getSubQueryCount();
    if (size == 0) {
      if (depth == 0) {
        return createNullQuery();
      } else {
        return null;
      }
    } else {
      return complexQuery;
    }
  }
private SearchQuery parseStandardQuery ( CharSequenceScanner parser , SearchQueryBuilderOptions options , String defaultProperty , int depth ) { ComplexSearchQuery complexQuery = createComplexQuery ( ) ; SearchQuery subQuery = null ; boolean todo = true ; while ( todo ) { parser . skipWhile ( CharFilter . WHITESPACE_FILTER ) ; char conjunction = 0 ; while ( parser . hasNext ( ) ) { char c = parser . peek ( ) ; if ( ( c == '+' ) || ( c == '-' ) ) { parser . next ( ) ; conjunction = c ; } else { break ; } } subQuery = parseStandardClause ( parser , defaultProperty , depth , options ) ; if ( subQuery != null ) { if ( conjunction == '+' ) { complexQuery . addRequiredQuery ( subQuery ) ; } else if ( conjunction == '-' ) { complexQuery . addExcludingQuery ( subQuery ) ; } else if ( options . isRequireTerms ( ) && ( depth == 0 ) ) { complexQuery . addRequiredQuery ( subQuery ) ; } else { complexQuery . addOptionalQuery ( subQuery ) ; } } if ( parser . hasNext ( ) ) { if ( parser . peek ( ) == ')' ) { parser . next ( ) ; if ( depth > 0 ) { todo = false ; } } } else { todo = false ; } } int size = complexQuery . getSubQueryCount ( ) ; if ( size == 0 ) { if ( depth == 0 ) { return createNullQuery ( ) ; } else { return null ; } } else { return complexQuery ; } }
@see #parseStandardQuery(String, SearchQueryBuilderOptions)
 @param parser is the scanner of the query-string.
@see #parseStandardQuery ( String SearchQueryBuilderOptions ) @param parser is the scanner of the query - string .
// determine conjunction... // TODO if no closing ) we should call errorHandler // } else if (size == 1) { // return subQuery;