org.apache.directory.api.ldap.codec.decorators
Class LdapResultDecorator

java.lang.Object
  extended by org.apache.directory.api.ldap.codec.decorators.LdapResultDecorator
All Implemented Interfaces:
Decorator<LdapResult>, LdapResult

public class LdapResultDecorator
extends Object
implements LdapResult, Decorator<LdapResult>

A decorator for the LdapResultResponse message

Author:
Apache Directory Project

Constructor Summary
LdapResultDecorator(LdapResult decoratedLdapResult)
          Makes a LdapResult encodable.
 
Method Summary
 int computeLength()
          Compute the LdapResult length LdapResult : 0x0A 01 resultCode (0..80) 0x04 L1 matchedDN (L1 = Length(matchedDN)) 0x04 L2 errorMessage (L2 = Length(errorMessage)) [0x83 L3] referrals | +--> 0x04 L4 referral +--> 0x04 L5 referral +--> ...
 ByteBuffer encode(ByteBuffer buffer)
          Encode the LdapResult message to a PDU.
 LdapApiService getCodecService()
          Gets the codec service responsible for managing the encoding and decoding of the decorated objects.
 LdapResult getDecorated()
          Gets the object being decorated by this IDecorator.
 String getDiagnosticMessage()
          Gets the descriptive diagnostic message associated with the error code.
 byte[] getErrorMessageBytes()
           
 Dn getMatchedDn()
          Gets the lowest entry in the directory that was matched.
 byte[] getMatchedDnBytes()
           
 Referral getReferral()
          Gets the Referral associated with this LdapResult if the resultCode property is set to the REFERRAL ResultCodeEnum.
 ResultCodeEnum getResultCode()
          Gets the result code enumeration associated with the response.
 boolean isDefaultSuccess()
          Tells if the LdapResult is a success, with no added information.
 boolean isReferral()
          Gets whether or not this result represents a Referral.
 void setDiagnosticMessage(String diagnosticMessage)
          Sets the descriptive diagnostic message associated with the error code.
 void setErrorMessageBytes(byte[] errorMessageBytes)
          Set the encoded message's bytes
 void setMatchedDn(Dn dn)
          Sets the lowest entry in the directory that was matched.
 void setMatchedDnBytes(byte[] matchedDnBytes)
          Sets the encoded value for MatchedDn
 void setReferral(Referral referral)
          Sets the Referral associated with this LdapResult if the resultCode property is set to the REFERRAL ResultCodeEnum.
 void setResultCode(ResultCodeEnum resultCode)
          Sets the result code enumeration associated with the response.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LdapResultDecorator

public LdapResultDecorator(LdapResult decoratedLdapResult)
Makes a LdapResult encodable.

Parameters:
decoratedLdapResult - the decorated LdapResult
Method Detail

getErrorMessageBytes

public byte[] getErrorMessageBytes()
Returns:
The encoded Error message

setErrorMessageBytes

public void setErrorMessageBytes(byte[] errorMessageBytes)
Set the encoded message's bytes

Parameters:
errorMessageBytes - The encoded bytes

setMatchedDnBytes

public void setMatchedDnBytes(byte[] matchedDnBytes)
Sets the encoded value for MatchedDn

Parameters:
matchedDnBytes - The encoded MatchedDN

getMatchedDnBytes

public byte[] getMatchedDnBytes()
Returns:
the encoded MatchedDN

getResultCode

public ResultCodeEnum getResultCode()
Gets the result code enumeration associated with the response. Corresponds to the resultCode field within the LDAPResult ASN.1 structure.

Specified by:
getResultCode in interface LdapResult
Returns:
the result code enum value.

setResultCode

public void setResultCode(ResultCodeEnum resultCode)
Sets the result code enumeration associated with the response. Corresponds to the resultCode field within the LDAPResult ASN.1 structure.

Specified by:
setResultCode in interface LdapResult
Parameters:
resultCode - the result code enum value.

getMatchedDn

