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