public final class LDIFChangeRecordWriter extends Object implements ChangeRecordWriter
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 |
---|
LDIFChangeRecordWriter(List<String> ldifLines)
Creates a new LDIF change record writer which will append lines of LDIF
to the provided list.
|
LDIFChangeRecordWriter(OutputStream out)
Creates a new LDIF change record writer whose destination is the provided
output stream.
|
LDIFChangeRecordWriter(Writer writer)
Creates a new LDIF change record writer whose destination is the provided
character stream writer.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this change record writer, flushing it first.
|
void |
flush()
Flushes this change record writer so that any buffered data is written
immediately to underlying stream, flushing the stream if it is also
Flushable . |
LDIFChangeRecordWriter |
setAddUserFriendlyComments(boolean addUserFriendlyComments)
Specifies whether user-friendly comments should be added whenever
distinguished names or UTF-8 attribute values are encountered which
contained non-ASCII characters.
|
LDIFChangeRecordWriter |
setExcludeAllOperationalAttributes(boolean excludeOperationalAttributes)
Specifies whether all operational attributes should be excluded
from any change records that are written to LDIF.
|
LDIFChangeRecordWriter |
setExcludeAllUserAttributes(boolean excludeUserAttributes)
Specifies whether all user attributes should be excluded from any
change records that are written to LDIF.
|
LDIFChangeRecordWriter |
setExcludeAttribute(AttributeDescription attributeDescription)
Excludes the named attribute from any change records that are written to
LDIF.
|
LDIFChangeRecordWriter |
setExcludeBranch(DN excludeBranch)
Excludes all change records which target entries beneath the named entry
(inclusive) from being written to LDIF.
|
LDIFChangeRecordWriter |
setIncludeAttribute(AttributeDescription attributeDescription)
Ensures that the named attribute is not excluded from any change records
that are written to LDIF.
|
LDIFChangeRecordWriter |
setIncludeBranch(DN includeBranch)
Ensures that all change records which target entries beneath the named
entry (inclusive) are written to LDIF.
|
LDIFChangeRecordWriter |
setWrapColumn(int wrapColumn)
Specifies the column at which long lines should be wrapped.
|
static String |
toString(ChangeRecord change)
Returns the LDIF string representation of the provided change record.
|
LDIFChangeRecordWriter |
writeChangeRecord(AddRequest change)
Writes an
Add change record. |
LDIFChangeRecordWriter |
writeChangeRecord(ChangeRecord change)
Writes a change record.
|
LDIFChangeRecordWriter |
writeChangeRecord(DeleteRequest change)
Writes a
Delete change record. |
LDIFChangeRecordWriter |
writeChangeRecord(ModifyDNRequest change)
Writes a
ModifyDN change record. |
LDIFChangeRecordWriter |
writeChangeRecord(ModifyRequest change)
Writes a
Modify change record. |
LDIFChangeRecordWriter |
writeComment(CharSequence comment)
Writes a comment.
|
public LDIFChangeRecordWriter(List<String> ldifLines)
ldifLines
- The list to which lines of LDIF should be appended.public LDIFChangeRecordWriter(OutputStream out)
out
- The output stream to use.public LDIFChangeRecordWriter(Writer writer)
writer
- The character stream writer to use.public static String toString(ChangeRecord change)
change
- The change record.public void close() throws IOException
ChangeRecordWriter
close
in interface Closeable
close
in interface AutoCloseable
close
in interface ChangeRecordWriter
IOException
- If an unexpected IO error occurred while closing.public void flush() throws IOException
ChangeRecordWriter
Flushable
.
If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
flush
in interface Flushable
flush
in interface ChangeRecordWriter
IOException
- If an unexpected IO error occurred while flushing.public LDIFChangeRecordWriter setAddUserFriendlyComments(boolean addUserFriendlyComments)
false
.addUserFriendlyComments
- true
if user-friendly comments should be added, or
false
otherwise.LDIFEntryWriter
.public LDIFChangeRecordWriter setExcludeAllOperationalAttributes(boolean excludeOperationalAttributes)
false
.excludeOperationalAttributes
- true
if all operational attributes should be excluded,
or false
otherwise.LDIFChangeRecordWriter
.public LDIFChangeRecordWriter setExcludeAllUserAttributes(boolean excludeUserAttributes)
false
.excludeUserAttributes
- true
if all user attributes should be excluded, or
false
otherwise.LDIFChangeRecordWriter
.public LDIFChangeRecordWriter setExcludeAttribute(AttributeDescription attributeDescription)
attributeDescription
- The name of the attribute to be excluded.LDIFChangeRecordWriter
.public LDIFChangeRecordWriter setExcludeBranch(DN excludeBranch)
excludeBranch
- The distinguished name of the branch to be excluded.LDIFChangeRecordWriter
.public LDIFChangeRecordWriter setIncludeAttribute(AttributeDescription attributeDescription)
attributeDescription
- The name of the attribute to be included.LDIFChangeRecordWriter
.public LDIFChangeRecordWriter setIncludeBranch(DN includeBranch)
includeBranch
- The distinguished name of the branch to be included.LDIFChangeRecordWriter
.public LDIFChangeRecordWriter setWrapColumn(int wrapColumn)
wrapColumn
- The column at which long lines should be wrapped.LDIFEntryWriter
.public LDIFChangeRecordWriter writeChangeRecord(AddRequest change) throws IOException
ChangeRecordWriter
Add
change record.writeChangeRecord
in interface ChangeRecordWriter
change
- The AddRequest
to be written as an Add
change
record.IOException
- If an unexpected IO error occurred while writing the change
record.public LDIFChangeRecordWriter writeChangeRecord(ChangeRecord change) throws IOException
ChangeRecordWriter
writeChangeRecord
in interface ChangeRecordWriter
change
- The ChangeRecord
to be written.IOException
- If an unexpected IO error occurred while writing the change
record.public LDIFChangeRecordWriter writeChangeRecord(DeleteRequest change) throws IOException
ChangeRecordWriter
Delete
change record.writeChangeRecord
in interface ChangeRecordWriter
change
- The DeleteRequest
to be written as an Delete
change record.IOException
- If an unexpected IO error occurred while writing the change
record.public LDIFChangeRecordWriter writeChangeRecord(ModifyDNRequest change) throws IOException
ChangeRecordWriter
ModifyDN
change record.writeChangeRecord
in interface ChangeRecordWriter
change
- The ModifyDNRequest
to be written as an
ModifyDN
change record.IOException
- If an unexpected IO error occurred while writing the change
record.public LDIFChangeRecordWriter writeChangeRecord(ModifyRequest change) throws IOException
ChangeRecordWriter
Modify
change record.writeChangeRecord
in interface ChangeRecordWriter
change
- The ModifyRequest
to be written as an Modify
change record.IOException
- If an unexpected IO error occurred while writing the change
record.public LDIFChangeRecordWriter writeComment(CharSequence comment) throws IOException
ChangeRecordWriter
writeComment
in interface ChangeRecordWriter
comment
- The CharSequence
to be written as a comment.IOException
- If an unexpected IO error occurred while writing the comment.Copyright 2010-2017 ForgeRock AS.