org.opends.server.protocols.internal
Class InternalLDAPOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.opends.server.protocols.internal.InternalLDAPOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, InternalSearchListener

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=false,
           mayExtend=false,
           mayInvoke=true)
public final class InternalLDAPOutputStream
extends java.io.OutputStream
implements InternalSearchListener

This class provides an implementation of a java.io.OutputStream that can be used to facilitate internal communication with the Directory Server. On the backend, data written to this output stream will be first decoded as an ASN.1 element and then as an LDAP message. That LDAP message will be converted to an internal operation which will then be processed and the result returned to the client via the input stream on the other side of the associated internal LDAP socket.


Constructor Summary
InternalLDAPOutputStream(InternalLDAPSocket socket)
          Creates a new instance of an internal LDAP output stream that is associated with the provided internal LDAP socket.
 
Method Summary
 void close()
          Closes this output stream, its associated socket, and the socket's associated input stream.
 void flush()
          Flushes this output stream and forces any buffered data to be written out.
 void handleInternalSearchEntry(InternalSearchOperation searchOperation, SearchResultEntry searchEntry)
          Performs any processing necessary for the provided search result entry.
 void handleInternalSearchReference(InternalSearchOperation searchOperation, SearchResultReference searchReference)
          Performs any processing necessary for the provided search result reference.
 java.lang.String toString()
          Retrieves a string representation of this internal LDAP socket.
 void write(byte[] b)
          Writes the contents of the provided byte array to this output stream.
 void write(byte[] b, int off, int len)
          Writes the specified portion of the data in the provided byte array to this output stream.
 void write(int b)
          Writes a single byte of data to this output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InternalLDAPOutputStream

public InternalLDAPOutputStream(InternalLDAPSocket socket)
Creates a new instance of an internal LDAP output stream that is associated with the provided internal LDAP socket.

Parameters:
socket - The internal LDAP socket that will be serviced by this internal LDAP output stream.
Method Detail

close

public void close()
Closes this output stream, its associated socket, and the socket's associated input stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream

flush

public void flush()
Flushes this output stream and forces any buffered data to be written out. This will have no effect, since this output stream implementation does not use buffering.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream

write

public void write(byte[] b)
           throws java.io.IOException
Writes the contents of the provided byte array to this output stream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - The byte array to be written.
Throws:
java.io.IOException - If the output stream is closed, or if there is a problem with the data being written.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes the specified portion of the data in the provided byte array to this output stream. Any data written will be accumulated until a complete ASN.1 element is available, at which point it will be decoded as an LDAP message and converted to an internal operation that will be processed.

Overrides:
write in class java.io.OutputStream
Parameters:
b - The byte array containing the data to be read.
off - The position in the array at which to start reading data.
len - The number of bytes to read from the array.
Throws:
java.io.IOException - If the output stream is closed, or if there is a problem with the data being written.

write

public void write(int b)
           throws java.io.IOException
Writes a single byte of data to this output stream. If the byte written completes an ASN.1 element that was in progress, then it will be decoded as an LDAP message and converted to an internal operation that will be processed. Otherwise, the data will be accumulated until a complete element can be formed.

Specified by:
write in class java.io.OutputStream
Parameters:
b - The byte to be written.
Throws:
java.io.IOException - If the output stream is closed, or if there is a problem with the data being written.

handleInternalSearchEntry

@PublicAPI(stability=PRIVATE,
           mayInstantiate=false,
           mayExtend=false,
           mayInvoke=false)
public void handleInternalSearchEntry(InternalSearchOperation searchOperation,
                                                                                                SearchResultEntry searchEntry)
Performs any processing necessary for the provided search result entry.

Specified by:
handleInternalSearchEntry in interface InternalSearchListener
Parameters:
searchOperation - The internal search operation being processed.
searchEntry - The matching search result entry to be processed.

handleInternalSearchReference

@PublicAPI(stability=PRIVATE,
           mayInstantiate=false,
           mayExtend=false,
           mayInvoke=false)
public void handleInternalSearchReference(InternalSearchOperation searchOperation,
                                                                                                    SearchResultReference searchReference)
Performs any processing necessary for the provided search result reference.

Specified by:
handleInternalSearchReference in interface InternalSearchListener
Parameters:
searchOperation - The internal search operation being processed.
searchReference - The search result reference to be processed.

toString

public java.lang.String toString()
Retrieves a string representation of this internal LDAP socket.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this internal LDAP socket.