directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r151131 [1/9] - in incubator/directory/asn1/branches/rewrite/ber: ./ src/java/org/apache/asn1/ber/ src/java/org/apache/asn1/ber/digester/ src/java/org/apache/asn1/ber/digester/rules/ src/java/org/apache/asn1/ber/primitives/ src/java/org/apache/asn1/tuples/ src/java/org/apache/asn1/util/ src/test/org/apache/asn1/ber/ src/test/org/apache/asn1/ber/primitives/
Date Thu, 03 Feb 2005 07:18:53 GMT
Author: akarasulu
Date: Wed Feb  2 23:18:42 2005
New Revision: 151131

URL: http://svn.apache.org/viewcvs?view=rev&rev=151131
Log:
changes ...

 o removed the commons lang dependency for now in a general trend
   to remove all commons dependencies as recommended by (Allan) - 
   this was done by forking whatever we use: eventually we'll trim 
   this down even further because we use so little of this stuff
 o added the new tuple interfaces into a separate tuple package
   for now
 

Added:
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/AbstractTuple.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tag.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tuple.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/ArrayUtils.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/BooleanUtils.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/Enum.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/EnumUtils.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/EqualsBuilder.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/ExceptionUtils.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/HashCodeBuilder.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/Nestable.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/NestableDelegate.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/NestableError.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/NestableException.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/NestableRuntimeException.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/ObjectUtils.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/RandomStringUtils.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/ReflectionToStringBuilder.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/StopWatch.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/StringUtils.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/SystemUtils.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/ToStringBuilder.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/ToStringStyle.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/Validate.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/util/ValuedEnum.java
Modified:
    incubator/directory/asn1/branches/rewrite/ber/project.xml
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoder.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoderState.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/DefaultMutableTupleNode.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagEnum.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/Tuple.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TypeClass.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/TagTree.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ByteAccumulator.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ObjectCreateRule.java
    incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/primitives/UniversalTag.java
    incubator/directory/asn1/branches/rewrite/ber/src/test/org/apache/asn1/ber/AbstractDecoderTestCaseTest.java
    incubator/directory/asn1/branches/rewrite/ber/src/test/org/apache/asn1/ber/BERDecoderTest.java
    incubator/directory/asn1/branches/rewrite/ber/src/test/org/apache/asn1/ber/BEREncoderTest.java
    incubator/directory/asn1/branches/rewrite/ber/src/test/org/apache/asn1/ber/TagTest.java
    incubator/directory/asn1/branches/rewrite/ber/src/test/org/apache/asn1/ber/TupleTest.java
    incubator/directory/asn1/branches/rewrite/ber/src/test/org/apache/asn1/ber/TupleTreeDecoderTest.java
    incubator/directory/asn1/branches/rewrite/ber/src/test/org/apache/asn1/ber/primitives/PrimitiveUtilsTest.java

Modified: incubator/directory/asn1/branches/rewrite/ber/project.xml
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/project.xml?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/project.xml (original)
+++ incubator/directory/asn1/branches/rewrite/ber/project.xml Wed Feb  2 23:18:42 2005
@@ -17,13 +17,6 @@
       
   <dependencies>
     <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>2.0</version>
-      <url>http://jakarta.apache.org/commons/lang/api</url>
-    </dependency>
-
-    <dependency>
       <groupId>commons-test</groupId>
       <artifactId>commons-test</artifactId>
       <version>0.1</version>

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/AbstractDecoderTestCase.java
Wed Feb  2 23:18:42 2005
@@ -29,15 +29,11 @@
 import org.apache.asn1.codec.stateful.DecoderMonitor ;
 import org.apache.asn1.codec.stateful.DecoderCallback ;
 import org.apache.asn1.codec.stateful.StatefulDecoder;
-import org.apache.asn1.codec.stateful.StatefulDecoder ;
-
-import org.apache.commons.lang.exception.ExceptionUtils ;
+import org.apache.asn1.util.ExceptionUtils;
 
 import org.apache.ldap.common.message.Message ;
 import org.apache.ldap.common.message.MessageEncoder;
 import org.apache.ldap.common.message.spi.Provider;
-import org.apache.asn1.codec.binary.BinaryCodec;
-import org.apache.asn1.codec.DecoderException;
 
 import junit.framework.TestCase ;
 

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoder.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoder.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoder.java
Wed Feb  2 23:18:42 2005
@@ -21,13 +21,12 @@
 
 import java.nio.ByteBuffer ;
 
-import org.apache.commons.lang.ArrayUtils ;
-
 import org.apache.asn1.codec.DecoderException ;
 import org.apache.asn1.codec.stateful.StatefulDecoder ;
 import org.apache.asn1.codec.stateful.DecoderCallback;
 import org.apache.asn1.codec.stateful.DecoderMonitor;
 import org.apache.asn1.codec.stateful.*;
