directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9770 - incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives
Date Sat, 27 Mar 2004 03:24:39 GMT
Author: akarasulu
Date: Fri Mar 26 19:24:38 2004
New Revision: 9770

Added:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
      - copied, changed from rev 9766, incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/PrimitiveType.java
Removed:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/PrimitiveType.java
Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/   (props
changed)
Log:
Moved and modified the UniversalTag type safe valued enum

Copied: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
(from rev 9766, incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/PrimitiveType.java)
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/PrimitiveType.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
Fri Mar 26 19:24:38 2004
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.snickers.ber.primitives;
+package org.apache.snickers.ber.primitives ;
 
 
 import java.util.Map ;
@@ -25,35 +25,215 @@
 
 
 /**
- * Type safe enum for an ASN.1 primitive types.  This can be take one of the 
- * following values: 
- * <ul>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * <li></li>
- * </ul>
+ * Type safe enum for ASN.1 UNIVERSAL class tags.  These tags can have one of 
+ * the following values:
+ * <p>
+ * <table border=1 cellspacing=1 width=60% >
+ * <tr><th>Id</th><th>Usage</th></tr>
+ * <tr><td>[UNIVERSAL 0]</td>       <td>reserved for BER</td></tr>
+ * <tr><td>[UNIVERSAL 1]</td>       <td>BOOLEAN</td></tr>
+ * <tr><td>[UNIVERSAL 2]</td>       <td>INTEGER</td></tr>
+ * <tr><td>[UNIVERSAL 3]</td>       <td>BIT STRING</td></tr>
+ * <tr><td>[UNIVERSAL 4]</td>       <td>OCTET STRING</td></tr>
+ * <tr><td>[UNIVERSAL 5]</td>       <td>NULL</td></tr>
+ * <tr><td>[UNIVERSAL 6]</td>       <td>OBJECT IDENTIFIER</td></tr>
+ * <tr><td>[UNIVERSAL 7]</td>       <td>ObjectDescriptor</td></tr>
+ * <tr><td>[UNIVERSAL 8]</td>       <td>EXTERNAL, INSTANCE OF</td></tr>
+ * <tr><td>[UNIVERSAL 9]</td>       <td>REAL</td></tr>
+ * <tr><td>[UNIVERSAL 10]</td>      <td>ENUMERATED</td></tr>
+ * <tr><td>[UNIVERSAL 11]</td>      <td>EMBEDDED PDV</td></tr>
+ * <tr><td>[UNIVERSAL 12]</td>      <td>UTF8String</td></tr>
+ * <tr><td>[UNIVERSAL 13]</td>      <td>RELATIVE-OID</td></tr>
+ * <tr><td>[UNIVERSAL 14]</td>      <td>reserved for future use</td></tr>
+ * <tr><td>[UNIVERSAL 15]</td>      <td>reserved for future use</td></tr>
+ * <tr><td>[UNIVERSAL 16]</td>      <td>SEQUENCE, SEQUENCE OF</td></tr>
+ * <tr><td>[UNIVERSAL 17]</td>      <td>SET, SET OF</td></tr>
+ * <tr><td>[UNIVERSAL 18]</td>      <td>NumericString</td></tr>
+ * <tr><td>[UNIVERSAL 19]</td>      <td>PrintableString</td></tr>
+ * <tr><td>[UNIVERSAL 20]</td>      <td>TeletexString, T61String</td></tr>
+ * <tr><td>[UNIVERSAL 21]</td>      <td>VideotexString</td></tr>
+ * <tr><td>[UNIVERSAL 22]</td>      <td>IA5String</td></tr>
+ * <tr><td>[UNIVERSAL 23]</td>      <td>UTCTime</td></tr>
+ * <tr><td>[UNIVERSAL 24]</td>      <td>GeneralizedTime</td></tr>
+ * <tr><td>[UNIVERSAL 25]</td>      <td>GraphicString</td></tr>
+ * <tr><td>[UNIVERSAL 26]</td>      <td>VisibleString, ISO646String</td></tr>
+ * <tr><td>[UNIVERSAL 27]</td>      <td>GeneralString</td></tr>
+ * <tr><td>[UNIVERSAL 28]</td>      <td>UniversalString</td></tr>
+ * <tr><td>[UNIVERSAL 29]</td>      <td>CHARACTER STRING</td></tr>
+ * <tr><td>[UNIVERSAL 30]</td>      <td>BMPString</td></tr>
+ * <tr><td>[UNIVERSAL 31]</td>      <td>reserved for future use</td></tr>
+ * </table> 
  * 
  * @author <a href="mailto:directory-dev@incubator.apache.org">
  * Apache Directory Project</a>
  * @version $Rev: 9747 $
  */
