View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  package org.apache.directory.ldap.client.template;
21  
22  
23  import org.apache.directory.api.ldap.model.entry.Attribute;
24  import org.apache.directory.api.ldap.model.entry.Entry;
25  import org.apache.directory.api.ldap.model.entry.Value;
26  import org.apache.directory.api.ldap.model.message.AddRequest;
27  import org.apache.directory.api.ldap.model.message.DeleteRequest;
28  import org.apache.directory.api.ldap.model.message.ModifyRequest;
29  import org.apache.directory.api.ldap.model.message.SearchRequest;
30  import org.apache.directory.api.ldap.model.message.SearchScope;
31  import org.apache.directory.api.ldap.model.name.Dn;
32  import org.apache.directory.ldap.client.api.search.FilterBuilder;
33  
34  
35  /**
36   * A factory for creating {@link org.apache.directory.api.ldap.model} objects.
37   *
38   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
39   */
40  public interface ModelFactory
41  {
42      /**
43       * Returns a new <code>AddRequest</code> for the <code>entry</code>.
44       *
45       * @param entry The Entry to add
46       * @return The resulting AddRequest
47       */
48      AddRequest newAddRequest( Entry entry );
49  
50  
51      /**
52       * Returns a new Attribute for with the provided <code>name</code> and
53       * a null value.  This is useful for clearing out an Attribute with a
54       * ModifyRequest, replace function.
55       *
56       * @param name The attribute's name
57       * @return The resulting Attribute
58       */
59      Attribute newAttribute( String name );
60  
61  
62      /**
63       * Returns a new Attribute for with the provided <code>name</code> and
64       * <code>value(s)</code>.
65       *
66       * @param name The attribute's name
67       * @param values The attribute's values
68       * @return The resulting Attribute
69       */
70      Attribute newAttribute( String name, byte[]... values );
71  
72  
73      /**
74       * Returns a new Attribute for with the provided <code>name</code> and
75       * <code>value(s)</code>.
76       *
77       * @param name The attribute's name
78       * @param values The attribute's values
79       * @return The resulting Attribute
80       */
81      Attribute newAttribute( String name, String... values );
82  
83  
84      /**
85       * Returns a new Attribute for with the provided <code>name</code> and
86       * <code>value(s)</code>.
87       *
88       * @param name The attribute's name
89       * @param values The attribute's values
90       * @return The resulting Attribute
91       */
92      Attribute newAttribute( String name, Value<?>... values );
93  
94  
95      /**
96       * Returns a new <code>DeleteRequest</code> for the <code>dn</code>.
97       *
98       * @param dn The Dn for the Entry to delete
99       * @return The resulting DeleteRequest
100      */
101     DeleteRequest newDeleteRequest( Dn dn );
102 
103 
104     /**
105      * Returns a <code>Dn</code> that represents <code>dn</code>.
106      *
107      * @param dn The Entry's Dn
108      * @return The resulting Dn
109      */
110     Dn newDn( String dn );
111 
112 
113     /**
114      * Returns a <code>Entry</code> with the specified <code>dn</code>.
115      *
116      * @param dn The Entry's Dn
117      * @return The resulting Entry
118      */
119     Entry newEntry( String dn );
120 
121 
122     /**
123      * Returns a <code>Entry</code> with the specified <code>dn</code>.
124      *
125      * @param dn The Entry's Dn
126      * @return The resulting Entry
127      */
128     Entry newEntry( Dn dn );
129 
130 
131     /**
132      * Returns a new <code>ModifyRequest</code> for the <code>dn</code>.
133      *
134      * @param dn  The Dn of the entry to modify
135      * @return The resulting ModifyRequest
136      */
137     ModifyRequest newModifyRequest( String dn );
138 
139 
140     /**
141      * Returns a new <code>ModifyRequest</code> for the <code>dn</code>.
142      *
143      * @param dn The DN of the entry to modify
144      * @return The resulting ModifyRequest
145      */
146     ModifyRequest newModifyRequest( Dn dn );
147 
148 
149     /**
150      * Returns a new <code>SearchRequest</code> over <code>baseDn</code> in
151      * <code>scope</code> matching <code>filter</code> returning 
152      * all normal attributes for each matching entry.
153      *
154      * @param baseDn The base DN from which to start the search
155      * @param filter The filter selecting the entries
156      * @param scope The scope to look from
157      * @return The resulting SearchRequest
158      */
159     SearchRequest newSearchRequest( String baseDn, FilterBuilder filter,
160         SearchScope scope );
161 
162 
163     /**
164      * Returns a new <code>SearchRequest</code> over <code>baseDn</code> in
165      * <code>scope</code> matching <code>filter</code> returning 
166      * all normal attributes for each matching entry.
167      *
168      * @param baseDn The base DN from which to start the search
169      * @param filter The filter selecting the entries
170      * @param scope The scope to look from
171      * @return The resulting SearchRequest
172      */
173     SearchRequest newSearchRequest( String baseDn, String filter,
174         SearchScope scope );
175 
176 
177     /**
178      * Returns a new <code>SearchRequest</code> over <code>baseDn</code> in
179      * <code>scope</code> matching <code>filter</code> returning 
180      * all normal attributes for each matching entry.
181      *
182      * @param baseDn The base DN from which to start the search
183      * @param filter The filter selecting the entries
184      * @param scope The scope to look from
185      * @return The resulting SearchRequest
186      */
187     SearchRequest newSearchRequest( Dn baseDn, String filter,
188         SearchScope scope );
189 
190 
191     /**
192      * Returns a new <code>SearchRequest</code> over <code>baseDn</code> in
193      * <code>scope</code> matching <code>filter</code> returning 
194      * all normal attributes for each matching entry.
195      *
196      * @param baseDn The base DN from which to start the search
197      * @param filter The filter selecting the entries
198      * @param scope The scope to look from
199      * @return The resulting SearchRequest
200      */
201     SearchRequest newSearchRequest( Dn baseDn, FilterBuilder filter,
202         SearchScope scope );
203 
204 
205     /**
206      * Returns a new <code>SearchRequest</code> over <code>baseDn</code> in
207      * <code>scope</code> matching <code>filter</code> returning 
208      * <code>attributes</code> for each matching entry.
209      *
210      * @param baseDn The base DN from which to start the search
211      * @param filter The filter selecting the entries
212      * @param scope The scope to look from
213      * @param attributes The list of AttributeType to return
214      * @return The resulting SearchRequest
215      */
216     SearchRequest newSearchRequest( String baseDn, String filter,
217         SearchScope scope, String... attributes );
218 
219 
220     /**
221      * Returns a new <code>SearchRequest</code> over <code>baseDn</code> in
222      * <code>scope</code> matching <code>filter</code> returning 
223      * <code>attributes</code> for each matching entry.
224      *
225      * @param baseDn The base DN from which to start the search
226      * @param filter The filter selecting the entries
227      * @param scope The scope to look from
228      * @param attributes The list of AttributeType to return
229      * @return The resulting SearchRequest
230      */
231     SearchRequest newSearchRequest( String baseDn, FilterBuilder filter,
232         SearchScope scope, String... attributes );
233 
234 
235     /**
236      * Returns a new <code>SearchRequest</code> over <code>baseDn</code> in
237      * <code>scope</code> matching <code>filter</code> returning 
238      * <code>attributes</code> for each matching entry.
239      *
240      * @param baseDn The base DN from which to start the search
241      * @param filter The filter selecting the entries
242      * @param scope The scope to look from
243      * @param attributes The list of AttributeType to return
244      * @return The resulting SearchRequest
245      */
246     SearchRequest newSearchRequest( Dn baseDn, String filter,
247         SearchScope scope, String... attributes );
248 
249 
250     /**
251      * Returns a new <code>SearchRequest</code> over <code>baseDn</code> in
252      * <code>scope</code> matching <code>filter</code> returning 
253      * <code>attributes</code> for each matching entry.
254      *
255      * @param baseDn The base DN from which to start the search
256      * @param filter The filter selecting the entries
257      * @param scope The scope to look from
258      * @param attributes The list of AttributeType to return
259      * @return The resulting SearchRequest
260      */
261     SearchRequest newSearchRequest( Dn baseDn, FilterBuilder filter,
262         SearchScope scope, String... attributes );
263 }