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 all operational attributes should be excluded
from any change records that are read from LDIF.
|
LdifChangeRecordReader |
setExcludeAllUserAttributes(boolean excludeUserAttributes)
Specifies whether 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.
|
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 void close() throws IOException
ChangeRecordReader
ChangeRecordReader.readChangeRecord()
has returned null
.close
in interface Closeable
close
in interface AutoCloseable
close
in interface ChangeRecordReader
IOException
- If an unexpected IO error occurred while closing.public boolean hasNext() throws 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 ChangeRecordReader
true
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 IOException
Add
change record.readChangeRecord
in interface ChangeRecordReader
DecodeException
- 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 © 2010-2018, ForgeRock All Rights Reserved.