+import org.apache.asn1.util.ArrayUtils;
 
 
 /**

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoderState.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoderState.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoderState.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/BERDecoderState.java
Wed Feb  2 23:18:42 2005
@@ -20,8 +20,8 @@
 import java.util.Map ;
 import java.util.List ;
 
-import org.apache.commons.lang.enum.EnumUtils ;
-import org.apache.commons.lang.enum.ValuedEnum ;
+import org.apache.asn1.util.ValuedEnum;
+import org.apache.asn1.util.EnumUtils;
 
 
 /**

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/DefaultMutableTupleNode.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/DefaultMutableTupleNode.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/DefaultMutableTupleNode.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/DefaultMutableTupleNode.java
Wed Feb  2 23:18:42 2005
@@ -24,8 +24,8 @@
 import java.util.ArrayList ;
 import java.util.Collections ;
 
-import org.apache.commons.lang.StringUtils ;
 import org.apache.asn1.codec.binary.Hex;
+import org.apache.asn1.util.StringUtils;
 
 
 /**
@@ -408,6 +408,7 @@
     public void printDepthFirst( StringBuffer buf, int level )
     {
         DefaultMutableTupleNode child = null ;
+
         String levelTab = StringUtils.repeat( "\t", level ) ;
         
         if ( level != 0 )
@@ -416,18 +417,27 @@
         }
         
         buf.append( levelTab ).append( tuple.getId() ) ;
+
         buf.append( " [" ).append( "0x" ) ;
+
         buf.append( getHex( tuple.getRawPrimitiveTag() ) ) ;
+
         buf.append( ']' ) ;
+
         buf.append( '[' ).append( tuple.length ).append( ']' ) ;
+
         for ( int ii = 0; ii < children.size(); ii++ )
         {
             child = ( DefaultMutableTupleNode ) children.get( ii ) ;
+
             child.printDepthFirst( buf, level + 1 ) ;
         }
     }
-    
-    
+
+
+
+
+
     // ------------------------------------------------------------------------
     // java.lang.Object overrides & overloads 
     // ------------------------------------------------------------------------

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagEnum.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagEnum.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagEnum.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagEnum.java
Wed Feb  2 23:18:42 2005
@@ -17,7 +17,7 @@
 package org.apache.asn1.ber ;
 
 
-import org.apache.commons.lang.enum.ValuedEnum ;
+import org.apache.asn1.util.ValuedEnum;
 
 
 /**

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TagOctetCollector.java
Wed Feb  2 23:18:42 2005
@@ -19,7 +19,7 @@
 
 import java.nio.BufferOverflowException;
 
-import org.apache.commons.lang.ArrayUtils ;
+import org.apache.asn1.util.ArrayUtils;
 
 
 /**

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/Tuple.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/Tuple.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/Tuple.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/Tuple.java
Wed Feb  2 23:18:42 2005
@@ -21,10 +21,7 @@
 
 import java.nio.ByteBuffer ;
 
-import org.apache.commons.lang.ArrayUtils ;
-import org.apache.asn1.ber.Length;
-import org.apache.asn1.ber.Tag;
-import org.apache.asn1.ber.TagEnum;
+import org.apache.asn1.util.ArrayUtils;
 
 
 /**

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TypeClass.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TypeClass.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TypeClass.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/TypeClass.java
Wed Feb  2 23:18:42 2005
@@ -20,8 +20,8 @@
 import java.util.Map ;
 import java.util.List ;
 
-import org.apache.commons.lang.enum.EnumUtils ;
-import org.apache.commons.lang.enum.ValuedEnum ;
+import org.apache.asn1.util.ValuedEnum;
+import org.apache.asn1.util.EnumUtils;
 
 
 /**

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/TagTree.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/TagTree.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/TagTree.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/TagTree.java
Wed Feb  2 23:18:42 2005
@@ -19,11 +19,9 @@
 
 import java.util.*;
 
-import org.apache.commons.lang.Validate ;
 import org.apache.commons.collections.primitives.IntStack ;
-import org.apache.asn1.ber.digester.Rule;
-import org.apache.asn1.ber.digester.RuleRegistration;
-import org.apache.asn1.ber.digester.TagNode;
+
+import org.apache.asn1.util.Validate;
 
 
 /**

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ByteAccumulator.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ByteAccumulator.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ByteAccumulator.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ByteAccumulator.java
Wed Feb  2 23:18:42 2005
@@ -17,7 +17,7 @@
 package org.apache.asn1.ber.digester.rules ;
 
 
-import org.apache.commons.lang.ArrayUtils ;
+import org.apache.asn1.util.ArrayUtils;
 
 import java.nio.ByteBuffer ;
 

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ObjectCreateRule.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ObjectCreateRule.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ObjectCreateRule.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/digester/rules/ObjectCreateRule.java
Wed Feb  2 23:18:42 2005
@@ -20,9 +20,7 @@
 import org.apache.asn1.ber.TypeClass ;
 import org.apache.asn1.ber.digester.BERDigester ;
 import org.apache.asn1.ber.digester.AbstractRule ;
-import org.apache.commons.lang.exception.NestableRuntimeException ;
-import org.apache.asn1.ber.digester.AbstractRule;
-import org.apache.asn1.ber.TypeClass;
+import org.apache.asn1.util.NestableRuntimeException;
 
 
 /**

Modified: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/primitives/UniversalTag.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/primitives/UniversalTag.java?view=diff&r1=151130&r2=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/primitives/UniversalTag.java
(original)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/ber/primitives/UniversalTag.java
Wed Feb  2 23:18:42 2005
@@ -20,9 +20,8 @@
 import java.util.Map ;
 import java.util.List ;
 
-import org.apache.commons.lang.enum.EnumUtils ;
-
 import org.apache.asn1.ber.TagEnum ;
+import org.apache.asn1.util.EnumUtils;
 
 
 /**

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/AbstractTuple.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/AbstractTuple.java?view=auto&rev=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/AbstractTuple.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/AbstractTuple.java
Wed Feb  2 23:18:42 2005
@@ -0,0 +1,59 @@
+/*
+ *   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.asn1.tuples;
+
+
+/**
+ * An abstract base for a Tag, Length, Value tuple.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public abstract class AbstractTuple implements Tuple
+{
+    /** the Tag of this Tuple */
+    private final Tag tag;
+
+    /** the byte index where this tuple begins within its PDU buffer */
+    private final int startIndex;
+
+
+    /**
+     * Sets up the tag and 0-based start index for the Tuple in the PDU.
+     *
+     * @param tag the Tag (type) of this Tuple
+     * @param startIndex the 0-based start index for the Tuple in the PDU
+     */
+    public AbstractTuple( Tag tag, int startIndex )
+    {
+        this.tag = tag;
+
+        this.startIndex = startIndex;
+    }
+
+
+    public int getTagStartIndex()
+    {
+        return this.startIndex;
+    }
+
+
+    public Tag getTag()
+    {
+        return this.tag;
+    }
+}

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tag.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tag.java?view=auto&rev=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tag.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tag.java
Wed Feb  2 23:18:42 2005
@@ -0,0 +1,98 @@
+/*
+ *   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.asn1.tuples ;
+
+
+import org.apache.asn1.ber.TypeClass;
+
+import org.apache.asn1.util.ValuedEnum;
+
+
+/**
+ * Abstract base class for type safe tag enumerations following the agreed upon
+ * convention for representing tags as integers.  This way the type safe
+ * enumeration also represents a preconstructed tag.  ASN.1 application module
+ * specific enumerations should extend this base for use with the digester.
+ *
+ * @see <a href="">link to a document explaining how we encoded prefab tags</a>
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev: 123524 $
+ */
+public abstract class Tag extends ValuedEnum
+{
+    /** the id for this tag */
+    private final int id;
+
+
+    /**
+     * Creates a type safe Tag.
+     *
+     * @param name the name associated with the tag
+     * @param value the value of the tag as a 4 byte primitive int
+     * @param id the id of the tag
+     */
+    protected Tag( final String name, final int value, final int id )
+    {
+        super( name, value ) ;
+
+        this.id = id ;
+    }
+
+
+    /**
+     * Gets the id of this tag.
+     *
+     * @return the id of the tag
+     */
+    public final int getTagId()
+    {
+        return this.id ;
+    }
+
+
+    /**
+     * Gets the primitive version of a tag.
+     *
+     * @return the primitive version of a tag with the P/C bit set to 0
+     */
+    public final int getPrimitiveTag()
+    {
+        return getValue() & 0xDFFFFFFF ;
+    }
+
+
+    /**
+     * Gets the constructed version of a tag.
+     *
+     * @return the constructed version of a tag with the P/C bit set to 1
+     */
+    public final int getConstructedTag()
+    {
+        return getValue() | 0x20000000 ;
+    }
+
+
+    /**
+     * Gets the type class of a tag.
+     *
+     * @return the type class for this tag enumeration.
+     */
+    public final TypeClass getTypeClass()
+    {
+        return TypeClass.getTypeClass( getValue() >> 24 ) ;
+    }
+}

Added: incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tuple.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tuple.java?view=auto&rev=151131
==============================================================================
--- incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tuple.java
(added)
+++ incubator/directory/asn1/branches/rewrite/ber/src/java/org/apache/asn1/tuples/Tuple.java
Wed Feb  2 23:18:42 2005
@@ -0,0 +1,49 @@
+/*
+ *   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.asn1.tuples;
+
+
+/**
+ * A minimal interface for a Tag, Length, Value tuple used for various
+ * encodings.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface Tuple
+{
+    /**
+     * Gets the zero based index into a PDU where the first byte of this Tuple's tag resides.
+     *
+     * @return zero based index of Tag's first byte in the PDU
+     */
+    int getTagStartIndex();
+
+    /**
+     * Gets this TLV Tuple's Tag (T) as a type safe enumeration.
+     *
+     * @return type safe enumeration for the Tag
+     */
+    Tag getTag();
+
+    /**
+     * Gets whether or not this Tuple is constructed.
+     *
+     * @return true if the Tag is constructed false if it is primitive.
+     */
+    boolean isConstructed();
+}



Mime
View raw message