directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r475805 [6/17] - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/direct...
Date Thu, 16 Nov 2006 16:38:51 GMT
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,209 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+public class Dsmlv2ResponseParser
+{    
+    private Dsmlv2Container container;
+    
+    public Dsmlv2ResponseParser() throws XmlPullParserException 
+    {  
+        this.container = new Dsmlv2Container();
+        
+        this.container.setGrammar( Dsmlv2ResponseGrammar.getInstance() );
+        
+        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+        // factory.setNamespaceAware(true);
+        XmlPullParser xpp = factory.newPullParser();
+        
+        container.setParser( xpp );
+    }
+    
+    public void setInput( String str ) throws FileNotFoundException, XmlPullParserException
+    {
+    	container.getParser().setInput( new StringReader( str ) );
+    }
+    
+    public void setInputFile( String fileName ) throws FileNotFoundException, XmlPullParserException
+    {
+        Reader reader = new FileReader( fileName );
+        container.getParser().setInput( reader );
+    }
+    
+    public void setInput( InputStream inputStream, String inputEncoding ) throws XmlPullParserException
+    {
+        container.getParser().setInput( inputStream, inputEncoding);
+    }
+    
+    
+    public void parse() throws Exception
+    {        
+        Dsmlv2ResponseGrammar grammar = Dsmlv2ResponseGrammar.getInstance();
+        
+        grammar.executeAction( container );
+    }
+    
+    public void parseBatchResponse() throws XmlPullParserException
+    {      
+            XmlPullParser xpp = container.getParser();
+            
+            int eventType = xpp.getEventType();
+            do
+            {
+                if ( eventType == XmlPullParser.START_DOCUMENT )
+                {
+                    container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+                }
+                else if ( eventType == XmlPullParser.END_DOCUMENT )
+                {
+                    container.setState( Dsmlv2StatesEnum.END_STATE );
+                }
+                else if ( eventType == XmlPullParser.START_TAG )
+                {
+                    processTag( container, Tag.START );
+                }
+                else if ( eventType == XmlPullParser.END_TAG )
+                {
+                    processTag( container, Tag.END );
+                }
+                try
+                {
+                    eventType = xpp.next();
+                }
+                catch ( IOException e )
+                {
+                    throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp, null );
+                }
+            }
+            while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
+        }
+
+    
+    private void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
+    {        
+        XmlPullParser xpp = container.getParser();
+        
+        String tagName = xpp.getName().toLowerCase();
+        
+        GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType) );
+        
+        if (transition != null)
+        {
+            container.setState( transition.getNextState() );
+            
+            if ( transition.hasAction() )
+            {
+                //                    System.out.println( transition.getAction().toString() );// TODO Suppress
+                transition.getAction().action( container );
+            }
+        }
+        else
+        {
+            throw new XmlPullParserException( "The tag " + new Tag(tagName, tagType) + " can't be found at this position" , xpp, null );   
+        }
+    }
+    
+    public BatchResponse getBatchResponse()
+    {
+        return container.getBatchResponse();
+    }
+    
+    /**
+     * Returns the next Request or null if there's no more request
+     * @return the next Request or null if there's no more request
+     * @throws XmlPullParserException 
+     * @throws Exception
+     */
+    public LdapResponse getNextResponse() throws XmlPullParserException
+    {
+        if ( container.getBatchResponse() == null )
+        {
+            throw new XmlPullParserException( "The batch response needs to be parsed before parsing a response", container.getParser(), null );
+        }
+        
+        XmlPullParser xpp = container.getParser();
+
+        int eventType = xpp.getEventType();
+        do
+        {
+            while ( eventType == XmlPullParser.TEXT )
+            {
+                try
+                {
+                    xpp.next();
+                }
+                catch ( IOException e )
+                {
+                    throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp, null );
+                }
+                eventType = xpp.getEventType();
+            }
+
+            if ( eventType == XmlPullParser.START_DOCUMENT )
+            {
+                container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+            }
+            else if ( eventType == XmlPullParser.END_DOCUMENT )
+            {
+                container.setState( Dsmlv2StatesEnum.END_STATE );
+                return null;
+            }
+            else if ( eventType == XmlPullParser.START_TAG )
+            {
+                processTag( container, Tag.START );
+            }
+            else if ( eventType == XmlPullParser.END_TAG )
+            {
+                processTag( container, Tag.END );
+            }
+            try
+            {
+                eventType = xpp.next();
+            }
+            catch ( IOException e )
+            {
+                throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp, null );
+            }
+        }
+        while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
+
+        return container.getBatchResponse().getCurrentResponse();
+    }
+    
+    public void parseAllResponses() throws Exception
+    {
+        while ( getNextResponse() != null ) {
+            continue;
+        }
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2StatesEnum.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2StatesEnum.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2StatesEnum.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2StatesEnum.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,811 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+/**
+ * This class store the Dsml grammar's constants. It is also used for debugging
+ * purpose
+ */
+public class Dsmlv2StatesEnum implements IStates
+{
+    //====================================================
+    //  <batchRequest> ... </batchRequest>
+    //====================================================
+    /** The &lt;batchRequest&gt; tag */
+    public static final int BATCHREQUEST_START_TAG = 104;
+    
+    public static final int BATCHREQUEST_LOOP = 105;
+    
+    /** The &lt;/batchRequest&gt; tag */
+    public static final int BATCHREQUEST_END_TAG = 1;
+    
+    
+    //====================================================
+    //  <abandonRequest> ... </abandonRequest>
+    //====================================================
+    /** The &lt;abandonRequest&gt; tag */
+    public static final int ABANDON_REQUEST_START_TAG = 2;
+    
+    /** The &lt;control&gt; tag */
+    public static final int ABANDON_REQUEST_CONTROL_START_TAG = 4;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int ABANDON_REQUEST_CONTROL_END_TAG = 5;
+    
+    /** The &lt;controlValue&gt; tag */
+    public static final int ABANDON_REQUEST_CONTROLVALUE_START_TAG = 6;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int ABANDON_REQUEST_CONTROLVALUE_END_TAG = 7;
+    
+    
+    //====================================================
+    //  <addRequest> ... </addRequest>
+    //====================================================
+    /** The &lt;addRequest&gt; tag */
+    public static final int ADD_REQUEST_START_TAG = 8;
+    
+    /** The &lt;control&gt; tag */
+    public static final int ADD_REQUEST_CONTROL_START_TAG = 10;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int ADD_REQUEST_CONTROL_END_TAG = 11;
+
+    /** The &lt;controlValue&gt; tag */
+    public static final int ADD_REQUEST_CONTROLVALUE_START_TAG = 12;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int ADD_REQUEST_CONTROLVALUE_END_TAG = 13;
+    
+    /** The &lt;attr&gt; tag */
+    public static final int ADD_REQUEST_ATTR_START_TAG = 14;
+    
+    /** The &lt;/attr&gt; tag */
+    public static final int ADD_REQUEST_ATTR_END_TAG = 15;
+    
+    /** The &lt;value&gt; tag */
+    public static final int ADD_REQUEST_VALUE_START_TAG = 16;
+    
+    /** The &lt;/value&gt; tag */
+    public static final int ADD_REQUEST_VALUE_END_TAG = 17;
+    
+    
+    //====================================================
+    //  <authRequest> ... </authRequest>
+    //====================================================
+    /** The &lt;authRequest&gt; tag */
+    public static final int AUTH_REQUEST_START_TAG = 18;
+
+    /** The &lt;control&gt; tag */
+    public static final int AUTH_REQUEST_CONTROL_START_TAG = 20;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int AUTH_REQUEST_CONTROL_END_TAG = 21;
+
+    /** The &lt;controlValue&gt; tag */
+    public static final int AUTH_REQUEST_CONTROLVALUE_START_TAG = 22;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int AUTH_REQUEST_CONTROLVALUE_END_TAG = 23;
+    
+    
+    //====================================================
+    //  <compareRequest> ... </compareRequest>
+    //====================================================
+    /** The &lt;compareRequest&gt; tag */
+    public static final int COMPARE_REQUEST_START_TAG = 24;
+
+    /** The &lt;control&gt; tag */
+    public static final int COMPARE_REQUEST_CONTROL_START_TAG = 26;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int COMPARE_REQUEST_CONTROL_END_TAG = 27;
+
+    /** The &lt;controlValue&gt; tag */
+    public static final int COMPARE_REQUEST_CONTROLVALUE_START_TAG = 28;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int COMPARE_REQUEST_CONTROLVALUE_END_TAG = 29;
+
+    /** The &lt;assertion&gt; tag */
+    public static final int COMPARE_REQUEST_ASSERTION_START_TAG = 30;
+    
+    /** The &lt;/assertion&gt; tag */
+    public static final int COMPARE_REQUEST_ASSERTION_END_TAG = 31;
+
+    /** The &lt;value&gt; tag */
+    public static final int COMPARE_REQUEST_VALUE_START_TAG = 32;
+    
+    /** The &lt;/value&gt; tag */
+    public static final int COMPARE_REQUEST_VALUE_END_TAG = 33;
+    
+
+    //====================================================
+    //  <delRequest> ... </delRequest>
+    //====================================================
+    /** The &lt;delRequest&gt; tag */
+    public static final int DEL_REQUEST_START_TAG = 34;
+    
+    /** The &lt;control&gt; tag */
+    public static final int DEL_REQUEST_CONTROL_START_TAG = 36;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int DEL_REQUEST_CONTROL_END_TAG = 37;
+
+    /** The &lt;controlValue&gt; tag */
+    public static final int DEL_REQUEST_CONTROLVALUE_START_TAG = 38;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int DEL_REQUEST_CONTROLVALUE_END_TAG = 39;
+    
+
+    //====================================================
+    //  <extendedRequest> ... </extendedRequest>
+    //====================================================
+    /** The &lt;extendedRequest&gt; tag */
+    public static final int EXTENDED_REQUEST_START_TAG = 40;
+
+    /** The &lt;control&gt; tag */
+    public static final int EXTENDED_REQUEST_CONTROL_START_TAG = 42;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int EXTENDED_REQUEST_CONTROL_END_TAG = 43;
+
+    /** The &lt;controlValue&gt; tag */
+    public static final int EXTENDED_REQUEST_CONTROLVALUE_START_TAG = 44;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int EXTENDED_REQUEST_CONTROLVALUE_END_TAG = 45;
+    
+    /** The &lt;requestName&gt; tag */
+    public static final int EXTENDED_REQUEST_REQUESTNAME_START_TAG = 46;
+    
+    /** The &lt;/requestName&gt; tag */
+    public static final int EXTENDED_REQUEST_REQUESTNAME_END_TAG = 47;
+    
+    /** The &lt;requestValue&gt; tag */
+    public static final int EXTENDED_REQUEST_REQUESTVALUE_START_TAG = 48;
+    
+    /** The &lt;/requestValue&gt; tag */
+    public static final int EXTENDED_REQUEST_REQUESTVALUE_END_TAG = 49;
+
+    
+    //====================================================
+    //  <modDNRequest> ... </modDNRequest>
+    //====================================================
+    /** The &lt;modDNRequest&gt; tag */
+    public static final int MODIFY_DN_REQUEST_START_TAG = 50;
+
+    /** The &lt;control&gt; tag */
+    public static final int MODIFY_DN_REQUEST_CONTROL_START_TAG = 52;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int MODIFY_DN_REQUEST_CONTROL_END_TAG = 53;
+
+    /** The &lt;controlValue&gt; tag */
+    public static final int MODIFY_DN_REQUEST_CONTROLVALUE_START_TAG = 54;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG = 55;
+    
+
+    //====================================================
+    //  <modifyRequest> ... </modifyRequest>
+    //====================================================
+    /** The &lt;modifyRequest&gt; tag */
+    public static final int MODIFY_REQUEST_START_TAG = 56;
+    
+    /** The &lt;control&gt; tag */
+    public static final int MODIFY_REQUEST_CONTROL_START_TAG = 58;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int MODIFY_REQUEST_CONTROL_END_TAG = 59;
+
+    /** The &lt;controlValue&gt; tag */
+    public static final int MODIFY_REQUEST_CONTROLVALUE_START_TAG = 60;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int MODIFY_REQUEST_CONTROLVALUE_END_TAG = 61;
+
+    /** The &lt;modification&gt; tag */
+    public static final int MODIFY_REQUEST_MODIFICATION_START_TAG = 62;
+    
+    /** The &lt;/modification&gt; tag */
+    public static final int MODIFY_REQUEST_MODIFICATION_END_TAG = 63;
+
+    /** The &lt;value&gt; tag */
+    public static final int MODIFY_REQUEST_VALUE_START_TAG = 64;
+    
+    /** The &lt;/value&gt; tag */
+    public static final int MODIFY_REQUEST_VALUE_END_TAG = 65;
+    
+    
+    //====================================================
+    //  <searchRequest> ... </searchRequest>
+    //====================================================
+    /** The &lt;searchRequest&gt; tag */
+    public static final int SEARCH_REQUEST_START_TAG = 66;
+    
+    /** The &lt;control&gt; tag */
+    public static final int SEARCH_REQUEST_CONTROL_START_TAG = 68;
+    
+    /** The &lt;/control&gt; tag */
+    public static final int SEARCH_REQUEST_CONTROL_END_TAG = 69;
+
+    /** The &lt;controlValue&gt; tag */
+    public static final int SEARCH_REQUEST_CONTROLVALUE_START_TAG = 70;
+    
+    /** The &lt;/controlValue&gt; tag */
+    public static final int SEARCH_REQUEST_CONTROLVALUE_END_TAG = 71;
+
+    /** The &lt;filter&gt; tag */
+    public static final int SEARCH_REQUEST_FILTER_START_TAG = 72;
+    
+    /** The &lt;/filter&gt; tag */
+    public static final int SEARCH_REQUEST_FILTER_END_TAG = 73;
+    
+    /** The &lt;attributes&gt; tag */
+    public static final int SEARCH_REQUEST_ATTRIBUTES_START_TAG = 74;
+    
+    /** The &lt;/attributes&gt; tag */
+    public static final int SEARCH_REQUEST_ATTRIBUTES_END_TAG = 75;
+    
+    /** The &lt;attribute&gt; tag */
+    public static final int SEARCH_REQUEST_ATTRIBUTE_START_TAG = 76;
+    
+    /** The &lt;/attribute&gt; tag */
+    public static final int SEARCH_REQUEST_ATTRIBUTE_END_TAG = 77;
+    
+    /** The &lt;equalityMatch&gt; tag */
+    public static final int SEARCH_REQUEST_EQUALITYMATCH_START_TAG = 84;
+    
+    /** The &lt;subStrings&gt; tag */
+    public static final int SEARCH_REQUEST_SUBSTRINGS_START_TAG = 86;
+    
+    /** The &lt;/subStrings&gt; tag */
+    public static final int SEARCH_REQUEST_SUBSTRINGS_END_TAG = 87;
+    
+    /** The &lt;greaterOrEqual&gt; tag */
+    public static final int SEARCH_REQUEST_GREATEROREQUAL_START_TAG = 88;
+
+    /** The &lt;lessOrEqual&gt; tag */
+    public static final int SEARCH_REQUEST_LESSOREQUAL_START_TAG = 90;
+
+    /** The &lt;present&gt; tag */
+    public static final int SEARCH_REQUEST_PRESENT_START_TAG = 92;
+    
+    /** The &lt;approxMatch&gt; tag */
+    public static final int SEARCH_REQUEST_APPROXMATCH_START_TAG = 94;
+    
+    /** The &lt;extensibleMatch&gt; tag */
+    public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG = 96;
+    
+    /** The &lt;value&gt; tag */
+    public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_START_TAG = 109;
+    
+    /** The &lt;/value&gt; tag */
+    public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG = 110;
+    
+    /** The &lt;initial&gt; tag */
+    public static final int SEARCH_REQUEST_INITIAL_START_TAG = 98;
+    
+    /** The &lt;/initial&gt; tag */
+    public static final int SEARCH_REQUEST_INITIAL_END_TAG = 99;
+    
+    /** The &lt;any&gt; tag */
+    public static final int SEARCH_REQUEST_ANY_START_TAG = 100;
+    
+    /** The &lt;/any&gt; tag */
+    public static final int SEARCH_REQUEST_ANY_END_TAG = 101;
+    
+    /** The &lt;final&gt; tag */
+    public static final int SEARCH_REQUEST_FINAL_START_TAG = 102;
+    
+    /** The &lt;/final&gt; tag */
+    public static final int SEARCH_REQUEST_FINAL_END_TAG = 103;
+    
+    /** The &lt;value&gt; tag */
+    public static final int SEARCH_REQUEST_VALUE_START_TAG = 107;
+    
+    /** The &lt;/value&gt; tag */
+    public static final int SEARCH_REQUEST_VALUE_END_TAG = 108;
+    
+    /** The Filter Loop state */
+    public static final int SEARCH_REQUEST_FILTER_LOOP = 106;
+ 
+    
+    //****************
+    // DSML Response 
+    //****************
+    
+    /** The Batch Response Loop state */
+    public static final int BATCH_RESPONSE_LOOP = 200;
+    
+    /** The Error Response Loop state */
+    public static final int ERROR_RESPONSE = 201;
+    
+    /** The Message Start state */
+    public static final int MESSAGE_START = 202;
+    
+    /** The Message End state */
+    public static final int MESSAGE_END = 203;
+    
+    /** The Detail Start state */
+    public static final int DETAIL_START = 204;
+    
+    /** The Detail End state */
+    public static final int DETAIL_END = 205;
+    
+    /** The Extended Response state */
+    public static final int EXTENDED_RESPONSE = 206;
+    
+    /** The Extended Response Control Start state */
+    public static final int EXTENDED_RESPONSE_CONTROL_START = 207;
+    
+    /** The Extended Response Control End state */
+    public static final int EXTENDED_RESPONSE_CONTROL_END = 208;
+    
+    /** The Extended Response Control Value Start state */
+    public static final int EXTENDED_RESPONSE_CONTROL_VALUE_START = 245;
+    
+    /** The Extended Response Control Value End state */
+    public static final int EXTENDED_RESPONSE_CONTROL_VALUE_END = 246;
+    
+    /** The Extended Response Result Code Start state */
+    public static final int EXTENDED_RESPONSE_RESULT_CODE_START = 209;
+    
+    /** The Extended Response Result Code End state */
+    public static final int EXTENDED_RESPONSE_RESULT_CODE_END = 210;
+    
+    /** The Extended Response Error Message Start state */
+    public static final int EXTENDED_RESPONSE_ERROR_MESSAGE_START = 211;
+    
+    /** The Extended Response Error Message End state */
+    public static final int EXTENDED_RESPONSE_ERROR_MESSAGE_END = 212;
+    
+    /** The Extended Response Referral Start state */
+    public static final int EXTENDED_RESPONSE_REFERRAL_START = 213;
+    
+    /** The Extended Response Referral End state */
+    public static final int EXTENDED_RESPONSE_REFERRAL_END = 214;
+
+    /** The Response Name Start state */
+    public static final int RESPONSE_NAME_START = 215;
+
+    /** The Response Name End state */
+    public static final int RESPONSE_NAME_END = 216;
+    
+    /** The Response Start state */
+    public static final int RESPONSE_START = 217;
+
+    /** The Response End state */
+    public static final int RESPONSE_END = 218;
+
+    /** The LDAP Result state */
+    public static final int LDAP_RESULT = 219;
+
+    /** The LDAP Result Control Start state */
+    public static final int LDAP_RESULT_CONTROL_START = 220;
+
+    /** The LDAP Result Control End state */
+    public static final int LDAP_RESULT_CONTROL_END = 221;
+    
+    /** The LDAP Result Control Value Start state */
+    public static final int LDAP_RESULT_CONTROL_VALUE_START = 247;
+
+    /** The LDAP Result Control Value End state */
+    public static final int LDAP_RESULT_CONTROL_VALUE_END = 248;
+
+    /** The LDAP Result Result Code Start state */
+    public static final int LDAP_RESULT_RESULT_CODE_START = 222;
+
+    /** The LDAP Result Result Code End state */
+    public static final int LDAP_RESULT_RESULT_CODE_END = 223;
+
+    /** The LDAP Result Error Message Start state */
+    public static final int LDAP_RESULT_ERROR_MESSAGE_START = 224;
+
+    /** The LDAP Result Error Message End state */
+    public static final int LDAP_RESULT_ERROR_MESSAGE_END = 225;
+
+    /** The LDAP Result Referral Start state */
+    public static final int LDAP_RESULT_REFERRAL_START = 226;
+
+    /** The LDAP Result Referral End state */
+    public static final int LDAP_RESULT_REFERRAL_END = 227;
+
+    /** The LDAP Result End state */
+    public static final int LDAP_RESULT_END = 228;
+    
+    /** The Search Response state */
+    public static final int SEARCH_RESPONSE = 229;
+
+    /** The Search Result Entry state */
+    public static final int SEARCH_RESULT_ENTRY = 230;
+
+    /** The Search Result Entry Control Start state */
+    public static final int SEARCH_RESULT_ENTRY_CONTROL_START = 231;
+
+    /** The Search Result Entry Control End state */
+    public static final int SEARCH_RESULT_ENTRY_CONTROL_END = 232;
+    
+    /** The Search Result Entry Control Value Start state */
+    public static final int SEARCH_RESULT_ENTRY_CONTROL_VALUE_START = 249;
+
+    /** The Search Result Entry Control Value End state */
+    public static final int SEARCH_RESULT_ENTRY_CONTROL_VALUE_END = 250;
+
+    /** The Search Result Entry Attr Start state */
+    public static final int SEARCH_RESULT_ENTRY_ATTR_START = 233;
+
+    /** The Search Result Entry Attr End state */
+    public static final int SEARCH_RESULT_ENTRY_ATTR_END = 234;
+
+    /** The Search Result Entry Value Start state */
+    public static final int SEARCH_RESULT_ENTRY_VALUE_START = 235;
+
+    /** The Search Result Entry Value End state */
+    public static final int SEARCH_RESULT_ENTRY_VALUE_END = 236;
+
+    /** The Search Result Entry Loop state */
+    public static final int SEARCH_RESULT_ENTRY_LOOP = 237;
+    
+    /** The Search Result Reference state */
+    public static final int SEARCH_RESULT_REFERENCE = 238;
+    
+    /** The Search Result Reference Control Start state */
+    public static final int SEARCH_RESULT_REFERENCE_CONTROL_START = 239;
+    
+    /** The Search Result Reference Control End state */
+    public static final int SEARCH_RESULT_REFERENCE_CONTROL_END = 240;
+    
+    /** The Search Result Reference Control Value Start state */
+    public static final int SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START = 251;
+    
+    /** The Search Result Reference Control Value End state */
+    public static final int SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END = 252;
+    
+    /** The Search Result Reference Ref Start state */
+    public static final int SEARCH_RESULT_REFERENCE_REF_START = 241;
+    
+    /** The Search Result Reference Ref End state */
+    public static final int SEARCH_RESULT_REFERENCE_REF_END = 242;
+    
+    /** The Search Result Reference Loop state */
+    public static final int SEARCH_RESULT_REFERENCE_LOOP = 243;
+    
+    /** The Search Result Done End state */
+    public static final int SEARCH_RESULT_DONE_END = 244;
+    
+    
+    /** The instance */
+    private static Dsmlv2StatesEnum instance = new Dsmlv2StatesEnum();
+    
+    private Dsmlv2StatesEnum()
+    {
+    }
+    
+    /**
+     * Get an instance of this class
+     * 
+     * @return An instance on this class
+     */
+    public static Dsmlv2StatesEnum getInstance()
+    {
+        return instance;
+    }
+
+    /** Get the current state for a specified grammar */
+    public String getState( int state )
+    {
+        switch ( state )
+        {
+            case BATCHREQUEST_START_TAG:
+                return "BATCHREQUEST_START_TAG";
+            case BATCHREQUEST_LOOP:
+                return "BATCHREQUEST_LOOP";
+            case BATCHREQUEST_END_TAG:
+                return "BATCHREQUEST_END_TAG";
+            case ABANDON_REQUEST_START_TAG:
+                return "ABANDON_REQUEST_START_TAG";
+            case ABANDON_REQUEST_CONTROL_START_TAG:
+                return "ABANDON_REQUEST_CONTROL_START_TAG";
+            case ABANDON_REQUEST_CONTROL_END_TAG:
+                return "ABANDON_REQUEST_CONTROL_END_TAG";
+            case ABANDON_REQUEST_CONTROLVALUE_START_TAG:
+                return "ABANDON_REQUEST_CONTROLVALUE_START_TAG";
+            case ABANDON_REQUEST_CONTROLVALUE_END_TAG:
+                return "ABANDON_REQUEST_CONTROLVALUE_END_TAG";
+            case ADD_REQUEST_START_TAG:
+                return "ADD_REQUEST_START_TAG";
+            case ADD_REQUEST_CONTROL_START_TAG:
+                return "ADD_REQUEST_CONTROL_START_TAG";
+            case ADD_REQUEST_CONTROL_END_TAG:
+                return "ADD_REQUEST_CONTROL_END_TAG";
+            case ADD_REQUEST_CONTROLVALUE_START_TAG:
+                return "ADD_REQUEST_CONTROLVALUE_START_TAG";
+            case ADD_REQUEST_CONTROLVALUE_END_TAG:
+                return "ADD_REQUEST_CONTROLVALUE_END_TAG";
+            case ADD_REQUEST_ATTR_START_TAG:
+                return "ADD_REQUEST_ATTR_START_TAG";
+            case ADD_REQUEST_ATTR_END_TAG:
+                return "ADD_REQUEST_ATTR_END_TAG";
+            case ADD_REQUEST_VALUE_START_TAG:
+                return "ADD_REQUEST_VALUE_START_TAG";
+            case ADD_REQUEST_VALUE_END_TAG:
+                return "ADD_REQUEST_VALUE_END_TAG";
+            case AUTH_REQUEST_START_TAG:
+                return "AUTH_REQUEST_START_TAG";
+            case AUTH_REQUEST_CONTROL_START_TAG:
+                return "AUTH_REQUEST_CONTROL_START_TAG";
+            case AUTH_REQUEST_CONTROL_END_TAG:
+                return "AUTH_REQUEST_CONTROL_END_TAG";
+            case AUTH_REQUEST_CONTROLVALUE_START_TAG:
+                return "AUTH_REQUEST_CONTROLVALUE_START_TAG";
+            case AUTH_REQUEST_CONTROLVALUE_END_TAG:
+                return "AUTH_REQUEST_CONTROLVALUE_END_TAG";
+            case COMPARE_REQUEST_START_TAG:
+                return "COMPARE_REQUEST_START_TAG";
+            case COMPARE_REQUEST_CONTROL_START_TAG:
+                return "COMPARE_REQUEST_CONTROL_START_TAG";
+            case COMPARE_REQUEST_CONTROL_END_TAG: 
+                return "COMPARE_REQUEST_CONTROL_END_TAG";
+            case COMPARE_REQUEST_CONTROLVALUE_START_TAG:
+                return "COMPARE_REQUEST_CONTROLVALUE_START_TAG";
+            case COMPARE_REQUEST_CONTROLVALUE_END_TAG:
+                return "COMPARE_REQUEST_CONTROLVALUE_END_TAG";
+            case COMPARE_REQUEST_ASSERTION_START_TAG:
+                return "COMPARE_REQUEST_ASSERTION_START_TAG";
+            case COMPARE_REQUEST_ASSERTION_END_TAG:
+                return "COMPARE_REQUEST_ASSERTION_END_TAG";
+            case COMPARE_REQUEST_VALUE_START_TAG:
+                return "COMPARE_REQUEST_VALUE_START_TAG";
+            case COMPARE_REQUEST_VALUE_END_TAG:
+                return "COMPARE_REQUEST_VALUE_END_TAG";
+            case DEL_REQUEST_START_TAG:
+                return "DEL_REQUEST_START_TAG";
+            case DEL_REQUEST_CONTROL_START_TAG:
+                return "DEL_REQUEST_CONTROL_START_TAG";
+            case DEL_REQUEST_CONTROL_END_TAG:
+                return "DEL_REQUEST_CONTROL_END_TAG";
+            case DEL_REQUEST_CONTROLVALUE_START_TAG:
+                return "DEL_REQUEST_CONTROLVALUE_START_TAG";
+            case DEL_REQUEST_CONTROLVALUE_END_TAG:
+                return "DEL_REQUEST_CONTROLVALUE_END_TAG";
+            case EXTENDED_REQUEST_START_TAG:
+                return "EXTENDED_REQUEST_START_TAG";
+            case EXTENDED_REQUEST_CONTROL_START_TAG: 
+                return "EXTENDED_REQUEST_CONTROL_START_TAG";
+            case EXTENDED_REQUEST_CONTROL_END_TAG:
+                return "EXTENDED_REQUEST_CONTROL_END_TAG";
+            case EXTENDED_REQUEST_CONTROLVALUE_START_TAG:
+                return "EXTENDED_REQUEST_CONTROLVALUE_START_TAG";
+            case EXTENDED_REQUEST_CONTROLVALUE_END_TAG:
+                return "EXTENDED_REQUEST_CONTROLVALUE_END_TAG";
+            case EXTENDED_REQUEST_REQUESTNAME_START_TAG:
+                return "EXTENDED_REQUEST_REQUESTNAME_START_TAG";
+            case EXTENDED_REQUEST_REQUESTNAME_END_TAG:
+                return "EXTENDED_REQUEST_REQUESTNAME_END_TAG";
+            case EXTENDED_REQUEST_REQUESTVALUE_START_TAG:
+                return "EXTENDED_REQUEST_REQUESTVALUE_START_TAG";
+            case EXTENDED_REQUEST_REQUESTVALUE_END_TAG:
+                return "EXTENDED_REQUEST_REQUESTVALUE_END_TAG";
+            case MODIFY_DN_REQUEST_START_TAG:
+                return "MODIFY_DN_REQUEST_START_TAG";
+            case MODIFY_DN_REQUEST_CONTROL_START_TAG:
+                return "MODIFY_DN_REQUEST_CONTROL_START_TAG";
+            case MODIFY_DN_REQUEST_CONTROL_END_TAG:
+                return "MODIFY_DN_REQUEST_CONTROL_END_TAG";
+            case MODIFY_DN_REQUEST_CONTROLVALUE_START_TAG:
+                return "MODIFY_DN_REQUEST_CONTROLVALUE_START_TAG";
+            case MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG:
+                return "MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG";
+            case MODIFY_REQUEST_START_TAG:
+                return "MODIFY_REQUEST_START_TAG";
+            case MODIFY_REQUEST_CONTROL_START_TAG:
+                return "MODIFY_REQUEST_CONTROL_START_TAG";
+            case MODIFY_REQUEST_CONTROL_END_TAG:
+                return "MODIFY_REQUEST_CONTROL_END_TAG";
+            case MODIFY_REQUEST_CONTROLVALUE_START_TAG:
+                return "MODIFY_REQUEST_CONTROLVALUE_START_TAG";
+            case MODIFY_REQUEST_CONTROLVALUE_END_TAG:
+                return "MODIFY_REQUEST_CONTROLVALUE_END_TAG";
+            case MODIFY_REQUEST_MODIFICATION_START_TAG:
+                return "MODIFY_REQUEST_MODIFICATION_START_TAG";
+            case MODIFY_REQUEST_MODIFICATION_END_TAG:
+                return "MODIFY_REQUEST_MODIFICATION_END_TAG";
+            case MODIFY_REQUEST_VALUE_START_TAG:
+                return "MODIFY_REQUEST_VALUE_START_TAG";
+            case MODIFY_REQUEST_VALUE_END_TAG:
+                return "MODIFY_REQUEST_VALUE_END_TAG";
+            case SEARCH_REQUEST_START_TAG:
+                return "SEARCH_REQUEST_START_TAG";
+            case SEARCH_REQUEST_CONTROL_START_TAG:
+                return "SEARCH_REQUEST_CONTROL_START_TAG";
+            case SEARCH_REQUEST_CONTROL_END_TAG:
+                return "SEARCH_REQUEST_CONTROL_END_TAG";
+            case SEARCH_REQUEST_CONTROLVALUE_START_TAG:
+                return "SEARCH_REQUEST_CONTROLVALUE_START_TAG";
+            case SEARCH_REQUEST_CONTROLVALUE_END_TAG:
+                return "SEARCH_REQUEST_CONTROLVALUE_END_TAG";
+            case SEARCH_REQUEST_FILTER_START_TAG:
+                return "SEARCH_REQUEST_FILTER_START_TAG";
+            case SEARCH_REQUEST_FILTER_END_TAG:
+                return "SEARCH_REQUEST_FILTER_END_TAG";
+            case SEARCH_REQUEST_ATTRIBUTES_START_TAG:
+                return "SEARCH_REQUEST_ATTRIBUTES_START_TAG";
+            case SEARCH_REQUEST_ATTRIBUTES_END_TAG:
+                return "SEARCH_REQUEST_ATTRIBUTES_END_TAG";
+            case SEARCH_REQUEST_ATTRIBUTE_START_TAG:
+                return "SEARCH_REQUEST_ATTRIBUTE_START_TAG";
+            case SEARCH_REQUEST_ATTRIBUTE_END_TAG:
+                return "SEARCH_REQUEST_ATTRIBUTE_END_TAG";
+            case SEARCH_REQUEST_EQUALITYMATCH_START_TAG:
+                return "SEARCH_REQUEST_EQUALITYMATCH_START_TAG";
+            case SEARCH_REQUEST_SUBSTRINGS_START_TAG:
+                return "SEARCH_REQUEST_SUBSTRINGS_START_TAG";
+            case SEARCH_REQUEST_SUBSTRINGS_END_TAG: 
+                return "SEARCH_REQUEST_SUBSTRINGS_END_TAG";
+            case SEARCH_REQUEST_GREATEROREQUAL_START_TAG:
+                return "SEARCH_REQUEST_GREATEROREQUAL_START_TAG";
+            case SEARCH_REQUEST_LESSOREQUAL_START_TAG:
+                return "SEARCH_REQUEST_LESSOREQUAL_START_TAG";
+            case SEARCH_REQUEST_PRESENT_START_TAG:
+                return "SEARCH_REQUEST_PRESENT_START_TAG";
+            case SEARCH_REQUEST_APPROXMATCH_START_TAG:
+                return "SEARCH_REQUEST_APPROXMATCH_START_TAG";
+            case SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG:
+                return "SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG";
+            case SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_START_TAG:
+                return "SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_START_TAG";
+            case SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG:
+                return "SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG";
+            case SEARCH_REQUEST_INITIAL_START_TAG:
+                return "SEARCH_REQUEST_INITIAL_START_TAG";
+            case SEARCH_REQUEST_INITIAL_END_TAG:
+                return "SEARCH_REQUEST_INITIAL_END_TAG";
+            case SEARCH_REQUEST_ANY_START_TAG:
+                return "SEARCH_REQUEST_ANY_START_TAG";
+            case SEARCH_REQUEST_ANY_END_TAG:
+                return "SEARCH_REQUEST_ANY_END_TAG";
+            case SEARCH_REQUEST_FINAL_START_TAG:
+                return "SEARCH_REQUEST_FINAL_START_TAG";
+            case SEARCH_REQUEST_FINAL_END_TAG:
+                return "SEARCH_REQUEST_FINAL_END_TAG";
+            case SEARCH_REQUEST_VALUE_START_TAG:
+                return "SEARCH_REQUEST_VALUE_START_TAG";
+            case SEARCH_REQUEST_VALUE_END_TAG:
+                return "SEARCH_REQUEST_VALUE_END_TAG";
+            case SEARCH_REQUEST_FILTER_LOOP:
+                return "SEARCH_REQUEST_FILTER_LOOP";
+               
+            case BATCH_RESPONSE_LOOP:
+            	return "BATCH_RESPONSE_LOOP";
+            case ERROR_RESPONSE:
+            	return "ERROR_RESPONSE";
+            case MESSAGE_START:
+            	return "MESSAGE_START";
+            case MESSAGE_END:
+            	return "MESSAGE_END";
+            case DETAIL_START:
+            	return "DETAIL_START";
+            case DETAIL_END:
+            	return "DETAIL_END";
+            case EXTENDED_RESPONSE:
+            	return "EXTENDED_RESPONSE";
+            case EXTENDED_RESPONSE_CONTROL_START:
+            	return "EXTENDED_RESPONSE_CONTROL_START";
+            case EXTENDED_RESPONSE_CONTROL_END:
+            	return "EXTENDED_RESPONSE_CONTROL_END";
+            case EXTENDED_RESPONSE_CONTROL_VALUE_START:
+            	return "EXTENDED_RESPONSE_CONTROL_VALUE_START";
+            case EXTENDED_RESPONSE_CONTROL_VALUE_END:
+            	return "EXTENDED_RESPONSE_CONTROL_VALUE_END";
+            case EXTENDED_RESPONSE_RESULT_CODE_START:
+            	return "EXTENDED_RESPONSE_RESULT_CODE_START";
+            case EXTENDED_RESPONSE_RESULT_CODE_END:
+            	return "EXTENDED_RESPONSE_RESULT_CODE_END";
+            case EXTENDED_RESPONSE_ERROR_MESSAGE_START:
+            	return "EXTENDED_RESPONSE_ERROR_MESSAGE_START";
+            case EXTENDED_RESPONSE_ERROR_MESSAGE_END:
+            	return "EXTENDED_RESPONSE_ERROR_MESSAGE_END";
+            case EXTENDED_RESPONSE_REFERRAL_START:
+            	return "EXTENDED_RESPONSE_REFERRAL_START";
+            case EXTENDED_RESPONSE_REFERRAL_END:
+            	return "EXTENDED_RESPONSE_REFERRAL_END";
+            case RESPONSE_NAME_START:
+            	return "RESPONSE_NAME_START";
+            case RESPONSE_NAME_END:
+            	return "RESPONSE_NAME_END";
+            case RESPONSE_START:
+            	return "RESPONSE_START";
+            case RESPONSE_END:
+            	return "RESPONSE_END";
+            case LDAP_RESULT:
+            	return "LDAP_RESULT";
+            case LDAP_RESULT_CONTROL_START:
+            	return "LDAP_RESULT_CONTROL_START";
+            case LDAP_RESULT_CONTROL_END:
+            	return "LDAP_RESULT_CONTROL_END";
+            case LDAP_RESULT_CONTROL_VALUE_START:
+            	return "LDAP_RESULT_CONTROL_VALUE_START";
+            case LDAP_RESULT_CONTROL_VALUE_END:
+            	return "LDAP_RESULT_CONTROL_VALUE_END";
+            case LDAP_RESULT_RESULT_CODE_START:
+            	return "LDAP_RESULT_RESULT_CODE_START";
+            case LDAP_RESULT_RESULT_CODE_END:
+            	return "LDAP_RESULT_RESULT_CODE_END";
+            case LDAP_RESULT_ERROR_MESSAGE_START:
+            	return "LDAP_RESULT_ERROR_MESSAGE_START";
+            case LDAP_RESULT_ERROR_MESSAGE_END:
+            	return "LDAP_RESULT_ERROR_MESSAGE_END";
+            case LDAP_RESULT_REFERRAL_START:
+            	return "LDAP_RESULT_REFERRAL_START";
+            case LDAP_RESULT_REFERRAL_END:
+            	return "LDAP_RESULT_REFERRAL_END";
+            case LDAP_RESULT_END:
+            	return "LDAP_RESULT_END";
+            case SEARCH_RESPONSE:
+            	return "SEARCH_RESPONSE";
+            case SEARCH_RESULT_ENTRY:
+            	return "SEARCH_RESULT_ENTRY";
+            case SEARCH_RESULT_ENTRY_CONTROL_START:
+            	return "SEARCH_RESULT_ENTRY_CONTROL_START";
+            case SEARCH_RESULT_ENTRY_CONTROL_END:
+            	return "SEARCH_RESULT_ENTRY_CONTROL_END";
+            case SEARCH_RESULT_ENTRY_CONTROL_VALUE_START:
+            	return "SEARCH_RESULT_ENTRY_CONTROL_VALUE_START";
+            case SEARCH_RESULT_ENTRY_CONTROL_VALUE_END:
+            	return "SEARCH_RESULT_ENTRY_CONTROL_VALUE_END";
+            case SEARCH_RESULT_ENTRY_ATTR_START:
+            	return "SEARCH_RESULT_ENTRY_ATTR_START";
+            case SEARCH_RESULT_ENTRY_ATTR_END:
+            	return "SEARCH_RESULT_ENTRY_ATTR_END";
+            case SEARCH_RESULT_ENTRY_VALUE_START:
+            	return "SEARCH_RESULT_ENTRY_VALUE_START";
+            case SEARCH_RESULT_ENTRY_VALUE_END:
+            	return "SEARCH_RESULT_ENTRY_VALUE_END";
+            case SEARCH_RESULT_ENTRY_LOOP:
+            	return "SEARCH_RESULT_ENTRY_LOOP"; 
+            case SEARCH_RESULT_REFERENCE:
+            	return "SEARCH_RESULT_REFERENCE";
+            case SEARCH_RESULT_REFERENCE_CONTROL_START:
+            	return "SEARCH_RESULT_REFERENCE_CONTROL_START";
+            case SEARCH_RESULT_REFERENCE_CONTROL_END:
+            	return "SEARCH_RESULT_REFERENCE_CONTROL_END";
+            case SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START:
+            	return "SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START";
+            case SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END:
+            	return "SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END";
+            case SEARCH_RESULT_REFERENCE_REF_START:
+            	return "SEARCH_RESULT_REFERENCE_REF_START";
+            case SEARCH_RESULT_REFERENCE_REF_END:
+            	return "SEARCH_RESULT_REFERENCE_REF_END";
+            case SEARCH_RESULT_REFERENCE_LOOP:
+            	return "SEARCH_RESULT_REFERENCE_LOOP";
+            case SEARCH_RESULT_DONE_END:
+            	return "SEARCH_RESULT_DONE_END";
+
+            default:
+                return "UNKNOWN";
+        }
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarAction.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarAction.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+/**
+ * A top level grammar class that store meta informations about the actions.
+ * Those informations are not mandatory, but they can be usefull for debugging.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class GrammarAction implements IAction
+{
+    // ~ Instance fields
+    // ----------------------------------------------------------------------------
+
+    /** The action's name */
+    protected String name;
+
+
+    // ~ Constructors
+    // -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new GrammarAction object.
+     * 
+     * @param name
+     *            The name of the create daction
+     */
+    public GrammarAction(String name)
+    {
+        this.name = name;
+    }
+
+
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * Print the action's name
+     * 
+     * @return The action's name
+     */
+    public String toString()
+    {
+        return name;
+    }
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarTransition.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarTransition.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarTransition.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarTransition.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,115 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+
+/**
+ * Define a transition between two states of a grammar. It stores the next
+ * state, and the action to execute while transiting.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GrammarTransition
+{
+    // ~ Instance fields
+    // ----------------------------------------------------------------------------
+
+    /** The next state in the grammar */
+    private int nextState;
+
+    /** The action associated to the transition */
+    private GrammarAction action;
+
+    /** The current state */
+    private int currentState;
+
+
+    // ~ Constructors
+    // -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new GrammarTransition object.
+     * 
+     * @param currentState
+     *            The current transition
+     * @param nextState
+     *            The target state
+     * @param action
+     *            The action to execute. It could be null.
+     */
+    public GrammarTransition(int currentState, int nextState, GrammarAction action)
+    {
+        this.currentState = currentState;
+        this.nextState = nextState;
+        this.action = action;
+    }
+
+
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * @return Returns the target state.
+     */
+    public int getNextState()
+    {
+        return nextState;
+    }
+
+
+    /**
+     * Tells if the transition has an associated action.
+     * 
+     * @return <code>true</code> if an action has been asociated to the
+     *         transition
+     */
+    public boolean hasAction()
+    {
+        return action != null;
+    }
+
+
+    /**
+     * @return Returns the action associated with the transition
+     */
+    public GrammarAction getAction()
+    {
+        return action;
+    }
+
+
+    /**
+     * @param grammar
+     *            The grammar which state we want a String from
+     * @return A representation of the transition as a string.
+     */
+    public String toString( int grammar, IStates statesEnum )
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "Transition from <" ).append( statesEnum.getState( currentState ) ).append( "> to <" )
+            .append( statesEnum.getState( nextState ) ).append( ">, action : " ).append(
+                ( ( action == null ) ? "no action" : action.toString() ) ).append( ">" );
+
+        return sb.toString();
+    }
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IAction.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IAction.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+/**
+ * IAction interface just contains the method 'action' which must be implemented
+ * in all the implementong classes.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface IAction
+{
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * The action to be executed.
+     * 
+     * @param container
+     *            The container which stores the current data
+     * @throws DecoderException
+     *             Thrown if something went wrong.
+     */
+    public void action( Dsmlv2Container container ) throws XmlPullParserException;
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IGrammar.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IGrammar.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IGrammar.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,69 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+import org.apache.directory.shared.asn1.codec.DecoderException;
+
+
+/**
+ * The interface which expose common behavior of a Gramar implementer.
+ */
+public interface IGrammar
+{
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+
+    /**
+     * This method, when called, execute an action on the current data stored in
+     * the container.
+     * 
+     * @param asn1Container
+     *            Store the data being processed.
+     * @throws DecoderException
+     *             Thrown when an unrecoverable error occurs.
+     */
+    void executeAction( Dsmlv2Container container ) throws Exception;
+
+
+    /**
+     * Get the grammar name
+     * 
+     * @return Return the grammar's name
+     */
+    String getName();
+
+
+    /**
+     * Get the statesEnum for the current grammar
+     * 
+     * @return The specific States Enum for the current grammar
+     */
+    IStates getStatesEnum();
+
+
+    /**
+     * Set the grammar's name
+     * 
+     * @param name
+     *            The grammar name
+     */
+    void setName( String name );
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IStates.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IStates.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IStates.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IStates.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+/**
+ * This interface is used to store the different states of a grammar.
+ */
+public interface IStates
+{
+    /** The initial state of every grammar */
+    static int INIT_GRAMMAR_STATE = 0;
+
+    /** The ending state for every grammars */
+    static int GRAMMAR_END = -1;
+
+    /** The END_STATE */
+    static int END_STATE = -1;
+
+    /** Get the current state for a specified grammar */
+    String getState(int state );
+}
\ No newline at end of file

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Main.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Main.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Main.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Main.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+import java.io.FileNotFoundException;
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.xmlpull.v1.XmlPullParserException;
+
+
+public class Main
+{
+    /**
+     * @param args
+     * @throws FileNotFoundException 
+     * @throws XmlPullParserException 
+     */
+    public static void main(String[] args) throws FileNotFoundException, XmlPullParserException
+    {
+        Dsmlv2Parser parser = new Dsmlv2Parser();
+        
+        parser.setInput( "document_dsml_test.xml" );
+        
+        try
+        {
+            parser.parseBatchRequest();
+
+            BatchRequest batchRequest = parser.getBatchRequest();
+            
+            System.out.println("toto");
+            
+            LdapMessage request1 = parser.getNextRequest();
+            
+            System.out.println("toto2");
+
+            LdapMessage request2 = parser.getNextRequest();
+            
+            System.out.println("toto3");
+            
+            parser.parseAllRequests();
+        }
+        catch ( Exception e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
+        
+//        Tag tag1 = new Tag("toto", Tag.START);
+//        Tag tag2 = new Tag("toto", Tag.END);
+//        Tag tag3 = new Tag("tata", Tag.START);
+//        Tag tag4 = new Tag("toto", Tag.START);
+//        
+//        System.out.println( tag1.equals( tag3 ) );
+        
+   //     Dsmlv2Grammar dsmlv2Grammar = Dsmlv2Grammar.getInstance();
+//        System.out.println( dsmlv2Grammar.getStateFromTag( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, new Tag("addrequESt", Tag.START) ) );
+        
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ResponseMain.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ResponseMain.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ResponseMain.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/ResponseMain.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+import java.io.FileNotFoundException;
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.xmlpull.v1.XmlPullParserException;
+
+
+public class ResponseMain
+{
+    /**
+     * @param args
+     * @throws FileNotFoundException 
+     * @throws XmlPullParserException 
+     */
+    public static void main(String[] args) throws FileNotFoundException, XmlPullParserException
+    {
+        Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
+        
+        parser.setInputFile( "BatchResponse.xml" );
+        
+        try
+        {
+            parser.parseBatchResponse();
+
+            BatchResponse batchResponse = parser.getBatchResponse();
+            
+            System.out.println("toto");
+            
+            LdapMessage request1 = parser.getNextResponse();
+            
+            System.out.println("toto2");
+
+            LdapMessage request2 = parser.getNextResponse();
+            
+            System.out.println("toto3");
+            
+            parser.parseAllResponses();
+        }
+        catch ( Exception e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        System.out.println("Done");
+        
+//        Tag tag1 = new Tag("toto", Tag.START);
+//        Tag tag2 = new Tag("toto", Tag.END);
+//        Tag tag3 = new Tag("tata", Tag.START);
+//        Tag tag4 = new Tag("toto", Tag.START);
+//        
+//        System.out.println( tag1.equals( tag3 ) );
+        
+   //     Dsmlv2Grammar dsmlv2Grammar = Dsmlv2Grammar.getInstance();
+//        System.out.println( dsmlv2Grammar.getStateFromTag( Dsmlv2StatesEnum.BATCHREQUEST_START_TAG, new Tag("addrequESt", Tag.START) ) );
+        
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Tag.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Tag.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Tag.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Tag.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,93 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2;
+
+public class Tag
+{
+
+    private String name;
+    private int type;
+    
+    public static int START = 0;
+    public static int END = 1;
+    
+    public Tag( String name, int type )
+    {
+        setName( name );
+        setType( type );
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name.toLowerCase();
+    }
+
+    public int getType()
+    {
+        return type;
+    }
+
+    public void setType( int type )
+    {
+        this.type = type;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj instanceof Tag )
+        {
+            Tag tag = ( Tag ) obj;
+            return ( ( this.name.equals( tag.getName() ) ) && ( this.type == tag.getType() ) );
+            
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    @Override
+    public int hashCode()
+    {
+        
+        return name.hashCode() + type<<24;
+    }
+
+    @Override
+    public String toString()
+    {
+        if (name != null)
+        {
+            return "<" + ( (type == Tag.END) ? "/" : "" ) + name + ">";
+        }
+        else
+        {
+            return "Unknown tag";
+        }
+    }
+    
+}



Mime
View raw message