@PublicAPI(stability=UNCOMMITTED, mayInstantiate=true, mayExtend=false, mayInvoke=true) public final class LDIFWriter extends Object implements Closeable
Constructor and Description |
---|
LDIFWriter(LDIFExportConfig exportConfig)
Creates a new LDIF writer with the provided configuration.
|
Modifier and Type | Method and Description |
---|---|
static void |
appendLDIFSeparatorAndValue(StringBuilder buffer,
org.forgerock.opendj.ldap.ByteSequence valueBytes)
Appends an LDIF separator and properly-encoded form of the given
value to the provided buffer.
|
static void |
appendLDIFSeparatorAndValue(StringBuilder buffer,
org.forgerock.opendj.ldap.ByteSequence valueBytes,
boolean isURL,
boolean isBase64)
Appends an LDIF separator and properly-encoded form of the given
value to the provided buffer.
|
void |
close()
Closes the LDIF writer and the underlying output stream or file.
|
void |
flush()
Flushes the data written to the output stream or underlying file.
|
void |
writeAddChangeRecord(Entry entry)
Writes an add change record for the provided entry.
|
void |
writeChangeRecord(ChangeRecordEntry changeRecord)
Writes a change record entry for the provided change record.
|
void |
writeComment(LocalizableMessage comment,
int wrapColumn)
Writes the provided comment to the LDIF file, optionally wrapping near the
specified column.
|
void |
writeDeleteChangeRecord(Entry entry,
boolean commentEntry)
Writes a delete change record for the provided entry, optionally including
a comment with the full entry contents.
|
boolean |
writeEntries(Collection<Entry> entries)
Iterates over each entry contained in the map and writes out the entry in
LDIF format.
|
boolean |
writeEntry(Entry entry)
Writes the provided entry to LDIF.
|
static void |
writeLDIFLine(StringBuilder line,
BufferedWriter writer,
boolean wrapLines,
int wrapColumn)
Writes the provided line to LDIF using the provided information.
|
void |
writeModifyChangeRecord(org.forgerock.opendj.ldap.Dn dn,
List<Modification> modifications)
Writes a modify change record with the provided information.
|
void |
writeModifyDNChangeRecord(org.forgerock.opendj.ldap.Dn dn,
org.forgerock.opendj.ldap.Rdn newRDN,
boolean deleteOldRDN,
org.forgerock.opendj.ldap.Dn newSuperior)
Writes a modify DN change record with the provided information.
|
boolean |
writeTemplateEntry(TemplateEntry templateEntry)
Writes the provided template entry to LDIF.
|
public LDIFWriter(LDIFExportConfig exportConfig) throws IOException
exportConfig
- The configuration to use for the export. It must not
be null
.IOException
- If a problem occurs while opening the writer.public void writeComment(LocalizableMessage comment, int wrapColumn) throws IOException
comment
- The comment to be written. Any line breaks that it
contains will be honored, and potentially new line
breaks may be introduced by the wrapping process. It
must not be null
.wrapColumn
- The column at which long lines should be wrapped, or
-1 to indicate that no additional wrapping should be
added. This will override the wrap column setting
specified in the LDIF export configuration.IOException
- If a problem occurs while attempting to write the
comment to the LDIF file.public boolean writeEntries(Collection<Entry> entries) throws IOException, LDIFException
entries
- The Map containing the entries keyed by DN.true
of all of the entries were
written out, false
if it was not
because of the export configuration.IOException
- If a problem occurs while writing the entry to LDIF.LDIFException
- If a problem occurs while trying to determine
whether to include the entry in the export.public boolean writeEntry(Entry entry) throws IOException, LDIFException
entry
- The entry to be written. It must not be null
.true
if the entry was actually written, or
false
if it was not because of the export
configuration.IOException
- If a problem occurs while writing the entry to LDIF.LDIFException
- If a problem occurs while trying to determine
whether to include the entry in the export.public boolean writeTemplateEntry(TemplateEntry templateEntry) throws IOException, LDIFException
templateEntry
- The template entry to be written. It must not be
null
.true
if the entry was actually written, or
false
if it was not because of the export
configuration.IOException
- If a problem occurs while writing the template entry
to LDIF.LDIFException
- If a problem occurs while trying to determine
whether to include the template entry in the
export.public void writeChangeRecord(ChangeRecordEntry changeRecord) throws IOException
changeRecord
- The change record entry to be written.IOException
- If a problem occurs while writing the change record.public void writeAddChangeRecord(Entry entry) throws IOException
entry
- The entry to include in the add change record. It must not
be null
.IOException
- If a problem occurs while writing the add record.public void writeDeleteChangeRecord(Entry entry, boolean commentEntry) throws IOException
entry
- The entry to include in the delete change record. It
must not be null
.commentEntry
- Indicates whether to include a comment with the
contents of the entry.IOException
- If a problem occurs while writing the delete record.public void writeModifyChangeRecord(org.forgerock.opendj.ldap.Dn dn, List<Modification> modifications) throws IOException
dn
- The DN of the entry being modified. It must not be
null
.modifications
- The set of modifications to include in the change
record. It must not be null
.IOException
- If a problem occurs while writing the modify record.public void writeModifyDNChangeRecord(org.forgerock.opendj.ldap.Dn dn, org.forgerock.opendj.ldap.Rdn newRDN, boolean deleteOldRDN, org.forgerock.opendj.ldap.Dn newSuperior) throws IOException
dn
- The DN of the entry before the rename. It must not
be null
.newRDN
- The new RDN for the entry. It must not be
null
.deleteOldRDN
- Indicates whether the old RDN value should be removed
from the entry.newSuperior
- The new superior DN for the entry, or
null
if the entry will stay below the
same parent.IOException
- If a problem occurs while writing the modify record.public void flush() throws IOException
IOException
- If a problem occurs while flushing the output.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- If a problem occurs while closing the writer.public static void appendLDIFSeparatorAndValue(StringBuilder buffer, org.forgerock.opendj.ldap.ByteSequence valueBytes)
buffer
- The buffer to which the information should be
appended. It must not be null
.valueBytes
- The value to append to the buffer. It must not be
null
.public static void appendLDIFSeparatorAndValue(StringBuilder buffer, org.forgerock.opendj.ldap.ByteSequence valueBytes, boolean isURL, boolean isBase64)
buffer
- The buffer to which the information should be
appended. It must not be null
.valueBytes
- The value to append to the buffer. It must not be
null
.isURL
- Whether the provided value is an URL value or not.isBase64
- Whether the provided value is a base 64 value or not.public static void writeLDIFLine(StringBuilder line, BufferedWriter writer, boolean wrapLines, int wrapColumn) throws IOException
line
- The line of information to write. It must not be
null
.writer
- The writer to which the data should be written. It
must not be null
.wrapLines
- Indicates whether to wrap long lines.wrapColumn
- The column at which long lines should be wrapped.IOException
- If a problem occurs while writing the information.Copyright © 2010-2017 ForgeRock AS. All Rights Reserved.