lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/queryParser QueryParser.java QueryParser.jj
Date Fri, 03 Oct 2003 15:13:57 GMT
ehatcher    2003/10/03 08:13:57

  Modified:    src/java/org/apache/lucene/queryParser QueryParser.java
                        QueryParser.jj
  Log:
  Change locale handling to be in line with the other tweakable parameters
  
  Revision  Changes    Path
  1.4       +19 -32    jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.java
  
  Index: QueryParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- QueryParser.java	3 Oct 2003 03:12:42 -0000	1.3
  +++ QueryParser.java	3 Oct 2003 15:13:57 -0000	1.4
  @@ -73,12 +73,9 @@
     Analyzer analyzer;
     String field;
     int phraseSlop = 0;
  -  Locale locale;
  -
  +  Locale locale = Locale.getDefault();
   
     /** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
  -   *  Default locale is used for date range parsing.
  -   *  Use {@link #parse(String, String, Analyzer, Locale)} for non-default locale handling.
      *  @param query	the query string to be parsed.
      *  @param field	the default field for query terms.
      *  @param analyzer   used to find terms in the query text.
  @@ -95,42 +92,14 @@
       }
     }
   
  -  /** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
  -   *  @param query	the query string to be parsed.
  -   *  @param field	the default field for query terms.
  -   *  @param analyzer   used to find terms in the query text.
  -   *  @param locale locale to use for date range parsing
  -   *  @throws ParseException if the parsing fails
  -   */
  -  static public Query parse(String query, String field, Analyzer analyzer, Locale locale)
  -       throws ParseException {
  -    try {
  -      QueryParser parser = new QueryParser(field, analyzer, locale);
  -      return parser.parse(query);
  -    }
  -    catch (TokenMgrError tme) {
  -      throw new ParseException(tme.getMessage());
  -    }
  -  }
  -
     /** Constructs a query parser.
      *  @param f	the default field for query terms.
      *  @param a   used to find terms in the query text.
      */
     public QueryParser(String f, Analyzer a) {
  -    this(f, a, Locale.getDefault());
  -  }
  -
  -  /** Constructs a query parser.
  -   *  @param f	the default field for query terms.
  -   *  @param a   used to find terms in the query text.
  -   *  @param locale
  -   */
  -  public QueryParser(String f, Analyzer a, Locale locale) {
       this(new FastCharStream(new StringReader("")));
       analyzer = a;
       field = f;
  -    this.locale = locale;
     }
   
     /** Parses a query string, returning a
  @@ -171,6 +140,10 @@
       this.operator = operator;
     }
   
  +  /**
  +   * Gets implicit operator setting, which will be either DEFAULT_OPERATOR_AND
  +   * or DEFAULT_OPERATOR_AND.
  +   */
     public int getOperator() {
       return operator;
     }
  @@ -181,6 +154,20 @@
   
     public boolean getLowercaseWildcardTerms() {
       return lowercaseWildcardTerms;
  +  }
  +
  +  /**
  +   * Set locale used by date range parsing.
  +   */
  +  public void setLocale(Locale locale) {
  +    this.locale = locale;
  +  }
  +
  +  /**
  +   * Returns current locale, allowing access by subclasses.
  +   */
  +  public Locale getLocale() {
  +    return locale;
     }
   
     protected void addClause(Vector clauses, int conj, int mods, Query q) {
  
  
  
  1.32      +19 -32    jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj
  
  Index: QueryParser.jj
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- QueryParser.jj	3 Oct 2003 03:12:42 -0000	1.31
  +++ QueryParser.jj	3 Oct 2003 15:13:57 -0000	1.32
  @@ -135,12 +135,9 @@
     Analyzer analyzer;
     String field;
     int phraseSlop = 0;
  -  Locale locale;
  -
  +  Locale locale = Locale.getDefault();
   
     /** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
  -   *  Default locale is used for date range parsing.
  -   *  Use {@link #parse(String, String, Analyzer, Locale)} for non-default locale handling.
      *  @param query	the query string to be parsed.
      *  @param field	the default field for query terms.
      *  @param analyzer   used to find terms in the query text.
  @@ -157,42 +154,14 @@
       }
     }
   
  -  /** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
  -   *  @param query	the query string to be parsed.
  -   *  @param field	the default field for query terms.
  -   *  @param analyzer   used to find terms in the query text.
  -   *  @param locale locale to use for date range parsing
  -   *  @throws ParseException if the parsing fails
  -   */
  -  static public Query parse(String query, String field, Analyzer analyzer, Locale locale)
  -       throws ParseException {
  -    try {
  -      QueryParser parser = new QueryParser(field, analyzer, locale);
  -      return parser.parse(query);
  -    }
  -    catch (TokenMgrError tme) {
  -      throw new ParseException(tme.getMessage());
  -    }
  -  }
  -
     /** Constructs a query parser.
      *  @param f	the default field for query terms.
      *  @param a   used to find terms in the query text.
      */
     public QueryParser(String f, Analyzer a) {
  -    this(f, a, Locale.getDefault());
  -  }
  -
  -  /** Constructs a query parser.
  -   *  @param f	the default field for query terms.
  -   *  @param a   used to find terms in the query text.
  -   *  @param locale
  -   */
  -  public QueryParser(String f, Analyzer a, Locale locale) {
       this(new FastCharStream(new StringReader("")));
       analyzer = a;
       field = f;
  -    this.locale = locale;
     }
   
     /** Parses a query string, returning a
  @@ -233,6 +202,10 @@
       this.operator = operator;
     }
   
  +  /**
  +   * Gets implicit operator setting, which will be either DEFAULT_OPERATOR_AND
  +   * or DEFAULT_OPERATOR_AND.
  +   */
     public int getOperator() {
       return operator;
     }
  @@ -243,6 +216,20 @@
   
     public boolean getLowercaseWildcardTerms() {
       return lowercaseWildcardTerms;
  +  }
  +
  +  /**
  +   * Set locale used by date range parsing.
  +   */
  +  public void setLocale(Locale locale) {
  +    this.locale = locale;
  +  }
  +
  +  /**
  +   * Returns current locale, allowing access by subclasses.
  +   */
  +  public Locale getLocale() {
  +    return locale;
     }
   
     protected void addClause(Vector clauses, int conj, int mods, Query q) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message