Class SearchRequestImpl

All Implemented Interfaces:
AbandonableRequest, ManyReplyRequest, Message, Request, ResultResponseRequest, SearchRequest

public class SearchRequestImpl extends AbstractAbandonableRequest implements SearchRequest
SearchRequest implementation.
Author:
Apache Directory Project
  • Constructor Details

    • SearchRequestImpl

      public SearchRequestImpl()
      Creates a SearcRequest implementing object used to search the DIT.
  • Method Details

    • getAttributes

      public List<String> getAttributes()
      Gets a list of the attributes to be returned from each entry which matches the search filter. There are two special values which may be used: an empty list with no attributes, and the attribute description string "*". Both of these signify that all user attributes are to be returned. (The "*" allows the client to request all user attributes in addition to specific operational attributes). Attributes MUST be named at most once in the list, and are returned at most once in an entry. If there are attribute descriptions in the list which are not recognized, they are ignored by the server. If the client does not want any attributes returned, it can specify a list containing only the attribute with OID "1.1". This OID was chosen arbitrarily and does not correspond to any attribute in use. Client implementors should note that even if all user attributes are requested, some attributes of the entry may not be included in search results due to access control or other restrictions. Furthermore, servers will not return operational attributes, such as objectClasses or attributeTypes, unless they are listed by name, since there may be extremely large number of values for certain operational attributes.
      Specified by:
      getAttributes in interface SearchRequest
      Returns:
      the attributes to return for this request
    • getBase

      public Dn getBase()
      Gets the search base as a distinguished name.
      Specified by:
      getBase in interface SearchRequest
      Returns:
      the search base
    • setBase

      public SearchRequest setBase(Dn base)
      Sets the search base as a distinguished name.
      Specified by:
      setBase in interface SearchRequest
      Parameters:
      base - the search base
      Returns:
      The SearchRequest instance
    • getDerefAliases

      public AliasDerefMode getDerefAliases()
      Gets the alias handling parameter.
      Specified by:
      getDerefAliases in interface SearchRequest
      Returns:
      the alias handling parameter enumeration.
    • setDerefAliases

      public SearchRequest setDerefAliases(AliasDerefMode aliasDerefAliases)
      Sets the alias handling parameter.
      Specified by:
      setDerefAliases in interface SearchRequest
      Parameters:
      aliasDerefAliases - the alias handling parameter enumeration.
      Returns:
      The SearchRequest instance
    • getFilter

      public ExprNode getFilter()
      Gets the search filter associated with this search request.
      Specified by:
      getFilter in interface SearchRequest
      Returns:
      the expression node for the root of the filter expression tree.
    • setFilter

      public SearchRequest setFilter(ExprNode filter)
      Sets the search filter associated with this search request.
      Specified by:
      setFilter in interface SearchRequest
      Parameters:
      filter - the expression node for the root of the filter expression tree.
      Returns:
      The SearchRequest instance
    • setFilter

      public SearchRequest setFilter(String filter) throws LdapException
      Sets the search filter associated with this search request.
      Specified by:
      setFilter in interface SearchRequest
      Parameters:
      filter - the expression node for the root of the filter expression tree.
      Returns:
      The SearchRequest instance
      Throws:
      LdapException - If the filter can't be added
    • setFilter

      public SearchRequest setFilter(SchemaManager schemaManager, String filter) throws LdapException
      Sets the search filter associated with this search request.
      Specified by:
      setFilter in interface SearchRequest
      Parameters:
      schemaManager - the SchemaManager instance
      filter - the expression node for the root of the filter expression tree.
      Returns:
      The SearchRequest instance
      Throws:
      LdapException - If the filter can't be added
    • getResponseTypes

      public MessageTypeEnum[] getResponseTypes()
      Gets the different response types generated by a search request.
      Specified by:
      getResponseTypes in interface ManyReplyRequest
      Specified by:
      getResponseTypes in interface SearchRequest
      Returns:
      the RESPONSE_TYPES array
      See Also:
    • getScope

      public SearchScope getScope()
      Gets the search scope parameter enumeration.
      Specified by:
      getScope in interface SearchRequest
      Returns:
      the scope enumeration parameter.
    • setScope

      public SearchRequest setScope(SearchScope scope)
      Sets the search scope parameter enumeration.
      Specified by:
      setScope in interface SearchRequest
      Parameters:
      scope - the scope enumeration parameter.
      Returns:
      The SearchRequest instance
    • getSizeLimit

      public long getSizeLimit()
      A sizelimit that restricts the maximum number of entries to be returned as a result of the search. A value of 0 in this field indicates that no client-requested sizelimit restrictions are in effect for the search. Servers may enforce a maximum number of entries to return.
      Specified by:
      getSizeLimit in interface SearchRequest
      Returns:
      search size limit.
    • setSizeLimit

      public SearchRequest setSizeLimit(long entriesMax)
      Sets sizelimit that restricts the maximum number of entries to be returned as a result of the search. A value of 0 in this field indicates that no client-requested sizelimit restrictions are in effect for the search. Servers may enforce a maximum number of entries to return.
      Specified by:
      setSizeLimit in interface SearchRequest
      Parameters:
      entriesMax - maximum search result entries to return.
      Returns:
      The SearchRequest instance
    • getTimeLimit

      public int getTimeLimit()
      Gets the timelimit that restricts the maximum time (in seconds) allowed for a search. A value of 0 in this field indicates that no client- requested timelimit restrictions are in effect for the search.
      Specified by:
      getTimeLimit in interface SearchRequest
      Returns:
      the search time limit in seconds.
    • setTimeLimit

      public SearchRequest setTimeLimit(int secondsMax)
      Sets the timelimit that restricts the maximum time (in seconds) allowed for a search. A value of 0 in this field indicates that no client- requested timelimit restrictions are in effect for the search.
      Specified by:
      setTimeLimit in interface SearchRequest
      Parameters:
      secondsMax - the search time limit in seconds.
      Returns:
      The SearchRequest instance
    • getTypesOnly

      public boolean getTypesOnly()
      An indicator as to whether search results will contain both attribute types and values, or just attribute types. Setting this field to TRUE causes only attribute types (no values) to be returned. Setting this field to FALSE causes both attribute types and values to be returned.
      Specified by:
      getTypesOnly in interface SearchRequest
      Returns:
      true for only types, false for types and values.
    • setTypesOnly

      public SearchRequest setTypesOnly(boolean typesOnly)
      An indicator as to whether search results will contain both attribute types and values, or just attribute types. Setting this field to TRUE causes only attribute types (no values) to be returned. Setting this field to FALSE causes both attribute types and values to be returned.
      Specified by:
      setTypesOnly in interface SearchRequest
      Parameters:
      typesOnly - true for only types, false for types and values.
      Returns:
      The SearchRequest instance
    • addAttributes

      public SearchRequest addAttributes(String... attributesToAdd)
      Adds some attributes to the set of entry attributes to return.
      Specified by:
      addAttributes in interface SearchRequest
      Parameters:
      attributesToAdd - the attributes description or identifier.
      Returns:
      The SearchRequest instance
    • removeAttribute

      public SearchRequest removeAttribute(String attribute)
      Removes an attribute to the set of entry attributes to return.
      Specified by:
      removeAttribute in interface SearchRequest
      Parameters:
      attribute - the attribute description or identifier.
      Returns:
      The SearchRequest instance
    • getResultResponse

      public SearchResultDone getResultResponse()
      If called for the first time, this method creates a result containing response object for this request.
      Specified by:
      getResultResponse in interface ResultResponseRequest
      Returns:
      a result containing response with defaults and the messageId set in response to this specific request
    • setMessageId

      public SearchRequest setMessageId(int messageId)
      Sets the Message ID for this request
      Specified by:
      setMessageId in interface Message
      Specified by:
      setMessageId in interface SearchRequest
      Overrides:
      setMessageId in class AbstractMessage
      Parameters:
      messageId - The message Id
      Returns:
      A Message reference
    • addControl

      public SearchRequest addControl(Control control)
      Adds a control to this Message.
      Specified by:
      addControl in interface Message
      Specified by:
      addControl in interface SearchRequest
      Overrides:
      addControl in class AbstractMessage
      Parameters:
      control - the control to add.
      Returns:
      A Message reference
    • addAllControls

      public SearchRequest addAllControls(Control[] controls)
      Adds an array of controls to this Message.
      Specified by:
      addAllControls in interface Message
      Specified by:
      addAllControls in interface SearchRequest
      Overrides:
      addAllControls in class AbstractMessage
      Parameters:
      controls - the controls to add.
      Returns:
      A Message reference
    • removeControl

      public SearchRequest removeControl(Control control)
      Deletes a control removing it from this Message.
      Specified by:
      removeControl in interface Message
      Specified by:
      removeControl in interface SearchRequest
      Overrides:
      removeControl in class AbstractMessage
      Parameters:
      control - the control to remove.
      Returns:
      A Message reference
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractRequest
      Returns:
      the instance's hash code
      See Also:
    • equals

      public boolean equals(Object obj)
      Checks to see if two search requests are equal. The Lockable properties and the get/set context specific parameters are not consulted to determine equality. The filter expression tree comparison will normalize the child order of filter branch nodes then generate a string representation which is comparable. For the time being this is a very costly operation.
      Overrides:
      equals in class AbstractRequest
      Parameters:
      obj - the object to check for equality to this SearchRequest
      Returns:
      true if the obj is a SearchRequest and equals this SearchRequest, false otherwise
    • toString

      public String toString()
      Return a string the represent a SearchRequest
      Overrides:
      toString in class Object
    • isFollowReferrals

      public boolean isFollowReferrals()
      Tells the client if it should follow referrals instead of throwing exceptions
      Specified by:
      isFollowReferrals in interface SearchRequest
      Returns:
      true if we should follow the referrals
    • followReferrals

      public SearchRequest followReferrals()
      Tells the client to follow referrals instead of throwing exceptions
      Specified by:
      followReferrals in interface SearchRequest
      Returns:
      The SearchRequest instance
    • isIgnoreReferrals

      public boolean isIgnoreReferrals()
      Tells the client if it should ignore referrals instead of throwing exceptions
      Specified by:
      isIgnoreReferrals in interface SearchRequest
      Returns:
      true if we should ignore the referrals
    • ignoreReferrals

      public SearchRequest ignoreReferrals()
      Tells the client to ignore referrals instead of throwing exceptions. The entry will contain the referral attributeType with the link.
      Specified by:
      ignoreReferrals in interface SearchRequest
      Returns:
      The SearchRequest instance