001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * docs/licenses/cddl.txt
011 * or http://www.opensource.org/licenses/cddl1.php.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * docs/licenses/cddl.txt.  If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 *      Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 *      Copyright 2010-2021 Ping Identity Corporation
026 */
027package com.unboundid.directory.sdk.common.types;
028
029
030
031import java.util.Set;
032
033import com.unboundid.directory.sdk.common.schema.AttributeType;
034import com.unboundid.ldap.sdk.Attribute;
035import com.unboundid.ldap.sdk.LDAPException;
036import com.unboundid.ldap.sdk.DN;
037import com.unboundid.util.NotExtensible;
038import com.unboundid.util.ThreadSafety;
039import com.unboundid.util.ThreadSafetyLevel;
040
041
042
043/**
044 * This interface defines a set of methods which may be used to update the
045 * contents of an entry.
046 */
047@NotExtensible()
048@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_NOT_THREADSAFE)
049public interface UpdatableEntry
050       extends Entry
051{
052  /**
053   * Specifies the DN for the entry.
054   *
055   * @param  dn  The DN for the entry.  It must not be {@code null}.
056   *
057   * @throws LDAPException  If the provided DN is not valid.
058   */
059  void setDN(final String dn)
060       throws LDAPException;
061
062
063
064  /**
065   * Specifies the DN for the entry.
066   *
067   * @param  dn  The DN for the entry.  It must not be {@code null}.
068   *
069   * @throws LDAPException  If the provided DN is not valid.
070   */
071  void setDN(final DN dn)
072       throws LDAPException;
073
074
075
076  /**
077   * Replaces the specified attribute in the entry, or adds the attribute if
078   * it does not exist.
079   *
080   * @param  attribute  The attribute to be stored in the entry.  It must not be
081   *                    {@code null}.
082   */
083  void setAttribute(final Attribute attribute);
084
085
086
087  /**
088   * Adds the provided attribute to the entry.  If an attribute already exists
089   * with the same name and set of options, then the values will be merged.
090   *
091   * @param  attribute  The attribute to be added.  It must not be {@code null}.
092   */
093  void addAttribute(final Attribute attribute);
094
095
096
097  /**
098   * Removes all occurrences of the specified attribute from the entry.
099   *
100   * @param  type  The attribute type for the attribute to remove from the
101   *               entry.  It must not be {@code null}.
102   */
103  void removeAttribute(final AttributeType type);
104
105
106
107  /**
108   * Removes all occurrences of the attribute with the specified name from the
109   * entry.
110   *
111   * @param  name  The name or OID of the attribute to remove from the entry.
112   *               It must not be {@code null}.
113   */
114  void removeAttribute(final String name);
115
116
117
118  /**
119   * Removes the attribute with the specified name and exact set of options
120   * from the entry.
121   *
122   * @param  type     The attribute type for the attribute to remove from the
123   *                  entry.  It must not be {@code null}.
124   * @param  options  The set of attribute options for the attribute to remove
125   *                  from the entry.  It may be {@code null} or empty if there
126   *                  are no options.
127   */
128  void removeAttribute(final AttributeType type, final Set<String> options);
129
130
131
132  /**
133   * Removes the attribute with the specified name and exact set of options
134   * from the entry.
135   *
136   * @param  name     The name or OID of the attribute to remove from the entry.
137   *                  It must not be {@code null}.
138   * @param  options  The set of attribute options for the attribute to remove
139   *                  from the entry.  It may be {@code null} or empty if there
140   *                  are no options.
141   */
142  void removeAttribute(final String name, final Set<String> options);
143}