directory-commits mailing list archives

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

Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
Log:
added check to see if type is primitive or not

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
Fri Mar 26 19:59:11 2004
@@ -277,6 +277,123 @@
      * @param octet the first octet of the TLV
      * @return the valued enum for the ASN.1 UNIVERSAL type tag
      */
+    public static boolean isPrimitive( int value )
+    {
+        boolean isPrimitive = false ;
+        
+        switch ( value )
+        {
+            case( RESERVED0_VAL ):
+                isPrimitive = false ;
+                break ;
+            case( BOOLEAN_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( INTEGER_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( BIT_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( OCTET_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( NULL_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( OBJECT_IDENTIFIER_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( OBJECT_DESCRIPTOR_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( EXTERNAL_INSTANCE_OF_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( REAL_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( ENUMERATED_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( EMBEDDED_PDV_VAL ):
+                isPrimitive = false ;
+                break ;
+            case( UTF8_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( RELATIVE_OID_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( RESERVED14_VAL ):
+                isPrimitive = false ;
+                break ;
+            case( RESERVED15_VAL ):
+                isPrimitive = false ;
+                break ;
+            case( SEQUENCE_SEQUENCE_OF_VAL ):
+                isPrimitive = false ;
+                break ;
+            case( SET_SET_OF_VAL ):
+                isPrimitive = false ;
+                break ;
+            case( NUMERIC_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( PRINTABLE_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( TELETEX_STRING_T61_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( VIDEOTEX_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( IA5_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( UTC_TIME_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( GENERALIZED_TIME_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( GRAPHIC_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( VISIBLE_STRING_ISO646_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( GENERAL_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( UNIVERSAL_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( CHARACTER_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( BMP_STRING_VAL ):
+                isPrimitive = true ;
+                break ;
+            case( RESERVED31_VAL ):
+                isPrimitive = false ;
+                break ;
+            default:
+                throw new IllegalArgumentException( "Only values between [0-31]"
+                        + " inclusive constitute valid UNIVERSAL Tags" ) ;
+        }
+        
+        return isPrimitive ;
+    }
+
+    
+    /**
+     * Gets the ASN.1 UNIVERSAL type tag's enum using an id value.
+     * 
+     * @param octet the first octet of the TLV
+     * @return the valued enum for the ASN.1 UNIVERSAL type tag
+     */
     public static UniversalTag getUniversalTag( int value )
     {
         UniversalTag type = null ;

Mime
View raw message