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