wam         02/03/19 09:28:15

  Modified:    src/share/org/apache/slide/search/basic
                        RequestedResourcesPoolImpl.java
                        RequestedResourcesPool.java
  Log:
  indicate partial result
  
  Revision  Changes    Path
  1.2       +109 -94   
jakarta-slide/src/share/org/apache/slide/search/basic/RequestedResourcesPoolImpl.java
  
  Index: RequestedResourcesPoolImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/RequestedResourcesPoolImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestedResourcesPoolImpl.java   14 Feb 2002 17:02:46 -0000      1.1
  +++ RequestedResourcesPoolImpl.java   19 Mar 2002 17:28:15 -0000      1.2
  @@ -32,120 +32,135 @@
    * computed.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Wallmer</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class RequestedResourcesPoolImpl implements RequestedResourcesPool {
       
  -     /**  */
  +    /**  */
       private Structure structure;
  -     private Content contentHelper;
  +    private Content contentHelper;
       private SlideToken slideToken;
       private QueryScope scope;
  -     
  -     private int maxDepth;
       
  +    private int scopeDepth;
  +    private int maxSlideDepth;
  +    private boolean partialResult = false;
       private Set pool;
       
  -     /**
  -      * Constructs a RequestedResourcesPool
  -      *
  -      * @param searchToken    the searchToken
  -      * @param scope          the scope of the query
  -      *
  -      * @throws BadQueryException
  -      */
  -     public RequestedResourcesPoolImpl (SearchToken searchToken,
  -                                                                        QueryScope 
scope)
  -             throws BadQueryException
  +    /**
  +     * Constructs a RequestedResourcesPool
  +     *
  +     * @param searchToken    the searchToken
  +     * @param scope          the scope of the query
  +     *
  +     * @throws BadQueryException
  +     */
  +    public RequestedResourcesPoolImpl (SearchToken searchToken,
  +                                       QueryScope scope)
  +        throws BadQueryException
       {
  -             this.structure  = searchToken.getStructureHelper();
  -             this.slideToken = searchToken.getSlideToken();
  -             this.scope      = scope;
  -             this.contentHelper = searchToken.getContentHelper();
  -             
  -             maxDepth = Math.min (searchToken.getMaxDepth(), scope.getDepth());
  -             createPool ();
  +        this.structure  = searchToken.getStructureHelper();
  +        this.slideToken = searchToken.getSlideToken();
  +        this.scope      = scope;
  +        this.contentHelper = searchToken.getContentHelper();
  +        
  +        scopeDepth = scope.getDepth ();
  +        maxSlideDepth = searchToken.getMaxDepth();
  +        
  +        createPool ();
       }
       
  -    
  -    
  -    
  -     /**
  -      * Method resourceIterator
  -      *
  -      * @return   an Iterator
  -      *
  -      */
  +    /**
  +     * Method resourceIterator
  +     *
  +     * @return   an Iterator
  +     *
  +     */
       public Iterator resourceIterator() {
  -             return pool.iterator();
  +        return pool.iterator();
       }
       
       
  -     /**
  -      * Method getPool
  -      *
  -      * @return   a Set
  -      *
  -      */
  +    /**
  +     * Method getPool
  +     *
  +     * @return   a Set
  +     *
  +     */
       public Set getPool() {
  -             return pool;
  +        return pool;
       }
       
       
  -     /**
  -      * Method createPool
  -      *
  -      * @throws   BadQueryException
  -      *
  -      */
  +    /**
  +     * Method createPool
  +     *
  +     * @throws   BadQueryException
  +     *
  +     */
       private void createPool () throws BadQueryException {
  -             pool = new HashSet ();
  -             
  -             String resourceUri = scope.getHref();
  -             
  -             // Get the object from Data.
  -             ObjectNode resource = null;
  -             
  -             try {
  -                     resource = structure.retrieve (slideToken, resourceUri);
  -                     parseOneObject (resource, 0);
  -             }
  -             catch (StructureException e) {
  -                     throw new InvalidScopeException
  -                             ("scope " + resourceUri + " is invalid");
  -             }
  -             catch (Exception e) {
  -                     throw new BadQueryException (e.getMessage());
  -             }
  -    }
  -    
  -     /**
  -      * Method parseOneObject
  -      *
  -      * @param    object              an ObjectNode
  -      * @param    currentDepth        an int
  -      *
  -      * @throws   SlideException
  -      *
  -      */
  +        pool = new HashSet ();
  +        
  +        String resourceUri = scope.getHref();
  +        
  +        // Get the object from Data.
  +        ObjectNode resource = null;
  +        
  +        try {
  +            resource = structure.retrieve (slideToken, resourceUri);
  +            parseOneObject (resource, 0);
  +        }
  +        catch (StructureException e) {
  +            throw new InvalidScopeException
  +                ("scope " + resourceUri + " is invalid");
  +        }
  +        catch (Exception e) {
  +            throw new BadQueryException (e.getMessage());
  +        }
  +    }
  +    
  +    /**
  +     * Method parseOneObject. Called recursively, result set truncation is done
  +     * here.
  +     *
  +     * @param    object              an ObjectNode
  +     * @param    currentDepth        an int
  +     *
  +     * @throws   SlideException
  +     *
  +     */
       private void parseOneObject (ObjectNode object, int currentDepth)
  -             throws SlideException
  -     {
  -             
  -             if (currentDepth > maxDepth)
  -                     return;
  -             
  -             Enumeration children = null;
  -             children = structure.getChildren (slideToken, object);
  -             
  -             while (children.hasMoreElements()) {
  -                     ObjectNode cur = (ObjectNode)children.nextElement();
  -                     parseOneObject (cur, currentDepth + 1);
  -             }
  -             
  -             RequestedResource item =
  -                     new RequestedResourceImpl (object, slideToken, contentHelper);
  -             
  -             pool.add (item);
  -     }
  +        throws SlideException
  +    {
  +        if (currentDepth > scopeDepth)
  +            return;
  +        
  +        if (currentDepth > maxSlideDepth) {
  +            partialResult = true;
  +            return;
  +        }
  +        
  +        Enumeration children = null;
  +        children = structure.getChildren (slideToken, object);
  +        
  +        while (children.hasMoreElements()) {
  +            ObjectNode cur = (ObjectNode)children.nextElement();
  +            parseOneObject (cur, currentDepth + 1);
  +        }
  +        
  +        RequestedResource item =
  +            new RequestedResourceImpl (object, slideToken, contentHelper);
  +        
  +        pool.add (item);
  +    }
  +    
  +    /**
  +     * Indicates if the server truncated the result set.
  +     *
  +     * @return   a boolean
  +     *
  +     */
  +    public boolean partialResult() {
  +        return partialResult;
  +    }
   }
  
  
  
  1.2       +30 -20    
