org.apache.directory.shared.ldap.message
Class MessageEncoder

java.lang.Object
  extended byorg.apache.directory.shared.ldap.message.MessageEncoder
All Implemented Interfaces:
ProviderEncoder, ProviderObject, org.apache.directory.shared.asn1.codec.stateful.StatefulEncoder

public final class MessageEncoder
extends java.lang.Object
implements ProviderEncoder

Encodes a Message instance into a binary message envelope using Basic Encoding rules flushing the PDU out to an OutputStream.

Version:
$Rev: 379341 $
Author:
Apache Directory Project

Constructor Summary
MessageEncoder(java.util.Hashtable env)
          Creates a MessageEncoder using default properties for enabling a BER library provider.
 
Method Summary
 void encode(java.lang.Object obj)
          Encodes a Message object peice by peice often emitting chunks of the final PDU to the callback if present.
 java.nio.ByteBuffer encodeBlocking(java.lang.Object obj)
          Encodes a compiler stub specific ASN.1 message envelope containment tree into byte array.
 void encodeBlocking(java.lang.Object lock, java.io.OutputStream out, java.lang.Object obj)
          Encodes a compiler stub specific ASN.1 message envelope containment tree onto an output stream.
 Provider getProvider()
          Gets the Provider associated with this SPI implementation object.
 void setCallback(org.apache.directory.shared.asn1.codec.stateful.EncoderCallback cb)
          Sets the callback of the underlying implementation.
 void setEncoderMonitor(org.apache.directory.shared.asn1.codec.stateful.EncoderMonitor monitor)
          Sets the monitor of the underlying implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageEncoder

public MessageEncoder(java.util.Hashtable env)
               throws MessageException
Creates a MessageEncoder using default properties for enabling a BER library provider.

Parameters:
env - The Map of environment parameters.
Throws:
MessageException - if the encoder cannot be created.
Method Detail

encodeBlocking

public void encodeBlocking(java.lang.Object lock,
                           java.io.OutputStream out,
                           java.lang.Object obj)
                    throws ProviderException
Description copied from interface: ProviderEncoder
Encodes a compiler stub specific ASN.1 message envelope containment tree onto an output stream.

Specified by:
encodeBlocking in interface ProviderEncoder
Parameters:
lock - lock object used to exclusively write to the output stream
out - the OutputStream to encode the message envelope onto.
obj - the top-level message envelope stub instance, i.e. for the Snacc4J service provider this would be an instance of the LDAPMessage compiler generated stub class.
Throws:
ProviderException - to indicate an error while attempting to encode the message envelope onto the output stream. Provider specific exceptions encountered while encoding can be held within this subclass of MultiException.
See Also:
ProviderEncoder.encodeBlocking(Object, java.io.OutputStream, Object)

encodeBlocking

public java.nio.ByteBuffer encodeBlocking(java.lang.Object obj)
                                   throws ProviderException
Description copied from interface: ProviderEncoder
Encodes a compiler stub specific ASN.1 message envelope containment tree into byte array.

Specified by:
encodeBlocking in interface ProviderEncoder
Parameters:
obj - the top-level message envelope stub instance, i.e. for the Snacc4J service provider this would be an instance of the LDAPMessage compiler generated stub class.
Returns:
the encoded object in a byte buffer
Throws:
ProviderException - to indicate an error while attempting to encode the message envelope into a byte buffer. Provider specific exceptions encountered while encoding can be held within this subclass of MultiException.
See Also:
ProviderEncoder.encodeBlocking(Object)

getProvider

public Provider getProvider()
Description copied from interface: ProviderObject
Gets the Provider associated with this SPI implementation object.

Specified by:
getProvider in interface ProviderObject
Returns:
Provider.
See Also:
ProviderObject.getProvider()

encode

public void encode(java.lang.Object obj)
            throws org.apache.directory.shared.asn1.codec.EncoderException
Encodes a Message object peice by peice often emitting chunks of the final PDU to the callback if present.

Specified by:
encode in interface org.apache.directory.shared.asn1.codec.stateful.StatefulEncoder
Parameters:
obj - the message object to encode into a PDU
Throws:
org.apache.directory.shared.asn1.codec.EncoderException - if there are problems while encodinggg

setCallback

public void setCallback(org.apache.directory.shared.asn1.codec.stateful.EncoderCallback cb)
Sets the callback of the underlying implementation. There is no need for any special callbacks because when encoding we do not need to transform before a value return as we did in the decoder.

Specified by:
setCallback in interface org.apache.directory.shared.asn1.codec.stateful.StatefulEncoder
Parameters:
cb - the callback to set on the underlying provider specific encoder

setEncoderMonitor

public void setEncoderMonitor(org.apache.directory.shared.asn1.codec.stateful.EncoderMonitor monitor)
Sets the monitor of the underlying implementation.

Specified by:
setEncoderMonitor in interface org.apache.directory.shared.asn1.codec.stateful.StatefulEncoder
Parameters:
monitor - the monitor to set on the underlying implementation


Copyright © 2003-2006 . All Rights Reserved.