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
030
031
032 /**
033 * This interface defines a set of methods that may be safely called in an LDAP
034 * add request without altering its contents. This interface must not be
035 * implemented by any class other than {@code AddRequest}.
036 * <BR><BR>
037 * This interface does not inherently provide the assurance of thread safety for
038 * the methods that it exposes, because it is still possible for a thread
039 * referencing the object which implements this interface to alter the request
040 * using methods not included in this interface. However, if it can be
041 * guaranteed that no thread will alter the underlying object, then the methods
042 * exposed by this interface can be safely invoked concurrently by any number of
043 * threads.
044 */
045 public interface ReadOnlyAddRequest
046 extends ReadOnlyLDAPRequest
047 {
048 /**
049 * Retrieves the DN for this add request.
050 *
051 * @return The DN for this add request.
052 */
053 String getDN();
054
055
056
057 /**
058 * Retrieves the set of attributes for this add request.
059 *
060 * @return The set of attributes for this add request.
061 */
062 List<Attribute> getAttributes();
063
064
065
066 /**
067 * Retrieves the specified attribute from this add request.
068 *
069 * @param attributeName The name of the attribute to retrieve. It must not
070 * be {@code null}.
071 *
072 * @return The requested attribute, or {@code null} if it does not exist in
073 * the add request.
074 */
075 Attribute getAttribute(final String attributeName);
076
077
078
079 /**
080 * Indicates whether this add request contains the specified attribute.
081 *
082 * @param attributeName The name of the attribute for which to make the
083 * determination. It must not be {@code null}.
084 *
085 * @return {@code true} if this add request contains the specified attribute,
086 * or {@code false} if not.
087 */
088 boolean hasAttribute(final String attributeName);
089
090
091
092 /**
093 * Indicates whether this add request contains the specified attribute. It
094 * will only return {@code true} if this add request contains an attribute
095 * with the same name and exact set of values.
096 *
097 * @param attribute The attribute for which to make the determination. It
098 * must not be {@code null}.
099 *
100 * @return {@code true} if this add request contains the specified attribute,
101 * or {@code false} if not.
102 */
103 boolean hasAttribute(final Attribute attribute);
104
105
106
107 /**
108 * Indicates whether this add request contains an attribute with the given
109 * name and value.
110 *
111 * @param attributeName The name of the attribute for which to make the
112 * determination. It must not be {@code null}.
113 * @param attributeValue The value for which to make the determination. It
114 * must not be {@code null}.
115 *
116 * @return {@code true} if this add request contains an attribute with the
117 * specified name and value, or {@code false} if not.
118 */
119 boolean hasAttributeValue(final String attributeName,
120 final String attributeValue);
121
122
123
124 /**
125 * Indicates whether this add request contains an attribute with the given
126 * name and value.
127 *
128 * @param attributeName The name of the attribute for which to make the
129 * determination. It must not be {@code null}.
130 * @param attributeValue The value for which to make the determination. It
131 * must not be {@code null}.
132 * @param matchingRule The matching rule to use to make the determination.
133 * It must not be {@code null}.
134 *
135 * @return {@code true} if this add request contains an attribute with the
136 * specified name and value, or {@code false} if not.
137 */
138 boolean hasAttributeValue(final String attributeName,
139 final String attributeValue,
140 final MatchingRule matchingRule);
141
142
143
144 /**
145 * Indicates whether this add request contains an attribute with the given
146 * name and value.
147 *
148 * @param attributeName The name of the attribute for which to make the
149 * determination. It must not be {@code null}.
150 * @param attributeValue The value for which to make the determination. It
151 * must not be {@code null}.
152 *
153 * @return {@code true} if this add request contains an attribute with the
154 * specified name and value, or {@code false} if not.
155 */
156 boolean hasAttributeValue(final String attributeName,
157 final byte[] attributeValue);
158
159
160
161 /**
162 * Indicates whether this add request contains an attribute with the given
163 * name and value.
164 *
165 * @param attributeName The name of the attribute for which to make the
166 * determination. It must not be {@code null}.
167 * @param attributeValue The value for which to make the determination. It
168 * must not be {@code null}.
169 * @param matchingRule The matching rule to use to make the determination.
170 * It must not be {@code null}.
171 *
172 * @return {@code true} if this add request contains an attribute with the
173 * specified name and value, or {@code false} if not.
174 */
175 boolean hasAttributeValue(final String attributeName,
176 final byte[] attributeValue,
177 final MatchingRule matchingRule);
178
179
180
181 /**
182 * Indicates whether this add request contains the specified object class.
183 *
184 * @param objectClassName The name of the object class for which to make the
185 * determination. It must not be {@code null}.
186 *
187 * @return {@code true} if this add request contains the specified object
188 * class, or {@code false} if not.
189 */
190 boolean hasObjectClass(final String objectClassName);
191
192
193
194 /**
195 * Retrieves an {@code Entry} object containing the DN and attributes of this
196 * add request.
197 *
198 * @return An {@code Entry} object containing the DN and attributes of this
199 * add request.
200 */
201 Entry toEntry();
202
203
204
205 /**
206 * {@inheritDoc}
207 */
208 AddRequest duplicate();
209
210
211
212 /**
213 * {@inheritDoc}
214 */
215 AddRequest duplicate(final Control[] controls);
216
217
218
219 /**
220 * Retrieves an LDIF add change record with the contents of this add request.
221 *
222 * @return An LDIF add change record with the contents of this add request.
223 */
224 LDIFAddChangeRecord toLDIFChangeRecord();
225
226
227
228 /**
229 * Retrieves a string array whose lines contain an LDIF representation of the
230 * corresponding add change record.
231 *
232 * @return A string array whose lines contain an LDIF representation of the
233 * corresponding add change record.
234 */
235 String[] toLDIF();
236
237
238
239 /**
240 * Retrieves an LDIF string representation of this add request.
241 *
242 * @return An LDIF string representation of this add request.
243 */
244 String toLDIFString();
245 }