All LDAP Classes
Internal LDAP Classes

com.novell.ldap
Class LDAPSearchResults

java.lang.Object
  extended by com.novell.ldap.LDAPSearchResults
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
DSMLSearchResults, SPMLSearchResults

public class LDAPSearchResults
extends java.lang.Object
implements java.io.Externalizable

An LDAPSearchResults object is returned from a synchronous search operation. It provides access to all results received during the operation (entries and exceptions).

Sample Code: Search.java

See Also:
LDAPConnection.search(java.lang.String, int, java.lang.String, java.lang.String[], boolean), Serialized Form

Field Summary
private  int batchSize
           
private  boolean completed
           
private  LDAPConnection conn
           
private  LDAPSearchConstraints cons
           
private  LDAPControl[] controls
           
private  java.util.Vector entries
           
private  int entryCount
           
private  int entryIndex
           
private  java.lang.String name
           
private static java.lang.Object nameLock
           
private  LDAPSearchQueue queue
           
private  int referenceCount
           
private  int referenceIndex
           
private  java.util.Vector references
           
private  java.util.ArrayList referralConn
           
private static int resultsNum
           
 
Constructor Summary
LDAPSearchResults()
          This constructor was added to support default Serialization
LDAPSearchResults(LDAPConnection conn, LDAPSearchQueue queue, LDAPSearchConstraints cons)
          Constructs a queue object for search results.
 
Method Summary
(package private)  void abandon()
          Cancels the search request and clears the message and enumeration.
private  boolean getBatchOfResults()
          Collects batchSize elements from an LDAPSearchQueue message queue and places them in a Vector.
 int getCount()
          Returns a count of the items in the search result.
 LDAPControl[] getDeSerializedControls()
          Returns LDAP Server Controls after De-serialization
 java.util.Vector getDeSerializedEntries()
          Returns LDAP Entries after De-serialization
 LDAPControl[] getResponseControls()
          Returns the latest server controls returned by the server in the context of this search request, or null if no server controls were returned.
private static LDAPXMLHandler getTopXMLHandler(java.lang.String tagname, LDAPXMLHandler parenthandler)
           
(package private) static LDAPXMLHandler getXMLControlHandler(java.lang.String tagname, LDAPXMLHandler parenthandler)
          This method return the LDAPHandler which handles the XML (DSML) tags for returned Server controls of this class
(package private) static LDAPXMLHandler getXMLEntryHandler(java.lang.String tagname, LDAPXMLHandler parenthandler)
          This method return the LDAPHandler which handles the XML (DSML) tags for returned LDAPEntries of this class
 boolean hasMore()
          Reports if there are more search results.
 LDAPEntry next()
          Returns the next result as an LDAPEntry.
static java.lang.Object readDSML(java.io.InputStream input)
          This method is used to deserialize the DSML encoded representation of this class.
 void readExternal(java.io.ObjectInput in)
          Reads the serialized object from the underlying input stream.
private  void resetVectors()
           
private  void writeAttribute(LDAPAttribute attr, java.lang.StringBuffer buff)
           
private  void writeControl(LDAPControl control, java.lang.StringBuffer buff)
           
 void writeExternal(java.io.ObjectOutput out)
          Writes the object state to a stream in XML format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries

private java.util.Vector entries

entryCount

private int entryCount

entryIndex

private int entryIndex

references

private java.util.Vector references

referenceCount

private int referenceCount

referenceIndex

private int referenceIndex

batchSize

private int batchSize

completed

private boolean completed

controls

private LDAPControl[] controls

queue

private LDAPSearchQueue queue

nameLock

private static java.lang.Object nameLock

resultsNum

private static int resultsNum

name

private java.lang.String name

conn

private LDAPConnection conn

cons

private LDAPSearchConstraints cons

referralConn

private java.util.ArrayList referralConn
Constructor Detail

LDAPSearchResults

public LDAPSearchResults()
This constructor was added to support default Serialization


LDAPSearchResults

LDAPSearchResults(LDAPConnection conn,
                  LDAPSearchQueue queue,
                  LDAPSearchConstraints cons)
Constructs a queue object for search results.

Parameters:
conn - The LDAPConnection which initiated the search

queue - The queue for the search results.

cons - The LDAPSearchConstraints associated with this search
Method Detail

getCount

