directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: rev 22811 - in incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding: . ber
Date Sat, 10 Jul 2004 22:23:34 GMT
Author: adc
Date: Sat Jul 10 15:23:33 2004
New Revision: 22811

Added:
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Length.java
      - copied, changed from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Length.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Tag.java
      - copied, changed from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Tag.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Tuple.java
      - copied, changed from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Tuple.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/TupleNode.java
      - copied, changed from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TupleNode.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/TypeClass.java
      - copied, changed from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TypeClass.java
Removed:
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Length.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Tag.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Tuple.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TupleNode.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TypeClass.java
Modified:
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/DecoderCallback.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoder.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoderCallbackAdapter.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoderMonitor.java
   incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TupleStack.java
Log:
Snickers reorg

Modified: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/DecoderCallback.java
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/DecoderCallback.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/DecoderCallback.java
Sat Jul 10 15:23:33 2004
@@ -18,8 +18,6 @@
 
 import java.nio.ByteBuffer;
 
-import org.apache.snickers.encoding.ber.Tuple;
-
 
 /**
  * Callback interface for stateful decoder callbacks.

Copied: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Length.java
(from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Length.java)
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Length.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Length.java
Sat Jul 10 15:23:33 2004
@@ -14,13 +14,11 @@
  *   limitations under the License.
  *
  */
-package org.apache.snickers.encoding.ber;
+package org.apache.snickers.encoding;
 
 
 import java.nio.ByteBuffer;
 
-import org.apache.snickers.encoding.DecoderException;
-
 
 /**
  * The length component of a BER TLV Tuple.
@@ -77,7 +75,7 @@
      * Clears this tag's data of all bytes and values calculated so all is as it
      * was when this instance was created.
      */
