You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by un...@apache.org on 2004/07/08 11:45:30 UTC

cvs commit: jakarta-slide/src/share/org/apache/slide/search/basic BasicQueryImpl.java

unico       2004/07/08 02:45:30

  Modified:    src/share/org/apache/slide/search/basic BasicQueryImpl.java
  Log:
  catch NFE when parsing nresults. minor javadoc fix
  
  Revision  Changes    Path
  1.15      +17 -8     jakarta-slide/src/share/org/apache/slide/search/basic/BasicQueryImpl.java
  
  Index: BasicQueryImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicQueryImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BasicQueryImpl.java	12 May 2004 12:50:43 -0000	1.14
  +++ BasicQueryImpl.java	8 Jul 2004 09:45:30 -0000	1.15
  @@ -72,16 +72,21 @@
   
       /**
        * Message of a BadQueryException that is thrown if the query element
  -     * neither contains a <from> nor a <from> element.
  +     * neither contains a <prop> nor a <allprop> element.
        */
       public static final String PROP_OR_ALLPROP_ELEMENT_MISSING = "Required element <prop> or <allprop> not supplied";
   
       /**
        * Message of a BadQueryException that is thrown if the query element
  -     * neither contains a &lt;from&gt; nor a &lt;from&gt; element.
  +     * contains a &lt;limit&gt; element but no &lt;nresults&gt; element.
        */
       public static final String NRESULTS_MISSING = "Required element <nresults> (when limit is supplied) not supplied";
   
  +    /**
  +     * Message of a BadQueryException that is thrown if the &lt;nresults&gt; element
  +     * is not an integer.
  +     */
  +    public static final String NRESULTS_MUST_BE_AN_INTEGER = "<nresults> should be an integer";
   
       /** the NotNormalizer, may be overridden in extending classes */
       protected NotNormalizer notNormalizer;
  @@ -354,8 +359,12 @@
               Element nResElem = limitElement.getChild (Literals.NRESULTS, namespace);
               if (nResElem == null)
                   throw new BadQueryException (NRESULTS_MISSING);
  -
  -            limit = new Integer (nResElem.getTextTrim()).intValue();
  +            try {
  +                limit = new Integer (nResElem.getTextTrim()).intValue();
  +            }
  +            catch (NumberFormatException e) {
  +                throw new BadQueryException(NRESULTS_MUST_BE_AN_INTEGER);
  +            }
               limitDefined = true;
           }
       }
  
  
  

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