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 Tue, 30 Sep 2003 04:38:36 GMT
ehatcher    2003/09/29 21:38:36

  Modified:    src/java/org/apache/lucene/queryParser QueryParser.java
                        QueryParser.jj
  Log:
  Add throws clause to query factory methods, allowing subclasses to use for rejecting, etc
  
  Revision  Changes    Path
  1.2       +19 -9     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- QueryParser.java	11 Sep 2003 01:51:33 -0000	1.1
  +++ QueryParser.java	30 Sep 2003 04:38:36 -0000	1.2
  @@ -93,8 +93,8 @@
     }
   
     /** Constructs a query parser.
  -   *  @param field	the default field for query terms.
  -   *  @param analyzer   used to find terms in the query text.
  +   *  @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(new FastCharStream(new StringReader("")));
  @@ -195,9 +195,12 @@
       clauses.addElement(new BooleanClause(q, required, prohibited));
     }
   
  +  /**
  +   * @exception ParseException throw in overridden method to disallow
  +   */
     protected Query getFieldQuery(String field,
                                   Analyzer analyzer,
  -                                String queryText) {
  +                                String queryText)  throws ParseException {
       // Use the analyzer to get all the tokens, and then build a TermQuery,
       // PhraseQuery, or nothing based on the term count
   
  @@ -231,13 +234,16 @@
       }
     }
   
  +  /**
  +   * @exception ParseException throw in overridden method to disallow
  +   */
     protected Query getRangeQuery(String field,
                                   Analyzer analyzer,
                                   String part1,
                                   String part2,
  -                                boolean inclusive)
  +                                boolean inclusive) throws ParseException
     {
  -    boolean isDate = false, isNumber = false;
  +    boolean isDate = false;
   
       try {
         DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
  @@ -270,8 +276,9 @@
      *    to join.
      *
      * @return Resulting {@link Query} object.
  +   * @exception ParseException throw in overridden method to disallow
      */
  -  protected Query getBooleanQuery(Vector clauses)
  +  protected Query getBooleanQuery(Vector clauses) throws ParseException
     {
       BooleanQuery query = new BooleanQuery();
       for (int i = 0; i < clauses.size(); i++) {
  @@ -299,8 +306,9 @@
      *   characters (? or *), but is not simple prefix term
      *
      * @return Resulting {@link Query} built for the term
  +   * @exception ParseException throw in overridden method to disallow
      */
  -  protected Query getWildcardQuery(String field, String termStr)
  +  protected Query getWildcardQuery(String field, String termStr) throws ParseException
     {
       if (lowercaseWildcardTerms) {
           termStr = termStr.toLowerCase();
  @@ -330,8 +338,9 @@
      *    (<b>without</b> trailing '*' character!)
      *
      * @return Resulting {@link Query} built for the term
  +   * @exception ParseException throw in overridden method to disallow
      */
  -  protected Query getPrefixQuery(String field, String termStr)
  +  protected Query getPrefixQuery(String field, String termStr) throws ParseException
     {
       if (lowercaseWildcardTerms) {
           termStr = termStr.toLowerCase();
  @@ -349,8 +358,9 @@
      * @param termStr Term token to use for building term for the query
      *
      * @return Resulting {@link Query} built for the term
  +   * @exception ParseException throw in overridden method to disallow
      */
  -  protected Query getFuzzyQuery(String field, String termStr)
  +  protected Query getFuzzyQuery(String field, String termStr) throws ParseException
     {
       Term t = new Term(field, termStr);
       return new FuzzyQuery(t);
  
  
  
  1.30      +19 -9     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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- QueryParser.jj	20 Mar 2003 18:28:13 -0000	1.29
  +++ QueryParser.jj	30 Sep 2003 04:38:36 -0000	1.30
  @@ -155,8 +155,8 @@
     }
   
     /** Constructs a query parser.
  -   *  @param field	the default field for query terms.
  -   *  @param analyzer   used to find terms in the query text.
  +   *  @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(new FastCharStream(new StringReader("")));
  @@ -257,9 +257,12 @@
       clauses.addElement(new BooleanClause(q, required, prohibited));
     }
   
  +  /**
  +   * @exception ParseException throw in overridden method to disallow
  +   */
     protected Query getFieldQuery(String field,
                                   Analyzer analyzer,
  -                                String queryText) {
  +                                String queryText)  throws ParseException {
       // Use the analyzer to get all the tokens, and then build a TermQuery,
       // PhraseQuery, or nothing based on the term count
   
  @@ -293,13 +296,16 @@
       }
     }
   
  +  /**
  +   * @exception ParseException throw in overridden method to disallow
  +   */
     protected Query getRangeQuery(String field,
                                   Analyzer analyzer,
                                   String part1,
                                   String part2,
  -                                boolean inclusive)
  +                                boolean inclusive) throws ParseException
     {
  -    boolean isDate = false, isNumber = false;
  +    boolean isDate = false;
   
       try {
         DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
  @@ -332,8 +338,9 @@
      *    to join.
      *
      * @return Resulting {@link Query} object.
  +   * @exception ParseException throw in overridden method to disallow
      */
  -  protected Query getBooleanQuery(Vector clauses)
  +  protected Query getBooleanQuery(Vector clauses) throws ParseException
     {
       BooleanQuery query = new BooleanQuery();
       for (int i = 0; i < clauses.size(); i++) {
  @@ -361,8 +368,9 @@
      *   characters (? or *), but is not simple prefix term
      *
      * @return Resulting {@link Query} built for the term
  +   * @exception ParseException throw in overridden method to disallow
      */
  -  protected Query getWildcardQuery(String field, String termStr)
  +  protected Query getWildcardQuery(String field, String termStr) throws ParseException
     {
       if (lowercaseWildcardTerms) {
   	termStr = termStr.toLowerCase();
  @@ -392,8 +400,9 @@
      *    (<b>without</b> trailing '*' character!)
      *
      * @return Resulting {@link Query} built for the term
  +   * @exception ParseException throw in overridden method to disallow
      */
  -  protected Query getPrefixQuery(String field, String termStr)
  +  protected Query getPrefixQuery(String field, String termStr) throws ParseException
     {
       if (lowercaseWildcardTerms) {
   	termStr = termStr.toLowerCase();
  @@ -411,8 +420,9 @@
      * @param termStr Term token to use for building term for the query
      *
      * @return Resulting {@link Query} built for the term
  +   * @exception ParseException throw in overridden method to disallow
      */
  -  protected Query getFuzzyQuery(String field, String termStr)
  +  protected Query getFuzzyQuery(String field, String termStr) throws ParseException
     {
       Term t = new Term(field, termStr);
       return new FuzzyQuery(t);
  
  
  

Mime
View raw message