org.apache.directory.shared.ldap.codec.decorators
Class SearchRequestDecorator

java.lang.Object
  extended by org.apache.directory.shared.ldap.codec.decorators.MessageDecorator<SearchRequest>
      extended by org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator
All Implemented Interfaces:
Decorator<SearchRequest>, AbandonableRequest, ManyReplyRequest, Message, Request, ResultResponseRequest, SearchRequest

public class SearchRequestDecorator
extends MessageDecorator<SearchRequest>
implements SearchRequest

A decorator for the SearchRequest message

Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.shared.ldap.codec.decorators.MessageDecorator
messageLength
 
Fields inherited from interface org.apache.directory.shared.ldap.model.message.SearchRequest
RESPONSE_TYPES
 
Constructor Summary
SearchRequestDecorator(LdapCodecService codec, SearchRequest decoratedMessage)
          Makes a SearchRequest encodable.
 
Method Summary
 void abandon()
           
 void addAbandonListener(AbandonListener listener)
           
 void addAttributes(String... attributes)
          
 void addCurrentFilter(Filter localFilter)
          Add a current filter.
 int computeLength()
          Compute the SearchRequest length SearchRequest :
 ByteBuffer encode(ByteBuffer buffer)
          Encode the SearchRequest message to a PDU.
 int getAttributeDescriptionListLength()
           
 List<String> getAttributes()
          
 Dn getBase()
          
 Filter getCodecFilter()
          Gets the search filter associated with this search request.
 Filter getCurrentFilter()
           
 AliasDerefMode getDerefAliases()
          
 ExprNode getFilter()
          
 ExprNode getFilterNode()
          Gets the search filter associated with this search request.
 MessageTypeEnum[] getResponseTypes()
          
 ResultResponse getResultResponse()
           
 SearchScope getScope()
          
 int getSearchRequestLength()
           
 long getSizeLimit()
          
 Filter getTerminalFilter()
          Get the terminal filter
 int getTimeLimit()
          
 boolean getTypesOnly()
          
 int hashCode()
          
 boolean hasResponse()
           
 boolean isAbandoned()
           
 void removeAttribute(String attribute)
          
 void setAttributeDescriptionListLength(int attributeDescriptionListLength)
          Stores the encoded length for the list of attributes
 void setBase(Dn baseDn)
          
 void setCurrentFilter(Filter filter)
          Set the current filter
 void setDerefAliases(AliasDerefMode aliasDerefAliases)
          
 void setFilter(ExprNode filter)
          
 void setFilter(String filter)
          
 void setScope(SearchScope scope)
          
 void setSearchRequestLength(int searchRequestLength)
          Stores the encoded length for the SearchRequest
 void setSizeLimit(long entriesMax)
          
 void setTerminalFilter(Filter terminalFilter)
          Set the terminal filter
 void setTimeLimit(int secondsMax)
          
 void setTlvId(int tlvId)
          Set the SearchRequest PDU TLV's Id
 void setTypesOnly(boolean typesOnly)
          
 void unstackFilters(Asn1Container container)
          This method is used to clear the filter's stack for terminated elements.
 
Methods inherited from class org.apache.directory.shared.ldap.codec.decorators.MessageDecorator
addAllControls, addControl, get, getCodecService, getControl, getControls, getControlsLength, getCurrentControl, getDecorated, getDecorator, getMessageId, getMessageLength, getType, hasControl, put, removeControl, setControlsLength, setMessageId, setMessageLength, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.directory.shared.ldap.model.message.Message
addAllControls, addControl, get, getControl, getControls, getMessageId, getType, hasControl, put, removeControl, setMessageId
 

Constructor Detail

SearchRequestDecorator

public SearchRequestDecorator(LdapCodecService codec,
                              SearchRequest decoratedMessage)
Makes a SearchRequest encodable.

Parameters:
decoratedMessage - the decorated SearchRequest
Method Detail

setSearchRequestLength

public void setSearchRequestLength(int searchRequestLength)
Stores the encoded length for the SearchRequest

Parameters:
searchRequestLength - The encoded length

getSearchRequestLength

public int getSearchRequestLength()
Returns:
The encoded SearchRequest's length

setAttributeDescriptionListLength

public void setAttributeDescriptionListLength(int attributeDescriptionListLength)
Stores the encoded length for the list of attributes

Parameters:
attributeDescriptionListLength - The encoded length of the attributes

getAttributeDescriptionListLength

public int getAttributeDescriptionListLength()
Returns:
The encoded SearchRequest's attributes length

setTlvId

public void setTlvId(int tlvId)
Set the SearchRequest PDU TLV's Id

Parameters:
tlvId - The TLV id

getCurrentFilter

public Filter getCurrentFilter()

getCodecFilter

public Filter getCodecFilter()
Gets the search filter associated with this search request.

Returns:
the expression node for the root of the filter expression tree.

getFilterNode

public ExprNode getFilterNode()
Gets the search filter associated with this search request.

Returns:
the expression node for the root of the filter expression tree.

getTerminalFilter

public Filter getTerminalFilter()
Get the terminal filter

Returns:
Returns the terminal filter.

setTerminalFilter

public void setTerminalFilter(Filter terminalFilter)
Set the terminal filter

