org.opends.server.tools.makeldif
Class MakeLDIFInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.opends.server.tools.makeldif.MakeLDIFInputStream
All Implemented Interfaces:
java.io.Closeable, EntryWriter

public class MakeLDIFInputStream
extends java.io.InputStream
implements EntryWriter

This class creates an input stream that can be used to read entries generated by MakeLDIF as if they were being read from another source like a file. It has a fixed-size queue that dictates how many entries may be held in memory at any given time.


Constructor Summary
MakeLDIFInputStream(TemplateFile templateFile)
          Creates a new MakeLDIF input stream that will generate entries based on the provided template file.
 
Method Summary
 void close()
          Closes this input stream so that no more data may be read from it.
 void closeEntryWriter()
          Notifies the entry writer that no more entries will be provided and that any associated cleanup may be performed.
 int read()
          Reads a single byte of data from this input stream.
 int read(byte[] b, int off, int len)
          Reads data from this input stream.
 boolean writeEntry(Entry entry)
          Writes the provided entry to the appropriate target.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MakeLDIFInputStream

public MakeLDIFInputStream(TemplateFile templateFile)
Creates a new MakeLDIF input stream that will generate entries based on the provided template file.

Parameters:
templateFile - The template file to use to generate the entries.
Method Detail

close

public void close()
Closes this input stream so that no more data may be read from it.

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

read

public int read()
         throws java.io.IOException
Reads a single byte of data from this input stream.

Specified by:
read in class java.io.InputStream
Returns:
The byte read from the input stream, or -1 if the end of the stream has been reached.
Throws:
java.io.IOException - If a problem has occurred while generating data for use by this input stream.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads data from this input stream.

Overrides:
read in class java.io.InputStream
Parameters:
b - The array into which the data should be read.
off - The position in the array at which point the data read may be placed.
len - The maximum number of bytes that may be read into the provided array.
Returns:
The number of bytes read from the input stream into the provided array, or -1 if the end of the stream has been reached.
Throws:
java.io.IOException - If a problem has occurred while generating data for use by this input stream.

writeEntry

public boolean writeEntry(Entry entry)
                   throws java.io.IOException,
                          MakeLDIFException
Writes the provided entry to the appropriate target.

Specified by:
writeEntry in interface EntryWriter
Parameters:
entry - The entry to be written.
Returns:
true if the entry writer will accept additional entries, or false if no more entries should be written.
Throws:
java.io.IOException - If a problem occurs while writing the entry to its intended destination.
MakeLDIFException - If some other problem occurs.

closeEntryWriter

public void closeEntryWriter()
Notifies the entry writer that no more entries will be provided and that any associated cleanup may be performed.

Specified by:
closeEntryWriter in interface EntryWriter