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.
|
boolean |
containsChanges()
Returns
true if changes has already been written in this LdifChangeRecordWriter . |
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.LdifChangeRecordWriter
.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.LdifChangeRecordWriter
.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.public boolean containsChanges()
true
if changes has already been written in this LdifChangeRecordWriter
.true
if changes has already been written in this LdifChangeRecordWriter
Copyright © 2010-2018, ForgeRock All Rights Reserved.