org.opends.server.protocols.internal
Class InternalLDAPInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.opends.server.protocols.internal.InternalLDAPInputStream
All Implemented Interfaces:
java.io.Closeable

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=false,
           mayExtend=false,
           mayInvoke=true)
public final class InternalLDAPInputStream
extends java.io.InputStream

This class provides an implementation of a java.io.InputStream that can be used to facilitate internal communication with the Directory Server. On the backend, this input stream will be populated by ASN.1 elements encoded from LDAP messages created from internal operation responses.


Constructor Summary
InternalLDAPInputStream(InternalLDAPSocket socket)
          Creates a new internal LDAP input stream that will service the provided internal LDAP socket.
 
Method Summary
 int available()
          Retrieves the number of bytes that can be read (or skipped over) from this input stream without blocking.
 void close()
          Closes this input stream.
 void mark(int readLimit)
          Marks the current position in the input stream.
 boolean markSupported()
          Indicates whether this input stream inplementation supports the use of the mark and reset methods.
 int read()
          Reads the next byte of data from the input stream, blocking if necessary until there is data available.
 int read(byte[] b)
          Reads some number of bytes from the input stream, blocking if necessary until there is data available, and adds them to the provided array starting at position 0.
 int read(byte[] b, int off, int len)
          Reads some number of bytes from the input stream, blocking if necessary until there is data available, and adds them to the provided array starting at the specified position.
 void reset()
          Repositions this stream to the position at the time that the mark method was called on this stream.
 long skip(long n)
          Skips over and discards up to the specified number of bytes of data from this input stream.
 java.lang.String toString()
          Retrieves a string representation of this internal LDAP socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InternalLDAPInputStream

public InternalLDAPInputStream(InternalLDAPSocket socket)
Creates a new internal LDAP input stream that will service the provided internal LDAP socket.

Parameters:
socket - The internal LDAP socket serviced by this internal LDAP input stream.
Method Detail

available

public int available()
Retrieves the number of bytes that can be read (or skipped over) from this input stream without blocking.

Overrides:
available in class java.io.InputStream
Returns:
The number of bytes that can be read (or skipped over) from this input stream wihtout blocking.

close

public void close()
Closes this input stream. This will add a special marker element to the message queue indicating that the end of the stream has been reached. If the queue is full, thenit will be cleared before adding the marker element.

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

mark

public void mark(int readLimit)
Marks the current position in the input stream. This will not have any effect, as this input stream inplementation does not support marking.

Overrides:
mark in class java.io.InputStream
Parameters:
readLimit - The maximum limit of bytes that can be read before the mark position becomes invalid.

markSupported

public boolean markSupported()
Indicates whether this input stream inplementation supports the use of the mark and reset methods. This implementation does not support that functionality.

Overrides:
markSupported in class java.io.InputStream
Returns:
false because this implementation does not support the use of the mark and reset methods.

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the input stream, blocking if necessary until there is data available.

Specified by:
read in class java.io.InputStream
Returns:
The next byte of data read from the input stream, or -1 if the end of the input stream has been reached.
Throws:
java.io.IOException - If a problem occurs while trying to read data from the stream.

read

public int read(byte[] b)
         throws java.io.IOException
Reads some number of bytes from the input stream, blocking if necessary until there is data available, and adds them to the provided array starting at position 0.

Overrides:
read in class java.io.InputStream
Parameters:
b - The array to which the data is to be written.
Returns:
The number of bytes actually written into the provided array, or -1 if the end of the stream has been reached.
Throws:
java.io.IOException - If a problem occurs while trying to read data from the stream.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads some number of bytes from the input stream, blocking if necessary until there is data available, and adds them to the provided array starting at the specified position.

Overrides:
read in class java.io.InputStream
Parameters:
b - The array to which the data is to be written.
off - The offset in the array at which to start writing data.
len - The maximum number of bytes that may be added to the array.
Returns:
The number of bytes actually written into the provided array, or -1 if the end of the stream has been reached.
Throws:
java.io.IOException - If a problem occurs while trying to read data from the stream.

reset

public void reset()
Repositions this stream to the position at the time that the mark method was called on this stream. This will not have any effect, as this input stream inplementation does not support marking.

Overrides:
reset in class java.io.InputStream

skip

public long skip(long n)
          throws java.io.IOException
Skips over and discards up to the specified number of bytes of data from this input stream. This implementation will always skip the requested number of bytes unless the end of the stream is reached.

Overrides:
skip in class java.io.InputStream
Parameters:
n - The maximum number of bytes to skip.
Returns:
The number of bytes actually skipped.
Throws:
java.io.IOException - If a problem occurs while trying to read data from the input stream.

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.