com.infoengine.au
Class DirectoryInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.infoengine.au.DirectoryInputStream
All Implemented Interfaces:
java.io.Closeable

public class DirectoryInputStream
extends java.io.InputStream

This class implements an input stream class that uses the JNDI adapter to read attributes from directory entries.

Version:
1.0 7/7/2000

Constructor Summary
DirectoryInputStream()
          Constructs an instance that is not initially associated with a directory entry.
DirectoryInputStream(java.lang.String url)
          Constructs an instance that is associated with a specific directory entry.
 
Method Summary
 int available()
          Returns the number of bytes that can be read without blocking.
 void close()
          Closes the input stream and releases all resources allocated to it.
 java.lang.String getUrl()
          Returns the URL of the directory entry currently associated with the input stream.
static void main(java.lang.String[] args)
           
 void mark(int readLimit)
          Marks the current position in the input stream.
 boolean markSupported()
          Returns an indication of support for input stream marking.
 int read()
          Returns a byte from the input stream.
 int read(byte[] b)
          Reads bytes from the input stream into an array.
 int read(byte[] b, int off, int len)
          Read bytes from the input stream into an array or subarray.
 java.lang.String readLine()
          Reads a line of text from the input stream using the default character encoding for the platform.
 java.lang.String readLine(java.lang.String encoding)
          Read a line of text from the input stream using a specified character encoding.
 void reset()
          Resets the input stream to the position of the last mark set.
 void setUrl(java.lang.String url)
          Sets the URL of the directory entry associated with the input stream.
 long skip(long n)
          Reads and discards bytes from the input stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryInputStream

public DirectoryInputStream()
                     throws IEException
Constructs an instance that is not initially associated with a directory entry. Use setUrl to associate the instance with a directory entry.

Throws:
IEException - if the JNDI adapter can not be loaded or initialized successfully

DirectoryInputStream

public DirectoryInputStream(java.lang.String url)
                     throws IEException
Constructs an instance that is associated with a specific directory entry.

Parameters:
url - The LDAP URL of a directory entry. The URL must specify the attribute(s) to be read from the entry.
Throws:
IEException - if the URL can not be used to read the specified directory entry successfully, or the JNDI adapter can not be loaded or initialized successfully
Method Detail

setUrl

public void setUrl(java.lang.String url)
            throws IEException
Sets the URL of the directory entry associated with the input stream.

Parameters:
url - The LDAP URL of a directory entry. The URL must specify the attribute(s) to be read from the entry.
Throws:
IEException - if the URL can not be used to read the specified directory entry successfully

getUrl

public java.lang.String getUrl()
Returns the URL of the directory entry currently associated with the input stream.

Returns:
The LDAP URL of the directory entry currently associated with the stream.

available

public int available()
              throws java.io.IOException
Returns the number of bytes that can be read without blocking.

Overrides:
available in class java.io.InputStream
Returns:
The number of bytes that can be read without blocking.
Throws:
java.io.IOException - if the number of available bytes can not be determined.

close

public void close()
           throws java.io.IOException
Closes the input stream and releases all resources allocated to it.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - if the output stream can not be closed.

mark

public void mark(int readLimit)
Marks the current position in the input stream.

Overrides:
mark in class java.io.InputStream
Parameters:
readLimit - The position to be marked.

markSupported

public boolean markSupported()
Returns an indication of support for input stream marking.

Overrides:
markSupported in class java.io.InputStream
Returns:
true if marking is supported.

read

public int read()
         throws java.io.IOException
Returns a byte from the input stream.

Specified by:
read in class java.io.InputStream
Returns:
The next byte from input stream, or -1 if the stream is positioned at end of file.
Throws:
java.io.IOException - if the input stream can not be read.

read

public int read(byte[] b)
         throws java.io.IOException
Reads bytes from the input stream into an array. This method blocks until the array can be filled, or the end of the stream is reached.

Overrides:
read in class java.io.InputStream
Parameters:
b - The array in which to store the bytes read.
Returns:
The number of bytes stored in the array, or -1 if the input stream is positioned at end of file.
Throws:
java.io.IOException - if the input stream can not be read.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read bytes from the input stream into an array or subarray. This method blocks until the maximum specified number of bytes are read, or the end of the stream is reached.

Overrides:
read in class java.io.InputStream
Parameters:
b - The array in which to store the bytes read.
off - The offset in the array at which to begin storing bytes.
len - The maximum number of bytes to read.
Returns:
The number of bytes read, or -1 if the input stream is positioned at end of file.
Throws:
java.io.IOException - if the input stream can not be read.

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Reads a line of text from the input stream using the default character encoding for the platform.

Returns:
The line of text read, with end of line sequence removed, or null if the stream is positioned at end of file.
Throws:
java.io.IOException - if the input stream can not be read.

readLine

public java.lang.String readLine(java.lang.String encoding)
                          throws java.io.IOException
Read a line of text from the input stream using a specified character encoding.

Parameters:
encoding - The character encoding to apply to the bytes read from the input stream.
Returns:
The line of text read, with end of line sequence removed, or null if the stream is positioned at end of file.
Throws:
java.io.IOException - if the input stream can not be read.

reset

public void reset()
           throws java.io.IOException
Resets the input stream to the position of the last mark set.

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException - if the input stream can not be reset.

skip

public long skip(long n)
          throws java.io.IOException
Reads and discards bytes from the input stream.

Overrides:
skip in class java.io.InputStream
Parameters:
n - The number of bytes to read and discard.
Returns:
The actual number of bytes read and discarded.
Throws:
java.io.IOException - if the input stream can not be read.

main

public static void main(java.lang.String[] args)