001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *  
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *  
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License. 
018 *  
019 */
020
021package org.apache.directory.shared.dsmlv2.request;
022
023
024import java.io.IOException;
025import java.lang.reflect.Array;
026import java.util.HashMap;
027
028import org.apache.directory.shared.asn1.DecoderException;
029import org.apache.directory.shared.asn1.util.Oid;
030import org.apache.directory.shared.dsmlv2.AbstractGrammar;
031import org.apache.directory.shared.dsmlv2.DsmlControl;
032import org.apache.directory.shared.dsmlv2.Dsmlv2Container;
033import org.apache.directory.shared.dsmlv2.Dsmlv2StatesEnum;
034import org.apache.directory.shared.dsmlv2.Grammar;
035import org.apache.directory.shared.dsmlv2.GrammarAction;
036import org.apache.directory.shared.dsmlv2.GrammarTransition;
037import org.apache.directory.shared.dsmlv2.ParserUtils;
038import org.apache.directory.shared.dsmlv2.Tag;
039import org.apache.directory.shared.dsmlv2.request.BatchRequestDsml.OnError;
040import org.apache.directory.shared.dsmlv2.request.BatchRequestDsml.Processing;
041import org.apache.directory.shared.dsmlv2.request.BatchRequestDsml.ResponseOrder;
042import org.apache.directory.shared.i18n.I18n;
043import org.apache.directory.shared.ldap.codec.api.CodecControl;
044import org.apache.directory.shared.ldap.codec.api.LdapApiService;
045import org.apache.directory.shared.ldap.codec.api.LdapApiServiceFactory;
046import org.apache.directory.shared.ldap.codec.api.LdapConstants;
047import org.apache.directory.shared.ldap.model.entry.BinaryValue;
048import org.apache.directory.shared.ldap.model.entry.StringValue;
049import org.apache.directory.shared.ldap.model.entry.Value;
050import org.apache.directory.shared.ldap.model.exception.LdapException;
051import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
052import org.apache.directory.shared.ldap.model.message.AbandonRequestImpl;
053import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
054import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
055import org.apache.directory.shared.ldap.model.message.BindRequestImpl;
056import org.apache.directory.shared.ldap.model.message.CompareRequest;
057import org.apache.directory.shared.ldap.model.message.CompareRequestImpl;
058import org.apache.directory.shared.ldap.model.message.Control;
059import org.apache.directory.shared.ldap.model.message.DeleteRequestImpl;
060import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
061import org.apache.directory.shared.ldap.model.message.ExtendedRequestImpl;
062import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
063import org.apache.directory.shared.ldap.model.message.ModifyDnRequestImpl;
064import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
065import org.apache.directory.shared.ldap.model.message.Request;
066import org.apache.directory.shared.ldap.model.message.SearchRequest;
067import org.apache.directory.shared.ldap.model.message.SearchRequestImpl;
068import org.apache.directory.shared.ldap.model.message.SearchScope;
069import org.apache.directory.shared.ldap.model.name.Dn;
070import org.apache.directory.shared.ldap.model.name.Rdn;
071import org.apache.directory.shared.util.Base64;
072import org.xmlpull.v1.XmlPullParser;
073import org.xmlpull.v1.XmlPullParserException;
074
075
076/**
077 * This Class represents the DSMLv2 Request Grammar
078 *
079 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
080 */
081public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
082{
083    private LdapApiService codec = LdapApiServiceFactory.getSingleton();
084    
085
086    /**
087     * Creates a new instance of Dsmlv2Grammar.
088     */
089    @SuppressWarnings("unchecked")
090    public Dsmlv2Grammar()
091    {
092        name = Dsmlv2Grammar.class.getName();
093
094        // Create the transitions table
095        super.transitions = ( HashMap<Tag, GrammarTransition>[] ) Array.newInstance( HashMap.class, 200 ); // TODO Change this value
096
097        //====================================================
098        //  Transitions concerning : BATCH REQUEST
099        //====================================================
100        super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE.ordinal()] = new HashMap<Tag, GrammarTransition>();
101        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
102        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()] = new HashMap<Tag, GrammarTransition>();
103        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
104
105        // ** OPEN BATCH REQUEST **
106        // State: [INIT_GRAMMAR_STATE] - Tag: <batchRequest>
107        super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE.ordinal()].put( new Tag( "batchRequest", Tag.START ),
108            new GrammarTransition( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE, Dsmlv2StatesEnum.BATCHREQUEST_START_TAG,
109                batchRequestCreation ) );
110
111        // ** CLOSE BATCH REQUEST **
112        // state: [BATCHREQUEST_START_TAG] - Tag: </batchRequest>
113        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()]
114            .put( new Tag( "batchRequest", Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG,
115                Dsmlv2StatesEnum.BATCHREQUEST_END_TAG, null ) );
116        //state: [BATCHREQUEST_LOOP] - Tag: </batchRequest>
117        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "batchRequest", Tag.END ),
118            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.GRAMMAR_END, null ) );
119
120        // ** ABANDON REQUEST **
121        // State: [BATCHREQUEST_START_TAG] - Tag: <abandonRequest>
122        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "abandonRequest", Tag.START ),
123            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, Dsmlv2StatesEnum.ABANDON_REQUEST_START_TAG,
124                abandonRequestCreation ) );
125        // state: [BATCHREQUEST_LOOP] - Tag: <abandonRequest>
126        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "abandonRequest", Tag.START ),
127            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.ABANDON_REQUEST_START_TAG,
128                abandonRequestCreation ) );
129
130        // ** ADD REQUEST **
131        // state: [BATCHREQUEST_START_TAG] - Tag: <addRequest>
132        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "addRequest", Tag.START ),
133            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, Dsmlv2StatesEnum.ADD_REQUEST_START_TAG,
134                addRequestCreation ) );
135        // state: [BATCHREQUEST_LOOP] - Tag: <addRequest>
136        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "addRequest", Tag.START ),
137            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.ADD_REQUEST_START_TAG,
138                addRequestCreation ) );
139
140        // ** AUTH REQUEST **
141        // state: [BATCHREQUEST_START_TAG] - Tag: <authRequest>
142        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "authRequest", Tag.START ),
143            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, Dsmlv2StatesEnum.AUTH_REQUEST_START_TAG,
144                authRequestCreation ) );
145
146        // ** COMPARE REQUEST **
147        // state: [BATCHREQUEST_START_TAG] - Tag: <compareRequest>
148        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "compareRequest", Tag.START ),
149            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, Dsmlv2StatesEnum.COMPARE_REQUEST_START_TAG,
150                compareRequestCreation ) );
151        // state: [BATCHREQUEST_LOOP] - Tag: <compareRequest>
152        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "compareRequest", Tag.START ),
153            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.COMPARE_REQUEST_START_TAG,
154                compareRequestCreation ) );
155
156        // ** DEL REQUEST **
157        // state: [BATCHREQUEST_START_TAG] - Tag: <delRequest>
158        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "delRequest", Tag.START ),
159            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, Dsmlv2StatesEnum.DEL_REQUEST_START_TAG,
160                delRequestCreation ) );
161        // state: [BATCHREQUEST_LOOP] - Tag: <delRequest>
162        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "delRequest", Tag.START ),
163            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.DEL_REQUEST_START_TAG,
164                delRequestCreation ) );
165
166        // ** EXTENDED REQUEST **
167        // state: [BATCHREQUEST_START_TAG] - Tag: <extendedRequest>
168        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "extendedRequest", Tag.START ),
169            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG,
170                Dsmlv2StatesEnum.EXTENDED_REQUEST_START_TAG, extendedRequestCreation ) );
171        // state: [BATCHREQUEST_LOOP] - Tag: <extendedRequest>
172        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "extendedRequest", Tag.START ),
173            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.EXTENDED_REQUEST_START_TAG,
174                extendedRequestCreation ) );
175
176        // ** MOD Dn REQUEST **
177        // state: [BATCHREQUEST_START_TAG] - Tag: <modDNRequest>
178        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "modDNRequest", Tag.START ),
179            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG,
180                Dsmlv2StatesEnum.MODIFY_DN_REQUEST_START_TAG, modDNRequestCreation ) );
181        // state: [BATCHREQUEST_LOOP] - Tag: <modDNRequest>
182        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "modDNRequest", Tag.START ),
183            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.MODIFY_DN_REQUEST_START_TAG,
184                modDNRequestCreation ) );
185
186        // ** MODIFY REQUEST **
187        // state: [BATCHREQUEST_START_TAG] - Tag: <modifyRequest>
188        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "modifyRequest", Tag.START ),
189            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG,
190                modifyRequestCreation ) );
191        // state: [BATCHREQUEST_LOOP] - Tag: <modifyRequest>
192        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "modifyRequest", Tag.START ),
193            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG,
194                modifyRequestCreation ) );
195
196        // ** SEARCH REQUEST **
197        // state: [BATCHREQUEST_START_TAG] - Tag: <searchRequest>
198        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_START_TAG.ordinal()].put( new Tag( "searchRequest", Tag.START ),
199            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, Dsmlv2StatesEnum.SEARCH_REQUEST_START_TAG,
200                searchRequestCreation ) );
201        // state: [BATCHREQUEST_LOOP] - Tag: <searchRequest>
202        super.transitions[Dsmlv2StatesEnum.BATCHREQUEST_LOOP.ordinal()].put( new Tag( "searchRequest", Tag.START ),
203            new GrammarTransition( Dsmlv2StatesEnum.BATCHREQUEST_LOOP, Dsmlv2StatesEnum.SEARCH_REQUEST_START_TAG,
204                searchRequestCreation ) );
205
206        //====================================================
207        //  Transitions concerning : ABANDON REQUEST
208        //====================================================
209        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
210        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
211        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
212        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
213
214        // State: [ABANDON_REQUEST_START_TAG] - Tag: </abandonRequest>
215        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_START_TAG.ordinal()]
216            .put( new Tag( "abandonRequest", Tag.END ), new GrammarTransition(
217                Dsmlv2StatesEnum.ABANDON_REQUEST_START_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
218
219        // State: [ABANDON_REQUEST_START_TAG] - Tag: <control>
220        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
221            new GrammarTransition( Dsmlv2StatesEnum.ABANDON_REQUEST_START_TAG,
222                Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_START_TAG, controlCreation ) );
223
224        // State: [ABANDON_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
225        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_START_TAG.ordinal()].put(
226            new Tag( "controlValue", Tag.START ), new GrammarTransition(
227                Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_START_TAG,
228                Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
229
230        // State: [ABANDON_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
231        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
232            new GrammarTransition( Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROLVALUE_END_TAG,
233                Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_END_TAG, null ) );
234
235        // State: [ABANDON_REQUEST_CONTROL_START_TAG] - Tag: </control>
236        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
237            new GrammarTransition( Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_START_TAG,
238                Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_END_TAG, null ) );
239
240        // State: [ABANDON_REQUEST_CONTROL_END_TAG] - Tag: <control>
241        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
242            new GrammarTransition( Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_END_TAG,
243                Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_START_TAG, controlCreation ) );
244
245        // State: [ABANDON_REQUEST_CONTROL_END_TAG] - Tag: </abandonRequest>
246        super.transitions[Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "abandonRequest", Tag.END ),
247            new GrammarTransition( Dsmlv2StatesEnum.ABANDON_REQUEST_CONTROL_END_TAG,
248                Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
249
250        //====================================================
251        //  Transitions concerning : ADD REQUEST
252        //====================================================
253        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
254        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
255        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
256        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
257        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
258        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_ATTR_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
259
260        // state: [ADD_REQUEST_START_TAG] -> Tag: </addRequest>
261        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_START_TAG.ordinal()].put( new Tag( "addRequest", Tag.END ),
262            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_START_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
263
264        // State: [ADD_REQUEST_START_TAG] - Tag: <control>
265        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
266            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_START_TAG,
267                Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_START_TAG, controlCreation ) );
268
269        // State: [ADD_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
270        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "controlValue", Tag.START ),
271            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_START_TAG,
272                Dsmlv2StatesEnum.ADD_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
273
274        // State: [ADD_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
275        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
276            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_CONTROLVALUE_END_TAG,
277                Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG, null ) );
278
279        // State: [ADD_REQUEST_CONTROL_START_TAG] - Tag: </control>
280        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
281            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_START_TAG,
282                Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG, null ) );
283
284        // State: [ADD_REQUEST_CONTROL_END_TAG] - Tag: <control>
285        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
286            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG,
287                Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_START_TAG, controlCreation ) );
288
289        // State: [ADD_REQUEST_CONTROL_END_TAG] - Tag: </addRequest>
290        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "addRequest", Tag.END ),
291            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP,
292                null ) );
293
294        // State: [ADD_REQUEST_START_TAG] - Tag: <attr>
295        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_START_TAG.ordinal()].put( new Tag( "attr", Tag.START ),
296            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_START_TAG, Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG,
297                addRequestAddAttribute ) );
298
299        // State: [ADD_REQUEST_CONTROL_END_TAG] - Tag: <attr>
300        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "attr", Tag.START ),
301            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_CONTROL_END_TAG,
302                Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG, addRequestAddAttribute ) );
303
304        // State: [ADD_REQUEST_ATTR_END_TAG] - Tag: <attr>
305        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_ATTR_END_TAG.ordinal()].put( new Tag( "attr", Tag.START ),
306            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_ATTR_END_TAG,
307                Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG, addRequestAddAttribute ) );
308
309        // State: [ADD_REQUEST_ATTR_START_TAG] - Tag: </attr>
310        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG.ordinal()].put( new Tag( "attr", Tag.END ),
311            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG,
312                Dsmlv2StatesEnum.ADD_REQUEST_ATTR_END_TAG, null ) );
313
314        // State: [ADD_REQUEST_ATTR_START_TAG] - Tag: <value>
315        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG.ordinal()].put( new Tag( "value", Tag.START ),
316            new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG,
317                Dsmlv2StatesEnum.ADD_REQUEST_ATTR_START_TAG, addRequestAddValue ) );
318
319        // State: [ADD_REQUEST_ATTR_END_TAG] - Tag: </addRequest>
320        super.transitions[Dsmlv2StatesEnum.ADD_REQUEST_ATTR_END_TAG.ordinal()]
321            .put( new Tag( "addRequest", Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.ADD_REQUEST_ATTR_END_TAG,
322                Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
323
324        //====================================================
325        //  Transitions concerning : AUTH REQUEST
326        //====================================================
327        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
328        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
329        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
330        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
331
332        // state: [AUTH_REQUEST_START_TAG] -> Tag: </authRequest>
333        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_START_TAG.ordinal()].put( new Tag( "authRequest", Tag.END ),
334            new GrammarTransition( Dsmlv2StatesEnum.AUTH_REQUEST_START_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
335
336        // State: [AUTH_REQUEST_START_TAG] - Tag: <control>
337        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
338            new GrammarTransition( Dsmlv2StatesEnum.AUTH_REQUEST_START_TAG,
339                Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_START_TAG, controlCreation ) );
340
341        // State: [AUTH_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
342        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "controlValue", Tag.START ),
343            new GrammarTransition( Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_START_TAG,
344                Dsmlv2StatesEnum.AUTH_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
345
346        // State: [AUTH_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
347        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
348            new GrammarTransition( Dsmlv2StatesEnum.AUTH_REQUEST_CONTROLVALUE_END_TAG,
349                Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_END_TAG, null ) );
350
351        // State: [AUTH_REQUEST_CONTROL_START_TAG] - Tag: </control>
352        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
353            new GrammarTransition( Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_START_TAG,
354                Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_END_TAG, null ) );
355
356        // State: [AUTH_REQUEST_CONTROL_END_TAG] - Tag: <control>
357        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
358            new GrammarTransition( Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_END_TAG,
359                Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_START_TAG, controlCreation ) );
360
361        // State: [AUTH_REQUEST_CONTROL_END_TAG] - Tag: </authRequest>
362        super.transitions[Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "authRequest", Tag.END ),
363            new GrammarTransition( Dsmlv2StatesEnum.AUTH_REQUEST_CONTROL_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP,
364                null ) );
365
366        //====================================================
367        //  Transitions concerning : COMPARE REQUEST
368        //====================================================
369        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
370        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
371        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
372        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
373        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
374        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
375        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_VALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
376
377        // State: [COMPARE_REQUEST_START_TAG] - Tag: <control>
378        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
379            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_START_TAG,
380                Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_START_TAG, controlCreation ) );
381
382        // State: [COMPARE_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
383        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_START_TAG.ordinal()].put(
384            new Tag( "controlValue", Tag.START ), new GrammarTransition(
385                Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_START_TAG,
386                Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
387
388        // State: [COMPARE_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
389        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
390            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROLVALUE_END_TAG,
391                Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG, null ) );
392
393        // State: [COMPARE_REQUEST_CONTROL_START_TAG] - Tag: </control>
394        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
395            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_START_TAG,
396                Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG, null ) );
397
398        // State: [COMPARE_REQUEST_CONTROL_END_TAG] - Tag: <control>
399        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
400            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG,
401                Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_START_TAG, controlCreation ) );
402
403        // State: [COMPARE_REQUEST_CONTROL_END_TAG] - Tag: </compareRequest>
404        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "compareRequest", Tag.END ),
405            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG,
406                Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
407
408        // State: [COMPARE_REQUEST_START_TAG] - Tag: <assertion>
409        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_START_TAG.ordinal()].put( new Tag( "assertion", Tag.START ),
410            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_START_TAG,
411                Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_START_TAG, compareRequestAddAssertion ) );
412
413        // State: [COMPARE_REQUEST_CONTROL_END_TAG] - Tag: <assertion>
414        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "assertion", Tag.START ),
415            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_CONTROL_END_TAG,
416                Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_START_TAG, compareRequestAddAssertion ) );
417
418        // State: [COMPARE_REQUEST_ASSERTION_START_TAG] - Tag: <value>
419        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_START_TAG.ordinal()].put( new Tag( "value", Tag.START ),
420            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_START_TAG,
421                Dsmlv2StatesEnum.COMPARE_REQUEST_VALUE_END_TAG, compareRequestAddValue ) );
422
423        //State: [COMPARE_REQUEST_VALUE_END_TAG] - Tag: </assertion>
424        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_VALUE_END_TAG.ordinal()].put( new Tag( "assertion", Tag.END ),
425            new GrammarTransition( Dsmlv2StatesEnum.COMPARE_REQUEST_VALUE_END_TAG,
426                Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_END_TAG, null ) );
427
428        // State: [COMPARE_REQUEST_ASSERTION_END_TAG] - Tag: </compareRequest>
429        super.transitions[Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_END_TAG.ordinal()].put(
430            new Tag( "compareRequest", Tag.END ), new GrammarTransition(
431                Dsmlv2StatesEnum.COMPARE_REQUEST_ASSERTION_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
432
433        //====================================================
434        //  Transitions concerning : DEL REQUEST
435        //====================================================
436        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
437        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
438        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
439        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
440
441        // State: [DEL_REQUEST_START_TAG] - Tag: </delRequest>
442        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_START_TAG.ordinal()].put( new Tag( "delRequest", Tag.END ),
443            new GrammarTransition( Dsmlv2StatesEnum.DEL_REQUEST_START_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
444
445        // State: [DEL_REQUEST_START_TAG] - Tag: <control>
446        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
447            new GrammarTransition( Dsmlv2StatesEnum.DEL_REQUEST_START_TAG,
448                Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_START_TAG, controlCreation ) );
449
450        // State: [DEL_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
451        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "controlValue", Tag.START ),
452            new GrammarTransition( Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_START_TAG,
453                Dsmlv2StatesEnum.DEL_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
454
455        // State: [DEL_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
456        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
457            new GrammarTransition( Dsmlv2StatesEnum.DEL_REQUEST_CONTROLVALUE_END_TAG,
458                Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_END_TAG, null ) );
459
460        // State: [DEL_REQUEST_CONTROL_START_TAG] - Tag: </control>
461        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
462            new GrammarTransition( Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_START_TAG,
463                Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_END_TAG, null ) );
464
465        // State: [DEL_REQUEST_CONTROL_END_TAG] - Tag: <control>
466        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
467            new GrammarTransition( Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_END_TAG,
468                Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_START_TAG, controlCreation ) );
469
470        // State: [DEL_REQUEST_CONTROL_END_TAG] - Tag: </delRequest>
471        super.transitions[Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "delRequest", Tag.END ),
472            new GrammarTransition( Dsmlv2StatesEnum.DEL_REQUEST_CONTROL_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP,
473                null ) );
474
475        //====================================================
476        //  Transitions concerning : EXTENDED REQUEST
477        //====================================================
478        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
479        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
480        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
481        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
482        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTNAME_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
483        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
484
485        // State: [EXTENDED_REQUEST_START_TAG] - Tag: <control>
486        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
487            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_START_TAG,
488                Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_START_TAG, controlCreation ) );
489
490        // State: [EXTENDED_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
491        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_START_TAG.ordinal()].put(
492            new Tag( "controlValue", Tag.START ), new GrammarTransition(
493                Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_START_TAG,
494                Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
495
496        // State: [EXTENDED_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
497        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
498            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROLVALUE_END_TAG,
499                Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG, null ) );
500
501        // State: [EXTENDED_REQUEST_CONTROL_START_TAG] - Tag: </control>
502        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
503            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_START_TAG,
504                Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG, null ) );
505
506        // State: [EXTENDED_REQUEST_CONTROL_END_TAG] - Tag: <control>
507        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
508            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG,
509                Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_START_TAG, controlCreation ) );
510
511        // State: [EXTENDED_REQUEST_CONTROL_END_TAG] - Tag: </extendedRequest>
512        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG.ordinal()].put(
513            new Tag( "extendedRequest", Tag.END ), new GrammarTransition(
514                Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
515
516        // State: [EXTENDED_REQUEST_START_TAG] - Tag: <requestName>
517        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_START_TAG.ordinal()].put( new Tag( "requestName", Tag.START ),
518            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_START_TAG,
519                Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTNAME_END_TAG, extendedRequestAddName ) );
520
521        // State: [EXTENDED_REQUEST_CONTROL_END_TAG] - Tag: <requestName>
522        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "requestName", Tag.START ),
523            new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_CONTROL_END_TAG,
524                Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTNAME_END_TAG, extendedRequestAddName ) );
525
526        // State: [EXTENDED_REQUEST_REQUESTNAME_END_TAG] - Tag: </extendedRequest>
527        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTNAME_END_TAG.ordinal()].put( new Tag( "extendedRequest",
528            Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTNAME_END_TAG,
529            Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
530
531        // State: [EXTENDED_REQUEST_REQUESTNAME_END_TAG] - Tag: <requestValue>
532        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTNAME_END_TAG.ordinal()].put( new Tag( "requestValue",
533            Tag.START ), new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTNAME_END_TAG,
534            Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTVALUE_END_TAG, extendedRequestAddValue ) );
535
536        // State: [EXTENDED_REQUEST_REQUESTVALUE_END_TAG] - Tag: </requestRequest>
537        super.transitions[Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTVALUE_END_TAG.ordinal()].put( new Tag( "extendedRequest",
538            Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_REQUEST_REQUESTVALUE_END_TAG,
539            Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
540
541        //====================================================
542        //  Transitions concerning : MODIFY Dn REQUEST
543        //====================================================
544        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
545        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
546        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
547        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
548
549        // State: [MODIFY_DN_REQUEST_START_TAG] - Tag: </modDNRequest>
550        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_START_TAG.ordinal()].put( new Tag( "modDNRequest", Tag.END ),
551            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_DN_REQUEST_START_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP,
552                null ) );
553
554        // State: [MODIFY_DN_REQUEST_START_TAG] - Tag: <control>
555        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
556            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_DN_REQUEST_START_TAG,
557                Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_START_TAG, controlCreation ) );
558
559        // State: [MODIFY_DN_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
560        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_START_TAG.ordinal()].put(
561            new Tag( "controlValue", Tag.START ), new GrammarTransition(
562                Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_START_TAG,
563                Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
564
565        // State: [MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
566        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
567            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG,
568                Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_END_TAG, null ) );
569
570        // State: [MODIFY_DN_REQUEST_CONTROL_START_TAG] - Tag: </control>
571        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
572            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_START_TAG,
573                Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_END_TAG, null ) );
574
575        // State: [MODIFY_DN_REQUEST_CONTROL_END_TAG] - Tag: <control>
576        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
577            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_END_TAG,
578                Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_START_TAG, controlCreation ) );
579
580        // State: [MODIFY_DN_REQUEST_CONTROL_END_TAG] - Tag: </modDNRequest>
581        super.transitions[Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "modDNRequest", Tag.END ),
582            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_DN_REQUEST_CONTROL_END_TAG,
583                Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
584
585        //====================================================
586        //  Transitions concerning : MODIFY REQUEST
587        //====================================================
588        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
589        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
590        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
591        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
592        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
593        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
594        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_VALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
595
596        // State: [MODIFY_REQUEST_START_TAG] - Tag: </modifyRequest>
597        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG.ordinal()]
598            .put( new Tag( "modifyRequest", Tag.END ), new GrammarTransition(
599                Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
600
601        // State: [MODIFY_REQUEST_START_TAG] - Tag: <control>
602        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
603            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG,
604                Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_START_TAG, controlCreation ) );
605
606        // State: [MODIFY_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
607        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "controlValue", Tag.START ),
608            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_START_TAG,
609                Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
610
611        // State: [MODIFY_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
612        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
613            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROLVALUE_END_TAG,
614                Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG, null ) );
615
616        // State: [MODIFY_REQUEST_CONTROL_START_TAG] - Tag: </control>
617        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
618            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_START_TAG,
619                Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG, null ) );
620
621        // State: [MODIFY_REQUEST_CONTROL_END_TAG] - Tag: <control>
622        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
623            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG,
624                Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_START_TAG, controlCreation ) );
625
626        // State: [MODIFY_REQUEST_CONTROL_END_TAG] - Tag: </modifyRequest>
627        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "modifyRequest", Tag.END ),
628            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP,
629                null ) );
630
631        // State: [MODIFY_REQUEST_CONTROL_END_TAG] - Tag: <modification>
632        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "modification", Tag.START ),
633            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_CONTROL_END_TAG,
634                Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_START_TAG, modifyRequestAddModification ) );
635
636        // State: [MODIFY_REQUEST_START_TAG] - Tag: <modification>
637        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG.ordinal()].put( new Tag( "modification", Tag.START ),
638            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_START_TAG,
639                Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_START_TAG, modifyRequestAddModification ) );
640
641        // State: [MODIFY_REQUEST_MODIFICATION_END_TAG] - Tag: <modification>
642        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_END_TAG.ordinal()].put(
643            new Tag( "modification", Tag.START ), new GrammarTransition(
644                Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_END_TAG,
645                Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_START_TAG, modifyRequestAddModification ) );
646
647        // State: [MODIFY_REQUEST_MODIFICATION_START_TAG] - Tag: </modification>
648        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_START_TAG.ordinal()].put(
649            new Tag( "modification", Tag.END ), new GrammarTransition(
650                Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_START_TAG,
651                Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_END_TAG, null ) );
652
653        // State: [MODIFY_REQUEST_MODIFICATION_START_TAG] - Tag: <value>
654        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_START_TAG.ordinal()].put( new Tag( "value", Tag.START ),
655            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_START_TAG,
656                Dsmlv2StatesEnum.MODIFY_REQUEST_VALUE_END_TAG, modifyRequestAddValue ) );
657
658        // State: [MODIFY_REQUEST_VALUE_END_TAG] - Tag: <value>
659        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_VALUE_END_TAG.ordinal()].put( new Tag( "value", Tag.START ),
660            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_VALUE_END_TAG,
661                Dsmlv2StatesEnum.MODIFY_REQUEST_VALUE_END_TAG, modifyRequestAddValue ) );
662
663        // State: [MODIFY_REQUEST_VALUE_END_TAG] - Tag: </modification>
664        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_VALUE_END_TAG.ordinal()].put( new Tag( "modification", Tag.END ),
665            new GrammarTransition( Dsmlv2StatesEnum.MODIFY_REQUEST_VALUE_END_TAG,
666                Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_END_TAG, null ) );
667
668        // State: [MODIFY_REQUEST_MODIFICATION_END_TAG] - Tag: </modifyRequest>
669        super.transitions[Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_END_TAG.ordinal()].put(
670            new Tag( "modifyRequest", Tag.END ), new GrammarTransition(
671                Dsmlv2StatesEnum.MODIFY_REQUEST_MODIFICATION_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP, null ) );
672
673        //====================================================
674        //  Transitions concerning : SEARCH REQUEST
675        //====================================================
676        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
677        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
678        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
679        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROLVALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
680        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
681        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
682        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
683        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
684
685        // State: [SEARCH_REQUEST_START_TAG] - Tag: <control>
686        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_START_TAG.ordinal()].put( new Tag( "control", Tag.START ),
687            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_START_TAG,
688                Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_START_TAG, controlCreation ) );
689
690        // State: [SEARCH_REQUEST_CONTROL_START_TAG] - Tag: <controlValue>
691        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "controlValue", Tag.START ),
692            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_START_TAG,
693                Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROLVALUE_END_TAG, controlValueCreation ) );
694
695        // State: [SEARCH_REQUEST_CONTROLVALUE_END_TAG] - Tag: </control>
696        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROLVALUE_END_TAG.ordinal()].put( new Tag( "control", Tag.END ),
697            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROLVALUE_END_TAG,
698                Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG, null ) );
699
700        // State: [SEARCH_REQUEST_CONTROL_START_TAG] - Tag: </control>
701        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_START_TAG.ordinal()].put( new Tag( "control", Tag.END ),
702            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_START_TAG,
703                Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG, null ) );
704
705        // State: [SEARCH_REQUEST_CONTROL_END_TAG] - Tag: <control>
706        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "control", Tag.START ),
707            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG,
708                Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_START_TAG, controlCreation ) );
709        
710        // State: [SEARCH_REQUEST_FILTER_END_TAG] - Tag: </searchRequest>
711        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "searchRequest", Tag.END ),
712            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP,
713                storeFilter ) );
714
715        // State: [SEARCH_REQUEST_ATTRIBUTES_START_TAG] - Tag: </attributes>
716        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_START_TAG.ordinal()].put( new Tag( "attributes", Tag.END ),
717            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_START_TAG,
718                Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_END_TAG, null ) );
719
720        // State: [SEARCH_REQUEST_ATTRIBUTES_START_TAG] - Tag: <attribute>
721        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_START_TAG.ordinal()].put( new Tag( "attribute", Tag.START ),
722            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_START_TAG,
723                Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_START_TAG, searchRequestAddAttribute ) );
724
725        // State: [SEARCH_REQUEST_ATTRIBUTE_START_TAG] - Tag: </attribute>
726        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_START_TAG.ordinal()].put( new Tag( "attribute", Tag.END ),
727            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_START_TAG,
728                Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_END_TAG, null ) );
729
730        // State: [SEARCH_REQUEST_ATTRIBUTE_END_TAG] - Tag: <attribute>
731        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_END_TAG.ordinal()].put( new Tag( "attribute", Tag.START ),
732            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_END_TAG,
733                Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_START_TAG, searchRequestAddAttribute ) );
734
735        // State: [SEARCH_REQUEST_ATTRIBUTE_END_TAG] - Tag: </attributes>
736        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_END_TAG.ordinal()].put( new Tag( "attributes", Tag.END ),
737            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTE_END_TAG,
738                Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_END_TAG, null ) );
739
740        // State: [SEARCH_REQUEST_ATTRIBUTES_END_TAG] - Tag: </searchRequest>
741        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_END_TAG.ordinal()].put( new Tag( "searchRequest", Tag.END ),
742            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_END_TAG,
743                Dsmlv2StatesEnum.BATCHREQUEST_LOOP, storeFilter ) );
744
745        //====================================================
746        //  Transitions concerning : FILTER
747        //====================================================
748        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
749        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
750        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()] = new HashMap<Tag, GrammarTransition>();
751        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_EQUALITYMATCH_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
752        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_GREATEROREQUAL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
753        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_LESSOREQUAL_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
754        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_APPROXMATCH_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
755        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_PRESENT_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
756        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
757        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
758        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
759
760        // State: [SEARCH_REQUEST_START_TAG] - Tag: <filter>
761        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_START_TAG.ordinal()].put( new Tag( "filter", Tag.START ),
762            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_START_TAG,
763                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG, null ) );
764
765        // State: [SEARCH_REQUEST_CONTROL_END_TAG] - Tag: <filter>
766        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG.ordinal()].put( new Tag( "filter", Tag.START ),
767            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_CONTROL_END_TAG,
768                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG, null ) );
769
770        //*** AND ***
771        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <and>
772        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put( new Tag( "and", Tag.START ),
773            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
774                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, andFilterCreation ) );
775
776        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <and>
777        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "and", Tag.START ),
778            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
779                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, andFilterCreation ) );
780
781        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: </and>
782        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "and", Tag.END ),
783            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
784                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, connectorFilterClose ) );
785
786        //*** OR ***
787        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <or>
788        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put( new Tag( "or", Tag.START ),
789            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
790                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, orFilterCreation ) );
791
792        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <or>
793        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "or", Tag.START ),
794            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
795                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, orFilterCreation ) );
796
797        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: </or>
798        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "or", Tag.END ),
799            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
800                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, connectorFilterClose ) );
801
802        //*** NOT ***
803        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <not>
804        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put( new Tag( "not", Tag.START ),
805            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
806                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, notFilterCreation ) );
807
808        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <not>
809        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "not", Tag.START ),
810            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
811                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, notFilterCreation ) );
812
813        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: </not>
814        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "not", Tag.END ),
815            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
816                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, connectorFilterClose ) );
817
818        //*** SUBSTRINGS ***
819        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <substrings>
820        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put( new Tag( "substrings", Tag.START ),
821            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
822                Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG, substringsFilterCreation ) );
823
824        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <substrings>
825        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "substrings", Tag.START ),
826            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
827                Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG, substringsFilterCreation ) );
828
829        //*** EQUALITY MATCH ***
830        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <equalityMatch>
831        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put( new Tag( "equalityMatch", Tag.START ),
832            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
833                Dsmlv2StatesEnum.SEARCH_REQUEST_EQUALITYMATCH_START_TAG, equalityMatchFilterCreation ) );
834
835        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <equalityMatch>
836        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "equalityMatch", Tag.START ),
837            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
838                Dsmlv2StatesEnum.SEARCH_REQUEST_EQUALITYMATCH_START_TAG, equalityMatchFilterCreation ) );
839
840        // State: [SEARCH_REQUEST_EQUALITYMATCH_START_TAG] - Tag: <value>
841        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_EQUALITYMATCH_START_TAG.ordinal()].put( new Tag( "value", Tag.START ),
842            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_EQUALITYMATCH_START_TAG,
843                Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG, filterAddValue ) );
844
845        // State: [SEARCH_REQUEST_VALUE_END_TAG] - Tag: </equalityMatch>
846        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG.ordinal()].put( new Tag( "equalityMatch", Tag.END ),
847            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG,
848                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, null ) );
849
850        //*** GREATER OR EQUAL ***
851        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <greaterOrEqual>
852        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put(
853            new Tag( "greaterOrEqual", Tag.START ), new GrammarTransition(
854                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
855                Dsmlv2StatesEnum.SEARCH_REQUEST_GREATEROREQUAL_START_TAG, greaterOrEqualFilterCreation ) );
856
857        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <greaterOrEqual>
858        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "greaterOrEqual", Tag.START ),
859            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
860                Dsmlv2StatesEnum.SEARCH_REQUEST_GREATEROREQUAL_START_TAG, greaterOrEqualFilterCreation ) );
861
862        // State: [SEARCH_REQUEST_GREATEROREQUAL_START_TAG] - Tag: <value>
863        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_GREATEROREQUAL_START_TAG.ordinal()].put( new Tag( "value", Tag.START ),
864            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_GREATEROREQUAL_START_TAG,
865                Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG, filterAddValue ) );
866
867        // State: [SEARCH_REQUEST_VALUE_END_TAG] - Tag: </greaterOrEqual>
868        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG.ordinal()].put( new Tag( "greaterOrEqual", Tag.END ),
869            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG,
870                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, null ) );
871
872        //*** LESS OR EQUAL ***
873        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <lessOrEqual>
874        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put( new Tag( "lessOrEqual", Tag.START ),
875            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
876                Dsmlv2StatesEnum.SEARCH_REQUEST_LESSOREQUAL_START_TAG, lessOrEqualFilterCreation ) );
877
878        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <lessOrEqual>
879        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "lessOrEqual", Tag.START ),
880            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
881                Dsmlv2StatesEnum.SEARCH_REQUEST_LESSOREQUAL_START_TAG, lessOrEqualFilterCreation ) );
882
883        // State: [SEARCH_REQUEST_LESSOREQUAL_START_TAG] - Tag: <value>
884        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_LESSOREQUAL_START_TAG.ordinal()].put( new Tag( "value", Tag.START ),
885            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_LESSOREQUAL_START_TAG,
886                Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG, filterAddValue ) );
887
888        // State: [SEARCH_REQUEST_VALUE_END_TAG] - Tag: </lessOrEqual>
889        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG.ordinal()].put( new Tag( "lessOrEqual", Tag.END ),
890            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG,
891                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, null ) );
892
893        //*** LESS OR EQUAL ***
894        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <approxMatch>
895        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put( new Tag( "approxMatch", Tag.START ),
896            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
897                Dsmlv2StatesEnum.SEARCH_REQUEST_APPROXMATCH_START_TAG, approxMatchFilterCreation ) );
898
899        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <approxMatch>
900        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "approxMatch", Tag.START ),
901            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
902                Dsmlv2StatesEnum.SEARCH_REQUEST_APPROXMATCH_START_TAG, approxMatchFilterCreation ) );
903
904        // State: [SEARCH_REQUEST_APPROXMATCH_START_TAG] - Tag: <value>
905        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_APPROXMATCH_START_TAG.ordinal()].put( new Tag( "value", Tag.START ),
906            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_APPROXMATCH_START_TAG,
907                Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG, filterAddValue ) );
908
909        // State: [SEARCH_REQUEST_VALUE_END_TAG] - Tag: </approxMatch>
910        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG.ordinal()].put( new Tag( "approxMatch", Tag.END ),
911            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_VALUE_END_TAG,
912                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, null ) );
913
914        //*** PRESENT ***
915        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <present>
916        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put( new Tag( "present", Tag.START ),
917            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
918                Dsmlv2StatesEnum.SEARCH_REQUEST_PRESENT_START_TAG, presentFilterCreation ) );
919
920        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <present>
921        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "present", Tag.START ),
922            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
923                Dsmlv2StatesEnum.SEARCH_REQUEST_PRESENT_START_TAG, presentFilterCreation ) );
924
925        // State: [SEARCH_REQUEST_PRESENT_START_TAG] - Tag: </present>
926        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_PRESENT_START_TAG.ordinal()].put( new Tag( "present", Tag.END ),
927            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_PRESENT_START_TAG,
928                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, null ) );
929
930        //*** EXTENSIBLE MATCH ***
931        // State: [SEARCH_REQUEST_FILTER_START_TAG] - Tag: <extensibleMatch>
932        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG.ordinal()].put(
933            new Tag( "extensibleMatch", Tag.START ), new GrammarTransition(
934                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_START_TAG,
935                Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG, extensibleMatchFilterCreation ) );
936
937        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: <extensibleMatch>
938        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "extensibleMatch", Tag.START ),
939            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
940                Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG, extensibleMatchFilterCreation ) );
941
942        // State: [SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG] - Tag: <value>
943        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG.ordinal()].put(
944            new Tag( "value", Tag.START ), new GrammarTransition(
945                Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG,
946                Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG, extensibleMatchAddValue ) );
947
948        // State: [SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG] - Tag: </extensibleMatch>
949        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG.ordinal()].put( new Tag(
950            "extensibleMatch", Tag.END ), new GrammarTransition(
951            Dsmlv2StatesEnum.SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG, Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
952            null ) );
953
954        //*** Filter (end) ***
955        // State: [SEARCH_REQUEST_FILTER_LOOP] - Tag: </filter>
956        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP.ordinal()].put( new Tag( "filter", Tag.END ),
957            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP,
958                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_END_TAG, null ) );
959
960        // State: [SEARCH_REQUEST_FILTER_END_TAG] - Tag: <attributes>
961        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_END_TAG.ordinal()].put( new Tag( "attributes", Tag.START ),
962            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_END_TAG,
963                Dsmlv2StatesEnum.SEARCH_REQUEST_ATTRIBUTES_START_TAG, null ) );
964
965        // State: [SEARCH_REQUEST_FILTER_END_TAG] - Tag: </searchRequest>
966        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_END_TAG.ordinal()].put( new Tag( "searchRequest", Tag.END ),
967            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_END_TAG, Dsmlv2StatesEnum.BATCHREQUEST_LOOP,
968                storeFilter ) );
969
970        //====================================================
971        //  Transitions concerning : SUBSTRING FILTER
972        //====================================================
973        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
974        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_INITIAL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
975        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
976        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FINAL_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
977        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
978
979        // State: [SEARCH_REQUEST_SUBSTRINGS_START_TAG] - Tag: </substrings>
980        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG.ordinal()].put( new Tag( "substrings", Tag.END ),
981            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG,
982                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, null ) );
983
984        // State: [SEARCH_REQUEST_SUBSTRINGS_START_TAG] - Tag: <initial>
985        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG.ordinal()].put( new Tag( "initial", Tag.START ),
986            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG,
987                Dsmlv2StatesEnum.SEARCH_REQUEST_INITIAL_END_TAG, substringsFilterSetInitial ) );
988
989        // State: [SEARCH_REQUEST_INITIAL_END_TAG] - Tag: <any>
990        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_INITIAL_END_TAG.ordinal()].put( new Tag( "any", Tag.START ),
991            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_INITIAL_END_TAG,
992                Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG, substringsFilterAddAny ) );
993
994        // State: [SEARCH_REQUEST_INITIAL_END_TAG] - Tag: <final>
995        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_INITIAL_END_TAG.ordinal()].put( new Tag( "final", Tag.START ),
996            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_INITIAL_END_TAG,
997                Dsmlv2StatesEnum.SEARCH_REQUEST_FINAL_END_TAG, substringsFilterSetFinal ) );
998
999        // State: [SEARCH_REQUEST_INITIAL_END_TAG] - Tag: </substrings>
1000        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_INITIAL_END_TAG.ordinal()].put( new Tag( "substrings", Tag.END ),
1001            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_INITIAL_END_TAG,
1002                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, substringsFilterClose ) );
1003
1004        // State: [SEARCH_REQUEST_SUBSTRINGS_START_TAG] - Tag: <any>
1005        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG.ordinal()].put( new Tag( "any", Tag.START ),
1006            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG,
1007                Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG, substringsFilterAddAny ) );
1008
1009        // State: [SEARCH_REQUEST_ANY_END_TAG] - Tag: </any>
1010        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG.ordinal()].put( new Tag( "any", Tag.START ),
1011            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG,
1012                Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG, substringsFilterAddAny ) );
1013
1014        // State: [SEARCH_REQUEST_ANY_END_TAG] - Tag: <final>
1015        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG.ordinal()].put( new Tag( "final", Tag.START ),
1016            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG,
1017                Dsmlv2StatesEnum.SEARCH_REQUEST_FINAL_END_TAG, substringsFilterSetFinal ) );
1018
1019        // State: [SEARCH_REQUEST_ANY_END_TAG] - Tag: </substrings>
1020        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG.ordinal()].put( new Tag( "substrings", Tag.END ),
1021            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_ANY_END_TAG,
1022                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, substringsFilterClose ) );
1023
1024        // State: [SEARCH_REQUEST_SUBSTRINGS_START_TAG] - Tag: <final>
1025        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG.ordinal()].put( new Tag( "final", Tag.START ),
1026            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_SUBSTRINGS_START_TAG,
1027                Dsmlv2StatesEnum.SEARCH_REQUEST_FINAL_END_TAG, substringsFilterSetFinal ) );
1028
1029        // State: [SEARCH_REQUEST_FINAL_END_TAG] - Tag: </substrings>
1030        super.transitions[Dsmlv2StatesEnum.SEARCH_REQUEST_FINAL_END_TAG.ordinal()].put( new Tag( "substrings", Tag.END ),
1031            new GrammarTransition( Dsmlv2StatesEnum.SEARCH_REQUEST_FINAL_END_TAG,
1032                Dsmlv2StatesEnum.SEARCH_REQUEST_FILTER_LOOP, substringsFilterClose ) );
1033
1034        
1035        //------------------------------------------ handle SOAP envelopes --------------------------
1036        super.transitions[Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
1037        super.transitions[Dsmlv2StatesEnum.SOAP_HEADER_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
1038        super.transitions[Dsmlv2StatesEnum.SOAP_HEADER_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
1039        super.transitions[Dsmlv2StatesEnum.SOAP_BODY_START_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
1040        super.transitions[Dsmlv2StatesEnum.SOAP_BODY_END_TAG.ordinal()] = new HashMap<Tag, GrammarTransition>();
1041        
1042        super.transitions[Dsmlv2StatesEnum.GRAMMAR_END.ordinal()] = new HashMap<Tag, GrammarTransition>();
1043        
1044        // State: [INIT_GRAMMAR_STATE] - Tag: <envelope>
1045        super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE.ordinal()].put( new Tag( "envelope", Tag.START ),
1046            new GrammarTransition( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE, Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG,
1047                null ) );
1048        
1049        // state: [SOAP_ENVELOPE_START_TAG] -> Tag: <header>
1050        super.transitions[Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG.ordinal()].put( new Tag( "header", Tag.START ),
1051            new GrammarTransition( Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG, Dsmlv2StatesEnum.SOAP_HEADER_START_TAG, readSoapHeader ) );
1052
1053        // state: [SOAP_HEADER_START_TAG] -> Tag: </header>
1054        super.transitions[Dsmlv2StatesEnum.SOAP_HEADER_START_TAG.ordinal()].put( new Tag( "header", Tag.END ),
1055            new GrammarTransition( Dsmlv2StatesEnum.SOAP_HEADER_START_TAG, Dsmlv2StatesEnum.SOAP_HEADER_END_TAG, null ) );
1056
1057        // state: [SOAP_HEADER_END_TAG] -> Tag: <body>
1058        super.transitions[Dsmlv2StatesEnum.SOAP_HEADER_END_TAG.ordinal()].put( new Tag( "body", Tag.START ),
1059            new GrammarTransition( Dsmlv2StatesEnum.SOAP_HEADER_END_TAG, Dsmlv2StatesEnum.SOAP_BODY_START_TAG, null ) );
1060
1061        // state: [SOAP_BODY_START_TAG] -> Tag: <batchRequest>
1062        super.transitions[Dsmlv2StatesEnum.SOAP_BODY_START_TAG.ordinal()].put( new Tag( "batchRequest", Tag.START ),
1063            new GrammarTransition( Dsmlv2StatesEnum.SOAP_BODY_START_TAG, Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, batchRequestCreation ) );
1064
1065        // the optional transition if no soap header is present
1066        // state: [SOAP_ENVELOPE_START_TAG] -> Tag: <body>
1067        super.transitions[Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG.ordinal()].put( new Tag( "body", Tag.START ),
1068            new GrammarTransition( Dsmlv2StatesEnum.SOAP_ENVELOPE_START_TAG, Dsmlv2StatesEnum.SOAP_BODY_START_TAG, null ) );
1069
1070        // the below two transitions are a bit unconventional, technically the container's state is set to GRAMMAR_END
1071        // when the </batchRequest> tag is encountered by the parser and the corresponding action gets executed but in
1072        // a SOAP envelop we still have two more end tags(</body> and </envelope>) are left so we set those corresponding
1073        // current and next transition states always to GRAMMAR_END
1074        super.transitions[Dsmlv2StatesEnum.GRAMMAR_END.ordinal()].put( new Tag( "body", Tag.END ),
1075            new GrammarTransition( Dsmlv2StatesEnum.GRAMMAR_END, Dsmlv2StatesEnum.GRAMMAR_END, null ) );
1076
1077        super.transitions[Dsmlv2StatesEnum.GRAMMAR_END.ordinal()].put( new Tag( "envelope", Tag.END ),
1078            new GrammarTransition( Dsmlv2StatesEnum.GRAMMAR_END, Dsmlv2StatesEnum.GRAMMAR_END, null ) );
1079
1080        //------------------------------------------
1081
1082    } // End of the constructor
1083
1084    
1085    
1086    /**
1087     * @return The LDAP codec service.
1088     */
1089    public LdapApiService getLdapCodecService()
1090    {
1091        return codec;
1092    }
1093    
1094    
1095    //*************************
1096    //*    GRAMMAR ACTIONS    *
1097    //*************************
1098
1099    /**
1100     * GrammarAction that creates an Abandon Request
1101     */
1102    private final GrammarAction batchRequestCreation = new GrammarAction( "Create Batch Request" )
1103    {
1104        public void action( Dsmlv2Container container ) throws XmlPullParserException
1105        {
1106            BatchRequestDsml batchRequest = new BatchRequestDsml();
1107
1108            container.setBatchRequest( batchRequest );
1109
1110            XmlPullParser xpp = container.getParser();
1111
1112            // Checking and adding the batchRequest's attributes
1113            String attributeValue;
1114            // requestID
1115            attributeValue = xpp.getAttributeValue( "", "requestID" );
1116            
1117            if ( attributeValue != null )
1118            {
1119                batchRequest.setRequestID( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1120            }
1121            // processing
1122            attributeValue = xpp.getAttributeValue( "", "processing" );
1123            
1124            if ( attributeValue != null )
1125            {
1126                if ( "sequential".equals( attributeValue ) )
1127                {
1128                    batchRequest.setProcessing( Processing.SEQUENTIAL );
1129                }
1130                else if ( "parallel".equals( attributeValue ) )
1131                {
1132                    batchRequest.setProcessing( Processing.PARALLEL );
1133                }
1134                else
1135                {
1136                    throw new XmlPullParserException( I18n.err( I18n.ERR_03013 ), xpp, null );
1137                }
1138            }
1139            else
1140            {
1141                batchRequest.setProcessing( Processing.SEQUENTIAL );
1142            }
1143            
1144            // onError
1145            attributeValue = xpp.getAttributeValue( "", "onError" );
1146            
1147            if ( attributeValue != null )
1148            {
1149                if ( "resume".equals( attributeValue ) )
1150                {
1151                    batchRequest.setOnError( OnError.RESUME );
1152                }
1153                else if ( "exit".equals( attributeValue ) )
1154                {
1155                    batchRequest.setOnError( OnError.EXIT );
1156                }
1157                else
1158                {
1159                    throw new XmlPullParserException( I18n.err( I18n.ERR_03014 ), xpp, null );
1160                }
1161            }
1162            else
1163            {
1164                batchRequest.setOnError( OnError.EXIT );
1165            }
1166            
1167            // responseOrder
1168            attributeValue = xpp.getAttributeValue( "", "responseOrder" );
1169            
1170            if ( attributeValue != null )
1171            {
1172                if ( "sequential".equals( attributeValue ) )
1173                {
1174                    batchRequest.setResponseOrder( ResponseOrder.SEQUENTIAL );
1175                }
1176                else if ( "unordered".equals( attributeValue ) )
1177                {
1178                    batchRequest.setResponseOrder( ResponseOrder.UNORDERED );
1179                }
1180                else
1181                {
1182                    throw new XmlPullParserException( I18n.err( I18n.ERR_03015 ), xpp, null );
1183                }
1184            }
1185            else
1186            {
1187                batchRequest.setResponseOrder( ResponseOrder.SEQUENTIAL );
1188            }
1189        }
1190    };
1191
1192    /**
1193     * GrammarAction that creates an Abandon Request
1194     */
1195    private final GrammarAction abandonRequestCreation = new GrammarAction( "Create Abandon Request" )
1196    {
1197        public void action( Dsmlv2Container container ) throws XmlPullParserException
1198        {
1199            AbandonRequestDsml abandonRequest = new AbandonRequestDsml( codec, new AbandonRequestImpl() );
1200            container.getBatchRequest().addRequest( abandonRequest );
1201
1202            XmlPullParser xpp = container.getParser();
1203
1204            // Checking and adding the request's attributes
1205            String attributeValue;
1206            // requestID
1207            attributeValue = xpp.getAttributeValue( "", "requestID" );
1208            if ( attributeValue != null )
1209            {
1210                abandonRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1211            }
1212            else
1213            {
1214                if ( ParserUtils.isRequestIdNeeded( container ) )
1215                {
1216                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1217                }
1218            }
1219            // abandonID
1220            attributeValue = xpp.getAttributeValue( "", "abandonID" );
1221            if ( attributeValue != null )
1222            {
1223                try
1224                {
1225                    abandonRequest.setAbandoned( Integer.parseInt( attributeValue ) );
1226                }
1227                catch ( NumberFormatException e )
1228                {
1229                    throw new XmlPullParserException( I18n.err( I18n.ERR_03017 ), xpp, null );
1230                }
1231            }
1232            else
1233            {
1234                throw new XmlPullParserException( I18n.err( I18n.ERR_03018 ), xpp, null );
1235            }
1236        }
1237    };
1238
1239    /**
1240     * GrammarAction that creates an Add Request
1241     */
1242    private final GrammarAction addRequestCreation = new GrammarAction( "Create Add Request" )
1243    {
1244        public void action( Dsmlv2Container container ) throws XmlPullParserException
1245        {
1246            AddRequestDsml addRequest = new AddRequestDsml( codec, new AddRequestImpl() );
1247            container.getBatchRequest().addRequest( addRequest );
1248
1249            XmlPullParser xpp = container.getParser();
1250
1251            // Checking and adding the request's attributes
1252            String attributeValue;
1253            // requestID
1254            attributeValue = xpp.getAttributeValue( "", "requestID" );
1255            if ( attributeValue != null )
1256            {
1257                addRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1258            }
1259            else
1260            {
1261                if ( ParserUtils.isRequestIdNeeded( container ) )
1262                {
1263                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1264                }
1265            }
1266            // dn
1267            attributeValue = xpp.getAttributeValue( "", "dn" );
1268            if ( attributeValue != null )
1269            {
1270                try
1271                {
1272                    addRequest.setEntryDn( new Dn( attributeValue ) );
1273                }
1274                catch ( LdapInvalidDnException e )
1275                {
1276                    throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1277                }
1278            }
1279            else
1280            {
1281                throw new XmlPullParserException( I18n.err( I18n.ERR_03019 ), xpp, null );
1282            }
1283        }
1284    };
1285
1286    /**
1287     * GrammarAction that adds an attribute to an Add Request
1288     */
1289    private final GrammarAction addRequestAddAttribute = new GrammarAction( "Add Attribute to Add Request" )
1290    {
1291        public void action( Dsmlv2Container container ) throws XmlPullParserException
1292        {
1293            AddRequestDsml addRequest = ( AddRequestDsml ) 
1294                container.getBatchRequest().getCurrentRequest();
1295
1296            XmlPullParser xpp = container.getParser();
1297
1298            // Checking and adding the request's attributes
1299            String attributeValue;
1300            // name
1301            attributeValue = xpp.getAttributeValue( "", "name" );
1302            
1303            if ( attributeValue != null )
1304            {
1305                try
1306                {
1307                    addRequest.addAttributeType( attributeValue );
1308                }
1309                catch ( LdapException e )
1310                {
1311                    throw new XmlPullParserException( I18n.err( I18n.ERR_03020 ), xpp, e );
1312                }
1313            }
1314            else
1315            {
1316                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
1317            }
1318        }
1319    };
1320
1321    /**
1322     * GrammarAction that adds a Value to an Attribute of an Add Request
1323     */
1324    private final GrammarAction addRequestAddValue = new GrammarAction( "Add Value to Attribute" )
1325    {
1326        public void action( Dsmlv2Container container ) throws XmlPullParserException
1327        {
1328            AddRequestDsml addRequest = ( AddRequestDsml ) 
1329                container.getBatchRequest().getCurrentRequest();
1330
1331            XmlPullParser xpp = container.getParser();
1332            
1333            try
1334            {
1335                // We have to catch the type Attribute Value before going to the next Text node
1336                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
1337
1338                // Getting the value
1339                String nextText = xpp.nextText();
1340                if ( !nextText.equals( "" ) )
1341                {
1342                    try
1343                    {
1344                        if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
1345                        {
1346                            addRequest.addAttributeValue( Base64.decode( nextText.trim().toCharArray() ) );
1347                        }
1348                        else
1349                        {
1350                            addRequest.addAttributeValue( nextText.trim() );
1351                        }
1352                    }
1353                    catch ( LdapException le )
1354                    {
1355                        throw new XmlPullParserException( le.getMessage() );
1356                    }
1357                }
1358            }
1359            catch ( IOException e )
1360            {
1361                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1362            }
1363        }
1364    };
1365
1366    /**
1367     * GrammarAction that creates an Auth Request
1368     */
1369    private final GrammarAction authRequestCreation = new GrammarAction( "Create Auth Request" )
1370    {
1371        public void action( Dsmlv2Container container ) throws XmlPullParserException
1372        {
1373            BindRequestDsml authRequest = new BindRequestDsml( codec, new BindRequestImpl() );
1374            container.getBatchRequest().addRequest( authRequest );
1375
1376            authRequest.setSimple( true );
1377            authRequest.setVersion3( true );
1378
1379            XmlPullParser xpp = container.getParser();
1380
1381            // Checking and adding the request's attributes
1382            String attributeValue;
1383            // requestID
1384            attributeValue = xpp.getAttributeValue( "", "requestID" );
1385
1386            if ( attributeValue != null )
1387            {
1388                authRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1389            }
1390            else
1391            {
1392                if ( ParserUtils.isRequestIdNeeded( container ) )
1393                {
1394                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1395                }
1396            }
1397            // principal
1398            attributeValue = xpp.getAttributeValue( "", "principal" );
1399
1400            if ( attributeValue != null )
1401            {
1402                try
1403                {
1404                    authRequest.setName( new Dn( attributeValue ) );
1405                }
1406                catch ( LdapInvalidDnException e )
1407                {
1408                    throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1409                }
1410            }
1411            else
1412            {
1413                throw new XmlPullParserException( I18n.err( I18n.ERR_03021 ), xpp, null );
1414            }
1415        }
1416    };
1417
1418    /**
1419     * GrammarAction that creates an Compare Request
1420     */
1421    private final GrammarAction compareRequestCreation = new GrammarAction( "Create Compare Request" )
1422    {
1423        public void action( Dsmlv2Container container ) throws XmlPullParserException
1424        {
1425            CompareRequestDsml compareRequest = new CompareRequestDsml( codec, new CompareRequestImpl() );
1426            container.getBatchRequest().addRequest( compareRequest );
1427
1428            XmlPullParser xpp = container.getParser();
1429
1430            // Checking and adding the request's attributes
1431            String attributeValue;
1432            // requestID
1433            attributeValue = xpp.getAttributeValue( "", "requestID" );
1434
1435            if ( attributeValue != null )
1436            {
1437                compareRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1438            }
1439            else
1440            {
1441                if ( ParserUtils.isRequestIdNeeded( container ) )
1442                {
1443                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1444                }
1445            }
1446
1447            // dn
1448            attributeValue = xpp.getAttributeValue( "", "dn" );
1449
1450            if ( attributeValue != null )
1451            {
1452                try
1453                {
1454                    compareRequest.setName( new Dn( attributeValue ) );
1455                }
1456                catch ( LdapInvalidDnException e )
1457                {
1458                    throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1459                }
1460            }
1461            else
1462            {
1463                throw new XmlPullParserException( I18n.err( I18n.ERR_03019 ), xpp, null );
1464            }
1465        }
1466    };
1467
1468    /**
1469     * GrammarAction that adds an Assertion to a Compare Request
1470     */
1471    private final GrammarAction compareRequestAddAssertion = new GrammarAction( "Add Assertion to Compare Request" )
1472    {
1473        public void action( Dsmlv2Container container ) throws XmlPullParserException
1474        {
1475            CompareRequest compareRequest = ( CompareRequest ) container.getBatchRequest().getCurrentRequest();
1476
1477            XmlPullParser xpp = container.getParser();
1478
1479            // Checking and adding the request's attributes
1480            String attributeId;
1481
1482            // name
1483            attributeId = xpp.getAttributeValue( "", "name" );
1484
1485            if ( attributeId != null )
1486            {
1487                compareRequest.setAttributeId( attributeId );
1488            }
1489            else
1490            {
1491                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
1492            }
1493        }
1494    };
1495
1496    /**
1497     * GrammarAction that adds a Value to a Compare Request
1498     */
1499    private final GrammarAction compareRequestAddValue = new GrammarAction( "Add Value to Compare Request" )
1500    {
1501        public void action( Dsmlv2Container container ) throws XmlPullParserException
1502        {
1503            CompareRequest compareRequest = ( CompareRequest ) container.getBatchRequest().getCurrentRequest();
1504
1505            XmlPullParser xpp = container.getParser();
1506
1507            try
1508            {
1509                // We have to catch the type Attribute Value before going to the next Text node
1510                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
1511
1512                // Getting the value
1513                String nextText = xpp.nextText();
1514
1515                if ( !nextText.equals( "" ) )
1516                {
1517                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
1518                    {
1519                        compareRequest.setAssertionValue( Base64.decode( nextText.trim().toCharArray() ) );
1520                    }
1521                    else
1522                    {
1523                        compareRequest.setAssertionValue( nextText.trim() );
1524                    }
1525                }
1526            }
1527            catch ( IOException e )
1528            {
1529                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1530            }
1531        }
1532    };
1533
1534    /**
1535     * GrammarAction that creates a Del Request
1536     */
1537    private final GrammarAction delRequestCreation = new GrammarAction( "Create Del Request" )
1538    {
1539        public void action( Dsmlv2Container container ) throws XmlPullParserException
1540        {
1541            DelRequestDsml delRequest = new DelRequestDsml( codec, new DeleteRequestImpl() );
1542            container.getBatchRequest().addRequest( delRequest );
1543
1544            XmlPullParser xpp = container.getParser();
1545
1546            // Checking and adding the request's attributes
1547            String attributeValue;
1548            // requestID
1549            attributeValue = xpp.getAttributeValue( "", "requestID" );
1550
1551            if ( attributeValue != null )
1552            {
1553                delRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1554            }
1555            else
1556            {
1557                if ( ParserUtils.isRequestIdNeeded( container ) )
1558                {
1559                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1560                }
1561            }
1562
1563            // dn
1564            attributeValue = xpp.getAttributeValue( "", "dn" );
1565
1566            if ( attributeValue != null )
1567            {
1568                try
1569                {
1570                    delRequest.setName( new Dn( attributeValue ) );
1571                }
1572                catch ( LdapInvalidDnException e )
1573                {
1574                    throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1575                }
1576            }
1577            else
1578            {
1579                throw new XmlPullParserException( I18n.err( I18n.ERR_03019 ), xpp, null );
1580            }
1581        }
1582    };
1583
1584    /**
1585     * GrammarAction that creates an Extended Request
1586     */
1587    private final GrammarAction extendedRequestCreation = new GrammarAction( "Create Extended Request" )
1588    {
1589        public void action( Dsmlv2Container container ) throws XmlPullParserException
1590        {
1591            ExtendedRequestDsml<?,?> extendedRequest = 
1592                new ExtendedRequestDsml<ExtendedRequest<ExtendedResponse>,ExtendedResponse>( codec, new ExtendedRequestImpl() );
1593            container.getBatchRequest().addRequest( extendedRequest );
1594
1595            XmlPullParser xpp = container.getParser();
1596
1597            // Checking and adding the request's attributes
1598            String attributeValue;
1599            // requestID
1600            attributeValue = xpp.getAttributeValue( "", "requestID" );
1601
1602            if ( attributeValue != null )
1603            {
1604                extendedRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1605            }
1606            else
1607            {
1608                if ( ParserUtils.isRequestIdNeeded( container ) )
1609                {
1610                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1611                }
1612            }
1613        }
1614    };
1615
1616    /**
1617     * GrammarAction that adds a Name to an Extended Request
1618     */
1619    private final GrammarAction extendedRequestAddName = new GrammarAction( "Add Name to Extended Request" )
1620    {
1621        public void action( Dsmlv2Container container ) throws XmlPullParserException
1622        {
1623            ExtendedRequestDsml<?,?> extendedRequest = ( ExtendedRequestDsml<?,?> ) 
1624                container.getBatchRequest().getCurrentRequest();
1625
1626            XmlPullParser xpp = container.getParser();
1627
1628            try
1629            {
1630                String nextText = xpp.nextText();
1631
1632                if ( nextText.equals( "" ) )
1633                {
1634                    throw new XmlPullParserException( I18n.err( I18n.ERR_03022 ), xpp, null );
1635                }
1636                else
1637                {
1638                    String oid = nextText.trim();
1639
1640                    if ( Oid.isOid( oid ) )
1641                    {
1642                        extendedRequest.setRequestName( nextText.trim() );
1643                    }
1644                    else
1645                    {
1646                        throw new XmlPullParserException( "Bad oid : " + oid, xpp, null );
1647                    }
1648                }
1649            }
1650            catch ( IOException e )
1651            {
1652                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1653            }
1654        }
1655    };
1656
1657    /**
1658     * GrammarAction that adds a Value to an Extended Request
1659     */
1660    private final GrammarAction extendedRequestAddValue = new GrammarAction( "Add Value to Extended Request" )
1661    {
1662        public void action( Dsmlv2Container container ) throws XmlPullParserException
1663        {
1664            ExtendedRequestDsml<?,?> extendedRequest = ( ExtendedRequestDsml<?,?> ) 
1665                container.getBatchRequest().getCurrentRequest();
1666
1667            XmlPullParser xpp = container.getParser();
1668
1669            try
1670            {
1671                // We have to catch the type Attribute Value before going to the next Text node
1672                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
1673
1674                // Getting the value
1675                String nextText = xpp.nextText();
1676
1677                if ( !nextText.equals( "" ) )
1678                {
1679                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
1680                    {
1681                        extendedRequest.setRequestValue( Base64.decode( nextText.trim().toCharArray() ) );
1682                    }
1683                    else
1684                    {
1685                        extendedRequest.setRequestValue( nextText.trim().getBytes() );
1686                    }
1687                }
1688            }
1689            catch ( IOException e )
1690            {
1691                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1692            }
1693        }
1694    };
1695
1696    /**
1697     * GrammarAction that creates a Modify Dn Request
1698     */
1699    private final GrammarAction modDNRequestCreation = new GrammarAction( "Create Modify Dn Request" )
1700    {
1701        public void action( Dsmlv2Container container ) throws XmlPullParserException
1702        {
1703            ModifyDNRequestDsml modifyDNRequest = new ModifyDNRequestDsml( codec, new ModifyDnRequestImpl() );
1704            container.getBatchRequest().addRequest( modifyDNRequest );
1705
1706            XmlPullParser xpp = container.getParser();
1707
1708            // Checking and adding the request's attributes
1709            String attributeValue;
1710            // requestID
1711            attributeValue = xpp.getAttributeValue( "", "requestID" );
1712
1713            if ( attributeValue != null )
1714            {
1715                modifyDNRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1716            }
1717            else
1718            {
1719                if ( ParserUtils.isRequestIdNeeded( container ) )
1720                {
1721                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1722                }
1723            }
1724
1725            // dn
1726            attributeValue = xpp.getAttributeValue( "", "dn" );
1727
1728            if ( attributeValue != null )
1729            {
1730                try
1731                {
1732                    modifyDNRequest.setName( new Dn( attributeValue ) );
1733                }
1734                catch ( LdapInvalidDnException e )
1735                {
1736                    throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1737                }
1738            }
1739            else
1740            {
1741                throw new XmlPullParserException( I18n.err( I18n.ERR_03019 ), xpp, null );
1742            }
1743
1744            // newrdn
1745            attributeValue = xpp.getAttributeValue( "", "newrdn" );
1746
1747            if ( attributeValue != null )
1748            {
1749                try
1750                {
1751                    modifyDNRequest.setNewRdn( new Rdn( attributeValue ) );
1752                }
1753                catch ( LdapInvalidDnException e )
1754                {
1755                    throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1756                }
1757            }
1758            else
1759            {
1760                throw new XmlPullParserException( I18n.err( I18n.ERR_03023 ), xpp, null );
1761            }
1762
1763            // deleteoldrdn
1764            attributeValue = xpp.getAttributeValue( "", "deleteoldrdn" );
1765
1766            if ( attributeValue != null )
1767            {
1768                if ( ( attributeValue.equalsIgnoreCase( "true" ) ) || ( attributeValue.equals( "1" ) ) )
1769                {
1770                    modifyDNRequest.setDeleteOldRdn( true );
1771                }
1772                else if ( ( attributeValue.equalsIgnoreCase( "false" ) ) || ( attributeValue.equals( "0" ) ) )
1773                {
1774                    modifyDNRequest.setDeleteOldRdn( false );
1775                }
1776                else
1777                {
1778                    throw new XmlPullParserException( I18n.err( I18n.ERR_03024 ), xpp, null );
1779                }
1780            }
1781            else
1782            {
1783                modifyDNRequest.setDeleteOldRdn( true );
1784            }
1785
1786            // newsuperior
1787            attributeValue = xpp.getAttributeValue( "", "newSuperior" );
1788
1789            if ( attributeValue != null )
1790            {
1791                try
1792                {
1793                    modifyDNRequest.setNewSuperior( new Dn( attributeValue ) );
1794                }
1795                catch ( LdapInvalidDnException e )
1796                {
1797                    throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1798                }
1799            }
1800        }
1801    };
1802
1803    /**
1804     * GrammarAction that creates a Modify Request
1805     */
1806    private final GrammarAction modifyRequestCreation = new GrammarAction( "Create Modify Request" )
1807    {
1808        public void action( Dsmlv2Container container ) throws XmlPullParserException
1809        {
1810            ModifyRequestDsml modifyRequest = new ModifyRequestDsml( codec, new ModifyRequestImpl() );
1811            container.getBatchRequest().addRequest( modifyRequest );
1812
1813            XmlPullParser xpp = container.getParser();
1814
1815            // Checking and adding the request's attributes
1816            String attributeValue;
1817            // requestID
1818            attributeValue = xpp.getAttributeValue( "", "requestID" );
1819
1820            if ( attributeValue != null )
1821            {
1822                modifyRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1823            }
1824            else
1825            {
1826                if ( ParserUtils.isRequestIdNeeded( container ) )
1827                {
1828                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1829                }
1830            }
1831
1832            // dn
1833            attributeValue = xpp.getAttributeValue( "", "dn" );
1834
1835            if ( attributeValue != null )
1836            {
1837                try
1838                {
1839                    modifyRequest.setName( new Dn( attributeValue ) );
1840                }
1841                catch ( LdapInvalidDnException e )
1842                {
1843                    throw new XmlPullParserException( "" + e.getLocalizedMessage(), xpp, null );
1844                }
1845            }
1846            else
1847            {
1848                throw new XmlPullParserException( "dn attribute is required", xpp, null );
1849            }
1850        }
1851    };
1852
1853    /**
1854     * GrammarAction that adds a Modification to a Modify Request
1855     */
1856    private final GrammarAction modifyRequestAddModification = new GrammarAction( "Adds Modification to Modify Request" )
1857    {
1858        public void action( Dsmlv2Container container ) throws XmlPullParserException
1859        {
1860            ModifyRequestDsml modifyRequest = ( ModifyRequestDsml ) 
1861                container.getBatchRequest().getCurrentRequest();
1862
1863            XmlPullParser xpp = container.getParser();
1864
1865            // Checking and adding the request's attributes
1866            String attributeValue;
1867            // operation
1868            attributeValue = xpp.getAttributeValue( "", "operation" );
1869
1870            if ( attributeValue != null )
1871            {
1872                if ( "add".equals( attributeValue ) )
1873                {
1874                    modifyRequest.setCurrentOperation( LdapConstants.OPERATION_ADD );
1875                }
1876                else if ( "delete".equals( attributeValue ) )
1877                {
1878                    modifyRequest.setCurrentOperation( LdapConstants.OPERATION_DELETE );
1879                }
1880                else if ( "replace".equals( attributeValue ) )
1881                {
1882                    modifyRequest.setCurrentOperation( LdapConstants.OPERATION_REPLACE );
1883                }
1884                else
1885                {
1886                    throw new XmlPullParserException(
1887                        "unknown operation. Operation can be 'add', 'delete' or 'replace'.", xpp, null );
1888                }
1889            }
1890            else
1891            {
1892                throw new XmlPullParserException( I18n.err( I18n.ERR_03025 ), xpp, null );
1893            }
1894
1895            // name
1896            attributeValue = xpp.getAttributeValue( "", "name" );
1897
1898            if ( attributeValue != null )
1899            {
1900                modifyRequest.addAttributeTypeAndValues( attributeValue );
1901            }
1902            else
1903            {
1904                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
1905            }
1906        }
1907    };
1908
1909    /**
1910     * GrammarAction that adds a Value to a Modification of a Modify Request
1911     */
1912    private final GrammarAction modifyRequestAddValue = new GrammarAction(
1913        "Add Value to Modification of Modify Request" )
1914    {
1915        public void action( Dsmlv2Container container ) throws XmlPullParserException
1916        {
1917            ModifyRequestDsml modifyRequest = ( ModifyRequestDsml ) 
1918                container.getBatchRequest().getCurrentRequest();
1919
1920            XmlPullParser xpp = container.getParser();
1921
1922            try
1923            {
1924                // We have to catch the type Attribute Value before going to the next Text node
1925                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
1926
1927                // Getting the value
1928                String nextText = xpp.nextText();
1929                // We are testing if nextText equals "" since a modification can be "".
1930
1931                try
1932                {
1933                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
1934                    {
1935                        modifyRequest.addAttributeValue( Base64.decode(nextText.trim().toCharArray()) );
1936                    }
1937                    else
1938                    {
1939                        modifyRequest.addAttributeValue( nextText.trim() );
1940                    }
1941                }
1942                catch ( LdapException le )
1943                {
1944                    throw new XmlPullParserException( le.getMessage() );
1945                }
1946            }
1947            catch ( IOException e )
1948            {
1949                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1950            }
1951        }
1952    };
1953
1954    /**
1955     * GrammarAction that creates a Search Request
1956     */
1957    private final GrammarAction searchRequestCreation = new GrammarAction( "Create Search Request" )
1958    {
1959        public void action( Dsmlv2Container container ) throws XmlPullParserException
1960        {
1961            SearchRequestDsml searchRequest = new SearchRequestDsml( codec, new SearchRequestImpl() );
1962            container.getBatchRequest().addRequest( searchRequest );
1963
1964            XmlPullParser xpp = container.getParser();
1965
1966            // Checking and adding the request's attributes
1967            String attributeValue;
1968            // requestID
1969            attributeValue = xpp.getAttributeValue( "", "requestID" );
1970
1971            if ( attributeValue != null )
1972            {
1973                searchRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1974            }
1975            else
1976            {
1977                if ( ParserUtils.isRequestIdNeeded( container ) )
1978                {
1979                    throw new XmlPullParserException( I18n.err( I18n.ERR_03016 ), xpp, null );
1980                }
1981            }
1982
1983            // dn
1984            attributeValue = xpp.getAttributeValue( "", "dn" );
1985
1986            if ( attributeValue != null )
1987            {
1988                try
1989                {
1990                    searchRequest.setBase( new Dn( attributeValue ) );
1991                }
1992                catch ( LdapInvalidDnException e )
1993                {
1994                    throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1995                }
1996            }
1997            else
1998            {
1999                throw new XmlPullParserException( I18n.err( I18n.ERR_03019 ), xpp, null );
2000            }
2001
2002            // scope
2003            attributeValue = xpp.getAttributeValue( "", "scope" );
2004
2005            if ( attributeValue != null )
2006            {
2007                if ( "baseObject".equals( attributeValue ) )
2008                {
2009                    searchRequest.setScope( SearchScope.OBJECT );
2010                }
2011                else if ( "singleLevel".equals( attributeValue ) )
2012                {
2013                    searchRequest.setScope( SearchScope.ONELEVEL );
2014                }
2015                else if ( "wholeSubtree".equals( attributeValue ) )
2016                {
2017                    searchRequest.setScope( SearchScope.SUBTREE );
2018                }
2019                else
2020                {
2021                    throw new XmlPullParserException( I18n.err( I18n.ERR_03026 ), xpp, null );
2022                }
2023            }
2024            else
2025            {
2026                throw new XmlPullParserException( I18n.err( I18n.ERR_03027 ), xpp, null );
2027            }
2028
2029            // derefAliases
2030            attributeValue = xpp.getAttributeValue( "", "derefAliases" );
2031
2032            if ( attributeValue != null )
2033            {
2034                if ( "neverDerefAliases".equals( attributeValue ) )
2035                {
2036                    searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
2037                }
2038                else if ( "derefInSearching".equals( attributeValue ) )
2039                {
2040                    searchRequest.setDerefAliases( AliasDerefMode.DEREF_IN_SEARCHING );
2041                }
2042                else if ( "derefFindingBaseObj".equals( attributeValue ) )
2043                {
2044                    searchRequest.setDerefAliases( AliasDerefMode.DEREF_FINDING_BASE_OBJ );
2045                }
2046                else if ( "derefAlways".equals( attributeValue ) )
2047                {
2048                    searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );
2049                }
2050                else
2051                {
2052                    throw new XmlPullParserException( I18n.err( I18n.ERR_03028 ), xpp, null );
2053                }
2054            }
2055            else
2056            {
2057                throw new XmlPullParserException( I18n.err( I18n.ERR_03029 ), xpp, null );
2058            }
2059
2060            // sizeLimit
2061            attributeValue = xpp.getAttributeValue( "", "sizeLimit" );
2062
2063            if ( attributeValue != null )
2064            {
2065                try
2066                {
2067                    searchRequest.setSizeLimit( Long.parseLong( attributeValue ) );
2068                }
2069                catch ( NumberFormatException e )
2070                {
2071                    throw new XmlPullParserException( I18n.err( I18n.ERR_03030 ), xpp, null );
2072                }
2073            }
2074            else
2075            {
2076                searchRequest.setSizeLimit( 0L );
2077            }
2078
2079            // timeLimit
2080            attributeValue = xpp.getAttributeValue( "", "timeLimit" );
2081
2082            if ( attributeValue != null )
2083            {
2084                try
2085                {
2086                    searchRequest.setTimeLimit( Integer.parseInt( attributeValue ) );
2087                }
2088                catch ( NumberFormatException e )
2089                {
2090                    throw new XmlPullParserException( I18n.err( I18n.ERR_03031 ), xpp, null );
2091                }
2092            }
2093            else
2094            {
2095                searchRequest.setTimeLimit( 0 );
2096            }
2097
2098            // typesOnly
2099            attributeValue = xpp.getAttributeValue( "", "typesOnly" );
2100
2101            if ( attributeValue != null )
2102            {
2103                if ( ( attributeValue.equals( "true" ) ) || ( attributeValue.equals( "1" ) ) )
2104                {
2105                    searchRequest.setTypesOnly( true );
2106                }
2107                else if ( ( attributeValue.equals( "false" ) ) || ( attributeValue.equals( "0" ) ) )
2108                {
2109                    searchRequest.setTypesOnly( false );
2110                }
2111                else
2112                {
2113                    throw new XmlPullParserException( I18n.err( I18n.ERR_03032 ), xpp, null );
2114                }
2115            }
2116            else
2117            {
2118                searchRequest.setTypesOnly( false );
2119            }
2120        }
2121    };
2122
2123    /**
2124     * GrammarAction that adds an Attribute to a Search Request
2125     */
2126    private final GrammarAction searchRequestAddAttribute = new GrammarAction(
2127        "Add Value to Modification of Modify Request" )
2128    {
2129        public void action( Dsmlv2Container container ) throws XmlPullParserException
2130        {
2131            SearchRequest searchRequest = ( SearchRequest ) container.getBatchRequest().getCurrentRequest();
2132
2133            XmlPullParser xpp = container.getParser();
2134
2135            // Checking and adding the request's attribute name
2136            String attributeName = xpp.getAttributeValue( "", "name" );
2137
2138            if ( attributeName != null )
2139            {
2140                searchRequest.addAttributes( attributeName );
2141            }
2142            else
2143            {
2144                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
2145            }
2146        }
2147    };
2148
2149    /**
2150     * GrammarAction that create a Substring Filter
2151     */
2152    private final GrammarAction substringsFilterCreation = new GrammarAction( "Create Substring Filter" )
2153    {
2154        public void action( Dsmlv2Container container ) throws XmlPullParserException
2155        {
2156            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2157                container.getBatchRequest().getCurrentRequest();
2158
2159            XmlPullParser xpp = container.getParser();
2160
2161            SubstringFilter filter = new SubstringFilter();
2162
2163            // Adding the filter to the Search Filter
2164            try
2165            {
2166                searchRequestDecorator.addCurrentFilter( filter );
2167            }
2168            catch ( DecoderException e )
2169            {
2170                throw new XmlPullParserException( e.getMessage(), xpp, null );
2171            }
2172            
2173            searchRequestDecorator.setTerminalFilter( filter );
2174
2175            // Checking and adding the filter's attributes
2176            String attributeValue;
2177            // name
2178            attributeValue = xpp.getAttributeValue( "", "name" );
2179
2180            if ( attributeValue != null )
2181            {
2182                filter.setType( attributeValue );
2183            }
2184            else
2185            {
2186                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
2187            }
2188        }
2189    };
2190
2191    /**
2192     * GrammarAction that sets the Initial value to a Substring Filter
2193     */
2194    private final GrammarAction substringsFilterSetInitial = new GrammarAction( "Set Initial value to Substring Filter" )
2195    {
2196        public void action( Dsmlv2Container container ) throws XmlPullParserException
2197        {
2198            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2199                container.getBatchRequest().getCurrentRequest();
2200
2201            SubstringFilter substringFilter = ( SubstringFilter ) 
2202                searchRequestDecorator.getTerminalFilter();
2203
2204            XmlPullParser xpp = container.getParser();
2205
2206            try
2207            {
2208                // We have to catch the type Attribute Value before going to the next Text node
2209                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
2210
2211                // Getting the value
2212                String nextText = xpp.nextText();
2213
2214                if ( !nextText.equals( "" ) )
2215                {
2216                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
2217                    {
2218                        substringFilter
2219                            .setInitialSubstrings( new String( Base64.decode( nextText.trim().toCharArray() ) ) );
2220                    }
2221                    else
2222                    {
2223                        substringFilter.setInitialSubstrings( nextText.trim() );
2224                    }
2225                }
2226            }
2227            catch ( IOException e )
2228            {
2229                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
2230            }
2231        }
2232    };
2233
2234    /**
2235     * GrammarAction that adds a Any value to a Substring Filter
2236     */
2237    private final GrammarAction substringsFilterAddAny = new GrammarAction( "Add Any value to Substring Filter" )
2238    {
2239        public void action( Dsmlv2Container container ) throws XmlPullParserException
2240        {
2241            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2242                container.getBatchRequest().getCurrentRequest();
2243
2244            SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
2245
2246            XmlPullParser xpp = container.getParser();
2247
2248            try
2249            {
2250                // We have to catch the type Attribute Value before going to the next Text node
2251                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
2252
2253                // Getting the value
2254                String nextText = xpp.nextText();
2255
2256                if ( !nextText.equals( "" ) )
2257                {
2258                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
2259                    {
2260                        substringFilter.addAnySubstrings( new String( Base64.decode( nextText.trim().toCharArray() ) ) );
2261                    }
2262                    else
2263                    {
2264                        substringFilter.addAnySubstrings( nextText.trim() );
2265                    }
2266                }
2267            }
2268            catch ( IOException e )
2269            {
2270                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
2271            }
2272        }
2273    };
2274
2275    /**
2276     * GrammarAction that sets the Final value to a Substring Filter
2277     */
2278    private final GrammarAction substringsFilterSetFinal = new GrammarAction( "Set Final value to Substring Filter" )
2279    {
2280        public void action( Dsmlv2Container container ) throws XmlPullParserException
2281        {
2282            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2283                container.getBatchRequest().getCurrentRequest();
2284
2285            SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();
2286
2287            XmlPullParser xpp = container.getParser();
2288
2289            try
2290            {
2291                // We have to catch the type Attribute Value before going to the next Text node
2292                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
2293
2294                // Getting the value
2295                String nextText = xpp.nextText();
2296
2297                if ( !nextText.equals( "" ) )
2298                {
2299                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
2300                    {
2301                        substringFilter
2302                            .setFinalSubstrings( new String( Base64.decode( nextText.trim().toCharArray() ) ) );
2303                    }
2304                    else
2305                    {
2306                        substringFilter.setFinalSubstrings( nextText.trim() );
2307                    }
2308                }
2309            }
2310            catch ( IOException e )
2311            {
2312                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
2313            }
2314        }
2315    };
2316
2317    /**
2318     * GrammarAction that closes a Substring Filter
2319     */
2320    private final GrammarAction substringsFilterClose = new GrammarAction( "Close Substring Filter" )
2321    {
2322        public void action( Dsmlv2Container container ) throws XmlPullParserException
2323        {
2324            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2325                container.getBatchRequest().getCurrentRequest();
2326
2327            searchRequestDecorator.setTerminalFilter( null );
2328        }
2329    };
2330
2331    /**
2332     * GrammarAction that create a And Filter
2333     */
2334    private final GrammarAction andFilterCreation = new GrammarAction( "Create And Filter" )
2335    {
2336        public void action( Dsmlv2Container container ) throws XmlPullParserException
2337        {
2338            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2339                container.getBatchRequest().getCurrentRequest();
2340
2341            XmlPullParser xpp = container.getParser();
2342
2343            AndFilter filter = new AndFilter();
2344
2345            // Adding the filter to the Search Filter
2346            try
2347            {
2348                searchRequestDecorator.addCurrentFilter( filter );
2349            }
2350            catch ( DecoderException e )
2351            {
2352                throw new XmlPullParserException( e.getMessage(), xpp, null );
2353            }
2354        }
2355    };
2356
2357    /**
2358     * GrammarAction that closes a Connector Filter (And, Or, Not)
2359     */
2360    private final GrammarAction connectorFilterClose = new GrammarAction( "Close Connector Filter" )
2361    {
2362        public void action( Dsmlv2Container container ) throws XmlPullParserException
2363        {
2364            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2365                container.getBatchRequest().getCurrentRequest();
2366
2367            Filter filter = searchRequestDecorator.getCurrentFilter();
2368
2369            searchRequestDecorator.setCurrentFilter( filter );
2370        }
2371    };
2372
2373    /**
2374     * GrammarAction that create a Or Filter
2375     */
2376    private final GrammarAction orFilterCreation = new GrammarAction( "Create Or Filter" )
2377    {
2378        public void action( Dsmlv2Container container ) throws XmlPullParserException
2379        {
2380            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2381                container.getBatchRequest().getCurrentRequest();
2382
2383            XmlPullParser xpp = container.getParser();
2384
2385            OrFilter filter = new OrFilter();
2386
2387            // Adding the filter to the Search Filter
2388            try
2389            {
2390                searchRequestDecorator.addCurrentFilter( filter );
2391            }
2392            catch ( DecoderException e )
2393            {
2394                throw new XmlPullParserException( e.getMessage(), xpp, null );
2395            }
2396        }
2397    };
2398
2399    /**
2400     * GrammarAction that create a Not Filter
2401     */
2402    private final GrammarAction notFilterCreation = new GrammarAction( "Create Not Filter" )
2403    {
2404        public void action( Dsmlv2Container container ) throws XmlPullParserException
2405        {
2406            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2407                container.getBatchRequest().getCurrentRequest();
2408
2409            XmlPullParser xpp = container.getParser();
2410
2411            NotFilter filter = new NotFilter();
2412
2413            // Adding the filter to the Search Filter
2414            try
2415            {
2416                searchRequestDecorator.addCurrentFilter( filter );
2417            }
2418            catch ( DecoderException e )
2419            {
2420                throw new XmlPullParserException( e.getMessage(), xpp, null );
2421            }
2422        }
2423    };
2424
2425    /**
2426     * GrammarAction that create a Equality Match Filter
2427     */
2428    private final GrammarAction equalityMatchFilterCreation = new GrammarAction( "Create Equality Match Filter" )
2429    {
2430        public void action( Dsmlv2Container container ) throws XmlPullParserException
2431        {
2432            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2433                container.getBatchRequest().getCurrentRequest();
2434
2435            XmlPullParser xpp = container.getParser();
2436
2437            AttributeValueAssertion assertion = new AttributeValueAssertion();
2438
2439            // Checking and adding the filter's attributes
2440            String attributeName = xpp.getAttributeValue( "", "name" );
2441
2442            if ( attributeName != null )
2443            {
2444                assertion.setAttributeDesc( attributeName );
2445            }
2446            else
2447            {
2448                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
2449            }
2450
2451            AttributeValueAssertionFilter filter = new AttributeValueAssertionFilter(
2452                LdapConstants.EQUALITY_MATCH_FILTER );
2453
2454            filter.setAssertion( assertion );
2455
2456            // Adding the filter to the Search Filter
2457            try
2458            {
2459                searchRequestDecorator.addCurrentFilter( filter );
2460            }
2461            catch ( DecoderException e )
2462            {
2463                throw new XmlPullParserException( e.getMessage(), xpp, null );
2464            }
2465
2466            searchRequestDecorator.setTerminalFilter( filter );
2467        }
2468    };
2469
2470    /**
2471     * GrammarAction that create a Greater Or Equal Filter
2472     */
2473    private final GrammarAction greaterOrEqualFilterCreation = new GrammarAction( "Create Greater Or Equal Filter" )
2474    {
2475        public void action( Dsmlv2Container container ) throws XmlPullParserException
2476        {
2477            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2478                container.getBatchRequest().getCurrentRequest();
2479
2480            XmlPullParser xpp = container.getParser();
2481
2482            AttributeValueAssertion assertion = new AttributeValueAssertion();
2483
2484            // Checking and adding the filter's attributes
2485            String attributeName = xpp.getAttributeValue( "", "name" );
2486
2487            if ( attributeName != null )
2488            {
2489                assertion.setAttributeDesc( attributeName );
2490            }
2491            else
2492            {
2493                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
2494            }
2495
2496            AttributeValueAssertionFilter filter = new AttributeValueAssertionFilter(
2497                LdapConstants.GREATER_OR_EQUAL_FILTER );
2498
2499            filter.setAssertion( assertion );
2500
2501            // Adding the filter to the Search Filter
2502            try
2503            {
2504                searchRequestDecorator.addCurrentFilter( filter );
2505            }
2506            catch ( DecoderException e )
2507            {
2508                throw new XmlPullParserException( e.getMessage(), xpp, null );
2509            }
2510
2511            searchRequestDecorator.setTerminalFilter( filter );
2512        }
2513    };
2514
2515    /**
2516     * GrammarAction that create a Less Or Equal Filter
2517     */
2518    private final GrammarAction lessOrEqualFilterCreation = new GrammarAction( "Create Less Or Equal Filter" )
2519    {
2520        public void action( Dsmlv2Container container ) throws XmlPullParserException
2521        {
2522            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2523                container.getBatchRequest().getCurrentRequest();
2524
2525            XmlPullParser xpp = container.getParser();
2526
2527            AttributeValueAssertion assertion = new AttributeValueAssertion();
2528
2529            // Checking and adding the filter's attributes
2530            String attributeValue;
2531            // name
2532            attributeValue = xpp.getAttributeValue( "", "name" );
2533
2534            if ( attributeValue != null )
2535            {
2536                assertion.setAttributeDesc( new String( attributeValue.getBytes() ) );
2537            }
2538            else
2539            {
2540                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
2541            }
2542
2543            AttributeValueAssertionFilter filter = new AttributeValueAssertionFilter(
2544                LdapConstants.LESS_OR_EQUAL_FILTER );
2545
2546            filter.setAssertion( assertion );
2547
2548            // Adding the filter to the Search Filter
2549            try
2550            {
2551                searchRequestDecorator.addCurrentFilter( filter );
2552            }
2553            catch ( DecoderException e )
2554            {
2555                throw new XmlPullParserException( e.getMessage(), xpp, null );
2556            }
2557
2558            searchRequestDecorator.setTerminalFilter( filter );
2559        }
2560    };
2561
2562    /**
2563     * GrammarAction that create an Approx Match Filter
2564     */
2565    private final GrammarAction approxMatchFilterCreation = new GrammarAction( "Create Approx Match Filter" )
2566    {
2567        public void action( Dsmlv2Container container ) throws XmlPullParserException
2568        {
2569            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2570                container.getBatchRequest().getCurrentRequest();
2571
2572            XmlPullParser xpp = container.getParser();
2573
2574            AttributeValueAssertion assertion = new AttributeValueAssertion();
2575
2576            // Checking and adding the filter's attributes
2577            String attributeName = xpp.getAttributeValue( "", "name" );
2578
2579            if ( attributeName != null )
2580            {
2581                assertion.setAttributeDesc( attributeName );
2582            }
2583            else
2584            {
2585                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
2586            }
2587
2588            AttributeValueAssertionFilter filter = new AttributeValueAssertionFilter( LdapConstants.APPROX_MATCH_FILTER );
2589
2590            filter.setAssertion( assertion );
2591
2592            // Adding the filter to the Search Filter
2593            try
2594            {
2595                searchRequestDecorator.addCurrentFilter( filter );
2596            }
2597            catch ( DecoderException e )
2598            {
2599                throw new XmlPullParserException( e.getMessage(), xpp, null );
2600            }
2601
2602            searchRequestDecorator.setTerminalFilter( filter );
2603        }
2604    };
2605
2606    /**
2607     * GrammarAction that adds a Value to a Filter
2608     */
2609    private final GrammarAction filterAddValue = new GrammarAction( "Adds Value to Filter" )
2610    {
2611        public void action( Dsmlv2Container container ) throws XmlPullParserException
2612        {
2613            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml )
2614                container.getBatchRequest().getCurrentRequest();
2615            AttributeValueAssertionFilter filter = ( AttributeValueAssertionFilter ) searchRequestDecorator.getTerminalFilter();
2616            AttributeValueAssertion assertion = filter.getAssertion();
2617
2618            XmlPullParser xpp = container.getParser();
2619
2620            try
2621            {
2622                // We have to catch the type Attribute Value before going to the next Text node
2623                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
2624
2625                // Getting the value
2626                String nextText = xpp.nextText();
2627
2628                if ( !nextText.equals( "" ) )
2629                {
2630                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
2631                    {
2632                        Value<byte[]> value = new BinaryValue( Base64.decode( nextText.trim().toCharArray() ) );
2633                        assertion.setAssertionValue( value );
2634                    }
2635                    else
2636                    {
2637                        Value<String> value = new StringValue( nextText.trim() );
2638                        assertion.setAssertionValue( value );
2639                    }
2640                }
2641            }
2642            catch ( IOException e )
2643            {
2644                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
2645            }
2646        }
2647    };
2648
2649    /**
2650     * GrammarAction that creates a Present Filter
2651     */
2652    private final GrammarAction presentFilterCreation = new GrammarAction( "Create Present Filter" )
2653    {
2654        public void action( Dsmlv2Container container ) throws XmlPullParserException
2655        {
2656            PresentFilter presentFilter = new PresentFilter();
2657
2658            XmlPullParser xpp = container.getParser();
2659
2660            // Adding the filter to the Search Filter
2661            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2662                container.getBatchRequest().getCurrentRequest();
2663
2664            try
2665            {
2666                searchRequestDecorator.addCurrentFilter( presentFilter );
2667            }
2668            catch ( DecoderException e )
2669            {
2670                throw new XmlPullParserException( e.getMessage(), xpp, null );
2671            }
2672
2673            // Checking and adding the filter's attributes
2674            String attributeValue;
2675            // name
2676            attributeValue = xpp.getAttributeValue( "", "name" );
2677
2678            if ( attributeValue != null )
2679            {
2680                presentFilter.setAttributeDescription( new String( attributeValue.getBytes() ) );
2681            }
2682            else
2683            {
2684                throw new XmlPullParserException( "name attribute is required", xpp, null );
2685            }
2686        }
2687    };
2688
2689    /**
2690     * GrammarAction that store the Filter into the searchRequest
2691     */
2692    private final GrammarAction storeFilter = new GrammarAction( "Store Filter" )
2693    {
2694        public void action( Dsmlv2Container container ) throws XmlPullParserException
2695        {
2696            // Adding the filter to the Search Filter
2697            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2698                container.getBatchRequest().getCurrentRequest();
2699            SearchRequest searchRequest = searchRequestDecorator.getDecorated();
2700
2701            if ( searchRequestDecorator.getFilterNode() == null )
2702            {
2703                throw new IllegalStateException( "No filter element present in the DSML search request" );
2704            }
2705            
2706            searchRequest.setFilter( searchRequestDecorator.getFilterNode() );
2707        }
2708    };
2709    
2710    /**
2711     * GrammarAction that creates an Extensible Match Filter
2712     */
2713    private final GrammarAction extensibleMatchFilterCreation = new GrammarAction( "Create Extensible Match Filter" )
2714    {
2715        public void action( Dsmlv2Container container ) throws XmlPullParserException
2716        {
2717            ExtensibleMatchFilter extensibleMatchFilter = new ExtensibleMatchFilter();
2718
2719            XmlPullParser xpp = container.getParser();
2720
2721            // Adding the filter to the Search Filter
2722            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2723                container.getBatchRequest().getCurrentRequest();
2724
2725            try
2726            {
2727                searchRequestDecorator.addCurrentFilter( extensibleMatchFilter );
2728            }
2729            catch ( DecoderException e )
2730            {
2731                throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
2732            }
2733
2734            searchRequestDecorator.setTerminalFilter( extensibleMatchFilter );
2735
2736            // Checking and adding the filter's attributes
2737            String attributeValue;
2738            // dnAttributes
2739            attributeValue = xpp.getAttributeValue( "", "dnAttributes" );
2740
2741            if ( attributeValue != null )
2742            {
2743                if ( ( attributeValue.equals( "true" ) ) || ( attributeValue.equals( "1" ) ) )
2744                {
2745                    extensibleMatchFilter.setDnAttributes( true );
2746                }
2747                else if ( ( attributeValue.equals( "false" ) ) || ( attributeValue.equals( "0" ) ) )
2748                {
2749                    extensibleMatchFilter.setDnAttributes( false );
2750                }
2751                else
2752                {
2753                    throw new XmlPullParserException( I18n.err( I18n.ERR_03033 ), xpp, null );
2754                }
2755            }
2756            else
2757            {
2758                extensibleMatchFilter.setDnAttributes( false );
2759            }
2760
2761            // matchingRule
2762            attributeValue = xpp.getAttributeValue( "", "matchingRule" );
2763
2764            if ( attributeValue != null )
2765            {
2766                extensibleMatchFilter.setMatchingRule( attributeValue );
2767            }
2768
2769            // name
2770            attributeValue = xpp.getAttributeValue( "", "name" );
2771
2772            if ( attributeValue != null )
2773            {
2774                extensibleMatchFilter.setType( attributeValue );
2775            }
2776        }
2777    };
2778
2779    /**
2780     * GrammarAction that adds a Value to an Extensible Match Filter
2781     */
2782    private final GrammarAction extensibleMatchAddValue = new GrammarAction( "Adds Value to Extensible MatchFilter" )
2783    {
2784        public void action( Dsmlv2Container container ) throws XmlPullParserException
2785        {
2786            SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml ) 
2787                container.getBatchRequest().getCurrentRequest();
2788            ExtensibleMatchFilter filter = ( ExtensibleMatchFilter ) searchRequestDecorator.getTerminalFilter();
2789
2790            XmlPullParser xpp = container.getParser();
2791
2792            try
2793            {
2794                // We have to catch the type Attribute Value before going to the next Text node
2795                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
2796
2797                // Getting the value
2798                String nextText = xpp.nextText();
2799                if ( !nextText.equals( "" ) )
2800                {
2801                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
2802                    {
2803                        filter.setMatchValue( new BinaryValue( Base64.decode( nextText.trim().toCharArray() ) ) );
2804                    }
2805                    else
2806                    {
2807                        filter.setMatchValue( new StringValue( nextText.trim() ) );
2808                    }
2809                }
2810            }
2811            catch ( IOException e )
2812            {
2813                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
2814            }
2815        }
2816    };
2817
2818    /**
2819     * GrammarAction that creates a Control
2820     */
2821    private final GrammarAction controlCreation = new GrammarAction( "Create Control" )
2822    {
2823        public void action( Dsmlv2Container container ) throws XmlPullParserException
2824        {
2825            XmlPullParser xpp = container.getParser();
2826            CodecControl<? extends Control> control;
2827
2828            // Checking and adding the Control's attributes
2829            String attributeValue;
2830            // TYPE
2831            attributeValue = xpp.getAttributeValue( "", "type" );
2832
2833            if ( attributeValue != null )
2834            {
2835                if ( !Oid.isOid( attributeValue ) )
2836                {
2837                    throw new XmlPullParserException( I18n.err( I18n.ERR_03034 ), xpp, null );
2838                }
2839
2840                control = codec.newControl( codec.newControl( attributeValue ) );
2841                ( ( Request ) container.getBatchRequest().getCurrentRequest() ).addControl( control );
2842            }
2843            else
2844            {
2845                throw new XmlPullParserException( I18n.err( I18n.ERR_03035 ), xpp, null );
2846            }
2847
2848            // CRITICALITY
2849            attributeValue = xpp.getAttributeValue( "", "criticality" );
2850
2851            if ( attributeValue != null )
2852            {
2853                if ( attributeValue.equals( "true" ) )
2854                {
2855                    control.setCritical( true );
2856                }
2857                else if ( attributeValue.equals( "false" ) )
2858                {
2859                    control.setCritical( false );
2860                }
2861                else
2862                {
2863                    throw new XmlPullParserException( I18n.err( I18n.ERR_03007 ), xpp, null );
2864                }
2865            }
2866        }
2867    };
2868
2869    /**
2870     * GrammarAction that adds a Value to a Control
2871     */
2872    private final GrammarAction controlValueCreation = new GrammarAction( "Add ControlValue to Control" )
2873    {
2874        public void action( Dsmlv2Container container ) throws XmlPullParserException
2875        {
2876            AbstractRequestDsml<? extends Request> request = 
2877                ( AbstractRequestDsml<? extends Request> ) container.getBatchRequest().getCurrentRequest();
2878            DsmlControl<? extends Control> control = request.getCurrentControl();
2879
2880            XmlPullParser xpp = container.getParser();
2881
2882            try
2883            {
2884                // We have to catch the type Attribute Value before going to the next Text node
2885                String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
2886
2887                // Getting the value
2888                String nextText = xpp.nextText();
2889
2890                if ( !nextText.equals( "" ) )
2891                {
2892                    if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
2893                    {
2894                        control.setValue( Base64.decode( nextText.trim().toCharArray() ) );
2895                    }
2896                    else
2897                    {
2898                        control.setValue( nextText.trim().getBytes() );
2899                    }
2900                }
2901            }
2902            catch ( IOException e )
2903            {
2904                throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
2905            }
2906        }
2907    };
2908
2909
2910    /**
2911     * GrammarAction that reads the SOAP header data
2912     */
2913    private final GrammarAction readSoapHeader = new GrammarAction( "Reads SOAP header" )
2914    {
2915        public void action( Dsmlv2Container container ) throws XmlPullParserException
2916        {
2917            try
2918            {
2919                XmlPullParser xpp = container.getParser();
2920                StringBuilder sb = new StringBuilder();
2921                
2922                String startTag = xpp.getText();
2923                sb.append( startTag );
2924
2925                // string '<' and '>'
2926                startTag = startTag.substring( 1, startTag.length() - 1 );
2927                
2928                int tagType = -1;
2929                String endTag = "";
2930                
2931                // continue parsing till we get to the end tag of SOAP header
2932                // and match the tag values including the namespace
2933                while( !startTag.equals( endTag ) )
2934                {
2935                    tagType = xpp.next();
2936                    endTag = xpp.getText();
2937                    sb.append( endTag );
2938                    
2939                    if ( tagType == XmlPullParser.END_TAG )
2940                    {
2941                        // strip '<', '/' and '>'
2942                        endTag = endTag.substring( 2, endTag.length() - 1 );
2943                    }
2944                }
2945                
2946                // change the state to header end
2947                container.setState( Dsmlv2StatesEnum.SOAP_HEADER_END_TAG );
2948                
2949                //System.out.println( sb );
2950            }
2951            catch( IOException e )
2952            {
2953                e.printStackTrace();
2954            }
2955            
2956        }
2957    };
2958}