-    void clear()
+    public void clear()
     {
         isFixated = false;
         value = 0;
@@ -107,7 +105,7 @@
      * 
      * @param octet the 8 bit byte to add
      */
-    void add( byte octet ) throws DecoderException
+    public void add( byte octet ) throws DecoderException
     {
         if ( isFixated )
         {

Copied: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Tag.java
(from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Tag.java)
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Tag.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Tag.java
Sat Jul 10 15:23:33 2004
@@ -14,12 +14,10 @@
  *   limitations under the License.
  *
  */
-package org.apache.snickers.encoding.ber;
+package org.apache.snickers.encoding;
 
 import java.nio.BufferOverflowException;
 
-import org.apache.snickers.encoding.DecoderException;
-
 
 /**
  * The Tag component of a BER TLV Tuple.
@@ -44,7 +42,7 @@
     /**
      * tag mask for the long tag format - 0111 1111 - 0x7F
      */
-    static final int LONG_MASK = 0x7F;
+    public static final int LONG_MASK = 0x7F;
     /**
      * tag flag indicating the use of the long tag encoding form
      */
@@ -93,7 +91,7 @@
      * Clears this tag's data of all bytes and values calculated so all is as it
      * was when this instance was created.
      */
-    void clear()
+    public void clear()
     {
         id = 0;
         isFixated = false;
@@ -127,7 +125,7 @@
      * 
      * @param octet the 8 bit byte to add
      */
-    void add( byte octet ) throws DecoderException
+    public void add( byte octet ) throws DecoderException
     {
         if ( isFixated )
         {

Copied: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Tuple.java
(from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Tuple.java)
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/Tuple.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/Tuple.java
Sat Jul 10 15:23:33 2004
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.snickers.encoding.ber;
+package org.apache.snickers.encoding;
 
 
 import java.nio.ByteBuffer;
@@ -100,10 +100,17 @@
     /**
      * Empty do nothing tuple.
      */
-    Tuple()
+    public Tuple()
     {
     }
 
+    public Tuple(Tag tag)
+    {
+        rawTag = tag.getRawTag();
+        id = tag.getId();
+        isPrimitive = tag.isPrimitive();
+        typeClass = tag.getTypeClass();
+    }
 
     /**
      * Creates constructed application type tlv tuples.  Constructed TLV's with
@@ -200,6 +207,14 @@
         return id;
     }
 
+    /**
+     * Sets the tag id for this TLV Tuple.
+     * @param id the tag id
+     */
+    public void setId( int id )
+    {
+        this.id = id;
+    }
 
     /**
      * Gets the raw tag as it is stuffed into a primitive int.
@@ -261,6 +276,14 @@
         return isPrimitive;
     }
 
+    /**
+     * Sets whether or not this TLV tuple is primitive or constructed.
+     * @param primitive
+     */
+    public void setPrimitive( boolean primitive )
+    {
+        isPrimitive = primitive;
+    }
 
     /**
      * Gets the value length for this TLV Tuple.
@@ -272,6 +295,15 @@
         return length;
     }
 
+    /**
+     * Sets the value length for this TLV Tuple.
+     *
+     * @param length the length in bytes of the value field for this TLV tuple
+     */
+    public void setLength( int length )
+    {
+        this.length = length;
+    }
 
     /**
      * Gets the BER TLV TypeClass for this TLV Tuple.
@@ -283,6 +315,14 @@
         return typeClass;
     }
 
+    /**
+     * Sets the BER TLV TypeClass for this TLV Tuple.
+     * @param typeClass the BER TLV TypeClass for this TLV Tuple
+     */
+    public void setTypeClass( TypeClass typeClass )
+    {
+        this.typeClass = typeClass;
+    }
 
     /**
      * Gets the total size of this TLV tuple in bytes.  This includes the
@@ -313,6 +353,16 @@
         index += amount;
     }
 
+    public int getIndex()
+    {
+        return index;
+    }
+
+    public void setIndex( int index )
+    {
+        this.index = index;
+    }
+    
     // ------------------------------------------------------------------------
     // Utility methods and java.lang.Object overrides
     // ------------------------------------------------------------------------
@@ -321,7 +371,7 @@
     /**
      * Clears the values of this tuple.
      */
-    void clear()
+    public void clear()
     {
         this.id = 0;
         this.index = 0;
@@ -431,7 +481,7 @@
      * @param octets    the buffer to set the tag in
      * @param tagLength the length of the tag section
      */
-    void setTag( ByteBuffer octets, int tagLength )
+    public void setTag( ByteBuffer octets, int tagLength )
     {
         if ( tagLength >= 6 )
         {
@@ -467,7 +517,7 @@
      * @param octets      the byte [] to set length in
      * @param lengthBytes the number bytes for the length section
      */
-    void setLength( ByteBuffer octets, int lengthBytes )
+    public void setLength( ByteBuffer octets, int lengthBytes )
     {
         if ( length == Length.INDEFINITE )
         {

Copied: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/TupleNode.java
(from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TupleNode.java)
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TupleNode.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/TupleNode.java
Sat Jul 10 15:23:33 2004
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.snickers.encoding.ber;
+package org.apache.snickers.encoding;
 
 
 import java.nio.ByteBuffer;

Copied: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/TypeClass.java
(from rev 22809, incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TypeClass.java)
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TypeClass.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/TypeClass.java
Sat Jul 10 15:23:33 2004
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.snickers.encoding.ber;
+package org.apache.snickers.encoding;
 
 
 import java.util.List;

Modified: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoder.java
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoder.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoder.java
Sat Jul 10 15:23:33 2004
@@ -22,13 +22,16 @@
 import org.apache.snickers.encoding.DecoderCallback;
 import org.apache.snickers.encoding.DecoderException;
 import org.apache.snickers.encoding.DecoderMonitor;
+import org.apache.snickers.encoding.Tuple;
+import org.apache.snickers.encoding.Tag;
+import org.apache.snickers.encoding.Length;
 
 
 /**
  * A decoder that decodes BER encoded bytes to Tag Value Length (TLV) tuples.
  * 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.  The decoder is a state machine which processes
+ * similar to the way SAX works except the elements of concern are the tagBuffer,
+ * lengthBuffer, and value entities.  The decoder is a state machine which processes
  * input as it is made available.
  * <p/>
  * A Stack is used to track the state of the decoder between decode calls.  It
@@ -124,7 +127,6 @@
      *
      * @throws ClassCastException       if the encoded argument is not a ByteBuffer
      * @throws IllegalArgumentException if the encoded is null or empty
-     * @see org.apache.commons.codec.stateful.StatefulDecoder#decode(java.lang.Object)
      */
     public void decode( ByteBuffer encoded ) throws DecoderException
     {
@@ -161,7 +163,7 @@
 
     protected class TagState extends State
     {
-        Tag tag = new Tag();
+        Tag tagBuffer = new Tag();
 
         /**
          * Decodes a peice of encoded data.  The nature of this call, synchronous
@@ -177,20 +179,15 @@
             while ( buf.hasRemaining() )
             {
                 byte octet = buf.get();
-                tag.add( octet );
+                tagBuffer.add( octet );
 
-                if ( tag.isFixated() )
+                if ( tagBuffer.isFixated() )
                 {
-                    tlv = new Tuple();
-
-                    tlv.rawTag = tag.getRawTag();
-                    tlv.id = tag.getId();
-                    tlv.isPrimitive = tag.isPrimitive();
-                    tlv.typeClass = tag.getTypeClass();
+                    tlv = new Tuple(tagBuffer);
 
                     state = LENGTH_STATE;
 
-                    tag.clear();
+                    tagBuffer.clear();
 
                     return;
                 }
@@ -202,7 +199,7 @@
 
     protected class LengthState extends State
     {
-        Length length = new Length();
+        Length lengthBuffer = new Length();
 
         /**
          * Decodes a peice of encoded data.  The nature of this call, synchronous
@@ -219,11 +216,11 @@
             while ( buf.hasRemaining() )
             {
                 byte octet = buf.get();
-                length.add( octet );
+                lengthBuffer.add( octet );
 
-                if ( length.isFixated() )
+                if ( lengthBuffer.isFixated() )
                 {
-                    tlv.length = length.getLength();
+                    tlv.setLength( lengthBuffer.getLength() );
 
                     stack.push( tlv );
 
@@ -236,7 +233,7 @@
                         state = VALUE_STATE;
                     }
 
-                    length.clear();
+                    lengthBuffer.clear();
 
                     return;
                 }

Modified: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoderCallbackAdapter.java
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoderCallbackAdapter.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoderCallbackAdapter.java
Sat Jul 10 15:23:33 2004
@@ -20,6 +20,7 @@
 
 import org.apache.snickers.encoding.Decoder;
 import org.apache.snickers.encoding.DecoderCallback;
+import org.apache.snickers.encoding.Tuple;
 
 
 /**
@@ -32,13 +33,13 @@
 {
     /**
      * Method used to receive notification that a TLV tuple has begun to be
-     * read.  The following tag properties of the TLV tuple are valid at this
+     * read.  The following tagBuffer properties of the TLV tuple are valid at this
      * point:
      * <ul>
      * <li>id</li>
      * <li>isPrimitive</li>
      * <li>typeClass</li>
-     * <li>length</li>
+     * <li>lengthBuffer</li>
      * </ul>
      *
      * @param tlv the TLV tuple

Modified: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoderMonitor.java
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoderMonitor.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/BERDecoderMonitor.java
Sat Jul 10 15:23:33 2004
@@ -18,6 +18,7 @@
 
 
 import org.apache.snickers.encoding.DecoderMonitor;
+import org.apache.snickers.encoding.Tuple;
 
 
 /**
@@ -31,8 +32,8 @@
 public interface BERDecoderMonitor extends DecoderMonitor
 {
     /**
-     * Method used to receive notification that a tag was decoded.  The
-     * following tag properties of the TLV tuple are valid at this point:
+     * Method used to receive notification that a tagBuffer was decoded.  The
+     * following tagBuffer properties of the TLV tuple are valid at this point:
      * <ul>
      * <li>id</li>
      * <li>isPrimitive</li>
@@ -44,13 +45,13 @@
     void tagDecoded( Tuple tlv );
 
     /**
-     * Method used to receive notification that a length was decoded.  The
+     * Method used to receive notification that a lengthBuffer was decoded.  The
      * following properties of the TLV tuple are valid at this point:
      * <ul>
      * <li>id</li>
      * <li>isPrimitive</li>
      * <li>typeClass</li>
-     * <li>length</li>
+     * <li>lengthBuffer</li>
      * </ul>
      *
      * @param tlv the TLV tuple

Modified: incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TupleStack.java
==============================================================================
--- incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TupleStack.java
(original)
+++ incubator/directory/snickers/branches/ber-decoder/modules/runtime/src/java/org/apache/snickers/encoding/ber/TupleStack.java
Sat Jul 10 15:23:33 2004
@@ -22,6 +22,7 @@
 import org.apache.snickers.encoding.DecoderCallback;
 import org.apache.snickers.encoding.DecoderMonitor;
 import org.apache.snickers.encoding.DecoderMonitorAdapter;
+import org.apache.snickers.encoding.Tuple;
 
 
 /**
@@ -124,18 +125,18 @@
      * This TLV will be managed by the stack and events about its condition
      * will be sent by this stack. <p/>
      * <p/>
-     * The following tag properties of the TLV tuple are valid at this
+     * The following tagBuffer properties of the TLV tuple are valid at this
      * point:
      * <ul>
      * <li>id</li>
      * <li>isPrimitive</li>
      * <li>typeClass</li>
-     * <li>length</li>
+     * <li>lengthBuffer</li>
      * </ul>
      *
      * @param tlv
      */
-    void push( Tuple tlv )
+    public void push( Tuple tlv )
     {
 
         if ( tlv.isIndefiniteTerminator() )

Mime
View raw message