public int getCount()
Returns a count of the items in the search result.

Returns a count of the entries and exceptions remaining in the object. If the search was submitted with a batch size greater than zero, getCount reports the number of results received so far but not enumerated with next(). The behavior is same for search submitted with batch size equals to 0.

For blocking calls with batch size equals to 0, get count returns the count of all the expected results from search for first time once after enumerated with hasMore(). The subsequent iterations decrement count value for both blocking and non-blocking calls.

Returns:
The number of items received but not retrieved by the application

getResponseControls

public LDAPControl[] getResponseControls()
Returns the latest server controls returned by the server in the context of this search request, or null if no server controls were returned.

Returns:
The server controls returned with the search request, or null if none were returned.

hasMore

public boolean hasMore()
Reports if there are more search results.

Returns:
true if there are more search results.

resetVectors

private void resetVectors()

next

public LDAPEntry next()
               throws LDAPException
Returns the next result as an LDAPEntry.

If automatic referral following is disabled or if a referral was not followed, next() will throw an LDAPReferralException when the referral is received.

Returns:
The next search result as an LDAPEntry.
Throws:
LDAPException - A general exception which includes an error message and an LDAP error code.
LDAPReferralException - A referral was received and not followed.

getBatchOfResults

private boolean getBatchOfResults()
Collects batchSize elements from an LDAPSearchQueue message queue and places them in a Vector.

If the last message from the server, the result message, contains an error, it will be stored in the Vector for nextElement to process. (although it does not increment the search result count) All search result entries will be placed in the Vector. If a null is returned from getResponse(), it is likely that the search was abandoned.

Returns:
true if all search results have been placed in the vector.

abandon

void abandon()
Cancels the search request and clears the message and enumeration.


writeAttribute

private void writeAttribute(LDAPAttribute attr,
                            java.lang.StringBuffer buff)
                     throws java.io.IOException
Throws:
java.io.IOException

writeControl

private void writeControl(LDAPControl control,
                          java.lang.StringBuffer buff)
                   throws java.io.IOException
Throws:
java.io.IOException

readDSML

public static java.lang.Object readDSML(java.io.InputStream input)
                                 throws java.io.IOException
This method is used to deserialize the DSML encoded representation of this class.

Parameters:
input - InputStream for the DSML formatted data.
Returns:
Deserialized form of this class.
Throws:
java.io.IOException - when serialization fails.

getTopXMLHandler

private static LDAPXMLHandler getTopXMLHandler(java.lang.String tagname,
                                               LDAPXMLHandler parenthandler)

getXMLControlHandler

static LDAPXMLHandler getXMLControlHandler(java.lang.String tagname,
                                           LDAPXMLHandler parenthandler)
This method return the LDAPHandler which handles the XML (DSML) tags for returned Server controls of this class

Parameters:
tagname - Name of the Root tag used to represent this class.
parenthandler - Parent LDAPXMLHandler for this tag.
Returns:
LDAPXMLHandler to handle this element.

getXMLEntryHandler

static LDAPXMLHandler getXMLEntryHandler(java.lang.String tagname,
                                         LDAPXMLHandler parenthandler)
This method return the LDAPHandler which handles the XML (DSML) tags for returned LDAPEntries of this class

Parameters:
tagname - Name of the Root tag used to represent this class.
parenthandler - Parent LDAPXMLHandler for this tag.
Returns:
LDAPXMLHandler to handle this element.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Writes the object state to a stream in XML format

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - The ObjectOutput stream where the Object in XML format is being written to
Throws:
java.io.IOException - - If I/O errors occur

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads the serialized object from the underlying input stream.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - The ObjectInput stream where the Serialized Object is being read from
Throws:
java.io.IOException - - If I/O errors occur
java.lang.ClassNotFoundException - - If the class for an object being restored cannot be found.

getDeSerializedEntries

public java.util.Vector getDeSerializedEntries()
Returns LDAP Entries after De-serialization

Returns:
entries as Vector.

getDeSerializedControls

public LDAPControl[] getDeSerializedControls()
Returns LDAP Server Controls after De-serialization

Returns:
controls as Array.

All LDAP Classes
Internal LDAP Classes

Copyright ? 2002 Novell, Inc. All Rights Reserved.
Novell, Inc.
1800 South Novell Place
Provo, Ut 84606
Phone: (801) 861-5000