Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 71238 invoked from network); 24 May 2005 06:30:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 May 2005 06:30:38 -0000 Received: (qmail 48205 invoked by uid 500); 24 May 2005 06:30:37 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 48156 invoked by uid 500); 24 May 2005 06:30:37 -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 48127 invoked by uid 99); 24 May 2005 06:30:37 -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; Mon, 23 May 2005 23:30:31 -0700 Received: (qmail 71139 invoked by uid 65534); 24 May 2005 06:30:25 -0000 Message-ID: <20050524063025.71137.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r178089 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/AbstractContainer.java /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java Date: Tue, 24 May 2005 06:30:24 -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: Mon May 23 23:30:23 2005 New Revision: 178089 URL: http://svn.apache.org/viewcvs?rev=3D178089&view=3Drev Log: Suppressed the pooling mechanism Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Abs= tractContainer.java directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn= 1Decoder.java Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/b= er/AbstractContainer.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/s= rc/java/org/apache/asn1/ber/AbstractContainer.java?rev=3D178089&r1=3D178088= &r2=3D178089&view=3Ddiff =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/ber/Abs= tractContainer.java (original) +++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Abs= tractContainer.java Mon May 23 23:30:23 2005 @@ -19,13 +19,11 @@ import org.apache.asn1.ber.containers.IAsn1Container; import org.apache.asn1.ber.grammar.IGrammar; import org.apache.asn1.ber.tlv.TLV; -import org.apache.asn1.util.pools.LocalPoolManager; -import org.apache.asn1.util.pools.PoolObject; =20 /** * @author Apache Directory Pr= oject */ -public class AbstractContainer extends PoolObject implements IAsn1Containe= r { +public class AbstractContainer implements IAsn1Container { /** The grammars that are used. * It's a stack as we can switch grammars */ protected IGrammar[] grammarStack; @@ -45,9 +43,6 @@ /** The current transition */ protected int transition; =20 - /** The pool that is associated with this container */ - protected LocalPoolManager poolManager; - /** The current TLV */ protected TLV tlv; =20 @@ -89,24 +84,6 @@ { grammarStack[currentGrammar] =3D null; currentGrammar --; - } - - /** - * Associate a pool Manager to the container - * - * @param poolManager The pool manager - */ - public void setPoolManager( LocalPoolManager poolManager ) - { - this.poolManager =3D poolManager; - } - - /** - * @return The poolManager associated with this container - */ - public LocalPoolManager getPoolManager() - { - return poolManager; } =20 /** Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/b= er/Asn1Decoder.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/s= rc/java/org/apache/asn1/ber/Asn1Decoder.java?rev=3D178089&r1=3D178088&r2=3D= 178089&view=3Ddiff =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/ber/Asn= 1Decoder.java (original) +++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn= 1Decoder.java Mon May 23 23:30:23 2005 @@ -22,14 +22,9 @@ import org.apache.asn1.ber.tlv.Length; import org.apache.asn1.ber.tlv.TLV; import org.apache.asn1.ber.tlv.ITLVBerDecoderMBean; -import org.apache.asn1.ber.tlv.TLVPoolEnum; import org.apache.asn1.ber.tlv.TLVStateEnum; import org.apache.asn1.ber.tlv.Tag; import org.apache.asn1.util.StringUtils; -import org.apache.asn1.util.pools.LocalPoolManager; -import org.apache.asn1.util.pools.PoolEnum; -import org.apache.asn1.util.pools.PoolException; -import org.apache.asn1.util.pools.PoolObject; =20 import org.apache.log4j.Logger; =20 @@ -71,38 +66,16 @@ /** The maximum number of bytes that could be used to encode the Tag */ private int maxTagLength; =20 - /** The local pool Manager */ - protected LocalPoolManager poolMgr; - =20 - /** A flag to set the memory mechanism to use */ - protected boolean isPooled; - =20 //~ Constructors -----------------------------------------------------= -------------------------- =20 /** * A public constructor of an Asn1 Decoder. - *=20 - * @param isPooled Set the memory allocation mechanism. If true<= /code>, - * a pooled mechanism will be used - */ - public Asn1Decoder(boolean isPooled) - { - this.indefiniteLengthAllowed =3D false; - this.maxLengthLength =3D 1; - this.maxTagLength =3D 1; - poolMgr =3D new LocalPoolManager(60, isPooled= ); - } - - /** - * A public constructor of an Asn1 Decoder. */ public Asn1Decoder() { this.indefiniteLengthAllowed =3D false; this.maxLengthLength =3D 1; this.maxTagLength =3D 1; - isPooled =3D true; - poolMgr =3D new LocalPoolManager(60, isPooled= ); } =20 //~ Methods ----------------------------------------------------------= -------------------------- @@ -128,67 +101,59 @@ =20 byte octet =3D stream.get(); =20 - try - { + TLV tlv =3D new TLV(); + Tag tag =3D tlv.getTag(); =20 - TLV tlv =3D ( TLV ) poolMgr.allocate( TLVPoolEnum.TLV_POOL= ); - Tag tag =3D tlv.getTag(); + tag.setSize( 1 ); + tag.setPrimitive( ( octet & Tag.CONSTRUCTED_FLAG ) =3D=3D 0 ); + tag.setTypeClass( Tag.TYPE_CLASS[( octet & Tag.TYPE_CLASS_MASK= ) >>> 6] ); =20 - tag.setSize( 1 ); - tag.setPrimitive( ( octet & Tag.CONSTRUCTED_FLAG ) =3D=3D = 0 ); - tag.setTypeClass( Tag.TYPE_CLASS[( octet & Tag.TYPE_CLASS_= MASK ) >>> 6] ); + int value =3D octet & Tag.SHORT_MASK; =20 - int value =3D octet & Tag.SHORT_MASK; + if ( value =3D=3D Tag.SHORT_MASK ) + { =20 - if ( value =3D=3D Tag.SHORT_MASK ) + // we have to check the typeClass. UNIVERSAL class is not + // allowed with this value. + if ( tag.isUniversal() ) { + throw new DecoderException( "Universal tag 31 is reser= ved" ); + } =20 - // we have to check the typeClass. UNIVERSAL class is = not - // allowed with this value. - if ( tag.isUniversal() ) - { - throw new DecoderException( "Universal tag 31 is r= eserved" ); - } + // we will have more than one byte to encode the value + // The tag is encoded on [2 - 6 bytes], its value + // is container in the 7 lower bits of the bytes following + // the first byte. + container.setState( TLVStateEnum.TAG_STATE_PENDING ); + tag.setId( 0 ); + tag.addByte( octet ); + } + else + { + // It's a tag wich value is below 30 (31 is not allowed + // as it signals a multi-bytes value. Everything is done. =20 - // we will have more than one byte to encode the value - // The tag is encoded on [2 - 6 bytes], its value - // is container in the 7 lower bits of the bytes follo= wing - // the first byte. - container.setState( TLVStateEnum.TAG_STATE_PENDING ); - tag.setId( 0 ); - tag.addByte( octet ); - } - else + // We have to check for reserved tags if typeClass is UNIV= ERSAL + if ( tag.isUniversal() ) { - // It's a tag wich value is below 30 (31 is not allowed - // as it signals a multi-bytes value. Everything is do= ne. =20 - // We have to check for reserved tags if typeClass is = UNIVERSAL - if ( tag.isUniversal() ) + if ( ( value =3D=3D 14 ) || ( value =3D=3D 15 ) ) { - - if ( ( value =3D=3D 14 ) || ( value =3D=3D 15 ) ) - { - throw new DecoderException( "Universal tag " += value + " is reserved" ); - } + throw new DecoderException( "Universal tag " + val= ue + " is reserved" ); } - - tag.setId( value ); - tag.addByte( octet ); - - // The tag has been completed, we have to decode the L= ength - container.setState( TLVStateEnum.TAG_STATE_END ); } =20 - // Store the current TLV in the container. - container.setCurrentTLV( tlv ); + tag.setId( value ); + tag.addByte( octet ); =20 - return MORE; - } - catch ( PoolException pe ) - { - throw new DecoderException( "Cannot allocate a TLV : " + p= e=2EgetMessage() ); + // The tag has been completed, we have to decode the Length + container.setState( TLVStateEnum.TAG_STATE_END ); } + + // Store the current TLV in the container. + container.setCurrentTLV( tlv ); + + return MORE; } else { @@ -557,7 +522,6 @@ =20 // Then we switch to the Start tag state and free the current TLV container.setState( TLVStateEnum.TAG_STATE_START ); - container.getCurrentTLV().free(); =20 return stream.hasRemaining(); } @@ -811,26 +775,4 @@ this.maxTagLength =3D maxTagLength; } =20 - /** - * Ask the local pool manager to allocate an object. - * - * @param pool The pool in which the object will be taken from - * - * @return The allocated object - * - * @throws PoolException Thrown if the object could not be allocated - */ - public PoolObject allocate( int pool ) throws PoolException - { - return isPooled ? poolMgr.allocate( pool ) : PoolEnum.allocate( pool = ); - } - - /** - * @return Returns the pool manager to the caller. - */ - public LocalPoolManager getPoolManager() - { - - return poolMgr; - } } // end class TLVTagDecoder