Parameters:
terminalFilter - the teminalFilter.

setFilter

public void setFilter(ExprNode filter)

Specified by:
setFilter in interface SearchRequest

setFilter

public void setFilter(String filter)
               throws LdapException

Specified by:
setFilter in interface SearchRequest
Throws:
LdapException

setCurrentFilter

public void setCurrentFilter(Filter filter)
Set the current filter

Parameters:
filter - The filter to set.

addCurrentFilter

public void addCurrentFilter(Filter localFilter)
                      throws DecoderException
Add a current filter. We have two cases : - there is no previous current filter : the filter is the top level filter - there is a previous current filter : the filter is added to the currentFilter set, and the current filter is changed In any case, the previous current filter will always be a ConnectorFilter when this method is called.

Parameters:
localFilter - The filter to set.
Throws:
DecoderException

unstackFilters

public void unstackFilters(Asn1Container container)
This method is used to clear the filter's stack for terminated elements. An element is considered as terminated either if : - it's a final element (ie an element which cannot contains a Filter) - its current length equals its expected length.

Parameters:
container - The container being decoded

hashCode

public int hashCode()

Overrides:
hashCode in class Object

getResponseTypes

public MessageTypeEnum[] getResponseTypes()

Specified by:
getResponseTypes in interface ManyReplyRequest
Specified by:
getResponseTypes in interface SearchRequest

getBase

public Dn getBase()

Specified by:
getBase in interface SearchRequest

setBase

public void setBase(Dn baseDn)

Specified by:
setBase in interface SearchRequest

getScope

public SearchScope getScope()

Specified by:
getScope in interface SearchRequest

setScope

public void setScope(SearchScope scope)

Specified by:
setScope in interface SearchRequest

getDerefAliases

public AliasDerefMode getDerefAliases()

Specified by:
getDerefAliases in interface SearchRequest

setDerefAliases

public void setDerefAliases(AliasDerefMode aliasDerefAliases)

Specified by:
setDerefAliases in interface SearchRequest

getSizeLimit

public long getSizeLimit()

Specified by:
getSizeLimit in interface SearchRequest

setSizeLimit

public void setSizeLimit(long entriesMax)

Specified by:
setSizeLimit in interface SearchRequest

getTimeLimit

public int getTimeLimit()

Specified by:
getTimeLimit in interface SearchRequest

setTimeLimit

public void setTimeLimit(int secondsMax)

Specified by:
setTimeLimit in interface SearchRequest

getTypesOnly

public boolean getTypesOnly()

Specified by:
getTypesOnly in interface SearchRequest

setTypesOnly

public void setTypesOnly(boolean typesOnly)

Specified by:
setTypesOnly in interface SearchRequest

getFilter

public ExprNode getFilter()

Specified by:
getFilter in interface SearchRequest

getAttributes

public List<String> getAttributes()

Specified by:
getAttributes in interface SearchRequest

addAttributes

public void addAttributes(String... attributes)

Specified by:
addAttributes in interface SearchRequest

removeAttribute

public void removeAttribute(String attribute)

Specified by:
removeAttribute in interface SearchRequest

computeLength

public int computeLength()
Compute the SearchRequest length SearchRequest :
 0x63 L1
  |
  +--> 0x04 L2 baseObject
  +--> 0x0A 0x01 scope
  +--> 0x0A 0x01 derefAliases
  +--> 0x02 0x0(1..4) sizeLimit
  +--> 0x02 0x0(1..4) timeLimit
  +--> 0x01 0x01 typesOnly
  +--> filter.computeLength()
  +--> 0x30 L3 (Attribute description list)
        |
        +--> 0x04 L4-1 Attribute description 
        +--> 0x04 L4-2 Attribute description 
        +--> ... 
        +--> 0x04 L4-i Attribute description 
        +--> ... 
        +--> 0x04 L4-n Attribute description 
        

Specified by:
computeLength in interface Decorator<SearchRequest>
Returns:
The object's computed length

encode

public ByteBuffer encode(ByteBuffer buffer)
                  throws EncoderException
Encode the SearchRequest message to a PDU. SearchRequest :
 0x63 LL
   0x04 LL baseObject
   0x0A 01 scope
   0x0A 01 derefAliases
   0x02 0N sizeLimit
   0x02 0N timeLimit
   0x01 0x01 typesOnly
   filter.encode()
   0x30 LL attributeDescriptionList
     0x04 LL attributeDescription
     ... 
     0x04 LL attributeDescription
 

Specified by:
encode in interface Decorator<SearchRequest>
Parameters:
buffer - The buffer where to put the PDU
Returns:
The PDU.
Throws:
EncoderException - if the buffer can't be encoded

getResultResponse

public ResultResponse getResultResponse()
Specified by:
getResultResponse in interface ResultResponseRequest

hasResponse

public boolean hasResponse()
Specified by:
hasResponse in interface Request

abandon

public void abandon()
Specified by:
abandon in interface AbandonableRequest

isAbandoned

public boolean isAbandoned()
Specified by:
isAbandoned in interface AbandonableRequest

addAbandonListener

public void addAbandonListener(AbandonListener listener)
Specified by:
addAbandonListener in interface AbandonableRequest


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.