directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10079 - incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules
Date Sun, 18 Apr 2004 04:53:51 GMT
Author: akarasulu
Date: Sat Apr 17 21:53:51 2004
New Revision: 10079

Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveIntDecodeRule.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRule.java
Log:
Commit changes ...

o Set up the int decoder rule to follow same mechanism of octet rule where it
  allows for easy subclassing.  Basically this translated to the introduction
  of a new tag member.
o Set constructors that are used by subclasses exclusively to protected.



Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveIntDecodeRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveIntDecodeRule.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveIntDecodeRule.java
Sat Apr 17 21:53:51 2004
@@ -18,6 +18,7 @@
 
 
 import org.apache.snickers.ber.TypeClass ;
+import org.apache.snickers.ber.TagEnum;
 import org.apache.snickers.ber.digester.AbstractRule ;
 import org.apache.snickers.ber.primitives.UniversalTag ;
 import org.apache.snickers.ber.primitives.PrimitiveUtils ;
@@ -52,26 +53,58 @@
     private int pos ;
     /** the number of bytes we must read */
     private int length ;
+    /** the tag this rule accepts */
+    private final TagEnum tag ;
+
+
+    // -----------------------------------------------------------------------
+    // C O N S T R U C T O R S
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Creates a default primitive integer decoding rule that only accepts
+     * tags of UniversalTag.INTEGER.
+     */
+    public PrimitiveIntDecodeRule()
+    {
+        tag = UniversalTag.INTEGER ;
+    }
+
+
+    /**
+     * Creates a default primitive integer decoding rule that only accepts
+     * tags of UniversalTag.INTEGER.
+     */
+    protected PrimitiveIntDecodeRule( TagEnum tag )
+    {
+        this.tag = tag ;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Rule Implementation
+    // -----------------------------------------------------------------------
 
 
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.Rule#tag(int, boolean,
+     * @see org.apache.snickers.ber.digester.Rule#tag(int, boolean,
      * org.apache.snickers.ber.TypeClass)
      */
     public void tag( int id, boolean isPrimitive, TypeClass typeClass )
     {
-        if ( id != UniversalTag.INTEGER.getTagId() )
+        if ( id != tag.getTagId() )
         {
             throw new IllegalArgumentException(
-                    "Expecting " + UniversalTag.INTEGER.getName()
-                    + " with an id of " + UniversalTag.INTEGER.getTagId()
+                    "Expecting " + tag.getName()
+                    + " with an id of " + tag.getTagId()
                     + " but instead got a tag id of " + id ) ;
         }
     }
 
 
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.Rule#length(int)
+     * @see org.apache.snickers.ber.digester.Rule#length(int)
      */
     public void length( int length )
     {
@@ -87,7 +120,7 @@
 
 
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     * @see org.apache.snickers.ber.digester.Rule#value(java.nio.ByteBuffer)
      */
     public void value( ByteBuffer buf )
     {
@@ -105,7 +138,7 @@
 
 
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.Rule#finish()
+     * @see org.apache.snickers.ber.digester.Rule#finish()
      */
     public void finish()
     {

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRule.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRule.java
Sat Apr 17 21:53:51 2004
@@ -67,10 +67,9 @@
      * OCTET_STRING fields are tagged with application specific tags.  In
      * this case we match for a different tag.
      *
-     *
      * @param tag the tag to accept
      */
-    public PrimitiveOctetStringRule( TagEnum tag )
+    protected PrimitiveOctetStringRule( TagEnum tag )
     {
         this.tag = tag ;
     }

Mime
View raw message