public Dn getMatchedDn()
Gets the lowest entry in the directory that was matched. For result codes of noSuchObject, aliasProblem, invalidDNSyntax and aliasDereferencingProblem, the matchedDN field is set to the name of the lowest entry (object or alias) in the directory that was matched. If no aliases were dereferenced while attempting to locate the entry, this will be a truncated form of the name provided, or if aliases were dereferenced, of the resulting name, as defined in section 12.5 of X.511 [8]. The matchedDN field is to be set to a zero length string with all other result codes.

Specified by:
getMatchedDn in interface LdapResult
Returns:
the Dn of the lowest matched entry.

setMatchedDn

public void setMatchedDn(Dn dn)
Sets the lowest entry in the directory that was matched.

Specified by:
setMatchedDn in interface LdapResult
Parameters:
dn - the Dn of the lowest matched entry.
See Also:
LdapResult.getMatchedDn()

getDiagnosticMessage

public String getDiagnosticMessage()
Gets the descriptive diagnostic message associated with the error code. May be null for SUCCESS, COMPARETRUE, COMPAREFALSE and REFERRAL operations.

Specified by:
getDiagnosticMessage in interface LdapResult
Returns:
the descriptive diagnostic message.

setDiagnosticMessage

public void setDiagnosticMessage(String diagnosticMessage)
Sets the descriptive diagnostic message associated with the error code. May be null for SUCCESS, COMPARETRUE, and COMPAREFALSE operations.

Specified by:
setDiagnosticMessage in interface LdapResult
Parameters:
diagnosticMessage - the descriptive diagnostic message.

isReferral

public boolean isReferral()
Gets whether or not this result represents a Referral. For referrals the error code is set to REFERRAL and the referral property is not null.

Specified by:
isReferral in interface LdapResult
Returns:
true if this result represents a referral.

getReferral

public Referral getReferral()
Gets the Referral associated with this LdapResult if the resultCode property is set to the REFERRAL ResultCodeEnum.

Specified by:
getReferral in interface LdapResult
Returns:
the referral on REFERRAL resultCode, null on all others.

setReferral

public void setReferral(Referral referral)
Sets the Referral associated with this LdapResult if the resultCode property is set to the REFERRAL ResultCodeEnum. Setting this property will result in a true return from isReferral and the resultCode should be set to REFERRAL.

Specified by:
setReferral in interface LdapResult
Parameters:
referral - optional referral on REFERRAL errors.

toString

public String toString()

Overrides:
toString in class Object

computeLength

public int computeLength()
Compute the LdapResult length LdapResult : 0x0A 01 resultCode (0..80) 0x04 L1 matchedDN (L1 = Length(matchedDN)) 0x04 L2 errorMessage (L2 = Length(errorMessage)) [0x83 L3] referrals | +--> 0x04 L4 referral +--> 0x04 L5 referral +--> ... +--> 0x04 Li referral +--> ... +--> 0x04 Ln referral L1 = Length(matchedDN) L2 = Length(errorMessage) L3 = n*Length(0x04) + sum(Length(L4) .. Length(Ln)) + sum(L4..Ln) L4..n = Length(0x04) + Length(Li) + Li Length(LdapResult) = Length(0x0x0A) + Length(0x01) + 1 + Length(0x04) + Length(L1) + L1 + Length(0x04) + Length(L2) + L2 + Length(0x83) + Length(L3) + L3

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

encode

public ByteBuffer encode(ByteBuffer buffer)
                  throws EncoderException
Encode the LdapResult message to a PDU.

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

getDecorated

public LdapResult getDecorated()
Gets the object being decorated by this IDecorator.

Specified by:
getDecorated in interface Decorator<LdapResult>
Returns:
The decorated object

getCodecService

public LdapApiService getCodecService()
Gets the codec service responsible for managing the encoding and decoding of the decorated objects.

Specified by:
getCodecService in interface Decorator<LdapResult>
Returns:
the codec service

isDefaultSuccess

public boolean isDefaultSuccess()
Tells if the LdapResult is a success, with no added information. The MatchedDn will be empty, as the diagnostic message and the referral. The ResultCode will always be 0.

Specified by:
isDefaultSuccess in interface LdapResult
Returns:
True if the LdapResult is SUCCESS.


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