jakarta-slide/src/share/org/apache/slide/search/basic/RequestedResourcesPool.java
  
  Index: RequestedResourcesPool.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/RequestedResourcesPool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestedResourcesPool.java       14 Feb 2002 17:02:46 -0000      1.1
  +++ RequestedResourcesPool.java       19 Mar 2002 17:28:15 -0000      1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/RequestedResourcesPool.java,v
 1.1 2002/02/14 17:02:46 wam Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/14 17:02:46 $
  + * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/RequestedResourcesPool.java,v
 1.2 2002/03/19 17:28:15 wam Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/03/19 17:28:15 $
    *
    * ====================================================================
    *
  @@ -70,29 +70,39 @@
   
   /**
    * Represents the pool of all resources out of which the query result is
  - * computed.
  + * computed. This may be the complete scope of the query or a subset, when
  + * the server the maximum depth of a query.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Wallmer</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public interface RequestedResourcesPool {
  -     
  -     /**
  -      * Method resourceIterator
  -      *
  -      * @return   an Iterator over RequestedResource objects
  -      *
  -      */
  +    
  +    /**
  +     * Method resourceIterator
  +     *
  +     * @return   an Iterator over RequestedResource objects
  +     *
  +     */
       Iterator resourceIterator ();
       
  -     /**
  -      * Method getPool
  -      *
  -      * @return   the pool as Set of RequestedResource objects.
  -      *
  -      * @throws   BadQueryException
  -      *
  -      */
  +    /**
  +     * Method getPool
  +     *
  +     * @return   the pool as Set of RequestedResource objects.
  +     *
  +     * @throws   BadQueryException
  +     *
  +     */
       Set getPool () throws BadQueryException ;
  +    
  +    
  +    /**
  +     * Indicates if the server truncated the result set.
  +     *
  +     * @return   a boolean
  +     *
  +     */
  +    boolean partialResult ();
   }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to