org.opends.server.tools
Class LDAPSearch

java.lang.Object
  extended by org.opends.server.tools.LDAPSearch

public class LDAPSearch
extends java.lang.Object

This class provides a tool that can be used to issue search requests to the Directory Server.


Constructor Summary
LDAPSearch(java.util.concurrent.atomic.AtomicInteger nextMessageID, java.io.PrintStream out, java.io.PrintStream err)
          Constructor for the LDAPSearch object.
 
Method Summary
 int executeSearch(LDAPConnection connection, java.lang.String baseDN, java.util.ArrayList<LDAPFilter> filters, java.util.LinkedHashSet<java.lang.String> attributes, LDAPSearchOptions searchOptions, int wrapColumn)
          Execute the search based on the specified input parameters.
 java.util.ArrayList<LDAPControl> getResponseControls()
          Retrieves the set of response controls included in the last search result done message.
static void main(java.lang.String[] args)
          The main method for LDAPSearch tool.
static int mainSearch(java.lang.String[] args)
          Parses the provided command-line arguments and uses that information to run the ldapsearch tool.
static int mainSearch(java.lang.String[] args, boolean initializeServer, java.io.OutputStream outStream, java.io.OutputStream errStream)
          Parses the provided command-line arguments and uses that information to run the ldapsearch tool.
 void toLDIF(SearchResultEntryProtocolOp entry, java.lang.StringBuilder buffer, int wrapColumn, boolean typesOnly)
          Appends an LDIF representation of the entry to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDAPSearch

public LDAPSearch(java.util.concurrent.atomic.AtomicInteger nextMessageID,
                  java.io.PrintStream out,
                  java.io.PrintStream err)
Constructor for the LDAPSearch object.

Parameters:
nextMessageID - The message ID counter to use for requests.
out - The print stream to use for standard output.
err - The print stream to use for standard error.
Method Detail

executeSearch

public int executeSearch(LDAPConnection connection,
                         java.lang.String baseDN,
                         java.util.ArrayList<LDAPFilter> filters,
                         java.util.LinkedHashSet<java.lang.String> attributes,
                         LDAPSearchOptions searchOptions,
                         int wrapColumn)
                  throws java.io.IOException,
                         LDAPException
Execute the search based on the specified input parameters.

Parameters:
connection - The connection to use for the search.
baseDN - The base DN for the search request.
filters - The filters to use for the results.
attributes - The attributes to return in the results.
searchOptions - The constraints for the search.
wrapColumn - The column at which to wrap long lines.
Returns:
The number of matching entries returned by the server. If there were multiple search filters provided, then this will be the total number of matching entries for all searches.
Throws:
java.io.IOException - If a problem occurs while attempting to communicate with the Directory Server.
LDAPException - If the Directory Server returns an error response.

toLDIF

public void toLDIF(SearchResultEntryProtocolOp entry,
                   java.lang.StringBuilder buffer,
                   int wrapColumn,
                   boolean typesOnly)
Appends an LDIF representation of the entry to the provided buffer.

Parameters:
entry - The entry to be written as LDIF.
buffer - The buffer to which the entry should be appended.
wrapColumn - The column at which long lines should be wrapped.
typesOnly - Indicates whether to include only attribute types without values.

getResponseControls

public java.util.ArrayList<LDAPControl> getResponseControls()
Retrieves the set of response controls included in the last search result done message.

Returns:
The set of response controls included in the last search result done message.

main

public static void main(java.lang.String[] args)
The main method for LDAPSearch tool.

Parameters:
args - The command-line arguments provided to this program.

mainSearch

public static int mainSearch(java.lang.String[] args)
Parses the provided command-line arguments and uses that information to run the ldapsearch tool.

Parameters:
args - The command-line arguments provided to this program.
Returns:
The error code.

mainSearch

public static int mainSearch(java.lang.String[] args,
                             boolean initializeServer,
                             java.io.OutputStream outStream,
                             java.io.OutputStream errStream)
Parses the provided command-line arguments and uses that information to run the ldapsearch tool.

Parameters:
args - The command-line arguments provided to this program.
initializeServer - Indicates whether to initialize the server.
outStream - The output stream to use for standard output, or null if standard output is not needed.
errStream - The output stream to use for standard error, or null if standard error is not needed.
Returns:
The error code.