KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > dsmlv2 > request > BatchRequest


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
21 package org.apache.directory.ldapstudio.dsmlv2.request;
22
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.apache.directory.shared.ldap.codec.LdapMessage;
28
29
30 /**
31  * This class represents the Batch Request of a DSML Request
32  *
33  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
34  * @version $Rev$, $Date$
35  */

36 public class BatchRequest
37 {
38     /**
39      * The requests contained in the Batch Request
40      */

41     private List JavaDoc<LdapMessage> requests;
42
43     /**
44      * The ID of the request
45      */

46     private int requestID;
47
48     /**
49      * This enum represents the different types of processing for a Batch Request
50      *
51      * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
52      * @version $Rev$, $Date$
53      */

54     public enum Processing
55     {
56         SEQUENTIAL, PARALLEL
57     };
58
59     /**
60      * The type of processing of the Batch Request
61      */

62     private Processing processing;
63
64     /**
65      * This enum represents the different types of on error handling for a BatchRequest
66      *
67      * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
68      * @version $Rev$, $Date$
69      */

70     public enum OnError
71     {
72         RESUME, EXIT
73     };
74
75     /**
76      * The type of on error handling
77      */

78     private OnError onError;
79
80     /**
81      * This enum represents the different types of response order for a Batch Request
82      *
83      * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
84      * @version $Rev$, $Date$
85      */

86     public enum ResponseOrder
87     {
88         SEQUENTIAL, UNORDERED
89     };
90
91     /**
92      * The response order
93      */

94     private ResponseOrder responseOrder;
95
96
97     /**
98      * Creates a new instance of BatchRequest.
99      */

100     public BatchRequest()
101     {
102         requests = new ArrayList JavaDoc<LdapMessage>();
103         responseOrder = ResponseOrder.SEQUENTIAL;
104         processing = Processing.SEQUENTIAL;
105         onError = OnError.EXIT;
106     }
107
108
109     /**
110      * Adds a request
111      *
112      * @param request
113      * the resquest to add
114      * @return
115      * true (as per the general contract of the Collection.add method)
116      */

117     public boolean addRequest( LdapMessage request )
118     {
119         return requests.add( request );
120     }
121
122
123     /**
124      * Gets the current request
125      *
126      * @return
127      * the current request
128      */

129     public LdapMessage getCurrentRequest()
130     {
131         return requests.get( requests.size() - 1 );
132     }
133
134
135     /**
136      * Gets the ID of the request
137      *
138      * @return
139      * the ID of the request
140      */

141     public int getRequestID()
142     {
143         return requestID;
144     }
145
146
147     /**
148      * Sets the ID of the request
149      *
150      * @param requestID
151      * the ID to set
152      */

153     public void setRequestID( int requestID )
154     {
155         this.requestID = requestID;
156     }
157
158
159     /**
160      * Gets the processing type of the request
161      *
162      * @return
163      * the processing type of the request
164      */

165     public Processing getProcessing()
166     {
167         return processing;
168     }
169
170
171     /**
172      * Sets the processing type of the request
173      *
174      * @param processing
175      * the processing type to set
176      */

177     public void setProcessing( Processing processing )
178     {
179         this.processing = processing;
180     }
181
182
183     /**
184      * Gets the on error handling type of the request
185      *
186      * @return
187      * the on error handling type of the request
188      */

189     public OnError getOnError()
190     {
191         return onError;
192     }
193
194
195     /**
196      * Sets the on error handling type of the request
197      *
198      * @param onError
199      * the on error handling type to set
200      */

201     public void setOnError( OnError onError )
202     {
203         this.onError = onError;
204     }
205
206
207     /**
208      * Gets the reponse order type of the request
209      *
210      * @return
211      * the reponse order type of the request
212      */

213     public ResponseOrder getResponseOrder()
214     {
215         return responseOrder;
216     }
217
218
219     /**
220      * Sets the reponse order type of the request
221      *
222      * @param responseOrder
223      * the reponse order type to set
224      */

225     public void setResponseOrder( ResponseOrder responseOrder )
226     {
227         this.responseOrder = responseOrder;
228     }
229
230
231     /**
232      * Gets the List of all the requests in the Batch Request
233      *
234      * @return
235      * the List of all the requests in the Batch Request
236      */

237     public List JavaDoc getRequests()
238     {
239         return requests;
240     }
241
242
243     /* (non-Javadoc)
244      * @see java.lang.Object#toString()
245      */

246     @Override JavaDoc
247     public String JavaDoc toString()
248     {
249         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
250
251         sb.append( "[" );
252         sb.append( "processing: " + processing );
253         sb.append( " - " );
254         sb.append( "onError: " + onError );
255         sb.append( " - " );
256         sb.append( "responseOrder: " + responseOrder );
257         sb.append( "]" );
258
259         return sb.toString();
260     }
261 }
262
Popular Tags