org.apache.directory.shared.ldap.codec.controls.search.pagedSearch
Class PagedResultsDecorator

java.lang.Object
  extended by org.apache.directory.shared.asn1.AbstractAsn1Object
      extended by org.apache.directory.shared.ldap.codec.controls.ControlDecorator<PagedResults>
          extended by org.apache.directory.shared.ldap.codec.controls.search.pagedSearch.PagedResultsDecorator
All Implemented Interfaces:
Asn1Object, CodecControl<PagedResults>, Decorator<PagedResults>, Control, PagedResults

public class PagedResultsDecorator
extends ControlDecorator<PagedResults>
implements PagedResults

A codec decorator for the PagedResultsImpl.

Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.shared.ldap.codec.controls.ControlDecorator
value, valueLength
 
Fields inherited from interface org.apache.directory.shared.ldap.model.message.controls.PagedResults
OID
 
Constructor Summary
PagedResultsDecorator(LdapCodecService codec)
          Creates a new instance of PagedResultsDecorator with a newly created decorated PagedResults Control.
PagedResultsDecorator(LdapCodecService codec, PagedResults pagedResults)
          Creates a new instance of PagedResultsDecorator using the supplied PagedResults Control to be decorated.
 
Method Summary
 int computeLength()
          Compute the PagedSearchControl length, which is the sum of the control length and the value length.
 Asn1Object decode(byte[] controlBytes)
          Decodes raw ASN.1 encoded bytes into an Asn1Object for the control.
 ByteBuffer encode(ByteBuffer buffer)
          Encodes the paged search control.
 boolean equals(Object o)
           
 byte[] getCookie()
           
 int getCookieValue()
           
 int getSize()
           
 byte[] getValue()
          Get the control value
 void setCookie(byte[] cookie)
          Set the cookie
 void setSize(int size)
          Set the number of entry requested or returned
 String toString()
          Return a String representing this PagedSearchControl.
 
Methods inherited from class org.apache.directory.shared.ldap.codec.controls.ControlDecorator
getCodecService, getDecorated, getOid, hashCode, hasValue, isCritical, setCritical, setDecorated, setValue
 
Methods inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
addLength, getCurrentLength, getExpectedLength, getParent, getTlvId, setCurrentLength, setExpectedLength, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.directory.shared.ldap.model.message.Control
getOid, isCritical, setCritical
 

Constructor Detail

PagedResultsDecorator

public PagedResultsDecorator(LdapCodecService codec)
Creates a new instance of PagedResultsDecorator with a newly created decorated PagedResults Control.


PagedResultsDecorator

public PagedResultsDecorator(LdapCodecService codec,
                             PagedResults pagedResults)
Creates a new instance of PagedResultsDecorator using the supplied PagedResults Control to be decorated.

Parameters:
pagedResults - The PagedResults Control to be decorated.
Method Detail

computeLength

public int computeLength()
Compute the PagedSearchControl length, which is the sum of the control length and the value length.
 PagedSearchControl value length :
 
 0x30 L1 
   | 
   +--> 0x02 0x0(1-4) [0..2^63-1] (size) 
   +--> 0x04 L2 (cookie)
 

Specified by:
computeLength in interface Asn1Object
Specified by:
computeLength in interface Decorator<PagedResults>
Overrides:
computeLength in class ControlDecorator<PagedResults>
Returns:
The object's computed length

encode

public ByteBuffer encode(ByteBuffer buffer)
                  throws EncoderException
Encodes the paged search control.

Specified by:
encode in interface Asn1Object
Specified by:
encode in interface Decorator<PagedResults>
Overrides:
encode in class AbstractAsn1Object
Parameters:
buffer - The encoded sink
Returns:
A ByteBuffer that contains the encoded PDU
Throws:
EncoderException - If anything goes wrong.

getValue

public byte[] getValue()
Get the control value

Specified by:
getValue in interface CodecControl<PagedResults>
Overrides:
getValue in class ControlDecorator<PagedResults>
Returns:
The control value

getSize

public int getSize()
Specified by:
getSize in interface PagedResults
Returns:
The requested or returned number of entries

setSize

public void setSize(int size)
Set the number of entry requested or returned

Specified by:
setSize in interface PagedResults
Parameters:
size - The number of entries

getCookie

public byte[] getCookie()
Specified by:
getCookie in interface PagedResults
Returns:
The stored cookie

setCookie

public void setCookie(byte[] cookie)
Set the cookie

Specified by:
setCookie in interface PagedResults
Parameters:
cookie - The cookie to store in this control

getCookieValue

public int getCookieValue()
Specified by:
getCookieValue in interface PagedResults
Returns:
The integer value for the current cookie

equals

public boolean equals(Object o)
Overrides:
equals in class ControlDecorator<PagedResults>
See Also:
Object.equals(Object)

toString

public String toString()
Return a String representing this PagedSearchControl.

Overrides:
toString in class ControlDecorator<PagedResults>

decode

public Asn1Object decode(byte[] controlBytes)
                  throws DecoderException
Decodes raw ASN.1 encoded bytes into an Asn1Object for the control.

Specified by:
decode in interface CodecControl<PagedResults>
Parameters:
controlBytes - the encoded control bytes
Returns:
the decoded Asn1Object for the control
Throws:
DecoderException - if anything goes wrong


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