001/*
002 * Copyright 2007-2019 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2008-2019 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk;
022
023
024
025import java.util.List;
026
027import com.unboundid.ldap.matchingrules.MatchingRule;
028import com.unboundid.ldif.LDIFAddChangeRecord;
029import com.unboundid.util.NotExtensible;
030import com.unboundid.util.ThreadSafety;
031import com.unboundid.util.ThreadSafetyLevel;
032
033
034
035/**
036 * This interface defines a set of methods that may be safely called in an LDAP
037 * add request without altering its contents.  This interface must not be
038 * implemented by any class other than {@link AddRequest}.
039 * <BR><BR>
040 * This interface does not inherently provide the assurance of thread safety for
041 * the methods that it exposes, because it is still possible for a thread
042 * referencing the object which implements this interface to alter the request
043 * using methods not included in this interface.  However, if it can be
044 * guaranteed that no thread will alter the underlying object, then the methods
045 * exposed by this interface can be safely invoked concurrently by any number of
046 * threads.
047 */
048@NotExtensible()
049@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_NOT_THREADSAFE)
050public interface ReadOnlyAddRequest
051       extends ReadOnlyLDAPRequest
052{
053  /**
054   * Retrieves the DN for this add request.
055   *
056   * @return  The DN for this add request.
057   */
058  String getDN();
059
060
061
062  /**
063   * Retrieves the set of attributes for this add request.
064   *
065   * @return  The set of attributes for this add request.
066   */
067  List<Attribute> getAttributes();
068
069
070
071  /**
072   * Retrieves the specified attribute from this add request.
073   *
074   * @param  attributeName  The name of the attribute to retrieve.  It must not
075   *                        be {@code null}.
076   *
077   * @return  The requested attribute, or {@code null} if it does not exist in
078   *          the add request.
079   */
080  Attribute getAttribute(String attributeName);
081
082
083
084  /**
085   * Indicates whether this add request contains the specified attribute.
086   *
087   * @param  attributeName  The name of the attribute for which to make the
088   *                        determination.  It must not be {@code null}.
089   *
090   * @return  {@code true} if this add request contains the specified attribute,
091   *          or {@code false} if not.
092   */
093  boolean hasAttribute(String attributeName);
094
095
096
097  /**
098   * Indicates whether this add request contains the specified attribute.  It
099   * will only return {@code true} if this add request contains an attribute
100   * with the same name and exact set of values.
101   *
102   * @param  attribute  The attribute for which to make the determination.  It
103   *                    must not be {@code null}.
104   *
105   * @return  {@code true} if this add request contains the specified attribute,
106   *          or {@code false} if not.
107   */
108  boolean hasAttribute(Attribute attribute);
109
110
111
112  /**
113   * Indicates whether this add request contains an attribute with the given
114   * name and value.
115   *
116   * @param  attributeName   The name of the attribute for which to make the
117   *                         determination.  It must not be {@code null}.
118   * @param  attributeValue  The value for which to make the determination.  It
119   *                         must not be {@code null}.
120   *
121   * @return  {@code true} if this add request contains an attribute with the
122   *          specified name and value, or {@code false} if not.
123   */
124  boolean hasAttributeValue(String attributeName, String attributeValue);
125
126
127
128  /**
129   * Indicates whether this add request contains an attribute with the given
130   * name and value.
131   *
132   * @param  attributeName   The name of the attribute for which to make the
133   *                         determination.  It must not be {@code null}.
134   * @param  attributeValue  The value for which to make the determination.  It
135   *                         must not be {@code null}.
136   * @param  matchingRule    The matching rule to use to make the determination.
137   *                         It must not be {@code null}.
138   *
139   * @return  {@code true} if this add request contains an attribute with the
140   *          specified name and value, or {@code false} if not.
141   */
142  boolean hasAttributeValue(String attributeName, String attributeValue,
143                            MatchingRule matchingRule);
144
145
146
147  /**
148   * Indicates whether this add request contains an attribute with the given
149   * name and value.
150   *
151   * @param  attributeName   The name of the attribute for which to make the
152   *                         determination.  It must not be {@code null}.
153   * @param  attributeValue  The value for which to make the determination.  It
154   *                         must not be {@code null}.
155   *
156   * @return  {@code true} if this add request  contains an attribute with the
157   *          specified name and value, or {@code false} if not.
158   */
159  boolean hasAttributeValue(String attributeName, byte[] attributeValue);
160
161
162
163  /**
164   * Indicates whether this add request contains an attribute with the given
165   * name and value.
166   *
167   * @param  attributeName   The name of the attribute for which to make the
168   *                         determination.  It must not be {@code null}.
169   * @param  attributeValue  The value for which to make the determination.  It
170   *                         must not be {@code null}.
171   * @param  matchingRule    The matching rule to use to make the determination.
172   *                         It must not be {@code null}.
173   *
174   * @return  {@code true} if this add request  contains an attribute with the
175   *          specified name and value, or {@code false} if not.
176   */
177  boolean hasAttributeValue(String attributeName, byte[] attributeValue,
178                            MatchingRule matchingRule);
179
180
181
182  /**
183   * Indicates whether this add request contains the specified object class.
184   *
185   * @param  objectClassName  The name of the object class for which to make the
186   *                          determination.  It must not be {@code null}.
187   *
188   * @return  {@code true} if this add request contains the specified object
189   *          class, or {@code false} if not.
190   */
191  boolean hasObjectClass(String objectClassName);
192
193
194
195  /**
196   * Retrieves an {@code Entry} object containing the DN and attributes of this
197   * add request.
198   *
199   * @return  An {@code Entry} object containing the DN and attributes of this
200   *          add request.
201   */
202  Entry toEntry();
203
204
205
206  /**
207   * {@inheritDoc}
208   */
209  @Override()
210  AddRequest duplicate();
211
212
213
214  /**
215   * {@inheritDoc}
216   */
217  @Override()
218  AddRequest duplicate(Control[] controls);
219
220
221
222  /**
223   * Retrieves an LDIF add change record with the contents of this add request.
224   *
225   * @return  An LDIF add change record with the contents of this add request.
226   */
227  LDIFAddChangeRecord toLDIFChangeRecord();
228
229
230
231  /**
232   * Retrieves a string array whose lines contain an LDIF representation of the
233   * corresponding add change record.
234   *
235   * @return  A string array whose lines contain an LDIF representation of the
236   *          corresponding add change record.
237   */
238  String[] toLDIF();
239
240
241
242  /**
243   * Retrieves an LDIF string representation of this add request.
244   *
245   * @return  An LDIF string representation of this add request.
246   */
247  String toLDIFString();
248}