directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r185064 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/ModifyDNResponseGrammar.java
Date Mon, 06 Jun 2005 22:24:04 GMT
Author: elecharny
Date: Mon Jun  6 15:24:04 2005
New Revision: 185064

URL: http://svn.apache.org/viewcvs?rev=185064&view=rev
Log:
Added the ModifyDNResponse grammar

Added:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/ModifyDNResponseGrammar.java

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/ModifyDNResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/ModifyDNResponseGrammar.java?rev=185064&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/ModifyDNResponseGrammar.java
(added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/ModifyDNResponseGrammar.java
Mon Jun  6 15:24:04 2005
@@ -0,0 +1,132 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed 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.asn1.ldap.codec.grammars;
+
+import org.apache.asn1.DecoderException;
+import org.apache.asn1.ber.containers.IAsn1Container;
+import org.apache.asn1.ber.grammar.AbstractGrammar;
+import org.apache.asn1.ber.grammar.GrammarAction;
+import org.apache.asn1.ber.grammar.GrammarTransition;
+import org.apache.asn1.ber.grammar.IGrammar;
+import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.ldap.codec.LdapMessageContainer;
+import org.apache.asn1.ldap.pojo.LdapMessagePOJO;
+import org.apache.asn1.ldap.pojo.ModifyDNResponsePOJO;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * This class implements the ModifyDNResponse LDAP message. All the actions are declared
in this
+ * class. As it is a singleton, these declaration are only done once.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModifyDNResponseGrammar extends AbstractGrammar implements IGrammar
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private static final Logger log = Logger.getLogger( ModifyDNResponseGrammar.class );
+
+    /** Logging speed up  */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** The instance of grammar. ModifyDNResponseGrammar is a singleton */
+    private static IGrammar instance = new ModifyDNResponseGrammar();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new ModifyDNResponseGrammar object.
+     */
+    private ModifyDNResponseGrammar()
+    {
+        name = ModifyDNResponseGrammar.class.getName();
+        statesEnum = LdapStatesEnum.getInstance();
+
+        // Intitialisation
+        super.transitions = new GrammarTransition[LdapStatesEnum.LAST_MODIFY_DN_RESPONSE_STATE][256];
+
+        //============================================================================================
+        // ModifyDNResponse Message
+        //============================================================================================
+        // LdapMessage ::= ... ModifyDNResponse ...
+        // ModifyDNResponse ::= [APPLICATION 13] LDAPResult (Tag)
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.MODIFY_RESPONSE_TAG][0x6D] = new GrammarTransition(
+                LdapStatesEnum.MODIFY_RESPONSE_TAG, LdapStatesEnum.MODIFY_RESPONSE_LENGTH,
null );
+
+        // We have to allocate a ModifyDNResponsePOJO
+        // LdapMessage ::= ... ModifyResponse ...
+        // ModifyDNResponse ::= [APPLICATION 13] LDAPResult (Length)
+        super.transitions[LdapStatesEnum.MODIFY_DN_RESPONSE_LENGTH][0x6D] = new GrammarTransition(
+                LdapStatesEnum.MODIFY_DN_RESPONSE_LENGTH, LdapStatesEnum.MODIFY_DN_RESPONSE_VALUE,
+                new GrammarAction( "Init ModifyDNResponse" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessagePOJO      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+
+                        checkLength( ldapMessageContainer.getLdapMessage(),
+                            ldapMessageContainer.getCurrentTLV() );
+
+                        // Now, we can allocate the ModifyDNResponse POJO
+                        ModifyDNResponsePOJO modifyDNResponse = new ModifyDNResponsePOJO();
+
+                        // As this is a new Constructed object, we have to init its length
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+                        int expectedLength = tlv.getLength().getLength();
+                        modifyDNResponse.setExpectedLength( expectedLength );
+                        modifyDNResponse.setCurrentLength( 0 );
+                        modifyDNResponse.setFather( ldapMessage );
+
+                        // And we associate it to the ldapMessage POJO
+                        ldapMessage.setProtocolOP( modifyDNResponse );
+                    }
+                } );
+
+        // LdapMessage ::= ... ModifyDNResponse ...
+        // ModifyDNResponse ::= [APPLICATION 13] LDAPResult (Value)
+        // The next Tag will be the LDAPResult Tag (0x0A).
+        // We will switch the grammar then.
+        super.transitions[LdapStatesEnum.MODIFY_DN_RESPONSE_VALUE][0x6D] = new GrammarTransition(
+                LdapStatesEnum.MODIFY_DN_RESPONSE_VALUE, LdapStatesEnum.MODIFY_DN_RESPONSE_LDAP_RESULT,
null );
+
+        // LdapMessage ::= ... ModifyDNResponse ...
+        // ModifyDNResponse ::= [APPLICATION 13] LDAPResult (Value)
+        // Ok, we have a LDAPResult Tag (0x0A). So we have to switch the grammar.
+        super.transitions[LdapStatesEnum.MODIFY_DN_RESPONSE_LDAP_RESULT][0x0A] = new GrammarTransition(
+                LdapStatesEnum.MODIFY_DN_RESPONSE_LDAP_RESULT, LdapStatesEnum.LDAP_RESULT_GRAMMAR_SWITCH,
null );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the instance of this grammar
+     *
+     * @return An instance on the LdapMessage Grammar
+     */
+    public static IGrammar getInstance()
+    {
+        return instance;
+    }
+}



Mime
View raw message