001 /*
002 * Copyright 2007-2016 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2008-2016 UnboundID Corp.
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 */
021 package com.unboundid.ldap.sdk;
022
023
024
025 import java.util.List;
026
027 import com.unboundid.ldap.matchingrules.MatchingRule;
028 import com.unboundid.ldif.LDIFAddChangeRecord;
029 import com.unboundid.util.NotExtensible;
030 import com.unboundid.util.ThreadSafety;
031 import 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)
050 public 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(final 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(final 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(final 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(final String attributeName,
125 final String attributeValue);
126
127
128
129 /**
130 * Indicates whether this add request contains an attribute with the given
131 * name and value.
132 *
133 * @param attributeName The name of the attribute for which to make the
134 * determination. It must not be {@code null}.
135 * @param attributeValue The value for which to make the determination. It
136 * must not be {@code null}.
137 * @param matchingRule The matching rule to use to make the determination.
138 * It must not be {@code null}.
139 *
140 * @return {@code true} if this add request contains an attribute with the
141 * specified name and value, or {@code false} if not.
142 */
143 boolean hasAttributeValue(final String attributeName,
144 final String attributeValue,
145 final MatchingRule matchingRule);
146
147
148
149 /**
150 * Indicates whether this add request contains an attribute with the given
151 * name and value.
152 *
153 * @param attributeName The name of the attribute for which to make the
154 * determination. It must not be {@code null}.
155 * @param attributeValue The value for which to make the determination. It
156 * must not be {@code null}.
157 *
158 * @return {@code true} if this add request contains an attribute with the
159 * specified name and value, or {@code false} if not.
160 */
161 boolean hasAttributeValue(final String attributeName,
162 final byte[] attributeValue);
163
164
165
166 /**
167 * Indicates whether this add request contains an attribute with the given
168 * name and value.
169 *
170 * @param attributeName The name of the attribute for which to make the
171 * determination. It must not be {@code null}.
172 * @param attributeValue The value for which to make the determination. It
173 * must not be {@code null}.
174 * @param matchingRule The matching rule to use to make the determination.
175 * It must not be {@code null}.
176 *
177 * @return {@code true} if this add request contains an attribute with the
178 * specified name and value, or {@code false} if not.
179 */
180 boolean hasAttributeValue(final String attributeName,
181 final byte[] attributeValue,
182 final MatchingRule matchingRule);
183
184
185
186 /**
187 * Indicates whether this add request contains the specified object class.
188 *
189 * @param objectClassName The name of the object class for which to make the
190 * determination. It must not be {@code null}.
191 *
192 * @return {@code true} if this add request contains the specified object
193 * class, or {@code false} if not.
194 */
195 boolean hasObjectClass(final String objectClassName);
196
197
198
199 /**
200 * Retrieves an {@code Entry} object containing the DN and attributes of this
201 * add request.
202 *
203 * @return An {@code Entry} object containing the DN and attributes of this
204 * add request.
205 */
206 Entry toEntry();
207
208
209
210 /**
211 * {@inheritDoc}
212 */
213 AddRequest duplicate();
214
215
216
217 /**
218 * {@inheritDoc}
219 */
220 AddRequest duplicate(final Control[] controls);
221
222
223
224 /**
225 * Retrieves an LDIF add change record with the contents of this add request.
226 *
227 * @return An LDIF add change record with the contents of this add request.
228 */
229 LDIFAddChangeRecord toLDIFChangeRecord();
230
231
232
233 /**
234 * Retrieves a string array whose lines contain an LDIF representation of the
235 * corresponding add change record.
236 *
237 * @return A string array whose lines contain an LDIF representation of the
238 * corresponding add change record.
239 */
240 String[] toLDIF();
241
242
243
244 /**
245 * Retrieves an LDIF string representation of this add request.
246 *
247 * @return An LDIF string representation of this add request.
248 */
249 String toLDIFString();
250 }