001/*
002 *   Licensed to the Apache Software Foundation (ASF) under one
003 *   or more contributor license agreements.  See the NOTICE file
004 *   distributed with this work for additional information
005 *   regarding copyright ownership.  The ASF licenses this file
006 *   to you under the Apache License, Version 2.0 (the
007 *   "License"); you may not use this file except in compliance
008 *   with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *   Unless required by applicable law or agreed to in writing,
013 *   software distributed under the License is distributed on an
014 *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *   KIND, either express or implied.  See the License for the
016 *   specific language governing permissions and limitations
017 *   under the License.
018 *
019 */
020
021package org.apache.directory.shared.ldap.model.cursor;
022
023
024import org.apache.directory.shared.ldap.model.entry.Entry;
025import org.apache.directory.shared.ldap.model.exception.LdapException;
026import org.apache.directory.shared.ldap.model.message.IntermediateResponse;
027import org.apache.directory.shared.ldap.model.message.Referral;
028import org.apache.directory.shared.ldap.model.message.Response;
029import org.apache.directory.shared.ldap.model.message.SearchResultDone;
030
031
032/**
033 * An extension of Cursor which includes the retrieval of the SearchResultDone. 
034 * 
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 */
037public interface SearchCursor extends Cursor<Response>
038{
039    /**
040     * @return true if the cursor has processed all the elements we were searching
041     */
042    boolean isDone();
043    
044    /**
045     * gives the SearchResultDone message received at the end of search results
046     * 
047     * @return the SearchResultDone message, null if the search operation fails for any reason 
048     */
049    SearchResultDone getSearchResultDone();
050
051    
052    /**
053     * @return true if the next element in the cursor is a referral 
054     */
055    boolean isReferral();
056    
057    
058    /**
059     * @return The next referral element, if it's a referral 
060     * @throws LdapException If the 
061     */
062    Referral getReferral() throws LdapException;
063    
064    
065    /**
066     * @return true if the next element in the cursor is an entry 
067     */
068    boolean isEntry();
069    
070    /**
071     * @return The next entry element, if it's an entry 
072     * @throws LdapException If the 
073     */
074    Entry getEntry() throws LdapException;
075    
076
077    /**
078     * @return true if the next element in the cursor is an intermediate response 
079     */
080    boolean isIntermediate();
081    
082    /**
083     * @return The next intermediate response element, if it's an intermediate response 
084     * @throws LdapException If the 
085     */
086    IntermediateResponse getIntermediate() throws LdapException;
087}