-public class PrimitiveType extends ValuedEnum
+public class UniversalTag extends ValuedEnum
 {
-    /** value for the x type */
-    public static final int x_VAL = 0 ;
-
-    /** enum for the universal type class */
-    public static final PrimitiveType x = 
-        new PrimitiveType( "x", x_VAL ) ;
+    /** value for the tag */
+    public static final int RESERVED0_VAL = 0 ;
+    /** value for the tag */
+    public static final int BOOLEAN_VAL = 1 ;
+    /** value for the tag */
+    public static final int INTEGER_VAL = 2 ;
+    /** value for the tag */
+    public static final int BIT_STRING_VAL = 3 ;
+    /** value for the tag */
+    public static final int OCTET_STRING_VAL = 4 ;
+    /** value for the tag */
+    public static final int NULL_VAL = 5 ;
+    /** value for the tag */
+    public static final int OBJECT_IDENTIFIER_VAL = 6 ;
+    /** value for the tag */
+    public static final int OBJECT_DESCRIPTOR_VAL = 7 ;
+    /** value for the tag */
+    public static final int EXTERNAL_INSTANCE_OF_VAL = 8 ;
+    /** value for the tag */
+    public static final int REAL_VAL = 9 ;
+    /** value for the tag */
+    public static final int ENUMERATED_VAL = 10 ;
+    /** value for the tag */
+    public static final int EMBEDDED_PDV_VAL = 11 ;
+    /** value for the tag */
+    public static final int UTF8_STRING_VAL = 12 ;
+    /** value for the tag */
+    public static final int RELATIVE_OID_VAL = 13 ;
+    /** value for the tag */
+    public static final int RESERVED14_VAL = 14 ;
+    /** value for the tag */
+    public static final int RESERVED15_VAL = 15 ;
+    /** value for the tag */
+    public static final int SEQUENCE_SEQUENCE_OF_VAL = 16 ;
+    /** value for the tag */
+    public static final int SET_SET_OF_VAL = 17 ;
+    /** value for the tag */
+    public static final int NUMERIC_STRING_VAL = 18 ;
+    /** value for the tag */
+    public static final int PRINTABLE_STRING_VAL = 19 ;
+    /** value for the tag */
+    public static final int TELETEX_STRING_T61_STRING_VAL = 20 ;
+    /** value for the tag */
+    public static final int VIDEOTEX_STRING_VAL = 21 ;
+    /** value for the tag */
+    public static final int IA5_STRING_VAL = 22 ;
+    /** value for the tag */
+    public static final int UTC_TIME_VAL = 23 ;
+    /** value for the tag */
+    public static final int GENERALIZED_TIME_VAL = 24 ;
+    /** value for the tag */
+    public static final int GRAPHIC_STRING_VAL = 25 ;
+    /** value for the tag */
+    public static final int VISIBLE_STRING_ISO646_STRING_VAL = 26 ;
+    /** value for the tag */
+    public static final int GENERAL_STRING_VAL = 27 ;
+    /** value for the tag */
+    public static final int UNIVERSAL_STRING_VAL = 28 ;
+    /** value for the tag */
+    public static final int CHARACTER_STRING_VAL = 29 ;
+    /** value for the tag */
+    public static final int BMP_STRING_VAL = 30 ;
+    /** value for the tag */
+    public static final int RESERVED31_VAL = 31 ;
+    /** value for the tag */
+    
+    /** enum for the tag */
+    public static final UniversalTag BOOLEAN = 
+        new UniversalTag( "BOOLEAN", BOOLEAN_VAL ) ;
+    /** enum for the tag */
+    public static final UniversalTag RESERVED0 = 
+        new UniversalTag( "RESERVED0", RESERVED0_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag INTEGER = 
+        new UniversalTag( "INTEGER", INTEGER_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag BIT_STRING = 
+        new UniversalTag( "BIT_STRING", BIT_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag OCTET_STRING = 
+        new UniversalTag( "OCTET_STRING", OCTET_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag NULL = 
+        new UniversalTag( "NULL", NULL_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag OBJECT_IDENTIFIER = 
+        new UniversalTag( "OBJECT_IDENTIFIER", OBJECT_IDENTIFIER_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag OBJECT_DESCRIPTOR = 
+        new UniversalTag( "OBJECT_DESCRIPTOR", OBJECT_DESCRIPTOR_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag EXTERNAL_INSTANCE_OF = 
+        new UniversalTag( "EXTERNAL_INSTANCE_OF", EXTERNAL_INSTANCE_OF_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag REAL = 
+        new UniversalTag( "REAL", REAL_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag ENUMERATED = 
+        new UniversalTag( "ENUMERATED", ENUMERATED_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag EMBEDDED_PDV = 
+        new UniversalTag( "EMBEDDED_PDV", EMBEDDED_PDV_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag UTF8_STRING = 
+        new UniversalTag( "UTF8_STRING", UTF8_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag RELATIVE_OID = 
+        new UniversalTag( "RELATIVE_OID", RELATIVE_OID_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag RESERVED14 = 
+        new UniversalTag( "RESERVED14", RESERVED14_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag RESERVED15 = 
+        new UniversalTag( "RESERVED15", RESERVED15_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag SEQUENCE_SEQUENCE_OF = 
+        new UniversalTag( "SEQUENCE_SEQUENCE_OF", SEQUENCE_SEQUENCE_OF_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag SET_SET_OF = 
+        new UniversalTag( "SET_SET_OF", SET_SET_OF_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag NUMERIC_STRING = 
+        new UniversalTag( "NUMERIC_STRING", NUMERIC_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag PRINTABLE_STRING = 
+        new UniversalTag( "PRINTABLE_STRING", PRINTABLE_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag TELETEX_STRING_T61_STRING = 
+        new UniversalTag( "TELETEX_STRING_T61_STRING", TELETEX_STRING_T61_STRING_VAL ) ;

+    /** enum for the tag */
+    public static final UniversalTag VIDEOTEX_STRING = 
+        new UniversalTag( "VIDEOTEX_STRING", VIDEOTEX_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag IA5_STRING = 
+        new UniversalTag( "IA5_STRING", IA5_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag UTC_TIME = 
+        new UniversalTag( "UTC_TIME", UTC_TIME_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag GENERALIZED_TIME = 
+        new UniversalTag( "GENERALIZED_TIME", GENERALIZED_TIME_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag GRAPHIC_STRING = 
+        new UniversalTag( "GRAPHIC_STRING", GRAPHIC_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag VISIBLE_STRING_ISO646_STRING = 
+        new UniversalTag( "VISIBLE_STRING_ISO646_STRING", 
+            VISIBLE_STRING_ISO646_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag GENERAL_STRING = 
+        new UniversalTag( "GENERAL_STRING", GENERAL_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag UNIVERSAL_STRING = 
+        new UniversalTag( "UNIVERSAL_STRING", UNIVERSAL_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag CHARACTER_STRING = 
+        new UniversalTag( "CHARACTER_STRING", CHARACTER_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag BMP_STRING = 
+        new UniversalTag( "BMP_STRING", BMP_STRING_VAL ) ; 
+    /** enum for the tag */
+    public static final UniversalTag RESERVED31 = 
+        new UniversalTag( "RESERVED31", RESERVED31_VAL ) ; 
+    
     
     /**
      * Private constructor so no other instances can be created other than the
@@ -62,72 +242,142 @@
      * @param name a string name for the enumeration value.
      * @param value the integer value of the enumeration.
      */
-    private PrimitiveType( final String name, final int value )
+    private UniversalTag( final String name, final int value )
     {
         super( name, value ) ;
     }
     
     
     /**
-     * Gets the enumeration type for the primitive type regardless of case.
-     * 
-     * @param primitiveType the primitive type name
-     * @return the PrimitiveType for the name
-     */
-    public static PrimitiveType getTypeClass( String primitiveType )
-    {
-        // check first using == since it will be the predominate use case
-        if ( primitiveType == x.getName() )
-        {
-            return x ;
-        }
-        
-        if ( primitiveType.equalsIgnoreCase( PrimitiveType.x.getName() ) )
-        {
-            return PrimitiveType.x ;
-        }
-        
-        throw new IllegalArgumentException( "Unknown primitive type name"
-            + primitiveType ) ;
-    }
-    
-    
-    /**
-     * Gets a List of the enumerations for ASN.1 primitive types.
+     * Gets a List of the enumerations for ASN.1 UNIVERSAL type tags.
      * 
-     * @return the List of enumerations possible for ASN.1 primitive types
+     * @return the List of enumerations possible for ASN.1 UNIVERSAL type tags
      */
     public static List list()
     {
-        return EnumUtils.getEnumList( PrimitiveType.class ) ;
+        return EnumUtils.getEnumList( UniversalTag.class ) ;
     }
     
     
     /**
-     * Gets the Map of TypeClass objects by name using the TypeClass class.
+     * Gets the Map of UniversalTag objects by name using the UniversalTag 
+     * class.
      * 
-     * @return the Map by name of TypeClass
+     * @return the Map by name of UniversalTag
      */
     public static Map map()
     {
-        return EnumUtils.getEnumMap( PrimitiveType.class ) ;
+        return EnumUtils.getEnumMap( UniversalTag.class ) ;
     }
 
 
     /**
-     * Gets the ASN.1 primitive type's enum using an id value.
+     * Gets the ASN.1 UNIVERSAL type tag's enum using an id value.
      * 
      * @param octet the first octet of the TLV
-     * @return the TypeClass enumeration for the ASN.1 type's class
+     * @return the valued enum for the ASN.1 UNIVERSAL type tag
      */
-    public static PrimitiveType getPrimitiveType( int value )
+    public static UniversalTag getUniversalTag( int value )
     {
-        PrimitiveType type = null ;
+        UniversalTag type = null ;
         
         switch ( value )
         {
-            case( x_VAL ):
-                type = x ;
+            case( RESERVED0_VAL ):
+                type = RESERVED0 ;
+                break ;
+            case( BOOLEAN_VAL ):
+                type = BOOLEAN ;
+                break ;
+            case( INTEGER_VAL ):
+                type = INTEGER ;
+                break ;
+            case( BIT_STRING_VAL ):
+                type = BIT_STRING ;
+                break ;
+            case( OCTET_STRING_VAL ):
+                type = OCTET_STRING ;
+                break ;
+            case( NULL_VAL ):
+                type = NULL ;
+                break ;
+            case( OBJECT_IDENTIFIER_VAL ):
+                type = OBJECT_IDENTIFIER ;
+                break ;
+            case( OBJECT_DESCRIPTOR_VAL ):
+                type = OBJECT_DESCRIPTOR ;
+                break ;
+            case( EXTERNAL_INSTANCE_OF_VAL ):
+                type = EXTERNAL_INSTANCE_OF ;
+                break ;
+            case( REAL_VAL ):
+                type = REAL ;
+                break ;
+            case( ENUMERATED_VAL ):
+                type = ENUMERATED ;
+                break ;
+            case( EMBEDDED_PDV_VAL ):
+                type = EMBEDDED_PDV ;
+                break ;
+            case( UTF8_STRING_VAL ):
+                type = UTF8_STRING ;
+                break ;
+            case( RELATIVE_OID_VAL ):
+                type = RELATIVE_OID ;
+                break ;
+            case( RESERVED14_VAL ):
+                type = RESERVED14 ;
+                break ;
+            case( RESERVED15_VAL ):
+                type = RESERVED15 ;
+                break ;
+            case( SEQUENCE_SEQUENCE_OF_VAL ):
+                type = SEQUENCE_SEQUENCE_OF ;
+                break ;
+            case( SET_SET_OF_VAL ):
+                type = SET_SET_OF ;
+                break ;
+            case( NUMERIC_STRING_VAL ):
+                type = NUMERIC_STRING ;
+                break ;
+            case( PRINTABLE_STRING_VAL ):
+                type = PRINTABLE_STRING ;
+                break ;
+            case( TELETEX_STRING_T61_STRING_VAL ):
+                type = TELETEX_STRING_T61_STRING ;
+                break ;
+            case( VIDEOTEX_STRING_VAL ):
+                type = VIDEOTEX_STRING ;
+                break ;
+            case( IA5_STRING_VAL ):
+                type = IA5_STRING ;
+                break ;
+            case( UTC_TIME_VAL ):
+                type = UTC_TIME ;
+                break ;
+            case( GENERALIZED_TIME_VAL ):
+                type = GENERALIZED_TIME ;
+                break ;
+            case( GRAPHIC_STRING_VAL ):
+                type = GRAPHIC_STRING ;
+                break ;
+            case( VISIBLE_STRING_ISO646_STRING_VAL ):
+                type = VISIBLE_STRING_ISO646_STRING ;
+                break ;
+            case( GENERAL_STRING_VAL ):
+                type = GENERAL_STRING ;
+                break ;
+            case( UNIVERSAL_STRING_VAL ):
+                type = UNIVERSAL_STRING ;
+                break ;
+            case( CHARACTER_STRING_VAL ):
+                type = CHARACTER_STRING ;
+                break ;
+            case( BMP_STRING_VAL ):
+                type = BMP_STRING ;
+                break ;
+            case( RESERVED31_VAL ):
+                type = RESERVED31 ;
                 break ;
         }
         

Mime
View raw message