mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
28.47.2010 f2160f4bd1c8ac67e5a86a6710d431e8932877f9
sdk/src/org/opends/sdk/ldif/LDIFEntryWriter.java
@@ -41,25 +41,24 @@
/**
 * An LDIF entry writer writes attribute value records (entries) using
 * the LDAP Data Interchange Format (LDIF) to a user defined
 * destination.
 * An LDIF entry writer writes attribute value records (entries) using the LDAP
 * Data Interchange Format (LDIF) to a user defined destination.
 *
 * @see <a href="http://tools.ietf.org/html/rfc2849">RFC 2849 - The LDAP
 *      Data Interchange Format (LDIF) - Technical Specification </a>
 * @see <a href="http://tools.ietf.org/html/rfc2849">RFC 2849 - The LDAP Data
 *      Interchange Format (LDIF) - Technical Specification </a>
 */
public final class LDIFEntryWriter extends AbstractLDIFWriter implements
    EntryWriter
{
  /**
   * Creates a new LDIF entry writer which will append lines of LDIF to
   * the provided list.
   * Creates a new LDIF entry writer which will append lines of LDIF to the
   * provided list.
   *
   * @param ldifLines
   *          The list to which lines of LDIF should be appended.
   */
  public LDIFEntryWriter(List<String> ldifLines)
  public LDIFEntryWriter(final List<String> ldifLines)
  {
    super(ldifLines);
  }
@@ -67,13 +66,13 @@
  /**
   * Creates a new LDIF entry writer whose destination is the provided
   * output stream.
   * Creates a new LDIF entry writer whose destination is the provided output
   * stream.
   *
   * @param out
   *          The output stream to use.
   */
  public LDIFEntryWriter(OutputStream out)
  public LDIFEntryWriter(final OutputStream out)
  {
    super(out);
  }
@@ -101,18 +100,17 @@
  /**
   * Specifies whether or not user-friendly comments should be added
   * whenever distinguished names or UTF-8 attribute values are
   * encountered which contained non-ASCII characters. The default is
   * {@code false}.
   * Specifies whether or not user-friendly comments should be added whenever
   * distinguished names or UTF-8 attribute values are encountered which
   * contained non-ASCII characters. The default is {@code false}.
   *
   * @param addUserFriendlyComments
   *          {@code true} if user-friendly comments should be added, or
   *          {@code false} otherwise.
   *          {@code true} if user-friendly comments should be added, or {@code
   *          false} otherwise.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setAddUserFriendlyComments(
      boolean addUserFriendlyComments)
      final boolean addUserFriendlyComments)
  {
    this.addUserFriendlyComments = addUserFriendlyComments;
    return this;
@@ -121,17 +119,16 @@
  /**
   * Specifies whether or not all operational attributes should be
   * excluded from any entries that are written to LDIF. The default is
   * {@code false}.
   * Specifies whether or not all operational attributes should be excluded from
   * any entries that are written to LDIF. The default is {@code false}.
   *
   * @param excludeOperationalAttributes
   *          {@code true} if all operational attributes should be
   *          excluded, or {@code false} otherwise.
   *          {@code true} if all operational attributes should be excluded, or
   *          {@code false} otherwise.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setExcludeAllOperationalAttributes(
      boolean excludeOperationalAttributes)
      final boolean excludeOperationalAttributes)
  {
    this.excludeOperationalAttributes = excludeOperationalAttributes;
    return this;
@@ -140,17 +137,16 @@
  /**
   * Specifies whether or not all user attributes should be excluded
   * from any entries that are written to LDIF. The default is {@code
   * false}.
   * Specifies whether or not all user attributes should be excluded from any
   * entries that are written to LDIF. The default is {@code false}.
   *
   * @param excludeUserAttributes
   *          {@code true} if all user attributes should be excluded, or
   *          {@code false} otherwise.
   *          {@code true} if all user attributes should be excluded, or {@code
   *          false} otherwise.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setExcludeAllUserAttributes(
      boolean excludeUserAttributes)
      final boolean excludeUserAttributes)
  {
    this.excludeUserAttributes = excludeUserAttributes;
    return this;
@@ -159,16 +155,15 @@
  /**
   * Excludes the named attribute from any entries that are written to
   * LDIF. By default all attributes are included unless explicitly
   * excluded.
   * Excludes the named attribute from any entries that are written to LDIF. By
   * default all attributes are included unless explicitly excluded.
   *
   * @param attributeDescription
   *          The name of the attribute to be excluded.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setExcludeAttribute(
      AttributeDescription attributeDescription)
      final AttributeDescription attributeDescription)
  {
    Validator.ensureNotNull(attributeDescription);
    excludeAttributes.add(attributeDescription);
@@ -178,15 +173,15 @@
  /**
   * Excludes all entries beneath the named entry (inclusive) from being
   * written to LDIF. By default all entries are written unless
   * explicitly excluded or included by branches or filters.
   * Excludes all entries beneath the named entry (inclusive) from being written
   * to LDIF. By default all entries are written unless explicitly excluded or
   * included by branches or filters.
   *
   * @param excludeBranch
   *          The distinguished name of the branch to be excluded.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setExcludeBranch(DN excludeBranch)
  public LDIFEntryWriter setExcludeBranch(final DN excludeBranch)
  {
    Validator.ensureNotNull(excludeBranch);
    excludeBranches.add(excludeBranch);
@@ -196,15 +191,15 @@
  /**
   * Excludes all entries which match the provided filter matcher from
   * being written to LDIF. By default all entries are written unless
   * explicitly excluded or included by branches or filters.
   * Excludes all entries which match the provided filter matcher from being
   * written to LDIF. By default all entries are written unless explicitly
   * excluded or included by branches or filters.
   *
   * @param excludeFilter
   *          The filter matcher.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setExcludeFilter(Matcher excludeFilter)
  public LDIFEntryWriter setExcludeFilter(final Matcher excludeFilter)
  {
    Validator.ensureNotNull(excludeFilter);
    excludeFilters.add(excludeFilter);
@@ -214,16 +209,16 @@
  /**
   * Ensures that the named attribute is not excluded from any entries
   * that are written to LDIF. By default all attributes are included
   * unless explicitly excluded.
   * Ensures that the named attribute is not excluded from any entries that are
   * written to LDIF. By default all attributes are included unless explicitly
   * excluded.
   *
   * @param attributeDescription
   *          The name of the attribute to be included.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setIncludeAttribute(
      AttributeDescription attributeDescription)
      final AttributeDescription attributeDescription)
  {
    Validator.ensureNotNull(attributeDescription);
    includeAttributes.add(attributeDescription);
@@ -233,15 +228,15 @@
  /**
   * Ensures that all entries beneath the named entry (inclusive) are
   * written to LDIF. By default all entries are written unless
   * explicitly excluded or included by branches or filters.
   * Ensures that all entries beneath the named entry (inclusive) are written to
   * LDIF. By default all entries are written unless explicitly excluded or
   * included by branches or filters.
   *
   * @param includeBranch
   *          The distinguished name of the branch to be included.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setIncludeBranch(DN includeBranch)
  public LDIFEntryWriter setIncludeBranch(final DN includeBranch)
  {
    Validator.ensureNotNull(includeBranch);
    includeBranches.add(includeBranch);
@@ -251,15 +246,15 @@
  /**
   * Ensures that all entries which match the provided filter matcher
   * are written to LDIF. By default all entries are written unless
   * explicitly excluded or included by branches or filters.
   * Ensures that all entries which match the provided filter matcher are
   * written to LDIF. By default all entries are written unless explicitly
   * excluded or included by branches or filters.
   *
   * @param includeFilter
   *          The filter matcher.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setIncludeFilter(Matcher includeFilter)
  public LDIFEntryWriter setIncludeFilter(final Matcher includeFilter)
  {
    Validator.ensureNotNull(includeFilter);
    includeFilters.add(includeFilter);
@@ -269,15 +264,15 @@
  /**
   * Sets the schema which should be used when filtering entries (not
   * required if no filtering is to be performed). The default schema is
   * used if no other is specified.
   * Sets the schema which should be used when filtering entries (not required
   * if no filtering is to be performed). The default schema is used if no other
   * is specified.
   *
   * @param schema
   *          The schema which should be used when filtering entries.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setSchema(Schema schema)
  public LDIFEntryWriter setSchema(final Schema schema)
  {
    Validator.ensureNotNull(schema);
    this.schema = schema;
@@ -287,15 +282,15 @@
  /**
   * Specifies the column at which long lines should be wrapped. A value
   * less than or equal to zero (the default) indicates that no wrapping
   * should be performed.
   * Specifies the column at which long lines should be wrapped. A value less
   * than or equal to zero (the default) indicates that no wrapping should be
   * performed.
   *
   * @param wrapColumn
   *          The column at which long lines should be wrapped.
   * @return A reference to this {@code LDIFEntryWriter}.
   */
  public LDIFEntryWriter setWrapColumn(int wrapColumn)
  public LDIFEntryWriter setWrapColumn(final int wrapColumn)
  {
    this.wrapColumn = wrapColumn;
    return this;
@@ -306,7 +301,7 @@
  /**
   * {@inheritDoc}
   */
  public LDIFEntryWriter writeComment(CharSequence comment)
  public LDIFEntryWriter writeComment(final CharSequence comment)
      throws IOException, NullPointerException
  {
    writeComment0(comment);
@@ -318,7 +313,7 @@
  /**
   * {@inheritDoc}
   */
  public LDIFEntryWriter writeEntry(Entry entry) throws IOException,
  public LDIFEntryWriter writeEntry(final Entry entry) throws IOException,
      NullPointerException
  {
    Validator.ensureNotNull(entry);
@@ -336,7 +331,7 @@
    }
    writeKeyAndValue("dn", entry.getName().toString());
    for (final Attribute attribute : entry.getAttributes())
    for (final Attribute attribute : entry.getAllAttributes())
    {
      // Filter the attribute if required.
      if (isAttributeExcluded(attribute.getAttributeDescription()))
@@ -344,8 +339,8 @@
        continue;
      }
      final String attributeDescription =
          attribute.getAttributeDescriptionAsString();
      final String attributeDescription = attribute
          .getAttributeDescriptionAsString();
      for (final ByteString value : attribute)
      {
        writeKeyAndValue(attributeDescription, value);