Package org.opends.server.tools.makeldif
Class MakeLDIFInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.opends.server.tools.makeldif.MakeLDIFInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable,EntryWriter
public class MakeLDIFInputStream extends 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this input stream so that no more data may be read from it.voidcloseEntryWriter()Notifies the entry writer that no more entries will be provided and that any associated cleanup may be performed.static MakeLDIFInputStreamnewStartedInputStream(TemplateFile templateFile)Creates a new MakeLDIF input stream based on the provided template file and starts generating entries in the background.intread()Reads a single byte of data from this input stream.intread(byte[] b, int off, int len)Reads data from this input stream.booleanwriteEntry(TemplateEntry entry)Writes the provided entry to the appropriate target.-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Method Detail
-
newStartedInputStream
public static MakeLDIFInputStream newStartedInputStream(TemplateFile templateFile)
Creates a new MakeLDIF input stream based on the provided template file and starts generating entries in the background.The generator thread is started here rather than by the constructor so that
thisis not published to it before construction has completed.- Parameters:
templateFile- The template file to use to generate the entries.- Returns:
- A new input stream which has started generating entries.
-
close
public void close()
Closes this input stream so that no more data may be read from it.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-
read
public int read() throws IOExceptionReads a single byte of data from this input stream.- Specified by:
readin classInputStream- Returns:
- The byte read from the input stream, or -1 if the end of the stream has been reached.
- Throws:
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 IOExceptionReads data from this input stream.- Overrides:
readin classInputStream- 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:
IOException- If a problem has occurred while generating data for use by this input stream.
-
writeEntry
public boolean writeEntry(TemplateEntry entry) throws IOException, MakeLDIFException
Description copied from interface:EntryWriterWrites the provided entry to the appropriate target.- Specified by:
writeEntryin interfaceEntryWriter- Parameters:
entry- The entry to be written.- Returns:
trueif the entry writer will accept additional entries, orfalseif no more entries should be written.- Throws:
IOException- If a problem occurs while writing the entry to its intended destination.MakeLDIFException- If some other problem occurs.
-
closeEntryWriter
public void closeEntryWriter()
Description copied from interface:EntryWriterNotifies the entry writer that no more entries will be provided and that any associated cleanup may be performed.- Specified by:
closeEntryWriterin interfaceEntryWriter
-
-