directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9470 - in incubator/directory/snickers/branches/refactoring: . ber ber/src/java/org/apache/snickers ber/src/java/org/apache/snickers/asn ber/src/java/org/apache/snickers/ber ber/src/test/org/apache/snickers ber/src/test/org/apache/snickers/asn ber/src/test/org/apache/snickers/ber ber/xdocs ber/xdocs/empty codec-stateful codec-stateful/src/java/org/apache/commons/codec/stateful
Date Sun, 14 Mar 2004 22:02:20 GMT
Author: akarasulu
Date: Sun Mar 14 14:02:18 2004
New Revision: 9470

Added:
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TagDecoder.java   (contents, props changed)
Modified:
   incubator/directory/snickers/branches/refactoring/ber/berlib.properties   (props changed)
   incubator/directory/snickers/branches/refactoring/ber/project.properties   (props changed)
   incubator/directory/snickers/branches/refactoring/ber/project.xml   (props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/SnickersDecoder.java   (props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/ASNDecoder.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/ASNFactory.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BERDecoderUtils.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BasicHandler.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BitString.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/Primitive.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLV.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLVHandler.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLVParsingUtility.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/AbstractDecoderTestCase.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoder.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderCallback.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderCallbackAdapter.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderMonitor.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderState.java   (props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERUtils.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/IntStack.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/Tuple.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleNode.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleTreeDecoder.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TypeClass.java   (props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/SnickersDecoderTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/asn/TestBitString.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/AbstractDecoderTestCaseTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderCallbackAdapterTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderStateTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERUtilsTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/ConstructedTLVTests.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/DefaultMutableTupleNodeTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/IntStackTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/LdapMessageTests.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/MultiByteLengthTests.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/ObjectVersePrimitiveTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SimplePrimitiveTLVTests.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SingleByteLengthTests.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SingleByteTagTests.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TupleTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TypeClassTest.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/todo.txt   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/xdocs/design.xml   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/xdocs/empty/index.xml   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/ber/xdocs/empty/navigation.xml   (props changed)
   incubator/directory/snickers/branches/refactoring/codec-stateful/project.properties   (props changed)
   incubator/directory/snickers/branches/refactoring/codec-stateful/project.xml   (props changed)
   incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/CallbackHistory.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderCallback.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderMonitor.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderMonitorAdapter.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/StatefulDecoder.java   (contents, props changed)
   incubator/directory/snickers/branches/refactoring/project.xml   (contents, props changed)
Log:
set some svn properties for eol and keywords

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/ASNDecoder.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/ASNDecoder.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/ASNDecoder.java	Sun Mar 14 14:02:18 2004
@@ -1,118 +1,118 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-
-package org.apache.snickers.asn;
-
-/**
- * @author Wes McKean
- *
- * Basic interface for decoding TLVs.  The bytes
- * are read in as ints, due to the casting limitation of
- * bytes (-1=0xFF), and then passed to the decoder
- * for decoding.
- */
-public interface ASNDecoder {
-
-    /**
-     * Decode a boolean from an array of bytes into a Java 
-     * Boolean object
-     * 
-     * @param value The boolean encoded as an array of ints(bytes)
-     * @return a Boolean (decoded)
-     */
-    Boolean decodeBoolean( int[] value );
-    
-    /**
-     * Decodes an Integer from an array of ints (bytes)
-     * 
-     * @param value The integer, encoded in an array of ints(bytes)
-     * @return an Integer (decoded)
-     */
-    Integer decodeInteger( int[] value );
-    
-    /**
-     * Decodes a <code>BitString</code> from the an array of
-     * ints (bytes) into which it has been encoded.
-     *  
-     * @param value the int (byte) encoded <code>BitString</code>
-     * @return The decoded <code>BitString</code>
-     */
-    BitString decodeBitString( int[] value );
-    
-    /**
-     * Decodes a <code>OctetString</code> from the an array of
-     * ints (bytes) into which it has been encoded.
-     *  
-     * @param value the int (byte) encoded <code>OctetString</code>
-     * @return The decoded <code>OctetString</code>
-     */
-    String decodeOctetString( int[] value );
-    
-    /**
-     * Decodes a <code>null</code> value.  Based on the way our
-     * parser is developing, it is unlikely that this will
-     * ever be used.  So it is being included as a place
-     * holder.
-     * 
-     * @param value the encoded null value (N/A)
-     */
-    void decodeNull( int[] value );
-    
-    /**
-     * Decodes an object identifier from the array of bytes
-     * into a String value.
-     * 
-     * @param value the byte encoded object identifier
-     * @return a String representation of the byte identifier
-     */
-    String decodeObjectIdentifier( int[] value );
-    
-    Integer decodeSequence( int[] value );
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+
+package org.apache.snickers.asn;
+
+/**
+ * @author Wes McKean
+ *
+ * Basic interface for decoding TLVs.  The bytes
+ * are read in as ints, due to the casting limitation of
+ * bytes (-1=0xFF), and then passed to the decoder
+ * for decoding.
+ */
+public interface ASNDecoder {
+
+    /**
+     * Decode a boolean from an array of bytes into a Java 
+     * Boolean object
+     * 
+     * @param value The boolean encoded as an array of ints(bytes)
+     * @return a Boolean (decoded)
+     */
+    Boolean decodeBoolean( int[] value );
+    
+    /**
+     * Decodes an Integer from an array of ints (bytes)
+     * 
+     * @param value The integer, encoded in an array of ints(bytes)
+     * @return an Integer (decoded)
+     */
+    Integer decodeInteger( int[] value );
+    
+    /**
+     * Decodes a <code>BitString</code> from the an array of
+     * ints (bytes) into which it has been encoded.
+     *  
+     * @param value the int (byte) encoded <code>BitString</code>
+     * @return The decoded <code>BitString</code>
+     */
+    BitString decodeBitString( int[] value );
+    
+    /**
+     * Decodes a <code>OctetString</code> from the an array of
+     * ints (bytes) into which it has been encoded.
+     *  
+     * @param value the int (byte) encoded <code>OctetString</code>
+     * @return The decoded <code>OctetString</code>
+     */
+    String decodeOctetString( int[] value );
+    
+    /**
+     * Decodes a <code>null</code> value.  Based on the way our
+     * parser is developing, it is unlikely that this will
+     * ever be used.  So it is being included as a place
+     * holder.
+     * 
+     * @param value the encoded null value (N/A)
+     */
+    void decodeNull( int[] value );
+    
+    /**
+     * Decodes an object identifier from the array of bytes
+     * into a String value.
+     * 
+     * @param value the byte encoded object identifier
+     * @return a String representation of the byte identifier
+     */
+    String decodeObjectIdentifier( int[] value );
+    
+    Integer decodeSequence( int[] value );
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/ASNFactory.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/ASNFactory.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/ASNFactory.java	Sun Mar 14 14:02:18 2004
@@ -1,90 +1,90 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-package org.apache.snickers.asn;
-
-
-/**
- * This factory is responsible for retreiving the proper
- * encoder or decoder per request.  This has been put into
- * a factory in case we want singleton instances of some
- * codecs, and per instance use of others.
- * 
- * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
- * @author $Author$
- * @version $Rev$ 
- */
-public class ASNFactory {
-
-    /** Singleton instance of our BERDecoder */
-    private static final BERDecoderUtils berDecoder = new BERDecoderUtils();
-    
-	/**
-	 * Basic constructor for ASNFactory 
-	 */
-	public ASNFactory() {
-		super();
-	}
-
-    /**
-     * Retrieve a decoder based on the encoding requested.  We put
-     * this here so that we can have singleton instances of some
-     * decoders, and others can return a new object every time.
-     * 
-     * @param encoding The encoding, current BER is only supported
-     * @return the decoder requested, or <code>null<code> if the
-     *         requested encoding is not supported. 
-     */
-    public static ASNDecoder getDecoder( String encoding ) {
-        if( encoding.equals("BER") )
-            return berDecoder;
-            
-        return null;
-    }
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+package org.apache.snickers.asn;
+
+
+/**
+ * This factory is responsible for retreiving the proper
+ * encoder or decoder per request.  This has been put into
+ * a factory in case we want singleton instances of some
+ * codecs, and per instance use of others.
+ * 
+ * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
+ * @author $Author$
+ * @version $Rev$ 
+ */
+public class ASNFactory {
+
+    /** Singleton instance of our BERDecoder */
+    private static final BERDecoderUtils berDecoder = new BERDecoderUtils();
+    
+	/**
+	 * Basic constructor for ASNFactory 
+	 */
+	public ASNFactory() {
+		super();
+	}
+
+    /**
+     * Retrieve a decoder based on the encoding requested.  We put
+     * this here so that we can have singleton instances of some
+     * decoders, and others can return a new object every time.
+     * 
+     * @param encoding The encoding, current BER is only supported
+     * @return the decoder requested, or <code>null<code> if the
+     *         requested encoding is not supported. 
+     */
+    public static ASNDecoder getDecoder( String encoding ) {
+        if( encoding.equals("BER") )
+            return berDecoder;
+            
+        return null;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BERDecoderUtils.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BERDecoderUtils.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BERDecoderUtils.java	Sun Mar 14 14:02:18 2004
@@ -1,155 +1,155 @@
-/*
- *   Copyright 2004 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.snickers.asn;
-
-
-
-/**
- * Implements the basic BER decoder used by the ASN
- * compiler package.  The decoder is primarily responsible
- * for converting streams of bytes into ASN.1 primatives.
- * 
- * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
- * @author $Author$
- * @version $Rev$ 
- */
-public class BERDecoderUtils implements ASNDecoder {
-
-	/**
-	 * The basic decoder constructor 
-	 */
-	public BERDecoderUtils() {
-		super();
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.asn.ASNDecoder#decodeBoolean(int[])
-	 */
-    public Boolean decodeBoolean( int[] value ) {
-        Boolean result = null;
-        
-        if( value[0] > (byte)0 )
-            result = new Boolean(true);
-        else
-            result = new Boolean( false );
-            
-        return result;
-    }
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.asn.ASNDecoder#decodeInteger(int[])
-	 */
-    public Integer decodeInteger( int[] value ) {
-        int result = 0;
-        
-        for( int i = 0; i < value.length; i++ ) {
-            result = ( result << 8 ) | (int)value[i];
-        }
-
-        return new Integer( result );
-    }
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.asn.ASNDecoder#decodeBitString(int[])
-	 */
-    public BitString decodeBitString( int[] value ) {
-        BitString result = new BitString( value, value.length );
-        return result;
-    }
-    
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.asn.ASNDecoder#decodeOctetString(int[])
-	 */
-    public String decodeOctetString( int[] value ) {
-        byte[] bytes = new byte[value.length];
-        
-        for( int i = 0; i < value.length; i++ )
-            bytes[i] = (byte)value[i];
-            
-        return new String( bytes );
-    }
-    
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.asn.ASNDecoder#decodeNull(int[])
-	 */
-	public void decodeNull(int[] value) {
-	}
-
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.asn.ASNDecoder#decodeObjectIdentifier(int[])
-	 */
-	public String decodeObjectIdentifier(int[] value) {
-        StringBuffer sb = new StringBuffer();
-        int length = value.length;
-        int index = 0;
-        int aByte;
-        
-        // The first byte is special, so we have to handle it outside our
-        // our loop where we process it below.  Special thanks to the folks
-        // at Cryptix, on SourceForge for helping me understand how to do
-        // this.
-        
-        if( length > 1 ) {
-            // Isolate t first byte
-            aByte = value[index++] & 0xFF;
-            int firstValue = 0;
-            
-            if( aByte >= 40 && aByte < 80 ) {
-                firstValue = 1;
-            }
-            else if( aByte >= 80 ) {
-                firstValue = 2;
-            }
-            
-            int secondValue = aByte - ( firstValue * 40 );
-            sb.append( firstValue );
-            sb.append( '.' );
-            sb.append( secondValue );
-        }
-
-        // Now process the rest of the OID ints.  Each individual
-        // integer is part of the value, and we keep processing it
-        // while the more bit is set.
-        int subId = 0;
-        boolean more;
-
-        for( int i = index; i < length; i++ ) {
-            more = ((value[i] & 0x80) != 0 );
-            aByte = value[i] & 0x7F;
-            subId = (subId << 7) | aByte;
-
-            if( !more ) {
-                sb.append('.');
-                sb.append( subId );
-                subId = 0;
-            }
-        }
-
-        String result = sb.toString();
-        return (result);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.asn.ASNDecoder#decodeSequence(int[])
-	 */
-	public Integer decodeSequence(int[] value) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-}
+/*
+ *   Copyright 2004 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.snickers.asn;
+
+
+
+/**
+ * Implements the basic BER decoder used by the ASN
+ * compiler package.  The decoder is primarily responsible
+ * for converting streams of bytes into ASN.1 primatives.
+ * 
+ * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
+ * @author $Author$
+ * @version $Rev$ 
+ */
+public class BERDecoderUtils implements ASNDecoder {
+
+	/**
+	 * The basic decoder constructor 
+	 */
+	public BERDecoderUtils() {
+		super();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.asn.ASNDecoder#decodeBoolean(int[])
+	 */
+    public Boolean decodeBoolean( int[] value ) {
+        Boolean result = null;
+        
+        if( value[0] > (byte)0 )
+            result = new Boolean(true);
+        else
+            result = new Boolean( false );
+            
+        return result;
+    }
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.asn.ASNDecoder#decodeInteger(int[])
+	 */
+    public Integer decodeInteger( int[] value ) {
+        int result = 0;
+        
+        for( int i = 0; i < value.length; i++ ) {
+            result = ( result << 8 ) | (int)value[i];
+        }
+
+        return new Integer( result );
+    }
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.asn.ASNDecoder#decodeBitString(int[])
+	 */
+    public BitString decodeBitString( int[] value ) {
+        BitString result = new BitString( value, value.length );
+        return result;
+    }
+    
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.asn.ASNDecoder#decodeOctetString(int[])
+	 */
+    public String decodeOctetString( int[] value ) {
+        byte[] bytes = new byte[value.length];
+        
+        for( int i = 0; i < value.length; i++ )
+            bytes[i] = (byte)value[i];
+            
+        return new String( bytes );
+    }
+    
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.asn.ASNDecoder#decodeNull(int[])
+	 */
+	public void decodeNull(int[] value) {
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.asn.ASNDecoder#decodeObjectIdentifier(int[])
+	 */
+	public String decodeObjectIdentifier(int[] value) {
+        StringBuffer sb = new StringBuffer();
+        int length = value.length;
+        int index = 0;
+        int aByte;
+        
+        // The first byte is special, so we have to handle it outside our
+        // our loop where we process it below.  Special thanks to the folks
+        // at Cryptix, on SourceForge for helping me understand how to do
+        // this.
+        
+        if( length > 1 ) {
+            // Isolate t first byte
+            aByte = value[index++] & 0xFF;
+            int firstValue = 0;
+            
+            if( aByte >= 40 && aByte < 80 ) {
+                firstValue = 1;
+            }
+            else if( aByte >= 80 ) {
+                firstValue = 2;
+            }
+            
+            int secondValue = aByte - ( firstValue * 40 );
+            sb.append( firstValue );
+            sb.append( '.' );
+            sb.append( secondValue );
+        }
+
+        // Now process the rest of the OID ints.  Each individual
+        // integer is part of the value, and we keep processing it
+        // while the more bit is set.
+        int subId = 0;
+        boolean more;
+
+        for( int i = index; i < length; i++ ) {
+            more = ((value[i] & 0x80) != 0 );
+            aByte = value[i] & 0x7F;
+            subId = (subId << 7) | aByte;
+
+            if( !more ) {
+                sb.append('.');
+                sb.append( subId );
+                subId = 0;
+            }
+        }
+
+        String result = sb.toString();
+        return (result);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.asn.ASNDecoder#decodeSequence(int[])
+	 */
+	public Integer decodeSequence(int[] value) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BasicHandler.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BasicHandler.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BasicHandler.java	Sun Mar 14 14:02:18 2004
@@ -1,125 +1,125 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-
-package org.apache.snickers.asn;
-
-import org.apache.commons.codec.DecoderException;
-import org.apache.snickers.ber.TypeClass;
-
-/**
- * Basic TLV Handler.  Really doesn't do anything, but does
- * provide the basic methods for decoding primatives
- *
- * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
- * @author $Author$
- * @version $Rev$
- */
-public class BasicHandler implements TLVHandler {
-
-    /** The decoder to be used by this handler */
-    protected ASNDecoder decoder = null;
-     
-	/**
-	 * The simplest constructor for a BasicHander.
-     * 
-     * @param encoding the encoding used by our codec.
-	 */
-	public BasicHandler( String encoding ) {
-		super();
-        decoder = ASNFactory.getDecoder( encoding );
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.ber.TLVHandler#beginTag(org.apache.snickers.ber.TypeClass, int, boolean)
-	 */
-	public void beginTag(TypeClass typeClass, int id, boolean isPrimative)
-		throws DecoderException {
-        /*
-         * do nothing
-         */
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.ber.TLVHandler#endTag(org.apache.snickers.ber.TypeClass, int)
-	 */
-	public void endTag(TypeClass typeClass, int id) throws DecoderException {
-        /*
-         * do nothing
-         */
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.ber.TLVHandler#length(org.apache.snickers.ber.TypeClass, int, int)
-	 */
-	public void length(TypeClass typeClass, int id, int length) throws DecoderException {
-        /*
-         * do nothing
-         */
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.ber.TLVHandler#data(org.apache.snickers.ber.TypeClass, int, byte[])
-	 */
-	public void data(TypeClass typeClass, int id, byte[] data) throws DecoderException {
-        /*
-         * do nothing
-         */
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.snickers.ber.TLVHandler#received(org.apache.snickers.ber.TypeClass, int, org.apache.snickers.ber.TLV)
-	 */
-	public void received(TypeClass typeClass, int id, TLV tlv) throws DecoderException {
-            /*
-             * do nothing
-             */
-	}
-    
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+
+package org.apache.snickers.asn;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.snickers.ber.TypeClass;
+
+/**
+ * Basic TLV Handler.  Really doesn't do anything, but does
+ * provide the basic methods for decoding primatives
+ *
+ * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
+ * @author $Author$
+ * @version $Rev$
+ */
+public class BasicHandler implements TLVHandler {
+
+    /** The decoder to be used by this handler */
+    protected ASNDecoder decoder = null;
+     
+	/**
+	 * The simplest constructor for a BasicHander.
+     * 
+     * @param encoding the encoding used by our codec.
+	 */
+	public BasicHandler( String encoding ) {
+		super();
+        decoder = ASNFactory.getDecoder( encoding );
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.ber.TLVHandler#beginTag(org.apache.snickers.ber.TypeClass, int, boolean)
+	 */
+	public void beginTag(TypeClass typeClass, int id, boolean isPrimative)
+		throws DecoderException {
+        /*
+         * do nothing
+         */
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.ber.TLVHandler#endTag(org.apache.snickers.ber.TypeClass, int)
+	 */
+	public void endTag(TypeClass typeClass, int id) throws DecoderException {
+        /*
+         * do nothing
+         */
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.ber.TLVHandler#length(org.apache.snickers.ber.TypeClass, int, int)
+	 */
+	public void length(TypeClass typeClass, int id, int length) throws DecoderException {
+        /*
+         * do nothing
+         */
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.ber.TLVHandler#data(org.apache.snickers.ber.TypeClass, int, byte[])
+	 */
+	public void data(TypeClass typeClass, int id, byte[] data) throws DecoderException {
+        /*
+         * do nothing
+         */
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.snickers.ber.TLVHandler#received(org.apache.snickers.ber.TypeClass, int, org.apache.snickers.ber.TLV)
+	 */
+	public void received(TypeClass typeClass, int id, TLV tlv) throws DecoderException {
+            /*
+             * do nothing
+             */
+	}
+    
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BitString.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BitString.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/BitString.java	Sun Mar 14 14:02:18 2004
@@ -1,189 +1,189 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-
-package org.apache.snickers.asn ;
-
-
-import java.util.BitSet ;
-
-
-/**
- * @author Wes McKean
- *
- * Encapsulates the basic functionality of a bit string
- */
-public class BitString extends BitSet {
-
-    private static final int[] bitflags = {
-        (1 << 0 ),
-        (1 << 1 ),
-        (1 << 2 ),
-        (1 << 3 ),
-        (1 << 4 ),
-        (1 << 5 ),
-        (1 << 6 ),
-        (1 << 7 ),
-        (1 << 8 ),
-        (1 << 9 ),
-        (1 << 10 ),
-        (1 << 11 ),
-        (1 << 12 ),
-        (1 << 13 ),
-        (1 << 14 ),
-        (1 << 15 ),
-        (1 << 16 ),
-        (1 << 17 ),
-        (1 << 18 ),
-        (1 << 19 ),
-        (1 << 20 ),
-        (1 << 21 ),
-        (1 << 22 ),
-        (1 << 23 ),
-        (1 << 24 ),
-        (1 << 25 ),
-        (1 << 26 ),
-        (1 << 27 ),
-        (1 << 28 ),
-        (1 << 29 ),
-        (1 << 30 ),
-        (1 << 31 )
-    };
-    
-	/**
-	 * The basic constructor for a BitString
-	 */
-	public BitString( int[] bits, int numbits ) {
-		super(numbits);
-
-        int index = 0;
-        
-        for( int i = 0; i < bits.length && index < numbits; i++ ) {
-            for( int j = 0; j < 32 && index < numbits; j++ ) {
-                this.set(index++, ((bits[i] & bitflags[j]) != 0) );        
-            }
-        }
-	}
-
-    /**
-     * Constuct a BitString from an existing BitSet.  Since
-     * BitString inherits BitSet, this will also work for
-     * BitStrings as well.
-     * 
-     * @param bitSet the bit set containing our data
-     */
-    public BitString( BitSet bitSet ) {
-        super( bitSet.length() );
-        
-        for( int i = 0; i < bitSet.length(); i++ ) {
-            this.set(i, bitSet.get(i));
-        }
-    }
-    
-    /**
-     * Performs a binary and on the passed in BitString
-     * 
-     * @param value the BitString to and against this one
-     * @return a new BitString of the combined values.  Please
-     *         note that the result will have the length of
-     *         the largest BitString.
-     */
-    public BitString and( BitString value ) {
-        BitSet bt = (BitSet)this.clone();
-        bt.and( value );
-        return new BitString( bt );
-    }
-    
-    /**
-     * Performs a binary or on the passed in BitString
-     * 
-     * @param value the BitString to or against this one
-     * @return a new BitString of the combined values.  Please
-     *         note that the result will have the length of
-     *         the largest BitString.
-     */
-    public BitString or( BitString value ) {
-        BitSet bt = (BitSet)this.clone();
-        bt.or( value );
-        return new BitString( bt );
-    }
-
-    /**
-     * Performs a binary xor on the passed in BitString
-     * 
-     * @param value the BitString to xor against this one
-     * @return a new BitString of the combined values.  Please
-     *         note that the result will have the length of
-     *         the largest BitString.
-     */
-    public BitString xor( BitString value ) {
-        BitSet bt = (BitSet)this.clone();
-        bt.xor( value );
-        return new BitString( bt );
-    }
-    
-
-	/* (non-Javadoc)
-	 * @see java.lang.Object#toString()
-	 */
-	public String toString() {
-		StringBuffer sb = new StringBuffer();
-        
-        for( int i = length()-1; i >= 0; i-- ) {
-            if( super.get(i) ) {
-                sb.append("1");
-            }
-            else {
-                sb.append("0");
-            }
-        }
-        
-        return sb.toString();
-	}
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+
+package org.apache.snickers.asn ;
+
+
+import java.util.BitSet ;
+
+
+/**
+ * @author Wes McKean
+ *
+ * Encapsulates the basic functionality of a bit string
+ */
+public class BitString extends BitSet {
+
+    private static final int[] bitflags = {
+        (1 << 0 ),
+        (1 << 1 ),
+        (1 << 2 ),
+        (1 << 3 ),
+        (1 << 4 ),
+        (1 << 5 ),
+        (1 << 6 ),
+        (1 << 7 ),
+        (1 << 8 ),
+        (1 << 9 ),
+        (1 << 10 ),
+        (1 << 11 ),
+        (1 << 12 ),
+        (1 << 13 ),
+        (1 << 14 ),
+        (1 << 15 ),
+        (1 << 16 ),
+        (1 << 17 ),
+        (1 << 18 ),
+        (1 << 19 ),
+        (1 << 20 ),
+        (1 << 21 ),
+        (1 << 22 ),
+        (1 << 23 ),
+        (1 << 24 ),
+        (1 << 25 ),
+        (1 << 26 ),
+        (1 << 27 ),
+        (1 << 28 ),
+        (1 << 29 ),
+        (1 << 30 ),
+        (1 << 31 )
+    };
+    
+	/**
+	 * The basic constructor for a BitString
+	 */
+	public BitString( int[] bits, int numbits ) {
+		super(numbits);
+
+        int index = 0;
+        
+        for( int i = 0; i < bits.length && index < numbits; i++ ) {
+            for( int j = 0; j < 32 && index < numbits; j++ ) {
+                this.set(index++, ((bits[i] & bitflags[j]) != 0) );        
+            }
+        }
+	}
+
+    /**
+     * Constuct a BitString from an existing BitSet.  Since
+     * BitString inherits BitSet, this will also work for
+     * BitStrings as well.
+     * 
+     * @param bitSet the bit set containing our data
+     */
+    public BitString( BitSet bitSet ) {
+        super( bitSet.length() );
+        
+        for( int i = 0; i < bitSet.length(); i++ ) {
+            this.set(i, bitSet.get(i));
+        }
+    }
+    
+    /**
+     * Performs a binary and on the passed in BitString
+     * 
+     * @param value the BitString to and against this one
+     * @return a new BitString of the combined values.  Please
+     *         note that the result will have the length of
+     *         the largest BitString.
+     */
+    public BitString and( BitString value ) {
+        BitSet bt = (BitSet)this.clone();
+        bt.and( value );
+        return new BitString( bt );
+    }
+    
+    /**
+     * Performs a binary or on the passed in BitString
+     * 
+     * @param value the BitString to or against this one
+     * @return a new BitString of the combined values.  Please
+     *         note that the result will have the length of
+     *         the largest BitString.
+     */
+    public BitString or( BitString value ) {
+        BitSet bt = (BitSet)this.clone();
+        bt.or( value );
+        return new BitString( bt );
+    }
+
+    /**
+     * Performs a binary xor on the passed in BitString
+     * 
+     * @param value the BitString to xor against this one
+     * @return a new BitString of the combined values.  Please
+     *         note that the result will have the length of
+     *         the largest BitString.
+     */
+    public BitString xor( BitString value ) {
+        BitSet bt = (BitSet)this.clone();
+        bt.xor( value );
+        return new BitString( bt );
+    }
+    
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	public String toString() {
+		StringBuffer sb = new StringBuffer();
+        
+        for( int i = length()-1; i >= 0; i-- ) {
+            if( super.get(i) ) {
+                sb.append("1");
+            }
+            else {
+                sb.append("0");
+            }
+        }
+        
+        return sb.toString();
+	}
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/Primitive.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/Primitive.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/Primitive.java	Sun Mar 14 14:02:18 2004
@@ -1,68 +1,68 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-
-package org.apache.snickers.asn;
-
-/**
- * Tag values for primitives
- * 
- * @author Wes McKean
- * @author $Author$
- * @version $Rev$
- */
-public interface Primitive {
-    public final int BOOLEAN = 1;
-    public final int INTEGER = 2;
-    public final int BITSTRING = 3;
-    public final int OCTETSTRING = 4;
-    public final int NULL = 5;
-    public final int OBJECTIDENTIFIER = 6;
-    public final int ENUMERATION = 10;
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+
+package org.apache.snickers.asn;
+
+/**
+ * Tag values for primitives
+ * 
+ * @author Wes McKean
+ * @author $Author: akarasulu $
+ * @version $Rev$
+ */
+public interface Primitive {
+    public final int BOOLEAN = 1;
+    public final int INTEGER = 2;
+    public final int BITSTRING = 3;
+    public final int OCTETSTRING = 4;
+    public final int NULL = 5;
+    public final int OBJECTIDENTIFIER = 6;
+    public final int ENUMERATION = 10;
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLV.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLV.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLV.java	Sun Mar 14 14:02:18 2004
@@ -1,269 +1,269 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-package org.apache.snickers.asn;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.apache.commons.codec.binary.Binary;
-import org.apache.snickers.ber.BERUtils;
-import org.apache.snickers.ber.TypeClass;
-
-/**
- * Basic TLV structure consisting of:
- * 
- *      Tag
- *      Length
- *      Value
- * 
- * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
- * @author $Author$
- * @version $Rev$
- */
-public class TLV {
-
-    /** The tag for encoded attribute */
-    private int tag;
-    
-    /** The length of the value portion of our encoded attribute */
-    private int length;
-    
-    /** The value of this encoded attribute */
-    byte[] value = null;
-    
-    /** 
-     * The TLV children of this TLV.  This occurs when the V portion
-     * of a TLV is constructed, that is, the V portion is made up of
-     * more TLVs.
-     */
-    ArrayList children = null;
-        
-	/**
-	 * Empty constructor
-	 */
-	public TLV() {
-		super();
-        
-        tag = 0;
-        length = 0;
-	}
-
-    /**
-     * Constructor for a TLV with specified values
-     * 
-     * @param tag the tag for this TLV
-     * @param length the length of the value
-     * @param value the bytes representing the encoded value
-     */
-    public TLV( int tag, int length, byte[] value ) {
-        this.tag = tag;
-        this.length = length;
-        this.value = new byte[ value.length ];
-        System.arraycopy(value, 0, this.value, 0, value.length );
-    }
-
-    /**
-     * Constructor for a TLV with specified values
-     * 
-     * @param tag the tag for this TLV
-     * @param length the length of the value
-     * @param value the bytes representing the encoded value
-     * @param children a collection of TLVs comprising the children
-     *                 of this TLV.
-     */
-    public TLV( int tag, int length, byte[] value, Collection children ) {
-        this.tag = tag;
-        this.length = length;
-        this.value = new byte[ value.length ];
-        System.arraycopy(value, 0, this.value, 0, value.length );
-        
-        this.children = new ArrayList();
-        this.children.addAll( children );
-    }
-    
-    /**
-     * Retrieves the tag value for this TLV
-     * 
-     * @return the tag, an int value for this TLV
-     */
-    public int getTag() {
-        return tag;
-    }
-    
-    /**
-     * Set the tag value associated with a TLV
-     * 
-     * @param tag the new tag, an int, for this TLV
-     */
-    public void setTag( int tag ) {
-        this.tag = tag;
-    }
-    
-    /**
-     * Return the length of the V portion of this TLV
-     * 
-     * @return an integer representing the length
-     */
-    public int getLength() {
-        return length;
-    }
-    
-    /**
-     * Set the length portion of this TLV
-     * 
-     * @param length an integer representation of the length
-     */
-    public void setLength( int length ) {
-        this.length = length;
-    }
-    
-    /**
-     * Return the value portion of this TLV
-     * 
-     * @return a byte array of the encoded value
-     */
-    public byte[] getValue() {
-        return value;
-    }
-    
-    /**
-     * Set the encoded value of this TLV
-     * 
-     * @param value the byte array of the encoded value
-     */
-    public void setValue( byte[] value ) {
-        this.value = new byte[ value.length ];
-        System.arraycopy(value, 0, this.value, 0, value.length );
-    }
-
-    /**
-     * Return the child TLVs of this TLV
-     * 
-     * @return a collection of TLVs
-     */    
-    public Collection getChildren() {
-        return children;
-    }
-    
-    /**
-     * Sets the children associated with this TLV
-     * 
-     * @param children the child TLVs to associate with this TLV
-     */
-    public void setChildren(Collection children) {
-        this.children = new ArrayList();
-        this.children.addAll( children );
-    }
-    
-    /**
-     * Return the <code>TypeClass</code> associated with this TLV
-     * 
-     * @return the type class
-     */
-    public TypeClass getTypeClass() {
-        return BERUtils.getTypeClass( (byte) tag );
-    }
-
-    /**
-     * Return the unique ID of this TLV as specified in the ASN.1
-     * grammar.  Not all TLVs will have valid ids.  Some TLVs are
-     * just expected!
-     * 
-     * @return the id of this encoded value, or 0 if it doesn't have one
-     */    
-    public int getId() {
-        return ( tag & (Binary.BIT_4 | Binary.BIT_3 | Binary.BIT_2 | 
-                        Binary.BIT_1 | Binary.BIT_0 ) );
-   }
-   
-   /**
-    * Returns a boolean indicating that the value portion of
-    * this TLV is a primative.  If not, then it is constructed
-    * of more TLVs.
-    * 
-    * @return true if the value is a primative, else false.
-    */
-   public boolean isPrimative() {
-       return BERUtils.isPrimitive( tag );
-   }
-   
-   /**
-    * Get the number of child TLVs
-    * 
-    * @return the count of children
-    */
-   public int getChildCount() {
-       
-       int result = 0;
-       
-      if( children != null ) {
-            result = children.size();
-      }
-      
-      return result;
-   }
-   
-   /**
-    * Retrieves a specific child TLV or null
-    * if the index is not valid.
-    * 
-    * @param i the index of the child
-    * @return the TLV child object
-    */
-   public TLV getChild( int i ) {
-       TLV result = null;
-       
-       if( children != null ) {
-           result = (TLV)children.get(i);
-       }
-       
-       return result;
-   }
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+package org.apache.snickers.asn;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.commons.codec.binary.Binary;
+import org.apache.snickers.ber.BERUtils;
+import org.apache.snickers.ber.TypeClass;
+
+/**
+ * Basic TLV structure consisting of:
+ * 
+ *      Tag
+ *      Length
+ *      Value
+ * 
+ * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
+ * @author $Author: akarasulu $
+ * @version $Rev$
+ */
+public class TLV {
+
+    /** The tag for encoded attribute */
+    private int tag;
+    
+    /** The length of the value portion of our encoded attribute */
+    private int length;
+    
+    /** The value of this encoded attribute */
+    byte[] value = null;
+    
+    /** 
+     * The TLV children of this TLV.  This occurs when the V portion
+     * of a TLV is constructed, that is, the V portion is made up of
+     * more TLVs.
+     */
+    ArrayList children = null;
+        
+	/**
+	 * Empty constructor
+	 */
+	public TLV() {
+		super();
+        
+        tag = 0;
+        length = 0;
+	}
+
+    /**
+     * Constructor for a TLV with specified values
+     * 
+     * @param tag the tag for this TLV
+     * @param length the length of the value
+     * @param value the bytes representing the encoded value
+     */
+    public TLV( int tag, int length, byte[] value ) {
+        this.tag = tag;
+        this.length = length;
+        this.value = new byte[ value.length ];
+        System.arraycopy(value, 0, this.value, 0, value.length );
+    }
+
+    /**
+     * Constructor for a TLV with specified values
+     * 
+     * @param tag the tag for this TLV
+     * @param length the length of the value
+     * @param value the bytes representing the encoded value
+     * @param children a collection of TLVs comprising the children
+     *                 of this TLV.
+     */
+    public TLV( int tag, int length, byte[] value, Collection children ) {
+        this.tag = tag;
+        this.length = length;
+        this.value = new byte[ value.length ];
+        System.arraycopy(value, 0, this.value, 0, value.length );
+        
+        this.children = new ArrayList();
+        this.children.addAll( children );
+    }
+    
+    /**
+     * Retrieves the tag value for this TLV
+     * 
+     * @return the tag, an int value for this TLV
+     */
+    public int getTag() {
+        return tag;
+    }
+    
+    /**
+     * Set the tag value associated with a TLV
+     * 
+     * @param tag the new tag, an int, for this TLV
+     */
+    public void setTag( int tag ) {
+        this.tag = tag;
+    }
+    
+    /**
+     * Return the length of the V portion of this TLV
+     * 
+     * @return an integer representing the length
+     */
+    public int getLength() {
+        return length;
+    }
+    
+    /**
+     * Set the length portion of this TLV
+     * 
+     * @param length an integer representation of the length
+     */
+    public void setLength( int length ) {
+        this.length = length;
+    }
+    
+    /**
+     * Return the value portion of this TLV
+     * 
+     * @return a byte array of the encoded value
+     */
+    public byte[] getValue() {
+        return value;
+    }
+    
+    /**
+     * Set the encoded value of this TLV
+     * 
+     * @param value the byte array of the encoded value
+     */
+    public void setValue( byte[] value ) {
+        this.value = new byte[ value.length ];
+        System.arraycopy(value, 0, this.value, 0, value.length );
+    }
+
+    /**
+     * Return the child TLVs of this TLV
+     * 
+     * @return a collection of TLVs
+     */    
+    public Collection getChildren() {
+        return children;
+    }
+    
+    /**
+     * Sets the children associated with this TLV
+     * 
+     * @param children the child TLVs to associate with this TLV
+     */
+    public void setChildren(Collection children) {
+        this.children = new ArrayList();
+        this.children.addAll( children );
+    }
+    
+    /**
+     * Return the <code>TypeClass</code> associated with this TLV
+     * 
+     * @return the type class
+     */
+    public TypeClass getTypeClass() {
+        return BERUtils.getTypeClass( (byte) tag );
+    }
+
+    /**
+     * Return the unique ID of this TLV as specified in the ASN.1
+     * grammar.  Not all TLVs will have valid ids.  Some TLVs are
+     * just expected!
+     * 
+     * @return the id of this encoded value, or 0 if it doesn't have one
+     */    
+    public int getId() {
+        return ( tag & (Binary.BIT_4 | Binary.BIT_3 | Binary.BIT_2 | 
+                        Binary.BIT_1 | Binary.BIT_0 ) );
+   }
+   
+   /**
+    * Returns a boolean indicating that the value portion of
+    * this TLV is a primative.  If not, then it is constructed
+    * of more TLVs.
+    * 
+    * @return true if the value is a primative, else false.
+    */
+   public boolean isPrimative() {
+       return BERUtils.isPrimitive( tag );
+   }
+   
+   /**
+    * Get the number of child TLVs
+    * 
+    * @return the count of children
+    */
+   public int getChildCount() {
+       
+       int result = 0;
+       
+      if( children != null ) {
+            result = children.size();
+      }
+      
+      return result;
+   }
+   
+   /**
+    * Retrieves a specific child TLV or null
+    * if the index is not valid.
+    * 
+    * @param i the index of the child
+    * @return the TLV child object
+    */
+   public TLV getChild( int i ) {
+       TLV result = null;
+       
+       if( children != null ) {
+           result = (TLV)children.get(i);
+       }
+       
+       return result;
+   }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLVHandler.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLVHandler.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLVHandler.java	Sun Mar 14 14:02:18 2004
@@ -1,139 +1,139 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-package org.apache.snickers.asn;
-
-
-import org.apache.commons.codec.DecoderException;
-import org.apache.snickers.ber.TypeClass;
-
-
-/**
- * Basic interface for handling TLVs from the TLVParser.  The order of event 
- * firing will normally (always) consist of:
- * 
- *      beginTag, length, data, received, endTag
- *
- * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
- * @author $Author$
- * @version $Rev$
- */
-public interface TLVHandler 
-{
-    /**
-     * Fired by the TLVParser to indicate that a new TLV is being decoded
-     * 
-     * @param typeClass a type class object representing one of the four ASN.1 
-     *      type classes
-     * @param id The encoded structure id.  Not all encoded values will have an 
-     *      associated id
-     * @param isPrimative a boolean indicating that this value is a primitive
-     * @throws DecoderException if an error occurs during handling
-     */
-    public void beginTag( TypeClass typeClass, int id, boolean isPrimative ) 
-        throws DecoderException;
-    
-    /**
-     * Fired by the TLVParser to indicate that the processing of the current TLV
-     * has been completed
-     * 
-     * @param typeClass a type class object representing one of the four ASN.1 
-     *      type classes
-     * @param id The encoded structure id.  Not all encoded values will have 
-     *      an associated id
-     * @throws DecoderException if an error occurs during handling
-     */
-    public void endTag( TypeClass typeClass, int id ) throws DecoderException;
-
-    /**
-     * Fired by the TLVParser to indicate the length of the V portion of the 
-     * TLV structure.  Per the ASN.1 spec, there are three seperate encoding 
-     * forms:  short, long, indefinite.  Please note that the length will be 
-     * zero if the form is indefinite.
-     * 
-     * @param typeClass a type class object representing one of the four ASN.1 
-     *      type classes
-     * @param id The encoded structure id.  Not all encoded values will have 
-     *      an associated id
-     * @param length the length of the V portion of the TLV structure
-     * @throws DecoderException if an error occurs during handling
-     */
-    public void length( TypeClass typeClass, int id, int length ) 
-        throws DecoderException;
-    
-    /**
-     * Fired by the TLVParser when data is received.  The data may be all of 
-     * the required length, or it may be coming over in chunks.  In other words,
-     * this event may be fired multiple times.
-     * 
-     * @param typeClass a type class object representing one of the four ASN.1 
-     *      type classes
-     * @param id The encoded structure id.  Not all encoded values will have an 
-     *      associated id
-     * @param data the byte data associated with the value
-     * @throws DecoderException if an error occurs during handling
-     */
-    public void data( TypeClass typeClass, int id, byte[] data ) 
-        throws DecoderException;
-    
-    /**
-     * Fired by the TLVParser once the entire TLV packet has been received.  
-     * This method may need to be removed if we think it is going to be too 
-     * much of a memory hog.
-     * 
-     * @param typeClass a type class object representing one of the four 
-     *      ASN.1 type classes
-     * @param id The encoded structure id.  Not all encoded values will have 
-     *      an associated id
-     * @param tlv the TLV object which has just finished being parsed.
-     * @throws DecoderException if an error occurs during handling
-     */
-    public void received( TypeClass typeClass, int id, TLV tlv ) 
-        throws DecoderException;
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+package org.apache.snickers.asn;
+
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.snickers.ber.TypeClass;
+
+
+/**
+ * Basic interface for handling TLVs from the TLVParser.  The order of event 
+ * firing will normally (always) consist of:
+ * 
+ *      beginTag, length, data, received, endTag
+ *
+ * @author <a href="mailto:wesmckean@apache.org">Wes McKean</a>
+ * @author $Author: akarasulu $
+ * @version $Rev$
+ */
+public interface TLVHandler 
+{
+    /**
+     * Fired by the TLVParser to indicate that a new TLV is being decoded
+     * 
+     * @param typeClass a type class object representing one of the four ASN.1 
+     *      type classes
+     * @param id The encoded structure id.  Not all encoded values will have an 
+     *      associated id
+     * @param isPrimative a boolean indicating that this value is a primitive
+     * @throws DecoderException if an error occurs during handling
+     */
+    public void beginTag( TypeClass typeClass, int id, boolean isPrimative ) 
+        throws DecoderException;
+    
+    /**
+     * Fired by the TLVParser to indicate that the processing of the current TLV
+     * has been completed
+     * 
+     * @param typeClass a type class object representing one of the four ASN.1 
+     *      type classes
+     * @param id The encoded structure id.  Not all encoded values will have 
+     *      an associated id
+     * @throws DecoderException if an error occurs during handling
+     */
+    public void endTag( TypeClass typeClass, int id ) throws DecoderException;
+
+    /**
+     * Fired by the TLVParser to indicate the length of the V portion of the 
+     * TLV structure.  Per the ASN.1 spec, there are three seperate encoding 
+     * forms:  short, long, indefinite.  Please note that the length will be 
+     * zero if the form is indefinite.
+     * 
+     * @param typeClass a type class object representing one of the four ASN.1 
+     *      type classes
+     * @param id The encoded structure id.  Not all encoded values will have 
+     *      an associated id
+     * @param length the length of the V portion of the TLV structure
+     * @throws DecoderException if an error occurs during handling
+     */
+    public void length( TypeClass typeClass, int id, int length ) 
+        throws DecoderException;
+    
+    /**
+     * Fired by the TLVParser when data is received.  The data may be all of 
+     * the required length, or it may be coming over in chunks.  In other words,
+     * this event may be fired multiple times.
+     * 
+     * @param typeClass a type class object representing one of the four ASN.1 
+     *      type classes
+     * @param id The encoded structure id.  Not all encoded values will have an 
+     *      associated id
+     * @param data the byte data associated with the value
+     * @throws DecoderException if an error occurs during handling
+     */
+    public void data( TypeClass typeClass, int id, byte[] data ) 
+        throws DecoderException;
+    
+    /**
+     * Fired by the TLVParser once the entire TLV packet has been received.  
+     * This method may need to be removed if we think it is going to be too 
+     * much of a memory hog.
+     * 
+     * @param typeClass a type class object representing one of the four 
+     *      ASN.1 type classes
+     * @param id The encoded structure id.  Not all encoded values will have 
+     *      an associated id
+     * @param tlv the TLV object which has just finished being parsed.
+     * @throws DecoderException if an error occurs during handling
+     */
+    public void received( TypeClass typeClass, int id, TLV tlv ) 
+        throws DecoderException;
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLVParsingUtility.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLVParsingUtility.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/asn/TLVParsingUtility.java	Sun Mar 14 14:02:18 2004
@@ -1,232 +1,232 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-package org.apache.snickers.asn;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.FileInputStream;
-
-import org.apache.commons.codec.binary.*;
-import org.apache.snickers.ber.*;
-
-/**
- * @author Wes McKean
- *
- * A simply utility class to parse the ASN.1 TLVs out of a
- * stream and display some useful information.
- */
-public class TLVParsingUtility {
-
-    private InputStream m_is = null;
-    
-	/**
-	 * Basic constructor
-	 */
-	public TLVParsingUtility( InputStream is ) {
-		super();
-        m_is = is;
-	}
-
-    public void execute() {
-        
-        boolean finished = false;
-        
-        while( decodeTLV(0) != -1 );
-    }
-    
-    private int decodeTLV( int indent ) {
-    
-        int count = 0;
-        StringBuffer sb = new StringBuffer();
-        
-        for( int j = 0; j < indent; j++ ) {
-            sb.append(" ");
-        }
-        
-        String strIndent = sb.toString();
-        int valueLen = 0;
-        
-        try {
-            // Read the tag first
-            int tag = m_is.read();
-            
-            if( tag == -1 ) return tag;
-            
-            count++;
-            
-            int id = tag & (Binary.BIT_4 | Binary.BIT_3 | Binary.BIT_2 | Binary.BIT_1 | Binary.BIT_0 );
-            boolean primative =  BERUtils.isPrimitive(tag);
-            TypeClass tc = BERUtils.getTypeClass((byte)tag);
-            
-            System.out.println( strIndent + ">>>>>>>>>>>>>> TLV <<<<<<<<<<<<<" );
-            System.out.println( strIndent + "Tag:  " + toBits(tag) );
-            System.out.println( strIndent + "   class:  " + tc );
-            System.out.println( strIndent + "   id:     " + id );
-            System.out.println( strIndent + "   p/c:    " + ( primative ? "primative" : "constructed" ) );
-            
-            int length = m_is.read();
-            count++;
-            
-            System.out.println( strIndent + "   length: " + toBits( length ) );
-            
-            // Try to determine the length value
-            if( ( length & Binary.BIT_7 ) == 0 ) {
-                valueLen = length & ~Binary.BIT_7;
-                System.out.println( strIndent + "            SHORT FORM=" + (valueLen)); 
-            }
-            else {
-                // BIT 8 is set to one, and we therefore have
-                // a long form or an indefinite form
-                int lenlen = (length & ~Binary.BIT_7);
-                
-                if( lenlen == 0 ) {
-                    System.out.println( strIndent + "            INDEFINITE FORM=" + (lenlen)); 
-                }
-                else {
-                    valueLen = 0;
-                    
-                    for( int i = 0; i < lenlen; i++ ) {
-                        int b = m_is.read();
-                        count++;
-                        valueLen = (( valueLen << 8 ) | b );
-                    }
-
-                    System.out.println( strIndent + "            LONG FORM=" + (valueLen)); 
-                }
-            }
-            
-            System.out.println(   strIndent+ "   value:  " );
-            
-            if( primative ) {
-                if( tc.equals( TypeClass.PRIVATE )) {
-                    while ( valueLen > 0 ) {
-                        int t = decodeTLV( indent + 5 );
-                        count += t;
-                        valueLen -= t;
-                    }
-                }
-                else {
-                    decodePrimative( id, valueLen, strIndent );
-                    count += valueLen;
-                }
-            }
-            else {
-                while ( valueLen > 0 ) {
-                    int t = decodeTLV( indent + 5 );
-                    count += t;
-                    valueLen -= t;
-                }
-            }
-            
-            System.out.println( strIndent + ">>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<" );
-            
-            return count;
-        }
-        catch( IOException e ) {
-            e.printStackTrace();
-        }
-        
-        return -1;
-    }
-
-    private void decodePrimative( int id, int len, String strIndent ) throws IOException {
-        byte[] b = new byte[len];
-        m_is.read(b, 0, len );
-        int value = 0;
-                
-        switch( id ) {
-            case Primitive.BOOLEAN:
-                boolean bVal = ( ((int)b[0] ) > 0 ) ? true : false;
-                System.out.println( strIndent + "           BOOLEAN = " + true );
-                break;
-            case Primitive.INTEGER:
-                
-                for( int i = 0; i < len; i++ ) {
-                    value = (value << 8) | (int)b[i];
-                }
-                System.out.println( strIndent + "           INTEGER = " + value );
-                break;
-            case Primitive.OCTETSTRING:
-                String svalue = new String(b);
-                System.out.println( strIndent + "           String = " + svalue );
-                break;
-            case Primitive.ENUMERATION:
-                for( int i = 0; i < len; i++ ) {
-                    value = (value << 8) | (int)b[i];
-                }
-                System.out.println( strIndent + "           ENUMERATION = " + value );
-                break;
-            default:
-                System.out.println( strIndent + "           CONTEXT SPECIFIC = " + new String(b) );
-        }    
-    }
-    
-    private String toBits( int octet ) {
-        String result = "";
-        
-        for( int i = 0; i < 8; i++ ) {
-            if( (( 1 << i ) & octet) != 0 ) {
-                result = "1" + result;
-            }
-            else
-                result = "0" + result;
-        }
-        
-        return result;
-    }
-    
-	public static void main(String[] args) throws Exception {
-        FileInputStream fis = new FileInputStream( args[0] );
-        TLVParsingUtility p = new TLVParsingUtility( fis );
-        p.execute();
-        
-        fis.close();        
-	}
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+package org.apache.snickers.asn;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.FileInputStream;
+
+import org.apache.commons.codec.binary.*;
+import org.apache.snickers.ber.*;
+
+/**
+ * @author Wes McKean
+ *
+ * A simply utility class to parse the ASN.1 TLVs out of a
+ * stream and display some useful information.
+ */
+public class TLVParsingUtility {
+
+    private InputStream m_is = null;
+    
+	/**
+	 * Basic constructor
+	 */
+	public TLVParsingUtility( InputStream is ) {
+		super();
+        m_is = is;
+	}
+
+    public void execute() {
+        
+        boolean finished = false;
+        
+        while( decodeTLV(0) != -1 );
+    }
+    
+    private int decodeTLV( int indent ) {
+    
+        int count = 0;
+        StringBuffer sb = new StringBuffer();
+        
+        for( int j = 0; j < indent; j++ ) {
+            sb.append(" ");
+        }
+        
+        String strIndent = sb.toString();
+        int valueLen = 0;
+        
+        try {
+            // Read the tag first
+            int tag = m_is.read();
+            
+            if( tag == -1 ) return tag;
+            
+            count++;
+            
+            int id = tag & (Binary.BIT_4 | Binary.BIT_3 | Binary.BIT_2 | Binary.BIT_1 | Binary.BIT_0 );
+            boolean primative =  BERUtils.isPrimitive(tag);
+            TypeClass tc = BERUtils.getTypeClass((byte)tag);
+            
+            System.out.println( strIndent + ">>>>>>>>>>>>>> TLV <<<<<<<<<<<<<" );
+            System.out.println( strIndent + "Tag:  " + toBits(tag) );
+            System.out.println( strIndent + "   class:  " + tc );
+            System.out.println( strIndent + "   id:     " + id );
+            System.out.println( strIndent + "   p/c:    " + ( primative ? "primative" : "constructed" ) );
+            
+            int length = m_is.read();
+            count++;
+            
+            System.out.println( strIndent + "   length: " + toBits( length ) );
+            
+            // Try to determine the length value
+            if( ( length & Binary.BIT_7 ) == 0 ) {
+                valueLen = length & ~Binary.BIT_7;
+                System.out.println( strIndent + "            SHORT FORM=" + (valueLen)); 
+            }
+            else {
+                // BIT 8 is set to one, and we therefore have
+                // a long form or an indefinite form
+                int lenlen = (length & ~Binary.BIT_7);
+                
+                if( lenlen == 0 ) {
+                    System.out.println( strIndent + "            INDEFINITE FORM=" + (lenlen)); 
+                }
+                else {
+                    valueLen = 0;
+                    
+                    for( int i = 0; i < lenlen; i++ ) {
+                        int b = m_is.read();
+                        count++;
+                        valueLen = (( valueLen << 8 ) | b );
+                    }
+
+                    System.out.println( strIndent + "            LONG FORM=" + (valueLen)); 
+                }
+            }
+            
+            System.out.println(   strIndent+ "   value:  " );
+            
+            if( primative ) {
+                if( tc.equals( TypeClass.PRIVATE )) {
+                    while ( valueLen > 0 ) {
+                        int t = decodeTLV( indent + 5 );
+                        count += t;
+                        valueLen -= t;
+                    }
+                }
+                else {
+                    decodePrimative( id, valueLen, strIndent );
+                    count += valueLen;
+                }
+            }
+            else {
+                while ( valueLen > 0 ) {
+                    int t = decodeTLV( indent + 5 );
+                    count += t;
+                    valueLen -= t;
+                }
+            }
+            
+            System.out.println( strIndent + ">>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<" );
+            
+            return count;
+        }
+        catch( IOException e ) {
+            e.printStackTrace();
+        }
+        
+        return -1;
+    }
+
+    private void decodePrimative( int id, int len, String strIndent ) throws IOException {
+        byte[] b = new byte[len];
+        m_is.read(b, 0, len );
+        int value = 0;
+                
+        switch( id ) {
+            case Primitive.BOOLEAN:
+                boolean bVal = ( ((int)b[0] ) > 0 ) ? true : false;
+                System.out.println( strIndent + "           BOOLEAN = " + true );
+                break;
+            case Primitive.INTEGER:
+                
+                for( int i = 0; i < len; i++ ) {
+                    value = (value << 8) | (int)b[i];
+                }
+                System.out.println( strIndent + "           INTEGER = " + value );
+                break;
+            case Primitive.OCTETSTRING:
+                String svalue = new String(b);
+                System.out.println( strIndent + "           String = " + svalue );
+                break;
+            case Primitive.ENUMERATION:
+                for( int i = 0; i < len; i++ ) {
+                    value = (value << 8) | (int)b[i];
+                }
+                System.out.println( strIndent + "           ENUMERATION = " + value );
+                break;
+            default:
+                System.out.println( strIndent + "           CONTEXT SPECIFIC = " + new String(b) );
+        }    
+    }
+    
+    private String toBits( int octet ) {
+        String result = "";
+        
+        for( int i = 0; i < 8; i++ ) {
+            if( (( 1 << i ) & octet) != 0 ) {
+                result = "1" + result;
+            }
+            else
+                result = "0" + result;
+        }
+        
+        return result;
+    }
+    
+	public static void main(String[] args) throws Exception {
+        FileInputStream fis = new FileInputStream( args[0] );
+        TLVParsingUtility p = new TLVParsingUtility( fis );
+        p.execute();
+        
+        fis.close();        
+	}
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/AbstractDecoderTestCase.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/AbstractDecoderTestCase.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/AbstractDecoderTestCase.java	Sun Mar 14 14:02:18 2004
@@ -1,388 +1,388 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.util.Stack ;
-import java.nio.ByteBuffer ;
-import java.util.ArrayList ;
-
-import org.apache.commons.codec.binary.Binary ;
-import org.apache.commons.codec.DecoderException ;
-import org.apache.commons.codec.stateful.DecoderMonitor ;
-import org.apache.commons.codec.stateful.DecoderCallback ;
-import org.apache.commons.codec.stateful.StatefulDecoder ;
-
-import org.apache.commons.lang.exception.ExceptionUtils ;
-
-import org.apache.ldap.common.message.Message ;
-import org.apache.ldap.common.message.MessageEncoder ;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests the BER decoder.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public abstract class AbstractDecoderTestCase extends TestCase 
-    implements BERDecoderCallback, DecoderMonitor
-{
-    /** list of encountered TLV's as we recieve completed decode callbacks */
-    protected ArrayList tlvList = new ArrayList() ;
-    /** the decoder that is constructed every time */
-    protected BERDecoder decoder = null ;
-    
-
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp() ;
-        decoder = new BERDecoder() ;
-        decoder.setCallback( this ) ;
-        decoder.setDecoderMonitor( this ) ;
-    }
-
-    
-    /*
-     * @see TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown() ;
-        tlvList.clear() ;
-        decoder = null ;
-    }
-
-    
-    /**
-     * Constructor for BERDecoderTest.
-     * @param arg0
-     */
-    public AbstractDecoderTestCase( String arg0 )
-    {
-        super( arg0 ) ;
-    }
-    
-    
-    /**
-     * Fragments an array of bytes into multiple arrays 'attempting' to keep 
-     * them the same size however the last fragment will be an array 
-     * bites.length%size which may or may not be of the requested fragment size.
-     * However it will never be greater.  Use this method to break appart TLV 
-     * byte arrays to feed them into the decoder for testing.
-     * 
-     * @param bites the bites to fragment
-     * @param size the maximum size of a fragment
-     * @return the array of byte[] fragments
-     */
-    public byte[][] fragment( byte[] bites, int size )
-    {
-        byte[][] fragments = null ;
-        
-        if ( size <= 0 )
-        {    
-            throw new IllegalArgumentException( 
-                    "fragment size should be 1 or more but was " + size ) ;
-        }
-        
-        int wholeFrags = bites.length/size ;
-        int partialFragSize = bites.length % size ; 
-
-        /*
-         * Allocate what we need depending on the size of our remainder
-         */
-        if ( partialFragSize == 0 ) 
-        {
-            fragments = new byte[wholeFrags][] ;
-        }
-        else
-        {
-            fragments = new byte[wholeFrags+1][] ;
-            fragments[wholeFrags] = new byte[partialFragSize] ;
-        }
-        
-        for ( int ii = 0; ii < wholeFrags; ii++ )
-        {
-            fragments[ii] = new byte[size] ;
-            System.arraycopy( bites, ii * size, fragments[ii], 0, size ) ;
-        }
-        
-        if ( partialFragSize != 0 )
-        {
-            int srcPos = wholeFrags * size ;
-            byte[] src = fragments[wholeFrags] ;
-            System.arraycopy( bites, srcPos, src, 0, partialFragSize ) ;
-        }
-        
-        return fragments ;
-    }
-    
-    
-    /**
-     * BER decodes a string of 0's and 1's.
-     * 
-     * @param bitString a string of ascii 0's and 1's
-     * @return a copy of the decoded tuple or the partially decoded current tlv
-     * @throws DecoderException if there are errors while decoding.
-     */
-    public Tuple decode( String bitString ) throws DecoderException
-    {
-        byte [] bites = Binary.fromAscii( bitString.getBytes() ) ;
-        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
-        int lastSize = tlvList.size() ;
-        decoder.decode( buf ) ;
-        
-        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
-        {
-            return decoder.getCurrentTuple() ;
-        }
-        
-        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
-    }
-
-    
-    /**
-     * BER decodes a single byte.
-     * 
-     * @param bite a single byte to decode
-     * @return a copy of the decoded tuple or the partially decoded current tlv
-     * @throws DecoderException if there are errors while decoding.
-     */
-    public Tuple decode( byte bite ) throws DecoderException
-    {
-        byte [] bites = { bite } ;
-        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
-        int lastSize = tlvList.size() ;
-        decoder.decode( buf ) ;
-        
-        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
-        {
-            return decoder.getCurrentTuple() ;
-        }
-        
-        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
-    }
-
-    
-    /**
-     * BER decodes a byte array.
-     * 
-     * @param bites a byte array to decode
-     * @return a copy of the decoded tuple or the partially decoded current tlv
-     * @throws DecoderException if there are errors while decoding.
-     */
-    public Tuple decode( byte[] bites ) throws DecoderException
-    {
-        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
-        int lastSize = tlvList.size() ;
-        decoder.decode( buf ) ;
-        
-        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
-        {
-            return decoder.getCurrentTuple() ;
-        }
-        
-        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
-    }
-
-    
-    /**
-     * First BER encodes then BER decodes a Tuple.
-     * 
-     * @param tlv a tuple to encode then decode
-     * @return a copy of the decoded tuple or the partially decoded current tlv
-     * @throws DecoderException if there are errors while decoding
-     */
-    public Tuple decode( Tuple tlv ) throws DecoderException
-    {
-        ByteBuffer buf = ByteBuffer.wrap( tlv.encode() ) ;
-        int lastSize = tlvList.size() ;
-        decoder.decode( buf ) ;
-        
-        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
-        {
-            Stack stack = decoder.getTupleStack() ;
-            
-            if ( stack.isEmpty() )
-            {    
-                return decoder.getCurrentTuple() ;
-            }
-            else
-            {
-                return ( Tuple ) stack.peek() ;
-            }
-        }
-        
-        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
-    }
-
-    
-    /**
-     * First BER encodes then BER decodes a train of Tuples.
-     * 
-     * @param tlvs a tuple array to encode then decode
-     * @return a copy of the decoded tuple or the partially decoded current tlv
-     * @throws DecoderException if there are errors while decoding
-     */
-    public Tuple decode( Tuple[] tlvs ) throws DecoderException
-    {
-        int lastSize = tlvList.size() ;
-
-        for ( int ii = 0; ii < tlvs.length; ii++ )
-        {
-            decode( tlvs[ii] ) ;
-        }
-        
-        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
-        {
-            return decoder.getCurrentTuple() ;
-        }
-        
-        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
-    }
-    
-    
-    /**
-     * Encodes a message using the message framework and the default BERLib
-     * provider which is snacc for now.  Later we shall remove this dependency.
-     * It then decodes encoded output generated.
-     * 
-     * @param msg the BER encoded message
-     * @return the last tuple generated by decoding the encoded message
-     * @throws DecoderException if there are any failures
-     */
-    public Tuple decode( Message msg ) throws DecoderException
-    {
-        MessageEncoder encoder = new MessageEncoder() ;
-        decode( encoder.encode( msg ) ) ;
-        
-        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.BERDecoderCallback#tagDecoded(
-     * org.apache.snickers.ber.Tuple)
-     */
-    public void tagDecoded( Tuple tlv )
-    {
-        assertTrue( decoder.getCurrentTuple().equals( tlv ) ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.BERDecoderCallback#lengthDecoded(
-     * org.apache.snickers.ber.Tuple)
-     */
-    public void lengthDecoded( Tuple tlv )
-    {
-        assertTrue( decoder.getCurrentTuple().equals( tlv ) ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
-     */
-    public void decodeOccurred( StatefulDecoder decoder, Object decoded )
-    {
-        Tuple t = ( Tuple ) decoded ;
-        tlvList.add( t.clone() ) ;
-        assertEquals( BERDecoderState.VALUE, this.decoder.getState() ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackOccured(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderCallback, java.lang.Object)
-     */
-    public void callbackOccured( StatefulDecoder decoder, DecoderCallback cb,
-								 Object decoded )
-    {
-        assertEquals( this, cb ) ;
-        assertEquals( this.decoder, decoder ) ;
-        Tuple t = ( Tuple ) decoded ;
-        assertNotNull( t ) ;
-        if ( t.isPrimitive )
-        {    
-            assertTrue( this.decoder.getCurrentTuple().equals( decoded ) ) ;
-        }
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackSet(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderCallback, 
-     * org.apache.commons.codec.stateful.DecoderCallback)
-     */
-    public void callbackSet( StatefulDecoder decoder, DecoderCallback oldcb,
-							 DecoderCallback newcb )
-    {
-        assertEquals( this, newcb ) ;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#error(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void error( StatefulDecoder decoder, Exception exception )
-    {
-        fail( ExceptionUtils.getFullStackTrace( exception ) ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#fatalError(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void fatalError( StatefulDecoder decoder, Exception exception )
-    {
-        fail( ExceptionUtils.getFullStackTrace( exception ) ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#monitorSet(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderMonitor)
-     */
-    public void monitorSet( StatefulDecoder decoder, DecoderMonitor oldmon )
-    {
-        assertEquals( this, oldmon ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#warning(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void warning( StatefulDecoder decoder, Exception exception )
-    {
-        fail( ExceptionUtils.getFullStackTrace( exception ) ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.util.Stack ;
+import java.nio.ByteBuffer ;
+import java.util.ArrayList ;
+
+import org.apache.commons.codec.binary.Binary ;
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+
+import org.apache.commons.lang.exception.ExceptionUtils ;
+
+import org.apache.ldap.common.message.Message ;
+import org.apache.ldap.common.message.MessageEncoder ;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests the BER decoder.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public abstract class AbstractDecoderTestCase extends TestCase 
+    implements BERDecoderCallback, DecoderMonitor
+{
+    /** list of encountered TLV's as we recieve completed decode callbacks */
+    protected ArrayList tlvList = new ArrayList() ;
+    /** the decoder that is constructed every time */
+    protected BERDecoder decoder = null ;
+    
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp() ;
+        decoder = new BERDecoder() ;
+        decoder.setCallback( this ) ;
+        decoder.setDecoderMonitor( this ) ;
+    }
+
+    
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown() ;
+        tlvList.clear() ;
+        decoder = null ;
+    }
+
+    
+    /**
+     * Constructor for BERDecoderTest.
+     * @param arg0
+     */
+    public AbstractDecoderTestCase( String arg0 )
+    {
+        super( arg0 ) ;
+    }
+    
+    
+    /**
+     * Fragments an array of bytes into multiple arrays 'attempting' to keep 
+     * them the same size however the last fragment will be an array 
+     * bites.length%size which may or may not be of the requested fragment size.
+     * However it will never be greater.  Use this method to break appart TLV 
+     * byte arrays to feed them into the decoder for testing.
+     * 
+     * @param bites the bites to fragment
+     * @param size the maximum size of a fragment
+     * @return the array of byte[] fragments
+     */
+    public byte[][] fragment( byte[] bites, int size )
+    {
+        byte[][] fragments = null ;
+        
+        if ( size <= 0 )
+        {    
+            throw new IllegalArgumentException( 
+                    "fragment size should be 1 or more but was " + size ) ;
+        }
+        
+        int wholeFrags = bites.length/size ;
+        int partialFragSize = bites.length % size ; 
+
+        /*
+         * Allocate what we need depending on the size of our remainder
+         */
+        if ( partialFragSize == 0 ) 
+        {
+            fragments = new byte[wholeFrags][] ;
+        }
+        else
+        {
+            fragments = new byte[wholeFrags+1][] ;
+            fragments[wholeFrags] = new byte[partialFragSize] ;
+        }
+        
+        for ( int ii = 0; ii < wholeFrags; ii++ )
+        {
+            fragments[ii] = new byte[size] ;
+            System.arraycopy( bites, ii * size, fragments[ii], 0, size ) ;
+        }
+        
+        if ( partialFragSize != 0 )
+        {
+            int srcPos = wholeFrags * size ;
+            byte[] src = fragments[wholeFrags] ;
+            System.arraycopy( bites, srcPos, src, 0, partialFragSize ) ;
+        }
+        
+        return fragments ;
+    }
+    
+    
+    /**
+     * BER decodes a string of 0's and 1's.
+     * 
+     * @param bitString a string of ascii 0's and 1's
+     * @return a copy of the decoded tuple or the partially decoded current tlv
+     * @throws DecoderException if there are errors while decoding.
+     */
+    public Tuple decode( String bitString ) throws DecoderException
+    {
+        byte [] bites = Binary.fromAscii( bitString.getBytes() ) ;
+        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
+        int lastSize = tlvList.size() ;
+        decoder.decode( buf ) ;
+        
+        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
+        {
+            return decoder.getCurrentTuple() ;
+        }
+        
+        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
+    }
+
+    
+    /**
+     * BER decodes a single byte.
+     * 
+     * @param bite a single byte to decode
+     * @return a copy of the decoded tuple or the partially decoded current tlv
+     * @throws DecoderException if there are errors while decoding.
+     */
+    public Tuple decode( byte bite ) throws DecoderException
+    {
+        byte [] bites = { bite } ;
+        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
+        int lastSize = tlvList.size() ;
+        decoder.decode( buf ) ;
+        
+        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
+        {
+            return decoder.getCurrentTuple() ;
+        }
+        
+        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
+    }
+
+    
+    /**
+     * BER decodes a byte array.
+     * 
+     * @param bites a byte array to decode
+     * @return a copy of the decoded tuple or the partially decoded current tlv
+     * @throws DecoderException if there are errors while decoding.
+     */
+    public Tuple decode( byte[] bites ) throws DecoderException
+    {
+        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
+        int lastSize = tlvList.size() ;
+        decoder.decode( buf ) ;
+        
+        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
+        {
+            return decoder.getCurrentTuple() ;
+        }
+        
+        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
+    }
+
+    
+    /**
+     * First BER encodes then BER decodes a Tuple.
+     * 
+     * @param tlv a tuple to encode then decode
+     * @return a copy of the decoded tuple or the partially decoded current tlv
+     * @throws DecoderException if there are errors while decoding
+     */
+    public Tuple decode( Tuple tlv ) throws DecoderException
+    {
+        ByteBuffer buf = ByteBuffer.wrap( tlv.encode() ) ;
+        int lastSize = tlvList.size() ;
+        decoder.decode( buf ) ;
+        
+        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
+        {
+            Stack stack = decoder.getTupleStack() ;
+            
+            if ( stack.isEmpty() )
+            {    
+                return decoder.getCurrentTuple() ;
+            }
+            else
+            {
+                return ( Tuple ) stack.peek() ;
+            }
+        }
+        
+        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
+    }
+
+    
+    /**
+     * First BER encodes then BER decodes a train of Tuples.
+     * 
+     * @param tlvs a tuple array to encode then decode
+     * @return a copy of the decoded tuple or the partially decoded current tlv
+     * @throws DecoderException if there are errors while decoding
+     */
+    public Tuple decode( Tuple[] tlvs ) throws DecoderException
+    {
+        int lastSize = tlvList.size() ;
+
+        for ( int ii = 0; ii < tlvs.length; ii++ )
+        {
+            decode( tlvs[ii] ) ;
+        }
+        
+        if ( tlvList.isEmpty() || tlvList.size() == lastSize )
+        {
+            return decoder.getCurrentTuple() ;
+        }
+        
+        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
+    }
+    
+    
+    /**
+     * Encodes a message using the message framework and the default BERLib
+     * provider which is snacc for now.  Later we shall remove this dependency.
+     * It then decodes encoded output generated.
+     * 
+     * @param msg the BER encoded message
+     * @return the last tuple generated by decoding the encoded message
+     * @throws DecoderException if there are any failures
+     */
+    public Tuple decode( Message msg ) throws DecoderException
+    {
+        MessageEncoder encoder = new MessageEncoder() ;
+        decode( encoder.encode( msg ) ) ;
+        
+        return ( Tuple ) tlvList.get( tlvList.size() - 1 ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.BERDecoderCallback#tagDecoded(
+     * org.apache.snickers.ber.Tuple)
+     */
+    public void tagDecoded( Tuple tlv )
+    {
+        assertTrue( decoder.getCurrentTuple().equals( tlv ) ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.BERDecoderCallback#lengthDecoded(
+     * org.apache.snickers.ber.Tuple)
+     */
+    public void lengthDecoded( Tuple tlv )
+    {
+        assertTrue( decoder.getCurrentTuple().equals( tlv ) ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
+     */
+    public void decodeOccurred( StatefulDecoder decoder, Object decoded )
+    {
+        Tuple t = ( Tuple ) decoded ;
+        tlvList.add( t.clone() ) ;
+        assertEquals( BERDecoderState.VALUE, this.decoder.getState() ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackOccured(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderCallback, java.lang.Object)
+     */
+    public void callbackOccured( StatefulDecoder decoder, DecoderCallback cb,
+								 Object decoded )
+    {
+        assertEquals( this, cb ) ;
+        assertEquals( this.decoder, decoder ) ;
+        Tuple t = ( Tuple ) decoded ;
+        assertNotNull( t ) ;
+        if ( t.isPrimitive )
+        {    
+            assertTrue( this.decoder.getCurrentTuple().equals( decoded ) ) ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackSet(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderCallback, 
+     * org.apache.commons.codec.stateful.DecoderCallback)
+     */
+    public void callbackSet( StatefulDecoder decoder, DecoderCallback oldcb,
+							 DecoderCallback newcb )
+    {
+        assertEquals( this, newcb ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#error(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void error( StatefulDecoder decoder, Exception exception )
+    {
+        fail( ExceptionUtils.getFullStackTrace( exception ) ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#fatalError(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void fatalError( StatefulDecoder decoder, Exception exception )
+    {
+        fail( ExceptionUtils.getFullStackTrace( exception ) ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#monitorSet(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderMonitor)
+     */
+    public void monitorSet( StatefulDecoder decoder, DecoderMonitor oldmon )
+    {
+        assertEquals( this, oldmon ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#warning(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void warning( StatefulDecoder decoder, Exception exception )
+    {
+        fail( ExceptionUtils.getFullStackTrace( exception ) ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoder.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoder.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoder.java	Sun Mar 14 14:02:18 2004
@@ -1,629 +1,629 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.util.Stack ;
-
-import java.nio.ByteBuffer ;
-
-import org.apache.commons.codec.binary.Binary ;
-import org.apache.commons.codec.DecoderException ;
-import org.apache.commons.codec.stateful.DecoderMonitor ;
-import org.apache.commons.codec.stateful.DecoderCallback ;
-import org.apache.commons.codec.stateful.StatefulDecoder ;
-import org.apache.commons.codec.stateful.DecoderMonitorAdapter ;
-import org.apache.commons.collections.primitives.ArrayByteList ;
-
-
-/**
- * Low level BER encoded bytes to Tag Value Length (TLV) tuple decoder.  
- * This decoder is a low level event based parser which operates in a fashion 
- * similar to the way SAX works except the elements of concern are the tag, 
- * length, and value entities.
- * <p>
- * Instance variables and a Stack is used to track the state of the decoder 
- * between decode calls.  The stack maintains the nesting of TLV tuples.  Rather
- * than creating new TLV tuple instances every time a single tuple is reused for
- * primitive types and new tlv tuples are cloned for constructed types.  The 
- * tuple fed to the callback must therefore be used very carefully - its values
- * must be copied to prevent their loss.
- * </p>
- * <p>
- * Note that all tuples are not created equal.  Constructed TLVs nesting others
- * will have null value members.  Only TLV tuples of primitive types or the 
- * leaf TLV tuples of the TLV tuple tree will only contain non null values.  
- * Therefore the nature of a TLV tuple should be investigated by callbacks 
- * before attempting to interpret their values.
- * </p>
- * 
- * @see Tuple for TLV tuple value size limitations
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class BERDecoder implements StatefulDecoder
-{
-    public static final BERDecoderCallback DEFAULT_CALLBACK = 
-        new BERDecoderCallbackAdapter() ;
-    public static final DecoderMonitor DEFAULT_MONITOR =
-        new DecoderMonitorAdapter() ;
-    
-    /** this decoder's callback */
-    private BERDecoderCallback cb = DEFAULT_CALLBACK ;
-    /** the monitor used by this decoder */
-    private DecoderMonitor monitor = DEFAULT_MONITOR ;
-    
-    /** the single TLV tuple used by this decoder */
-    private final Tuple tlv = new Tuple() ;
-
-    /** a byte buffer used to collect the arriving tag octets */ 
-    private final ArrayByteList tagBuffer = new ArrayByteList( 10 ) ;
-    /** a byte buffer used to collect the arriving legth octets */ 
-    private final ArrayByteList lengthBuffer = new ArrayByteList( 10 ) ;
-
-    /** stack of nested/constructed TLV tuples */
-    private final Stack tlvStack = new Stack() ;
-
-    /** the length of the length data */
-    private int lengthOfLength = 0 ;
-    
-    /** the state of this decoder */
-    private BERDecoderState state = BERDecoderState.getStartState() ;
-    
-    
-    // ------------------------------------------------------------------------
-    // StatefulDecoder Methods
-    // ------------------------------------------------------------------------
-
-    
-    /**
-     * Expects a ByteBuffer containing BER encoded data.
-     * 
-     * @see org.apache.commons.codec.stateful.StatefulDecoder#decode(
-     * java.lang.Object)
-     * @throws ClassCastException if the encoded argument is not a ByteBuffer
-     * @throws IllegalArgumentException if the buffer is null or empty
-     */
-    public void decode( Object encoded ) throws DecoderException
-    {
-        ByteBuffer buf = ( ByteBuffer ) encoded ;
-        
-        /* --------------------------------------------------------------------
-           Handle any unusual input by informing the monitor. 
-           ------------------------------------------------------------------ */
-        
-        if ( buf == null && monitor != null )
-        {
-            String msg = "ignoring null argument to decode()" ;
-            monitor.warning( this, new IllegalArgumentException( msg ) ) ;
-            return ;
-        }
-
-        if ( buf.remaining() == 0 && monitor != null )
-        {
-            String msg = "ignoring empty buffer" ;
-            monitor.warning( this, new IllegalArgumentException( msg ) ) ;
-            return ;
-        }
-        
-        /*
-         * This loop is used instead of costly recursion.  This requires each
-         * of the statewise decode methods to process bytes from the buffer.  If
-         * they can process enough to switch state they do and return 
-         * immediately.  This loop makes sure the next processing state is 
-         * handled if there is more data for that state.
-         */
-        while ( buf.hasRemaining() )
-        {    
-            switch( state.getValue() )
-            {
-                case( BERDecoderState.TAG_VAL ):
-                    decodeTag( buf ) ;
-                    break ;
-                case( BERDecoderState.LENGTH_VAL ):
-                    decodeLength( buf ) ;
-                    break ;
-                case( BERDecoderState.VALUE_VAL ):
-                    decodeValue( buf ) ;
-                    break ;
-            }
-        }
-    }
-    
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.StatefulDecoder#setCallback(
-     * org.apache.commons.codec.stateful.DecoderCallback)
-     */
-    public void setCallback( DecoderCallback cb )
-    {
-        this.cb = ( BERDecoderCallback ) cb ;
-    }
-    
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
-     * org.apache.commons.codec.stateful.DecoderMonitor)
-     */
-    public void setDecoderMonitor( DecoderMonitor monitor )
-    {
-        this.monitor = monitor ;
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // State Based Decode Methods
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * Extracts the TLV's tag portion from the buffer.
-     * 
-     * @param buf the byte byffer containing BER encoded data 
-     */
-    private void decodeTag( ByteBuffer buf ) throws DecoderException
-    {
-        for ( tlv.index = 0; buf.hasRemaining(); tlv.index++ )
-        {
-            byte octet = buf.get() ;
-            tagBuffer.add( octet ) ;
-            
-            if ( tagBuffer.size() == 1 )
-            {
-                int id = BERUtils.SHORT_TAG_MASK & octet ;
-                tlv.isPrimitive = BERUtils.isPrimitive( octet ) ; 
-                tlv.typeClass = BERUtils.getTypeClass( octet ) ;
-                
-                // continue to collect more octets if this is the long Tag form
-                if ( id == BERUtils.SHORT_TAG_MASK )
-                {
-                    continue ;
-                }
-                
-                // its the short form so we get the id, switch state & return
-                tlv.id = id ;
-                fireTagDecoded() ;
-                state = state.getNext( tlv.isPrimitive ) ;
-                
-                // we moved by one byte so we update stack indices by 1
-                updateStack( 1 ) ;
-                return ;
-            }
-            
-            /*
-             * From here on we're dealing with the long form of the tag.  The
-             * terminating octet for the long form uses a raised most 
-             * significant bit to flag the end of the train of octets for the 
-             * tag id.
-             */ 
-            if ( ( octet & Binary.BIT_7 ) == 0 )
-            {
-                tlv.id = BERUtils.getTagId( tagBuffer ) ;
-                fireTagDecoded() ;
-                state = state.getNext( tlv.isPrimitive ) ;
-                
-                // we moved by many bytes so we update stack accordingly
-                updateStack( tagBuffer.size() ) ;
-                return ;
-            }
-        }
-    }
-    
-    
-    /**
-     * Extracts the length portion from the buffer.
-     * 
-     * @param buf the byte byffer containing BER encoded data 
-     */
-    private void decodeLength( ByteBuffer buf ) throws DecoderException
-    {
-        while ( buf.hasRemaining() )
-        {
-            tlv.index++ ;
-            byte octet = buf.get() ;
-            lengthBuffer.add( octet ) ;
-            
-            if ( lengthBuffer.size() == 1 )
-            {
-                lengthOfLength = octet & BERUtils.LONG_TAG_MASK ;
-                
-                // handle the short form of the length here
-                if ( ( octet & Binary.BIT_7 ) == 0 ) 
-                {
-                    lengthOfLength = 0 ;
-                    tlv.length = octet ;
-                    tlv.valueIndex = Tuple.UNDEFINED ;
-
-                    if ( tlv.isPrimitive )
-                    {
-                        tlv.value = new byte[tlv.length] ;
-                        fireLengthDecoded() ;
-                        state = BERDecoderState.VALUE ;
-                        // we moved by one byte so we update stack indices by 1
-                        updateStack( 1 ) ;
-                    }
-                    else 
-                    {
-                        // We moved by one byte so we update stack indices by 1
-                        // need to do this here so we do not double update the
-                        // current tuple after pushing it onto the stack.
-                        updateStack( 1 ) ;
-
-                        tlvStack.push( tlv.clone() ) ;
-                        fireLengthDecoded() ;
-                        tlv.clear() ;
-                        state = BERDecoderState.TAG ;
-                    }
-
-                    handleIndefinateTerminator() ;
-                    return ;
-                }
-                // the indefinate form of the length
-                else if ( lengthOfLength == 0 )
-                {
-                    lengthOfLength = Tuple.INDEFINATE ;
-                    tlv.index = Tuple.INDEFINATE ;
-                    tlv.length = Tuple.INDEFINATE ;
-                    tlv.valueIndex = Tuple.UNDEFINED ;
-                    fireLengthDecoded() ;
-                    tlvStack.push( tlv.clone() ) ;
-                    tlv.clear() ;
-                    state = BERDecoderState.TAG ;
-
-                    // we moved by one byte so we update stack indices by 1
-                    updateStack( 1 ) ;
-                    return ;
-                }
-            }
-
-            /*
-             * if we have collected all the octets needed for computing the long
-             * form length so we need to calculate the length push it and return
-             */
-            if ( lengthBuffer.size() == lengthOfLength + 1 )
-            {
-                lengthOfLength = 0 ;
-                tlv.length = BERUtils.getLength( lengthBuffer ) ;
-                tlv.valueIndex = Tuple.UNDEFINED ;
-                
-                if ( tlv.isPrimitive )
-                {
-                    tlv.value = new byte[tlv.length] ;
-                    fireLengthDecoded() ;
-                    state = BERDecoderState.VALUE ;
-                }
-                else
-                {
-                    tlvStack.push( tlv.clone() ) ;
-                    fireLengthDecoded() ;
-                    tlv.clear() ;
-                    state = BERDecoderState.TAG ;
-                }
-                
-                /*
-                 * we moved by one byte + lengthOfLength so we update stack 
-                 * indices by lengthOfLength + 1 
-                 */
-                updateStack( lengthOfLength + 1 ) ;
-                return ;
-            }
-        }
-    }
-
-    
-    /**
-     * Extracts the value portion from the buffer for a primitive type.
-     * 
-     * @param buf the byte byffer containing BER encoded data 
-     */
-    private void decodeValue( ByteBuffer buf ) throws DecoderException
-    {
-        byte[] value = ( byte [] ) tlv.value ;
-        int offset = Tuple.UNDEFINED ;
-        int needToRead = Tuple.UNDEFINED ;
-
-        if ( ! tlv.isPrimitive )
-        {
-            IllegalStateException e = new IllegalStateException( 
-                    "should only be working with primitive tlv" ) ;
-            
-            if ( monitor == null )
-            {    
-                throw e ;
-            }
-            else
-            {
-                monitor.fatalError( this, e ) ;
-            }
-            
-            return ;
-        }
-        
-        if ( ! buf.hasRemaining() )
-        {
-            return ;
-        }
-
-        /*
-         * setup to start decoding the value
-         */
-        if ( tlv.valueIndex == Tuple.UNDEFINED )
-        {
-            needToRead = tlv.length ;
-            offset = 0 ;
-        }
-        else
-        {
-            needToRead = tlv.length - tlv.valueIndex ;
-            offset = tlv.valueIndex ;
-        }
-        
-        /*
-         * check if we have the remainder of the value to complete the 
-         * TLV within the current buffer - if so we read all of it
-         */
-        if ( buf.remaining() >= needToRead )
-        {
-            buf.get( value, offset, needToRead ) ;
-            tlv.valueIndex = tlv.length ;
-            tlv.index += needToRead ;
-            fireDecodeOccurred( tlv ) ;
-            updateStack( needToRead ) ;
-            tlv.clear() ;
-            state = BERDecoderState.TAG ;
-        }
-        
-        /*
-         * the buffer does not contain the rest of the value we need in order
-         * to complete the current TLV - the value is fragmented so we read
-         * what we can and update indices by that amount.
-         */
-        else
-        {
-            if ( tlv.valueIndex == Tuple.UNDEFINED )
-            {
-                tlv.valueIndex = 0 ;
-            }
-            
-            int remaining = buf.remaining() ;
-            buf.get( value, offset, remaining ) ;
-            tlv.valueIndex += remaining ;
-            updateStack( remaining ) ;
-        }
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // private utility methods
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * Fires a tag decoded event by making the appropriate calls to the 
-     * callback and the monitor.   If the monitor is a BERDecoderMonitor with
-     * extended reporting, then those methods are invoked.
-     * 
-     * Also as a side-effect this method clears the tag buffer once it has 
-     * finished notifying the monitor and calling the callback. 
-     */
-    private void fireTagDecoded()
-    {
-        if ( cb != null )
-        {
-            cb.tagDecoded( tlv ) ;
-        }
-        
-        if ( monitor != null && monitor instanceof BERDecoderMonitor )
-        {
-            BERDecoderMonitor berMonitor = ( BERDecoderMonitor ) monitor ;
-            berMonitor.tagDecoded( tlv, tagBuffer.toArray() ) ;
-        }
-        
-        tagBuffer.clear() ;
-    }
-    
-    
-    /**
-     * Fires a length decoded event by making the appropriate calls to the 
-     * callback and the monitor.   If the monitor is a BERDecoderMonitor with
-     * extended reporting, then those methods are invoked.
-     * 
-     * Also as a side-effect this method clears the length buffer once it has 
-     * finished notifying the monitor and calling the callback. 
-     */
-    private void fireLengthDecoded()
-    {
-        if ( cb != null )
-        {
-            cb.lengthDecoded( tlv ) ;
-        }
-        
-        if ( monitor != null && monitor instanceof BERDecoderMonitor )
-        {
-            BERDecoderMonitor berMonitor = ( BERDecoderMonitor ) monitor ;
-            berMonitor.lengthDecoded( tlv, lengthBuffer.toArray() ) ;
-        }
-        
-        lengthBuffer.clear() ;
-    }
-    
-    
-    /**
-     * Fires a complete TLV decoded event by making the appropriate calls to 
-     * the callback and the monitor.
-     */
-    private void fireDecodeOccurred( Tuple tlv )
-    {
-        if ( cb != null )
-        {
-            cb.decodeOccurred( this, tlv ) ;
-        }
-        
-        if ( monitor != null )
-        {
-            monitor.callbackOccured( this, cb, tlv ) ;
-        }
-    }
-
-    
-    /**
-     * Increments the indices of constructed TLV's within the TLV Stack.
-     * 
-     * @param increment the amount to increment indices by.
-     */
-    private void updateStack( int increment )
-    {
-        for ( int ii = 0; ii < tlvStack.size(); ii++ )
-        {
-            Tuple t = ( Tuple ) tlvStack.get( ii ) ;
-                
-            t.index += increment ;
-                
-            if ( t.valueIndex == Tuple.UNDEFINED )
-            {
-                t.valueIndex = 0 ;
-            }
-                
-            t.valueIndex += increment ;
-        }
-        
-        if ( tlvStack.isEmpty() )
-        {
-            return ;
-        }
-        
-        do
-        {
-            Tuple top = ( Tuple ) tlvStack.peek() ;
-                
-            if ( top.isIndefinate() )
-            {
-                break ;
-            }
-            if ( top.valueIndex >= top.length )
-            {
-                tlvStack.pop() ;
-                fireDecodeOccurred( top ) ;
-            }
-            else
-            {
-                break ;
-            }
-        } while( tlvStack.size() > 0 ) ;
-    }
-    
-
-    private void handleIndefinateTerminator()
-    {
-        /*
-         * Check for a INDEFINATE length TLV when tlv is primitive with 
-         * zero length and a type class of UNIVERSAL which is reserved
-         * for use by encoding rules.
-         */
-        if ( tlv.id == 0 && tlv.length == 0 && 
-                tlv.typeClass == TypeClass.UNIVERSAL )
-        {
-            String msg = "expected indefinate length TLV on the stack" ;
-
-            if ( tlvStack.isEmpty() )
-            {
-                IllegalStateException e = new IllegalStateException(
-                         msg + " but the stack is empty" ) ;
-                    
-                if ( monitor != null )
-                {
-                    monitor.fatalError( this, e ) ;
-                }
-                    
-                throw e ;
-            }
-
-            Tuple top = ( Tuple ) tlvStack.peek() ;
-            if ( top.length != Tuple.INDEFINATE )
-            {
-                IllegalStateException e = new IllegalStateException(
-                         msg + " but TLV on top has a definate length" ) ;
-                    
-                if ( monitor == null )
-                {
-                    throw e ;
-                }
-                else
-                {
-                    monitor.fatalError( this, e ) ;
-                }
-                    
-                return ;
-            }
-                
-            tlvStack.pop() ;
-            fireDecodeOccurred( top ) ;
-            tlv.clear() ;
-            state = BERDecoderState.TAG ;
-        }
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // Methods used for testing
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * Gets the current state of this BERDecoder.  Used only for debugging and 
-     * testing.
-     * 
-     * @return the state enum
-     */
-    BERDecoderState getState()
-    {
-        return state ;
-    }
-    
-    
-    /**
-     * Gets a cloned copy of the current tuple.  Used only for debugging and 
-     * testing.
-     * 
-     * @return a clone of the current tlv 
-     */
-    Tuple getCurrentTuple()
-    {
-        return ( Tuple ) tlv.clone() ;
-    }
-    
-    
-    /**
-     * Gets a deep copy of the constructed tuple stack.  Used only for debugging
-     * and testing.
-     * 
-     * @return a deep copy of the tuple stack
-     */
-    Stack getTupleStack()
-    {
-        Stack stack = new Stack() ;
-        
-        for ( int ii = 0; ii < tlvStack.size(); ii++ )
-        {
-            Tuple t = ( Tuple ) tlvStack.get( ii ) ;
-            stack.add( t.clone() ) ;
-        }
-        
-        return stack ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.util.Stack ;
+
+import java.nio.ByteBuffer ;
+
+import org.apache.commons.codec.binary.Binary ;
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+import org.apache.commons.codec.stateful.DecoderMonitorAdapter ;
+import org.apache.commons.collections.primitives.ArrayByteList ;
+
+
+/**
+ * Low level BER encoded bytes to Tag Value Length (TLV) tuple decoder.  
+ * This decoder is a low level event based parser which operates in a fashion 
+ * similar to the way SAX works except the elements of concern are the tag, 
+ * length, and value entities.
+ * <p>
+ * Instance variables and a Stack is used to track the state of the decoder 
+ * between decode calls.  The stack maintains the nesting of TLV tuples.  Rather
+ * than creating new TLV tuple instances every time a single tuple is reused for
+ * primitive types and new tlv tuples are cloned for constructed types.  The 
+ * tuple fed to the callback must therefore be used very carefully - its values
+ * must be copied to prevent their loss.
+ * </p>
+ * <p>
+ * Note that all tuples are not created equal.  Constructed TLVs nesting others
+ * will have null value members.  Only TLV tuples of primitive types or the 
+ * leaf TLV tuples of the TLV tuple tree will only contain non null values.  
+ * Therefore the nature of a TLV tuple should be investigated by callbacks 
+ * before attempting to interpret their values.
+ * </p>
+ * 
+ * @see Tuple for TLV tuple value size limitations
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BERDecoder implements StatefulDecoder
+{
+    public static final BERDecoderCallback DEFAULT_CALLBACK = 
+        new BERDecoderCallbackAdapter() ;
+    public static final DecoderMonitor DEFAULT_MONITOR =
+        new DecoderMonitorAdapter() ;
+    
+    /** this decoder's callback */
+    private BERDecoderCallback cb = DEFAULT_CALLBACK ;
+    /** the monitor used by this decoder */
+    private DecoderMonitor monitor = DEFAULT_MONITOR ;
+    
+    /** the single TLV tuple used by this decoder */
+    private final Tuple tlv = new Tuple() ;
+
+    /** a byte buffer used to collect the arriving tag octets */ 
+    private final ArrayByteList tagBuffer = new ArrayByteList( 10 ) ;
+    /** a byte buffer used to collect the arriving legth octets */ 
+    private final ArrayByteList lengthBuffer = new ArrayByteList( 10 ) ;
+
+    /** stack of nested/constructed TLV tuples */
+    private final Stack tlvStack = new Stack() ;
+
+    /** the length of the length data */
+    private int lengthOfLength = 0 ;
+    
+    /** the state of this decoder */
+    private BERDecoderState state = BERDecoderState.getStartState() ;
+    
+    
+    // ------------------------------------------------------------------------
+    // StatefulDecoder Methods
+    // ------------------------------------------------------------------------
+
+    
+    /**
+     * Expects a ByteBuffer containing BER encoded data.
+     * 
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#decode(
+     * java.lang.Object)
+     * @throws ClassCastException if the encoded argument is not a ByteBuffer
+     * @throws IllegalArgumentException if the buffer is null or empty
+     */
+    public void decode( Object encoded ) throws DecoderException
+    {
+        ByteBuffer buf = ( ByteBuffer ) encoded ;
+        
+        /* --------------------------------------------------------------------
+           Handle any unusual input by informing the monitor. 
+           ------------------------------------------------------------------ */
+        
+        if ( buf == null && monitor != null )
+        {
+            String msg = "ignoring null argument to decode()" ;
+            monitor.warning( this, new IllegalArgumentException( msg ) ) ;
+            return ;
+        }
+
+        if ( buf.remaining() == 0 && monitor != null )
+        {
+            String msg = "ignoring empty buffer" ;
+            monitor.warning( this, new IllegalArgumentException( msg ) ) ;
+            return ;
+        }
+        
+        /*
+         * This loop is used instead of costly recursion.  This requires each
+         * of the statewise decode methods to process bytes from the buffer.  If
+         * they can process enough to switch state they do and return 
+         * immediately.  This loop makes sure the next processing state is 
+         * handled if there is more data for that state.
+         */
+        while ( buf.hasRemaining() )
+        {    
+            switch( state.getValue() )
+            {
+                case( BERDecoderState.TAG_VAL ):
+                    decodeTag( buf ) ;
+                    break ;
+                case( BERDecoderState.LENGTH_VAL ):
+                    decodeLength( buf ) ;
+                    break ;
+                case( BERDecoderState.VALUE_VAL ):
+                    decodeValue( buf ) ;
+                    break ;
+            }
+        }
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#setCallback(
+     * org.apache.commons.codec.stateful.DecoderCallback)
+     */
+    public void setCallback( DecoderCallback cb )
+    {
+        this.cb = ( BERDecoderCallback ) cb ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
+     * org.apache.commons.codec.stateful.DecoderMonitor)
+     */
+    public void setDecoderMonitor( DecoderMonitor monitor )
+    {
+        this.monitor = monitor ;
+    }
+    
+    
+    // ------------------------------------------------------------------------
+    // State Based Decode Methods
+    // ------------------------------------------------------------------------
+    
+    
+    /**
+     * Extracts the TLV's tag portion from the buffer.
+     * 
+     * @param buf the byte byffer containing BER encoded data 
+     */
+    private void decodeTag( ByteBuffer buf ) throws DecoderException
+    {
+        for ( tlv.index = 0; buf.hasRemaining(); tlv.index++ )
+        {
+            byte octet = buf.get() ;
+            tagBuffer.add( octet ) ;
+            
+            if ( tagBuffer.size() == 1 )
+            {
+                int id = BERUtils.SHORT_TAG_MASK & octet ;
+                tlv.isPrimitive = BERUtils.isPrimitive( octet ) ; 
+                tlv.typeClass = BERUtils.getTypeClass( octet ) ;
+                
+                // continue to collect more octets if this is the long Tag form
+                if ( id == BERUtils.SHORT_TAG_MASK )
+                {
+                    continue ;
+                }
+                
+                // its the short form so we get the id, switch state & return
+                tlv.id = id ;
+                fireTagDecoded() ;
+                state = state.getNext( tlv.isPrimitive ) ;
+                
+                // we moved by one byte so we update stack indices by 1
+                updateStack( 1 ) ;
+                return ;
+            }
+            
+            /*
+             * From here on we're dealing with the long form of the tag.  The
+             * terminating octet for the long form uses a raised most 
+             * significant bit to flag the end of the train of octets for the 
+             * tag id.
+             */ 
+            if ( ( octet & Binary.BIT_7 ) == 0 )
+            {
+                tlv.id = BERUtils.getTagId( tagBuffer ) ;
+                fireTagDecoded() ;
+                state = state.getNext( tlv.isPrimitive ) ;
+                
+                // we moved by many bytes so we update stack accordingly
+                updateStack( tagBuffer.size() ) ;
+                return ;
+            }
+        }
+    }
+    
+    
+    /**
+     * Extracts the length portion from the buffer.
+     * 
+     * @param buf the byte byffer containing BER encoded data 
+     */
+    private void decodeLength( ByteBuffer buf ) throws DecoderException
+    {
+        while ( buf.hasRemaining() )
+        {
+            tlv.index++ ;
+            byte octet = buf.get() ;
+            lengthBuffer.add( octet ) ;
+            
+            if ( lengthBuffer.size() == 1 )
+            {
+                lengthOfLength = octet & BERUtils.LONG_TAG_MASK ;
+                
+                // handle the short form of the length here
+                if ( ( octet & Binary.BIT_7 ) == 0 ) 
+                {
+                    lengthOfLength = 0 ;
+                    tlv.length = octet ;
+                    tlv.valueIndex = Tuple.UNDEFINED ;
+
+                    if ( tlv.isPrimitive )
+                    {
+                        tlv.value = new byte[tlv.length] ;
+                        fireLengthDecoded() ;
+                        state = BERDecoderState.VALUE ;
+                        // we moved by one byte so we update stack indices by 1
+                        updateStack( 1 ) ;
+                    }
+                    else 
+                    {
+                        // We moved by one byte so we update stack indices by 1
+                        // need to do this here so we do not double update the
+                        // current tuple after pushing it onto the stack.
+                        updateStack( 1 ) ;
+
+                        tlvStack.push( tlv.clone() ) ;
+                        fireLengthDecoded() ;
+                        tlv.clear() ;
+                        state = BERDecoderState.TAG ;
+                    }
+
+                    handleIndefinateTerminator() ;
+                    return ;
+                }
+                // the indefinate form of the length
+                else if ( lengthOfLength == 0 )
+                {
+                    lengthOfLength = Tuple.INDEFINATE ;
+                    tlv.index = Tuple.INDEFINATE ;
+                    tlv.length = Tuple.INDEFINATE ;
+                    tlv.valueIndex = Tuple.UNDEFINED ;
+                    fireLengthDecoded() ;
+                    tlvStack.push( tlv.clone() ) ;
+                    tlv.clear() ;
+                    state = BERDecoderState.TAG ;
+
+                    // we moved by one byte so we update stack indices by 1
+                    updateStack( 1 ) ;
+                    return ;
+                }
+            }
+
+            /*
+             * if we have collected all the octets needed for computing the long
+             * form length so we need to calculate the length push it and return
+             */
+            if ( lengthBuffer.size() == lengthOfLength + 1 )
+            {
+                lengthOfLength = 0 ;
+                tlv.length = BERUtils.getLength( lengthBuffer ) ;
+                tlv.valueIndex = Tuple.UNDEFINED ;
+                
+                if ( tlv.isPrimitive )
+                {
+                    tlv.value = new byte[tlv.length] ;
+                    fireLengthDecoded() ;
+                    state = BERDecoderState.VALUE ;
+                }
+                else
+                {
+                    tlvStack.push( tlv.clone() ) ;
+                    fireLengthDecoded() ;
+                    tlv.clear() ;
+                    state = BERDecoderState.TAG ;
+                }
+                
+                /*
+                 * we moved by one byte + lengthOfLength so we update stack 
+                 * indices by lengthOfLength + 1 
+                 */
+                updateStack( lengthOfLength + 1 ) ;
+                return ;
+            }
+        }
+    }
+
+    
+    /**
+     * Extracts the value portion from the buffer for a primitive type.
+     * 
+     * @param buf the byte byffer containing BER encoded data 
+     */
+    private void decodeValue( ByteBuffer buf ) throws DecoderException
+    {
+        byte[] value = ( byte [] ) tlv.value ;
+        int offset = Tuple.UNDEFINED ;
+        int needToRead = Tuple.UNDEFINED ;
+
+        if ( ! tlv.isPrimitive )
+        {
+            IllegalStateException e = new IllegalStateException( 
+                    "should only be working with primitive tlv" ) ;
+            
+            if ( monitor == null )
+            {    
+                throw e ;
+            }
+            else
+            {
+                monitor.fatalError( this, e ) ;
+            }
+            
+            return ;
+        }
+        
+        if ( ! buf.hasRemaining() )
+        {
+            return ;
+        }
+
+        /*
+         * setup to start decoding the value
+         */
+        if ( tlv.valueIndex == Tuple.UNDEFINED )
+        {
+            needToRead = tlv.length ;
+            offset = 0 ;
+        }
+        else
+        {
+            needToRead = tlv.length - tlv.valueIndex ;
+            offset = tlv.valueIndex ;
+        }
+        
+        /*
+         * check if we have the remainder of the value to complete the 
+         * TLV within the current buffer - if so we read all of it
+         */
+        if ( buf.remaining() >= needToRead )
+        {
+            buf.get( value, offset, needToRead ) ;
+            tlv.valueIndex = tlv.length ;
+            tlv.index += needToRead ;
+            fireDecodeOccurred( tlv ) ;
+            updateStack( needToRead ) ;
+            tlv.clear() ;
+            state = BERDecoderState.TAG ;
+        }
+        
+        /*
+         * the buffer does not contain the rest of the value we need in order
+         * to complete the current TLV - the value is fragmented so we read
+         * what we can and update indices by that amount.
+         */
+        else
+        {
+            if ( tlv.valueIndex == Tuple.UNDEFINED )
+            {
+                tlv.valueIndex = 0 ;
+            }
+            
+            int remaining = buf.remaining() ;
+            buf.get( value, offset, remaining ) ;
+            tlv.valueIndex += remaining ;
+            updateStack( remaining ) ;
+        }
+    }
+    
+    
+    // ------------------------------------------------------------------------
+    // private utility methods
+    // ------------------------------------------------------------------------
+    
+    
+    /**
+     * Fires a tag decoded event by making the appropriate calls to the 
+     * callback and the monitor.   If the monitor is a BERDecoderMonitor with
+     * extended reporting, then those methods are invoked.
+     * 
+     * Also as a side-effect this method clears the tag buffer once it has 
+     * finished notifying the monitor and calling the callback. 
+     */
+    private void fireTagDecoded()
+    {
+        if ( cb != null )
+        {
+            cb.tagDecoded( tlv ) ;
+        }
+        
+        if ( monitor != null && monitor instanceof BERDecoderMonitor )
+        {
+            BERDecoderMonitor berMonitor = ( BERDecoderMonitor ) monitor ;
+            berMonitor.tagDecoded( tlv, tagBuffer.toArray() ) ;
+        }
+        
+        tagBuffer.clear() ;
+    }
+    
+    
+    /**
+     * Fires a length decoded event by making the appropriate calls to the 
+     * callback and the monitor.   If the monitor is a BERDecoderMonitor with
+     * extended reporting, then those methods are invoked.
+     * 
+     * Also as a side-effect this method clears the length buffer once it has 
+     * finished notifying the monitor and calling the callback. 
+     */
+    private void fireLengthDecoded()
+    {
+        if ( cb != null )
+        {
+            cb.lengthDecoded( tlv ) ;
+        }
+        
+        if ( monitor != null && monitor instanceof BERDecoderMonitor )
+        {
+            BERDecoderMonitor berMonitor = ( BERDecoderMonitor ) monitor ;
+            berMonitor.lengthDecoded( tlv, lengthBuffer.toArray() ) ;
+        }
+        
+        lengthBuffer.clear() ;
+    }
+    
+    
+    /**
+     * Fires a complete TLV decoded event by making the appropriate calls to 
+     * the callback and the monitor.
+     */
+    private void fireDecodeOccurred( Tuple tlv )
+    {
+        if ( cb != null )
+        {
+            cb.decodeOccurred( this, tlv ) ;
+        }
+        
+        if ( monitor != null )
+        {
+            monitor.callbackOccured( this, cb, tlv ) ;
+        }
+    }
+
+    
+    /**
+     * Increments the indices of constructed TLV's within the TLV Stack.
+     * 
+     * @param increment the amount to increment indices by.
+     */
+    private void updateStack( int increment )
+    {
+        for ( int ii = 0; ii < tlvStack.size(); ii++ )
+        {
+            Tuple t = ( Tuple ) tlvStack.get( ii ) ;
+                
+            t.index += increment ;
+                
+            if ( t.valueIndex == Tuple.UNDEFINED )
+            {
+                t.valueIndex = 0 ;
+            }
+                
+            t.valueIndex += increment ;
+        }
+        
+        if ( tlvStack.isEmpty() )
+        {
+            return ;
+        }
+        
+        do
+        {
+            Tuple top = ( Tuple ) tlvStack.peek() ;
+                
+            if ( top.isIndefinate() )
+            {
+                break ;
+            }
+            if ( top.valueIndex >= top.length )
+            {
+                tlvStack.pop() ;
+                fireDecodeOccurred( top ) ;
+            }
+            else
+            {
+                break ;
+            }
+        } while( tlvStack.size() > 0 ) ;
+    }
+    
+
+    private void handleIndefinateTerminator()
+    {
+        /*
+         * Check for a INDEFINATE length TLV when tlv is primitive with 
+         * zero length and a type class of UNIVERSAL which is reserved
+         * for use by encoding rules.
+         */
+        if ( tlv.id == 0 && tlv.length == 0 && 
+                tlv.typeClass == TypeClass.UNIVERSAL )
+        {
+            String msg = "expected indefinate length TLV on the stack" ;
+
+            if ( tlvStack.isEmpty() )
+            {
+                IllegalStateException e = new IllegalStateException(
+                         msg + " but the stack is empty" ) ;
+                    
+                if ( monitor != null )
+                {
+                    monitor.fatalError( this, e ) ;
+                }
+                    
+                throw e ;
+            }
+
+            Tuple top = ( Tuple ) tlvStack.peek() ;
+            if ( top.length != Tuple.INDEFINATE )
+            {
+                IllegalStateException e = new IllegalStateException(
+                         msg + " but TLV on top has a definate length" ) ;
+                    
+                if ( monitor == null )
+                {
+                    throw e ;
+                }
+                else
+                {
+                    monitor.fatalError( this, e ) ;
+                }
+                    
+                return ;
+            }
+                
+            tlvStack.pop() ;
+            fireDecodeOccurred( top ) ;
+            tlv.clear() ;
+            state = BERDecoderState.TAG ;
+        }
+    }
+    
+    
+    // ------------------------------------------------------------------------
+    // Methods used for testing
+    // ------------------------------------------------------------------------
+    
+    
+    /**
+     * Gets the current state of this BERDecoder.  Used only for debugging and 
+     * testing.
+     * 
+     * @return the state enum
+     */
+    BERDecoderState getState()
+    {
+        return state ;
+    }
+    
+    
+    /**
+     * Gets a cloned copy of the current tuple.  Used only for debugging and 
+     * testing.
+     * 
+     * @return a clone of the current tlv 
+     */
+    Tuple getCurrentTuple()
+    {
+        return ( Tuple ) tlv.clone() ;
+    }
+    
+    
+    /**
+     * Gets a deep copy of the constructed tuple stack.  Used only for debugging
+     * and testing.
+     * 
+     * @return a deep copy of the tuple stack
+     */
+    Stack getTupleStack()
+    {
+        Stack stack = new Stack() ;
+        
+        for ( int ii = 0; ii < tlvStack.size(); ii++ )
+        {
+            Tuple t = ( Tuple ) tlvStack.get( ii ) ;
+            stack.add( t.clone() ) ;
+        }
+        
+        return stack ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderCallback.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderCallback.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderCallback.java	Sun Mar 14 14:02:18 2004
@@ -1,58 +1,58 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import org.apache.commons.codec.stateful.DecoderCallback ;
-
-
-/**
- * A specialized decoder callback that handles specific BER events.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public interface BERDecoderCallback extends DecoderCallback
-{
-    /**
-     * A tag was decoded.  The following tag properties of the TLV tuple are 
-     * valid at this point:
-     * <ul>
-     * <li>id</li>
-     * <li>isPrimitive</li>
-     * <li>typeClass</li>
-     * </ul>
-     * 
-     * @param tlv the TLV tuple
-     */
-    void tagDecoded( Tuple tlv ) ;
-    
-    /**
-     * A tag was decoded.  The following tag properties of the TLV tuple are 
-     * valid at this point:
-     * <ul>
-     * <li>id</li>
-     * <li>isPrimitive</li>
-     * <li>typeClass</li>
-     * <li>length</li>
-     * </ul>
-     * 
-     * @param tlv the TLV tuple
-     */
-    void lengthDecoded( Tuple tlv ) ;
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.codec.stateful.DecoderCallback ;
+
+
+/**
+ * A specialized decoder callback that handles specific BER events.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface BERDecoderCallback extends DecoderCallback
+{
+    /**
+     * A tag was decoded.  The following tag properties of the TLV tuple are 
+     * valid at this point:
+     * <ul>
+     * <li>id</li>
+     * <li>isPrimitive</li>
+     * <li>typeClass</li>
+     * </ul>
+     * 
+     * @param tlv the TLV tuple
+     */
+    void tagDecoded( Tuple tlv ) ;
+    
+    /**
+     * A tag was decoded.  The following tag properties of the TLV tuple are 
+     * valid at this point:
+     * <ul>
+     * <li>id</li>
+     * <li>isPrimitive</li>
+     * <li>typeClass</li>
+     * <li>length</li>
+     * </ul>
+     * 
+     * @param tlv the TLV tuple
+     */
+    void lengthDecoded( Tuple tlv ) ;
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderCallbackAdapter.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderCallbackAdapter.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderCallbackAdapter.java	Sun Mar 14 14:02:18 2004
@@ -1,57 +1,57 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import org.apache.commons.codec.stateful.StatefulDecoder ;
-
-
-/**
- * A do nothing callback adapter.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class BERDecoderCallbackAdapter implements BERDecoderCallback
-{
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.BERDecoderCallback#tagDecoded(
-     * org.apache.snickers.ber.Tuple)
-     */
-    public void tagDecoded( Tuple tlv )
-    {
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.BERDecoderCallback#lengthDecoded(
-     * org.apache.snickers.ber.Tuple)
-     */
-    public void lengthDecoded( Tuple tlv )
-    {
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
-     */
-    public void decodeOccurred( StatefulDecoder decoder, Object decoded )
-    {
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+
+
+/**
+ * A do nothing callback adapter.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BERDecoderCallbackAdapter implements BERDecoderCallback
+{
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.BERDecoderCallback#tagDecoded(
+     * org.apache.snickers.ber.Tuple)
+     */
+    public void tagDecoded( Tuple tlv )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.BERDecoderCallback#lengthDecoded(
+     * org.apache.snickers.ber.Tuple)
+     */
+    public void lengthDecoded( Tuple tlv )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
+     */
+    public void decodeOccurred( StatefulDecoder decoder, Object decoded )
+    {
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderMonitor.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderMonitor.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERDecoderMonitor.java	Sun Mar 14 14:02:18 2004
@@ -1,35 +1,35 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import org.apache.commons.codec.stateful.DecoderMonitor ;
-
-
-/**
- * A monitor designed for extended BER decoder functionality with greater 
- * detail to specific BER decoder events.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public interface BERDecoderMonitor extends DecoderMonitor
-{
-    void tagDecoded( Tuple tlv, byte[] tagData ) ;
-    void lengthDecoded( Tuple tlv, byte[] lengthData ) ;
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+
+
+/**
+ * A monitor designed for extended BER decoder functionality with greater 
+ * detail to specific BER decoder events.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface BERDecoderMonitor extends DecoderMonitor
+{
+    void tagDecoded( Tuple tlv, byte[] tagData ) ;
+    void lengthDecoded( Tuple tlv, byte[] lengthData ) ;
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERUtils.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERUtils.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/BERUtils.java	Sun Mar 14 14:02:18 2004
@@ -1,242 +1,242 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import org.apache.commons.codec.binary.Binary ;
-import org.apache.commons.codec.DecoderException ;
-import org.apache.commons.collections.primitives.ArrayByteList ;
-
-
-/**
- * Basic Encoding Rule (BER) utility functions.
- *
- * @author <a href="mailto:akarasulu@apache.org">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Rev$
- */
-public final class BERUtils
-{
-    /** mask for the tag value of a short tag value format in a single octet */
-    public static final int SHORT_TAG_MASK = Binary.BIT_0 | Binary.BIT_1 | 
-        Binary.BIT_2 | Binary.BIT_3 | Binary.BIT_4 ;
-    /** mask for the tag value of long tag value format in more than 1 octet */
-    public static final int LONG_TAG_MASK = Binary.BIT_0 | Binary.BIT_1 |
-        Binary.BIT_2 | Binary.BIT_3 | Binary.BIT_4 | Binary.BIT_5 | 
-        Binary.BIT_6 ;
-    
-    
-    /**
-     * Gets the ASN.1 type's class using a TLV tag.
-     * 
-     * @param octet the first octet of the TLV
-     * @return the TypeClass enumeration for the ASN.1 type's class
-     */
-    public final static TypeClass getTypeClass( byte octet )
-    {
-        return TypeClass.getTypeClass( octet ) ;
-    }
-
-
-    /**
-     * Checks to see if the TLV is constructed.
-     * 
-     * @param octet the first octet of the TLV
-     * @return true if this TLV contains more TLVs, false if it's a simple type
-     */
-    public final static boolean isConstructed( byte octet )
-    {
-        return ( octet & Binary.BIT_5 ) == Binary.BIT_5 ;
-    }
-    
-    
-    /**
-     * Checks to see if the TLV is constructed.
-     * 
-     * @param octet the first octet of the TLV
-     * @return true if this TLV contains more TLVs, false if it's a simple type
-     */
-    public final static boolean isConstructed( int octet )
-    {
-        return ( octet & Binary.BIT_5 ) == Binary.BIT_5 ;
-    }
-
-
-    /**
-     * Checks to see if the TLV is a primitive.
-     * 
-     * @param octet the first octet of the TLV
-     * @return true if this TLV is a simple type, false if it contains TLVs
-     */
-    public final static boolean isPrimitive( byte octet )
-    {
-        return ( octet & Binary.BIT_5 ) == 0 ;
-    }
-    
-    
-    /**
-     * Checks to see if the TLV is a primitive.
-     * 
-     * @param octet the first octet of the TLV
-     * @return true if this TLV is a simple type, false if it contains TLVs
-     */
-    public final static boolean isPrimitive( int octet )
-    {
-        return ( octet & Binary.BIT_5 ) == 0 ;
-    }
-
-    
-    /**
-     * Gets the tag id of a TLV from the tag octets.
-     * 
-     * @param octets the set of octets needed to determine the tag value 
-     *      (a.k.a identifier octets)
-     * @return the tag id
-     * @throws DecoderException if the id cannot be determined due to
-     *      type limitations of this method's return type. 
-     */
-    public final static int getTagId( byte[] octets )
-        throws DecoderException
-    {
-        if ( octets.length > 6 )
-        {
-            /*
-             * If this exception is ever thrown which is highly unlikely, then
-             * we need to switch to another data type to return because after
-             * 5 bytes the int can no longer hold the number.
-             */
-            throw new DecoderException( "Tag number is too large." ) ;
-        }
-        
-        int id = octets[0] & SHORT_TAG_MASK ;
-        
-        // if bits are not all 1's then return the value which is less than 31
-        if ( id != SHORT_TAG_MASK && octets.length == 1 )
-        {
-            return id ;
-        }
-        
-        // clear the id now
-        id = 0 ;
-
-        // calculate tag value w/ long tag format
-        for( int ii = 1 ; ii < octets.length; ii++ )
-        {    
-            int shift = ( ii - 1 ) * 7 ;
-            if ( shift > 0 )
-            {    
-                id |= ( octets[ii] & LONG_TAG_MASK ) << shift ;
-            }
-            else
-            {
-                id |= ( octets[ii] & LONG_TAG_MASK ) ;
-            }
-        }
-        
-        return id ;
-    }
-
-
-    /**
-     * Gets the tag id of a TLV from the tag octets.
-     * 
-     * @param octets the set of octets needed to determine the tag value 
-     *      (a.k.a identifier octets)
-     * @return the tag id
-     * @throws DecoderException if the id cannot be determined due to
-     *      type limitations of this method's return type. 
-     */
-    public final static int getTagId( ArrayByteList octets )
-        throws DecoderException
-    {
-        if ( octets.size() > 6 )
-        {
-            /*
-             * If this exception is ever thrown which is highly unlikely, then
-             * we need to switch to another data type to return because after
-             * 5 bytes the int can no longer hold the number.
-             */
-            throw new DecoderException( "Tag number is too large." ) ;
-        }
-        
-        int id = octets.get( 0 ) & SHORT_TAG_MASK ;
-        
-        // if bits are not all 1's then return the value which is less than 31
-        if ( id != SHORT_TAG_MASK && octets.size() == 1 )
-        {
-            return id ;
-        }
-        
-        // clear the id now
-        id = 0 ;
-
-        // calculate tag value w/ long tag format
-        for( int ii = 1 ; ii < octets.size(); ii++ )
-        {    
-            int shift = ( ii - 1 ) * 7 ;
-            if ( shift > 0 )
-            {    
-                id |= ( octets.get( ii ) & LONG_TAG_MASK ) << shift ;
-            }
-            else
-            {
-                id |= ( octets.get( ii ) & LONG_TAG_MASK ) ;
-            }
-        }
-        
-        return id ;
-    }
-
-    
-    /**
-     * Decodes the length of a value for a tlv using the Length field bytes.
-     * 
-     * @param octets the length field bytes in the TLV
-     * @return the length of the TLV
-     * @throws DecoderException if the precision cannot hold the number
-     */
-    public static int getLength( ArrayByteList octets ) throws DecoderException
-    {
-        if ( octets.size() >= 6 )
-        {
-            /*
-             * If this exception is ever thrown which is highly unlikely, then
-             * we need to switch to another data type to return because after
-             * 5 bytes the int can no longer hold the number.
-             */
-            throw new DecoderException( "Length number is too large." ) ;
-        }
-        
-        // if we are using the short form then just return the first octet
-        if ( ( octets.get( 0 ) & Binary.BIT_7 ) == 0 )
-        {
-            return octets.get( 0 ) ;
-        }
-        
-        // clear the id now
-        int length = 0 ;
-
-        // calculate tag value w/ long tag format
-        for( int ii = 1 ; ii < octets.size(); ii++ )
-        {    
-            int shift = ( ii - 1 ) * 8 ;
-            length |=  ( 0x00ff & ( int ) octets.get( ii ) ) << shift ;
-        }
-        
-        return length ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.codec.binary.Binary ;
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.collections.primitives.ArrayByteList ;
+
+
+/**
+ * Basic Encoding Rule (BER) utility functions.
+ *
+ * @author <a href="mailto:akarasulu@apache.org">Alex Karasulu</a>
+ * @author $Author: akarasulu $
+ * @version $Rev$
+ */
+public final class BERUtils
+{
+    /** mask for the tag value of a short tag value format in a single octet */
+    public static final int SHORT_TAG_MASK = Binary.BIT_0 | Binary.BIT_1 | 
+        Binary.BIT_2 | Binary.BIT_3 | Binary.BIT_4 ;
+    /** mask for the tag value of long tag value format in more than 1 octet */
+    public static final int LONG_TAG_MASK = Binary.BIT_0 | Binary.BIT_1 |
+        Binary.BIT_2 | Binary.BIT_3 | Binary.BIT_4 | Binary.BIT_5 | 
+        Binary.BIT_6 ;
+    
+    
+    /**
+     * Gets the ASN.1 type's class using a TLV tag.
+     * 
+     * @param octet the first octet of the TLV
+     * @return the TypeClass enumeration for the ASN.1 type's class
+     */
+    public final static TypeClass getTypeClass( byte octet )
+    {
+        return TypeClass.getTypeClass( octet ) ;
+    }
+
+
+    /**
+     * Checks to see if the TLV is constructed.
+     * 
+     * @param octet the first octet of the TLV
+     * @return true if this TLV contains more TLVs, false if it's a simple type
+     */
+    public final static boolean isConstructed( byte octet )
+    {
+        return ( octet & Binary.BIT_5 ) == Binary.BIT_5 ;
+    }
+    
+    
+    /**
+     * Checks to see if the TLV is constructed.
+     * 
+     * @param octet the first octet of the TLV
+     * @return true if this TLV contains more TLVs, false if it's a simple type
+     */
+    public final static boolean isConstructed( int octet )
+    {
+        return ( octet & Binary.BIT_5 ) == Binary.BIT_5 ;
+    }
+
+
+    /**
+     * Checks to see if the TLV is a primitive.
+     * 
+     * @param octet the first octet of the TLV
+     * @return true if this TLV is a simple type, false if it contains TLVs
+     */
+    public final static boolean isPrimitive( byte octet )
+    {
+        return ( octet & Binary.BIT_5 ) == 0 ;
+    }
+    
+    
+    /**
+     * Checks to see if the TLV is a primitive.
+     * 
+     * @param octet the first octet of the TLV
+     * @return true if this TLV is a simple type, false if it contains TLVs
+     */
+    public final static boolean isPrimitive( int octet )
+    {
+        return ( octet & Binary.BIT_5 ) == 0 ;
+    }
+
+    
+    /**
+     * Gets the tag id of a TLV from the tag octets.
+     * 
+     * @param octets the set of octets needed to determine the tag value 
+     *      (a.k.a identifier octets)
+     * @return the tag id
+     * @throws DecoderException if the id cannot be determined due to
+     *      type limitations of this method's return type. 
+     */
+    public final static int getTagId( byte[] octets )
+        throws DecoderException
+    {
+        if ( octets.length > 6 )
+        {
+            /*
+             * If this exception is ever thrown which is highly unlikely, then
+             * we need to switch to another data type to return because after
+             * 5 bytes the int can no longer hold the number.
+             */
+            throw new DecoderException( "Tag number is too large." ) ;
+        }
+        
+        int id = octets[0] & SHORT_TAG_MASK ;
+        
+        // if bits are not all 1's then return the value which is less than 31
+        if ( id != SHORT_TAG_MASK && octets.length == 1 )
+        {
+            return id ;
+        }
+        
+        // clear the id now
+        id = 0 ;
+
+        // calculate tag value w/ long tag format
+        for( int ii = 1 ; ii < octets.length; ii++ )
+        {    
+            int shift = ( ii - 1 ) * 7 ;
+            if ( shift > 0 )
+            {    
+                id |= ( octets[ii] & LONG_TAG_MASK ) << shift ;
+            }
+            else
+            {
+                id |= ( octets[ii] & LONG_TAG_MASK ) ;
+            }
+        }
+        
+        return id ;
+    }
+
+
+    /**
+     * Gets the tag id of a TLV from the tag octets.
+     * 
+     * @param octets the set of octets needed to determine the tag value 
+     *      (a.k.a identifier octets)
+     * @return the tag id
+     * @throws DecoderException if the id cannot be determined due to
+     *      type limitations of this method's return type. 
+     */
+    public final static int getTagId( ArrayByteList octets )
+        throws DecoderException
+    {
+        if ( octets.size() > 6 )
+        {
+            /*
+             * If this exception is ever thrown which is highly unlikely, then
+             * we need to switch to another data type to return because after
+             * 5 bytes the int can no longer hold the number.
+             */
+            throw new DecoderException( "Tag number is too large." ) ;
+        }
+        
+        int id = octets.get( 0 ) & SHORT_TAG_MASK ;
+        
+        // if bits are not all 1's then return the value which is less than 31
+        if ( id != SHORT_TAG_MASK && octets.size() == 1 )
+        {
+            return id ;
+        }
+        
+        // clear the id now
+        id = 0 ;
+
+        // calculate tag value w/ long tag format
+        for( int ii = 1 ; ii < octets.size(); ii++ )
+        {    
+            int shift = ( ii - 1 ) * 7 ;
+            if ( shift > 0 )
+            {    
+                id |= ( octets.get( ii ) & LONG_TAG_MASK ) << shift ;
+            }
+            else
+            {
+                id |= ( octets.get( ii ) & LONG_TAG_MASK ) ;
+            }
+        }
+        
+        return id ;
+    }
+
+    
+    /**
+     * Decodes the length of a value for a tlv using the Length field bytes.
+     * 
+     * @param octets the length field bytes in the TLV
+     * @return the length of the TLV
+     * @throws DecoderException if the precision cannot hold the number
+     */
+    public static int getLength( ArrayByteList octets ) throws DecoderException
+    {
+        if ( octets.size() >= 6 )
+        {
+            /*
+             * If this exception is ever thrown which is highly unlikely, then
+             * we need to switch to another data type to return because after
+             * 5 bytes the int can no longer hold the number.
+             */
+            throw new DecoderException( "Length number is too large." ) ;
+        }
+        
+        // if we are using the short form then just return the first octet
+        if ( ( octets.get( 0 ) & Binary.BIT_7 ) == 0 )
+        {
+            return octets.get( 0 ) ;
+        }
+        
+        // clear the id now
+        int length = 0 ;
+
+        // calculate tag value w/ long tag format
+        for( int ii = 1 ; ii < octets.size(); ii++ )
+        {    
+            int shift = ( ii - 1 ) * 8 ;
+            length |=  ( 0x00ff & ( int ) octets.get( ii ) ) << shift ;
+        }
+        
+        return length ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/DefaultMutableTupleNode.java	Sun Mar 14 14:02:18 2004
@@ -1,442 +1,442 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.nio.ByteBuffer ;
-
-import java.util.Iterator ;
-import java.util.ArrayList ;
-import java.util.Enumeration ;
-import java.util.Collections ;
-
-import javax.swing.tree.TreeNode ;
-import javax.swing.tree.MutableTreeNode ;
-
-import org.apache.commons.lang.StringUtils ;
-
-
-/**
- * The default mutable tuple node.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class DefaultMutableTupleNode 
-    implements MutableTupleNode, MutableTreeNode
-{
-    private Tuple tuple ;
-    private ArrayList children = new ArrayList() ;
-    private DefaultMutableTupleNode parent ;
-    
-    
-    /**
-     * Creates a node without a parent and without a tuple.
-     */
-    public DefaultMutableTupleNode()
-    {
-    }
-    
-
-    /**
-     * Creates a node without a parent.
-     * 
-     * @param tuple the tuple to set for this node
-     */
-    public DefaultMutableTupleNode( Tuple tuple )
-    {
-        this.tuple = tuple ;
-    }
-    
-
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.MutableTupleNode#insert(
-     * org.apache.snickers.ber.MutableTupleNode, int)
-     */
-    public void insert( MutableTupleNode child, int index )
-    {
-        children.add( index, child ) ; 
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.MutableTupleNode#remove(int)
-     */
-    public void remove( int index )
-    {
-        children.remove( index ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.MutableTupleNode#remove(
-     * org.apache.snickers.ber.MutableTupleNode)
-     */
-    public void remove( MutableTupleNode node )
-    {
-        children.remove( node ) ;
-    }
-    
-
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.MutableTupleNode#removeFromParent()
-     */
-    public void removeFromParent()
-    {
-        parent.remove( ( MutableTupleNode ) this ) ;
-        parent = null ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.MutableTupleNode#setParent(
-     * org.apache.snickers.ber.MutableTupleNode)
-     */
-    public void setParent( MutableTupleNode newParent )
-    {
-        if ( parent != null )
-        {    
-            parent.remove( ( MutableTupleNode ) this ) ;
-        }
-        
-        parent = ( DefaultMutableTupleNode ) newParent ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.MutableTupleNode#setTuple(
-     * org.apache.snickers.ber.Tuple)
-     */
-    public void setTuple( Tuple t )
-    {
-        tuple = t ;
-    }
-    
-
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.TupleNode#getParent()
-     */
-    public TupleNode getParentTupleNode()
-    {
-        return parent ;
-    }
-    
-
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.TupleNode#children()
-     */
-    public Iterator getChildren()
-    {
-        return Collections.unmodifiableList( children ).iterator() ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.TupleNode#getChildAt()
-     */
-    public TupleNode getChildTupleNodeAt( int index )
-    {
-        return ( TupleNode ) children.get( index ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.TupleNode#getIndex(
-     * org.apache.snickers.ber.TupleNode)
-     */
-    public int getIndex( TupleNode node )
-    {
-        return children.indexOf( node ) ;
-    }
-    
-
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.TupleNode#getChildCount()
-     */
-    public int getChildCount()
-    {
-        return children.size() ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.TupleNode#size()
-     */
-    public int size()
-    {
-        if ( tuple.isPrimitive() )
-        {
-            return tuple.size() ;
-        }
-        else
-        {
-            int size = tuple.size() ;
-            
-            if ( tuple.isIndefinate() )
-            {    
-                TupleNode child = null ;
-                for ( int ii = 0; ii < children.size(); ii++ )
-                {
-                    child = ( TupleNode ) children.get( ii ) ;
-                    size += child.size() ;
-                }
-                
-                if ( child != null )
-                {
-                    if ( ! child.getTuple().isIndefinateTerminator() )
-                    {
-                        size += 2 ;
-                    }
-                }
-                else
-                {
-                    size += 2 ;
-                }
-            }
-
-            return size ;
-        }
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.TupleNode#getTuple()
-     */
-    public Tuple getTuple()
-    {
-        return tuple ;
-    }
-    
-    
-    /**
-     * Depth first generation of this tlv tuple node's encoded image.
-     * 
-     * @see org.apache.snickers.ber.TupleNode#encode()
-     */
-    public void encode( ByteBuffer dest )
-    {
-        dest.put( tuple.encode() ) ;
-        
-        if ( tuple.isPrimitive() )
-        {
-            return ;
-        }
-        
-        TupleNode child = null ;
-        for ( int ii = 0; ii < children.size(); ii++ )
-        {
-            child = ( TupleNode ) children.get( ii ) ;
-            child.encode( dest ) ;
-        }
-        
-        if ( child != null )
-        {
-            Tuple childTuple = child.getTuple() ;
-            if ( childTuple.isIndefinateTerminator() )
-            {
-                return ;
-            }
-        }
-        
-        if ( tuple.isIndefinate() ) 
-        {
-            // lay down the termination
-            dest.put( ( byte ) 0 ) ;
-            dest.put( ( byte ) 0 ) ;
-        }
-    }
-    
-    
-    /*
-     * Prinsts some informative information regarding the tlv node. 
-     * 
-     * (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
-    public String toString()
-    {
-        StringBuffer buf = new StringBuffer() ;
-        buf.append( tuple.getId() ) ;
-        buf.append( ' ' ).append( tuple.typeClass ) ;
-        buf.append( '[' ).append( tuple.length ).append( ']' ) ;
-        buf.append( '[' ).append( new String( (byte[]) tuple.getValue() ) ) ;
-        buf.append( ']' ) ;
-        
-        return buf.toString() ;
-    }
-    
-
-    /**
-     * Generates a depth first traversal of this node.
-     * 
-     * @return a depth first traversal print out for this node
-     */
-    public String toDepthFirstString()
-    {
-        StringBuffer buf = new StringBuffer() ;
-        printDepthFirst( buf, 0 ) ;
-        return buf.toString() ;
-    }
-    
-    
-    /**
-     * Start analyzing the tree rooted at this node.
-     */
-    public void analyze()
-    {
-        TupleTreeAnalyzer analyzer = new TupleTreeAnalyzer( this ) ;
-        analyzer.startup() ;
-    }
-    
-    
-    /**
-     * Generates a depth first traversal of this node.
-     * 
-     * @param buf the buffer to capture the traversal into
-     * @param level the level down into the tree
-     */
-    public void printDepthFirst( StringBuffer buf, int level )
-    {
-        DefaultMutableTupleNode child = null ;
-        String levelTab = StringUtils.repeat( "\t", level ) ;
-        
-        if ( level != 0 )
-        {
-            buf.append( "\n" ) ;
-        }
-        
-        buf.append( levelTab ).append( tuple.getId() ) ;
-        buf.append( ' ' ).append( tuple.typeClass ) ;
-        buf.append( '[' ).append( tuple.length ).append( ']' ) ;
-        buf.append( '[' ).append( new String( (byte[]) tuple.getValue() ) ) ;
-        buf.append( ']' ) ;
-        for ( int ii = 0; ii < children.size(); ii++ )
-        {
-            child = ( DefaultMutableTupleNode ) children.get( ii ) ;
-            child.printDepthFirst( buf, level + 1 ) ;
-        }
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // MutableTreeNode implementations
-    // ------------------------------------------------------------------------
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#children()
-     */
-    public Enumeration children()
-    {
-        return Collections.enumeration( children ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#getAllowsChildren()
-     */
-    public boolean getAllowsChildren()
-    {
-        return ! tuple.isPrimitive() ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#getChildAt(int)
-     */
-    public TreeNode getChildAt( int childIndex )
-    {
-        return ( TreeNode ) getChildTupleNodeAt( childIndex ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
-     */
-    public int getIndex( TreeNode node )
-    {
-        return getIndex( ( TupleNode ) node ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#getParent()
-     */
-    public TreeNode getParent()
-    {
-        return parent ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.MutableTreeNode#insert(
-     * javax.swing.tree.MutableTreeNode, int)
-     */
-    public void insert( MutableTreeNode child, int index )
-    {
-        insert( ( MutableTupleNode ) child, index ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.TreeNode#isLeaf()
-     */
-    public boolean isLeaf()
-    {
-        if ( tuple != null && tuple.isPrimitive() )
-        {    
-            return true ;
-        }
-        
-        if ( children.isEmpty() )
-        {
-            return true ;
-        }
-
-        return false ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.MutableTreeNode#remove(
-     * javax.swing.tree.MutableTreeNode)
-     */
-    public void remove( MutableTreeNode node )
-    {
-        remove( ( MutableTupleNode ) node ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.MutableTreeNode#setParent(
-     * javax.swing.tree.MutableTreeNode)
-     */
-    public void setParent( MutableTreeNode newParent )
-    {
-        parent = ( DefaultMutableTupleNode ) newParent ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see javax.swing.tree.MutableTreeNode#setUserObject(java.lang.Object)
-     */
-    public void setUserObject( Object object )
-    {
-        tuple = ( Tuple ) object ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.nio.ByteBuffer ;
+
+import java.util.Iterator ;
+import java.util.ArrayList ;
+import java.util.Enumeration ;
+import java.util.Collections ;
+
+import javax.swing.tree.TreeNode ;
+import javax.swing.tree.MutableTreeNode ;
+
+import org.apache.commons.lang.StringUtils ;
+
+
+/**
+ * The default mutable tuple node.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DefaultMutableTupleNode 
+    implements MutableTupleNode, MutableTreeNode
+{
+    private Tuple tuple ;
+    private ArrayList children = new ArrayList() ;
+    private DefaultMutableTupleNode parent ;
+    
+    
+    /**
+     * Creates a node without a parent and without a tuple.
+     */
+    public DefaultMutableTupleNode()
+    {
+    }
+    
+
+    /**
+     * Creates a node without a parent.
+     * 
+     * @param tuple the tuple to set for this node
+     */
+    public DefaultMutableTupleNode( Tuple tuple )
+    {
+        this.tuple = tuple ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#insert(
+     * org.apache.snickers.ber.MutableTupleNode, int)
+     */
+    public void insert( MutableTupleNode child, int index )
+    {
+        children.add( index, child ) ; 
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#remove(int)
+     */
+    public void remove( int index )
+    {
+        children.remove( index ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#remove(
+     * org.apache.snickers.ber.MutableTupleNode)
+     */
+    public void remove( MutableTupleNode node )
+    {
+        children.remove( node ) ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#removeFromParent()
+     */
+    public void removeFromParent()
+    {
+        parent.remove( ( MutableTupleNode ) this ) ;
+        parent = null ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#setParent(
+     * org.apache.snickers.ber.MutableTupleNode)
+     */
+    public void setParent( MutableTupleNode newParent )
+    {
+        if ( parent != null )
+        {    
+            parent.remove( ( MutableTupleNode ) this ) ;
+        }
+        
+        parent = ( DefaultMutableTupleNode ) newParent ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.MutableTupleNode#setTuple(
+     * org.apache.snickers.ber.Tuple)
+     */
+    public void setTuple( Tuple t )
+    {
+        tuple = t ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getParent()
+     */
+    public TupleNode getParentTupleNode()
+    {
+        return parent ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#children()
+     */
+    public Iterator getChildren()
+    {
+        return Collections.unmodifiableList( children ).iterator() ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getChildAt()
+     */
+    public TupleNode getChildTupleNodeAt( int index )
+    {
+        return ( TupleNode ) children.get( index ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getIndex(
+     * org.apache.snickers.ber.TupleNode)
+     */
+    public int getIndex( TupleNode node )
+    {
+        return children.indexOf( node ) ;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getChildCount()
+     */
+    public int getChildCount()
+    {
+        return children.size() ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#size()
+     */
+    public int size()
+    {
+        if ( tuple.isPrimitive() )
+        {
+            return tuple.size() ;
+        }
+        else
+        {
+            int size = tuple.size() ;
+            
+            if ( tuple.isIndefinate() )
+            {    
+                TupleNode child = null ;
+                for ( int ii = 0; ii < children.size(); ii++ )
+                {
+                    child = ( TupleNode ) children.get( ii ) ;
+                    size += child.size() ;
+                }
+                
+                if ( child != null )
+                {
+                    if ( ! child.getTuple().isIndefinateTerminator() )
+                    {
+                        size += 2 ;
+                    }
+                }
+                else
+                {
+                    size += 2 ;
+                }
+            }
+
+            return size ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.TupleNode#getTuple()
+     */
+    public Tuple getTuple()
+    {
+        return tuple ;
+    }
+    
+    
+    /**
+     * Depth first generation of this tlv tuple node's encoded image.
+     * 
+     * @see org.apache.snickers.ber.TupleNode#encode()
+     */
+    public void encode( ByteBuffer dest )
+    {
+        dest.put( tuple.encode() ) ;
+        
+        if ( tuple.isPrimitive() )
+        {
+            return ;
+        }
+        
+        TupleNode child = null ;
+        for ( int ii = 0; ii < children.size(); ii++ )
+        {
+            child = ( TupleNode ) children.get( ii ) ;
+            child.encode( dest ) ;
+        }
+        
+        if ( child != null )
+        {
+            Tuple childTuple = child.getTuple() ;
+            if ( childTuple.isIndefinateTerminator() )
+            {
+                return ;
+            }
+        }
+        
+        if ( tuple.isIndefinate() ) 
+        {
+            // lay down the termination
+            dest.put( ( byte ) 0 ) ;
+            dest.put( ( byte ) 0 ) ;
+        }
+    }
+    
+    
+    /*
+     * Prinsts some informative information regarding the tlv node. 
+     * 
+     * (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer() ;
+        buf.append( tuple.getId() ) ;
+        buf.append( ' ' ).append( tuple.typeClass ) ;
+        buf.append( '[' ).append( tuple.length ).append( ']' ) ;
+        buf.append( '[' ).append( new String( (byte[]) tuple.getValue() ) ) ;
+        buf.append( ']' ) ;
+        
+        return buf.toString() ;
+    }
+    
+
+    /**
+     * Generates a depth first traversal of this node.
+     * 
+     * @return a depth first traversal print out for this node
+     */
+    public String toDepthFirstString()
+    {
+        StringBuffer buf = new StringBuffer() ;
+        printDepthFirst( buf, 0 ) ;
+        return buf.toString() ;
+    }
+    
+    
+    /**
+     * Start analyzing the tree rooted at this node.
+     */
+    public void analyze()
+    {
+        TupleTreeAnalyzer analyzer = new TupleTreeAnalyzer( this ) ;
+        analyzer.startup() ;
+    }
+    
+    
+    /**
+     * Generates a depth first traversal of this node.
+     * 
+     * @param buf the buffer to capture the traversal into
+     * @param level the level down into the tree
+     */
+    public void printDepthFirst( StringBuffer buf, int level )
+    {
+        DefaultMutableTupleNode child = null ;
+        String levelTab = StringUtils.repeat( "\t", level ) ;
+        
+        if ( level != 0 )
+        {
+            buf.append( "\n" ) ;
+        }
+        
+        buf.append( levelTab ).append( tuple.getId() ) ;
+        buf.append( ' ' ).append( tuple.typeClass ) ;
+        buf.append( '[' ).append( tuple.length ).append( ']' ) ;
+        buf.append( '[' ).append( new String( (byte[]) tuple.getValue() ) ) ;
+        buf.append( ']' ) ;
+        for ( int ii = 0; ii < children.size(); ii++ )
+        {
+            child = ( DefaultMutableTupleNode ) children.get( ii ) ;
+            child.printDepthFirst( buf, level + 1 ) ;
+        }
+    }
+    
+    
+    // ------------------------------------------------------------------------
+    // MutableTreeNode implementations
+    // ------------------------------------------------------------------------
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.TreeNode#children()
+     */
+    public Enumeration children()
+    {
+        return Collections.enumeration( children ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.TreeNode#getAllowsChildren()
+     */
+    public boolean getAllowsChildren()
+    {
+        return ! tuple.isPrimitive() ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.TreeNode#getChildAt(int)
+     */
+    public TreeNode getChildAt( int childIndex )
+    {
+        return ( TreeNode ) getChildTupleNodeAt( childIndex ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
+     */
+    public int getIndex( TreeNode node )
+    {
+        return getIndex( ( TupleNode ) node ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.TreeNode#getParent()
+     */
+    public TreeNode getParent()
+    {
+        return parent ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.MutableTreeNode#insert(
+     * javax.swing.tree.MutableTreeNode, int)
+     */
+    public void insert( MutableTreeNode child, int index )
+    {
+        insert( ( MutableTupleNode ) child, index ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.TreeNode#isLeaf()
+     */
+    public boolean isLeaf()
+    {
+        if ( tuple != null && tuple.isPrimitive() )
+        {    
+            return true ;
+        }
+        
+        if ( children.isEmpty() )
+        {
+            return true ;
+        }
+
+        return false ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.MutableTreeNode#remove(
+     * javax.swing.tree.MutableTreeNode)
+     */
+    public void remove( MutableTreeNode node )
+    {
+        remove( ( MutableTupleNode ) node ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.MutableTreeNode#setParent(
+     * javax.swing.tree.MutableTreeNode)
+     */
+    public void setParent( MutableTreeNode newParent )
+    {
+        parent = ( DefaultMutableTupleNode ) newParent ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see javax.swing.tree.MutableTreeNode#setUserObject(java.lang.Object)
+     */
+    public void setUserObject( Object object )
+    {
+        tuple = ( Tuple ) object ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/IntStack.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/IntStack.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/IntStack.java	Sun Mar 14 14:02:18 2004
@@ -1,121 +1,121 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.util.EmptyStackException ;
-
-import org.apache.commons.collections.primitives.ArrayIntList ;
-
-
-/**
- * A primitive int based Stack.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class IntStack
-{
-    /** the underlying dynamic primitive backing store */
-    private ArrayIntList list = new ArrayIntList() ;
-    
-
-    /**
-     * Tests if this stack is empty.
-     * 
-     * @return true if and only if this stack contains no ints; false otherwise
-     */
-    public boolean empty()
-    {
-        return list.isEmpty() ;
-    }
-
-    
-    /**
-     * Looks at the int at the top of this stack without removing it from 
-     * the stack.
-     * 
-     * @return int at the top of this stack (last int in ArrayIntList)
-     * @throws EmptyStackException if this stack is empty
-     */
-    public int peek()
-    {
-        if ( list.isEmpty() )
-        {
-            throw new EmptyStackException() ;
-        }
-        
-        return list.get( list.size() - 1 ) ;
-    }
-
-    
-    /**
-     * Removes the int at the top of this stack and returns that object as the 
-     * value of this function.
-     * 
-     * @return int at the top of this stack (last int in ArrayIntList)
-     * @throws EmptyStackException if this stack is empty
-     */
-    public int pop()
-    {
-        if ( list.isEmpty() )
-        {
-            throw new EmptyStackException() ;
-        }
-        
-        return list.removeElementAt( list.size() - 1 ) ;
-    }
-
-    
-    /**
-     * Pushes an int item onto the top of this stack.
-     * 
-     * @param item the int item to push onto this stack
-     * @return the item argument for call chaining
-     */
-    public int push( int item )
-    {
-        list.add( item ) ;
-        return item ;
-    }
-    
-
-    /**
-     * Returns the 1-based position where an int is on this stack. If the int 
-     * occurs as an item in this stack, this method returns the distance from 
-     * the top of the stack of the occurrence nearest the top of the stack; the 
-     * topmost item on the stack is considered to be at distance 1. 
-     * 
-     * @param item the int to search for from the top down
-     * @return the 1-based position from the top of the stack where the int is 
-     *  located; the return value -1 indicates that the int is not on the stack
-     */
-    public int search( int item )
-    {
-        for ( int ii = list.size() - 1; ii >= 0; ii-- )
-        {
-            if ( list.get( ii ) == item )
-            {
-                return list.size() - ii ;
-            }
-        }
-        
-        
-        return -1 ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.util.EmptyStackException ;
+
+import org.apache.commons.collections.primitives.ArrayIntList ;
+
+
+/**
+ * A primitive int based Stack.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class IntStack
+{
+    /** the underlying dynamic primitive backing store */
+    private ArrayIntList list = new ArrayIntList() ;
+    
+
+    /**
+     * Tests if this stack is empty.
+     * 
+     * @return true if and only if this stack contains no ints; false otherwise
+     */
+    public boolean empty()
+    {
+        return list.isEmpty() ;
+    }
+
+    
+    /**
+     * Looks at the int at the top of this stack without removing it from 
+     * the stack.
+     * 
+     * @return int at the top of this stack (last int in ArrayIntList)
+     * @throws EmptyStackException if this stack is empty
+     */
+    public int peek()
+    {
+        if ( list.isEmpty() )
+        {
+            throw new EmptyStackException() ;
+        }
+        
+        return list.get( list.size() - 1 ) ;
+    }
+
+    
+    /**
+     * Removes the int at the top of this stack and returns that object as the 
+     * value of this function.
+     * 
+     * @return int at the top of this stack (last int in ArrayIntList)
+     * @throws EmptyStackException if this stack is empty
+     */
+    public int pop()
+    {
+        if ( list.isEmpty() )
+        {
+            throw new EmptyStackException() ;
+        }
+        
+        return list.removeElementAt( list.size() - 1 ) ;
+    }
+
+    
+    /**
+     * Pushes an int item onto the top of this stack.
+     * 
+     * @param item the int item to push onto this stack
+     * @return the item argument for call chaining
+     */
+    public int push( int item )
+    {
+        list.add( item ) ;
+        return item ;
+    }
+    
+
+    /**
+     * Returns the 1-based position where an int is on this stack. If the int 
+     * occurs as an item in this stack, this method returns the distance from 
+     * the top of the stack of the occurrence nearest the top of the stack; the 
+     * topmost item on the stack is considered to be at distance 1. 
+     * 
+     * @param item the int to search for from the top down
+     * @return the 1-based position from the top of the stack where the int is 
+     *  located; the return value -1 indicates that the int is not on the stack
+     */
+    public int search( int item )
+    {
+        for ( int ii = list.size() - 1; ii >= 0; ii-- )
+        {
+            if ( list.get( ii ) == item )
+            {
+                return list.size() - ii ;
+            }
+        }
+        
+        
+        return -1 ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/MutableTupleNode.java	Sun Mar 14 14:02:18 2004
@@ -1,70 +1,70 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-/**
- * A mutable TupleNode used for building TLV Tuple trees.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public interface MutableTupleNode extends TupleNode
-{
-    /**
-     * Adds child to the receiver at index.
-     * 
-     * @param child
-     * @param index
-     */
-    void insert( MutableTupleNode child, int index ) ; 
-              
-    /**
-     * Removes the child at index from the receiver.
-     * 
-     * @param index
-     */
-    void remove( int index ) ;
-              
-    /**
-     * Removes node from the receiver. 
-     * 
-     * @param node
-     */
-     void remove( MutableTupleNode node ) ; 
-              
-     /**
-      * Removes the receiver from its parent.
-      */
-     void removeFromParent() ; 
-               
-     /**
-      * Sets the parent of the receiver to newParent.
-      * 
-      * @param newParent
-      */
-     void setParent( MutableTupleNode newParent ) ; 
-              
-     /**
-      * Resets the Tuple of the receiver object.
-      * 
-      * @param t
-      */
-     void setTuple( Tuple t ) ;  
-               
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+/**
+ * A mutable TupleNode used for building TLV Tuple trees.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface MutableTupleNode extends TupleNode
+{
+    /**
+     * Adds child to the receiver at index.
+     * 
+     * @param child
+     * @param index
+     */
+    void insert( MutableTupleNode child, int index ) ; 
+              
+    /**
+     * Removes the child at index from the receiver.
+     * 
+     * @param index
+     */
+    void remove( int index ) ;
+              
+    /**
+     * Removes node from the receiver. 
+     * 
+     * @param node
+     */
+     void remove( MutableTupleNode node ) ; 
+              
+     /**
+      * Removes the receiver from its parent.
+      */
+     void removeFromParent() ; 
+               
+     /**
+      * Sets the parent of the receiver to newParent.
+      * 
+      * @param newParent
+      */
+     void setParent( MutableTupleNode newParent ) ; 
+              
+     /**
+      * Resets the Tuple of the receiver object.
+      * 
+      * @param t
+      */
+     void setTuple( Tuple t ) ;  
+               
+}

Added: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TagDecoder.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TagDecoder.java	Sun Mar 14 14:02:18 2004
@@ -0,0 +1,63 @@
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+
+
+/**
+ * A BER Tag decoder.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TagDecoder implements StatefulDecoder
+{
+    
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#decode(
+     * java.lang.Object)
+     */
+    public void decode( Object arg0 ) throws DecoderException
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#setCallback(
+     * org.apache.commons.codec.stateful.DecoderCallback)
+     */
+    public void setCallback( DecoderCallback cb )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
+     * org.apache.commons.codec.stateful.DecoderMonitor)
+     */
+    public void setDecoderMonitor( DecoderMonitor monitor )
+    {
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/Tuple.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/Tuple.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/Tuple.java	Sun Mar 14 14:02:18 2004
@@ -1,694 +1,694 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import org.apache.commons.lang.ArrayUtils ;
-import org.apache.commons.codec.binary.Binary ;
-
-
-/**
- * Simple TLV Tuple.  Because the length fields is a primitive int it's maximum
- * value is 2,147,483,647 a single TLV's tuple cannot have a length over this
- * amount or a value size over 2 GB.  I don't think we'll be hitting this soon
- * especially with the value size protection feature planned for the decoder.
- * 
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class Tuple
-{
-    /** used to mark lengths and indices and indefinate */
-    public static final int INDEFINATE = -2 ;
-    /** used to mark indices as undefined */ 
-    public static final int UNDEFINED = -1 ;
-
-    /** precalculated left shift of 1 by 7 places */
-    static final int BIT_6 = 1 << 7 ;
-    /** precalculated left shift of 1 by 8 places */
-    static final int BIT_7 = 1 << 8 ;
-    /** precalculated left shift of 1 by 14 places */
-    static final int BIT_13 = 1 << 14 ;
-    /** precalculated left shift of 1 by 16 places */
-    static final int BIT_15 = 1 << 16 ;
-    /** precalculated left shift of 1 by 21 places */
-    static final int BIT_20 = 1 << 21 ;
-    /** precalculated left shift of 1 by 24 places */
-    static final int BIT_23 = 1 << 24 ;
-    /** precalculated left shift of 1 by 28 places */
-    static final int BIT_27 = 1 << 28 ;
-    
-    /** the tag id for this TLV tuple */
-    int id = 0 ;
-    /** the flag for whether or not this TLV is constructed or primitive */
-    boolean isPrimitive = true ;
-    /** the type class for this TLV */
-    TypeClass typeClass = TypeClass.APPLICATION ;
-    /** the length for this TLV tuple */
-    int length = 0 ;
-    /** the value for this TLV tuple */
-    Object value = ArrayUtils.EMPTY_BYTE_ARRAY ;
-    
-    /** tlv byte index */
-    int index = Tuple.UNDEFINED ;
-    /** tlv value index for how far into the value we have read */
-    int valueIndex = Tuple.UNDEFINED ;
-    
-    
-    // ------------------------------------------------------------------------
-    // C O N S T R U C T O R S
-    // ------------------------------------------------------------------------
-    
-
-    /**
-     * Empty do nothing tuple.
-     */
-    Tuple() 
-    { 
-    }
-    
-    
-    /**
-     * Creates constructed application type tlv tuples.  Constructed TLV's with
-     * a definate length will use this constructor predominantly.  The TypeClass
-     * defualts to APPLICATION.
-     * 
-     * @param id the tag id of the tlv
-     * @param length the length of the value which is the length of all the 
-     *      nested tuples.
-     */
-    public Tuple( int id, int length )
-    {
-        this( id, length, TypeClass.APPLICATION ) ;
-    }
-    
-    
-    /**
-     * Creates constructed application type tlv tuples.  Constructed TLV's with
-     * a definate length will use this constructor predominantly.
-     * 
-     * @param id the tag id of the tlv
-     * @param length the length of the value which is the length of all the 
-     *      nested tuples.
-     * @param typeClass the type class of this tlv tuple
-     */
-    public Tuple( int id, int length, TypeClass typeClass )
-    {
-        this.id = id ;
-        this.length = length ;
-        value = ArrayUtils.EMPTY_BYTE_ARRAY ;
-        isPrimitive = false ;
-        
-        if ( typeClass != null )
-        {
-            this.typeClass = typeClass ;
-        }
-    }
-    
-    
-    /**
-     * Creates primitive application type tlv tuples.  This will be the primary
-     * constructor used to build primitives.
-     * 
-     * @param id the tag id of the tlv
-     * @param value the value portion for this Tuple
-     */
-    public Tuple( int id, byte[] value )
-    {
-        this( id, TypeClass.APPLICATION, true, value ) ;
-    }
-    
-    
-    /**
-     * Creates an application type tlv with a set value and length.  
-     * 
-     * @param id the tag id of the tlv
-     * @param isPrimitive whether or not the tlv is primitive or constructed
-     * @param value the value portion for this Tuple
-     */
-    public Tuple( int id, boolean isPrimitive, byte[] value )
-    {
-        this( id, TypeClass.APPLICATION, isPrimitive, value ) ;
-    }
-    
-    
-    /**
-     * Creates a tuple where the length is indefinate.  The tuple according to
-     * the BER encoding must be of the constructed type.
-     * 
-     * @param id the tag id of the tlv
-     * @param typeClass the type class for the tlv
-     * @param isPrimitive whether or not the tlv is primitive or constructed
-     * @param value the value portion for this Tuple
-     */
-    public Tuple( int id, TypeClass typeClass )
-    {
-        this.id = id ;
-        this.isPrimitive = false ;
-        value = ArrayUtils.EMPTY_BYTE_ARRAY ;
-        length = Tuple.INDEFINATE ;
-        
-        if ( typeClass != null )
-        {
-            this.typeClass = typeClass ;
-        }
-    }
-    
-    
-    /**
-     * Creates a tuple where every member is specified including the length 
-     * which is taken from the value array.
-     * 
-     * @param id the tag id of the tlv
-     * @param typeClass the type class for the tlv
-     * @param isPrimitive whether or not the tlv is primitive or constructed
-     * @param value the value portion for this Tuple
-     */
-    public Tuple( int id, TypeClass typeClass, boolean isPrimitive, 
-                  byte[] value )
-    {
-        this.id = id ;
-        this.isPrimitive = isPrimitive ;
-        
-        if ( value != null )
-        {
-            this.value = value ;
-            this.length = value.length ;
-        }
-        
-        if ( typeClass != null )
-        {
-            this.typeClass = typeClass ;
-        }
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // Public Accessors
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * Gets the tag id (T-part) for this TLV Tuple.
-     * 
-     * @return the tag id
-     */
-    public int getId()
-    {
-        return id ;
-    }
-    
-    
-    /**
-     * Get's whether or not this tuples's length is indefinate.
-     * 
-     * @return whether or not this tuple's length is indefinate
-     */
-    public boolean isIndefinate()
-    {
-        return length == Tuple.INDEFINATE ;
-    }
-    
-
-    /**
-     * Get's whether or not this tuple terminates an indefinate constructed 
-     * tuple.  This means that length == 0 && isPrimitive = true && id == 0
-     * and the type class is universal.
-     * 
-     * @return whether or not this node's length is indefinate
-     */
-    public boolean isIndefinateTerminator()
-    {
-        return isPrimitive && ( id + length ) == 0 && 
-            typeClass.equals( TypeClass.UNIVERSAL ) ;
-    }
-    
-
-    /**
-     * Gets whether or not this TLV tuple is primitive or constructed.
-     * 
-     * @return true if it is primitive, false if it is constructed
-     */
-    public boolean isPrimitive()
-    {
-        return isPrimitive ;
-    }
-
-    
-    /**
-     * Gets the value length for this TLV Tuple.
-     * 
-     * @return the length in bytes of the value field for this TLV tuple
-     */
-    public int getLength()
-    {
-        return length ;
-    }
-
-    
-    /**
-     * Gets the BER TLV TypeClass for this TLV Tuple.
-     * 
-     * @return the BER TLV TypeClass for this TLV Tuple
-     */
-    public TypeClass getTypeClass()
-    {
-        return typeClass ;
-    }
-
-    
-    /**
-     * Gets the value field (V-part) for this TLV Tuple.
-     * 
-     * @return the value field for this TLV Tuple
-     */
-    public Object getValue()
-    {
-        return value ;
-    }
-    
-    
-    /**
-     * Gets the total size of this TLV tuple in bytes.  This includes the
-     * length of the tag field, the length of the length field and the length
-     * of the value filed.
-     * 
-     * @return the total TLV size in bytes
-     */
-    public int size()
-    {
-        if ( this.length == Tuple.INDEFINATE )
-        {    
-            return getTagLength() + getLengthLength() ;
-        }
-        else
-        {
-            return getTagLength() + getLengthLength() + length ;
-        }
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // Utility methods and java.lang.Object overrides
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * Clears the values of this tuple.
-     */
-    void clear()
-    {
-        this.id = 0 ;
-        this.index = 0 ;
-        this.isPrimitive = true ;
-        this.length = Tuple.UNDEFINED ;
-        this.typeClass = TypeClass.APPLICATION ;
-        this.value = ArrayUtils.EMPTY_BYTE_ARRAY ;
-        this.valueIndex = Tuple.UNDEFINED ;
-    }
-
-    
-    /**
-     * Does not take into account the index or the valueIndex values when
-     * checking for equality.  Technically if both are being constructed by
-     * the decoder then they should only be equal when these values are equal
-     * because the tag, length or value would not be correct.
-     *
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals( Object o )
-    {
-        if ( o == this )
-        {
-            return true ;
-        }
-        
-        if ( o instanceof Tuple )
-        {
-            Tuple t = ( Tuple ) o ;
-            
-            if ( t.id != id )
-            {
-                return false ;
-            }
-            
-            if ( t.isPrimitive != isPrimitive )
-            {
-                return false ;
-            }
-            
-            if ( t.length != length )
-            {
-                return false ;
-            }
-            
-            if ( t.typeClass != typeClass )
-            {
-                return false ;
-            }
-            
-            if ( t.value == null && value == null )
-            {
-                
-            }
-            else if ( ! ArrayUtils.isEquals( t.value, value ) )
-            {
-                return false ;
-            }
-            
-            return true ;
-        }
-        
-        return false ;
-    }
-    
-
-    /*
-     * (non-Javadoc)
-     * @see java.lang.Object#clone()
-     */
-    public Object clone()
-    {
-        Tuple t = new Tuple() ;
-        t.id = id ;
-        t.isPrimitive = isPrimitive ;
-        t.typeClass = typeClass ;
-        t.length = length ;
-        t.value = value ;
-        t.index = index ;
-        t.valueIndex = valueIndex ;
-        
-        return t ;
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // Tuple encoding operations
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * If this is a primitive TLV then it is encoded fully.  If it is not then
-     * only the TL part of the tuple is encoded leaving the value to be encoded
-     * by the set of child TLVs.
-     * 
-     * @return partial encoded image if constructed or complete TLV if primitive
-     */
-    public byte[] encode()
-    {
-        byte[] octets = null ;
-        int tagLength = getTagLength() ;
-        int lengthLength = getLengthLength() ;
-        int valueLength = 0 ;
-        int total = tagLength + lengthLength ;
-
-        if ( isPrimitive )
-        {
-            valueLength = ( ( byte[] ) value ).length ;
-            total += valueLength ;
-        }
-        
-        octets = new byte[total] ;
-        setTag( octets, tagLength ) ;
-        setLength( octets, tagLength, lengthLength ) ;
-        
-        if ( isPrimitive )
-        {
-            int destPos = tagLength + lengthLength ;
-            System.arraycopy( value, 0, octets, destPos, valueLength ) ;
-        }
-        
-        return octets ;
-    }
-    
-    
-    /**
-     * Sets the tag section within the array at the start of the array.
-     * 
-     * @param octets the array of bytes to set the tag in
-     * @param tagLength the length of the tag section
-     */
-    void setTag( byte[] octets, int tagLength )
-    {
-        octets[0] = ( byte ) typeClass.getValue() ;
-        
-        if ( ! isPrimitive )
-        {
-            octets[0] |= Binary.BIT_5 ;
-        }
-        
-        if ( tagLength == 1 )
-        {
-            octets[0] |= id ;
-        }
-        else
-        {
-            octets[0] |= BERUtils.SHORT_TAG_MASK ;
-        }
-        
-        if ( tagLength >= 2 )
-        {
-            octets[1] = ( byte ) ( ( int ) 0x0000007f & id ) ;
-            
-            if ( tagLength > 2 )
-            {
-                octets[1] |= Binary.BIT_7 ;
-            }
-        }
-        else
-        {
-            return ;
-        }
-        
-        /* 
-         * Take bits [8-14] (1 based bit indexing) inclusive in id and set the
-         * value for the second byte to this when shifted down 7 positions so
-         * we need the following mask:
-         * 
-         * 0011 1111 1000 0000 => 0x3f80
-         * 
-         */
-        if ( tagLength >= 3 )
-        {
-            octets[2] = ( byte ) ( ( ( int ) 0x3f80 & id ) >> 7 ) ;
-            
-            if ( tagLength > 3 )
-            {
-                octets[2] |= Binary.BIT_7 ;
-            }
-        }
-        else
-        {
-            return ;
-        }
-        
-        /* 
-         * Take bits [15-21] (1 based bit indexing) inclusive in id and set the
-         * value for the second byte to this when shifted down 14 positions so
-         * we need the following mask:
-         * 
-         * 0001 1111 1100 0000 0000 0000 => 0x1fc000
-         * 
-         */
-        if ( tagLength >= 4 )
-        {
-            octets[3] = ( byte ) ( ( ( int ) 0x1fc000 & id ) >> 14 ) ;
-            
-            if ( tagLength > 4 )
-            {
-                octets[3] |= Binary.BIT_7 ;
-            }
-        }
-        else
-        {
-            return ;
-        }
-        
-        /* 
-         * Take bits [22-28] (1 based bit indexing) inclusive in id and set the
-         * value for the second byte to this when shifted down 21 positions so
-         * we need the following mask:
-         * 
-         * 0000 1111 1110 0000 0000 0000 0000 0000 => 0x0fe00000
-         * 
-         */
-        if ( tagLength >= 5 )
-        {
-            octets[4] = ( byte ) ( ( ( int ) 0x0fe00000 & id ) >> 21 ) ;
-            
-            if ( tagLength > 5 )
-            {
-                octets[4] |= Binary.BIT_7 ;
-            }
-        }
-        else
-        {
-            return ;
-        }
-        
-        if ( tagLength >= 6 )
-        {    
-            throw new IllegalArgumentException( "cannot support id's as large "
-                    + "as " + id + " unless we start using longs for the id" ) ;
-        }
-    }
-
-
-    /**
-     * Sets the length bytes.
-     * 
-     * @param octets the byte [] to set length in
-     * @param offset the offset in the array to start the length section in
-     * @param lengthBytes the number bytes for the length section
-     */
-    void setLength( byte[] octets, int offset, int lengthBytes )
-    {
-        if ( length == Tuple.INDEFINATE )
-        {
-            octets[offset] |= BIT_6 ;
-            return ;
-        }
-        else if ( lengthBytes == 1 )
-        {
-            octets[offset] |= length ;
-        }
-        else
-        {
-            octets[offset] |= Binary.BIT_7 | lengthBytes - 1 ;
-        }
-        
-        if ( lengthBytes >= 2 )
-        {
-            octets[offset + 1] =  ( byte ) ( 0xff & length ) ;
-        }
-        else
-        {
-            return ;
-        }
-        
-        if ( lengthBytes >= 3 )
-        {
-            octets[offset + 2] = ( byte ) ( ( 0xff00 & length ) >> 8 ) ;
-        }
-        else
-        {
-            return ;
-        }
-        
-        if ( lengthBytes >= 4 )
-        {
-            octets[offset + 3] = ( byte ) ( ( 0xff0000 & length ) >> 16 ) ;
-        }
-        else
-        {
-            return ;
-        }
-        
-        if ( lengthBytes >= 5 )
-        {
-            octets[offset + 4] = ( byte ) ( ( 0xff000000 & length ) >> 24 ) ;
-        }
-        else
-        {
-            return ;
-        }
-        
-        if ( lengthBytes >= 6 )
-        {    
-            throw new IllegalArgumentException( "cannot support lengths as "
-                    + "large as " + length 
-                    + " unless we start using longs for the length" ) ;
-        }
-    }
-
-
-    /**
-     * Gets the length in bytes of the tag section for this TLV tuple.
-     * 
-     * @return the length in bytes of the tag section for this TLV tuple
-     */
-    public int getTagLength()
-    {
-        if ( id < 31 )
-        {
-            return 1 ;
-        }
-        else if ( id < BIT_6 )
-        {
-            return 2 ;
-        }
-        
-        else if ( id < BIT_13 )
-        {
-            return 3 ;
-        }
-        else if ( id < BIT_20 )
-        {
-            return 4 ;
-        }
-        else if ( id < BIT_27 )
-        {
-            return 5 ;
-        }
-        
-        throw new IllegalArgumentException( "cannot support id's larger than " 
-                + id + " unless we start using longs for the id" ) ;
-    }
-    
-    
-    /**
-     * Gets the length in bytes of the length section of this TLV Tuple.
-     * 
-     * @return the length in bytes of the length section
-     */
-    public int getLengthLength()
-    {
-        if ( length == Tuple.INDEFINATE )
-        {
-            return 1 ;
-        }
-        
-        if ( length < 0 )
-        {
-            throw new IllegalArgumentException( "integer overflow makes id " 
-                    + "negative with a value of " + id 
-                    + " - unless we start using longs for"
-                    + " the id there you've hit a limitation" ) ;
-        }
-        else if ( length < BIT_6 )
-        {
-            return 1 ;
-        }
-        else if ( length < BIT_7 )
-        {    
-            return 2 ;
-        }
-        else if ( length < BIT_15 )
-        {
-            return 3 ;
-        }
-        else if ( length < BIT_23 )
-        {
-            return 4 ;
-        }
-        else 
-        {
-            return 5 ;
-        }
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.lang.ArrayUtils ;
+import org.apache.commons.codec.binary.Binary ;
+
+
+/**
+ * Simple TLV Tuple.  Because the length fields is a primitive int it's maximum
+ * value is 2,147,483,647 a single TLV's tuple cannot have a length over this
+ * amount or a value size over 2 GB.  I don't think we'll be hitting this soon
+ * especially with the value size protection feature planned for the decoder.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class Tuple
+{
+    /** used to mark lengths and indices and indefinate */
+    public static final int INDEFINATE = -2 ;
+    /** used to mark indices as undefined */ 
+    public static final int UNDEFINED = -1 ;
+
+    /** precalculated left shift of 1 by 7 places */
+    static final int BIT_6 = 1 << 7 ;
+    /** precalculated left shift of 1 by 8 places */
+    static final int BIT_7 = 1 << 8 ;
+    /** precalculated left shift of 1 by 14 places */
+    static final int BIT_13 = 1 << 14 ;
+    /** precalculated left shift of 1 by 16 places */
+    static final int BIT_15 = 1 << 16 ;
+    /** precalculated left shift of 1 by 21 places */
+    static final int BIT_20 = 1 << 21 ;
+    /** precalculated left shift of 1 by 24 places */
+    static final int BIT_23 = 1 << 24 ;
+    /** precalculated left shift of 1 by 28 places */
+    static final int BIT_27 = 1 << 28 ;
+    
+    /** the tag id for this TLV tuple */
+    int id = 0 ;
+    /** the flag for whether or not this TLV is constructed or primitive */
+    boolean isPrimitive = true ;
+    /** the type class for this TLV */
+    TypeClass typeClass = TypeClass.APPLICATION ;
+    /** the length for this TLV tuple */
+    int length = 0 ;
+    /** the value for this TLV tuple */
+    Object value = ArrayUtils.EMPTY_BYTE_ARRAY ;
+    
+    /** tlv byte index */
+    int index = Tuple.UNDEFINED ;
+    /** tlv value index for how far into the value we have read */
+    int valueIndex = Tuple.UNDEFINED ;
+    
+    
+    // ------------------------------------------------------------------------
+    // C O N S T R U C T O R S
+    // ------------------------------------------------------------------------
+    
+
+    /**
+     * Empty do nothing tuple.
+     */
+    Tuple() 
+    { 
+    }
+    
+    
+    /**
+     * Creates constructed application type tlv tuples.  Constructed TLV's with
+     * a definate length will use this constructor predominantly.  The TypeClass
+     * defualts to APPLICATION.
+     * 
+     * @param id the tag id of the tlv
+     * @param length the length of the value which is the length of all the 
+     *      nested tuples.
+     */
+    public Tuple( int id, int length )
+    {
+        this( id, length, TypeClass.APPLICATION ) ;
+    }
+    
+    
+    /**
+     * Creates constructed application type tlv tuples.  Constructed TLV's with
+     * a definate length will use this constructor predominantly.
+     * 
+     * @param id the tag id of the tlv
+     * @param length the length of the value which is the length of all the 
+     *      nested tuples.
+     * @param typeClass the type class of this tlv tuple
+     */
+    public Tuple( int id, int length, TypeClass typeClass )
+    {
+        this.id = id ;
+        this.length = length ;
+        value = ArrayUtils.EMPTY_BYTE_ARRAY ;
+        isPrimitive = false ;
+        
+        if ( typeClass != null )
+        {
+            this.typeClass = typeClass ;
+        }
+    }
+    
+    
+    /**
+     * Creates primitive application type tlv tuples.  This will be the primary
+     * constructor used to build primitives.
+     * 
+     * @param id the tag id of the tlv
+     * @param value the value portion for this Tuple
+     */
+    public Tuple( int id, byte[] value )
+    {
+        this( id, TypeClass.APPLICATION, true, value ) ;
+    }
+    
+    
+    /**
+     * Creates an application type tlv with a set value and length.  
+     * 
+     * @param id the tag id of the tlv
+     * @param isPrimitive whether or not the tlv is primitive or constructed
+     * @param value the value portion for this Tuple
+     */
+    public Tuple( int id, boolean isPrimitive, byte[] value )
+    {
+        this( id, TypeClass.APPLICATION, isPrimitive, value ) ;
+    }
+    
+    
+    /**
+     * Creates a tuple where the length is indefinate.  The tuple according to
+     * the BER encoding must be of the constructed type.
+     * 
+     * @param id the tag id of the tlv
+     * @param typeClass the type class for the tlv
+     * @param isPrimitive whether or not the tlv is primitive or constructed
+     * @param value the value portion for this Tuple
+     */
+    public Tuple( int id, TypeClass typeClass )
+    {
+        this.id = id ;
+        this.isPrimitive = false ;
+        value = ArrayUtils.EMPTY_BYTE_ARRAY ;
+        length = Tuple.INDEFINATE ;
+        
+        if ( typeClass != null )
+        {
+            this.typeClass = typeClass ;
+        }
+    }
+    
+    
+    /**
+     * Creates a tuple where every member is specified including the length 
+     * which is taken from the value array.
+     * 
+     * @param id the tag id of the tlv
+     * @param typeClass the type class for the tlv
+     * @param isPrimitive whether or not the tlv is primitive or constructed
+     * @param value the value portion for this Tuple
+     */
+    public Tuple( int id, TypeClass typeClass, boolean isPrimitive, 
+                  byte[] value )
+    {
+        this.id = id ;
+        this.isPrimitive = isPrimitive ;
+        
+        if ( value != null )
+        {
+            this.value = value ;
+            this.length = value.length ;
+        }
+        
+        if ( typeClass != null )
+        {
+            this.typeClass = typeClass ;
+        }
+    }
+    
+    
+    // ------------------------------------------------------------------------
+    // Public Accessors
+    // ------------------------------------------------------------------------
+    
+    
+    /**
+     * Gets the tag id (T-part) for this TLV Tuple.
+     * 
+     * @return the tag id
+     */
+    public int getId()
+    {
+        return id ;
+    }
+    
+    
+    /**
+     * Get's whether or not this tuples's length is indefinate.
+     * 
+     * @return whether or not this tuple's length is indefinate
+     */
+    public boolean isIndefinate()
+    {
+        return length == Tuple.INDEFINATE ;
+    }
+    
+
+    /**
+     * Get's whether or not this tuple terminates an indefinate constructed 
+     * tuple.  This means that length == 0 && isPrimitive = true && id == 0
+     * and the type class is universal.
+     * 
+     * @return whether or not this node's length is indefinate
+     */
+    public boolean isIndefinateTerminator()
+    {
+        return isPrimitive && ( id + length ) == 0 && 
+            typeClass.equals( TypeClass.UNIVERSAL ) ;
+    }
+    
+
+    /**
+     * Gets whether or not this TLV tuple is primitive or constructed.
+     * 
+     * @return true if it is primitive, false if it is constructed
+     */
+    public boolean isPrimitive()
+    {
+        return isPrimitive ;
+    }
+
+    
+    /**
+     * Gets the value length for this TLV Tuple.
+     * 
+     * @return the length in bytes of the value field for this TLV tuple
+     */
+    public int getLength()
+    {
+        return length ;
+    }
+
+    
+    /**
+     * Gets the BER TLV TypeClass for this TLV Tuple.
+     * 
+     * @return the BER TLV TypeClass for this TLV Tuple
+     */
+    public TypeClass getTypeClass()
+    {
+        return typeClass ;
+    }
+
+    
+    /**
+     * Gets the value field (V-part) for this TLV Tuple.
+     * 
+     * @return the value field for this TLV Tuple
+     */
+    public Object getValue()
+    {
+        return value ;
+    }
+    
+    
+    /**
+     * Gets the total size of this TLV tuple in bytes.  This includes the
+     * length of the tag field, the length of the length field and the length
+     * of the value filed.
+     * 
+     * @return the total TLV size in bytes
+     */
+    public int size()
+    {
+        if ( this.length == Tuple.INDEFINATE )
+        {    
+            return getTagLength() + getLengthLength() ;
+        }
+        else
+        {
+            return getTagLength() + getLengthLength() + length ;
+        }
+    }
+    
+    
+    // ------------------------------------------------------------------------
+    // Utility methods and java.lang.Object overrides
+    // ------------------------------------------------------------------------
+    
+    
+    /**
+     * Clears the values of this tuple.
+     */
+    void clear()
+    {
+        this.id = 0 ;
+        this.index = 0 ;
+        this.isPrimitive = true ;
+        this.length = Tuple.UNDEFINED ;
+        this.typeClass = TypeClass.APPLICATION ;
+        this.value = ArrayUtils.EMPTY_BYTE_ARRAY ;
+        this.valueIndex = Tuple.UNDEFINED ;
+    }
+
+    
+    /**
+     * Does not take into account the index or the valueIndex values when
+     * checking for equality.  Technically if both are being constructed by
+     * the decoder then they should only be equal when these values are equal
+     * because the tag, length or value would not be correct.
+     *
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals( Object o )
+    {
+        if ( o == this )
+        {
+            return true ;
+        }
+        
+        if ( o instanceof Tuple )
+        {
+            Tuple t = ( Tuple ) o ;
+            
+            if ( t.id != id )
+            {
+                return false ;
+            }
+            
+            if ( t.isPrimitive != isPrimitive )
+            {
+                return false ;
+            }
+            
+            if ( t.length != length )
+            {
+                return false ;
+            }
+            
+            if ( t.typeClass != typeClass )
+            {
+                return false ;
+            }
+            
+            if ( t.value == null && value == null )
+            {
+                
+            }
+            else if ( ! ArrayUtils.isEquals( t.value, value ) )
+            {
+                return false ;
+            }
+            
+            return true ;
+        }
+        
+        return false ;
+    }
+    
+
+    /*
+     * (non-Javadoc)
+     * @see java.lang.Object#clone()
+     */
+    public Object clone()
+    {
+        Tuple t = new Tuple() ;
+        t.id = id ;
+        t.isPrimitive = isPrimitive ;
+        t.typeClass = typeClass ;
+        t.length = length ;
+        t.value = value ;
+        t.index = index ;
+        t.valueIndex = valueIndex ;
+        
+        return t ;
+    }
+    
+    
+    // ------------------------------------------------------------------------
+    // Tuple encoding operations
+    // ------------------------------------------------------------------------
+    
+    
+    /**
+     * If this is a primitive TLV then it is encoded fully.  If it is not then
+     * only the TL part of the tuple is encoded leaving the value to be encoded
+     * by the set of child TLVs.
+     * 
+     * @return partial encoded image if constructed or complete TLV if primitive
+     */
+    public byte[] encode()
+    {
+        byte[] octets = null ;
+        int tagLength = getTagLength() ;
+        int lengthLength = getLengthLength() ;
+        int valueLength = 0 ;
+        int total = tagLength + lengthLength ;
+
+        if ( isPrimitive )
+        {
+            valueLength = ( ( byte[] ) value ).length ;
+            total += valueLength ;
+        }
+        
+        octets = new byte[total] ;
+        setTag( octets, tagLength ) ;
+        setLength( octets, tagLength, lengthLength ) ;
+        
+        if ( isPrimitive )
+        {
+            int destPos = tagLength + lengthLength ;
+            System.arraycopy( value, 0, octets, destPos, valueLength ) ;
+        }
+        
+        return octets ;
+    }
+    
+    
+    /**
+     * Sets the tag section within the array at the start of the array.
+     * 
+     * @param octets the array of bytes to set the tag in
+     * @param tagLength the length of the tag section
+     */
+    void setTag( byte[] octets, int tagLength )
+    {
+        octets[0] = ( byte ) typeClass.getValue() ;
+        
+        if ( ! isPrimitive )
+        {
+            octets[0] |= Binary.BIT_5 ;
+        }
+        
+        if ( tagLength == 1 )
+        {
+            octets[0] |= id ;
+        }
+        else
+        {
+            octets[0] |= BERUtils.SHORT_TAG_MASK ;
+        }
+        
+        if ( tagLength >= 2 )
+        {
+            octets[1] = ( byte ) ( ( int ) 0x0000007f & id ) ;
+            
+            if ( tagLength > 2 )
+            {
+                octets[1] |= Binary.BIT_7 ;
+            }
+        }
+        else
+        {
+            return ;
+        }
+        
+        /* 
+         * Take bits [8-14] (1 based bit indexing) inclusive in id and set the
+         * value for the second byte to this when shifted down 7 positions so
+         * we need the following mask:
+         * 
+         * 0011 1111 1000 0000 => 0x3f80
+         * 
+         */
+        if ( tagLength >= 3 )
+        {
+            octets[2] = ( byte ) ( ( ( int ) 0x3f80 & id ) >> 7 ) ;
+            
+            if ( tagLength > 3 )
+            {
+                octets[2] |= Binary.BIT_7 ;
+            }
+        }
+        else
+        {
+            return ;
+        }
+        
+        /* 
+         * Take bits [15-21] (1 based bit indexing) inclusive in id and set the
+         * value for the second byte to this when shifted down 14 positions so
+         * we need the following mask:
+         * 
+         * 0001 1111 1100 0000 0000 0000 => 0x1fc000
+         * 
+         */
+        if ( tagLength >= 4 )
+        {
+            octets[3] = ( byte ) ( ( ( int ) 0x1fc000 & id ) >> 14 ) ;
+            
+            if ( tagLength > 4 )
+            {
+                octets[3] |= Binary.BIT_7 ;
+            }
+        }
+        else
+        {
+            return ;
+        }
+        
+        /* 
+         * Take bits [22-28] (1 based bit indexing) inclusive in id and set the
+         * value for the second byte to this when shifted down 21 positions so
+         * we need the following mask:
+         * 
+         * 0000 1111 1110 0000 0000 0000 0000 0000 => 0x0fe00000
+         * 
+         */
+        if ( tagLength >= 5 )
+        {
+            octets[4] = ( byte ) ( ( ( int ) 0x0fe00000 & id ) >> 21 ) ;
+            
+            if ( tagLength > 5 )
+            {
+                octets[4] |= Binary.BIT_7 ;
+            }
+        }
+        else
+        {
+            return ;
+        }
+        
+        if ( tagLength >= 6 )
+        {    
+            throw new IllegalArgumentException( "cannot support id's as large "
+                    + "as " + id + " unless we start using longs for the id" ) ;
+        }
+    }
+
+
+    /**
+     * Sets the length bytes.
+     * 
+     * @param octets the byte [] to set length in
+     * @param offset the offset in the array to start the length section in
+     * @param lengthBytes the number bytes for the length section
+     */
+    void setLength( byte[] octets, int offset, int lengthBytes )
+    {
+        if ( length == Tuple.INDEFINATE )
+        {
+            octets[offset] |= BIT_6 ;
+            return ;
+        }
+        else if ( lengthBytes == 1 )
+        {
+            octets[offset] |= length ;
+        }
+        else
+        {
+            octets[offset] |= Binary.BIT_7 | lengthBytes - 1 ;
+        }
+        
+        if ( lengthBytes >= 2 )
+        {
+            octets[offset + 1] =  ( byte ) ( 0xff & length ) ;
+        }
+        else
+        {
+            return ;
+        }
+        
+        if ( lengthBytes >= 3 )
+        {
+            octets[offset + 2] = ( byte ) ( ( 0xff00 & length ) >> 8 ) ;
+        }
+        else
+        {
+            return ;
+        }
+        
+        if ( lengthBytes >= 4 )
+        {
+            octets[offset + 3] = ( byte ) ( ( 0xff0000 & length ) >> 16 ) ;
+        }
+        else
+        {
+            return ;
+        }
+        
+        if ( lengthBytes >= 5 )
+        {
+            octets[offset + 4] = ( byte ) ( ( 0xff000000 & length ) >> 24 ) ;
+        }
+        else
+        {
+            return ;
+        }
+        
+        if ( lengthBytes >= 6 )
+        {    
+            throw new IllegalArgumentException( "cannot support lengths as "
+                    + "large as " + length 
+                    + " unless we start using longs for the length" ) ;
+        }
+    }
+
+
+    /**
+     * Gets the length in bytes of the tag section for this TLV tuple.
+     * 
+     * @return the length in bytes of the tag section for this TLV tuple
+     */
+    public int getTagLength()
+    {
+        if ( id < 31 )
+        {
+            return 1 ;
+        }
+        else if ( id < BIT_6 )
+        {
+            return 2 ;
+        }
+        
+        else if ( id < BIT_13 )
+        {
+            return 3 ;
+        }
+        else if ( id < BIT_20 )
+        {
+            return 4 ;
+        }
+        else if ( id < BIT_27 )
+        {
+            return 5 ;
+        }
+        
+        throw new IllegalArgumentException( "cannot support id's larger than " 
+                + id + " unless we start using longs for the id" ) ;
+    }
+    
+    
+    /**
+     * Gets the length in bytes of the length section of this TLV Tuple.
+     * 
+     * @return the length in bytes of the length section
+     */
+    public int getLengthLength()
+    {
+        if ( length == Tuple.INDEFINATE )
+        {
+            return 1 ;
+        }
+        
+        if ( length < 0 )
+        {
+            throw new IllegalArgumentException( "integer overflow makes id " 
+                    + "negative with a value of " + id 
+                    + " - unless we start using longs for"
+                    + " the id there you've hit a limitation" ) ;
+        }
+        else if ( length < BIT_6 )
+        {
+            return 1 ;
+        }
+        else if ( length < BIT_7 )
+        {    
+            return 2 ;
+        }
+        else if ( length < BIT_15 )
+        {
+            return 3 ;
+        }
+        else if ( length < BIT_23 )
+        {
+            return 4 ;
+        }
+        else 
+        {
+            return 5 ;
+        }
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleNode.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleNode.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleNode.java	Sun Mar 14 14:02:18 2004
@@ -1,41 +1,41 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.util.Iterator ;
-import java.nio.ByteBuffer ;
-
-
-/**
- * A TLV Tuple tree node.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public interface TupleNode
-{
-    TupleNode getParentTupleNode() ;
-    Iterator getChildren() ;
-    TupleNode getChildTupleNodeAt( int index ) ;
-    int getIndex( TupleNode node ) ;
-    int getChildCount() ;
-    int size() ;
-    Tuple getTuple() ;
-    void encode( ByteBuffer buf ) ;
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.util.Iterator ;
+import java.nio.ByteBuffer ;
+
+
+/**
+ * A TLV Tuple tree node.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface TupleNode
+{
+    TupleNode getParentTupleNode() ;
+    Iterator getChildren() ;
+    TupleNode getChildTupleNodeAt( int index ) ;
+    int getIndex( TupleNode node ) ;
+    int getChildCount() ;
+    int size() ;
+    Tuple getTuple() ;
+    void encode( ByteBuffer buf ) ;
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java	Sun Mar 14 14:02:18 2004
@@ -1,269 +1,269 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import javax.swing.JMenu ;
-import javax.swing.JTree ;
-import javax.swing.JFrame ;
-import javax.swing.JPanel ;
-import javax.swing.JLabel ;
-import javax.swing.JMenuBar ;
-import javax.swing.JMenuItem ;
-import javax.swing.JTextArea ;
-import javax.swing.JTextField ;
-import javax.swing.JSplitPane ;
-import javax.swing.JScrollPane ;
-import javax.swing.JFileChooser ;
-import javax.swing.tree.DefaultTreeModel ;
-
-import java.awt.Toolkit ;
-import java.awt.Dimension ;
-import java.awt.BorderLayout ;
-import java.awt.event.ActionEvent ;
-import java.awt.event.WindowEvent ;
-import java.awt.event.ActionListener ;
-
-
-/**
- * Simple JTree view of a tuple tree.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class TupleTreeAnalyzer extends JFrame 
-{
-    DefaultMutableTupleNode root = null ;
-    
-    /** Creates new form JFrame */
-    public TupleTreeAnalyzer( DefaultMutableTupleNode root ) 
-    {
-        this.root = root ;
-        
-        initGUI() ;
-        pack() ;
-    }
-
-    /** This method is called from within 
-     * the constructor to initialize the form. */
-    private void initGUI() {
-
-        getContentPane().setLayout(layout);
-        JPanel content = new JPanel();
-        content.setPreferredSize(new Dimension(300, 200));
-        getContentPane().add(content, BorderLayout.CENTER);
-        // set title
-        setTitle("");
-        // add status bar
-        getContentPane().add(statusBar, BorderLayout.SOUTH);
-        // add menu bar
-        JMenuBar menuBar = new JMenuBar();
-        JMenu menuFile = new JMenu("File");
-        menuFile.setMnemonic('F');
-        // create Exit menu item
-        JMenuItem fileExit = new JMenuItem("Exit");
-        fileExit.setMnemonic('E');
-        fileExit.addActionListener(
-            new ActionListener() {
-                public void actionPerformed(ActionEvent e) {
-                    System.exit(0);
-                }
-            });
-        // create About menu item
-        JMenu menuHelp = new JMenu("Help");
-        menuHelp.setMnemonic('H');
-        JMenuItem helpAbout = new JMenuItem("About");
-        helpAbout.setMnemonic('A');
-        helpAbout.addActionListener(
-            new ActionListener() {
-                public void actionPerformed(ActionEvent e) {
-                }
-            });
-        menuHelp.add(helpAbout);
-        // create Open menu item
-        final JFileChooser fc = new JFileChooser();
-        JMenuItem openFile = new JMenuItem("Open");
-        openFile.setMnemonic('O');
-        openFile.addActionListener(
-            new java.awt.event.ActionListener() {
-                public void actionPerformed(java.awt.event.ActionEvent e) {
-                    int returnVal = fc.showOpenDialog(TupleTreeAnalyzer.this);
-                    if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
-                        java.io.File file = fc.getSelectedFile();
-                        // Write your code here what to do with selected file
-                    } else {
-                        // Write your code here what to do if user has canceled
-                    }
-                }
-            });
-        menuFile.add(openFile);
-        // create Save menu item
-        JMenuItem saveFile = new JMenuItem("Save");
-        saveFile.setMnemonic('S');
-        saveFile.addActionListener(
-            new java.awt.event.ActionListener() {
-                public void actionPerformed(java.awt.event.ActionEvent e) {
-                    int returnVal = fc.showSaveDialog(TupleTreeAnalyzer.this);
-                    if (returnVal == JFileChooser.APPROVE_OPTION) {
-                        java.io.File file = fc.getSelectedFile();
-                        // Write your code here what to do with selected file
-                    } else {
-// Write your code here what to do if user has canceled Save dialog
-                    }
-                }
-            });
-        menuFile.add(saveFile);
-        // create Print menu item
-        JMenuItem print = new JMenuItem("Print");
-        print.setMnemonic('P');
-        print.addActionListener(
-            new java.awt.event.ActionListener() {
-                public void actionPerformed(java.awt.event.ActionEvent e) {
-                    // PrintDialog.print(getGraphics());
-                }
-            }); menuFile.add(print);
-        menuFile.add(fileExit);
-        menuBar.add(menuFile);
-        menuBar.add(menuHelp);
-        // sets menu bar
-        setJMenuBar(menuBar);
-        addWindowListener(
-            new java.awt.event.WindowAdapter() {
-                public void windowClosing(java.awt.event.WindowEvent evt) {
-                    exitForm(evt);
-                }
-            });
-        
-        
-        jLabel3.setText("Type Class:");
-        jPanel5.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
-        jPanel5.add(jLabel3);
-        jPanel5.add(jTextField3);
-        jTextField3.setText("");
-        jTextField3.setMinimumSize(new java.awt.Dimension(104, 25));
-        jTextField3.setPreferredSize(new java.awt.Dimension(104, 25));
-        jSplitPane1.setLastDividerLocation(50);
-        jSplitPane1.setDividerLocation(180);
-        jSplitPane1.add(jScrollPane1, javax.swing.JSplitPane.LEFT);
-        jSplitPane1.add(jPanel1, javax.swing.JSplitPane.RIGHT);
-        addWindowListener(
-            new java.awt.event.WindowAdapter() {
-                public void windowClosing(java.awt.event.WindowEvent evt) {
-                    exitForm(evt);
-                }
-            });
-        getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);
-        jScrollPane1.getViewport().add(jTree1);
-        jTree1.setBounds(new java.awt.Rectangle(95,95,85,84));
-        jTree1.setShowsRootHandles(true);
-        jPanel1.setLayout(new java.awt.GridBagLayout());
-        jPanel1.add(jPanel2,
-        new java.awt.GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, 
-                        java.awt.GridBagConstraints.WEST, 
-                        java.awt.GridBagConstraints.HORIZONTAL,
-        new java.awt.Insets(0, 9, 0, 9), 0, 0));
-        jPanel1.add(jPanel3,
-        new java.awt.GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, 
-                        java.awt.GridBagConstraints.WEST, 
-                        java.awt.GridBagConstraints.HORIZONTAL,
-        new java.awt.Insets(0, 9, 0, 9), 0, 0));
-        jPanel1.add(jPanel4,
-        new java.awt.GridBagConstraints(0, 3, 1, 35, 1.0, 1.0, 
-                        java.awt.GridBagConstraints.CENTER, 
-                        java.awt.GridBagConstraints.BOTH,
-        new java.awt.Insets(9, 12, 9, 12), 0, 0));
-        jPanel1.add(jPanel5,
-        new java.awt.GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, 
-                        java.awt.GridBagConstraints.WEST, 
-                        java.awt.GridBagConstraints.HORIZONTAL,
-        new java.awt.Insets(0, 9, 0, 9), 0, 0));
-        jLabel1.setText("Tag Id:");
-        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
-        jPanel2.add(jLabel1);
-        jPanel2.add(jTextField1);
-        jLabel2.setText("Length:");
-        jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
-        jPanel3.add(jLabel2);
-        jPanel3.add(jTextField2);
-        jPanel4.setLayout(new java.awt.BorderLayout());
-        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(
-                        javax.swing.BorderFactory.createLineBorder(
-        new java.awt.Color(153, 153, 153), 1), "Value", 
-                        javax.swing.border.TitledBorder.LEADING, 
-                        javax.swing.border.TitledBorder.TOP,
-        new java.awt.Font("Comic Sans MS", 0, 14), 
-                        new java.awt.Color(60, 60, 60)));
-        jPanel4.add(jScrollPane2, java.awt.BorderLayout.CENTER);
-        jTextArea1.setText("");
-        jScrollPane2.getViewport().add(jTextArea1);
-        jTextField1.setText("");
-        jTextField1.setMinimumSize(new java.awt.Dimension(104, 25));
-        jTextField1.setPreferredSize(new java.awt.Dimension(104, 25));
-        jTextField1.setEditable(true);
-        jTextField2.setText("");
-        jTextField2.setPreferredSize(new java.awt.Dimension(104,25));
-        jTextField2.setMinimumSize(new java.awt.Dimension(104,25));
-        jTextField2.setEditable(true);
-        jScrollPane2.setVerticalScrollBarPolicy(
-                javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
-        jScrollPane2.setHorizontalScrollBarPolicy(
-                javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
-        jScrollPane2.setBorder(null);
-        
-        jTree1.setModel( new DefaultTreeModel( root ) ) ;
-    }
-
-    /** Exit the Application */
-    private void exitForm(WindowEvent evt) {
-        System.exit(0);
-    }
-
-    
-    public void startup()
-    {
-        setSize( 800, 640 ) ;
-        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-        Dimension frameSize = getSize();
-        frameSize.height = ((frameSize.height > screenSize.height) 
-                ? screenSize.height : frameSize.height);
-        frameSize.width = ((frameSize.width > screenSize.width) 
-                ? screenSize.width : frameSize.width);
-        setLocation((screenSize.width - frameSize.width) / 2, 
-                (screenSize.height - frameSize.height) / 2);
-        setVisible(true);
-    }
-
-    private BorderLayout layout = new BorderLayout();
-    private JLabel statusBar = new JLabel("Ready");
-    private JSplitPane jSplitPane1 = new JSplitPane();
-    private JScrollPane jScrollPane1 = new JScrollPane();
-    private JPanel jPanel1 = new JPanel();
-    private JTree jTree1 = new JTree();
-    private JPanel jPanel2 = new JPanel();
-    private JPanel jPanel5 = new JPanel();
-    private JPanel jPanel3 = new JPanel();
-    private JPanel jPanel4 = new JPanel();
-    private JLabel jLabel1 = new JLabel();
-    private JLabel jLabel3 = new JLabel();
-    private JLabel jLabel2 = new JLabel();
-    private JScrollPane jScrollPane2 = new JScrollPane();
-    private JTextArea jTextArea1 = new JTextArea();
-    private JTextField jTextField1 = new JTextField();
-    private JTextField jTextField3 = new JTextField();
-    private JTextField jTextField2 = new JTextField();
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import javax.swing.JMenu ;
+import javax.swing.JTree ;
+import javax.swing.JFrame ;
+import javax.swing.JPanel ;
+import javax.swing.JLabel ;
+import javax.swing.JMenuBar ;
+import javax.swing.JMenuItem ;
+import javax.swing.JTextArea ;
+import javax.swing.JTextField ;
+import javax.swing.JSplitPane ;
+import javax.swing.JScrollPane ;
+import javax.swing.JFileChooser ;
+import javax.swing.tree.DefaultTreeModel ;
+
+import java.awt.Toolkit ;
+import java.awt.Dimension ;
+import java.awt.BorderLayout ;
+import java.awt.event.ActionEvent ;
+import java.awt.event.WindowEvent ;
+import java.awt.event.ActionListener ;
+
+
+/**
+ * Simple JTree view of a tuple tree.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TupleTreeAnalyzer extends JFrame 
+{
+    DefaultMutableTupleNode root = null ;
+    
+    /** Creates new form JFrame */
+    public TupleTreeAnalyzer( DefaultMutableTupleNode root ) 
+    {
+        this.root = root ;
+        
+        initGUI() ;
+        pack() ;
+    }
+
+    /** This method is called from within 
+     * the constructor to initialize the form. */
+    private void initGUI() {
+
+        getContentPane().setLayout(layout);
+        JPanel content = new JPanel();
+        content.setPreferredSize(new Dimension(300, 200));
+        getContentPane().add(content, BorderLayout.CENTER);
+        // set title
+        setTitle("");
+        // add status bar
+        getContentPane().add(statusBar, BorderLayout.SOUTH);
+        // add menu bar
+        JMenuBar menuBar = new JMenuBar();
+        JMenu menuFile = new JMenu("File");
+        menuFile.setMnemonic('F');
+        // create Exit menu item
+        JMenuItem fileExit = new JMenuItem("Exit");
+        fileExit.setMnemonic('E');
+        fileExit.addActionListener(
+            new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    System.exit(0);
+                }
+            });
+        // create About menu item
+        JMenu menuHelp = new JMenu("Help");
+        menuHelp.setMnemonic('H');
+        JMenuItem helpAbout = new JMenuItem("About");
+        helpAbout.setMnemonic('A');
+        helpAbout.addActionListener(
+            new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                }
+            });
+        menuHelp.add(helpAbout);
+        // create Open menu item
+        final JFileChooser fc = new JFileChooser();
+        JMenuItem openFile = new JMenuItem("Open");
+        openFile.setMnemonic('O');
+        openFile.addActionListener(
+            new java.awt.event.ActionListener() {
+                public void actionPerformed(java.awt.event.ActionEvent e) {
+                    int returnVal = fc.showOpenDialog(TupleTreeAnalyzer.this);
+                    if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
+                        java.io.File file = fc.getSelectedFile();
+                        // Write your code here what to do with selected file
+                    } else {
+                        // Write your code here what to do if user has canceled
+                    }
+                }
+            });
+        menuFile.add(openFile);
+        // create Save menu item
+        JMenuItem saveFile = new JMenuItem("Save");
+        saveFile.setMnemonic('S');
+        saveFile.addActionListener(
+            new java.awt.event.ActionListener() {
+                public void actionPerformed(java.awt.event.ActionEvent e) {
+                    int returnVal = fc.showSaveDialog(TupleTreeAnalyzer.this);
+                    if (returnVal == JFileChooser.APPROVE_OPTION) {
+                        java.io.File file = fc.getSelectedFile();
+                        // Write your code here what to do with selected file
+                    } else {
+// Write your code here what to do if user has canceled Save dialog
+                    }
+                }
+            });
+        menuFile.add(saveFile);
+        // create Print menu item
+        JMenuItem print = new JMenuItem("Print");
+        print.setMnemonic('P');
+        print.addActionListener(
+            new java.awt.event.ActionListener() {
+                public void actionPerformed(java.awt.event.ActionEvent e) {
+                    // PrintDialog.print(getGraphics());
+                }
+            }); menuFile.add(print);
+        menuFile.add(fileExit);
+        menuBar.add(menuFile);
+        menuBar.add(menuHelp);
+        // sets menu bar
+        setJMenuBar(menuBar);
+        addWindowListener(
+            new java.awt.event.WindowAdapter() {
+                public void windowClosing(java.awt.event.WindowEvent evt) {
+                    exitForm(evt);
+                }
+            });
+        
+        
+        jLabel3.setText("Type Class:");
+        jPanel5.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
+        jPanel5.add(jLabel3);
+        jPanel5.add(jTextField3);
+        jTextField3.setText("");
+        jTextField3.setMinimumSize(new java.awt.Dimension(104, 25));
+        jTextField3.setPreferredSize(new java.awt.Dimension(104, 25));
+        jSplitPane1.setLastDividerLocation(50);
+        jSplitPane1.setDividerLocation(180);
+        jSplitPane1.add(jScrollPane1, javax.swing.JSplitPane.LEFT);
+        jSplitPane1.add(jPanel1, javax.swing.JSplitPane.RIGHT);
+        addWindowListener(
+            new java.awt.event.WindowAdapter() {
+                public void windowClosing(java.awt.event.WindowEvent evt) {
+                    exitForm(evt);
+                }
+            });
+        getContentPane().add(jSplitPane1, java.awt.BorderLayout.CENTER);
+        jScrollPane1.getViewport().add(jTree1);
+        jTree1.setBounds(new java.awt.Rectangle(95,95,85,84));
+        jTree1.setShowsRootHandles(true);
+        jPanel1.setLayout(new java.awt.GridBagLayout());
+        jPanel1.add(jPanel2,
+        new java.awt.GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, 
+                        java.awt.GridBagConstraints.WEST, 
+                        java.awt.GridBagConstraints.HORIZONTAL,
+        new java.awt.Insets(0, 9, 0, 9), 0, 0));
+        jPanel1.add(jPanel3,
+        new java.awt.GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, 
+                        java.awt.GridBagConstraints.WEST, 
+                        java.awt.GridBagConstraints.HORIZONTAL,
+        new java.awt.Insets(0, 9, 0, 9), 0, 0));
+        jPanel1.add(jPanel4,
+        new java.awt.GridBagConstraints(0, 3, 1, 35, 1.0, 1.0, 
+                        java.awt.GridBagConstraints.CENTER, 
+                        java.awt.GridBagConstraints.BOTH,
+        new java.awt.Insets(9, 12, 9, 12), 0, 0));
+        jPanel1.add(jPanel5,
+        new java.awt.GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, 
+                        java.awt.GridBagConstraints.WEST, 
+                        java.awt.GridBagConstraints.HORIZONTAL,
+        new java.awt.Insets(0, 9, 0, 9), 0, 0));
+        jLabel1.setText("Tag Id:");
+        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
+        jPanel2.add(jLabel1);
+        jPanel2.add(jTextField1);
+        jLabel2.setText("Length:");
+        jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
+        jPanel3.add(jLabel2);
+        jPanel3.add(jTextField2);
+        jPanel4.setLayout(new java.awt.BorderLayout());
+        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(
+                        javax.swing.BorderFactory.createLineBorder(
+        new java.awt.Color(153, 153, 153), 1), "Value", 
+                        javax.swing.border.TitledBorder.LEADING, 
+                        javax.swing.border.TitledBorder.TOP,
+        new java.awt.Font("Comic Sans MS", 0, 14), 
+                        new java.awt.Color(60, 60, 60)));
+        jPanel4.add(jScrollPane2, java.awt.BorderLayout.CENTER);
+        jTextArea1.setText("");
+        jScrollPane2.getViewport().add(jTextArea1);
+        jTextField1.setText("");
+        jTextField1.setMinimumSize(new java.awt.Dimension(104, 25));
+        jTextField1.setPreferredSize(new java.awt.Dimension(104, 25));
+        jTextField1.setEditable(true);
+        jTextField2.setText("");
+        jTextField2.setPreferredSize(new java.awt.Dimension(104,25));
+        jTextField2.setMinimumSize(new java.awt.Dimension(104,25));
+        jTextField2.setEditable(true);
+        jScrollPane2.setVerticalScrollBarPolicy(
+                javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+        jScrollPane2.setHorizontalScrollBarPolicy(
+                javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+        jScrollPane2.setBorder(null);
+        
+        jTree1.setModel( new DefaultTreeModel( root ) ) ;
+    }
+
+    /** Exit the Application */
+    private void exitForm(WindowEvent evt) {
+        System.exit(0);
+    }
+
+    
+    public void startup()
+    {
+        setSize( 800, 640 ) ;
+        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+        Dimension frameSize = getSize();
+        frameSize.height = ((frameSize.height > screenSize.height) 
+                ? screenSize.height : frameSize.height);
+        frameSize.width = ((frameSize.width > screenSize.width) 
+                ? screenSize.width : frameSize.width);
+        setLocation((screenSize.width - frameSize.width) / 2, 
+                (screenSize.height - frameSize.height) / 2);
+        setVisible(true);
+    }
+
+    private BorderLayout layout = new BorderLayout();
+    private JLabel statusBar = new JLabel("Ready");
+    private JSplitPane jSplitPane1 = new JSplitPane();
+    private JScrollPane jScrollPane1 = new JScrollPane();
+    private JPanel jPanel1 = new JPanel();
+    private JTree jTree1 = new JTree();
+    private JPanel jPanel2 = new JPanel();
+    private JPanel jPanel5 = new JPanel();
+    private JPanel jPanel3 = new JPanel();
+    private JPanel jPanel4 = new JPanel();
+    private JLabel jLabel1 = new JLabel();
+    private JLabel jLabel3 = new JLabel();
+    private JLabel jLabel2 = new JLabel();
+    private JScrollPane jScrollPane2 = new JScrollPane();
+    private JTextArea jTextArea1 = new JTextArea();
+    private JTextField jTextField1 = new JTextField();
+    private JTextField jTextField3 = new JTextField();
+    private JTextField jTextField2 = new JTextField();
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleTreeDecoder.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleTreeDecoder.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/java/org/apache/snickers/ber/TupleTreeDecoder.java	Sun Mar 14 14:02:18 2004
@@ -1,175 +1,175 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.nio.ByteBuffer;
-import java.util.Stack ;
-
-import org.apache.commons.codec.DecoderException ;
-import org.apache.commons.codec.stateful.CallbackHistory;
-import org.apache.commons.codec.stateful.DecoderMonitor ;
-import org.apache.commons.codec.stateful.DecoderCallback ;
-import org.apache.commons.codec.stateful.StatefulDecoder ;
-import org.apache.commons.codec.stateful.DecoderMonitorAdapter ;
-
-
-/**
- * Builds a TLV tree from the TLV stream emitted from the decoder.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class TupleTreeDecoder implements StatefulDecoder
-{
-    Stack stack = new Stack() ;
-    BERDecoder decoder = new BERDecoder() ;
-    DecoderCallback cb = null ;
-    DecoderMonitor monitor = new DecoderMonitorAdapter() ;
-
-    
-    public TupleTreeDecoder()
-    {
-        BERDecoderCallback berCallback = new BERDecoderCallback()
-        {
-            public void tagDecoded( Tuple tlv ) { }
-        
-            public void lengthDecoded( Tuple tlv )
-            {
-                if ( ! tlv.isPrimitive ) 
-                {
-                    MutableTupleNode child = null ;
-                    MutableTupleNode parent = null ;
-                    Tuple cloned = ( Tuple ) tlv.clone() ;
-                    
-                    if ( stack.isEmpty() )
-                    {
-                        stack.push( new DefaultMutableTupleNode( cloned ) ) ;
-                        return ;
-                    }
-                    
-                    parent = ( MutableTupleNode ) stack.peek() ;
-                    child = new DefaultMutableTupleNode( cloned ) ;
-                    child.setParent( parent ) ;
-                    
-                    int index = parent.getChildCount() - 1 ;
-                    
-                    if ( index < 0 )
-                    {
-                        index = 0 ;
-                    }
-                    
-                    parent.insert( child, index ) ;
-                    stack.push( child ) ;
-                }
-            }
-    
-            public void 
-                decodeOccurred( StatefulDecoder decoder, Object decoded )
-            {
-                handleTuple( ( Tuple ) decoded ) ;
-            }
-        } ;
-        
-        decoder.setCallback( berCallback ) ;
-        decoder.setDecoderMonitor( monitor ) ;
-    }
-    
-    
-    public void handleTuple( Tuple t )
-    {
-        System.out.println( t.id ) ;
-        MutableTupleNode node = null ;
-        
-        if ( t.isPrimitive )
-        {
-            node = new DefaultMutableTupleNode( ( Tuple ) t.clone() ) ;
-                
-            if ( ! stack.isEmpty() )
-            {    
-                MutableTupleNode parent = ( MutableTupleNode ) stack.peek() ;
-                node.setParent( parent ) ;
-                int index = parent.getChildCount() - 1 ;
-                
-                if ( index < 0 ) 
-                {
-                    index = 0 ; 
-                }
-                
-                parent.insert( node, index ) ;
-            }
-            
-            return ;
-        }
-            
-        node = ( MutableTupleNode ) stack.pop() ;
-        
-        if ( cb != null && stack.isEmpty() )
-        {
-            cb.decodeOccurred( this, node ) ;
-        }
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.StatefulDecoder#decode(
-     * java.lang.Object)
-     */
-    public void decode( Object encoded ) throws DecoderException
-    {
-        decoder.decode( encoded ) ;
-    }
-    
-    
-    public static TupleNode treeDecode( ByteBuffer buf ) throws DecoderException
-    {
-        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        CallbackHistory history = new CallbackHistory( 1 ) ;
-        
-        decoder.setCallback( history ) ;
-        decoder.decode( buf ) ;
-        
-        if ( history.isEmpty() )
-        {
-            return null ;
-        }
-        
-        return ( TupleNode ) history.getMostRecent() ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.StatefulDecoder#setCallback(
-     * org.apache.commons.codec.stateful.DecoderCallback)
-     */
-    public void setCallback( DecoderCallback cb )
-    {
-        this.cb = cb ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
-     * org.apache.commons.codec.stateful.DecoderMonitor)
-     */
-    public void setDecoderMonitor( DecoderMonitor monitor )
-    {
-        this.monitor = monitor ;
-        decoder.setDecoderMonitor( monitor ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.nio.ByteBuffer;
+import java.util.Stack ;
+
+import org.apache.commons.codec.DecoderException ;
+import org.apache.commons.codec.stateful.CallbackHistory;
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+import org.apache.commons.codec.stateful.DecoderMonitorAdapter ;
+
+
+/**
+ * Builds a TLV tree from the TLV stream emitted from the decoder.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TupleTreeDecoder implements StatefulDecoder
+{
+    Stack stack = new Stack() ;
+    BERDecoder decoder = new BERDecoder() ;
+    DecoderCallback cb = null ;
+    DecoderMonitor monitor = new DecoderMonitorAdapter() ;
+
+    
+    public TupleTreeDecoder()
+    {
+        BERDecoderCallback berCallback = new BERDecoderCallback()
+        {
+            public void tagDecoded( Tuple tlv ) { }
+        
+            public void lengthDecoded( Tuple tlv )
+            {
+                if ( ! tlv.isPrimitive ) 
+                {
+                    MutableTupleNode child = null ;
+                    MutableTupleNode parent = null ;
+                    Tuple cloned = ( Tuple ) tlv.clone() ;
+                    
+                    if ( stack.isEmpty() )
+                    {
+                        stack.push( new DefaultMutableTupleNode( cloned ) ) ;
+                        return ;
+                    }
+                    
+                    parent = ( MutableTupleNode ) stack.peek() ;
+                    child = new DefaultMutableTupleNode( cloned ) ;
+                    child.setParent( parent ) ;
+                    
+                    int index = parent.getChildCount() - 1 ;
+                    
+                    if ( index < 0 )
+                    {
+                        index = 0 ;
+                    }
+                    
+                    parent.insert( child, index ) ;
+                    stack.push( child ) ;
+                }
+            }
+    
+            public void 
+                decodeOccurred( StatefulDecoder decoder, Object decoded )
+            {
+                handleTuple( ( Tuple ) decoded ) ;
+            }
+        } ;
+        
+        decoder.setCallback( berCallback ) ;
+        decoder.setDecoderMonitor( monitor ) ;
+    }
+    
+    
+    public void handleTuple( Tuple t )
+    {
+        System.out.println( t.id ) ;
+        MutableTupleNode node = null ;
+        
+        if ( t.isPrimitive )
+        {
+            node = new DefaultMutableTupleNode( ( Tuple ) t.clone() ) ;
+                
+            if ( ! stack.isEmpty() )
+            {    
+                MutableTupleNode parent = ( MutableTupleNode ) stack.peek() ;
+                node.setParent( parent ) ;
+                int index = parent.getChildCount() - 1 ;
+                
+                if ( index < 0 ) 
+                {
+                    index = 0 ; 
+                }
+                
+                parent.insert( node, index ) ;
+            }
+            
+            return ;
+        }
+            
+        node = ( MutableTupleNode ) stack.pop() ;
+        
+        if ( cb != null && stack.isEmpty() )
+        {
+            cb.decodeOccurred( this, node ) ;
+        }
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#decode(
+     * java.lang.Object)
+     */
+    public void decode( Object encoded ) throws DecoderException
+    {
+        decoder.decode( encoded ) ;
+    }
+    
+    
+    public static TupleNode treeDecode( ByteBuffer buf ) throws DecoderException
+    {
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        CallbackHistory history = new CallbackHistory( 1 ) ;
+        
+        decoder.setCallback( history ) ;
+        decoder.decode( buf ) ;
+        
+        if ( history.isEmpty() )
+        {
+            return null ;
+        }
+        
+        return ( TupleNode ) history.getMostRecent() ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#setCallback(
+     * org.apache.commons.codec.stateful.DecoderCallback)
+     */
+    public void setCallback( DecoderCallback cb )
+    {
+        this.cb = cb ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.StatefulDecoder#setDecoderMonitor(
+     * org.apache.commons.codec.stateful.DecoderMonitor)
+     */
+    public void setDecoderMonitor( DecoderMonitor monitor )
+    {
+        this.monitor = monitor ;
+        decoder.setDecoderMonitor( monitor ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/SnickersDecoderTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/SnickersDecoderTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/SnickersDecoderTest.java	Sun Mar 14 14:02:18 2004
@@ -1,337 +1,337 @@
-/*
- *   Copyright 2004 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.snickers ;
-
-
-import java.util.ArrayList ;
-
-import java.math.BigInteger ;
-
-import java.nio.ByteBuffer ;
-
-import javax.naming.directory.Attributes ;
-
-import org.apache.commons.codec.stateful.DecoderMonitor ;
-import org.apache.commons.codec.stateful.DecoderCallback ;
-import org.apache.commons.codec.stateful.StatefulDecoder ;
-
-import org.apache.ldap.common.message.Message ;
-import org.apache.ldap.common.message.ScopeEnum ;
-import org.apache.ldap.common.filter.PresenceNode ;
-import org.apache.ldap.common.message.MessageEncoder ;
-import org.apache.ldap.common.message.AddRequestImpl ;
-import org.apache.ldap.common.message.BindRequestImpl ;
-import org.apache.ldap.common.message.DerefAliasesEnum ;
-import org.apache.ldap.common.message.DeleteRequestImpl ;
-import org.apache.ldap.common.message.SearchRequestImpl ;
-import org.apache.ldap.common.message.ModifyRequestImpl ;
-import org.apache.ldap.common.message.AbandonRequestImpl ;
-import org.apache.ldap.common.message.CompareRequestImpl ;
-import org.apache.ldap.common.message.ExtendedRequestImpl ;
-import org.apache.ldap.common.message.ModifyDnRequestImpl ;
-import org.apache.ldap.common.message.LockableAttributesImpl ;
-import org.apache.snickers.ber.TupleNode;
-import org.apache.snickers.ber.TupleTreeDecoder;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests the SnickersDecoder.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class SnickersDecoderTest extends TestCase 
-    implements DecoderCallback, DecoderMonitor
-{
-    private SnickersDecoder decoder = null ;
-    private ArrayList msgList = new ArrayList() ;
-    
-    
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        
-        decoder = new SnickersDecoder( this ) ;
-        decoder.setDecoderMonitor( this ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-
-        msgList.clear() ;
-        decoder = null ;
-    }
-    
-    
-    /*
-     * Class to test for Message decode(TupleNode)
-     */
-    public void testDecodeTupleNode() throws Exception
-    {
-        TupleNode node = null ;
-        
-        AddRequestImpl request = new AddRequestImpl( BigInteger.ONE ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        
-        Attributes attrs = new LockableAttributesImpl() ;
-        attrs.put( "attr0", "val0" ) ;
-        attrs.put( "attr0", "val1" ) ;
-        attrs.put( "attr0", "val2" ) ;
-        attrs.put( "attr1", "val0" ) ;
-        attrs.put( "attr2", "val0" ) ;
-        attrs.put( "attr2", "val1" ) ;
-        
-        request.setEntry( attrs ) ;
-        MessageEncoder encoder = new MessageEncoder() ;
-        byte[] bites = encoder.encode( request ) ;
-        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
-        TupleTreeDecoder ttd = new TupleTreeDecoder() ;
-        
-        final ArrayList list = new ArrayList() ;
-        ttd.setCallback( new DecoderCallback(){
-            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
-            {
-                list.add( arg1 ) ;
-            }}) ;
-
-        ttd.decode( buf ) ;
-        node = ( TupleNode ) list.get( 0 ) ;
-        Message msg = decoder.decode( node ) ;
-        assertNotNull( msg ) ;
-    }
-    
-
-    public void decode( Message msg ) throws Exception
-    {
-        MessageEncoder encoder = new MessageEncoder() ;
-        ByteBuffer buf = ByteBuffer.wrap( encoder.encode( msg ) ) ;
-        decoder.decode( buf ) ;
-    }
-    
-
-    public void testBindMessage() throws Exception
-    {
-        BindRequestImpl request = new BindRequestImpl( BigInteger.ONE ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setSimple( true ) ;
-        request.setCredentials( "password".getBytes() ) ;
-        request.setVersion3( true ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-
-    public void testAddMessage() throws Exception
-    {
-        AddRequestImpl request = new AddRequestImpl( BigInteger.ONE ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        
-        Attributes attrs = new LockableAttributesImpl() ;
-        attrs.put( "attr0", "val0" ) ;
-        attrs.put( "attr0", "val1" ) ;
-        attrs.put( "attr0", "val2" ) ;
-        attrs.put( "attr1", "val0" ) ;
-        attrs.put( "attr2", "val0" ) ;
-        attrs.put( "attr2", "val1" ) ;
-        
-        request.setEntry( attrs ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-
-    public void testDeleteMessage() throws Exception
-    {
-        DeleteRequestImpl request = new DeleteRequestImpl( BigInteger.ONE ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-
-    public void testAbandonMessage() throws Exception
-    {
-        AbandonRequestImpl request = new AbandonRequestImpl( BigInteger.ONE ) ;
-        request.setAbandoned( new BigInteger( "3" ) ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-
-    public void testCompareMessage() throws Exception
-    {
-        CompareRequestImpl request = new CompareRequestImpl( BigInteger.ONE ) ;
-        request.setAssertionValue( "testvalue" ) ;
-        request.setAttributeId( "testattr" ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-
-    public void testExtendedMessage() throws Exception
-    {
-        ExtendedRequestImpl request = new ExtendedRequestImpl( BigInteger.ONE ) ;
-        request.setOid( "1234.1234.1324" ) ;
-        request.setPayload( "Hello World".getBytes() ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-
-    public void testModifyDnMessage() throws Exception
-    {
-        ModifyDnRequestImpl request = new ModifyDnRequestImpl( BigInteger.ONE ) ;
-        request.setDeleteOldRdn(true) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setNewRdn( "uid=aok" ) ;
-        request.setNewSuperior( "dc=example,dc=com" ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-
-    public void testModifyMessage() throws Exception
-    {
-        ModifyRequestImpl request = new ModifyRequestImpl( BigInteger.ONE ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-
-    public void testSearchMessage() throws Exception
-    {
-        SearchRequestImpl request = new SearchRequestImpl( BigInteger.ONE ) ;
-        request.setBase( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setDerefAliases( DerefAliasesEnum.DEREFALWAYS ) ;
-        PresenceNode node = new PresenceNode( "attrib0" ) ;
-        request.setFilter( node ) ;
-        request.setScope( ScopeEnum.BASEOBJECT ) ;
-        request.setSizeLimit( BigInteger.ZERO ) ;
-        request.setTimeLimit( BigInteger.ZERO ) ;
-        decode( request ) ;
-        assertFalse( msgList.isEmpty() ) ;
-    }
-
-    
-    public void testSetCallback()
-    {
-        decoder.setCallback( this ) ;
-    }
-    
-
-    public void testSetDecoderMonitor()
-    {
-        decoder.setDecoderMonitor( this ) ;
-        assertNotNull( decoder ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
-     */
-    public void decodeOccurred( StatefulDecoder arg0, Object message )
-    {
-        msgList.add( message ) ;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackOccured(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderCallback, java.lang.Object)
-     */
-    public void callbackOccured( StatefulDecoder decoder, DecoderCallback cb,
-            Object decoded )
-    {
-        assertSame( decoder, this.decoder ) ;
-        assertSame( this, cb ) ;
-        assertNotNull( decoded ) ;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackSet(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderCallback, 
-     * org.apache.commons.codec.stateful.DecoderCallback)
-     */
-    public void callbackSet( StatefulDecoder decoder, DecoderCallback cb,
-            DecoderCallback ncb )
-    {
-        assertSame(this.decoder, decoder) ;
-        assertNotNull(cb) ;
-        assertNotNull(ncb) ;
-    } 
-
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#error(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void error( StatefulDecoder decoder, Exception e )
-    {
-        assertSame( decoder, this.decoder ) ;
-        assertNotNull( e ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#fatalError(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void fatalError( StatefulDecoder decoder, Exception e )
-    {
-        assertSame( decoder, this.decoder ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#monitorSet(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderMonitor)
-     */
-    public void monitorSet( StatefulDecoder decoder, DecoderMonitor monitor )
-    {
-        assertSame( decoder, this.decoder ) ;
-        assertNotNull( monitor ) ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#warning(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void warning( StatefulDecoder decoder, Exception e )
-    {
-        assertSame( this.decoder, decoder ) ;
-        assertNotNull( e ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers ;
+
+
+import java.util.ArrayList ;
+
+import java.math.BigInteger ;
+
+import java.nio.ByteBuffer ;
+
+import javax.naming.directory.Attributes ;
+
+import org.apache.commons.codec.stateful.DecoderMonitor ;
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+
+import org.apache.ldap.common.message.Message ;
+import org.apache.ldap.common.message.ScopeEnum ;
+import org.apache.ldap.common.filter.PresenceNode ;
+import org.apache.ldap.common.message.MessageEncoder ;
+import org.apache.ldap.common.message.AddRequestImpl ;
+import org.apache.ldap.common.message.BindRequestImpl ;
+import org.apache.ldap.common.message.DerefAliasesEnum ;
+import org.apache.ldap.common.message.DeleteRequestImpl ;
+import org.apache.ldap.common.message.SearchRequestImpl ;
+import org.apache.ldap.common.message.ModifyRequestImpl ;
+import org.apache.ldap.common.message.AbandonRequestImpl ;
+import org.apache.ldap.common.message.CompareRequestImpl ;
+import org.apache.ldap.common.message.ExtendedRequestImpl ;
+import org.apache.ldap.common.message.ModifyDnRequestImpl ;
+import org.apache.ldap.common.message.LockableAttributesImpl ;
+import org.apache.snickers.ber.TupleNode;
+import org.apache.snickers.ber.TupleTreeDecoder;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests the SnickersDecoder.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SnickersDecoderTest extends TestCase 
+    implements DecoderCallback, DecoderMonitor
+{
+    private SnickersDecoder decoder = null ;
+    private ArrayList msgList = new ArrayList() ;
+    
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        
+        decoder = new SnickersDecoder( this ) ;
+        decoder.setDecoderMonitor( this ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+
+        msgList.clear() ;
+        decoder = null ;
+    }
+    
+    
+    /*
+     * Class to test for Message decode(TupleNode)
+     */
+    public void testDecodeTupleNode() throws Exception
+    {
+        TupleNode node = null ;
+        
+        AddRequestImpl request = new AddRequestImpl( BigInteger.ONE ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        
+        Attributes attrs = new LockableAttributesImpl() ;
+        attrs.put( "attr0", "val0" ) ;
+        attrs.put( "attr0", "val1" ) ;
+        attrs.put( "attr0", "val2" ) ;
+        attrs.put( "attr1", "val0" ) ;
+        attrs.put( "attr2", "val0" ) ;
+        attrs.put( "attr2", "val1" ) ;
+        
+        request.setEntry( attrs ) ;
+        MessageEncoder encoder = new MessageEncoder() ;
+        byte[] bites = encoder.encode( request ) ;
+        ByteBuffer buf = ByteBuffer.wrap( bites ) ;
+        TupleTreeDecoder ttd = new TupleTreeDecoder() ;
+        
+        final ArrayList list = new ArrayList() ;
+        ttd.setCallback( new DecoderCallback(){
+            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
+            {
+                list.add( arg1 ) ;
+            }}) ;
+
+        ttd.decode( buf ) ;
+        node = ( TupleNode ) list.get( 0 ) ;
+        Message msg = decoder.decode( node ) ;
+        assertNotNull( msg ) ;
+    }
+    
+
+    public void decode( Message msg ) throws Exception
+    {
+        MessageEncoder encoder = new MessageEncoder() ;
+        ByteBuffer buf = ByteBuffer.wrap( encoder.encode( msg ) ) ;
+        decoder.decode( buf ) ;
+    }
+    
+
+    public void testBindMessage() throws Exception
+    {
+        BindRequestImpl request = new BindRequestImpl( BigInteger.ONE ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        request.setSimple( true ) ;
+        request.setCredentials( "password".getBytes() ) ;
+        request.setVersion3( true ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+
+    public void testAddMessage() throws Exception
+    {
+        AddRequestImpl request = new AddRequestImpl( BigInteger.ONE ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        
+        Attributes attrs = new LockableAttributesImpl() ;
+        attrs.put( "attr0", "val0" ) ;
+        attrs.put( "attr0", "val1" ) ;
+        attrs.put( "attr0", "val2" ) ;
+        attrs.put( "attr1", "val0" ) ;
+        attrs.put( "attr2", "val0" ) ;
+        attrs.put( "attr2", "val1" ) ;
+        
+        request.setEntry( attrs ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+
+    public void testDeleteMessage() throws Exception
+    {
+        DeleteRequestImpl request = new DeleteRequestImpl( BigInteger.ONE ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+
+    public void testAbandonMessage() throws Exception
+    {
+        AbandonRequestImpl request = new AbandonRequestImpl( BigInteger.ONE ) ;
+        request.setAbandoned( new BigInteger( "3" ) ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+
+    public void testCompareMessage() throws Exception
+    {
+        CompareRequestImpl request = new CompareRequestImpl( BigInteger.ONE ) ;
+        request.setAssertionValue( "testvalue" ) ;
+        request.setAttributeId( "testattr" ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+
+    public void testExtendedMessage() throws Exception
+    {
+        ExtendedRequestImpl request = new ExtendedRequestImpl( BigInteger.ONE ) ;
+        request.setOid( "1234.1234.1324" ) ;
+        request.setPayload( "Hello World".getBytes() ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+
+    public void testModifyDnMessage() throws Exception
+    {
+        ModifyDnRequestImpl request = new ModifyDnRequestImpl( BigInteger.ONE ) ;
+        request.setDeleteOldRdn(true) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        request.setNewRdn( "uid=aok" ) ;
+        request.setNewSuperior( "dc=example,dc=com" ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+
+    public void testModifyMessage() throws Exception
+    {
+        ModifyRequestImpl request = new ModifyRequestImpl( BigInteger.ONE ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+
+    public void testSearchMessage() throws Exception
+    {
+        SearchRequestImpl request = new SearchRequestImpl( BigInteger.ONE ) ;
+        request.setBase( "uid=akarasulu,dc=example,dc=com" ) ;
+        request.setDerefAliases( DerefAliasesEnum.DEREFALWAYS ) ;
+        PresenceNode node = new PresenceNode( "attrib0" ) ;
+        request.setFilter( node ) ;
+        request.setScope( ScopeEnum.BASEOBJECT ) ;
+        request.setSizeLimit( BigInteger.ZERO ) ;
+        request.setTimeLimit( BigInteger.ZERO ) ;
+        decode( request ) ;
+        assertFalse( msgList.isEmpty() ) ;
+    }
+
+    
+    public void testSetCallback()
+    {
+        decoder.setCallback( this ) ;
+    }
+    
+
+    public void testSetDecoderMonitor()
+    {
+        decoder.setDecoderMonitor( this ) ;
+        assertNotNull( decoder ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
+     */
+    public void decodeOccurred( StatefulDecoder arg0, Object message )
+    {
+        msgList.add( message ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackOccured(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderCallback, java.lang.Object)
+     */
+    public void callbackOccured( StatefulDecoder decoder, DecoderCallback cb,
+            Object decoded )
+    {
+        assertSame( decoder, this.decoder ) ;
+        assertSame( this, cb ) ;
+        assertNotNull( decoded ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackSet(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderCallback, 
+     * org.apache.commons.codec.stateful.DecoderCallback)
+     */
+    public void callbackSet( StatefulDecoder decoder, DecoderCallback cb,
+            DecoderCallback ncb )
+    {
+        assertSame(this.decoder, decoder) ;
+        assertNotNull(cb) ;
+        assertNotNull(ncb) ;
+    } 
+
+
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#error(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void error( StatefulDecoder decoder, Exception e )
+    {
+        assertSame( decoder, this.decoder ) ;
+        assertNotNull( e ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#fatalError(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void fatalError( StatefulDecoder decoder, Exception e )
+    {
+        assertSame( decoder, this.decoder ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#monitorSet(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderMonitor)
+     */
+    public void monitorSet( StatefulDecoder decoder, DecoderMonitor monitor )
+    {
+        assertSame( decoder, this.decoder ) ;
+        assertNotNull( monitor ) ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#warning(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void warning( StatefulDecoder decoder, Exception e )
+    {
+        assertSame( this.decoder, decoder ) ;
+        assertNotNull( e ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/asn/TestBitString.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/asn/TestBitString.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/asn/TestBitString.java	Sun Mar 14 14:02:18 2004
@@ -1,242 +1,242 @@
-/*
-
- ============================================================================
-                   The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of  source code must  retain the above copyright  notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
-    include  the following  acknowledgment:  "This product includes  software
-    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
-    Alternately, this  acknowledgment may  appear in the software itself,  if
-    and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
-    and "Apache Software Foundation"  must not be used to endorse or promote
-    products derived  from this  software without  prior written
-    permission. For written permission, please contact apache@apache.org.
-
- 5. Products  derived from this software may not  be called "Apache", nor may
-    "Apache" appear  in their name,  without prior written permission  of the
-    Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
- (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software  consists of voluntary contributions made  by many individuals
- on  behalf of the Apache Software  Foundation. For more  information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-
-package org.apache.snickers.asn;
-
-import java.util.BitSet;
-import junit.framework.TestCase;
-import org.apache.commons.codec.binary.Binary;
-import org.apache.snickers.asn.BitString;
-
-/**
- * @author Wes McKean
- *
- * Test the BitString class
- */
-public class TestBitString extends TestCase {
-
-    String binary[] = {
-        "1",
-        "10",
-        "100",
-        "1000",
-        "10000",
-        "100000",
-        "1000000",
-        "10000000"
-    };
-    
-	/**
-	 * @param name the test to run
-	 */
-	public TestBitString(String name) {
-		super(name);
-	}
-
-    /**
-     * Run a simple test of the bits in <code>Binary</code>
-     * 
-     * @throws Exception if an error occurs
-     */
-    public void testSimpleBinary() throws Exception {
-        int vals[] = {
-            Binary.BIT_0,
-            Binary.BIT_1,
-            Binary.BIT_2,
-            Binary.BIT_3,
-            Binary.BIT_4,
-            Binary.BIT_5,
-            Binary.BIT_6,
-            Binary.BIT_7
-        };
-        
-        for( int i = 0; i < vals.length; i++ ) {
-            int[] tmp = new int[1];
-            tmp[0] = vals[i];
-            BitString bs = new BitString( tmp,8 );
-            BitSet bset = bs;
-            // System.out.println( "\n" + bs.toString());
-            // System.out.println( bset.toString() );
-            assertTrue( "testSimpleBinary:" + binary[i], bs.toString().equals(binary[i]));
-        }
-    }
-    
-    /**
-     * A test for more complicated bit patterns.  Nothing fancy yet.
-     * 
-     * @throws Exception
-     */
-    public void testComplicated() throws Exception {
-        int []tmp;
-        
-        // First test.  1 int with various bits set
-        tmp = new int[1];
-        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
-        
-        BitString bs = new BitString( tmp, 16 ); 
-        BitSet bset = bs;
-        //System.out.println( "\n" + bs.toString() );
-        //System.out.println( bset.toString() );
-        assertTrue( "testComplicated:1", bs.toString().equals("1000100000001110") );
-        
-        // Lets do a 24 bit bit string. 
-        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 16 ) | ((Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 )<<8) |
-                    (Binary.BIT_6 | Binary.BIT_0);
-        bs = new BitString( tmp, 24 ); 
-        //System.out.println( "\n" + bs.toString() );
-        bset = bs;
-        //System.out.println( bset.toString() );
-        assertTrue( "testComplicated:2", bs.toString().equals("100010000000111001000001") );
-        
-        // Lets do a 32 bit string
-        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 24 ) | ((Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 )<<16) |
-                    ((Binary.BIT_6 | Binary.BIT_0) << 8 ) | (Binary.BIT_5 | Binary.BIT_0 | Binary.BIT_1 | Binary.BIT_3 );
-        bs = new BitString( tmp, 32 );
-        //System.out.println( "\n" + bs.toString() );
-        bset = bs; 
-        //System.out.println( bset );
-        assertTrue( "testComplicated:3", bs.toString().equals("10001000000011100100000100101011") );
-        
-        // Now for the real test.  2 ints (64 bit strings)
-        tmp = new int[2];        
-        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 24 ) | ((Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 )<<16) |
-                    ((Binary.BIT_6 | Binary.BIT_0) << 8 ) | (Binary.BIT_5 | Binary.BIT_0 | Binary.BIT_1 | Binary.BIT_3 );
-                    
-        tmp[1] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
-        bs = new BitString( tmp,48 );
-        //System.out.println( "\n" + bs.toString() );
-        assertTrue( "testComplicated:4", bs.toString().equals("100010000000111010001000000011100100000100101011") );
-    }
-
-    /**
-     *  Execute some simple 32-bit tests
-     */    
-    public void testAnd() throws Exception {
-        // First test.  1 int with various bits set
-        int[] tmp = new int[1];
-        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
-        
-        int[] tmp2 = new int[1];
-        tmp2[0] = (( Binary.BIT_7 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_5 );
-        
-        BitString bs1 = new BitString( tmp, 16 );
-        BitString bs2 = new BitString( tmp2, 16 );
-        BitString delta = bs1.and(bs2);
-        
-        //System.out.println( "\n" + bs1.toString() );
-        //System.out.println( bs2.toString() );
-        //System.out.println( delta.toString() );
-        
-        //     1000100000001110
-        // AND 1000000000000110
-        //     ----------------
-        //     1000000000000110        
-        
-        assertTrue( "testAnd", delta.toString().equals("1000000000000110"));
-    }
-
-    /**
-     *  Execute some simple 32-bit tests
-     */    
-    public void testOr() throws Exception {
-        // First test.  1 int with various bits set
-        int[] tmp = new int[1];
-        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
-        
-        int[] tmp2 = new int[1];
-        tmp2[0] = (( Binary.BIT_7 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_5 );
-        
-        BitString bs1 = new BitString( tmp, 16 );
-        BitString bs2 = new BitString( tmp2, 16 );
-        BitString delta = bs1.or(bs2);
-        
-        //System.out.println( "\n" + bs1.toString() );
-        //System.out.println( bs2.toString() );
-        //System.out.println( delta.toString() );
-        
-        //     1000100000001110
-        //  OR 1000000000100110
-        //     ----------------
-        //     1000100000101110        
-        
-        assertTrue( "testOr", delta.toString().equals("1000100000101110"));
-    }
-
-    /**
-     *  Execute some simple 32-bit tests
-     */    
-    public void testXor() throws Exception {
-        // First test.  1 int with various bits set
-        int[] tmp = new int[1];
-        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
-        
-        int[] tmp2 = new int[1];
-        tmp2[0] = (( Binary.BIT_7 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_5 );
-        
-        BitString bs1 = new BitString( tmp, 16 );
-        BitString bs2 = new BitString( tmp2, 16 );
-        BitString delta = bs1.xor(bs2);
-        
-        //System.out.println( "\n" + bs1.toString() );
-        //System.out.println( bs2.toString() );
-        //System.out.println( delta.toString() );
-        
-        //     1000100000001110
-        // XOR 1000000000100110
-        //     ----------------
-        //     0000100000101000        
-        
-        assertTrue( "testXor", delta.toString().equals("100000101000"));
-    }
-    
-	public static void main(String[] args) {
-        junit.textui.TestRunner.run( TestBitString.class );
-	}
-}
+/*
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve" 
+    and "Apache Software Foundation"  must not be used to endorse or promote
+    products derived  from this  software without  prior written
+    permission. For written permission, please contact apache@apache.org.
+
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation. For more  information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+
+package org.apache.snickers.asn;
+
+import java.util.BitSet;
+import junit.framework.TestCase;
+import org.apache.commons.codec.binary.Binary;
+import org.apache.snickers.asn.BitString;
+
+/**
+ * @author Wes McKean
+ *
+ * Test the BitString class
+ */
+public class TestBitString extends TestCase {
+
+    String binary[] = {
+        "1",
+        "10",
+        "100",
+        "1000",
+        "10000",
+        "100000",
+        "1000000",
+        "10000000"
+    };
+    
+	/**
+	 * @param name the test to run
+	 */
+	public TestBitString(String name) {
+		super(name);
+	}
+
+    /**
+     * Run a simple test of the bits in <code>Binary</code>
+     * 
+     * @throws Exception if an error occurs
+     */
+    public void testSimpleBinary() throws Exception {
+        int vals[] = {
+            Binary.BIT_0,
+            Binary.BIT_1,
+            Binary.BIT_2,
+            Binary.BIT_3,
+            Binary.BIT_4,
+            Binary.BIT_5,
+            Binary.BIT_6,
+            Binary.BIT_7
+        };
+        
+        for( int i = 0; i < vals.length; i++ ) {
+            int[] tmp = new int[1];
+            tmp[0] = vals[i];
+            BitString bs = new BitString( tmp,8 );
+            BitSet bset = bs;
+            // System.out.println( "\n" + bs.toString());
+            // System.out.println( bset.toString() );
+            assertTrue( "testSimpleBinary:" + binary[i], bs.toString().equals(binary[i]));
+        }
+    }
+    
+    /**
+     * A test for more complicated bit patterns.  Nothing fancy yet.
+     * 
+     * @throws Exception
+     */
+    public void testComplicated() throws Exception {
+        int []tmp;
+        
+        // First test.  1 int with various bits set
+        tmp = new int[1];
+        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
+        
+        BitString bs = new BitString( tmp, 16 ); 
+        BitSet bset = bs;
+        //System.out.println( "\n" + bs.toString() );
+        //System.out.println( bset.toString() );
+        assertTrue( "testComplicated:1", bs.toString().equals("1000100000001110") );
+        
+        // Lets do a 24 bit bit string. 
+        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 16 ) | ((Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 )<<8) |
+                    (Binary.BIT_6 | Binary.BIT_0);
+        bs = new BitString( tmp, 24 ); 
+        //System.out.println( "\n" + bs.toString() );
+        bset = bs;
+        //System.out.println( bset.toString() );
+        assertTrue( "testComplicated:2", bs.toString().equals("100010000000111001000001") );
+        
+        // Lets do a 32 bit string
+        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 24 ) | ((Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 )<<16) |
+                    ((Binary.BIT_6 | Binary.BIT_0) << 8 ) | (Binary.BIT_5 | Binary.BIT_0 | Binary.BIT_1 | Binary.BIT_3 );
+        bs = new BitString( tmp, 32 );
+        //System.out.println( "\n" + bs.toString() );
+        bset = bs; 
+        //System.out.println( bset );
+        assertTrue( "testComplicated:3", bs.toString().equals("10001000000011100100000100101011") );
+        
+        // Now for the real test.  2 ints (64 bit strings)
+        tmp = new int[2];        
+        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 24 ) | ((Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 )<<16) |
+                    ((Binary.BIT_6 | Binary.BIT_0) << 8 ) | (Binary.BIT_5 | Binary.BIT_0 | Binary.BIT_1 | Binary.BIT_3 );
+                    
+        tmp[1] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
+        bs = new BitString( tmp,48 );
+        //System.out.println( "\n" + bs.toString() );
+        assertTrue( "testComplicated:4", bs.toString().equals("100010000000111010001000000011100100000100101011") );
+    }
+
+    /**
+     *  Execute some simple 32-bit tests
+     */    
+    public void testAnd() throws Exception {
+        // First test.  1 int with various bits set
+        int[] tmp = new int[1];
+        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
+        
+        int[] tmp2 = new int[1];
+        tmp2[0] = (( Binary.BIT_7 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_5 );
+        
+        BitString bs1 = new BitString( tmp, 16 );
+        BitString bs2 = new BitString( tmp2, 16 );
+        BitString delta = bs1.and(bs2);
+        
+        //System.out.println( "\n" + bs1.toString() );
+        //System.out.println( bs2.toString() );
+        //System.out.println( delta.toString() );
+        
+        //     1000100000001110
+        // AND 1000000000000110
+        //     ----------------
+        //     1000000000000110        
+        
+        assertTrue( "testAnd", delta.toString().equals("1000000000000110"));
+    }
+
+    /**
+     *  Execute some simple 32-bit tests
+     */    
+    public void testOr() throws Exception {
+        // First test.  1 int with various bits set
+        int[] tmp = new int[1];
+        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
+        
+        int[] tmp2 = new int[1];
+        tmp2[0] = (( Binary.BIT_7 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_5 );
+        
+        BitString bs1 = new BitString( tmp, 16 );
+        BitString bs2 = new BitString( tmp2, 16 );
+        BitString delta = bs1.or(bs2);
+        
+        //System.out.println( "\n" + bs1.toString() );
+        //System.out.println( bs2.toString() );
+        //System.out.println( delta.toString() );
+        
+        //     1000100000001110
+        //  OR 1000000000100110
+        //     ----------------
+        //     1000100000101110        
+        
+        assertTrue( "testOr", delta.toString().equals("1000100000101110"));
+    }
+
+    /**
+     *  Execute some simple 32-bit tests
+     */    
+    public void testXor() throws Exception {
+        // First test.  1 int with various bits set
+        int[] tmp = new int[1];
+        tmp[0] = (( Binary.BIT_7 | Binary.BIT_3 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_3 );
+        
+        int[] tmp2 = new int[1];
+        tmp2[0] = (( Binary.BIT_7 ) << 8 ) | (Binary.BIT_1 | Binary.BIT_2 | Binary.BIT_5 );
+        
+        BitString bs1 = new BitString( tmp, 16 );
+        BitString bs2 = new BitString( tmp2, 16 );
+        BitString delta = bs1.xor(bs2);
+        
+        //System.out.println( "\n" + bs1.toString() );
+        //System.out.println( bs2.toString() );
+        //System.out.println( delta.toString() );
+        
+        //     1000100000001110
+        // XOR 1000000000100110
+        //     ----------------
+        //     0000100000101000        
+        
+        assertTrue( "testXor", delta.toString().equals("100000101000"));
+    }
+    
+	public static void main(String[] args) {
+        junit.textui.TestRunner.run( TestBitString.class );
+	}
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/AbstractDecoderTestCaseTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/AbstractDecoderTestCaseTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/AbstractDecoderTestCaseTest.java	Sun Mar 14 14:02:18 2004
@@ -1,137 +1,137 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import org.apache.commons.lang.ArrayUtils ;
-
-
-/**
- * Tests the base test class functions.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class AbstractDecoderTestCaseTest extends AbstractDecoderTestCase
-{
-    
-    public AbstractDecoderTestCaseTest()
-    {
-        super ( AbstractDecoderTestCaseTest.class.getName() ) ; 
-    }
-
-    public void testFragment()
-    {
-        byte[] all = new byte[3] ;
-        assertEquals( 1, fragment(all, 3).length) ;
-        try
-        {
-            fragment(ArrayUtils.EMPTY_BYTE_ARRAY, 0) ;
-            fail( "should have thrown exception before reaching this line" ) ;
-        }
-        catch( IllegalArgumentException e )
-        {
-            assertNotNull( e ) ;
-        }
-    }
-
-    /*
-     * Class to test for Tuple decode(byte)
-     */
-    public void testDecodebyte() throws Exception
-    {
-        decode( ( byte ) 1 ) ;
-        decode( ( byte ) 1 ) ;
-        Tuple t = decode( ( byte ) 1 ) ;
-        assertEquals( 1, t.id ) ;
-        assertEquals( 1, t.length ) ;
-    }
-
-    /*
-     * Class to test for Tuple decode(Tuple[])
-     */
-    public void testDecodeTupleArray() throws Exception
-    {
-        Tuple [] tuples = new Tuple[2] ;
-        tuples[0] = new Tuple(1, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        tuples[1] = new Tuple(1, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        decode(tuples) ;
-        
-        decode( new Tuple[0] ) ;
-    }
-
-    public void testCallbackOccured() throws Exception
-    {
-        decoder.setDecoderMonitor( this ) ;
-        Tuple [] tuples = new Tuple[2] ;
-        tuples[0] = new Tuple(1, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        tuples[1] = new Tuple(1, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        decode(tuples) ;
-        callbackOccured(decoder, this, tuples[1]) ;
-    }
-
-    public void testCallbackSet()
-    {
-        decoder.setCallback(this) ;
-        callbackSet(decoder, this, this) ;
-    }
-
-    public void testError()
-    {
-        try
-        {
-            error( decoder, new Exception() ) ;
-            fail("should not get here") ;
-        }
-        catch ( Throwable e )
-        {
-            assertNotNull( e ) ;
-        }
-    }
-
-    public void testFatalError()
-    {
-        try
-        {
-            fatalError( decoder, new Exception() ) ;
-            fail("should not get here") ;
-        }
-        catch ( Throwable e )
-        {
-            assertNotNull( e ) ;
-        }
-    }
-
-    public void testMonitorSet()
-    {
-        monitorSet( decoder, this ) ;
-    }
-
-    public void testWarning()
-    {
-        try
-        {
-            warning( decoder, new Exception() ) ;
-            fail("should not get here") ;
-        }
-        catch ( Throwable e )
-        {
-            assertNotNull( e ) ;
-        }
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.lang.ArrayUtils ;
+
+
+/**
+ * Tests the base test class functions.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AbstractDecoderTestCaseTest extends AbstractDecoderTestCase
+{
+    
+    public AbstractDecoderTestCaseTest()
+    {
+        super ( AbstractDecoderTestCaseTest.class.getName() ) ; 
+    }
+
+    public void testFragment()
+    {
+        byte[] all = new byte[3] ;
+        assertEquals( 1, fragment(all, 3).length) ;
+        try
+        {
+            fragment(ArrayUtils.EMPTY_BYTE_ARRAY, 0) ;
+            fail( "should have thrown exception before reaching this line" ) ;
+        }
+        catch( IllegalArgumentException e )
+        {
+            assertNotNull( e ) ;
+        }
+    }
+
+    /*
+     * Class to test for Tuple decode(byte)
+     */
+    public void testDecodebyte() throws Exception
+    {
+        decode( ( byte ) 1 ) ;
+        decode( ( byte ) 1 ) ;
+        Tuple t = decode( ( byte ) 1 ) ;
+        assertEquals( 1, t.id ) ;
+        assertEquals( 1, t.length ) ;
+    }
+
+    /*
+     * Class to test for Tuple decode(Tuple[])
+     */
+    public void testDecodeTupleArray() throws Exception
+    {
+        Tuple [] tuples = new Tuple[2] ;
+        tuples[0] = new Tuple(1, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        tuples[1] = new Tuple(1, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        decode(tuples) ;
+        
+        decode( new Tuple[0] ) ;
+    }
+
+    public void testCallbackOccured() throws Exception
+    {
+        decoder.setDecoderMonitor( this ) ;
+        Tuple [] tuples = new Tuple[2] ;
+        tuples[0] = new Tuple(1, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        tuples[1] = new Tuple(1, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        decode(tuples) ;
+        callbackOccured(decoder, this, tuples[1]) ;
+    }
+
+    public void testCallbackSet()
+    {
+        decoder.setCallback(this) ;
+        callbackSet(decoder, this, this) ;
+    }
+
+    public void testError()
+    {
+        try
+        {
+            error( decoder, new Exception() ) ;
+            fail("should not get here") ;
+        }
+        catch ( Throwable e )
+        {
+            assertNotNull( e ) ;
+        }
+    }
+
+    public void testFatalError()
+    {
+        try
+        {
+            fatalError( decoder, new Exception() ) ;
+            fail("should not get here") ;
+        }
+        catch ( Throwable e )
+        {
+            assertNotNull( e ) ;
+        }
+    }
+
+    public void testMonitorSet()
+    {
+        monitorSet( decoder, this ) ;
+    }
+
+    public void testWarning()
+    {
+        try
+        {
+            warning( decoder, new Exception() ) ;
+            fail("should not get here") ;
+        }
+        catch ( Throwable e )
+        {
+            assertNotNull( e ) ;
+        }
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderCallbackAdapterTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderCallbackAdapterTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderCallbackAdapterTest.java	Sun Mar 14 14:02:18 2004
@@ -1,82 +1,82 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests for the adapter to pass clover coverage.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class BERDecoderCallbackAdapterTest extends TestCase
-{
-    BERDecoderCallbackAdapter adapter = null ;
-    
-
-    public static void main(String[] args)
-    {
-        junit.textui.TestRunner.run(BERDecoderCallbackAdapterTest.class);
-    }
-
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        adapter = new BERDecoderCallbackAdapter() ;
-    }
-
-    /*
-     * @see TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-        adapter = null ;
-    }
-
-    /**
-     * Constructor for BERDecoderCallbackAdapter.
-     * @param arg0
-     */
-    public BERDecoderCallbackAdapterTest(String arg0)
-    {
-        super(arg0);
-    }
-
-    public void testTagDecoded()
-    {
-        adapter.tagDecoded( null ) ;
-    }
-
-    public void testLengthDecoded()
-    {
-        adapter.lengthDecoded( null ) ;
-    }
-
-    public void testDecodeOccurred()
-    {
-        adapter.decodeOccurred( null, null ) ;
-    }
-
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests for the adapter to pass clover coverage.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BERDecoderCallbackAdapterTest extends TestCase
+{
+    BERDecoderCallbackAdapter adapter = null ;
+    
+
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(BERDecoderCallbackAdapterTest.class);
+    }
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        adapter = new BERDecoderCallbackAdapter() ;
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        adapter = null ;
+    }
+
+    /**
+     * Constructor for BERDecoderCallbackAdapter.
+     * @param arg0
+     */
+    public BERDecoderCallbackAdapterTest(String arg0)
+    {
+        super(arg0);
+    }
+
+    public void testTagDecoded()
+    {
+        adapter.tagDecoded( null ) ;
+    }
+
+    public void testLengthDecoded()
+    {
+        adapter.lengthDecoded( null ) ;
+    }
+
+    public void testDecodeOccurred()
+    {
+        adapter.decodeOccurred( null, null ) ;
+    }
+
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderStateTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderStateTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderStateTest.java	Sun Mar 14 14:02:18 2004
@@ -1,173 +1,173 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests the 
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class BERDecoderStateTest extends TestCase
-{
-
-    public static void main(String[] args)
-    {
-        junit.textui.TestRunner.run(BERDecoderStateTest.class);
-    }
-
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-
-    /*
-     * @see TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-
-    /**
-     * Constructor for BERDecoderStateTest.
-     * @param arg0
-     */
-    public BERDecoderStateTest(String arg0)
-    {
-        super(arg0);
-    }
-
-    public void testGetNext()
-    {
-        BERDecoderState state = BERDecoderState.getStartState() ;
-        
-        assertEquals( BERDecoderState.TAG, state ) ;
-        state = state.getNext( true ) ;
-        assertEquals( BERDecoderState.LENGTH, state ) ;
-        state = state.getNext( true ) ;
-        assertEquals( BERDecoderState.VALUE, state ) ;
-
-        state = state.getNext( true ) ;
-        assertEquals( BERDecoderState.TAG, state ) ;
-        state = state.getNext( true ) ;
-        assertEquals( BERDecoderState.LENGTH, state ) ;
-        state = state.getNext( false ) ;
-        assertEquals( BERDecoderState.TAG, state ) ;
-    }
-
-    public void testIsEndState()
-    {
-        assertFalse( BERDecoderState.TAG.isEndState( true ) ) ;
-        assertFalse( BERDecoderState.TAG.isEndState( false ) ) ;
-        assertFalse( BERDecoderState.LENGTH.isEndState( true ) ) ;
-        assertTrue( BERDecoderState.LENGTH.isEndState( false ) ) ;
-        assertTrue( BERDecoderState.VALUE.isEndState( true ) ) ;
-        assertTrue( BERDecoderState.VALUE.isEndState( false ) ) ;
-    }
-
-    public void testGetStartState()
-    {
-        assertEquals( BERDecoderState.TAG, BERDecoderState.getStartState() ) ;
-    }
-
-    /*
-     * Class to test for BERDecoderState getTypeClass(String)
-     */
-    public void testGetStateString()
-    {
-        assertEquals( BERDecoderState.LENGTH, 
-                BERDecoderState.getState(BERDecoderState.LENGTH.getName()) ) ;
-        assertEquals( BERDecoderState.TAG, 
-                BERDecoderState.getState(BERDecoderState.TAG.getName()) ) ;
-        assertEquals( BERDecoderState.VALUE, 
-                BERDecoderState.getState(BERDecoderState.VALUE.getName()) ) ;
-        
-        assertEquals( BERDecoderState.LENGTH, 
-                BERDecoderState.getState("length") ) ;
-        assertEquals( BERDecoderState.TAG, 
-                BERDecoderState.getState("TAG") ) ;
-        assertEquals( BERDecoderState.TAG, 
-                BERDecoderState.getState("Tag") ) ;
-        assertEquals( BERDecoderState.VALUE, 
-                BERDecoderState.getState("value") ) ;
-        
-        try
-        {
-            BERDecoderState.getState("asdf") ;
-            fail( "should not be reached due to thrown exception" ) ;
-        }
-        catch ( Throwable t )
-        {
-            assertNotNull( t ) ;
-        }
-    }
-
-    public void testList()
-    {
-        List list = BERDecoderState.list() ;
-        assertNotNull( list ) ;
-        assertEquals( 3, list.size() ) ;
-        assertTrue( list.contains( BERDecoderState.LENGTH ) ) ;
-        assertTrue( list.contains( BERDecoderState.TAG ) ) ;
-        assertTrue( list.contains( BERDecoderState.VALUE ) ) ;
-    }
-
-    public void testMap()
-    {
-        Map map = BERDecoderState.map() ;
-        assertNotNull( map ) ;
-        assertEquals( 3, map.size() ) ;
-        assertTrue( map.containsKey( BERDecoderState.VALUE.getName() ) ) ;
-        assertTrue( map.containsKey( BERDecoderState.LENGTH.getName() ) ) ;
-        assertTrue( map.containsKey( BERDecoderState.TAG.getName() ) ) ;
-    }
-
-    /*
-     * Class to test for BERDecoderState getTypeClass(int)
-     */
-    public void testGetStateint()
-    {
-        assertEquals( BERDecoderState.LENGTH, 
-                BERDecoderState.getState(BERDecoderState.LENGTH_VAL) ) ;
-        assertEquals( BERDecoderState.TAG, 
-                BERDecoderState.getState(BERDecoderState.TAG_VAL) ) ;
-        assertEquals( BERDecoderState.VALUE, 
-                BERDecoderState.getState(BERDecoderState.VALUE_VAL) ) ;
-        
-        try
-        {
-            BERDecoderState.getState( 293847 ) ;
-            fail( "should not be reached due to thrown exception" ) ;
-        }
-        catch ( Throwable t )
-        {
-            assertNotNull( t ) ;
-        }
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests the 
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BERDecoderStateTest extends TestCase
+{
+
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(BERDecoderStateTest.class);
+    }
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * Constructor for BERDecoderStateTest.
+     * @param arg0
+     */
+    public BERDecoderStateTest(String arg0)
+    {
+        super(arg0);
+    }
+
+    public void testGetNext()
+    {
+        BERDecoderState state = BERDecoderState.getStartState() ;
+        
+        assertEquals( BERDecoderState.TAG, state ) ;
+        state = state.getNext( true ) ;
+        assertEquals( BERDecoderState.LENGTH, state ) ;
+        state = state.getNext( true ) ;
+        assertEquals( BERDecoderState.VALUE, state ) ;
+
+        state = state.getNext( true ) ;
+        assertEquals( BERDecoderState.TAG, state ) ;
+        state = state.getNext( true ) ;
+        assertEquals( BERDecoderState.LENGTH, state ) ;
+        state = state.getNext( false ) ;
+        assertEquals( BERDecoderState.TAG, state ) ;
+    }
+
+    public void testIsEndState()
+    {
+        assertFalse( BERDecoderState.TAG.isEndState( true ) ) ;
+        assertFalse( BERDecoderState.TAG.isEndState( false ) ) ;
+        assertFalse( BERDecoderState.LENGTH.isEndState( true ) ) ;
+        assertTrue( BERDecoderState.LENGTH.isEndState( false ) ) ;
+        assertTrue( BERDecoderState.VALUE.isEndState( true ) ) ;
+        assertTrue( BERDecoderState.VALUE.isEndState( false ) ) ;
+    }
+
+    public void testGetStartState()
+    {
+        assertEquals( BERDecoderState.TAG, BERDecoderState.getStartState() ) ;
+    }
+
+    /*
+     * Class to test for BERDecoderState getTypeClass(String)
+     */
+    public void testGetStateString()
+    {
+        assertEquals( BERDecoderState.LENGTH, 
+                BERDecoderState.getState(BERDecoderState.LENGTH.getName()) ) ;
+        assertEquals( BERDecoderState.TAG, 
+                BERDecoderState.getState(BERDecoderState.TAG.getName()) ) ;
+        assertEquals( BERDecoderState.VALUE, 
+                BERDecoderState.getState(BERDecoderState.VALUE.getName()) ) ;
+        
+        assertEquals( BERDecoderState.LENGTH, 
+                BERDecoderState.getState("length") ) ;
+        assertEquals( BERDecoderState.TAG, 
+                BERDecoderState.getState("TAG") ) ;
+        assertEquals( BERDecoderState.TAG, 
+                BERDecoderState.getState("Tag") ) ;
+        assertEquals( BERDecoderState.VALUE, 
+                BERDecoderState.getState("value") ) ;
+        
+        try
+        {
+            BERDecoderState.getState("asdf") ;
+            fail( "should not be reached due to thrown exception" ) ;
+        }
+        catch ( Throwable t )
+        {
+            assertNotNull( t ) ;
+        }
+    }
+
+    public void testList()
+    {
+        List list = BERDecoderState.list() ;
+        assertNotNull( list ) ;
+        assertEquals( 3, list.size() ) ;
+        assertTrue( list.contains( BERDecoderState.LENGTH ) ) ;
+        assertTrue( list.contains( BERDecoderState.TAG ) ) ;
+        assertTrue( list.contains( BERDecoderState.VALUE ) ) ;
+    }
+
+    public void testMap()
+    {
+        Map map = BERDecoderState.map() ;
+        assertNotNull( map ) ;
+        assertEquals( 3, map.size() ) ;
+        assertTrue( map.containsKey( BERDecoderState.VALUE.getName() ) ) ;
+        assertTrue( map.containsKey( BERDecoderState.LENGTH.getName() ) ) ;
+        assertTrue( map.containsKey( BERDecoderState.TAG.getName() ) ) ;
+    }
+
+    /*
+     * Class to test for BERDecoderState getTypeClass(int)
+     */
+    public void testGetStateint()
+    {
+        assertEquals( BERDecoderState.LENGTH, 
+                BERDecoderState.getState(BERDecoderState.LENGTH_VAL) ) ;
+        assertEquals( BERDecoderState.TAG, 
+                BERDecoderState.getState(BERDecoderState.TAG_VAL) ) ;
+        assertEquals( BERDecoderState.VALUE, 
+                BERDecoderState.getState(BERDecoderState.VALUE_VAL) ) ;
+        
+        try
+        {
+            BERDecoderState.getState( 293847 ) ;
+            fail( "should not be reached due to thrown exception" ) ;
+        }
+        catch ( Throwable t )
+        {
+            assertNotNull( t ) ;
+        }
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERDecoderTest.java	Sun Mar 14 14:02:18 2004
@@ -1,156 +1,156 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.nio.ByteBuffer;
-
-import org.apache.commons.codec.stateful.DecoderMonitorAdapter;
-import org.apache.commons.lang.ArrayUtils ;
-import org.apache.commons.lang.RandomStringUtils ;
-
-
-/**
- * Tests the decoder using various complext TLV decoding scenarios and performs
- * round trip encode - decode functionality.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class BERDecoderTest extends AbstractDecoderTestCase
-{
-    public BERDecoderTest()
-    {
-        super( BERDecoderTest.class.getName() ) ;
-    }
-    
-    
-    public void testBasisCases() throws Exception
-    {
-        decoder.setDecoderMonitor( new DecoderMonitorAdapter() ) ;
-        decoder.decode( null ) ;
-        decoder.decode( ByteBuffer.wrap( ArrayUtils.EMPTY_BYTE_ARRAY ) ) ;
-    }
-    
-    
-    public void testPrimitives() throws Exception
-    {
-        byte[] bites = null ;
-        Tuple decoded = null ;
-        Tuple t = new Tuple( 45, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        assertTrue( decode( t ).equals( t ) ) ; 
-        
-        t = new Tuple( 45, "Hello world!".getBytes() ) ;
-        decoded = decode( t ) ;
-        assertTrue( decoded.equals( t ) ) ;
-        assertEquals( "Hello world!", new String( (byte[]) 
-                        decoded.getValue() ) ) ;
-
-        String mesg = RandomStringUtils.randomAlphanumeric(1000) ;
-        t = new Tuple( 1234233, mesg.getBytes() ) ;
-        decoded = decode( t ) ;
-        assertTrue( decoded.equals( t ) ) ;
-        assertEquals( mesg, new String( (byte[]) 
-                        decoded.getValue() ) ) ;
-    }
-    
-    
-    public void testConstructedIndefinate() throws Exception
-    {
-        Tuple top = new Tuple( 1, TypeClass.APPLICATION ) ;
-        Tuple t0 = new Tuple( 2, "Hello".getBytes() ) ;
-        Tuple t1 = new Tuple( 3, "World".getBytes() ) ;
-        Tuple terminator = new Tuple( 0, TypeClass.UNIVERSAL, true, 
-                ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        assertTrue( decode( top ).equals( top ) ) ;
-
-        Tuple decoded = decode( t0 ) ; 
-        assertTrue( decoded.equals( t0 ) ) ;
-        assertEquals( "Hello", new String( ( byte[] ) decoded.getValue() ) ) ;
-        
-        decoded = decode( t1 ) ; 
-        assertTrue( decoded.equals( t1 ) ) ;
-        assertEquals( "World", new String( ( byte[] ) decoded.getValue() ) ) ;
-        
-        decoded = decode( terminator ) ;
-        assertTrue( decoded.equals( top ) ) ;
-    }
-    
-    
-    public void testConstructedLongLengthForm() throws Exception
-    {
-        String str0 = RandomStringUtils.randomAlphanumeric(10000) ;
-        Tuple t0 = new Tuple( 2, str0.getBytes() ) ;
-        String str1 = RandomStringUtils.randomAlphanumeric(10000) ;
-        Tuple t1 = new Tuple( 3, str1.getBytes() ) ;
-        Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
-        assertTrue( decode( top ).equals( top ) ) ;
-
-        Tuple decoded = decode( t0 ) ; 
-        assertTrue( decoded.equals( t0 ) ) ;
-        assertEquals( str0, new String( ( byte[] ) decoded.getValue() ) ) ;
-        
-        // automatically set to top because after t1 is delivered top is 
-        decoded = decode( t1 ) ; 
-        assertTrue( decoded.equals( top ) ) ;
-    }
-
-
-    public void testConstructedShortLengthForm() throws Exception
-    {
-        Tuple t0 = new Tuple( 2, "Hello".getBytes() ) ;
-        Tuple t1 = new Tuple( 3, "World".getBytes() ) ;
-        Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
-        assertTrue( decode( top ).equals( top ) ) ;
-
-        Tuple decoded = decode( t0 ) ; 
-        assertTrue( decoded.equals( t0 ) ) ;
-        assertEquals( "Hello", new String( ( byte[] ) decoded.getValue() ) ) ;
-        
-        // automatically set to top because after t1 is delivered top is 
-        decoded = decode( t1 ) ; 
-        assertTrue( decoded.equals( top ) ) ;
-    }
-    
-    
-    public void testFragmentedValue() throws Exception
-    {
-        String str0 = RandomStringUtils.randomAlphanumeric(20) ;
-        Tuple t0 = new Tuple( 2, str0.getBytes() ) ;
-        String str1 = RandomStringUtils.randomAlphanumeric(20) ;
-        Tuple t1 = new Tuple( 3, str1.getBytes() ) ;
-        Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
-        assertTrue( decode( top ).equals( top ) ) ;
-
-        byte[] all = t0.encode() ;
-        byte[][] fragments = fragment( all, 10 ) ;
-        Tuple decoded = null ;
-        
-        for ( int ii = 0; ii < fragments.length; ii++ )
-        {
-            decoded = decode( fragments[ii] ) ;
-        }
-        
-        assertTrue( decoded.equals( t0 ) ) ;
-        assertEquals( str0, new String( ( byte[] ) decoded.getValue() ) ) ;
-        
-        // automatically set to top because after t1 is delivered top is 
-        decoded = decode( t1 ) ; 
-        assertTrue( decoded.equals( top ) ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.commons.codec.stateful.DecoderMonitorAdapter;
+import org.apache.commons.lang.ArrayUtils ;
+import org.apache.commons.lang.RandomStringUtils ;
+
+
+/**
+ * Tests the decoder using various complext TLV decoding scenarios and performs
+ * round trip encode - decode functionality.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BERDecoderTest extends AbstractDecoderTestCase
+{
+    public BERDecoderTest()
+    {
+        super( BERDecoderTest.class.getName() ) ;
+    }
+    
+    
+    public void testBasisCases() throws Exception
+    {
+        decoder.setDecoderMonitor( new DecoderMonitorAdapter() ) ;
+        decoder.decode( null ) ;
+        decoder.decode( ByteBuffer.wrap( ArrayUtils.EMPTY_BYTE_ARRAY ) ) ;
+    }
+    
+    
+    public void testPrimitives() throws Exception
+    {
+        byte[] bites = null ;
+        Tuple decoded = null ;
+        Tuple t = new Tuple( 45, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        assertTrue( decode( t ).equals( t ) ) ; 
+        
+        t = new Tuple( 45, "Hello world!".getBytes() ) ;
+        decoded = decode( t ) ;
+        assertTrue( decoded.equals( t ) ) ;
+        assertEquals( "Hello world!", new String( (byte[]) 
+                        decoded.getValue() ) ) ;
+
+        String mesg = RandomStringUtils.randomAlphanumeric(1000) ;
+        t = new Tuple( 1234233, mesg.getBytes() ) ;
+        decoded = decode( t ) ;
+        assertTrue( decoded.equals( t ) ) ;
+        assertEquals( mesg, new String( (byte[]) 
+                        decoded.getValue() ) ) ;
+    }
+    
+    
+    public void testConstructedIndefinate() throws Exception
+    {
+        Tuple top = new Tuple( 1, TypeClass.APPLICATION ) ;
+        Tuple t0 = new Tuple( 2, "Hello".getBytes() ) ;
+        Tuple t1 = new Tuple( 3, "World".getBytes() ) ;
+        Tuple terminator = new Tuple( 0, TypeClass.UNIVERSAL, true, 
+                ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        assertTrue( decode( top ).equals( top ) ) ;
+
+        Tuple decoded = decode( t0 ) ; 
+        assertTrue( decoded.equals( t0 ) ) ;
+        assertEquals( "Hello", new String( ( byte[] ) decoded.getValue() ) ) ;
+        
+        decoded = decode( t1 ) ; 
+        assertTrue( decoded.equals( t1 ) ) ;
+        assertEquals( "World", new String( ( byte[] ) decoded.getValue() ) ) ;
+        
+        decoded = decode( terminator ) ;
+        assertTrue( decoded.equals( top ) ) ;
+    }
+    
+    
+    public void testConstructedLongLengthForm() throws Exception
+    {
+        String str0 = RandomStringUtils.randomAlphanumeric(10000) ;
+        Tuple t0 = new Tuple( 2, str0.getBytes() ) ;
+        String str1 = RandomStringUtils.randomAlphanumeric(10000) ;
+        Tuple t1 = new Tuple( 3, str1.getBytes() ) ;
+        Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
+        assertTrue( decode( top ).equals( top ) ) ;
+
+        Tuple decoded = decode( t0 ) ; 
+        assertTrue( decoded.equals( t0 ) ) ;
+        assertEquals( str0, new String( ( byte[] ) decoded.getValue() ) ) ;
+        
+        // automatically set to top because after t1 is delivered top is 
+        decoded = decode( t1 ) ; 
+        assertTrue( decoded.equals( top ) ) ;
+    }
+
+
+    public void testConstructedShortLengthForm() throws Exception
+    {
+        Tuple t0 = new Tuple( 2, "Hello".getBytes() ) ;
+        Tuple t1 = new Tuple( 3, "World".getBytes() ) ;
+        Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
+        assertTrue( decode( top ).equals( top ) ) ;
+
+        Tuple decoded = decode( t0 ) ; 
+        assertTrue( decoded.equals( t0 ) ) ;
+        assertEquals( "Hello", new String( ( byte[] ) decoded.getValue() ) ) ;
+        
+        // automatically set to top because after t1 is delivered top is 
+        decoded = decode( t1 ) ; 
+        assertTrue( decoded.equals( top ) ) ;
+    }
+    
+    
+    public void testFragmentedValue() throws Exception
+    {
+        String str0 = RandomStringUtils.randomAlphanumeric(20) ;
+        Tuple t0 = new Tuple( 2, str0.getBytes() ) ;
+        String str1 = RandomStringUtils.randomAlphanumeric(20) ;
+        Tuple t1 = new Tuple( 3, str1.getBytes() ) ;
+        Tuple top = new Tuple( 1, t0.size() + t1.size() ) ;
+        assertTrue( decode( top ).equals( top ) ) ;
+
+        byte[] all = t0.encode() ;
+        byte[][] fragments = fragment( all, 10 ) ;
+        Tuple decoded = null ;
+        
+        for ( int ii = 0; ii < fragments.length; ii++ )
+        {
+            decoded = decode( fragments[ii] ) ;
+        }
+        
+        assertTrue( decoded.equals( t0 ) ) ;
+        assertEquals( str0, new String( ( byte[] ) decoded.getValue() ) ) ;
+        
+        // automatically set to top because after t1 is delivered top is 
+        decoded = decode( t1 ) ; 
+        assertTrue( decoded.equals( top ) ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERUtilsTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERUtilsTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/BERUtilsTest.java	Sun Mar 14 14:02:18 2004
@@ -1,250 +1,250 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import org.apache.commons.codec.binary.Binary ;
-import org.apache.commons.collections.primitives.ArrayByteList ;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests the BER utility functions.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class BERUtilsTest extends TestCase
-{
-
-    public static void main(String[] args)
-    {
-        junit.textui.TestRunner.run(BERUtilsTest.class);
-    }
-
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-
-    /*
-     * @see TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-
-    /**
-     * Constructor for BERUtilsTest.
-     * @param arg0
-     */
-    public BERUtilsTest(String arg0)
-    {
-        super(arg0);
-    }
-    
-    
-    public void getTypeClass()
-    {
-        assertEquals( TypeClass.UNIVERSAL, BERUtils.getTypeClass( (byte) 0 ) ) ;
-    }
-    
-    public void testIsPrimitive() throws Exception
-    {
-        byte octet = Binary.BIT_5 ;
-        
-        assertFalse( BERUtils.isPrimitive( octet ) ) ;
-        assertFalse( BERUtils.isPrimitive( Binary.BIT_5 ) ) ;
-        
-        assertTrue( BERUtils.isPrimitive( 0 ) ) ;
-        assertTrue( BERUtils.isPrimitive( Binary.BIT_0 ) ) ;
-        assertTrue( BERUtils.isPrimitive( Binary.BIT_1 ) ) ;
-        assertTrue( BERUtils.isPrimitive( Binary.BIT_2 ) ) ;
-        assertTrue( BERUtils.isPrimitive( Binary.BIT_3 ) ) ;
-        assertTrue( BERUtils.isPrimitive( Binary.BIT_4 ) ) ;
-        assertTrue( BERUtils.isPrimitive( Binary.BIT_6 ) ) ;
-        assertTrue( BERUtils.isPrimitive( Binary.BIT_7 ) ) ;
-    }
-
-
-    public void testIsConstructed() throws Exception
-    {
-        byte octet = Binary.BIT_5 ;
-        
-        assertTrue( BERUtils.isConstructed( octet ) ) ;
-        assertTrue( BERUtils.isConstructed( Binary.BIT_5 ) ) ;
-        
-        assertFalse( BERUtils.isConstructed( 0 ) ) ;
-        assertFalse( BERUtils.isConstructed( Binary.BIT_0 ) ) ;
-        assertFalse( BERUtils.isConstructed( Binary.BIT_1 ) ) ;
-        assertFalse( BERUtils.isConstructed( Binary.BIT_2 ) ) ;
-        assertFalse( BERUtils.isConstructed( Binary.BIT_3 ) ) ;
-        assertFalse( BERUtils.isConstructed( Binary.BIT_4 ) ) ;
-        assertFalse( BERUtils.isConstructed( Binary.BIT_6 ) ) ;
-        assertFalse( BERUtils.isConstructed( Binary.BIT_7 ) ) ;
-    }
-    
-    
-    public void testGetTagId() throws Exception
-    {
-        byte[] octets = new byte[1] ;
-        
-        for ( int ii = 0 ; ii < 128; ii++ )
-        {
-            octets[0] = ( byte ) ii ;
-            
-            if ( ii < 31 ) 
-            {
-                assertEquals( BERUtils.getTagId( octets ), ii ) ;
-            }
-            else
-            {
-                assertTrue( BERUtils.getTagId( octets ) != ii ) ;
-            }
-        }
-        
-        octets = new byte[2] ;
-        octets[0] = 31 ;
-        octets[1] = 0 ;
-        
-        for ( int ii = 31 ; ii < 255; ii++ )
-        {
-            octets[1] = ( byte ) ii ;
-            
-            if ( ii < 128 ) 
-            {
-                assertEquals( BERUtils.getTagId( octets ), ii ) ;
-            }
-            else
-            {
-                assertTrue( BERUtils.getTagId( octets ) != ii ) ;
-            }
-        }
-        
-        octets = new byte[3] ;
-        octets[0] = 31 ;
-        octets[1] = 0 ;
-        octets[2] = 0 ;
-        
-        for ( int ii = 128 ; ii < 20000; ii++ )
-        {
-            octets[1] = ( byte ) ( ii & BERUtils.LONG_TAG_MASK ) ;
-            octets[2] = ( byte ) ( ( ii >> 7 ) & BERUtils.LONG_TAG_MASK ) ;
-            
-            if ( ii < 16384 ) 
-            {
-                assertEquals( BERUtils.getTagId( octets ), ii ) ;
-            }
-            else
-            {
-                assertTrue( BERUtils.getTagId( octets ) != ii ) ;
-            }
-        }
-
-        octets = new byte[6] ;
-        octets[0] = 31 ;
-        octets[1] = 0 ; // shift 0
-        octets[2] = 0 ; // shift 7
-        octets[3] = 0 ; // shift 14
-        octets[4] = 0 ; // shift 21
-        octets[5] = 0 ; // shift 28
-        
-        for ( int ii = 16384 ; ii < 2100000 ; ii++ )
-        {
-            octets[1] = ( byte ) ( ii & BERUtils.LONG_TAG_MASK ) ;
-            octets[2] = ( byte ) ( ( ii >> 7 ) & BERUtils.LONG_TAG_MASK ) ;
-            octets[3] = ( byte ) ( ( ii >> 14 ) & BERUtils.LONG_TAG_MASK ) ;
-            
-            if ( ii < 2097152 ) 
-            {
-                assertEquals( BERUtils.getTagId( octets ), ii ) ;
-            }
-            else
-            {
-                assertTrue( BERUtils.getTagId( octets ) != ii ) ;
-            }
-        }
-        
-        ArrayByteList list = new ArrayByteList() ;
-        list.add( (byte)1) ;
-        assertEquals( 1, BERUtils.getTagId( list ) ) ;
-
-        list.add( (byte)1) ;
-        list.add( (byte)1) ;
-        list.add( (byte)1) ;
-        list.add( (byte)1) ;
-        list.add( (byte)1) ;
-        list.add( (byte)1) ;
-        list.add( (byte)1) ;
-        list.add( (byte)1) ;
-        try
-        {
-            BERUtils.getTagId( list ) ;
-            fail( "should fail before getting here" ) ;
-        }
-        catch ( Throwable t )
-        {
-            assertNotNull( t ) ;
-        }
-
-    
-        try
-        {
-            BERUtils.getTagId( new byte[56] ) ;
-            fail( "should fail before getting here" ) ;
-        }
-        catch ( Throwable t )
-        {
-            assertNotNull( t ) ;
-        }
-    }
-    
-    
-    public void testGetLength() throws Exception
-    {
-        ArrayByteList list = new ArrayByteList() ;
-        list.add( (byte) 0x1 ) ;
-        list.add( (byte) 0x1 ) ;
-        list.add( (byte) 0x1 ) ;
-        list.add( (byte) 0x1 ) ;
-        list.add( (byte) 0x1 ) ;
-        list.add( (byte) 0x1 ) ;
-        list.add( (byte) 0x1 ) ;
-        list.add( (byte) 0x1 ) ;
-        
-        try
-        {
-            BERUtils.getLength( list ) ;
-            fail( "should fail before we get here" ) ;
-        }
-        catch ( Throwable t )
-        {
-            assertNotNull( t ) ;
-        }
-        
-        
-        list.clear() ;
-        list.add(( byte ) 0x7 ) ;
-        assertEquals( 7, BERUtils.getLength( list ) ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.codec.binary.Binary ;
+import org.apache.commons.collections.primitives.ArrayByteList ;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests the BER utility functions.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BERUtilsTest extends TestCase
+{
+
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(BERUtilsTest.class);
+    }
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * Constructor for BERUtilsTest.
+     * @param arg0
+     */
+    public BERUtilsTest(String arg0)
+    {
+        super(arg0);
+    }
+    
+    
+    public void getTypeClass()
+    {
+        assertEquals( TypeClass.UNIVERSAL, BERUtils.getTypeClass( (byte) 0 ) ) ;
+    }
+    
+    public void testIsPrimitive() throws Exception
+    {
+        byte octet = Binary.BIT_5 ;
+        
+        assertFalse( BERUtils.isPrimitive( octet ) ) ;
+        assertFalse( BERUtils.isPrimitive( Binary.BIT_5 ) ) ;
+        
+        assertTrue( BERUtils.isPrimitive( 0 ) ) ;
+        assertTrue( BERUtils.isPrimitive( Binary.BIT_0 ) ) ;
+        assertTrue( BERUtils.isPrimitive( Binary.BIT_1 ) ) ;
+        assertTrue( BERUtils.isPrimitive( Binary.BIT_2 ) ) ;
+        assertTrue( BERUtils.isPrimitive( Binary.BIT_3 ) ) ;
+        assertTrue( BERUtils.isPrimitive( Binary.BIT_4 ) ) ;
+        assertTrue( BERUtils.isPrimitive( Binary.BIT_6 ) ) ;
+        assertTrue( BERUtils.isPrimitive( Binary.BIT_7 ) ) ;
+    }
+
+
+    public void testIsConstructed() throws Exception
+    {
+        byte octet = Binary.BIT_5 ;
+        
+        assertTrue( BERUtils.isConstructed( octet ) ) ;
+        assertTrue( BERUtils.isConstructed( Binary.BIT_5 ) ) ;
+        
+        assertFalse( BERUtils.isConstructed( 0 ) ) ;
+        assertFalse( BERUtils.isConstructed( Binary.BIT_0 ) ) ;
+        assertFalse( BERUtils.isConstructed( Binary.BIT_1 ) ) ;
+        assertFalse( BERUtils.isConstructed( Binary.BIT_2 ) ) ;
+        assertFalse( BERUtils.isConstructed( Binary.BIT_3 ) ) ;
+        assertFalse( BERUtils.isConstructed( Binary.BIT_4 ) ) ;
+        assertFalse( BERUtils.isConstructed( Binary.BIT_6 ) ) ;
+        assertFalse( BERUtils.isConstructed( Binary.BIT_7 ) ) ;
+    }
+    
+    
+    public void testGetTagId() throws Exception
+    {
+        byte[] octets = new byte[1] ;
+        
+        for ( int ii = 0 ; ii < 128; ii++ )
+        {
+            octets[0] = ( byte ) ii ;
+            
+            if ( ii < 31 ) 
+            {
+                assertEquals( BERUtils.getTagId( octets ), ii ) ;
+            }
+            else
+            {
+                assertTrue( BERUtils.getTagId( octets ) != ii ) ;
+            }
+        }
+        
+        octets = new byte[2] ;
+        octets[0] = 31 ;
+        octets[1] = 0 ;
+        
+        for ( int ii = 31 ; ii < 255; ii++ )
+        {
+            octets[1] = ( byte ) ii ;
+            
+            if ( ii < 128 ) 
+            {
+                assertEquals( BERUtils.getTagId( octets ), ii ) ;
+            }
+            else
+            {
+                assertTrue( BERUtils.getTagId( octets ) != ii ) ;
+            }
+        }
+        
+        octets = new byte[3] ;
+        octets[0] = 31 ;
+        octets[1] = 0 ;
+        octets[2] = 0 ;
+        
+        for ( int ii = 128 ; ii < 20000; ii++ )
+        {
+            octets[1] = ( byte ) ( ii & BERUtils.LONG_TAG_MASK ) ;
+            octets[2] = ( byte ) ( ( ii >> 7 ) & BERUtils.LONG_TAG_MASK ) ;
+            
+            if ( ii < 16384 ) 
+            {
+                assertEquals( BERUtils.getTagId( octets ), ii ) ;
+            }
+            else
+            {
+                assertTrue( BERUtils.getTagId( octets ) != ii ) ;
+            }
+        }
+
+        octets = new byte[6] ;
+        octets[0] = 31 ;
+        octets[1] = 0 ; // shift 0
+        octets[2] = 0 ; // shift 7
+        octets[3] = 0 ; // shift 14
+        octets[4] = 0 ; // shift 21
+        octets[5] = 0 ; // shift 28
+        
+        for ( int ii = 16384 ; ii < 2100000 ; ii++ )
+        {
+            octets[1] = ( byte ) ( ii & BERUtils.LONG_TAG_MASK ) ;
+            octets[2] = ( byte ) ( ( ii >> 7 ) & BERUtils.LONG_TAG_MASK ) ;
+            octets[3] = ( byte ) ( ( ii >> 14 ) & BERUtils.LONG_TAG_MASK ) ;
+            
+            if ( ii < 2097152 ) 
+            {
+                assertEquals( BERUtils.getTagId( octets ), ii ) ;
+            }
+            else
+            {
+                assertTrue( BERUtils.getTagId( octets ) != ii ) ;
+            }
+        }
+        
+        ArrayByteList list = new ArrayByteList() ;
+        list.add( (byte)1) ;
+        assertEquals( 1, BERUtils.getTagId( list ) ) ;
+
+        list.add( (byte)1) ;
+        list.add( (byte)1) ;
+        list.add( (byte)1) ;
+        list.add( (byte)1) ;
+        list.add( (byte)1) ;
+        list.add( (byte)1) ;
+        list.add( (byte)1) ;
+        list.add( (byte)1) ;
+        try
+        {
+            BERUtils.getTagId( list ) ;
+            fail( "should fail before getting here" ) ;
+        }
+        catch ( Throwable t )
+        {
+            assertNotNull( t ) ;
+        }
+
+    
+        try
+        {
+            BERUtils.getTagId( new byte[56] ) ;
+            fail( "should fail before getting here" ) ;
+        }
+        catch ( Throwable t )
+        {
+            assertNotNull( t ) ;
+        }
+    }
+    
+    
+    public void testGetLength() throws Exception
+    {
+        ArrayByteList list = new ArrayByteList() ;
+        list.add( (byte) 0x1 ) ;
+        list.add( (byte) 0x1 ) ;
+        list.add( (byte) 0x1 ) ;
+        list.add( (byte) 0x1 ) ;
+        list.add( (byte) 0x1 ) ;
+        list.add( (byte) 0x1 ) ;
+        list.add( (byte) 0x1 ) ;
+        list.add( (byte) 0x1 ) ;
+        
+        try
+        {
+            BERUtils.getLength( list ) ;
+            fail( "should fail before we get here" ) ;
+        }
+        catch ( Throwable t )
+        {
+            assertNotNull( t ) ;
+        }
+        
+        
+        list.clear() ;
+        list.add(( byte ) 0x7 ) ;
+        assertEquals( 7, BERUtils.getLength( list ) ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/ConstructedTLVTests.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/ConstructedTLVTests.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/ConstructedTLVTests.java	Sun Mar 14 14:02:18 2004
@@ -1,200 +1,200 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-/**
- * Performs constructed tlv tests.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class ConstructedTLVTests extends AbstractDecoderTestCase
-{
-
-    /**
-     * @param arg0
-     */
-    public ConstructedTLVTests( String arg0 )
-    {
-        super( arg0 ) ;
-    }
-    
-    
-    public void testConstructedDefinateTLV() throws Exception
-    {
-        // decode tag
-        Tuple outter = decode( "01100001" ) ;
-        assertEquals( 1, outter.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( false, outter.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, outter.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        outter = decode( "00000011" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        
-        // decode tag
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "00000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-        
-        // decode value
-        tlv = decode( "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 2, tlvList.size() ) ;
-    }
-
-
-    public void testMultipleIndefinateTLV() throws Exception
-    {
-        // --------------------------------------------------------------------
-        
-        // decode tag
-        Tuple outter = decode( "01100001" ) ;
-        assertEquals( 1, outter.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( false, outter.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, outter.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        outter = decode( "10000000" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        
-        // --------------------------------------------------------------------
-
-        
-        // decode tag
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "00000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        
-        // decode value
-        tlv = decode( "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 1, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
-
-        
-        // --------------------------------------------------------------------
-
-
-        // decode tag
-        tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 1, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "00000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-        
-        // decode value
-        tlv = decode( "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 2, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
-
-    
-        // --------------------------------------------------------------------
-
-
-        // decode tag
-        tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 2, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "00000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-        
-        // decode value
-        tlv = decode( "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 3, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
-
-        decode( "00000000" ) ;
-        decode( "00000000" ) ;
-        
-        assertEquals( 4, tlvList.size() ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-    }
-
-
-    public void testIllegalState() throws Exception
-    {
-        try 
-        {
-            decode( "00000000" ) ;
-            decode( "00000000" ) ;
-            fail( "should throw an exception before getting here" ) ;
-        }
-        catch( Throwable e ) 
-        {
-            assertNotNull( e ) ;
-        }
-    }
-
-
-    public void testIllegalStateNoMonitor() throws Exception
-    {
-        decoder.setDecoderMonitor( null ) ;
-        
-        try 
-        {
-            decode( "00000000" ) ;
-            decode( "00000000" ) ;
-            fail( "should throw an exception before getting here" ) ;
-        }
-        catch( Throwable e ) 
-        {
-            assertNotNull( e ) ;
-        }
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+/**
+ * Performs constructed tlv tests.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ConstructedTLVTests extends AbstractDecoderTestCase
+{
+
+    /**
+     * @param arg0
+     */
+    public ConstructedTLVTests( String arg0 )
+    {
+        super( arg0 ) ;
+    }
+    
+    
+    public void testConstructedDefinateTLV() throws Exception
+    {
+        // decode tag
+        Tuple outter = decode( "01100001" ) ;
+        assertEquals( 1, outter.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( false, outter.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, outter.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        outter = decode( "00000011" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        
+        // decode tag
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "00000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+        
+        // decode value
+        tlv = decode( "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 2, tlvList.size() ) ;
+    }
+
+
+    public void testMultipleIndefinateTLV() throws Exception
+    {
+        // --------------------------------------------------------------------
+        
+        // decode tag
+        Tuple outter = decode( "01100001" ) ;
+        assertEquals( 1, outter.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( false, outter.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, outter.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        outter = decode( "10000000" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        
+        // --------------------------------------------------------------------
+
+        
+        // decode tag
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "00000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        
+        // decode value
+        tlv = decode( "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 1, tlvList.size() ) ;
+        assertNotNull( tlv.value ) ;
+        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
+
+        
+        // --------------------------------------------------------------------
+
+
+        // decode tag
+        tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 1, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "00000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+        
+        // decode value
+        tlv = decode( "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 2, tlvList.size() ) ;
+        assertNotNull( tlv.value ) ;
+        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
+
+    
+        // --------------------------------------------------------------------
+
+
+        // decode tag
+        tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 2, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "00000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+        
+        // decode value
+        tlv = decode( "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 3, tlvList.size() ) ;
+        assertNotNull( tlv.value ) ;
+        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
+
+        decode( "00000000" ) ;
+        decode( "00000000" ) ;
+        
+        assertEquals( 4, tlvList.size() ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+    }
+
+
+    public void testIllegalState() throws Exception
+    {
+        try 
+        {
+            decode( "00000000" ) ;
+            decode( "00000000" ) ;
+            fail( "should throw an exception before getting here" ) ;
+        }
+        catch( Throwable e ) 
+        {
+            assertNotNull( e ) ;
+        }
+    }
+
+
+    public void testIllegalStateNoMonitor() throws Exception
+    {
+        decoder.setDecoderMonitor( null ) ;
+        
+        try 
+        {
+            decode( "00000000" ) ;
+            decode( "00000000" ) ;
+            fail( "should throw an exception before getting here" ) ;
+        }
+        catch( Throwable e ) 
+        {
+            assertNotNull( e ) ;
+        }
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/DefaultMutableTupleNodeTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/DefaultMutableTupleNodeTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/DefaultMutableTupleNodeTest.java	Sun Mar 14 14:02:18 2004
@@ -1,506 +1,506 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Enumeration;
-
-import javax.swing.tree.MutableTreeNode;
-
-import org.apache.commons.codec.stateful.DecoderCallback;
-import org.apache.commons.codec.stateful.StatefulDecoder;
-import org.apache.commons.lang.ArrayUtils;
-
-
-/**
- * Tests the default MutableTupleNode implementation.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class DefaultMutableTupleNodeTest extends AbstractDecoderTestCase
-{
-    public DefaultMutableTupleNodeTest()
-    {
-        super ( DefaultMutableTupleNodeTest.class.getName() ) ; 
-    }
-
-
-    /*
-     * Class to test for void DefaultMutableTupleNode()
-     */
-    public void testDefaultMutableTupleNode()
-    {
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        assertNotNull( node ) ;
-    }
-
-    /*
-     * Class to test for void DefaultMutableTupleNode(Tuple)
-     */
-    public void testDefaultMutableTupleNodeTuple()
-    {
-    }
-
-    /*
-     * Class to test for void insert(MutableTupleNode, int)
-     */
-    public void testInsertMutableTupleNodeint()
-    {
-    }
-
-    /*
-     * Class to test for void remove(int)
-     */
-    public void testRemoveint()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        assertEquals(1,parent.getChildCount()) ;
-        parent.remove( 0 ) ;
-        assertEquals(0,parent.getChildCount()) ;
-    }
-
-    /*
-     * Class to test for void remove(MutableTupleNode)
-     */
-    public void testRemoveMutableTupleNode()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        assertEquals(1,parent.getChildCount()) ;
-        parent.remove( (MutableTupleNode) node ) ;
-        assertEquals(0,parent.getChildCount()) ;
-
-        parent.insert( (MutableTreeNode) node, 0 ) ;
-        assertEquals(1,parent.getChildCount()) ;
-        parent.remove( (MutableTreeNode) node ) ;
-        assertEquals(0,parent.getChildCount()) ;
-    }
-
-    public void testRemoveFromParent()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        assertEquals(1,parent.getChildCount()) ;
-        node.removeFromParent() ;
-        assertEquals(0,parent.getChildCount()) ;
-    }
-
-    /*
-     * Class to test for void setParent(MutableTupleNode)
-     */
-    public void testSetParentMutableTupleNode()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        assertEquals(parent, node.getParent()) ;
-        node.setParent((MutableTupleNode)new DefaultMutableTupleNode()) ;
-        assertNotSame(parent, node.getParent()) ;
-    }
-
-    /*
-     * Class to test for void setParent(MutableTupleNode)
-     */
-    public void testSetParentMutableTreeNode()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTreeNode) node, 0 ) ;
-        node.setParent( (MutableTreeNode) parent) ;
-        assertEquals(parent, node.getParent()) ;
-        node.setParent((MutableTreeNode)new DefaultMutableTupleNode()) ;
-        assertNotSame(parent, node.getParent()) ;
-    }
-
-    public void testSetTuple()
-    {
-        Tuple t = new Tuple() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        node.setTuple( t ) ;
-        assertEquals(t, node.getTuple()) ;
-    }
-
-    public void testGetParentTupleNode()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        assertSame(parent, node.getParentTupleNode()) ;
-        assertSame(parent, node.getParent()) ;
-    }
-
-    public void testGetChildren()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        assertSame(parent, node.getParentTupleNode()) ;
-        assertTrue( parent.getChildren().hasNext()) ;
-    }
-
-    
-    public void testGetChildTupleNodeAt()
-    {
-    }
-
-    /*
-     * Class to test for int getIndex(TupleNode)
-     */
-    public void testGetIndexTupleNode()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        assertEquals( 0, parent.getIndex((MutableTupleNode)node));
-        assertEquals( 0, parent.getIndex((MutableTreeNode)node));
-    }
-
-    public void testGetChildCount()
-    {
-    }
-
-    public void testSize()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        parent.setTuple( constructed ) ;
-        node.setTuple( primitive ) ;
-        
-        // fact that we use the indefinate form we automatically add two to
-        // the contained size
-        assertEquals(9, parent.size()) ;
-    }
-
-    public void testSize2()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
-        Tuple constructed = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
-        parent.setTuple( constructed ) ;
-        node.setTuple( primitive ) ;
-        
-        assertEquals(7, parent.size()) ;
-    }
-
-    public void testSize3()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        parent.setTuple( constructed ) ;
-        
-        assertEquals(4, parent.size()) ;
-    }
-
-    public void testEncode3() throws Exception
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        parent.setTuple( constructed ) ;
-        
-        assertEquals(4, parent.size()) ;
-        
-        ByteBuffer buf = ByteBuffer.allocate( 4 ) ;
-        parent.encode( buf ) ;
-
-        final ArrayList list = new ArrayList() ;
-        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        decoder.setCallback( new DecoderCallback(){
-            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
-            {
-                list.add( arg1 ) ;
-            }}) ;
-        
-        decoder.decode(buf.flip()) ;
-        DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
-            list.get(0); 
-        assertEquals( decoded.getTuple(), parent.getTuple()) ;
-    }
-
-    public void testGetTuple()
-    {
-        Tuple t = new Tuple() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        node.setTuple(t) ;
-        assertSame(t, node.getTuple()) ;
-    }
-
-    public void testEncode0() throws Exception
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) end, 0 ) ;
-        end.setParent( (MutableTupleNode) parent) ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
-        terminator.typeClass = TypeClass.UNIVERSAL ;
-        parent.setTuple( constructed ) ;
-        node.setTuple( primitive ) ;
-        end.setTuple(terminator) ;
-        
-        assertEquals(9, parent.size()) ;
-        
-        ByteBuffer buf = ByteBuffer.allocate( 9 ) ;
-        parent.encode( buf ) ;
-
-        final ArrayList list = new ArrayList() ;
-        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        decoder.setCallback( new DecoderCallback(){
-            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
-            {
-                list.add( arg1 ) ;
-            }}) ;
-        
-        decoder.decode(buf.flip()) ;
-        DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
-            list.get(0); 
-        assertEquals( decoded.getTuple(), parent.getTuple()) ;
-    }
-
-    public void testEncode1() throws Exception
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        parent.setTuple( constructed ) ;
-        node.setTuple( primitive ) ;
-        
-        // 2 extra bytes added for indefinate form
-        assertEquals(9, parent.size()) ;
-        
-        ByteBuffer buf = ByteBuffer.allocate( 9 ) ;
-        parent.encode( buf ) ;
-
-        final ArrayList list = new ArrayList() ;
-        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        decoder.setCallback( new DecoderCallback(){
-            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
-            {
-                list.add( arg1 ) ;
-            }}) ;
-        
-        decoder.decode(buf.flip()) ;
-        DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
-            list.get(0); 
-        assertEquals( decoded.getTuple(), parent.getTuple()) ;
-    }
-
-    public void testEncode2() throws Exception
-    {
-        DefaultMutableTupleNode top = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode middle = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode bottom = new DefaultMutableTupleNode() ;
-        top.insert( (MutableTupleNode) middle, 0 ) ;
-        middle.setParent( (MutableTupleNode) top) ;
-        middle.insert( (MutableTupleNode) bottom, 0 ) ;
-        bottom.setParent( (MutableTupleNode) middle) ;
-        
-        Tuple middleTuple = new Tuple( 1, 3, TypeClass.APPLICATION  ) ;
-        Tuple topTuple = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
-        Tuple bottomTuple = new Tuple( 3, new byte[1]) ;
-        
-        bottomTuple.typeClass = TypeClass.UNIVERSAL ;
-        top.setTuple( topTuple ) ;
-        middle.setTuple( middleTuple ) ;
-        bottom.setTuple( bottomTuple ) ;
-        
-        assertEquals(7, top.size()) ;
-        
-        ByteBuffer buf = ByteBuffer.allocate( 7 ) ;
-        top.encode( buf ) ;
-
-        final ArrayList list = new ArrayList() ;
-        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        decoder.setCallback( new DecoderCallback(){
-            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
-            {
-                list.add( arg1 ) ;
-            }}) ;
-        
-        decoder.decode(buf.flip()) ;
-        DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
-            list.get(0); 
-        assertEquals( decoded.getTuple(), top.getTuple()) ;
-    }
-
-    /*
-     * Class to test for String toString()
-     */
-    public void testToString()
-    {
-    }
-
-    public void testPrintDepthFirst()
-    {
-    }
-
-    public void testChildren()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) end, 0 ) ;
-        end.setParent( (MutableTupleNode) parent) ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
-        terminator.typeClass = TypeClass.UNIVERSAL ;
-        parent.setTuple( constructed ) ;
-        node.setTuple( primitive ) ;
-        end.setTuple(terminator) ;
-        
-        Enumeration list = parent.children() ;
-        
-        assertEquals( node, list.nextElement() ) ;
-        assertEquals( end, list.nextElement() ) ;
-        
-        try
-        {
-            list.nextElement() ;
-            fail( "should never get here due to thrown exception" ) ;
-        }
-        catch( Throwable t ) 
-        {
-            assertNotNull( t ) ;
-        }
-    }
-
-    public void testGetAllowsChildren()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) end, 0 ) ;
-        end.setParent( (MutableTupleNode) parent) ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
-        terminator.typeClass = TypeClass.UNIVERSAL ;
-        parent.setTuple( constructed ) ;
-        node.setTuple( primitive ) ;
-        end.setTuple(terminator) ;
-        
-        assertFalse( end.getAllowsChildren() ) ;
-        assertFalse( node.getAllowsChildren() ) ;
-        assertTrue( parent.getAllowsChildren() ) ;
-    }
-
-    public void testGetChildAt()
-    {
-    }
-
-    /*
-     * Class to test for int getIndex(TreeNode)
-     */
-    public void testGetIndexTreeNode()
-    {
-    }
-
-    public void testGetParent()
-    {
-    }
-
-    /*
-     * Class to test for void insert(MutableTreeNode, int)
-     */
-    public void testInsertMutableTreeNodeint()
-    {
-    }
-
-    public void testIsLeaf0()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        assertTrue( parent.isLeaf() ) ;
-    }
-
-    public void testIsLeaf1()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        parent.setTuple(new Tuple()) ;
-        assertTrue( parent.isLeaf() ) ;
-    }
-
-    public void testIsLeaf2()
-    {
-        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
-        parent.insert( (MutableTupleNode) end, 0 ) ;
-        end.setParent( (MutableTupleNode) parent) ;
-        parent.insert( (MutableTupleNode) node, 0 ) ;
-        node.setParent( (MutableTupleNode) parent) ;
-        
-        Tuple primitive = new Tuple( 1, new byte[3] ) ;
-        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
-        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
-        terminator.typeClass = TypeClass.UNIVERSAL ;
-        parent.setTuple( constructed ) ;
-        node.setTuple( primitive ) ;
-        end.setTuple(terminator) ;
-        
-        assertFalse( parent.isLeaf() ) ;
-    }
-
-    /*
-     * Class to test for void remove(MutableTreeNode)
-     */
-    public void testRemoveMutableTreeNode()
-    {
-    }
-
-    public void testSetUserObject()
-    {
-        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
-        node.setUserObject( new Tuple() ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import javax.swing.tree.MutableTreeNode;
+
+import org.apache.commons.codec.stateful.DecoderCallback;
+import org.apache.commons.codec.stateful.StatefulDecoder;
+import org.apache.commons.lang.ArrayUtils;
+
+
+/**
+ * Tests the default MutableTupleNode implementation.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DefaultMutableTupleNodeTest extends AbstractDecoderTestCase
+{
+    public DefaultMutableTupleNodeTest()
+    {
+        super ( DefaultMutableTupleNodeTest.class.getName() ) ; 
+    }
+
+
+    /*
+     * Class to test for void DefaultMutableTupleNode()
+     */
+    public void testDefaultMutableTupleNode()
+    {
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        assertNotNull( node ) ;
+    }
+
+    /*
+     * Class to test for void DefaultMutableTupleNode(Tuple)
+     */
+    public void testDefaultMutableTupleNodeTuple()
+    {
+    }
+
+    /*
+     * Class to test for void insert(MutableTupleNode, int)
+     */
+    public void testInsertMutableTupleNodeint()
+    {
+    }
+
+    /*
+     * Class to test for void remove(int)
+     */
+    public void testRemoveint()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        assertEquals(1,parent.getChildCount()) ;
+        parent.remove( 0 ) ;
+        assertEquals(0,parent.getChildCount()) ;
+    }
+
+    /*
+     * Class to test for void remove(MutableTupleNode)
+     */
+    public void testRemoveMutableTupleNode()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        assertEquals(1,parent.getChildCount()) ;
+        parent.remove( (MutableTupleNode) node ) ;
+        assertEquals(0,parent.getChildCount()) ;
+
+        parent.insert( (MutableTreeNode) node, 0 ) ;
+        assertEquals(1,parent.getChildCount()) ;
+        parent.remove( (MutableTreeNode) node ) ;
+        assertEquals(0,parent.getChildCount()) ;
+    }
+
+    public void testRemoveFromParent()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        
+        assertEquals(1,parent.getChildCount()) ;
+        node.removeFromParent() ;
+        assertEquals(0,parent.getChildCount()) ;
+    }
+
+    /*
+     * Class to test for void setParent(MutableTupleNode)
+     */
+    public void testSetParentMutableTupleNode()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        assertEquals(parent, node.getParent()) ;
+        node.setParent((MutableTupleNode)new DefaultMutableTupleNode()) ;
+        assertNotSame(parent, node.getParent()) ;
+    }
+
+    /*
+     * Class to test for void setParent(MutableTupleNode)
+     */
+    public void testSetParentMutableTreeNode()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTreeNode) node, 0 ) ;
+        node.setParent( (MutableTreeNode) parent) ;
+        assertEquals(parent, node.getParent()) ;
+        node.setParent((MutableTreeNode)new DefaultMutableTupleNode()) ;
+        assertNotSame(parent, node.getParent()) ;
+    }
+
+    public void testSetTuple()
+    {
+        Tuple t = new Tuple() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        node.setTuple( t ) ;
+        assertEquals(t, node.getTuple()) ;
+    }
+
+    public void testGetParentTupleNode()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        assertSame(parent, node.getParentTupleNode()) ;
+        assertSame(parent, node.getParent()) ;
+    }
+
+    public void testGetChildren()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        assertSame(parent, node.getParentTupleNode()) ;
+        assertTrue( parent.getChildren().hasNext()) ;
+    }
+
+    
+    public void testGetChildTupleNodeAt()
+    {
+    }
+
+    /*
+     * Class to test for int getIndex(TupleNode)
+     */
+    public void testGetIndexTupleNode()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        assertEquals( 0, parent.getIndex((MutableTupleNode)node));
+        assertEquals( 0, parent.getIndex((MutableTreeNode)node));
+    }
+
+    public void testGetChildCount()
+    {
+    }
+
+    public void testSize()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        
+        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive ) ;
+        
+        // fact that we use the indefinate form we automatically add two to
+        // the contained size
+        assertEquals(9, parent.size()) ;
+    }
+
+    public void testSize2()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        
+        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple constructed = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive ) ;
+        
+        assertEquals(7, parent.size()) ;
+    }
+
+    public void testSize3()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        parent.setTuple( constructed ) ;
+        
+        assertEquals(4, parent.size()) ;
+    }
+
+    public void testEncode3() throws Exception
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        parent.setTuple( constructed ) ;
+        
+        assertEquals(4, parent.size()) ;
+        
+        ByteBuffer buf = ByteBuffer.allocate( 4 ) ;
+        parent.encode( buf ) ;
+
+        final ArrayList list = new ArrayList() ;
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        decoder.setCallback( new DecoderCallback(){
+            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
+            {
+                list.add( arg1 ) ;
+            }}) ;
+        
+        decoder.decode(buf.flip()) ;
+        DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
+            list.get(0); 
+        assertEquals( decoded.getTuple(), parent.getTuple()) ;
+    }
+
+    public void testGetTuple()
+    {
+        Tuple t = new Tuple() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        node.setTuple(t) ;
+        assertSame(t, node.getTuple()) ;
+    }
+
+    public void testEncode0() throws Exception
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) end, 0 ) ;
+        end.setParent( (MutableTupleNode) parent) ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        
+        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        terminator.typeClass = TypeClass.UNIVERSAL ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive ) ;
+        end.setTuple(terminator) ;
+        
+        assertEquals(9, parent.size()) ;
+        
+        ByteBuffer buf = ByteBuffer.allocate( 9 ) ;
+        parent.encode( buf ) ;
+
+        final ArrayList list = new ArrayList() ;
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        decoder.setCallback( new DecoderCallback(){
+            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
+            {
+                list.add( arg1 ) ;
+            }}) ;
+        
+        decoder.decode(buf.flip()) ;
+        DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
+            list.get(0); 
+        assertEquals( decoded.getTuple(), parent.getTuple()) ;
+    }
+
+    public void testEncode1() throws Exception
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        
+        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive ) ;
+        
+        // 2 extra bytes added for indefinate form
+        assertEquals(9, parent.size()) ;
+        
+        ByteBuffer buf = ByteBuffer.allocate( 9 ) ;
+        parent.encode( buf ) ;
+
+        final ArrayList list = new ArrayList() ;
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        decoder.setCallback( new DecoderCallback(){
+            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
+            {
+                list.add( arg1 ) ;
+            }}) ;
+        
+        decoder.decode(buf.flip()) ;
+        DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
+            list.get(0); 
+        assertEquals( decoded.getTuple(), parent.getTuple()) ;
+    }
+
+    public void testEncode2() throws Exception
+    {
+        DefaultMutableTupleNode top = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode middle = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode bottom = new DefaultMutableTupleNode() ;
+        top.insert( (MutableTupleNode) middle, 0 ) ;
+        middle.setParent( (MutableTupleNode) top) ;
+        middle.insert( (MutableTupleNode) bottom, 0 ) ;
+        bottom.setParent( (MutableTupleNode) middle) ;
+        
+        Tuple middleTuple = new Tuple( 1, 3, TypeClass.APPLICATION  ) ;
+        Tuple topTuple = new Tuple ( 2, 5, TypeClass.APPLICATION ) ;
+        Tuple bottomTuple = new Tuple( 3, new byte[1]) ;
+        
+        bottomTuple.typeClass = TypeClass.UNIVERSAL ;
+        top.setTuple( topTuple ) ;
+        middle.setTuple( middleTuple ) ;
+        bottom.setTuple( bottomTuple ) ;
+        
+        assertEquals(7, top.size()) ;
+        
+        ByteBuffer buf = ByteBuffer.allocate( 7 ) ;
+        top.encode( buf ) ;
+
+        final ArrayList list = new ArrayList() ;
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        decoder.setCallback( new DecoderCallback(){
+            public void decodeOccurred(StatefulDecoder arg0, Object arg1)
+            {
+                list.add( arg1 ) ;
+            }}) ;
+        
+        decoder.decode(buf.flip()) ;
+        DefaultMutableTupleNode decoded = ( DefaultMutableTupleNode ) 
+            list.get(0); 
+        assertEquals( decoded.getTuple(), top.getTuple()) ;
+    }
+
+    /*
+     * Class to test for String toString()
+     */
+    public void testToString()
+    {
+    }
+
+    public void testPrintDepthFirst()
+    {
+    }
+
+    public void testChildren()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) end, 0 ) ;
+        end.setParent( (MutableTupleNode) parent) ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        
+        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        terminator.typeClass = TypeClass.UNIVERSAL ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive ) ;
+        end.setTuple(terminator) ;
+        
+        Enumeration list = parent.children() ;
+        
+        assertEquals( node, list.nextElement() ) ;
+        assertEquals( end, list.nextElement() ) ;
+        
+        try
+        {
+            list.nextElement() ;
+            fail( "should never get here due to thrown exception" ) ;
+        }
+        catch( Throwable t ) 
+        {
+            assertNotNull( t ) ;
+        }
+    }
+
+    public void testGetAllowsChildren()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) end, 0 ) ;
+        end.setParent( (MutableTupleNode) parent) ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        
+        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        terminator.typeClass = TypeClass.UNIVERSAL ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive ) ;
+        end.setTuple(terminator) ;
+        
+        assertFalse( end.getAllowsChildren() ) ;
+        assertFalse( node.getAllowsChildren() ) ;
+        assertTrue( parent.getAllowsChildren() ) ;
+    }
+
+    public void testGetChildAt()
+    {
+    }
+
+    /*
+     * Class to test for int getIndex(TreeNode)
+     */
+    public void testGetIndexTreeNode()
+    {
+    }
+
+    public void testGetParent()
+    {
+    }
+
+    /*
+     * Class to test for void insert(MutableTreeNode, int)
+     */
+    public void testInsertMutableTreeNodeint()
+    {
+    }
+
+    public void testIsLeaf0()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        assertTrue( parent.isLeaf() ) ;
+    }
+
+    public void testIsLeaf1()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        parent.setTuple(new Tuple()) ;
+        assertTrue( parent.isLeaf() ) ;
+    }
+
+    public void testIsLeaf2()
+    {
+        DefaultMutableTupleNode parent = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        DefaultMutableTupleNode end = new DefaultMutableTupleNode() ;
+        parent.insert( (MutableTupleNode) end, 0 ) ;
+        end.setParent( (MutableTupleNode) parent) ;
+        parent.insert( (MutableTupleNode) node, 0 ) ;
+        node.setParent( (MutableTupleNode) parent) ;
+        
+        Tuple primitive = new Tuple( 1, new byte[3] ) ;
+        Tuple constructed = new Tuple ( 2, TypeClass.APPLICATION ) ;
+        Tuple terminator = new Tuple( 0, true, ArrayUtils.EMPTY_BYTE_ARRAY) ;
+        terminator.typeClass = TypeClass.UNIVERSAL ;
+        parent.setTuple( constructed ) ;
+        node.setTuple( primitive ) ;
+        end.setTuple(terminator) ;
+        
+        assertFalse( parent.isLeaf() ) ;
+    }
+
+    /*
+     * Class to test for void remove(MutableTreeNode)
+     */
+    public void testRemoveMutableTreeNode()
+    {
+    }
+
+    public void testSetUserObject()
+    {
+        DefaultMutableTupleNode node = new DefaultMutableTupleNode() ;
+        node.setUserObject( new Tuple() ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java	Sun Mar 14 14:02:18 2004
@@ -1,80 +1,80 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.nio.ByteBuffer ;
-import java.math.BigInteger ;
-import java.io.ByteArrayInputStream ;
-
-import org.apache.commons.codec.binary.Hex ;
-import org.apache.ldap.common.message.AbandonRequest ;
-import org.apache.ldap.common.message.MessageDecoder ;
-import org.apache.ldap.common.message.MessageEncoder ;
-import org.apache.ldap.common.message.AbandonRequestImpl ;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Testing out round trip encode decode.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class EncodeDecodeTests extends TestCase
-{
-    public void testAbandonRequest() throws Exception
-    {
-        DefaultMutableTupleNode root = null ;
-        ByteBuffer buf = null ;
-        AbandonRequestImpl request = new AbandonRequestImpl( BigInteger.ONE ) ;
-        request.setAbandoned( new BigInteger( "3" ) ) ;
-        
-        MessageEncoder encoder = new MessageEncoder() ;
-        byte[] snaccBytes = encoder.encode( request ) ;
-        
-        String snaccEncoded = new String( Hex.encodeHex( snaccBytes ) ) ;
-        System.out.println( "snacc encoded = [" + snaccEncoded + "][" 
-                + snaccBytes.length + "]" ) ;
-        
-        MessageDecoder decoder = new MessageDecoder() ;
-        AbandonRequest msg = ( AbandonRequest ) decoder.decode( null, 
-                new ByteArrayInputStream( snaccBytes ) ) ;
-        assertTrue( msg.getMessageId().equals( request.getMessageId() ) ) ;
-        
-        System.out.println( "snacc decoded = " + msg ) ;
-        
-        root = ( DefaultMutableTupleNode ) 
-            TupleTreeDecoder.treeDecode( ByteBuffer.wrap( snaccBytes ) ) ;
-        //root.analyze() ;
-        
-        if ( root == null )
-        {
-            System.out.println( "nothing decoded" ) ;
-            return ;
-        }
-        
-        buf = ByteBuffer.allocate( root.size() ) ;
-        root.encode( buf ) ;
-        buf.flip() ;
-        byte[] snickersBytes = new byte[buf.remaining()] ;
-        buf.get( snickersBytes ) ;
-        String snickersEncoded = new String( Hex.encodeHex( snickersBytes ) ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.nio.ByteBuffer ;
+import java.math.BigInteger ;
+import java.io.ByteArrayInputStream ;
+
+import org.apache.commons.codec.binary.Hex ;
+import org.apache.ldap.common.message.AbandonRequest ;
+import org.apache.ldap.common.message.MessageDecoder ;
+import org.apache.ldap.common.message.MessageEncoder ;
+import org.apache.ldap.common.message.AbandonRequestImpl ;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Testing out round trip encode decode.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class EncodeDecodeTests extends TestCase
+{
+    public void testAbandonRequest() throws Exception
+    {
+        DefaultMutableTupleNode root = null ;
+        ByteBuffer buf = null ;
+        AbandonRequestImpl request = new AbandonRequestImpl( BigInteger.ONE ) ;
+        request.setAbandoned( new BigInteger( "3" ) ) ;
+        
+        MessageEncoder encoder = new MessageEncoder() ;
+        byte[] snaccBytes = encoder.encode( request ) ;
+        
+        String snaccEncoded = new String( Hex.encodeHex( snaccBytes ) ) ;
+        System.out.println( "snacc encoded = [" + snaccEncoded + "][" 
+                + snaccBytes.length + "]" ) ;
+        
+        MessageDecoder decoder = new MessageDecoder() ;
+        AbandonRequest msg = ( AbandonRequest ) decoder.decode( null, 
+                new ByteArrayInputStream( snaccBytes ) ) ;
+        assertTrue( msg.getMessageId().equals( request.getMessageId() ) ) ;
+        
+        System.out.println( "snacc decoded = " + msg ) ;
+        
+        root = ( DefaultMutableTupleNode ) 
+            TupleTreeDecoder.treeDecode( ByteBuffer.wrap( snaccBytes ) ) ;
+        //root.analyze() ;
+        
+        if ( root == null )
+        {
+            System.out.println( "nothing decoded" ) ;
+            return ;
+        }
+        
+        buf = ByteBuffer.allocate( root.size() ) ;
+        root.encode( buf ) ;
+        buf.flip() ;
+        byte[] snickersBytes = new byte[buf.remaining()] ;
+        buf.get( snickersBytes ) ;
+        String snickersEncoded = new String( Hex.encodeHex( snickersBytes ) ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/IntStackTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/IntStackTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/IntStackTest.java	Sun Mar 14 14:02:18 2004
@@ -1,151 +1,151 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.util.EmptyStackException ;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests the IntStack class.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class IntStackTest extends TestCase
-{
-    IntStack stack = null ;
-    
-    
-    /**
-     * Runs the test. 
-     * 
-     * @param args nada
-     */
-    public static void main( String[] args )
-    {
-        junit.textui.TestRunner.run( IntStackTest.class ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp() ;
-        stack = new IntStack() ;
-    }
-    
-    
-    /**
-     * Constructor for IntStackTest.
-     * @param arg0
-     */
-    public IntStackTest( String arg0 )
-    {
-        super( arg0 ) ;
-    }
-
-    
-    public void testEmpty()
-    {
-        assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
-        stack.push( 0 ) ;
-        assertFalse( "Stack with item should not be empty", stack.empty() ) ;
-        stack.pop() ;
-        assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
-    }
-
-    
-    public void testPeek()
-    {
-        try
-        {
-            stack.peek() ;
-            throw new AssertionError( 
-                    "Peek should have thrown an EmptyStackException" ) ;
-        }
-        catch( EmptyStackException e )
-        {
-            assertNotNull( "EmptyStackException should not be null", e ) ;
-        }
-        
-        for( int ii = 0; ii < 10; ii++ )
-        {    
-            stack.push( ii ) ;
-            assertEquals( ii, stack.peek() ) ;
-        }
-    }
-
-    
-    public void testPop()
-    {
-        try
-        {
-            stack.pop() ;
-            throw new AssertionError( 
-                    "Pop should have thrown an EmptyStackException" ) ;
-        }
-        catch( EmptyStackException e )
-        {
-            assertNotNull( "EmptyStackException should not be null", e ) ;
-        }
-        
-        for( int ii = 0; ii < 10; ii++ )
-        {    
-            stack.push( ii ) ;
-            assertEquals( ii, stack.pop() ) ;
-        }
-
-        for( int ii = 0; ii < 10; ii++ )
-        {    
-            stack.push( ii ) ;
-        }
-        for( int ii = 10; ii < 0; ii-- )
-        {    
-            stack.push( ii ) ;
-            assertEquals( ii, stack.pop() ) ;
-        }
-    }
-
-    
-    public void testPush()
-    {
-        stack.push( 0 ) ;
-        stack.push( 0 ) ;
-        assertFalse( stack.empty() ) ;
-        assertEquals( 0, stack.pop() ) ;
-        assertEquals( 0, stack.pop() ) ;
-    }
-
-    
-    public void testSearch()
-    {
-        stack.push( 0 ) ;
-        stack.push( 1 ) ;
-        assertEquals( 2, stack.search( 0 ) ) ;
-        stack.push( 0 ) ;
-        assertEquals( 1, stack.search( 0 ) ) ;
-        stack.push( 0 ) ;
-        assertEquals( 3, stack.search( 1 ) ) ;
-        assertEquals( -1, stack.search( 44 ) ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.util.EmptyStackException ;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests the IntStack class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class IntStackTest extends TestCase
+{
+    IntStack stack = null ;
+    
+    
+    /**
+     * Runs the test. 
+     * 
+     * @param args nada
+     */
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( IntStackTest.class ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp() ;
+        stack = new IntStack() ;
+    }
+    
+    
+    /**
+     * Constructor for IntStackTest.
+     * @param arg0
+     */
+    public IntStackTest( String arg0 )
+    {
+        super( arg0 ) ;
+    }
+
+    
+    public void testEmpty()
+    {
+        assertTrue( "Newly created stacks should be empty", stack.empty() ) ;
+        stack.push( 0 ) ;
+        assertFalse( "Stack with item should not be empty", stack.empty() ) ;
+        stack.pop() ;
+        assertTrue( "Stack last int popped should be empty", stack.empty() ) ;
+    }
+
+    
+    public void testPeek()
+    {
+        try
+        {
+            stack.peek() ;
+            throw new AssertionError( 
+                    "Peek should have thrown an EmptyStackException" ) ;
+        }
+        catch( EmptyStackException e )
+        {
+            assertNotNull( "EmptyStackException should not be null", e ) ;
+        }
+        
+        for( int ii = 0; ii < 10; ii++ )
+        {    
+            stack.push( ii ) ;
+            assertEquals( ii, stack.peek() ) ;
+        }
+    }
+
+    
+    public void testPop()
+    {
+        try
+        {
+            stack.pop() ;
+            throw new AssertionError( 
+                    "Pop should have thrown an EmptyStackException" ) ;
+        }
+        catch( EmptyStackException e )
+        {
+            assertNotNull( "EmptyStackException should not be null", e ) ;
+        }
+        
+        for( int ii = 0; ii < 10; ii++ )
+        {    
+            stack.push( ii ) ;
+            assertEquals( ii, stack.pop() ) ;
+        }
+
+        for( int ii = 0; ii < 10; ii++ )
+        {    
+            stack.push( ii ) ;
+        }
+        for( int ii = 10; ii < 0; ii-- )
+        {    
+            stack.push( ii ) ;
+            assertEquals( ii, stack.pop() ) ;
+        }
+    }
+
+    
+    public void testPush()
+    {
+        stack.push( 0 ) ;
+        stack.push( 0 ) ;
+        assertFalse( stack.empty() ) ;
+        assertEquals( 0, stack.pop() ) ;
+        assertEquals( 0, stack.pop() ) ;
+    }
+
+    
+    public void testSearch()
+    {
+        stack.push( 0 ) ;
+        stack.push( 1 ) ;
+        assertEquals( 2, stack.search( 0 ) ) ;
+        stack.push( 0 ) ;
+        assertEquals( 1, stack.search( 0 ) ) ;
+        stack.push( 0 ) ;
+        assertEquals( 3, stack.search( 1 ) ) ;
+        assertEquals( -1, stack.search( 44 ) ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/LdapMessageTests.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/LdapMessageTests.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/LdapMessageTests.java	Sun Mar 14 14:02:18 2004
@@ -1,159 +1,159 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.math.BigInteger ;
-
-import javax.naming.directory.Attributes ;
-
-import org.apache.ldap.common.message.ScopeEnum ;
-import org.apache.ldap.common.filter.PresenceNode ;
-import org.apache.ldap.common.message.AddRequestImpl ;
-import org.apache.ldap.common.message.BindRequestImpl ;
-import org.apache.ldap.common.message.DerefAliasesEnum ;
-import org.apache.ldap.common.message.DeleteRequestImpl ;
-import org.apache.ldap.common.message.SearchRequestImpl ;
-import org.apache.ldap.common.message.ModifyRequestImpl ;
-import org.apache.ldap.common.message.AbandonRequestImpl ;
-import org.apache.ldap.common.message.CompareRequestImpl ;
-import org.apache.ldap.common.message.ExtendedRequestImpl ;
-import org.apache.ldap.common.message.ModifyDnRequestImpl ;
-import org.apache.ldap.common.message.LockableAttributesImpl ;
-
-
-/**
- * $todo$ doc me
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class LdapMessageTests extends AbstractDecoderTestCase
-{
-    public LdapMessageTests()
-    {
-        super ( LdapMessageTests.class.getName() ) ;
-    }
-    
-    
-    public void testBindMessage() throws Exception
-    {
-        BindRequestImpl request = new BindRequestImpl( BigInteger.ONE ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setSimple( true ) ;
-        request.setCredentials( "password".getBytes() ) ;
-        request.setVersion3( true ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-
-
-    public void testAddMessage() throws Exception
-    {
-        AddRequestImpl request = new AddRequestImpl( BigInteger.ONE ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        
-        Attributes attrs = new LockableAttributesImpl() ;
-        attrs.put( "attr0", "val0" ) ;
-        attrs.put( "attr0", "val1" ) ;
-        attrs.put( "attr0", "val2" ) ;
-        attrs.put( "attr1", "val0" ) ;
-        attrs.put( "attr2", "val0" ) ;
-        attrs.put( "attr2", "val1" ) ;
-        
-        request.setEntry( attrs ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-
-
-    public void testDeleteMessage() throws Exception
-    {
-        DeleteRequestImpl request = new DeleteRequestImpl( BigInteger.ONE ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-
-
-    public void testAbandonMessage() throws Exception
-    {
-        AbandonRequestImpl request = new AbandonRequestImpl( BigInteger.ONE ) ;
-        request.setAbandoned( new BigInteger( "3" ) ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-
-
-    public void testCompareMessage() throws Exception
-    {
-        CompareRequestImpl request = new CompareRequestImpl( BigInteger.ONE ) ;
-        request.setAssertionValue( "testvalue" ) ;
-        request.setAttributeId( "testattr" ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-
-
-    public void testExtendedMessage() throws Exception
-    {
-        ExtendedRequestImpl request = new ExtendedRequestImpl( BigInteger.ONE ) ;
-        request.setOid( "1234.1234.1324" ) ;
-        request.setPayload( "Hello World".getBytes() ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-
-
-    public void testModifyDnMessage() throws Exception
-    {
-        ModifyDnRequestImpl request = new ModifyDnRequestImpl( BigInteger.ONE ) ;
-        request.setDeleteOldRdn(true) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setNewRdn( "uid=aok" ) ;
-        request.setNewSuperior( "dc=example,dc=com" ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-
-
-    public void testModifyMessage() throws Exception
-    {
-        ModifyRequestImpl request = 
-            new ModifyRequestImpl( new BigInteger( "17" ) ) ;
-        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-
-
-    public void testSearchMessage() throws Exception
-    {
-        SearchRequestImpl request = new SearchRequestImpl( BigInteger.ONE ) ;
-        request.setBase( "uid=akarasulu,dc=example,dc=com" ) ;
-        request.setDerefAliases( DerefAliasesEnum.DEREFALWAYS ) ;
-        PresenceNode node = new PresenceNode( "attrib0" ) ;
-        request.setFilter( node ) ;
-        request.setScope( ScopeEnum.BASEOBJECT ) ;
-        request.setSizeLimit( BigInteger.ZERO ) ;
-        request.setTimeLimit( BigInteger.ZERO ) ;
-        decode( request ) ;
-        assertFalse( tlvList.isEmpty() ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.math.BigInteger ;
+
+import javax.naming.directory.Attributes ;
+
+import org.apache.ldap.common.message.ScopeEnum ;
+import org.apache.ldap.common.filter.PresenceNode ;
+import org.apache.ldap.common.message.AddRequestImpl ;
+import org.apache.ldap.common.message.BindRequestImpl ;
+import org.apache.ldap.common.message.DerefAliasesEnum ;
+import org.apache.ldap.common.message.DeleteRequestImpl ;
+import org.apache.ldap.common.message.SearchRequestImpl ;
+import org.apache.ldap.common.message.ModifyRequestImpl ;
+import org.apache.ldap.common.message.AbandonRequestImpl ;
+import org.apache.ldap.common.message.CompareRequestImpl ;
+import org.apache.ldap.common.message.ExtendedRequestImpl ;
+import org.apache.ldap.common.message.ModifyDnRequestImpl ;
+import org.apache.ldap.common.message.LockableAttributesImpl ;
+
+
+/**
+ * $todo$ doc me
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class LdapMessageTests extends AbstractDecoderTestCase
+{
+    public LdapMessageTests()
+    {
+        super ( LdapMessageTests.class.getName() ) ;
+    }
+    
+    
+    public void testBindMessage() throws Exception
+    {
+        BindRequestImpl request = new BindRequestImpl( BigInteger.ONE ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        request.setSimple( true ) ;
+        request.setCredentials( "password".getBytes() ) ;
+        request.setVersion3( true ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+
+
+    public void testAddMessage() throws Exception
+    {
+        AddRequestImpl request = new AddRequestImpl( BigInteger.ONE ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        
+        Attributes attrs = new LockableAttributesImpl() ;
+        attrs.put( "attr0", "val0" ) ;
+        attrs.put( "attr0", "val1" ) ;
+        attrs.put( "attr0", "val2" ) ;
+        attrs.put( "attr1", "val0" ) ;
+        attrs.put( "attr2", "val0" ) ;
+        attrs.put( "attr2", "val1" ) ;
+        
+        request.setEntry( attrs ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+
+
+    public void testDeleteMessage() throws Exception
+    {
+        DeleteRequestImpl request = new DeleteRequestImpl( BigInteger.ONE ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+
+
+    public void testAbandonMessage() throws Exception
+    {
+        AbandonRequestImpl request = new AbandonRequestImpl( BigInteger.ONE ) ;
+        request.setAbandoned( new BigInteger( "3" ) ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+
+
+    public void testCompareMessage() throws Exception
+    {
+        CompareRequestImpl request = new CompareRequestImpl( BigInteger.ONE ) ;
+        request.setAssertionValue( "testvalue" ) ;
+        request.setAttributeId( "testattr" ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+
+
+    public void testExtendedMessage() throws Exception
+    {
+        ExtendedRequestImpl request = new ExtendedRequestImpl( BigInteger.ONE ) ;
+        request.setOid( "1234.1234.1324" ) ;
+        request.setPayload( "Hello World".getBytes() ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+
+
+    public void testModifyDnMessage() throws Exception
+    {
+        ModifyDnRequestImpl request = new ModifyDnRequestImpl( BigInteger.ONE ) ;
+        request.setDeleteOldRdn(true) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        request.setNewRdn( "uid=aok" ) ;
+        request.setNewSuperior( "dc=example,dc=com" ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+
+
+    public void testModifyMessage() throws Exception
+    {
+        ModifyRequestImpl request = 
+            new ModifyRequestImpl( new BigInteger( "17" ) ) ;
+        request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+
+
+    public void testSearchMessage() throws Exception
+    {
+        SearchRequestImpl request = new SearchRequestImpl( BigInteger.ONE ) ;
+        request.setBase( "uid=akarasulu,dc=example,dc=com" ) ;
+        request.setDerefAliases( DerefAliasesEnum.DEREFALWAYS ) ;
+        PresenceNode node = new PresenceNode( "attrib0" ) ;
+        request.setFilter( node ) ;
+        request.setScope( ScopeEnum.BASEOBJECT ) ;
+        request.setSizeLimit( BigInteger.ZERO ) ;
+        request.setTimeLimit( BigInteger.ZERO ) ;
+        decode( request ) ;
+        assertFalse( tlvList.isEmpty() ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/MultiByteLengthTests.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/MultiByteLengthTests.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/MultiByteLengthTests.java	Sun Mar 14 14:02:18 2004
@@ -1,146 +1,146 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-/**
- * Tests single byte length encodings in a BER TLV.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class MultiByteLengthTests extends AbstractDecoderTestCase
-{
-    /**
-     * Creates a single byte lenth test case.
-     * 
-     * @param name the name of this test
-     */
-    public MultiByteLengthTests( String name )
-    {
-        super( name ) ;
-    }
-
-    
-    public void testLength128() throws Exception
-    {
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-        
-        tlv = decode( "10000001" ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 128, tlv.length ) ;
-    }
-
-
-    public void testLength129() throws Exception
-    {
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-        
-        tlv = decode( "10000001" ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-
-        tlv = decode( "10000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 129, tlv.length ) ;
-    }
-
-
-    public void testLength255() throws Exception
-    {
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-        
-        tlv = decode( "10000001" ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 255, tlv.length ) ;
-    }
-    
-    
-    public void testLength32768() throws Exception
-    {
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-        
-        tlv = decode( "10000010" ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-
-        tlv = decode( "00000000" ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 32768, tlv.length ) ;
-    }
-    
-    
-    public void testLength65535() throws Exception
-    {
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-        
-        tlv = decode( "10000010" ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 65535, tlv.length ) ;
-    }
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+/**
+ * Tests single byte length encodings in a BER TLV.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MultiByteLengthTests extends AbstractDecoderTestCase
+{
+    /**
+     * Creates a single byte lenth test case.
+     * 
+     * @param name the name of this test
+     */
+    public MultiByteLengthTests( String name )
+    {
+        super( name ) ;
+    }
+
+    
+    public void testLength128() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+        
+        tlv = decode( "10000001" ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 128, tlv.length ) ;
+    }
+
+
+    public void testLength129() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+        
+        tlv = decode( "10000001" ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 129, tlv.length ) ;
+    }
+
+
+    public void testLength255() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+        
+        tlv = decode( "10000001" ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 255, tlv.length ) ;
+    }
+    
+    
+    public void testLength32768() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+        
+        tlv = decode( "10000010" ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+
+        tlv = decode( "00000000" ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 32768, tlv.length ) ;
+    }
+    
+    
+    public void testLength65535() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+        
+        tlv = decode( "10000010" ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 65535, tlv.length ) ;
+    }
 }

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/MultiByteTagTests.java	Sun Mar 14 14:02:18 2004
@@ -1,354 +1,354 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-/**
- * Here we test simple 1 byte tag and length values to test the decoder's 
- * ability to handle these most simple tlvs.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class MultiByteTagTests extends AbstractDecoderTestCase
-{
-
-    /**
-     * @param arg0
-     */
-    public MultiByteTagTests( String arg0 )
-    {
-        super( arg0 ) ;
-    }
-    
-    
-    public void testId31() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00011111" ) ;
-        assertEquals( 31, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId100() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "01100100" ) ;
-        assertEquals( 100, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId127() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "01111111" ) ;
-        assertEquals( 127, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId128() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00000001" ) ;
-        assertEquals( 128, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId129() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000001" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00000001" ) ;
-        assertEquals( 129, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-
-
-    public void testIdShift14() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_13, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testIdShift14Minus1() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "01111111" ) ;
-        assertEquals( Tuple.BIT_13 - 1, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testIdShift14Plus1() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000001" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_13 + 1, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-    
-    public void testIdShift21() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_20, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testIdShift21Minus1() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "01111111" ) ;
-        assertEquals( Tuple.BIT_20 - 1, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testIdShift21Plus1() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000001" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_20 + 1, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testIdShift28() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_27, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testIdShift28Minus1() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "11111111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "01111111" ) ;
-        assertEquals( Tuple.BIT_27 - 1, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testIdShift28Plus1() throws Exception
-    {
-        Tuple tlv = decode( "01011111" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000001" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "10000000" ) ;
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-
-        tlv = decode( "00000001" ) ;
-        assertEquals( Tuple.BIT_27 + 1, tlv.id ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+/**
+ * Here we test simple 1 byte tag and length values to test the decoder's 
+ * ability to handle these most simple tlvs.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MultiByteTagTests extends AbstractDecoderTestCase
+{
+
+    /**
+     * @param arg0
+     */
+    public MultiByteTagTests( String arg0 )
+    {
+        super( arg0 ) ;
+    }
+    
+    
+    public void testId31() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00011111" ) ;
+        assertEquals( 31, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId100() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01100100" ) ;
+        assertEquals( 100, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId127() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01111111" ) ;
+        assertEquals( 127, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId128() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( 128, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId129() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( 129, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+
+
+    public void testIdShift14() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.BIT_13, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift14Minus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01111111" ) ;
+        assertEquals( Tuple.BIT_13 - 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift14Plus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.BIT_13 + 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+    
+    public void testIdShift21() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.BIT_20, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift21Minus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01111111" ) ;
+        assertEquals( Tuple.BIT_20 - 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift21Plus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.BIT_20 + 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift28() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.BIT_27, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift28Minus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "11111111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "01111111" ) ;
+        assertEquals( Tuple.BIT_27 - 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testIdShift28Plus1() throws Exception
+    {
+        Tuple tlv = decode( "01011111" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000001" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "10000000" ) ;
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+
+        tlv = decode( "00000001" ) ;
+        assertEquals( Tuple.BIT_27 + 1, tlv.id ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/ObjectVersePrimitiveTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/ObjectVersePrimitiveTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/ObjectVersePrimitiveTest.java	Sun Mar 14 14:02:18 2004
@@ -1,158 +1,158 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.util.Stack;
-
-import org.apache.commons.lang.time.StopWatch;
-
-import junit.framework.TestCase ;
-
-
-/**
- * $todo$ doc me
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class ObjectVersePrimitiveTest extends TestCase
-{
-    public static final int MEMBER_COUNT = 3 ;
-    public static final int INSTANCE_COUNT = 1000000 ;
-    public static final Class OBJECT_CLASS = Tuple.class ;
-    
-    long objTime = 0 ;
-    double objTimePerInst = 0.0 ;
-    long objTimeNew = 0 ;
-    double objTimeNewPerInst = 0.0 ;
-    long intTime = 0 ;
-    double intTimePerInst = 0.0 ;
-    
-    IntStack[] intStacks = new IntStack[MEMBER_COUNT] ;
-    Stack objStack = null ;
-
-    
-    public static void main( String[] args )
-    {
-        junit.textui.TestRunner.run( ObjectVersePrimitiveTest.class ) ;
-    }
-
-    
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp() ;
-        
-        objStack = new Stack() ;
-        for ( int ii = 0; ii < intStacks.length; ii++ )
-        {
-            intStacks[ii] = new IntStack() ;
-        }
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-        
-        objStack = null ;
-        for ( int ii = 0; ii < intStacks.length; ii++ )
-        {
-            intStacks[ii] = null ;
-        }
-    }
-    
-    
-    public void testObject()
-    {
-        StopWatch sw = new StopWatch() ;
-        sw.start() ;
-        for ( int ii = 0; ii < INSTANCE_COUNT; ii++ )
-        {
-            Object obj = new Tuple() ;
-            objStack.push( obj ) ;
-            objStack.pop() ;
-        }
-        sw.stop() ;
-        objTime = sw.getTime() ;
-        objTimePerInst = objTime/INSTANCE_COUNT ;
-        System.out.println( "----------------------------------------------" ) ;
-        System.out.println( "TEST: java.lang.Object create, push and pop" ) ;
-        System.out.println( "----------------------------------------------" ) ;
-        System.out.println( "# of Instances: " + INSTANCE_COUNT ) ;
-        System.out.println( "Total Time: " + objTime ) ;
-        System.out.println( "Per Instance Time: " + objTimePerInst ) ;
-        System.out.println( "----------------------------------------------" ) ;
-    }
-    
-
-    public void testObjectNewInstance() throws Exception
-    {
-        StopWatch sw = new StopWatch() ;
-        sw.start() ;
-        for ( int ii = 0; ii < INSTANCE_COUNT; ii++ )
-        {
-            Object obj = OBJECT_CLASS.newInstance() ;
-            objStack.push( obj ) ;
-            objStack.pop() ;
-        }
-        sw.stop() ;
-        objTimeNew = sw.getTime() ;
-        objTimeNewPerInst = objTimeNew/INSTANCE_COUNT ;
-        System.out.println( "----------------------------------------------" ) ;
-        System.out.println( "TEST: " + OBJECT_CLASS 
-                + ".newInstance create, push, pop" ) ;
-        System.out.println( "----------------------------------------------" ) ;
-        System.out.println( "# of Instances: " + INSTANCE_COUNT ) ;
-        System.out.println( "Total Time: " + objTimeNew ) ;
-        System.out.println( "Per Instance Time: " + objTimeNewPerInst ) ;
-        System.out.println( "----------------------------------------------" ) ;
-    }
-
-
-    public void testPrimitive()
-    {
-        StopWatch sw = new StopWatch() ;
-        sw.start() ;
-        for ( int ii = 0; ii < INSTANCE_COUNT; ii++ )
-        {
-            for ( int jj = 0; jj < MEMBER_COUNT; jj++ )
-            {
-                intStacks[jj].push( jj ) ;
-                intStacks[jj].pop() ;
-            }
-        }
-        sw.stop() ;
-        intTime = sw.getTime() ;
-        intTimePerInst = intTime/INSTANCE_COUNT ;
-        System.out.println( "----------------------------------------------" ) ;
-        System.out.println( "TEST: push " + MEMBER_COUNT + " primitive ints "
-                + "onto separate stacks then pop em" ) ;
-        System.out.println( "----------------------------------------------" ) ;
-        System.out.println( "# of Instances: " + INSTANCE_COUNT ) ;
-        System.out.println( "Total Time: " + intTime ) ;
-        System.out.println( "Per Instance Time: " + intTimePerInst ) ;
-        System.out.println( "----------------------------------------------" ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.util.Stack;
+
+import org.apache.commons.lang.time.StopWatch;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * $todo$ doc me
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ObjectVersePrimitiveTest extends TestCase
+{
+    public static final int MEMBER_COUNT = 3 ;
+    public static final int INSTANCE_COUNT = 1000000 ;
+    public static final Class OBJECT_CLASS = Tuple.class ;
+    
+    long objTime = 0 ;
+    double objTimePerInst = 0.0 ;
+    long objTimeNew = 0 ;
+    double objTimeNewPerInst = 0.0 ;
+    long intTime = 0 ;
+    double intTimePerInst = 0.0 ;
+    
+    IntStack[] intStacks = new IntStack[MEMBER_COUNT] ;
+    Stack objStack = null ;
+
+    
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( ObjectVersePrimitiveTest.class ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp() ;
+        
+        objStack = new Stack() ;
+        for ( int ii = 0; ii < intStacks.length; ii++ )
+        {
+            intStacks[ii] = new IntStack() ;
+        }
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        
+        objStack = null ;
+        for ( int ii = 0; ii < intStacks.length; ii++ )
+        {
+            intStacks[ii] = null ;
+        }
+    }
+    
+    
+    public void testObject()
+    {
+        StopWatch sw = new StopWatch() ;
+        sw.start() ;
+        for ( int ii = 0; ii < INSTANCE_COUNT; ii++ )
+        {
+            Object obj = new Tuple() ;
+            objStack.push( obj ) ;
+            objStack.pop() ;
+        }
+        sw.stop() ;
+        objTime = sw.getTime() ;
+        objTimePerInst = objTime/INSTANCE_COUNT ;
+        System.out.println( "----------------------------------------------" ) ;
+        System.out.println( "TEST: java.lang.Object create, push and pop" ) ;
+        System.out.println( "----------------------------------------------" ) ;
+        System.out.println( "# of Instances: " + INSTANCE_COUNT ) ;
+        System.out.println( "Total Time: " + objTime ) ;
+        System.out.println( "Per Instance Time: " + objTimePerInst ) ;
+        System.out.println( "----------------------------------------------" ) ;
+    }
+    
+
+    public void testObjectNewInstance() throws Exception
+    {
+        StopWatch sw = new StopWatch() ;
+        sw.start() ;
+        for ( int ii = 0; ii < INSTANCE_COUNT; ii++ )
+        {
+            Object obj = OBJECT_CLASS.newInstance() ;
+            objStack.push( obj ) ;
+            objStack.pop() ;
+        }
+        sw.stop() ;
+        objTimeNew = sw.getTime() ;
+        objTimeNewPerInst = objTimeNew/INSTANCE_COUNT ;
+        System.out.println( "----------------------------------------------" ) ;
+        System.out.println( "TEST: " + OBJECT_CLASS 
+                + ".newInstance create, push, pop" ) ;
+        System.out.println( "----------------------------------------------" ) ;
+        System.out.println( "# of Instances: " + INSTANCE_COUNT ) ;
+        System.out.println( "Total Time: " + objTimeNew ) ;
+        System.out.println( "Per Instance Time: " + objTimeNewPerInst ) ;
+        System.out.println( "----------------------------------------------" ) ;
+    }
+
+
+    public void testPrimitive()
+    {
+        StopWatch sw = new StopWatch() ;
+        sw.start() ;
+        for ( int ii = 0; ii < INSTANCE_COUNT; ii++ )
+        {
+            for ( int jj = 0; jj < MEMBER_COUNT; jj++ )
+            {
+                intStacks[jj].push( jj ) ;
+                intStacks[jj].pop() ;
+            }
+        }
+        sw.stop() ;
+        intTime = sw.getTime() ;
+        intTimePerInst = intTime/INSTANCE_COUNT ;
+        System.out.println( "----------------------------------------------" ) ;
+        System.out.println( "TEST: push " + MEMBER_COUNT + " primitive ints "
+                + "onto separate stacks then pop em" ) ;
+        System.out.println( "----------------------------------------------" ) ;
+        System.out.println( "# of Instances: " + INSTANCE_COUNT ) ;
+        System.out.println( "Total Time: " + intTime ) ;
+        System.out.println( "Per Instance Time: " + intTimePerInst ) ;
+        System.out.println( "----------------------------------------------" ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SimplePrimitiveTLVTests.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SimplePrimitiveTLVTests.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SimplePrimitiveTLVTests.java	Sun Mar 14 14:02:18 2004
@@ -1,162 +1,162 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-/**
- * Performs simple primitive tlv tests.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class SimplePrimitiveTLVTests extends AbstractDecoderTestCase
-{
-
-    /**
-     * @param arg0
-     */
-    public SimplePrimitiveTLVTests( String arg0 )
-    {
-        super( arg0 ) ;
-    }
-    
-    
-    public void testSingleSimpleTLV() throws Exception
-    {
-        // decode tag
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "00000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-        
-        // decode value
-        tlv = decode( "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 1, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
-    }
-
-
-    public void testMultipleSimpleTLV() throws Exception
-    {
-        // decode tag
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "00000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-        
-        // decode value
-        tlv = decode( "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 1, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
-
-    
-        // decode tag
-        tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 1, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "00000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-        
-        // decode value
-        tlv = decode( "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 2, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
-
-    
-        // decode tag
-        tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 2, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "00000001" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-        
-        // decode value
-        tlv = decode( "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 3, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
-    }
-
-
-    public void testSingleSimpleLongTLV() throws Exception
-    {
-        // decode tag
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        
-        // decode length 
-        tlv = decode( "10000001" ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-        
-        tlv = decode( "00000111" ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 7, tlv.length ) ;
-        
-        // decode value
-        tlv = decode( "01010101" + "01010101" + "01010101" + "01010101"
-                + "01010101" + "01010101" + "01010101" ) ;
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-        assertEquals( 1, tlvList.size() ) ;
-        assertNotNull( tlv.value ) ;
-        assertEquals( 7, ((byte[]) tlv.value).length) ;
-        
-        byte[] value = (byte[]) tlv.value ;
-        for ( int ii = 0 ; ii < 7; ii++ )
-        {    
-            assertEquals( 0x0055, 0x00ff & ( int ) value[ii] ) ;
-        }
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+/**
+ * Performs simple primitive tlv tests.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SimplePrimitiveTLVTests extends AbstractDecoderTestCase
+{
+
+    /**
+     * @param arg0
+     */
+    public SimplePrimitiveTLVTests( String arg0 )
+    {
+        super( arg0 ) ;
+    }
+    
+    
+    public void testSingleSimpleTLV() throws Exception
+    {
+        // decode tag
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "00000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+        
+        // decode value
+        tlv = decode( "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 1, tlvList.size() ) ;
+        assertNotNull( tlv.value ) ;
+        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
+    }
+
+
+    public void testMultipleSimpleTLV() throws Exception
+    {
+        // decode tag
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "00000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+        
+        // decode value
+        tlv = decode( "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 1, tlvList.size() ) ;
+        assertNotNull( tlv.value ) ;
+        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
+
+    
+        // decode tag
+        tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 1, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "00000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+        
+        // decode value
+        tlv = decode( "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 2, tlvList.size() ) ;
+        assertNotNull( tlv.value ) ;
+        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
+
+    
+        // decode tag
+        tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 2, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "00000001" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+        
+        // decode value
+        tlv = decode( "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 3, tlvList.size() ) ;
+        assertNotNull( tlv.value ) ;
+        assertEquals( 0x0055, 0x00ff & ( int ) ( (byte[]) tlv.value)[0] ) ;
+    }
+
+
+    public void testSingleSimpleLongTLV() throws Exception
+    {
+        // decode tag
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        
+        // decode length 
+        tlv = decode( "10000001" ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+        
+        tlv = decode( "00000111" ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 7, tlv.length ) ;
+        
+        // decode value
+        tlv = decode( "01010101" + "01010101" + "01010101" + "01010101"
+                + "01010101" + "01010101" + "01010101" ) ;
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+        assertEquals( 1, tlvList.size() ) ;
+        assertNotNull( tlv.value ) ;
+        assertEquals( 7, ((byte[]) tlv.value).length) ;
+        
+        byte[] value = (byte[]) tlv.value ;
+        for ( int ii = 0 ; ii < 7; ii++ )
+        {    
+            assertEquals( 0x0055, 0x00ff & ( int ) value[ii] ) ;
+        }
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SingleByteLengthTests.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SingleByteLengthTests.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SingleByteLengthTests.java	Sun Mar 14 14:02:18 2004
@@ -1,86 +1,86 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-/**
- * Tests single byte length encodings in a BER TLV.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class SingleByteLengthTests extends AbstractDecoderTestCase
-{
-    /**
-     * Creates a single byte lenth test case.
-     * 
-     * @param name the name of this test
-     */
-    public SingleByteLengthTests( String name )
-    {
-        super( name ) ;
-    }
-
-    
-    public void testLength0() throws Exception
-    {
-        Tuple tlv = decode( "00000000" + "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 0, tlv.length ) ;
-    }
-
-
-    public void testLength1() throws Exception
-    {
-        Tuple tlv = decode( "00000001" + "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 1, tlv.length ) ;
-    }
-
-
-    public void testLength3() throws Exception
-    {
-        Tuple tlv = decode( "00000011" + "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 3, tlv.length ) ;
-    }
-
-
-    public void testLength127() throws Exception
-    {
-        Tuple tlv = decode( "01111111" + "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
-        assertEquals( 127, tlv.length ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+/**
+ * Tests single byte length encodings in a BER TLV.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SingleByteLengthTests extends AbstractDecoderTestCase
+{
+    /**
+     * Creates a single byte lenth test case.
+     * 
+     * @param name the name of this test
+     */
+    public SingleByteLengthTests( String name )
+    {
+        super( name ) ;
+    }
+
+    
+    public void testLength0() throws Exception
+    {
+        Tuple tlv = decode( "00000000" + "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 0, tlv.length ) ;
+    }
+
+
+    public void testLength1() throws Exception
+    {
+        Tuple tlv = decode( "00000001" + "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 1, tlv.length ) ;
+    }
+
+
+    public void testLength3() throws Exception
+    {
+        Tuple tlv = decode( "00000011" + "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 3, tlv.length ) ;
+    }
+
+
+    public void testLength127() throws Exception
+    {
+        Tuple tlv = decode( "01111111" + "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.VALUE, decoder.getState() ) ;
+        assertEquals( 127, tlv.length ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SingleByteTagTests.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SingleByteTagTests.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/SingleByteTagTests.java	Sun Mar 14 14:02:18 2004
@@ -1,450 +1,450 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-/**
- * Here we test simple 1 byte tag and length values to test the decoder's 
- * ability to handle these most simple tlvs.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class SingleByteTagTests extends AbstractDecoderTestCase
-{
-
-    /**
-     * @param arg0
-     */
-    public SingleByteTagTests( String arg0 )
-    {
-        super( arg0 ) ;
-    }
-    
-    
-    public void testAppTypeClass() throws Exception
-    {
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testPrivTypeClass() throws Exception
-    {
-        Tuple tlv = decode( "11000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.PRIVATE, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testCtxTypeClass() throws Exception
-    {
-        Tuple tlv = decode( "10000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.CONTEXT_SPECIFIC, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-    
-    public void testUniTypeClass() throws Exception
-    {
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-
-    }
-    
-    public void testIllegalStateWithUniTypeClass() throws Exception
-    {
-        try
-        {
-            Tuple tlv = decode( "00000001" ) ;
-        }
-        catch( IllegalStateException e ) 
-        {
-            assertNotNull( e ) ;
-        }
-    }
-
-    public void testId1() throws Exception
-    {
-        Tuple tlv = decode( "01000001" ) ;
-        assertEquals( 1, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId2() throws Exception
-    {
-        Tuple tlv = decode( "01000010" ) ;
-        assertEquals( 2, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId3() throws Exception
-    {
-        Tuple tlv = decode( "01000011" ) ;
-        assertEquals( 3, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId4() throws Exception
-    {
-        Tuple tlv = decode( "01000100" ) ;
-        assertEquals( 4, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId5() throws Exception
-    {
-        Tuple tlv = decode( "01000101" ) ;
-        assertEquals( 5, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId6() throws Exception
-    {
-        Tuple tlv = decode( "01000110" ) ;
-        assertEquals( 6, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId7() throws Exception
-    {
-        Tuple tlv = decode( "01000111" ) ;
-        assertEquals( 7, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId8() throws Exception
-    {
-        Tuple tlv = decode( "01001000" ) ;
-        assertEquals( 8, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId9() throws Exception
-    {
-        Tuple tlv = decode( "01001001" ) ;
-        assertEquals( 9, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId10() throws Exception
-    {
-        Tuple tlv = decode( "01001010" ) ;
-        assertEquals( 10, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId11() throws Exception
-    {
-        Tuple tlv = decode( "01001011" ) ;
-        assertEquals( 11, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId12() throws Exception
-    {
-        Tuple tlv = decode( "01001100" ) ;
-        assertEquals( 12, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId13() throws Exception
-    {
-        Tuple tlv = decode( "01001101" ) ;
-        assertEquals( 13, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId14() throws Exception
-    {
-        Tuple tlv = decode( "01001110" ) ;
-        assertEquals( 14, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId15() throws Exception
-    {
-        Tuple tlv = decode( "01001111" ) ;
-        assertEquals( 15, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId16() throws Exception
-    {
-        Tuple tlv = decode( "01010000" ) ;
-        assertEquals( 16, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId17() throws Exception
-    {
-        Tuple tlv = decode( "01010001" ) ;
-        assertEquals( 17, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId18() throws Exception
-    {
-        Tuple tlv = decode( "01010010" ) ;
-        assertEquals( 18, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId19() throws Exception
-    {
-        Tuple tlv = decode( "01010011" ) ;
-        assertEquals( 19, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId20() throws Exception
-    {
-        Tuple tlv = decode( "01010100" ) ;
-        assertEquals( 20, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId21() throws Exception
-    {
-        Tuple tlv = decode( "01010101" ) ;
-        assertEquals( 21, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId22() throws Exception
-    {
-        Tuple tlv = decode( "01010110" ) ;
-        assertEquals( 22, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId23() throws Exception
-    {
-        Tuple tlv = decode( "01010111" ) ;
-        assertEquals( 23, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId24() throws Exception
-    {
-        Tuple tlv = decode( "01011000" ) ;
-        assertEquals( 24, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId25() throws Exception
-    {
-        Tuple tlv = decode( "01011001" ) ;
-        assertEquals( 25, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId26() throws Exception
-    {
-        Tuple tlv = decode( "01011010" ) ;
-        assertEquals( 26, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId27() throws Exception
-    {
-        Tuple tlv = decode( "01011011" ) ;
-        assertEquals( 27, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId28() throws Exception
-    {
-        Tuple tlv = decode( "01011100" ) ;
-        assertEquals( 28, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId29() throws Exception
-    {
-        Tuple tlv = decode( "01011101" ) ;
-        assertEquals( 29, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-
-
-    public void testId30() throws Exception
-    {
-        Tuple tlv = decode( "01011110" ) ;
-        assertEquals( 30, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-    
-    
-    public void testIdOverLimit() throws Exception
-    {
-        // this is the long form
-        Tuple tlv = decode( "01011111" ) ;
-        
-        assertEquals( 0, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( true, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        
-        // state did not switch since we are still reading the long tag  
-        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
-    }
-
-    
-    public void testIsConstructed() throws Exception
-    {
-        Tuple tlv = decode( "01111110" ) ;
-        assertEquals( 30, tlv.id ) ;
-        assertEquals( 0, tlvList.size() ) ;
-        assertEquals( false, tlv.isPrimitive ) ;
-        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
-        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+/**
+ * Here we test simple 1 byte tag and length values to test the decoder's 
+ * ability to handle these most simple tlvs.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SingleByteTagTests extends AbstractDecoderTestCase
+{
+
+    /**
+     * @param arg0
+     */
+    public SingleByteTagTests( String arg0 )
+    {
+        super( arg0 ) ;
+    }
+    
+    
+    public void testAppTypeClass() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testPrivTypeClass() throws Exception
+    {
+        Tuple tlv = decode( "11000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.PRIVATE, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testCtxTypeClass() throws Exception
+    {
+        Tuple tlv = decode( "10000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.CONTEXT_SPECIFIC, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+    
+    public void testUniTypeClass() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+
+    }
+    
+    public void testIllegalStateWithUniTypeClass() throws Exception
+    {
+        try
+        {
+            Tuple tlv = decode( "00000001" ) ;
+        }
+        catch( IllegalStateException e ) 
+        {
+            assertNotNull( e ) ;
+        }
+    }
+
+    public void testId1() throws Exception
+    {
+        Tuple tlv = decode( "01000001" ) ;
+        assertEquals( 1, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId2() throws Exception
+    {
+        Tuple tlv = decode( "01000010" ) ;
+        assertEquals( 2, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId3() throws Exception
+    {
+        Tuple tlv = decode( "01000011" ) ;
+        assertEquals( 3, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId4() throws Exception
+    {
+        Tuple tlv = decode( "01000100" ) ;
+        assertEquals( 4, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId5() throws Exception
+    {
+        Tuple tlv = decode( "01000101" ) ;
+        assertEquals( 5, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId6() throws Exception
+    {
+        Tuple tlv = decode( "01000110" ) ;
+        assertEquals( 6, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId7() throws Exception
+    {
+        Tuple tlv = decode( "01000111" ) ;
+        assertEquals( 7, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId8() throws Exception
+    {
+        Tuple tlv = decode( "01001000" ) ;
+        assertEquals( 8, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId9() throws Exception
+    {
+        Tuple tlv = decode( "01001001" ) ;
+        assertEquals( 9, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId10() throws Exception
+    {
+        Tuple tlv = decode( "01001010" ) ;
+        assertEquals( 10, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId11() throws Exception
+    {
+        Tuple tlv = decode( "01001011" ) ;
+        assertEquals( 11, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId12() throws Exception
+    {
+        Tuple tlv = decode( "01001100" ) ;
+        assertEquals( 12, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId13() throws Exception
+    {
+        Tuple tlv = decode( "01001101" ) ;
+        assertEquals( 13, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId14() throws Exception
+    {
+        Tuple tlv = decode( "01001110" ) ;
+        assertEquals( 14, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId15() throws Exception
+    {
+        Tuple tlv = decode( "01001111" ) ;
+        assertEquals( 15, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId16() throws Exception
+    {
+        Tuple tlv = decode( "01010000" ) ;
+        assertEquals( 16, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId17() throws Exception
+    {
+        Tuple tlv = decode( "01010001" ) ;
+        assertEquals( 17, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId18() throws Exception
+    {
+        Tuple tlv = decode( "01010010" ) ;
+        assertEquals( 18, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId19() throws Exception
+    {
+        Tuple tlv = decode( "01010011" ) ;
+        assertEquals( 19, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId20() throws Exception
+    {
+        Tuple tlv = decode( "01010100" ) ;
+        assertEquals( 20, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId21() throws Exception
+    {
+        Tuple tlv = decode( "01010101" ) ;
+        assertEquals( 21, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId22() throws Exception
+    {
+        Tuple tlv = decode( "01010110" ) ;
+        assertEquals( 22, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId23() throws Exception
+    {
+        Tuple tlv = decode( "01010111" ) ;
+        assertEquals( 23, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId24() throws Exception
+    {
+        Tuple tlv = decode( "01011000" ) ;
+        assertEquals( 24, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId25() throws Exception
+    {
+        Tuple tlv = decode( "01011001" ) ;
+        assertEquals( 25, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId26() throws Exception
+    {
+        Tuple tlv = decode( "01011010" ) ;
+        assertEquals( 26, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId27() throws Exception
+    {
+        Tuple tlv = decode( "01011011" ) ;
+        assertEquals( 27, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId28() throws Exception
+    {
+        Tuple tlv = decode( "01011100" ) ;
+        assertEquals( 28, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId29() throws Exception
+    {
+        Tuple tlv = decode( "01011101" ) ;
+        assertEquals( 29, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+
+
+    public void testId30() throws Exception
+    {
+        Tuple tlv = decode( "01011110" ) ;
+        assertEquals( 30, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+    
+    
+    public void testIdOverLimit() throws Exception
+    {
+        // this is the long form
+        Tuple tlv = decode( "01011111" ) ;
+        
+        assertEquals( 0, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( true, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        
+        // state did not switch since we are still reading the long tag  
+        assertEquals( BERDecoderState.TAG, decoder.getState() ) ;
+    }
+
+    
+    public void testIsConstructed() throws Exception
+    {
+        Tuple tlv = decode( "01111110" ) ;
+        assertEquals( 30, tlv.id ) ;
+        assertEquals( 0, tlvList.size() ) ;
+        assertEquals( false, tlv.isPrimitive ) ;
+        assertEquals( TypeClass.APPLICATION, tlv.typeClass ) ;
+        assertEquals( BERDecoderState.LENGTH, decoder.getState() ) ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TupleTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TupleTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TupleTest.java	Sun Mar 14 14:02:18 2004
@@ -1,975 +1,975 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import org.apache.commons.lang.ArrayUtils ;
-import org.apache.commons.codec.binary.Binary ;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests Tuple class.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class TupleTest extends TestCase
-{
-
-    public static void main(String[] args)
-    {
-        junit.textui.TestRunner.run(TupleTest.class);
-    }
-
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-
-    /*
-     * @see TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-
-    /**
-     * Constructor for TupleTest.
-     * @param arg0
-     */
-    public TupleTest(String arg0)
-    {
-        super(arg0);
-    }
-
-    /*
-     * Class to test for void Tuple()
-     */
-    public void testTuple()
-    {
-        assertNotNull( new Tuple() ) ;
-    }
-
-    /*
-     * Class to test for void Tuple(int)
-     */
-    public void testTupleint()
-    {
-        Tuple t0 = new Tuple( 0, 0 ) ;
-        assertEquals( 0, t0.id ) ;
-        Tuple t1 = new Tuple( 1, 0 ) ;
-        assertEquals( 1, t1.id ) ;
-        assertFalse( t0.equals(t1) ) ;
-    }
-
-    /*
-     * Class to test for void Tuple(int, int)
-     */
-    public void testTupleintint()
-    {
-        Tuple t0 = new Tuple( 0, 0 ) ;
-        assertEquals( 0, t0.id ) ;
-        assertEquals( 0, t0.length ) ;
-        Tuple t1 = new Tuple( 0, 1 ) ;
-        assertEquals( 0, t1.id ) ;
-        assertEquals( 1, t1.length ) ;
-        assertFalse( t0.equals(t1) ) ;
-    }
-
-    /*
-     * Class to test for void Tuple(int, int, TypeClass)
-     */
-    public void testTupleintintTypeClass()
-    {
-        Tuple t0 = new Tuple( 0, 0, TypeClass.PRIVATE ) ;
-        assertEquals( 0, t0.id ) ;
-        assertEquals( 0, t0.length ) ;
-        assertEquals( TypeClass.PRIVATE, t0.getTypeClass() ) ;
-        Tuple t1 = new Tuple( 0, 1, null ) ;
-        assertEquals( 0, t1.id ) ;
-        assertEquals( 1, t1.length ) ;
-        assertFalse( t0.equals(t1) ) ;
-        assertEquals( TypeClass.APPLICATION, t1.getTypeClass() ) ;
-    }
-
-    /*
-     * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
-     */
-    public void testTupleintTypeClassbooleanbyteArray()
-    {
-        Tuple t = new Tuple( 2, TypeClass.PRIVATE, true, 
-                ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
-        assertEquals( true, t.isPrimitive() ) ;
-        assertEquals( 0, t.getLength() ) ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-
-        t = new Tuple( 2, TypeClass.PRIVATE, true, null ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
-        assertEquals( true, t.isPrimitive() ) ;
-        assertEquals( 0, t.getLength() ) ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-
-        byte[] bites = new byte[7] ;
-        t = new Tuple( 2, (TypeClass) null, false, bites ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
-        assertEquals( false, t.isPrimitive() ) ;
-        assertEquals( 7, t.getLength() ) ;
-        assertEquals( bites, t.getValue() ) ;
-        
-        t = new Tuple( 2, null, false,  null ) ; 
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
-        assertEquals( false, t.isPrimitive() ) ;
-        assertEquals( 0, t.getLength() ) ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-    }
-
-    /*
-     * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
-     */
-    public void testTupleintbyteArray()
-    {
-        Tuple t = new Tuple( 2, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
-        assertEquals( true, t.isPrimitive() ) ;
-        assertEquals( 0, t.getLength() ) ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-        
-        byte[] bites = new byte[5] ;
-        t = new Tuple( 2, bites ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
-        assertEquals( true, t.isPrimitive() ) ;
-        assertEquals( 5, t.getLength() ) ;
-        assertEquals( bites, t.getValue() ) ;
-    }
-
-    /*
-     * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
-     */
-    public void testTupleintbooleanbyteArray()
-    {
-        Tuple t = new Tuple( 2, false, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
-        assertEquals( false, t.isPrimitive() ) ;
-        assertEquals( 0, t.getLength() ) ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-        
-        byte[] bites = new byte[5] ;
-        t = new Tuple( 2, false, bites ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
-        assertEquals( false, t.isPrimitive() ) ;
-        assertEquals( 5, t.getLength() ) ;
-        assertEquals( bites, t.getValue() ) ;
-    }
-
-    /*
-     * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
-     */
-    public void testTupleintTypeClass()
-    {
-        Tuple t = new Tuple( 2, TypeClass.PRIVATE ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
-        assertEquals( false, t.isPrimitive() ) ;
-        assertEquals( Tuple.INDEFINATE, t.getLength() ) ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-
-        t = new Tuple( 2, (TypeClass) null ) ;
-        assertEquals( 2, t.getId() ) ;
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
-        assertEquals( false, t.isPrimitive() ) ;
-        assertEquals( Tuple.INDEFINATE, t.getLength() ) ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-    }
-
-    public void testGetId()
-    {
-        Tuple t = new Tuple() ;
-        assertEquals( 0, t.getId() ) ;
-        t = new Tuple( 2, 0 ) ;
-        assertEquals( 2, t.getId() ) ;
-        t.id = 21 ;
-        assertEquals( 21, t.getId() ) ;
-    }
-    
-    
-    public void testSize()
-    {
-        Tuple t = new Tuple( 1, TypeClass.APPLICATION ) ;
-        assertEquals( 2, t.size() ) ;
-        t.id = 32 ;
-        assertEquals( 3, t.size() ) ;
-        t.id = 127 ;
-        assertEquals( 3, t.size() ) ;
-        t.id = 128 ;
-        assertEquals( 4, t.size() ) ;
-        t.id = 1 << 14 ;
-        assertEquals( 5, t.size() ) ;
-        t.id = 1 << 21 ;
-        assertEquals( 6, t.size() ) ;
-        
-        t.length = 127 ;
-        assertEquals( 6+127, t.size() ) ;
-        t.length = 128 ;
-        assertEquals( 7+128, t.size() ) ;
-        t.length = 255 ;
-        assertEquals( 7+255, t.size() ) ;
-        t.length = 256 ;
-        assertEquals( 8+256, t.size() ) ;
-    }
-    
-    
-    public void testIsIndefinate()
-    {
-        Tuple t = new Tuple() ;
-        assertFalse( t.isIndefinate() ) ;
-        t.length = Tuple.INDEFINATE ;
-        assertTrue( t.isIndefinate() ) ;
-    }
-    
-
-    public void testIsIndefinateTerminator()
-    {
-        Tuple t = new Tuple() ;
-        assertFalse( t.isIndefinateTerminator() ) ;
-        t.id = 0 ;
-        t.length = 0 ;
-        t.isPrimitive = true ;
-        t.typeClass = TypeClass.UNIVERSAL ;
-        assertTrue( t.isIndefinateTerminator() ) ;
-    }
-    
-
-    public void testIsPrimitive()
-    {
-        Tuple t = new Tuple() ;
-        assertTrue( t.isPrimitive() ) ;
-        t.isPrimitive = false ;
-        assertFalse( t.isPrimitive() ) ;
-    }
-
-    public void testGetLength()
-    {
-        Tuple t = new Tuple() ;
-        assertEquals( 0, t.getLength() ) ;
-        t = new Tuple( 1, 2 ) ;
-        assertEquals( 2, t.getLength() ) ;
-        t.length = 21 ;
-        assertEquals( 21, t.getLength() ) ;
-    }
-
-    public void testGetTypeClass()
-    {
-        Tuple t = new Tuple() ;
-        assertEquals( t.typeClass, TypeClass.APPLICATION ) ;
-        t = new Tuple( 0, 0 ) ;
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
-        t.typeClass = TypeClass.PRIVATE ;
-        assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
-    }
-
-    public void testGetValue()
-    {
-        Tuple t = new Tuple() ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-        byte[] bites = {1, 2, 3, 45} ;
-        t.value = bites ;
-        assertEquals( bites, t.getValue() ) ;
-        byte[] bites2 = {1, 2, 3, 45} ;
-        assertFalse( bites2 == t.getValue() ) ;
-        t.clear() ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
-    }
-
-    public void testClear()
-    {
-        Tuple t = new Tuple() ;
-        t.id = 12 ;
-        assertEquals( 12, t.id ) ;
-        t.clear() ;
-        assertEquals( 0, t.id ) ;
-
-        t.length = 12 ;
-        assertEquals( 12, t.length ) ;
-        t.clear() ;
-        assertEquals( Tuple.UNDEFINED, t.length ) ;
-
-        t.index = 12 ;
-        assertEquals( 12, t.index ) ;
-        t.clear() ;
-        assertEquals( 0, t.index ) ;
-
-        t.isPrimitive = false ;
-        assertEquals( false, t.isPrimitive ) ;
-        t.clear() ;
-        assertEquals( true, t.isPrimitive ) ;
-
-        t.typeClass = TypeClass.CONTEXT_SPECIFIC ;
-        assertEquals( TypeClass.CONTEXT_SPECIFIC, t.typeClass ) ;
-        t.clear() ;
-        assertEquals( TypeClass.APPLICATION, t.typeClass ) ;
-
-        t.value = new byte[3] ;
-        assertNotNull( t.value ) ;
-        t.clear() ;
-        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.value ) ;
-
-        t.valueIndex = 12 ;
-        assertEquals( 12, t.valueIndex ) ;
-        t.clear() ;
-        assertEquals( Tuple.UNDEFINED, t.valueIndex ) ;
-
-    }
-
-    /*
-     * Class to test for boolean equals(Object)
-     */
-    public void testEqualsObject()
-    {
-        Tuple tnull0 = new Tuple() ;
-        tnull0.value = null ;
-        Tuple tnull1 = new Tuple() ;
-        tnull1.value = null ;
-        tnull0.equals( tnull1 ) ;
-        
-        tnull1.equals( tnull1 ) ;
-        tnull0.equals( tnull0 ) ;
-        
-        Tuple t0 = new Tuple() ;
-        Tuple t1 = ( Tuple ) t0.clone() ;
-        
-        assertTrue( t0.equals( t1 ) ) ;
-        t0.id = 23 ;
-        assertFalse( t0.equals( t1 ) ) ;
-        t1 = ( Tuple ) t0.clone() ;
-        assertTrue( t0.equals( t1 ) ) ;
-
-        // indices are not taken into account in Tuple.equals(Object)
-        t0.index = 23 ;
-        t1.index = 33 ;
-        assertTrue( t0.equals( t1 ) ) ;
-        t1 = ( Tuple ) t0.clone() ;
-        assertTrue( t0.equals( t1 ) ) ;
-
-        t0.isPrimitive = false ;
-        t1.isPrimitive = true ;
-        assertFalse( t0.equals( t1 ) ) ;
-        t1 = ( Tuple ) t0.clone() ;
-        assertTrue( t0.equals( t1 ) ) ;
-
-        t0.length = 23 ;
-        assertFalse( t0.equals( t1 ) ) ;
-        t1 = ( Tuple ) t0.clone() ;
-        assertTrue( t0.equals( t1 ) ) ;
-
-        t0.typeClass = TypeClass.PRIVATE ;
-        t1.typeClass = TypeClass.UNIVERSAL ;
-        assertFalse( t0.equals( t1 ) ) ;
-        t1 = ( Tuple ) t0.clone() ;
-        assertTrue( t0.equals( t1 ) ) ;
-
-        // indices are not taken into account in Tuple.equals(Object)
-        t0.valueIndex = 23 ;
-        t1.valueIndex = 3 ;
-        assertTrue( t0.equals( t1 ) ) ;
-        t1 = ( Tuple ) t0.clone() ;
-        assertTrue( t0.equals( t1 ) ) ;
-
-        t0.value = new byte[4] ;
-        t1.value = null ;
-        assertFalse( t0.equals( t1 ) ) ;
-        t1 = ( Tuple ) t0.clone() ;
-        assertTrue( t0.equals( t1 ) ) ;
-
-        assertFalse( t0.equals( new Object() )) ;
-     }
-
-    /*
-     * Class to test for Object clone()
-     */
-    public void testClone()
-    {
-        Tuple t = new Tuple() ;
-        assertTrue( t.equals( t.clone() ) ) ;
-    }
-
-    public void testEncodeConstructed()
-    {
-        Tuple t = null ;
-        byte[] encoded ;
-        String binary ;
-        
-        t = new Tuple( 0, 0 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "01100000"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( 2, 0 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "01100010"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( 30, 0 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "01111110"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( 31, 0 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "00011111" +
-                "01111111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( 128, 0 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "00000001" +
-                "10000000" +
-                "01111111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( 128, 127 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "01111111" +
-                "00000001" +
-                "10000000" +
-                "01111111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( 128, 128 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "10000000" +
-                "10000001" +
-                "00000001" +
-                "10000000" +
-                "01111111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( 128, 255 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "11111111" +
-                "10000001" +
-                "00000001" +
-                "10000000" +
-                "01111111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( 128, 256 ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000001" +
-                "00000000" +
-                "10000010" +
-                "00000001" +
-                "10000000" +
-                "01111111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        t = new Tuple( Tuple.BIT_27-1, Integer.MAX_VALUE ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( Binary.toAsciiString( Integer.MAX_VALUE ) + 
-                "10000100" +
-                "01111111" +
-                "11111111" +
-                "11111111" +
-                "11111111" +
-                "01111111"
-                , Binary.toAsciiString( encoded ) ) ;
-    }
-
-    public void testEncodePrimitive()
-    {
-        Tuple t = null ;
-        byte[] encoded ;
-        byte[] data ;
-        String binary ;
-        
-        data = new byte[0] ;
-        t = new Tuple( 0, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "01000000"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[0] ;
-        t = new Tuple( 2, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "01000010"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[0] ;
-        t = new Tuple( 30, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "01011110"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[0] ;
-        t = new Tuple( 31, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "00011111" +
-                "01011111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[0] ;
-        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "00000001" +
-                "10000000" +
-                "01011111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[1] ;
-        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( 
-                "00000000" +
-                "00000001" +
-                "00000001" +
-                "10000000" +
-                "01011111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[127] ;
-        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( Binary.toAsciiString( data ) +
-                "01111111" +
-                "00000001" +
-                "10000000" +
-                "01011111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[128] ;
-        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( Binary.toAsciiString( data ) +
-                "10000000" +
-                "10000001" +
-                "00000001" +
-                "10000000" +
-                "01011111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[255] ;
-        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( Binary.toAsciiString( data ) +
-                "11111111" +
-                "10000001" +
-                "00000001" +
-                "10000000" +
-                "01011111"
-                , Binary.toAsciiString( encoded ) ) ;
-
-        data = new byte[256] ;
-        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
-        encoded = t.encode() ;
-        binary = Binary.toAsciiString( encoded ) ;
-        assertEquals( Binary.toAsciiString( data ) + 
-                "00000001" +
-                "00000000" +
-                "10000010" +
-                "00000001" +
-                "10000000" +
-                "01011111"
-                , Binary.toAsciiString( encoded ) ) ;
-    }
-
-    public void testSetTag()
-    {
-        byte[] bites = new byte[1] ;
-        Tuple t = new Tuple( 0, 0 ) ;
-        t.setTag( bites, 1 ) ;
-        String binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "01100000", binary ) ;
-        
-        bites = new byte[1] ;
-        t = new Tuple( 30, 0 ) ;
-        t.setTag( bites, 1 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "01111110", binary ) ;
-
-        bites = new byte[1] ;
-        t = new Tuple( 30, 0 ) ;
-        t.isPrimitive = true ;
-        t.setTag( bites, 1 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "01011110", binary ) ;
-
-        bites = new byte[2] ;
-        t = new Tuple( 31, 0 ) ;
-        t.setTag( bites, 2 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00011111" + "01111111", binary ) ;
-
-        bites = new byte[2] ;
-        t = new Tuple( 127, 0 ) ;
-        t.setTag( bites, 2 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "01111111" + "01111111", binary ) ;
-
-        bites = new byte[3] ;
-        t = new Tuple( 128, 0 ) ;
-        t.setTag( bites, 3 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" + "10000000" + "01111111", binary ) ;
-
-        bites = new byte[3] ;
-        t = new Tuple( Tuple.BIT_13 - 1, 0 ) ;
-        t.setTag( bites, 3 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "01111111" + 
-                      "11111111" + 
-                      "01111111", binary ) ;
-
-        bites = new byte[4] ;
-        t = new Tuple( Tuple.BIT_13, 0 ) ;
-        t.setTag( bites, 4 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "10000000" +
-                      "10000000" + 
-                      "01111111", binary ) ;
-
-        bites = new byte[4] ;
-        t = new Tuple( Tuple.BIT_13 + 1, 0 ) ;
-        t.setTag( bites, 4 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "10000000" +
-                      "10000001" + 
-                      "01111111", binary ) ;
-
-        bites = new byte[4] ;
-        t = new Tuple( Tuple.BIT_20 - 1, 0 ) ;
-        t.setTag( bites, 4 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "01111111" + 
-                      "11111111" + 
-                      "11111111" + 
-                      "01111111", binary ) ;
-
-        bites = new byte[5] ;
-        t = new Tuple( Tuple.BIT_20, 0 ) ;
-        t.setTag( bites, 5 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "10000000" +
-                      "10000000" +
-                      "10000000" + 
-                      "01111111", binary ) ;
-
-        bites = new byte[5] ;
-        t = new Tuple( Tuple.BIT_20 + 1, 0 ) ;
-        t.setTag( bites, 5 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "10000000" +
-                      "10000000" +
-                      "10000001" + 
-                      "01111111", binary ) ;
-
-        bites = new byte[5] ;
-        t = new Tuple( Tuple.BIT_27 - 1, 0 ) ;
-        t.setTag( bites, 5 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "01111111" + 
-                      "11111111" + 
-                      "11111111" + 
-                      "11111111" + 
-                      "01111111", binary ) ;
-
-        bites = new byte[6] ;
-        t = new Tuple( Tuple.BIT_27, 0 ) ;
-        
-        try
-        {
-            t.setTag( bites, 6 ) ;
-            fail( "should never reach this point due to thrown exception" ) ;
-        }
-        catch( IllegalArgumentException e )
-        {
-            assertNotNull( e ) ;
-        }
-    }
-
-    public void testSetLength()
-    {
-        byte[] bites = new byte[1] ;
-        Tuple t = new Tuple( 0, 0 ) ;
-        t.setLength( bites, 0, 1 ) ;
-        String binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000000", binary ) ;
-
-        bites = new byte[1] ;
-        t = new Tuple( 30, 15 ) ;
-        t.setLength( bites, 0, 1 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00001111", binary ) ;
-
-        bites = new byte[1] ;
-        t = new Tuple( 30, 127 ) ;
-        t.setLength( bites, 0, 1 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "01111111", binary ) ;
-        
-        bites = new byte[2] ;
-        t = new Tuple( 30, 128 ) ;
-        t.setLength( bites, 0, 2 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "10000000" +
-                      "10000001", binary ) ;
-        
-        bites = new byte[2] ;
-        t = new Tuple( 30, 255 ) ;
-        t.setLength( bites, 0, 2 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "11111111" +
-                      "10000001", binary ) ;
-        
-        bites = new byte[3] ;
-        t = new Tuple( 30, 256 ) ;
-        t.setLength( bites, 0, 3 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "00000000" +
-                      "10000010", binary ) ;
-        
-        bites = new byte[3] ;
-        t = new Tuple( 30, Tuple.BIT_15 - 1 ) ;
-        t.setLength( bites, 0, 3 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "11111111" +
-                      "11111111" +
-                      "10000010", binary ) ;
-        
-        bites = new byte[4] ;
-        t = new Tuple( 30, Tuple.BIT_15 ) ;
-        t.setLength( bites, 0, 4 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "00000000" +
-                      "00000000" +
-                      "10000011", binary ) ;
-        
-        bites = new byte[4] ;
-        t = new Tuple( 30, Tuple.BIT_15 + 1 ) ;
-        t.setLength( bites, 0, 4 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "00000000" +
-                      "00000001" +
-                      "10000011", binary ) ;
-        
-        bites = new byte[4] ;
-        t = new Tuple( 30, Tuple.BIT_23 - 1 ) ;
-        t.setLength( bites, 0, 4 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "11111111" +
-                      "11111111" +
-                      "11111111" +
-                      "10000011", binary ) ;
-        
-        bites = new byte[5] ;
-        t = new Tuple( 30, Tuple.BIT_23 ) ;
-        t.setLength( bites, 0, 5 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "00000000" +
-                      "00000000" +
-                      "00000000" +
-                      "10000100", binary ) ;
-        
-        bites = new byte[5] ;
-        t = new Tuple( 30, Tuple.BIT_23 + 1 ) ;
-        t.setLength( bites, 0, 5 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( "00000001" +
-                      "00000000" +
-                      "00000000" +
-                      "00000001" +
-                      "10000100", binary ) ;
-        
-        bites = new byte[5] ;
-        t = new Tuple( 30, Integer.MAX_VALUE ) ;
-        t.setLength( bites, 0, 5 ) ;
-        t.setLength( bites, 0, 5 ) ;
-        binary = Binary.toAsciiString( bites ) ;
-        assertEquals( Binary.toAsciiString( Integer.MAX_VALUE ) +
-                      "10000100", binary ) ;
-        
-        
-        bites = new byte[6] ;
-        t = new Tuple( 30, Integer.MAX_VALUE + 1 ) ;
-
-        try
-        {
-            t.setLength( bites, 0, 6 ) ;
-            fail( "should never get here due to thrown exception" ) ;
-        }
-        catch( IllegalArgumentException e ) 
-        {
-            assertNotNull( e ) ;
-        }
-    }
-
-    public void testGetTagLength()
-    {
-        Tuple t = new Tuple() ;
-        assertEquals( 1, t.getTagLength() ) ;
-        t.id = 30 ;
-        assertEquals( 1, t.getTagLength() ) ;
-        t.id = 31 ;
-        assertEquals( 2, t.getTagLength() ) ;
-        t.id = 100 ;
-        assertEquals( 2, t.getTagLength() ) ;
-        t.id = 127 ;
-        assertEquals( 2, t.getTagLength() ) ;
-        t.id = 128 ;
-        assertEquals( 3, t.getTagLength() ) ;
-        t.id = 129 ;
-        assertEquals( 3, t.getTagLength() ) ;
-
-        t.id = Tuple.BIT_13 - 1 ;
-        assertEquals( 3, t.getTagLength() ) ;
-        t.id = Tuple.BIT_13 ;
-        assertEquals( 4, t.getTagLength() ) ;
-        t.id = Tuple.BIT_13 + 100 ;
-        assertEquals( 4, t.getTagLength() ) ;
-        
-        t.id = Tuple.BIT_20 - 1 ;
-        assertEquals( 4, t.getTagLength() ) ;
-        t.id = Tuple.BIT_20 ;
-        assertEquals( 5, t.getTagLength() ) ;
-        t.id = Tuple.BIT_20 + 100 ;
-        assertEquals( 5, t.getTagLength() ) ;
-
-        t.id = Tuple.BIT_27 - 1 ;
-        assertEquals( 5, t.getTagLength() ) ;
-
-        t.id = Tuple.BIT_27 ;
-        
-        try
-        {
-            assertEquals( 6, t.getTagLength() ) ;
-            fail( "should throw an exception before getting here" ) ;
-        }
-        catch( IllegalArgumentException e )
-        {
-            assertNotNull( e ) ;
-        }
-    }
-
-    public void testGetLengthLength()
-    {
-        Tuple t = new Tuple() ;
-        assertEquals( 1, t.getLengthLength() ) ;
-        t.length = 127 ;
-        assertEquals( 1, t.getLengthLength() ) ;
-        t.length = 128 ;
-        assertEquals( 2, t.getLengthLength() ) ;
-        t.length = 255 ;
-        assertEquals( 2, t.getLengthLength() ) ;
-        t.length = 256 ;
-        assertEquals( 3, t.getLengthLength() ) ;
-
-        t.length = Tuple.BIT_15 - 1 ;
-        assertEquals( 3, t.getLengthLength() ) ;
-        t.length = Tuple.BIT_15 ;
-        assertEquals( 4, t.getLengthLength() ) ;
-        t.length = Tuple.BIT_15 + 100 ;
-        assertEquals( 4, t.getLengthLength() ) ;
-        
-        t.length = Tuple.BIT_23 - 1 ;
-        assertEquals( 4, t.getLengthLength() ) ;
-        t.length = Tuple.BIT_23 ;
-        assertEquals( 5, t.getLengthLength() ) ;
-        t.length = Tuple.BIT_23 + 100 ;
-        assertEquals( 5, t.getLengthLength() ) ;
-
-        t.length = Integer.MAX_VALUE ;
-        assertEquals( 5, t.getLengthLength() ) ;
-
-        
-        t.length = Integer.MAX_VALUE + 1 ;
-        try
-        {
-            assertEquals( 6, t.getLengthLength() ) ;
-            fail( "should throw an exception before getting here" ) ;
-        }
-        catch( IllegalArgumentException e )
-        {
-            assertNotNull( e ) ;
-        }
-        
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import org.apache.commons.lang.ArrayUtils ;
+import org.apache.commons.codec.binary.Binary ;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests Tuple class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TupleTest extends TestCase
+{
+
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(TupleTest.class);
+    }
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * Constructor for TupleTest.
+     * @param arg0
+     */
+    public TupleTest(String arg0)
+    {
+        super(arg0);
+    }
+
+    /*
+     * Class to test for void Tuple()
+     */
+    public void testTuple()
+    {
+        assertNotNull( new Tuple() ) ;
+    }
+
+    /*
+     * Class to test for void Tuple(int)
+     */
+    public void testTupleint()
+    {
+        Tuple t0 = new Tuple( 0, 0 ) ;
+        assertEquals( 0, t0.id ) ;
+        Tuple t1 = new Tuple( 1, 0 ) ;
+        assertEquals( 1, t1.id ) ;
+        assertFalse( t0.equals(t1) ) ;
+    }
+
+    /*
+     * Class to test for void Tuple(int, int)
+     */
+    public void testTupleintint()
+    {
+        Tuple t0 = new Tuple( 0, 0 ) ;
+        assertEquals( 0, t0.id ) ;
+        assertEquals( 0, t0.length ) ;
+        Tuple t1 = new Tuple( 0, 1 ) ;
+        assertEquals( 0, t1.id ) ;
+        assertEquals( 1, t1.length ) ;
+        assertFalse( t0.equals(t1) ) ;
+    }
+
+    /*
+     * Class to test for void Tuple(int, int, TypeClass)
+     */
+    public void testTupleintintTypeClass()
+    {
+        Tuple t0 = new Tuple( 0, 0, TypeClass.PRIVATE ) ;
+        assertEquals( 0, t0.id ) ;
+        assertEquals( 0, t0.length ) ;
+        assertEquals( TypeClass.PRIVATE, t0.getTypeClass() ) ;
+        Tuple t1 = new Tuple( 0, 1, null ) ;
+        assertEquals( 0, t1.id ) ;
+        assertEquals( 1, t1.length ) ;
+        assertFalse( t0.equals(t1) ) ;
+        assertEquals( TypeClass.APPLICATION, t1.getTypeClass() ) ;
+    }
+
+    /*
+     * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
+     */
+    public void testTupleintTypeClassbooleanbyteArray()
+    {
+        Tuple t = new Tuple( 2, TypeClass.PRIVATE, true, 
+                ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
+        assertEquals( true, t.isPrimitive() ) ;
+        assertEquals( 0, t.getLength() ) ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+
+        t = new Tuple( 2, TypeClass.PRIVATE, true, null ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
+        assertEquals( true, t.isPrimitive() ) ;
+        assertEquals( 0, t.getLength() ) ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+
+        byte[] bites = new byte[7] ;
+        t = new Tuple( 2, (TypeClass) null, false, bites ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
+        assertEquals( false, t.isPrimitive() ) ;
+        assertEquals( 7, t.getLength() ) ;
+        assertEquals( bites, t.getValue() ) ;
+        
+        t = new Tuple( 2, null, false,  null ) ; 
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
+        assertEquals( false, t.isPrimitive() ) ;
+        assertEquals( 0, t.getLength() ) ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+    }
+
+    /*
+     * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
+     */
+    public void testTupleintbyteArray()
+    {
+        Tuple t = new Tuple( 2, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
+        assertEquals( true, t.isPrimitive() ) ;
+        assertEquals( 0, t.getLength() ) ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+        
+        byte[] bites = new byte[5] ;
+        t = new Tuple( 2, bites ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
+        assertEquals( true, t.isPrimitive() ) ;
+        assertEquals( 5, t.getLength() ) ;
+        assertEquals( bites, t.getValue() ) ;
+    }
+
+    /*
+     * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
+     */
+    public void testTupleintbooleanbyteArray()
+    {
+        Tuple t = new Tuple( 2, false, ArrayUtils.EMPTY_BYTE_ARRAY ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
+        assertEquals( false, t.isPrimitive() ) ;
+        assertEquals( 0, t.getLength() ) ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+        
+        byte[] bites = new byte[5] ;
+        t = new Tuple( 2, false, bites ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
+        assertEquals( false, t.isPrimitive() ) ;
+        assertEquals( 5, t.getLength() ) ;
+        assertEquals( bites, t.getValue() ) ;
+    }
+
+    /*
+     * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
+     */
+    public void testTupleintTypeClass()
+    {
+        Tuple t = new Tuple( 2, TypeClass.PRIVATE ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
+        assertEquals( false, t.isPrimitive() ) ;
+        assertEquals( Tuple.INDEFINATE, t.getLength() ) ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+
+        t = new Tuple( 2, (TypeClass) null ) ;
+        assertEquals( 2, t.getId() ) ;
+        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
+        assertEquals( false, t.isPrimitive() ) ;
+        assertEquals( Tuple.INDEFINATE, t.getLength() ) ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+    }
+
+    public void testGetId()
+    {
+        Tuple t = new Tuple() ;
+        assertEquals( 0, t.getId() ) ;
+        t = new Tuple( 2, 0 ) ;
+        assertEquals( 2, t.getId() ) ;
+        t.id = 21 ;
+        assertEquals( 21, t.getId() ) ;
+    }
+    
+    
+    public void testSize()
+    {
+        Tuple t = new Tuple( 1, TypeClass.APPLICATION ) ;
+        assertEquals( 2, t.size() ) ;
+        t.id = 32 ;
+        assertEquals( 3, t.size() ) ;
+        t.id = 127 ;
+        assertEquals( 3, t.size() ) ;
+        t.id = 128 ;
+        assertEquals( 4, t.size() ) ;
+        t.id = 1 << 14 ;
+        assertEquals( 5, t.size() ) ;
+        t.id = 1 << 21 ;
+        assertEquals( 6, t.size() ) ;
+        
+        t.length = 127 ;
+        assertEquals( 6+127, t.size() ) ;
+        t.length = 128 ;
+        assertEquals( 7+128, t.size() ) ;
+        t.length = 255 ;
+        assertEquals( 7+255, t.size() ) ;
+        t.length = 256 ;
+        assertEquals( 8+256, t.size() ) ;
+    }
+    
+    
+    public void testIsIndefinate()
+    {
+        Tuple t = new Tuple() ;
+        assertFalse( t.isIndefinate() ) ;
+        t.length = Tuple.INDEFINATE ;
+        assertTrue( t.isIndefinate() ) ;
+    }
+    
+
+    public void testIsIndefinateTerminator()
+    {
+        Tuple t = new Tuple() ;
+        assertFalse( t.isIndefinateTerminator() ) ;
+        t.id = 0 ;
+        t.length = 0 ;
+        t.isPrimitive = true ;
+        t.typeClass = TypeClass.UNIVERSAL ;
+        assertTrue( t.isIndefinateTerminator() ) ;
+    }
+    
+
+    public void testIsPrimitive()
+    {
+        Tuple t = new Tuple() ;
+        assertTrue( t.isPrimitive() ) ;
+        t.isPrimitive = false ;
+        assertFalse( t.isPrimitive() ) ;
+    }
+
+    public void testGetLength()
+    {
+        Tuple t = new Tuple() ;
+        assertEquals( 0, t.getLength() ) ;
+        t = new Tuple( 1, 2 ) ;
+        assertEquals( 2, t.getLength() ) ;
+        t.length = 21 ;
+        assertEquals( 21, t.getLength() ) ;
+    }
+
+    public void testGetTypeClass()
+    {
+        Tuple t = new Tuple() ;
+        assertEquals( t.typeClass, TypeClass.APPLICATION ) ;
+        t = new Tuple( 0, 0 ) ;
+        assertEquals( TypeClass.APPLICATION, t.getTypeClass() ) ;
+        t.typeClass = TypeClass.PRIVATE ;
+        assertEquals( TypeClass.PRIVATE, t.getTypeClass() ) ;
+    }
+
+    public void testGetValue()
+    {
+        Tuple t = new Tuple() ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+        byte[] bites = {1, 2, 3, 45} ;
+        t.value = bites ;
+        assertEquals( bites, t.getValue() ) ;
+        byte[] bites2 = {1, 2, 3, 45} ;
+        assertFalse( bites2 == t.getValue() ) ;
+        t.clear() ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.getValue() ) ;
+    }
+
+    public void testClear()
+    {
+        Tuple t = new Tuple() ;
+        t.id = 12 ;
+        assertEquals( 12, t.id ) ;
+        t.clear() ;
+        assertEquals( 0, t.id ) ;
+
+        t.length = 12 ;
+        assertEquals( 12, t.length ) ;
+        t.clear() ;
+        assertEquals( Tuple.UNDEFINED, t.length ) ;
+
+        t.index = 12 ;
+        assertEquals( 12, t.index ) ;
+        t.clear() ;
+        assertEquals( 0, t.index ) ;
+
+        t.isPrimitive = false ;
+        assertEquals( false, t.isPrimitive ) ;
+        t.clear() ;
+        assertEquals( true, t.isPrimitive ) ;
+
+        t.typeClass = TypeClass.CONTEXT_SPECIFIC ;
+        assertEquals( TypeClass.CONTEXT_SPECIFIC, t.typeClass ) ;
+        t.clear() ;
+        assertEquals( TypeClass.APPLICATION, t.typeClass ) ;
+
+        t.value = new byte[3] ;
+        assertNotNull( t.value ) ;
+        t.clear() ;
+        assertEquals( ArrayUtils.EMPTY_BYTE_ARRAY, t.value ) ;
+
+        t.valueIndex = 12 ;
+        assertEquals( 12, t.valueIndex ) ;
+        t.clear() ;
+        assertEquals( Tuple.UNDEFINED, t.valueIndex ) ;
+
+    }
+
+    /*
+     * Class to test for boolean equals(Object)
+     */
+    public void testEqualsObject()
+    {
+        Tuple tnull0 = new Tuple() ;
+        tnull0.value = null ;
+        Tuple tnull1 = new Tuple() ;
+        tnull1.value = null ;
+        tnull0.equals( tnull1 ) ;
+        
+        tnull1.equals( tnull1 ) ;
+        tnull0.equals( tnull0 ) ;
+        
+        Tuple t0 = new Tuple() ;
+        Tuple t1 = ( Tuple ) t0.clone() ;
+        
+        assertTrue( t0.equals( t1 ) ) ;
+        t0.id = 23 ;
+        assertFalse( t0.equals( t1 ) ) ;
+        t1 = ( Tuple ) t0.clone() ;
+        assertTrue( t0.equals( t1 ) ) ;
+
+        // indices are not taken into account in Tuple.equals(Object)
+        t0.index = 23 ;
+        t1.index = 33 ;
+        assertTrue( t0.equals( t1 ) ) ;
+        t1 = ( Tuple ) t0.clone() ;
+        assertTrue( t0.equals( t1 ) ) ;
+
+        t0.isPrimitive = false ;
+        t1.isPrimitive = true ;
+        assertFalse( t0.equals( t1 ) ) ;
+        t1 = ( Tuple ) t0.clone() ;
+        assertTrue( t0.equals( t1 ) ) ;
+
+        t0.length = 23 ;
+        assertFalse( t0.equals( t1 ) ) ;
+        t1 = ( Tuple ) t0.clone() ;
+        assertTrue( t0.equals( t1 ) ) ;
+
+        t0.typeClass = TypeClass.PRIVATE ;
+        t1.typeClass = TypeClass.UNIVERSAL ;
+        assertFalse( t0.equals( t1 ) ) ;
+        t1 = ( Tuple ) t0.clone() ;
+        assertTrue( t0.equals( t1 ) ) ;
+
+        // indices are not taken into account in Tuple.equals(Object)
+        t0.valueIndex = 23 ;
+        t1.valueIndex = 3 ;
+        assertTrue( t0.equals( t1 ) ) ;
+        t1 = ( Tuple ) t0.clone() ;
+        assertTrue( t0.equals( t1 ) ) ;
+
+        t0.value = new byte[4] ;
+        t1.value = null ;
+        assertFalse( t0.equals( t1 ) ) ;
+        t1 = ( Tuple ) t0.clone() ;
+        assertTrue( t0.equals( t1 ) ) ;
+
+        assertFalse( t0.equals( new Object() )) ;
+     }
+
+    /*
+     * Class to test for Object clone()
+     */
+    public void testClone()
+    {
+        Tuple t = new Tuple() ;
+        assertTrue( t.equals( t.clone() ) ) ;
+    }
+
+    public void testEncodeConstructed()
+    {
+        Tuple t = null ;
+        byte[] encoded ;
+        String binary ;
+        
+        t = new Tuple( 0, 0 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "01100000"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( 2, 0 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "01100010"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( 30, 0 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "01111110"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( 31, 0 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "00011111" +
+                "01111111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( 128, 0 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "00000001" +
+                "10000000" +
+                "01111111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( 128, 127 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "01111111" +
+                "00000001" +
+                "10000000" +
+                "01111111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( 128, 128 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "10000000" +
+                "10000001" +
+                "00000001" +
+                "10000000" +
+                "01111111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( 128, 255 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "11111111" +
+                "10000001" +
+                "00000001" +
+                "10000000" +
+                "01111111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( 128, 256 ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000001" +
+                "00000000" +
+                "10000010" +
+                "00000001" +
+                "10000000" +
+                "01111111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        t = new Tuple( Tuple.BIT_27-1, Integer.MAX_VALUE ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( Binary.toAsciiString( Integer.MAX_VALUE ) + 
+                "10000100" +
+                "01111111" +
+                "11111111" +
+                "11111111" +
+                "11111111" +
+                "01111111"
+                , Binary.toAsciiString( encoded ) ) ;
+    }
+
+    public void testEncodePrimitive()
+    {
+        Tuple t = null ;
+        byte[] encoded ;
+        byte[] data ;
+        String binary ;
+        
+        data = new byte[0] ;
+        t = new Tuple( 0, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "01000000"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[0] ;
+        t = new Tuple( 2, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "01000010"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[0] ;
+        t = new Tuple( 30, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "01011110"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[0] ;
+        t = new Tuple( 31, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "00011111" +
+                "01011111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[0] ;
+        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "00000001" +
+                "10000000" +
+                "01011111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[1] ;
+        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( 
+                "00000000" +
+                "00000001" +
+                "00000001" +
+                "10000000" +
+                "01011111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[127] ;
+        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( Binary.toAsciiString( data ) +
+                "01111111" +
+                "00000001" +
+                "10000000" +
+                "01011111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[128] ;
+        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( Binary.toAsciiString( data ) +
+                "10000000" +
+                "10000001" +
+                "00000001" +
+                "10000000" +
+                "01011111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[255] ;
+        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( Binary.toAsciiString( data ) +
+                "11111111" +
+                "10000001" +
+                "00000001" +
+                "10000000" +
+                "01011111"
+                , Binary.toAsciiString( encoded ) ) ;
+
+        data = new byte[256] ;
+        t = new Tuple( 128, TypeClass.APPLICATION, true, data ) ;
+        encoded = t.encode() ;
+        binary = Binary.toAsciiString( encoded ) ;
+        assertEquals( Binary.toAsciiString( data ) + 
+                "00000001" +
+                "00000000" +
+                "10000010" +
+                "00000001" +
+                "10000000" +
+                "01011111"
+                , Binary.toAsciiString( encoded ) ) ;
+    }
+
+    public void testSetTag()
+    {
+        byte[] bites = new byte[1] ;
+        Tuple t = new Tuple( 0, 0 ) ;
+        t.setTag( bites, 1 ) ;
+        String binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "01100000", binary ) ;
+        
+        bites = new byte[1] ;
+        t = new Tuple( 30, 0 ) ;
+        t.setTag( bites, 1 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "01111110", binary ) ;
+
+        bites = new byte[1] ;
+        t = new Tuple( 30, 0 ) ;
+        t.isPrimitive = true ;
+        t.setTag( bites, 1 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "01011110", binary ) ;
+
+        bites = new byte[2] ;
+        t = new Tuple( 31, 0 ) ;
+        t.setTag( bites, 2 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00011111" + "01111111", binary ) ;
+
+        bites = new byte[2] ;
+        t = new Tuple( 127, 0 ) ;
+        t.setTag( bites, 2 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "01111111" + "01111111", binary ) ;
+
+        bites = new byte[3] ;
+        t = new Tuple( 128, 0 ) ;
+        t.setTag( bites, 3 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" + "10000000" + "01111111", binary ) ;
+
+        bites = new byte[3] ;
+        t = new Tuple( Tuple.BIT_13 - 1, 0 ) ;
+        t.setTag( bites, 3 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "01111111" + 
+                      "11111111" + 
+                      "01111111", binary ) ;
+
+        bites = new byte[4] ;
+        t = new Tuple( Tuple.BIT_13, 0 ) ;
+        t.setTag( bites, 4 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "10000000" +
+                      "10000000" + 
+                      "01111111", binary ) ;
+
+        bites = new byte[4] ;
+        t = new Tuple( Tuple.BIT_13 + 1, 0 ) ;
+        t.setTag( bites, 4 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "10000000" +
+                      "10000001" + 
+                      "01111111", binary ) ;
+
+        bites = new byte[4] ;
+        t = new Tuple( Tuple.BIT_20 - 1, 0 ) ;
+        t.setTag( bites, 4 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "01111111" + 
+                      "11111111" + 
+                      "11111111" + 
+                      "01111111", binary ) ;
+
+        bites = new byte[5] ;
+        t = new Tuple( Tuple.BIT_20, 0 ) ;
+        t.setTag( bites, 5 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "10000000" +
+                      "10000000" +
+                      "10000000" + 
+                      "01111111", binary ) ;
+
+        bites = new byte[5] ;
+        t = new Tuple( Tuple.BIT_20 + 1, 0 ) ;
+        t.setTag( bites, 5 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "10000000" +
+                      "10000000" +
+                      "10000001" + 
+                      "01111111", binary ) ;
+
+        bites = new byte[5] ;
+        t = new Tuple( Tuple.BIT_27 - 1, 0 ) ;
+        t.setTag( bites, 5 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "01111111" + 
+                      "11111111" + 
+                      "11111111" + 
+                      "11111111" + 
+                      "01111111", binary ) ;
+
+        bites = new byte[6] ;
+        t = new Tuple( Tuple.BIT_27, 0 ) ;
+        
+        try
+        {
+            t.setTag( bites, 6 ) ;
+            fail( "should never reach this point due to thrown exception" ) ;
+        }
+        catch( IllegalArgumentException e )
+        {
+            assertNotNull( e ) ;
+        }
+    }
+
+    public void testSetLength()
+    {
+        byte[] bites = new byte[1] ;
+        Tuple t = new Tuple( 0, 0 ) ;
+        t.setLength( bites, 0, 1 ) ;
+        String binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000000", binary ) ;
+
+        bites = new byte[1] ;
+        t = new Tuple( 30, 15 ) ;
+        t.setLength( bites, 0, 1 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00001111", binary ) ;
+
+        bites = new byte[1] ;
+        t = new Tuple( 30, 127 ) ;
+        t.setLength( bites, 0, 1 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "01111111", binary ) ;
+        
+        bites = new byte[2] ;
+        t = new Tuple( 30, 128 ) ;
+        t.setLength( bites, 0, 2 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "10000000" +
+                      "10000001", binary ) ;
+        
+        bites = new byte[2] ;
+        t = new Tuple( 30, 255 ) ;
+        t.setLength( bites, 0, 2 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "11111111" +
+                      "10000001", binary ) ;
+        
+        bites = new byte[3] ;
+        t = new Tuple( 30, 256 ) ;
+        t.setLength( bites, 0, 3 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "00000000" +
+                      "10000010", binary ) ;
+        
+        bites = new byte[3] ;
+        t = new Tuple( 30, Tuple.BIT_15 - 1 ) ;
+        t.setLength( bites, 0, 3 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "11111111" +
+                      "11111111" +
+                      "10000010", binary ) ;
+        
+        bites = new byte[4] ;
+        t = new Tuple( 30, Tuple.BIT_15 ) ;
+        t.setLength( bites, 0, 4 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "00000000" +
+                      "00000000" +
+                      "10000011", binary ) ;
+        
+        bites = new byte[4] ;
+        t = new Tuple( 30, Tuple.BIT_15 + 1 ) ;
+        t.setLength( bites, 0, 4 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "00000000" +
+                      "00000001" +
+                      "10000011", binary ) ;
+        
+        bites = new byte[4] ;
+        t = new Tuple( 30, Tuple.BIT_23 - 1 ) ;
+        t.setLength( bites, 0, 4 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "11111111" +
+                      "11111111" +
+                      "11111111" +
+                      "10000011", binary ) ;
+        
+        bites = new byte[5] ;
+        t = new Tuple( 30, Tuple.BIT_23 ) ;
+        t.setLength( bites, 0, 5 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "00000000" +
+                      "00000000" +
+                      "00000000" +
+                      "10000100", binary ) ;
+        
+        bites = new byte[5] ;
+        t = new Tuple( 30, Tuple.BIT_23 + 1 ) ;
+        t.setLength( bites, 0, 5 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( "00000001" +
+                      "00000000" +
+                      "00000000" +
+                      "00000001" +
+                      "10000100", binary ) ;
+        
+        bites = new byte[5] ;
+        t = new Tuple( 30, Integer.MAX_VALUE ) ;
+        t.setLength( bites, 0, 5 ) ;
+        t.setLength( bites, 0, 5 ) ;
+        binary = Binary.toAsciiString( bites ) ;
+        assertEquals( Binary.toAsciiString( Integer.MAX_VALUE ) +
+                      "10000100", binary ) ;
+        
+        
+        bites = new byte[6] ;
+        t = new Tuple( 30, Integer.MAX_VALUE + 1 ) ;
+
+        try
+        {
+            t.setLength( bites, 0, 6 ) ;
+            fail( "should never get here due to thrown exception" ) ;
+        }
+        catch( IllegalArgumentException e ) 
+        {
+            assertNotNull( e ) ;
+        }
+    }
+
+    public void testGetTagLength()
+    {
+        Tuple t = new Tuple() ;
+        assertEquals( 1, t.getTagLength() ) ;
+        t.id = 30 ;
+        assertEquals( 1, t.getTagLength() ) ;
+        t.id = 31 ;
+        assertEquals( 2, t.getTagLength() ) ;
+        t.id = 100 ;
+        assertEquals( 2, t.getTagLength() ) ;
+        t.id = 127 ;
+        assertEquals( 2, t.getTagLength() ) ;
+        t.id = 128 ;
+        assertEquals( 3, t.getTagLength() ) ;
+        t.id = 129 ;
+        assertEquals( 3, t.getTagLength() ) ;
+
+        t.id = Tuple.BIT_13 - 1 ;
+        assertEquals( 3, t.getTagLength() ) ;
+        t.id = Tuple.BIT_13 ;
+        assertEquals( 4, t.getTagLength() ) ;
+        t.id = Tuple.BIT_13 + 100 ;
+        assertEquals( 4, t.getTagLength() ) ;
+        
+        t.id = Tuple.BIT_20 - 1 ;
+        assertEquals( 4, t.getTagLength() ) ;
+        t.id = Tuple.BIT_20 ;
+        assertEquals( 5, t.getTagLength() ) ;
+        t.id = Tuple.BIT_20 + 100 ;
+        assertEquals( 5, t.getTagLength() ) ;
+
+        t.id = Tuple.BIT_27 - 1 ;
+        assertEquals( 5, t.getTagLength() ) ;
+
+        t.id = Tuple.BIT_27 ;
+        
+        try
+        {
+            assertEquals( 6, t.getTagLength() ) ;
+            fail( "should throw an exception before getting here" ) ;
+        }
+        catch( IllegalArgumentException e )
+        {
+            assertNotNull( e ) ;
+        }
+    }
+
+    public void testGetLengthLength()
+    {
+        Tuple t = new Tuple() ;
+        assertEquals( 1, t.getLengthLength() ) ;
+        t.length = 127 ;
+        assertEquals( 1, t.getLengthLength() ) ;
+        t.length = 128 ;
+        assertEquals( 2, t.getLengthLength() ) ;
+        t.length = 255 ;
+        assertEquals( 2, t.getLengthLength() ) ;
+        t.length = 256 ;
+        assertEquals( 3, t.getLengthLength() ) ;
+
+        t.length = Tuple.BIT_15 - 1 ;
+        assertEquals( 3, t.getLengthLength() ) ;
+        t.length = Tuple.BIT_15 ;
+        assertEquals( 4, t.getLengthLength() ) ;
+        t.length = Tuple.BIT_15 + 100 ;
+        assertEquals( 4, t.getLengthLength() ) ;
+        
+        t.length = Tuple.BIT_23 - 1 ;
+        assertEquals( 4, t.getLengthLength() ) ;
+        t.length = Tuple.BIT_23 ;
+        assertEquals( 5, t.getLengthLength() ) ;
+        t.length = Tuple.BIT_23 + 100 ;
+        assertEquals( 5, t.getLengthLength() ) ;
+
+        t.length = Integer.MAX_VALUE ;
+        assertEquals( 5, t.getLengthLength() ) ;
+
+        
+        t.length = Integer.MAX_VALUE + 1 ;
+        try
+        {
+            assertEquals( 6, t.getLengthLength() ) ;
+            fail( "should throw an exception before getting here" ) ;
+        }
+        catch( IllegalArgumentException e )
+        {
+            assertNotNull( e ) ;
+        }
+        
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java	Sun Mar 14 14:02:18 2004
@@ -1,115 +1,115 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.io.ByteArrayOutputStream ;
-
-import java.math.BigInteger ;
-
-import java.nio.ByteBuffer ;
-
-import org.apache.commons.codec.stateful.DecoderCallback ;
-import org.apache.commons.codec.stateful.DecoderMonitorAdapter;
-import org.apache.commons.codec.stateful.StatefulDecoder ;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.time.StopWatch ;
-
-import org.apache.ldap.common.message.MessageEncoder ;
-import org.apache.ldap.common.message.BindRequestImpl ;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests the TupleTreeDecoder.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class TupleTreeDecoderTest extends TestCase implements DecoderCallback
-{
-    DefaultMutableTupleNode root = null ;
-    
-    public static void main( String[] args)
-    {
-        TupleTreeDecoderTest test = new TupleTreeDecoderTest() ;
-        
-        try { test.testTTD() ; } catch ( Exception e ) { e.printStackTrace() ; } 
-    }
-    
-    public void testSetMonitor()
-    {
-        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        decoder.setDecoderMonitor( null ) ;
-        decoder.setDecoderMonitor( new DecoderMonitorAdapter() ) ;
-    }
-    
-    
-    public void testTTD2() throws Exception
-    {
-        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        decoder.handleTuple(new Tuple( 1, ArrayUtils.EMPTY_BYTE_ARRAY )) ;
-        decoder.decode( ByteBuffer.wrap( new Tuple( 1, 
-                                ArrayUtils.EMPTY_BYTE_ARRAY ).encode() ) ) ;
-    }    
-    
-    public void testTTD() throws Exception
-    {
-        ByteArrayOutputStream out = new ByteArrayOutputStream() ;
-        
-        // Setup the bind request
-        BindRequestImpl l_request = new BindRequestImpl( BigInteger.ONE ) ;
-        l_request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
-        l_request.setSimple( true ) ;
-        l_request.setCredentials( "password".getBytes() ) ;
-        l_request.setVersion3( true ) ;
-        
-        // Setup the ASN1 Enoder
-        MessageEncoder l_encoder = new MessageEncoder();
- 
-        // Send encoded request to server
-        l_encoder.encode( null, out, l_request );
-        
-        StopWatch watch = new StopWatch() ;
-        watch.start() ;
-        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
-        decoder.setCallback( this ) ;
-        decoder.decode( ByteBuffer.wrap( out.toByteArray() ) ) ;
-        watch.stop() ;
-        System.out.println( "time for decode = " + watch.getTime() ) ;
-        
-        StringBuffer buf = new StringBuffer() ;
-        root.printDepthFirst( buf, 0 ) ;
-        System.out.println( "tuple tlv tree =\n" + buf.toString() ) ;
-        TupleTreeAnalyzer analyzer = new TupleTreeAnalyzer( root ) ;
-        analyzer.startup() ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderCallback#
-     * decodeOccurred(org.apache.commons.codec.stateful.StatefulDecoder, 
-     * java.lang.Object)
-     */
-    public void decodeOccurred( StatefulDecoder decoder, Object decoded )
-    {
-        root = ( DefaultMutableTupleNode ) decoded ;
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.io.ByteArrayOutputStream ;
+
+import java.math.BigInteger ;
+
+import java.nio.ByteBuffer ;
+
+import org.apache.commons.codec.stateful.DecoderCallback ;
+import org.apache.commons.codec.stateful.DecoderMonitorAdapter;
+import org.apache.commons.codec.stateful.StatefulDecoder ;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.time.StopWatch ;
+
+import org.apache.ldap.common.message.MessageEncoder ;
+import org.apache.ldap.common.message.BindRequestImpl ;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests the TupleTreeDecoder.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TupleTreeDecoderTest extends TestCase implements DecoderCallback
+{
+    DefaultMutableTupleNode root = null ;
+    
+    public static void main( String[] args)
+    {
+        TupleTreeDecoderTest test = new TupleTreeDecoderTest() ;
+        
+        try { test.testTTD() ; } catch ( Exception e ) { e.printStackTrace() ; } 
+    }
+    
+    public void testSetMonitor()
+    {
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        decoder.setDecoderMonitor( null ) ;
+        decoder.setDecoderMonitor( new DecoderMonitorAdapter() ) ;
+    }
+    
+    
+    public void testTTD2() throws Exception
+    {
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        decoder.handleTuple(new Tuple( 1, ArrayUtils.EMPTY_BYTE_ARRAY )) ;
+        decoder.decode( ByteBuffer.wrap( new Tuple( 1, 
+                                ArrayUtils.EMPTY_BYTE_ARRAY ).encode() ) ) ;
+    }    
+    
+    public void testTTD() throws Exception
+    {
+        ByteArrayOutputStream out = new ByteArrayOutputStream() ;
+        
+        // Setup the bind request
+        BindRequestImpl l_request = new BindRequestImpl( BigInteger.ONE ) ;
+        l_request.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        l_request.setSimple( true ) ;
+        l_request.setCredentials( "password".getBytes() ) ;
+        l_request.setVersion3( true ) ;
+        
+        // Setup the ASN1 Enoder
+        MessageEncoder l_encoder = new MessageEncoder();
+ 
+        // Send encoded request to server
+        l_encoder.encode( null, out, l_request );
+        
+        StopWatch watch = new StopWatch() ;
+        watch.start() ;
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        decoder.setCallback( this ) ;
+        decoder.decode( ByteBuffer.wrap( out.toByteArray() ) ) ;
+        watch.stop() ;
+        System.out.println( "time for decode = " + watch.getTime() ) ;
+        
+        StringBuffer buf = new StringBuffer() ;
+        root.printDepthFirst( buf, 0 ) ;
+        System.out.println( "tuple tlv tree =\n" + buf.toString() ) ;
+        TupleTreeAnalyzer analyzer = new TupleTreeAnalyzer( root ) ;
+        analyzer.startup() ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderCallback#
+     * decodeOccurred(org.apache.commons.codec.stateful.StatefulDecoder, 
+     * java.lang.Object)
+     */
+    public void decodeOccurred( StatefulDecoder decoder, Object decoded )
+    {
+        root = ( DefaultMutableTupleNode ) decoded ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TypeClassTest.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TypeClassTest.java	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/src/test/org/apache/snickers/ber/TypeClassTest.java	Sun Mar 14 14:02:18 2004
@@ -1,146 +1,146 @@
-/*
- *   Copyright 2004 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.snickers.ber ;
-
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase ;
-
-
-/**
- * Tests TypeClass class.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class TypeClassTest extends TestCase
-{
-
-    public static void main(String[] args)
-    {
-        junit.textui.TestRunner.run(TypeClassTest.class);
-    }
-
-    /*
-     * @see TestCase#setUp()
-     */
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-
-    /*
-     * @see TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-
-    /**
-     * Constructor for TypeClassTest.
-     * @param arg0
-     */
-    public TypeClassTest(String arg0)
-    {
-        super(arg0);
-    }
-
-    /*
-     * Class to test for TypeClass getTypeClass(String)
-     */
-    public void testGetTypeClassString()
-    {
-        assertEquals( TypeClass.APPLICATION, TypeClass.getTypeClass( 
-                        TypeClass.APPLICATION.getName() ) ) ;
-        assertEquals( TypeClass.UNIVERSAL, TypeClass.getTypeClass( 
-                        TypeClass.UNIVERSAL.getName() ) ) ;
-        assertEquals( TypeClass.PRIVATE, TypeClass.getTypeClass( 
-                        TypeClass.PRIVATE.getName() ) ) ;
-        assertEquals( TypeClass.CONTEXT_SPECIFIC, TypeClass.getTypeClass( 
-                        TypeClass.CONTEXT_SPECIFIC.getName() ) ) ;
-
-        assertEquals( TypeClass.APPLICATION, TypeClass.getTypeClass( 
-                        "application") ) ;
-        assertEquals( TypeClass.UNIVERSAL, TypeClass.getTypeClass( 
-                        "Universal" ) ) ;
-        assertEquals( TypeClass.PRIVATE, TypeClass.getTypeClass( 
-                        "PRivatE" ) ) ;
-        assertEquals( TypeClass.CONTEXT_SPECIFIC, TypeClass.getTypeClass( 
-                        "context_specific" ) ) ;
-        
-        try
-        {
-            TypeClass.getTypeClass( "asdf" ) ;
-            fail( "exception should prevent this failure" ) ;
-        }
-        catch ( Throwable t )
-        { 
-            assertNotNull( t ) ;
-        }
-    }
-
-    public void testList()
-    {
-        List list = TypeClass.list() ;
-        assertNotNull( list ) ;
-        assertEquals( 4, list.size() ) ;
-        assertTrue( list.contains( TypeClass.PRIVATE ) ) ;
-        assertTrue( list.contains( TypeClass.UNIVERSAL ) ) ;
-        assertTrue( list.contains( TypeClass.APPLICATION ) ) ;
-        assertTrue( list.contains( TypeClass.CONTEXT_SPECIFIC ) ) ;
-    }
-
-    public void testMap()
-    {
-        Map map = TypeClass.map() ;
-        assertNotNull( map ) ;
-        assertEquals( 4, map.size() ) ;
-        assertTrue( map.containsKey( TypeClass.PRIVATE.getName() ) ) ;
-        assertTrue( map.containsKey( TypeClass.UNIVERSAL.getName() ) ) ;
-        assertTrue( map.containsKey( TypeClass.APPLICATION.getName() ) ) ;
-        assertTrue( map.containsKey( TypeClass.CONTEXT_SPECIFIC.getName() ) ) ;
-    }
-
-    /*
-     * Class to test for TypeClass getTypeClass(int)
-     */
-    public void testGetTypeClassint()
-    {
-        assertEquals( TypeClass.APPLICATION, TypeClass.getTypeClass( 
-                        TypeClass.APPLICATION_VAL ) ) ;
-        assertEquals( TypeClass.PRIVATE, TypeClass.getTypeClass( 
-                        TypeClass.PRIVATE_VAL ) ) ;
-        assertEquals( TypeClass.UNIVERSAL, TypeClass.getTypeClass( 
-                        TypeClass.UNIVERSAL_VAL ) ) ;
-        assertEquals( TypeClass.CONTEXT_SPECIFIC, TypeClass.getTypeClass( 
-                        TypeClass.CONTEXT_SPECIFIC_VAL ) ) ;
-        
-        try
-        {
-            TypeClass.getTypeClass( 35 ) ;
-            fail( "exception should prevent this failure" ) ;
-        }
-        catch( Throwable t )
-        {
-            assertNotNull( t ) ;
-        }
-    }
-}
+/*
+ *   Copyright 2004 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.snickers.ber ;
+
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests TypeClass class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TypeClassTest extends TestCase
+{
+
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(TypeClassTest.class);
+    }
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * Constructor for TypeClassTest.
+     * @param arg0
+     */
+    public TypeClassTest(String arg0)
+    {
+        super(arg0);
+    }
+
+    /*
+     * Class to test for TypeClass getTypeClass(String)
+     */
+    public void testGetTypeClassString()
+    {
+        assertEquals( TypeClass.APPLICATION, TypeClass.getTypeClass( 
+                        TypeClass.APPLICATION.getName() ) ) ;
+        assertEquals( TypeClass.UNIVERSAL, TypeClass.getTypeClass( 
+                        TypeClass.UNIVERSAL.getName() ) ) ;
+        assertEquals( TypeClass.PRIVATE, TypeClass.getTypeClass( 
+                        TypeClass.PRIVATE.getName() ) ) ;
+        assertEquals( TypeClass.CONTEXT_SPECIFIC, TypeClass.getTypeClass( 
+                        TypeClass.CONTEXT_SPECIFIC.getName() ) ) ;
+
+        assertEquals( TypeClass.APPLICATION, TypeClass.getTypeClass( 
+                        "application") ) ;
+        assertEquals( TypeClass.UNIVERSAL, TypeClass.getTypeClass( 
+                        "Universal" ) ) ;
+        assertEquals( TypeClass.PRIVATE, TypeClass.getTypeClass( 
+                        "PRivatE" ) ) ;
+        assertEquals( TypeClass.CONTEXT_SPECIFIC, TypeClass.getTypeClass( 
+                        "context_specific" ) ) ;
+        
+        try
+        {
+            TypeClass.getTypeClass( "asdf" ) ;
+            fail( "exception should prevent this failure" ) ;
+        }
+        catch ( Throwable t )
+        { 
+            assertNotNull( t ) ;
+        }
+    }
+
+    public void testList()
+    {
+        List list = TypeClass.list() ;
+        assertNotNull( list ) ;
+        assertEquals( 4, list.size() ) ;
+        assertTrue( list.contains( TypeClass.PRIVATE ) ) ;
+        assertTrue( list.contains( TypeClass.UNIVERSAL ) ) ;
+        assertTrue( list.contains( TypeClass.APPLICATION ) ) ;
+        assertTrue( list.contains( TypeClass.CONTEXT_SPECIFIC ) ) ;
+    }
+
+    public void testMap()
+    {
+        Map map = TypeClass.map() ;
+        assertNotNull( map ) ;
+        assertEquals( 4, map.size() ) ;
+        assertTrue( map.containsKey( TypeClass.PRIVATE.getName() ) ) ;
+        assertTrue( map.containsKey( TypeClass.UNIVERSAL.getName() ) ) ;
+        assertTrue( map.containsKey( TypeClass.APPLICATION.getName() ) ) ;
+        assertTrue( map.containsKey( TypeClass.CONTEXT_SPECIFIC.getName() ) ) ;
+    }
+
+    /*
+     * Class to test for TypeClass getTypeClass(int)
+     */
+    public void testGetTypeClassint()
+    {
+        assertEquals( TypeClass.APPLICATION, TypeClass.getTypeClass( 
+                        TypeClass.APPLICATION_VAL ) ) ;
+        assertEquals( TypeClass.PRIVATE, TypeClass.getTypeClass( 
+                        TypeClass.PRIVATE_VAL ) ) ;
+        assertEquals( TypeClass.UNIVERSAL, TypeClass.getTypeClass( 
+                        TypeClass.UNIVERSAL_VAL ) ) ;
+        assertEquals( TypeClass.CONTEXT_SPECIFIC, TypeClass.getTypeClass( 
+                        TypeClass.CONTEXT_SPECIFIC_VAL ) ) ;
+        
+        try
+        {
+            TypeClass.getTypeClass( 35 ) ;
+            fail( "exception should prevent this failure" ) ;
+        }
+        catch( Throwable t )
+        {
+            assertNotNull( t ) ;
+        }
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/ber/todo.txt
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/todo.txt	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/todo.txt	Sun Mar 14 14:02:18 2004
@@ -1,39 +1,39 @@
-
-
-                                T O D O   L I S T 
-                                =================
-
-* Need an equality test for TupleNodes hence trees.
-
-* For the mock decoder in Eve see if we can rig in a decoder that builds on this
-  BERDecoder that can at a bare minimum detect when an LDAP message starts and 
-  ends.  This way we can continue working on Eve while the snickers code 
-  progresses forward.  In fact we could even capture a full buffer and feed it
-  to the old synchronous SNACC provider just for now to get decodes working.
-
---o--
-
-* Add a value size protection feature to the decoder to either break up 
-  incomming massive tlv's into smaller tlv's or to stream them to disk, 
-  and providing a data reference rather than a byte[] to the callback's 
-  decodeOccurred method.  This will be huge for both performance and the
-  prevention of denial of service attacks where massive TLV's bombard the
-  decoder.  We need to look at the big picture to figure out which approach
-  is best within the whole decoding processs.
-
---o--
-
-* Build a library of primitive ASN.1 data types mapping them to Java types.
-
-* Build a digester like tool on top of the BERDecoder, for now we'll call it a
-  TLVDecoder.  It is fed a train of TLV's and it statefully constructs ASN.1
-  stubs based on the input.  When an entire stub has been assembled it is 
-  emitted via the decodeOccurred callback.
-  
-* It will be worth while taking a good look at the way digester works to get 
-  some ideas here.
-  
-* Also we need to read the Sample Neufeld papper to make sure we're decoding
-  appropriately.
-  
-  
+
+
+                                T O D O   L I S T 
+                                =================
+
+* Need an equality test for TupleNodes hence trees.
+
+* For the mock decoder in Eve see if we can rig in a decoder that builds on this
+  BERDecoder that can at a bare minimum detect when an LDAP message starts and 
+  ends.  This way we can continue working on Eve while the snickers code 
+  progresses forward.  In fact we could even capture a full buffer and feed it
+  to the old synchronous SNACC provider just for now to get decodes working.
+
+--o--
+
+* Add a value size protection feature to the decoder to either break up 
+  incomming massive tlv's into smaller tlv's or to stream them to disk, 
+  and providing a data reference rather than a byte[] to the callback's 
+  decodeOccurred method.  This will be huge for both performance and the
+  prevention of denial of service attacks where massive TLV's bombard the
+  decoder.  We need to look at the big picture to figure out which approach
+  is best within the whole decoding processs.
+
+--o--
+
+* Build a library of primitive ASN.1 data types mapping them to Java types.
+
+* Build a digester like tool on top of the BERDecoder, for now we'll call it a
+  TLVDecoder.  It is fed a train of TLV's and it statefully constructs ASN.1
+  stubs based on the input.  When an entire stub has been assembled it is 
+  emitted via the decodeOccurred callback.
+  
+* It will be worth while taking a good look at the way digester works to get 
+  some ideas here.
+  
+* Also we need to read the Sample Neufeld papper to make sure we're decoding
+  appropriately.
+  
+  

Modified: incubator/directory/snickers/branches/refactoring/ber/xdocs/design.xml
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/xdocs/design.xml	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/xdocs/design.xml	Sun Mar 14 14:02:18 2004
@@ -1,99 +1,99 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document>
-  <properties>
-    <author email="akarasulu@apache.org">Alex Karasulu</author>
-    <title>Design Documentation</title>
-  </properties>
-  <body>
-    <section name="Introduction">
-      <p>
-        We're designing the decoder peice using the stateful decoder interfaces
-        that were carved up for the commons-codec API within their stateful 
-        package.  The stateful decoder is designed to maintain state while 
-        processing arriving chunks of TLV data.
-      </p>
-      
-      <p>
-        There are several issues confronted by the decoder while decoding a 
-        stream of TLV trees where TLV tuples are nested within each other.  In
-        general this decoder is viewed as a simple line parser for TLV tuples
-        notifying of their arrival via callbacks.
-      </p>
-    </section>
-    
-    <section name="Requirements">
-      <p>
-        The decoder must be fast, have a fixed memory footprint, and be simple.
-        It should perform only one task: notifying content handlers via 
-        callbacks of the arrival of TLV tuples.  While doing so it must maintain
-        state in between calls to decode a chunk of arriving BER encoded data.
-      </p>
-      
-      <p>
-        It should not try to interpret the content of the TLV tuples.  These 
-        aspects are left to be handled by higher level content based facilities
-        that build on top of the BERDecoder.  These higher facilities provide 
-        their own callbacks to build on TLV events.
-      </p>
-    </section>
-    
-    <section name="Object Reuse and Using Primitive Types">
-      <p>
-        The density of TLV tuples encountered during decoder operation will 
-        vary based on message characteristics.  One of the most involved aspects
-        to the decoder is to spit out TLV tuples when emitting events.
-      </p>
-      
-      <p>
-        We could just instantiate a new TLV tuple object for every tuple but
-        this would slow the decoder down and increase the memory footprint 
-        making it less efficient.  For this reason we decided to reuse the same
-        TLV tuple to deliver TLV data via notification events on the callback.
-        The callback implementation must copy the tuple's data if it intends to
-        save the TLV for use later.  Otherwise the decoder will overwrite the 
-        TLV members on the next event.  We leave the option to copy the TLV 
-        upto the higher level facility that way only those TLV tuples of 
-        interest, known only to the content specific handler, can be copied.
-        Why waste space and time within the decoder one those events that will
-        not be of interest?
-      </p>
-       
-      <p>
-        The most complex part of the decoder deals with maintaining state while
-        decoding.  Data can arrive at any time to contain any part of a TLV or
-        multiple TLVs along with parts of others.  Often the fragmentation of
-        the data will not be known.  Furthermore the nesting of TLVs must be
-        tracked while maintaining state.  A stack is perhaps the best structure
-        to use to track the nesting of TLV tuples within a TLV tree.
-      </p>
-      
-      <p>
-        We do not instantiate TLV tuple objects so pushing the one TLV instance 
-        we reuse is pointless.  We could use two approaches here to handle this
-        nuisance.  First we could just create a new instance only for those TLV
-        tuples that nest others and hence need to be pushed onto the stack.  Or
-        we can use multiple primitive stacks based on an int to store the set
-        of values contained in the tuple.  The second approach leads to greater
-        complexity while the first leads to some overhead in extra instantiation
-        time and memory which is negligable really.  Which approach is best 
-        depends on the number of members in the tuple or in otherwords the 
-        number of primitive int stacks.
-      </p>
-      
-      <p>
-        We wrote a little test to figure out when one approach out performs the
-        other in the ObjectVersePrimitiveTest unit test case.  From tinkering
-        with the parameters of the test case we found the use of primitives to
-        out perform tuple object instantiation when the number of member stacks
-        is less than or equal to 2.  If the number of stacks used is 3 or more
-        then instantiating an TLV object and pushing it onto one stack is best.
-        In our case we have 3 peices of information that need to be pushed and
-        poped together so from this data the choice is clear.  We clone the TLV
-        tuple or instantiate a new one for constructed TLVs that are pushed onto
-        a single stack.  This is faster and removes the need to manage multiple
-        stacks making the code less complex.
-      </p>
-    </section>
-    
-  </body>
+<?xml version="1.0" encoding="UTF-8"?>
+<document>
+  <properties>
+    <author email="akarasulu@apache.org">Alex Karasulu</author>
+    <title>Design Documentation</title>
+  </properties>
+  <body>
+    <section name="Introduction">
+      <p>
+        We're designing the decoder peice using the stateful decoder interfaces
+        that were carved up for the commons-codec API within their stateful 
+        package.  The stateful decoder is designed to maintain state while 
+        processing arriving chunks of TLV data.
+      </p>
+      
+      <p>
+        There are several issues confronted by the decoder while decoding a 
+        stream of TLV trees where TLV tuples are nested within each other.  In
+        general this decoder is viewed as a simple line parser for TLV tuples
+        notifying of their arrival via callbacks.
+      </p>
+    </section>
+    
+    <section name="Requirements">
+      <p>
+        The decoder must be fast, have a fixed memory footprint, and be simple.
+        It should perform only one task: notifying content handlers via 
+        callbacks of the arrival of TLV tuples.  While doing so it must maintain
+        state in between calls to decode a chunk of arriving BER encoded data.
+      </p>
+      
+      <p>
+        It should not try to interpret the content of the TLV tuples.  These 
+        aspects are left to be handled by higher level content based facilities
+        that build on top of the BERDecoder.  These higher facilities provide 
+        their own callbacks to build on TLV events.
+      </p>
+    </section>
+    
+    <section name="Object Reuse and Using Primitive Types">
+      <p>
+        The density of TLV tuples encountered during decoder operation will 
+        vary based on message characteristics.  One of the most involved aspects
+        to the decoder is to spit out TLV tuples when emitting events.
+      </p>
+      
+      <p>
+        We could just instantiate a new TLV tuple object for every tuple but
+        this would slow the decoder down and increase the memory footprint 
+        making it less efficient.  For this reason we decided to reuse the same
+        TLV tuple to deliver TLV data via notification events on the callback.
+        The callback implementation must copy the tuple's data if it intends to
+        save the TLV for use later.  Otherwise the decoder will overwrite the 
+        TLV members on the next event.  We leave the option to copy the TLV 
+        upto the higher level facility that way only those TLV tuples of 
+        interest, known only to the content specific handler, can be copied.
+        Why waste space and time within the decoder one those events that will
+        not be of interest?
+      </p>
+       
+      <p>
+        The most complex part of the decoder deals with maintaining state while
+        decoding.  Data can arrive at any time to contain any part of a TLV or
+        multiple TLVs along with parts of others.  Often the fragmentation of
+        the data will not be known.  Furthermore the nesting of TLVs must be
+        tracked while maintaining state.  A stack is perhaps the best structure
+        to use to track the nesting of TLV tuples within a TLV tree.
+      </p>
+      
+      <p>
+        We do not instantiate TLV tuple objects so pushing the one TLV instance 
+        we reuse is pointless.  We could use two approaches here to handle this
+        nuisance.  First we could just create a new instance only for those TLV
+        tuples that nest others and hence need to be pushed onto the stack.  Or
+        we can use multiple primitive stacks based on an int to store the set
+        of values contained in the tuple.  The second approach leads to greater
+        complexity while the first leads to some overhead in extra instantiation
+        time and memory which is negligable really.  Which approach is best 
+        depends on the number of members in the tuple or in otherwords the 
+        number of primitive int stacks.
+      </p>
+      
+      <p>
+        We wrote a little test to figure out when one approach out performs the
+        other in the ObjectVersePrimitiveTest unit test case.  From tinkering
+        with the parameters of the test case we found the use of primitives to
+        out perform tuple object instantiation when the number of member stacks
+        is less than or equal to 2.  If the number of stacks used is 3 or more
+        then instantiating an TLV object and pushing it onto one stack is best.
+        In our case we have 3 peices of information that need to be pushed and
+        poped together so from this data the choice is clear.  We clone the TLV
+        tuple or instantiate a new one for constructed TLVs that are pushed onto
+        a single stack.  This is faster and removes the need to manage multiple
+        stacks making the code less complex.
+      </p>
+    </section>
+    
+  </body>
 </document>

Modified: incubator/directory/snickers/branches/refactoring/ber/xdocs/empty/index.xml
==============================================================================
--- incubator/directory/snickers/branches/refactoring/ber/xdocs/empty/index.xml	(original)
+++ incubator/directory/snickers/branches/refactoring/ber/xdocs/empty/index.xml	Sun Mar 14 14:02:18 2004
@@ -1,12 +1,12 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document>
-  <properties>
-    <author email="akarasulu@apache.org">Alex Karasulu</author>
-    <title>Empty!</title>
-  </properties>
-  <body>
-    <section name="Empty!">
-      <p>This is an empty place holder for pages one directory above.</p>
-    </section>
-  </body>
-</document>
+<?xml version="1.0" encoding="UTF-8"?>
+<document>
+  <properties>
+    <author email="akarasulu@apache.org">Alex Karasulu</author>
+    <title>Empty!</title>
+  </properties>
+  <body>
+    <section name="Empty!">
+      <p>This is an empty place holder for pages one directory above.</p>
+    </section>
+  </body>
+</document>

Modified: incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/CallbackHistory.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/CallbackHistory.java	(original)
+++ incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/CallbackHistory.java	Sun Mar 14 14:02:18 2004
@@ -1,127 +1,127 @@
-/*
- *   Copyright 2004 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.commons.codec.stateful ;
-
-
-import java.util.LinkedList ;
-
-
-/**
- * A convenience callback which collects decoded objects to audit a decoder's 
- * activity.  The callback also comes in handy when data is to be pushed 
- * through a decoder and grabed immediately afterwords.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public class CallbackHistory implements DecoderCallback
-{
-    /** history of decoded objects in cronological order */
-    private final LinkedList history ;
-    /** the length of callback history stored */
-    private final int length ;
-    
-
-    /**
-     * Creates an auditing callback that manages a history of fixed or 
-     * indefinate length.  If the length is fixed the history effectively 
-     * becomes a FIFO structure.
-     * 
-     * @param length the maximum length of callback history to store before
-     *  dropping decoded items, a length of zero or 1 corresponds to indefinate
-     *  history 
-     */
-    public CallbackHistory( int length )
-    {
-        this.length = length ;
-        history = new LinkedList() ;
-    }
-    
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
-     */
-    public void decodeOccurred( StatefulDecoder decoder, Object decoded )
-    {
-        if ( length > 0 )
-        {    
-            while ( history.size() >= length )
-            {
-                history.removeLast() ;
-            }
-        }
-        
-        history.addFirst( decoded ) ;
-    }
-    
-    
-    /**
-     * Gets the most recent decoded object if one exists.
-     * 
-     * @return the most recent decoded object
-     * @throws java.util.NoSuchElementException if the history is empty
-     */
-    public Object getMostRecent()
-    {
-        return history.getFirst() ;
-    }
-    
-    
-    /**
-     * Gets the oldest decoded object if one exists.
-     * 
-     * @return the oldest decoded object
-     * @throws java.util.NoSuchElementException if the history is empty
-     */
-    public Object getOldest()
-    {
-        return history.getLast() ;
-    }
-    
-    
-    /**
-     * Tests to see if the history is empty.
-     * 
-     * @return true if the history is empty, false otherwise
-     */
-    public boolean isEmpty()
-    {
-        return history.isEmpty() ;
-    }
-    
-    
-    /**
-     * Clears the history of decoded items.
-     */
-    public void clear()
-    {
-        history.clear() ;
-    }
-    
-    
-    /**
-     * Gets the number of decoded items in the callback history.
-     * 
-     * @return the number of decoded items in the callback history
-     */
-    public int size()
-    {
-        return history.size() ;
-    }
-}
+/*
+ *   Copyright 2004 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.commons.codec.stateful ;
+
+
+import java.util.LinkedList ;
+
+
+/**
+ * A convenience callback which collects decoded objects to audit a decoder's 
+ * activity.  The callback also comes in handy when data is to be pushed 
+ * through a decoder and grabed immediately afterwords.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class CallbackHistory implements DecoderCallback
+{
+    /** history of decoded objects in cronological order */
+    private final LinkedList history ;
+    /** the length of callback history stored */
+    private final int length ;
+    
+
+    /**
+     * Creates an auditing callback that manages a history of fixed or 
+     * indefinate length.  If the length is fixed the history effectively 
+     * becomes a FIFO structure.
+     * 
+     * @param length the maximum length of callback history to store before
+     *  dropping decoded items, a length of zero or 1 corresponds to indefinate
+     *  history 
+     */
+    public CallbackHistory( int length )
+    {
+        this.length = length ;
+        history = new LinkedList() ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderCallback#decodeOccurred(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Object)
+     */
+    public void decodeOccurred( StatefulDecoder decoder, Object decoded )
+    {
+        if ( length > 0 )
+        {    
+            while ( history.size() >= length )
+            {
+                history.removeLast() ;
+            }
+        }
+        
+        history.addFirst( decoded ) ;
+    }
+    
+    
+    /**
+     * Gets the most recent decoded object if one exists.
+     * 
+     * @return the most recent decoded object
+     * @throws java.util.NoSuchElementException if the history is empty
+     */
+    public Object getMostRecent()
+    {
+        return history.getFirst() ;
+    }
+    
+    
+    /**
+     * Gets the oldest decoded object if one exists.
+     * 
+     * @return the oldest decoded object
+     * @throws java.util.NoSuchElementException if the history is empty
+     */
+    public Object getOldest()
+    {
+        return history.getLast() ;
+    }
+    
+    
+    /**
+     * Tests to see if the history is empty.
+     * 
+     * @return true if the history is empty, false otherwise
+     */
+    public boolean isEmpty()
+    {
+        return history.isEmpty() ;
+    }
+    
+    
+    /**
+     * Clears the history of decoded items.
+     */
+    public void clear()
+    {
+        history.clear() ;
+    }
+    
+    
+    /**
+     * Gets the number of decoded items in the callback history.
+     * 
+     * @return the number of decoded items in the callback history
+     */
+    public int size()
+    {
+        return history.size() ;
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderCallback.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderCallback.java	(original)
+++ incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderCallback.java	Sun Mar 14 14:02:18 2004
@@ -1,34 +1,34 @@
-/*
- *   Copyright 2004 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.commons.codec.stateful ;
-
-/**
- * Callback interface for stateful decoder callbacks.
- *
- * @author <a href="mailto:commons-dev@jakarta.apache.org">Jakarta Commons</a>
- * @version $Rev$
- */
-public interface DecoderCallback
-{
-    /**
-     * Callback to deliver a fully decoded object.
-     * 
-     * @param decoder the stateful decoder driving the callback
-     * @param decoded the object that was decoded
-     */
-    void decodeOccurred( StatefulDecoder decoder, Object decoded ) ;
-}
+/*
+ *   Copyright 2004 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.commons.codec.stateful ;
+
+/**
+ * Callback interface for stateful decoder callbacks.
+ *
+ * @author <a href="mailto:commons-dev@jakarta.apache.org">Jakarta Commons</a>
+ * @version $Rev$
+ */
+public interface DecoderCallback
+{
+    /**
+     * Callback to deliver a fully decoded object.
+     * 
+     * @param decoder the stateful decoder driving the callback
+     * @param decoded the object that was decoded
+     */
+    void decodeOccurred( StatefulDecoder decoder, Object decoded ) ;
+}

Modified: incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderMonitor.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderMonitor.java	(original)
+++ incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderMonitor.java	Sun Mar 14 14:02:18 2004
@@ -1,90 +1,90 @@
-/*
- *   Copyright 2004 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.commons.codec.stateful ;
-
-
-/**
- * Monitors decoder errors.  This class borrowed some from the <code>
- * org.xml.sax.ErrorHandler</code> interface and its documentation.
- *
- * @author <a href="mailto:directory-dev@incubator.apache.org">
- * Apache Directory Project</a>
- * @version $Rev$
- */
-public interface DecoderMonitor
-{
-    /**
-     * Receive notification of a recoverable error.  This callback is used to
-     * denote a failure to handle a unit of data to be encoded or decoded.  The
-     * entire [en|de]codable unit is lost but the [en|de]coding operation can 
-     * still proceed.
-     * 
-     * @param decoder the decoder that had the error
-     * @param exception the error information encapsulated in an exception
-     */
-    void error( StatefulDecoder decoder, Exception exception ) ;
-    
-    /**
-     * Receive notification of a warning.  The decoder must continue to provide
-     * normal callbacks after invoking this method: it should still be possible 
-     * for the application to process the encoded data through to the end.
-     * 
-     * @param decoder the decoder that had the error
-     * @param exception the warning information encapsulated in an exception
-     */
-    void fatalError( StatefulDecoder decoder, Exception exception ) ;
-    
-    /**
-     * Receive notification of a non-recoverable error.  The application must 
-     * assume that the stream data is unusable after the decoder has invoked 
-     * this method, and should continue (if at all) only for the sake of 
-     * collecting addition error messages: in fact, decoders are free to stop 
-     * reporting any other events once this method has been invoked.
-     *  
-     * @param decoder the decoder that had the failure
-     * @param exception the warning information encapsulated in an exception
-     */
-    void warning( StatefulDecoder decoder, Exception exception ) ;
-
-    /**
-     * Monitors callbacks that deliver a fully decoded object.
-     * 
-     * @param decoder the stateful decoder driving the callback
-     * @param decoded the object that was decoded
-     */
-    void callbackOccured( StatefulDecoder decoder, DecoderCallback cb, 
-						  Object decoded ) ;
-    
-    /**
-     * Monitors changes to the callback.
-     * 
-     * @param decoder the decoder whose callback was set
-     * @param oldcb the unset old callback, or null if none was set
-     * @param newcb the newly set callback, or null if callback is cleared
-     */
-    void callbackSet( StatefulDecoder decoder, DecoderCallback oldcb, 
-					  DecoderCallback newcb ) ;
-
-    /**
-     * Monitors changes to the the monitor for the decoder.  Note that the
-     * object being called is the new monitor.
-     * 
-     * @param decoder the decoder whose monitor was set
-     * @param oldmon the old monitor or null if none was set
-     */
-    void monitorSet( StatefulDecoder decoder, DecoderMonitor oldmon ) ;
-}
+/*
+ *   Copyright 2004 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.commons.codec.stateful ;
+
+
+/**
+ * Monitors decoder errors.  This class borrowed some from the <code>
+ * org.xml.sax.ErrorHandler</code> interface and its documentation.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface DecoderMonitor
+{
+    /**
+     * Receive notification of a recoverable error.  This callback is used to
+     * denote a failure to handle a unit of data to be encoded or decoded.  The
+     * entire [en|de]codable unit is lost but the [en|de]coding operation can 
+     * still proceed.
+     * 
+     * @param decoder the decoder that had the error
+     * @param exception the error information encapsulated in an exception
+     */
+    void error( StatefulDecoder decoder, Exception exception ) ;
+    
+    /**
+     * Receive notification of a warning.  The decoder must continue to provide
+     * normal callbacks after invoking this method: it should still be possible 
+     * for the application to process the encoded data through to the end.
+     * 
+     * @param decoder the decoder that had the error
+     * @param exception the warning information encapsulated in an exception
+     */
+    void fatalError( StatefulDecoder decoder, Exception exception ) ;
+    
+    /**
+     * Receive notification of a non-recoverable error.  The application must 
+     * assume that the stream data is unusable after the decoder has invoked 
+     * this method, and should continue (if at all) only for the sake of 
+     * collecting addition error messages: in fact, decoders are free to stop 
+     * reporting any other events once this method has been invoked.
+     *  
+     * @param decoder the decoder that had the failure
+     * @param exception the warning information encapsulated in an exception
+     */
+    void warning( StatefulDecoder decoder, Exception exception ) ;
+
+    /**
+     * Monitors callbacks that deliver a fully decoded object.
+     * 
+     * @param decoder the stateful decoder driving the callback
+     * @param decoded the object that was decoded
+     */
+    void callbackOccured( StatefulDecoder decoder, DecoderCallback cb, 
+						  Object decoded ) ;
+    
+    /**
+     * Monitors changes to the callback.
+     * 
+     * @param decoder the decoder whose callback was set
+     * @param oldcb the unset old callback, or null if none was set
+     * @param newcb the newly set callback, or null if callback is cleared
+     */
+    void callbackSet( StatefulDecoder decoder, DecoderCallback oldcb, 
+					  DecoderCallback newcb ) ;
+
+    /**
+     * Monitors changes to the the monitor for the decoder.  Note that the
+     * object being called is the new monitor.
+     * 
+     * @param decoder the decoder whose monitor was set
+     * @param oldmon the old monitor or null if none was set
+     */
+    void monitorSet( StatefulDecoder decoder, DecoderMonitor oldmon ) ;
+}

Modified: incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderMonitorAdapter.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderMonitorAdapter.java	(original)
+++ incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/DecoderMonitorAdapter.java	Sun Mar 14 14:02:18 2004
@@ -1,87 +1,87 @@
-/*
- *   Copyright 2004 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.commons.codec.stateful ;
-
-
-/**
- * A do nothing decoder monitor adapter.
- *
- * @author Apache Software Foundation
- * @version $Rev$
- */
-public class DecoderMonitorAdapter implements DecoderMonitor
-{
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#error(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void error( StatefulDecoder decoder, Exception exception )
-    {
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#fatalError(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void fatalError( StatefulDecoder decoder, Exception exception )
-    {
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#warning(
-     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
-     */
-    public void warning( StatefulDecoder decoder, Exception exception )
-    {
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackOccured(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderCallback, java.lang.Object)
-     */
-    public void callbackOccured( StatefulDecoder decoder, DecoderCallback cb,
-								 Object decoded )
-    {
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackSet(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderCallback, 
-     * org.apache.commons.codec.stateful.DecoderCallback)
-     */
-    public void callbackSet( StatefulDecoder decoder, DecoderCallback oldcb,
-							 DecoderCallback newcb )
-    {
-    }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.commons.codec.stateful.DecoderMonitor#monitorSet(
-     * org.apache.commons.codec.stateful.StatefulDecoder, 
-     * org.apache.commons.codec.stateful.DecoderMonitor)
-     */
-    public void monitorSet( StatefulDecoder decoder, DecoderMonitor oldmon )
-    {
-    }
-}
+/*
+ *   Copyright 2004 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.commons.codec.stateful ;
+
+
+/**
+ * A do nothing decoder monitor adapter.
+ *
+ * @author Apache Software Foundation
+ * @version $Rev$
+ */
+public class DecoderMonitorAdapter implements DecoderMonitor
+{
+
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#error(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void error( StatefulDecoder decoder, Exception exception )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#fatalError(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void fatalError( StatefulDecoder decoder, Exception exception )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#warning(
+     * org.apache.commons.codec.stateful.StatefulDecoder, java.lang.Exception)
+     */
+    public void warning( StatefulDecoder decoder, Exception exception )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackOccured(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderCallback, java.lang.Object)
+     */
+    public void callbackOccured( StatefulDecoder decoder, DecoderCallback cb,
+								 Object decoded )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#callbackSet(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderCallback, 
+     * org.apache.commons.codec.stateful.DecoderCallback)
+     */
+    public void callbackSet( StatefulDecoder decoder, DecoderCallback oldcb,
+							 DecoderCallback newcb )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.commons.codec.stateful.DecoderMonitor#monitorSet(
+     * org.apache.commons.codec.stateful.StatefulDecoder, 
+     * org.apache.commons.codec.stateful.DecoderMonitor)
+     */
+    public void monitorSet( StatefulDecoder decoder, DecoderMonitor oldmon )
+    {
+    }
+}

Modified: incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/StatefulDecoder.java
==============================================================================
--- incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/StatefulDecoder.java	(original)
+++ incubator/directory/snickers/branches/refactoring/codec-stateful/src/java/org/apache/commons/codec/stateful/StatefulDecoder.java	Sun Mar 14 14:02:18 2004
@@ -1,60 +1,60 @@
-/*
- *   Copyright 2004 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.commons.codec.stateful ;
-
-
-import org.apache.commons.codec.DecoderException ;
-
-
-/**
- * A statful decoder which decodes encoded data as it arrives in peices.
- * As chunks of encoded data arrive the decoder processes each chunk of encoded
- * data and maintains decoding state in between arrivals: it is hence stateful 
- * and should be associated with a single channel or encoded data producer.  
- * When an arbitrary unit of encoding, to be determined by the encoding scheme,
- * has been decoded, a registered DecoderCallback is called.
- *
- * @author <a href="mailto:commons-dev@jakarta.apache.org">Jakarta Commons</a>
- * @version $Rev$
- */
-public interface StatefulDecoder
-{
-    /**
-     * Decodes a peice of encoded data.  The nature of this call, synchronous
-     * verses asynchonous, with respect to driving the actual decoding of the 
-     * encoded data argument is determined by an implementation.  A return from
-     * this method does not guarrantee any callbacks: zero or more callbacks 
-     * may occur during this call.
-     * 
-     * @param encode an object representing a peice of encoded data
-     */
-    void decode( Object encoded ) throws DecoderException ;
-
-    /**
-     * Sets the callback for this StatefulDecoder.
-     * 
-     * @param cb the callback to inform of a complete decode operation
-     */
-    void setCallback( DecoderCallback cb ) ;
-    
-    /**
-     * Monitors all kinds of events that occur during processing.
-     * 
-     * @param monitor to set for this StatefulDecoder
-     */
-    void setDecoderMonitor( DecoderMonitor monitor ) ;
-}
+/*
+ *   Copyright 2004 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.commons.codec.stateful ;
+
+
+import org.apache.commons.codec.DecoderException ;
+
+
+/**
+ * A statful decoder which decodes encoded data as it arrives in peices.
+ * As chunks of encoded data arrive the decoder processes each chunk of encoded
+ * data and maintains decoding state in between arrivals: it is hence stateful 
+ * and should be associated with a single channel or encoded data producer.  
+ * When an arbitrary unit of encoding, to be determined by the encoding scheme,
+ * has been decoded, a registered DecoderCallback is called.
+ *
+ * @author <a href="mailto:commons-dev@jakarta.apache.org">Jakarta Commons</a>
+ * @version $Rev$
+ */
+public interface StatefulDecoder
+{
+    /**
+     * Decodes a peice of encoded data.  The nature of this call, synchronous
+     * verses asynchonous, with respect to driving the actual decoding of the 
+     * encoded data argument is determined by an implementation.  A return from
+     * this method does not guarrantee any callbacks: zero or more callbacks 
+     * may occur during this call.
+     * 
+     * @param encode an object representing a peice of encoded data
+     */
+    void decode( Object encoded ) throws DecoderException ;
+
+    /**
+     * Sets the callback for this StatefulDecoder.
+     * 
+     * @param cb the callback to inform of a complete decode operation
+     */
+    void setCallback( DecoderCallback cb ) ;
+    
+    /**
+     * Monitors all kinds of events that occur during processing.
+     * 
+     * @param monitor to set for this StatefulDecoder
+     */
+    void setDecoderMonitor( DecoderMonitor monitor ) ;
+}

Modified: incubator/directory/snickers/branches/refactoring/project.xml
==============================================================================
--- incubator/directory/snickers/branches/refactoring/project.xml	(original)
+++ incubator/directory/snickers/branches/refactoring/project.xml	Sun Mar 14 14:02:18 2004
@@ -1,214 +1,214 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<project>
-    <groupId>directory</groupId>
-    <id>snickers</id>
-    <name>Snickers ASN.1 Tools</name>
-    <package>org.apache.snickers</package>
-
-    <inceptionYear>2003</inceptionYear>
-    <url>http://directory.apache.org/snickers</url>
-    <issueTrackingUrl>
-      http://nagoya.apache.org/scarab/servlet/scarab
-    </issueTrackingUrl>
-    <siteAddress>directory.apache.org</siteAddress>
-    <siteDirectory>/home/akarasulu/public_html</siteDirectory>
-    <distributionDirectory>
-      /home/akarasulu/public_html/dist
-    </distributionDirectory>
-
-    <repository>
-      <connection>
-          scm:svn:http://cvs.apache.org/repos/asf/incubator/directory/snickers/trunk
-      </connection>
-
-      <url>
-        http://cvs.apache.org/viewcvs.cgi/incubator/directory/snickers/trunk?root=Apache-SVN
-      </url>
-      
-      <developerConnection>
-        http://cvs.apache.org/repos/asf/incubator/directory/snickers/trunk
-      </developerConnection>
-    </repository>
-  
-    <shortDescription>Snickers ASN.1 Tools</shortDescription>
-      
-    <description>
-      The snickers subproject attempts to isolate the ASN.1 tools used to
-      build Basic Encoding Rule (BER) codecs for any ASN.1 based network
-      protocol.  The LDAP and X.500 aspects of the directory project impose
-      the need for ASN.1 tools and BER codecs.  Rather than implement highly
-      specific and britle code for these needs we decided to separate out
-      the APIs and implementations used for dealing with BER codecs for any
-      ASN.1 defined protocol.
-    </description>
-
-    <mailingLists>
-      <mailingList>
-        <name>Apache Directory Developement - use [snickers] prefix</name>
-          <subscribe>
-            directory-dev-subscribe@incubator.apache.org
-          </subscribe>
-          <unsubscribe>
-            directory-dev-unsubscribe@incubator.apache.org
-          </unsubscribe>
-          <archive>
-            http://nagoya.apache.org/eyebrowse/SummarizeList?listId=181
-          </archive>
-        </mailingList>
-    </mailingLists>
-    
-    <developers>
-      <developer>
-        <name>Alex Karasulu</name>
-        <id>akarasulu</id>
-        <email>akarasulu at apache.org</email>
-        <roles>
-          <role>Founder</role>
-          <role>Developer</role>
-          <role>Architect</role>
-          <role>Lead Developer</role>
-        </roles>
-      </developer>
-      <developer>
-        <name>Robb Penoyer</name>
-        <id>rpenoyer</id>
-        <email>rpenoyer at apache.org</email>
-        <roles>
-          <role>Developer</role>
-        </roles>
-      </developer>
-      <developer>
-        <name>Jeff Machols</name>
-        <id>jmachols</id>
-        <email>jmachols at apache.org</email>
-        <roles>
-          <role>Developer</role>
-          <role>Infrastructure Support</role>
-        </roles>
-      </developer>
-      <developer>
-        <name>Wes McKean</name>
-        <id>wesmckean</id>
-        <email>wesmckean at apache.org</email>
-        <roles>
-          <role>Developer</role>
-        </roles>
-      </developer>
-      <developer>
-        <name>Noel Bergman</name>
-        <id>noeljb</id>
-        <email>noeljb at apache.org</email>
-        <roles>
-          <role>Mentor</role>
-          <role>Advisor</role>
-          <role>Sponsor</role>
-        </roles>
-      </developer>
-      <developer>
-        <name>Stephen McConnell</name>
-        <id>mcconnell</id>
-        <email>mcconnell at apache.org</email>
-        <roles>
-          <role>Mentor</role>
-          <role>Sponsor</role>
-          <role>Advisor</role>
-        </roles>
-      </developer>
-    </developers>
-
-    <licenses>
-      <license>
-        <name>Apache 1.1 License</name>
-        <url>
-http://cvs.apache.org/viewcvs.cgi/incubator/directory/LICENSE.txt?rev=1369&amp;root=Apache-SVN&amp;view=markup
-        </url>
-        <distribution>repo</distribution>
-      </license>
-    </licenses>
-
-    <dependencies>
-      <dependency>
-        <groupId>junit</groupId>
-        <artifactId>junit</artifactId>
-        <version>3.8.1</version>
-        <url>http://junit.org</url>
-      </dependency>
-    </dependencies>        
-  
-    <build>
-      <nagEmailAddress>directory-dev@incubator.apache.org</nagEmailAddress>
-      <sourceDirectory>${basedir}/src/java</sourceDirectory>
-      <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
-      <integrationUnitTestSourceDirectory/>
-      <aspectSourceDirectory/>
-
-      <unitTest>
-        <includes>
-          <include>**/*Test*</include>
-          <include>**/*TestCase*</include>
-        </includes>
-              
-        <excludes>
-            <exclude></exclude>
-        </excludes>
-        
-        <resources>
-          <resource>
-            <directory>${basedir}/src/test</directory>
-            <includes> 
-              <include>**/*.dtd</include>
-              <include>**/*.ldif</include>
-              <include>**/*.properties</include>
-              <include>**/*.x*</include>
-              <include>**/*.mf</include>
-              <include>**/*.jar</include>
-            </includes>
-          </resource>
-
-          <resource>
-            <directory>${basedir}/src/test</directory>
-            <includes> 
-              <include>**/*.dtd</include>
-              <include>**/*.ldif</include>
-              <include>**/*.properties</include>
-              <include>**/*.x*</include>
-              <include>**/*.mf</include>
-              <include>**/*.jar</include>
-            </includes>
-          </resource>
-        </resources>
-      </unitTest>
-    
-      <resources>
-        <resource>
-          <directory>${basedir}/src/java</directory>
-          <includes>
-            <include>**/*.dtd</include>
-            <include>**/*.properties</include>
-            <include>**/*.x*</include>
-          </includes>
-        </resource>
-              
-        <resource>
-          <directory>${basedir}/conf</directory>
-          <targetPath>BLOCK-INF</targetPath>
-          <includes>
-            <include>block.xml</include>
-          </includes>
-        </resource>
-      </resources>
-      <jars></jars>
-    </build>
-    
-    <reports>
-    	<report>maven-jxr-plugin</report>
-    	<report>maven-license-plugin</report>
-        <!-- report>maven-changelog-plugin</report -->
-        <report>maven-javadoc-plugin</report>
-        <report>maven-clover-plugin</report>
-    	<report>maven-tasklist-plugin</report>
-    </reports>
-</project>
-
-
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<project>
+    <groupId>directory</groupId>
+    <id>snickers</id>
+    <name>Snickers ASN.1 Tools</name>
+    <package>org.apache.snickers</package>
+
+    <inceptionYear>2003</inceptionYear>
+    <url>http://directory.apache.org/snickers</url>
+    <issueTrackingUrl>
+      http://nagoya.apache.org/scarab/servlet/scarab
+    </issueTrackingUrl>
+    <siteAddress>directory.apache.org</siteAddress>
+    <siteDirectory>/home/akarasulu/public_html</siteDirectory>
+    <distributionDirectory>
+      /home/akarasulu/public_html/dist
+    </distributionDirectory>
+
+    <repository>
+      <connection>
+          scm:svn:http://cvs.apache.org/repos/asf/incubator/directory/snickers/trunk
+      </connection>
+
+      <url>
+        http://cvs.apache.org/viewcvs.cgi/incubator/directory/snickers/trunk?root=Apache-SVN
+      </url>
+      
+      <developerConnection>
+        http://cvs.apache.org/repos/asf/incubator/directory/snickers/trunk
+      </developerConnection>
+    </repository>
+  
+    <shortDescription>Snickers ASN.1 Tools</shortDescription>
+      
+    <description>
+      The snickers subproject attempts to isolate the ASN.1 tools used to
+      build Basic Encoding Rule (BER) codecs for any ASN.1 based network
+      protocol.  The LDAP and X.500 aspects of the directory project impose
+      the need for ASN.1 tools and BER codecs.  Rather than implement highly
+      specific and britle code for these needs we decided to separate out
+      the APIs and implementations used for dealing with BER codecs for any
+      ASN.1 defined protocol.
+    </description>
+
+    <mailingLists>
+      <mailingList>
+        <name>Apache Directory Developement - use [snickers] prefix</name>
+          <subscribe>
+            directory-dev-subscribe@incubator.apache.org
+          </subscribe>
+          <unsubscribe>
+            directory-dev-unsubscribe@incubator.apache.org
+          </unsubscribe>
+          <archive>
+            http://nagoya.apache.org/eyebrowse/SummarizeList?listId=181
+          </archive>
+        </mailingList>
+    </mailingLists>
+    
+    <developers>
+      <developer>
+        <name>Alex Karasulu</name>
+        <id>akarasulu</id>
+        <email>akarasulu at apache.org</email>
+        <roles>
+          <role>Founder</role>
+          <role>Developer</role>
+          <role>Architect</role>
+          <role>Lead Developer</role>
+        </roles>
+      </developer>
+      <developer>
+        <name>Robb Penoyer</name>
+        <id>rpenoyer</id>
+        <email>rpenoyer at apache.org</email>
+        <roles>
+          <role>Developer</role>
+        </roles>
+      </developer>
+      <developer>
+        <name>Jeff Machols</name>
+        <id>jmachols</id>
+        <email>jmachols at apache.org</email>
+        <roles>
+          <role>Developer</role>
+          <role>Infrastructure Support</role>
+        </roles>
+      </developer>
+      <developer>
+        <name>Wes McKean</name>
+        <id>wesmckean</id>
+        <email>wesmckean at apache.org</email>
+        <roles>
+          <role>Developer</role>
+        </roles>
+      </developer>
+      <developer>
+        <name>Noel Bergman</name>
+        <id>noeljb</id>
+        <email>noeljb at apache.org</email>
+        <roles>
+          <role>Mentor</role>
+          <role>Advisor</role>
+          <role>Sponsor</role>
+        </roles>
+      </developer>
+      <developer>
+        <name>Stephen McConnell</name>
+        <id>mcconnell</id>
+        <email>mcconnell at apache.org</email>
+        <roles>
+          <role>Mentor</role>
+          <role>Sponsor</role>
+          <role>Advisor</role>
+        </roles>
+      </developer>
+    </developers>
+
+    <licenses>
+      <license>
+        <name>Apache 1.1 License</name>
+        <url>
+http://cvs.apache.org/viewcvs.cgi/incubator/directory/LICENSE.txt?rev=1369&amp;root=Apache-SVN&amp;view=markup
+        </url>
+        <distribution>repo</distribution>
+      </license>
+    </licenses>
+
+    <dependencies>
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>3.8.1</version>
+        <url>http://junit.org</url>
+      </dependency>
+    </dependencies>        
+  
+    <build>
+      <nagEmailAddress>directory-dev@incubator.apache.org</nagEmailAddress>
+      <sourceDirectory>${basedir}/src/java</sourceDirectory>
+      <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
+      <integrationUnitTestSourceDirectory/>
+      <aspectSourceDirectory/>
+
+      <unitTest>
+        <includes>
+          <include>**/*Test*</include>
+          <include>**/*TestCase*</include>
+        </includes>
+              
+        <excludes>
+            <exclude></exclude>
+        </excludes>
+        
+        <resources>
+          <resource>
+            <directory>${basedir}/src/test</directory>
+            <includes> 
+              <include>**/*.dtd</include>
+              <include>**/*.ldif</include>
+              <include>**/*.properties</include>
+              <include>**/*.x*</include>
+              <include>**/*.mf</include>
+              <include>**/*.jar</include>
+            </includes>
+          </resource>
+
+          <resource>
+            <directory>${basedir}/src/test</directory>
+            <includes> 
+              <include>**/*.dtd</include>
+              <include>**/*.ldif</include>
+              <include>**/*.properties</include>
+              <include>**/*.x*</include>
+              <include>**/*.mf</include>
+              <include>**/*.jar</include>
+            </includes>
+          </resource>
+        </resources>
+      </unitTest>
+    
+      <resources>
+        <resource>
+          <directory>${basedir}/src/java</directory>
+          <includes>
+            <include>**/*.dtd</include>
+            <include>**/*.properties</include>
+            <include>**/*.x*</include>
+          </includes>
+        </resource>
+              
+        <resource>
+          <directory>${basedir}/conf</directory>
+          <targetPath>BLOCK-INF</targetPath>
+          <includes>
+            <include>block.xml</include>
+          </includes>
+        </resource>
+      </resources>
+      <jars></jars>
+    </build>
+    
+    <reports>
+    	<report>maven-jxr-plugin</report>
+    	<report>maven-license-plugin</report>
+        <!-- report>maven-changelog-plugin</report -->
+        <report>maven-javadoc-plugin</report>
+        <report>maven-clover-plugin</report>
+    	<report>maven-tasklist-plugin</report>
+    </reports>
+</project>
+
+

Mime
View raw message