public final class LDIFChangeRecordReader extends Object implements ChangeRecordReader
The following example reads changes from LDIF, and writes the changes to the directory server.
InputStream ldif = ...;
LDIFChangeRecordReader reader = new LDIFChangeRecordReader(ldif);
Connection connection = ...;
connection.bind(...);
ConnectionChangeRecordWriter writer =
new ConnectionChangeRecordWriter(connection);
while (reader.hasNext()) {
ChangeRecord changeRecord = reader.readChangeRecord();
writer.writeChangeRecord(changeRecord);
}
| Constructor and Description |
|---|
LDIFChangeRecordReader(InputStream in)
Creates a new LDIF change record reader whose source is the provided
input stream.
|
LDIFChangeRecordReader(List<String> ldifLines)
Creates a new LDIF change record reader which will read lines of LDIF
from the provided list of LDIF lines.
|
LDIFChangeRecordReader(Reader reader)
Creates a new LDIF change record reader whose source is the provided
character stream reader.
|
LDIFChangeRecordReader(String... ldifLines)
Creates a new LDIF change record reader which will read lines of LDIF
from the provided array of LDIF lines.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this change record reader if it not already closed.
|
boolean |
hasNext()
Returns
true if this reader contains another change record,
blocking if necessary until either the next change record is available or
the end of the stream is reached. |
ChangeRecord |
readChangeRecord()
Reads the next change record, blocking if necessary until a change record
is available.
|
LDIFChangeRecordReader |
setExcludeAllOperationalAttributes(boolean excludeOperationalAttributes)
Specifies whether or not all operational attributes should be excluded
from any change records that are read from LDIF.
|
LDIFChangeRecordReader |
setExcludeAllUserAttributes(boolean excludeUserAttributes)
Specifies whether or not all user attributes should be excluded from any
change records that are read from LDIF.
|
LDIFChangeRecordReader |
setExcludeAttribute(AttributeDescription attributeDescription)
Excludes the named attribute from any change records that are read from
LDIF.
|
LDIFChangeRecordReader |
setExcludeBranch(DN excludeBranch)
Excludes all change records which target entries beneath the named entry
(inclusive) from being read from LDIF.
|
LDIFChangeRecordReader |
setIncludeAttribute(AttributeDescription attributeDescription)
Ensures that the named attribute is not excluded from any change records
that are read from LDIF.
|
LDIFChangeRecordReader |
setIncludeBranch(DN includeBranch)
Ensures that all change records which target entries beneath the named
entry (inclusive) are read from LDIF.
|
LDIFChangeRecordReader |
setRejectedLDIFListener(RejectedLDIFListener listener)
Sets the rejected record listener which should be notified whenever an
LDIF record is skipped, malformed, or fails schema validation.
|
LDIFChangeRecordReader |
setSchema(Schema schema)
Sets the schema which should be used for decoding change records that are
read from LDIF.
|
LDIFChangeRecordReader |
setSchemaValidationPolicy(SchemaValidationPolicy policy)
Specifies the schema validation which should be used when reading LDIF
change records.
|
static ChangeRecord |
valueOfLDIFChangeRecord(String... ldifLines)
Parses the provided array of LDIF lines as a single LDIF change record.
|
public LDIFChangeRecordReader(InputStream in)
in - The input stream to use.NullPointerException - If in was null.public LDIFChangeRecordReader(List<String> ldifLines)
ldifLines - The lines of LDIF to be read.NullPointerException - If ldifLines was null.public LDIFChangeRecordReader(Reader reader)
reader - The character stream reader to use.NullPointerException - If reader was null.public LDIFChangeRecordReader(String... ldifLines)
ldifLines - The lines of LDIF to be read.NullPointerException - If ldifLines was null.public static ChangeRecord valueOfLDIFChangeRecord(String... ldifLines)
ldifLines - The lines of LDIF to be parsed.LocalizedIllegalArgumentException - If ldifLines did not contain an LDIF change record,
if it contained multiple change records, if contained
malformed LDIF, or if the change record could not be decoded
using the default schema.NullPointerException - If ldifLines was null.public void close() throws IOException
ChangeRecordReader.readChangeRecord() has returned null.close in interface Closeableclose in interface AutoCloseableclose in interface ChangeRecordReaderIOException - If an unexpected IO error occurred while closing.public boolean hasNext() throws DecodeException, IOException
true if this reader contains another change record,
blocking if necessary until either the next change record is available or
the end of the stream is reached.hasNext in interface ChangeRecordReadertrue if this reader contains another change record.DecodeException - If the change record could not be decoded because it was
malformed.IOException - If an unexpected IO error occurred.public ChangeRecord readChangeRecord() throws DecodeException, IOException
Add change record.readChangeRecord in interface ChangeRecordReaderDecodeException - If the entry could not be decoded because it was malformed.IOException - If an unexpected IO error occurred while reading the change
record.public LDIFChangeRecordReader setExcludeAllOperationalAttributes(boolean excludeOperationalAttributes)
false.excludeOperationalAttributes - true if all operational attributes should be excluded,
or false otherwise.LDIFChangeRecordReader.public LDIFChangeRecordReader setExcludeAllUserAttributes(boolean excludeUserAttributes)
false.excludeUserAttributes - true if all user attributes should be excluded, or
false otherwise.LDIFChangeRecordReader.public LDIFChangeRecordReader setExcludeAttribute(AttributeDescription attributeDescription)
attributeDescription - The name of the attribute to be excluded.LDIFChangeRecordReader.public LDIFChangeRecordReader setExcludeBranch(DN excludeBranch)
excludeBranch - The distinguished name of the branch to be excluded.LDIFChangeRecordReader.public LDIFChangeRecordReader setIncludeAttribute(AttributeDescription attributeDescription)
attributeDescription - The name of the attribute to be included.LDIFChangeRecordReader.public LDIFChangeRecordReader setIncludeBranch(DN includeBranch)
includeBranch - The distinguished name of the branch to be included.LDIFChangeRecordReader.public LDIFChangeRecordReader setRejectedLDIFListener(RejectedLDIFListener listener)
By default the RejectedLDIFListener.FAIL_FAST listener is used.
listener - The rejected record listener.LDIFChangeRecordReader.public LDIFChangeRecordReader setSchema(Schema schema)
schema - The schema which should be used for decoding change records
that are read from LDIF.LDIFChangeRecordReader.public LDIFChangeRecordReader setSchemaValidationPolicy(SchemaValidationPolicy policy)
Schema validation is disabled by default.
NOTE: this method copies the provided policy so changes made to it after this method has been called will have no effect.
policy - The schema validation which should be used when reading LDIF
change records.LDIFChangeRecordReader.Copyright © 2011-2015 ForgeRock AS. All Rights Reserved.