From commits-return-4861-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Thu Jun 02 07:05:31 2005 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 75761 invoked from network); 2 Jun 2005 07:05:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Jun 2005 07:05:31 -0000 Received: (qmail 80630 invoked by uid 500); 2 Jun 2005 07:05:30 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 80590 invoked by uid 500); 2 Jun 2005 07:05:30 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 80572 invoked by uid 99); 2 Jun 2005 07:05:30 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 02 Jun 2005 00:05:26 -0700 Received: (qmail 75713 invoked by uid 65534); 2 Jun 2005 07:05:17 -0000 Message-ID: <20050602070517.75712.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r179534 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/ModifyResponseGrammar.java Date: Thu, 02 Jun 2005 07:05:16 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: elecharny Date: Thu Jun 2 00:05:16 2005 New Revision: 179534 URL: http://svn.apache.org/viewcvs?rev=3D179534&view=3Drev Log: Added the ModifyResponse grammar Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/grammars/ModifyResponseGrammar.java Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap= /codec/grammars/ModifyResponseGrammar.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/s= rc/java/org/apache/asn1/ldap/codec/grammars/ModifyResponseGrammar.java?rev= =3D179534&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/grammars/ModifyResponseGrammar.java (added) +++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/grammars/ModifyResponseGrammar.java Thu Jun 2 00:05:16 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 impli= ed. + * 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.ModifyResponsePOJO; + +import org.apache.log4j.Logger; + + +/** + * This class implements the ModifyResponse LDAP message. All the actions = are declared in this + * class. As it is a singleton, these declaration are only done once. + *=20 + * @author Apache Directory Pr= oject + */ +public class ModifyResponseGrammar extends AbstractGrammar implements IGra= mmar +{ + //~ Static fields/initializers ---------------------------------------= -------------------------- + + /** The logger */ + private static final Logger log =3D Logger.getLogger( ModifyResponseGr= ammar.class ); + + /** Logging speed up */ + private static final boolean DEBUG =3D log.isDebugEnabled(); + + /** The instance of grammar. ModifyResponseGrammar is a singleton */ + private static IGrammar instance =3D new ModifyResponseGrammar(); + + //~ Constructors -----------------------------------------------------= -------------------------- + + /** + * Creates a new ModifyResponseGrammar object. + */ + private ModifyResponseGrammar() + { + name =3D ModifyResponseGrammar.class.getName(); + statesEnum =3D LdapStatesEnum.getInstance(); + + // Intitialisation + super.transitions =3D new GrammarTransition[LdapStatesEnum.LAST_MO= DIFY_RESPONSE_STATE][256]; + + //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + // ModifyResponse Message + //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + // LdapMessage ::=3D ... ModifyResponse ... + // ModifyResponse ::=3D [APPLICATION 7] LDAPResult (Tag) + // Nothing to do. + super.transitions[LdapStatesEnum.MODIFY_RESPONSE_TAG][0x67] =3D ne= w GrammarTransition( + LdapStatesEnum.MODIFY_RESPONSE_TAG, LdapStatesEnum.MODIFY_= RESPONSE_LENGTH, null ); + + // We have to allocate a ModifyResponsePOJO + // LdapMessage ::=3D ... ModifyResponse ... + // ModifyResponse ::=3D [APPLICATION 7] LDAPResult (Length) + super.transitions[LdapStatesEnum.MODIFY_RESPONSE_LENGTH][0x67] =3D= new GrammarTransition( + LdapStatesEnum.MODIFY_RESPONSE_LENGTH, LdapStatesEnum.MODI= FY_RESPONSE_VALUE, + new GrammarAction( "Init ModifyResponse" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + + LdapMessageContainer ldapMessageContainer =3D ( Ld= apMessageContainer ) + container; + LdapMessagePOJO ldapMessage =3D + ldapMessageContainer.getLdapMessage(); + + checkLength( ldapMessageContainer.getLdapMessage(), + ldapMessageContainer.getCurrentTLV() ); + + // Now, we can allocate the ModifyResponse POJO + ModifyResponsePOJO modifyResponse =3D new ModifyRe= sponsePOJO(); + + // As this is a new Constructed object, we have to= init its length + TLV tlv =3D ldapMessageContainer.getCur= rentTLV(); + int expectedLength =3D tlv.getLength().getLength(); + modifyResponse.setExpectedLength( expectedLength ); + modifyResponse.setCurrentLength( 0 ); + modifyResponse.setFather( ldapMessage ); + + // And we associate it to the ldapMessage POJO + ldapMessage.setProtocolOP( modifyResponse ); + } + } ); + + // LdapMessage ::=3D ... ModifyResponse ... + // ModifyResponse ::=3D [APPLICATION 11] LDAPResult (Value) + // The next Tag will be the LDAPResult Tag (0x0A). + // We will switch the grammar then. + super.transitions[LdapStatesEnum.MODIFY_RESPONSE_VALUE][0x67] =3D = new GrammarTransition( + LdapStatesEnum.MODIFY_RESPONSE_VALUE, LdapStatesEnum.MODIF= Y_RESPONSE_LDAP_RESULT, null ); + + // LdapMessage ::=3D ... ModifyResponse ... + // ModifyResponse ::=3D [APPLICATION 7] LDAPResult (Value) + // Ok, we have a LDAPResult Tag (0x0A). So we have to switch the g= rammar. + super.transitions[LdapStatesEnum.MODIFY_RESPONSE_LDAP_RESULT][0x0A= ] =3D new GrammarTransition( + LdapStatesEnum.MODIFY_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; + } +}