OSDN Git Service

* Add constructor with a String to INTEGER classes (INTEGER, ENUMERATED, BigINTEGER...
authorjwat <jwat@users.sourceforge.jp>
Mon, 19 Nov 2012 05:27:47 +0000 (14:27 +0900)
committerjwat <jwat@users.sourceforge.jp>
Mon, 19 Nov 2012 05:27:47 +0000 (14:27 +0900)
12 files changed:
jp/bitmeister/asn1/pojo/PojoDecoder.java
jp/bitmeister/asn1/pojo/PojoEncoder.java
jp/bitmeister/asn1/pojo/annotation/ASN1JavaField.java
jp/bitmeister/asn1/sample/FrightStatusMain.java
jp/bitmeister/asn1/type/ASN1Module.java
jp/bitmeister/asn1/type/ASN1ModuleManager.java
jp/bitmeister/asn1/type/AbstractInteger.java
jp/bitmeister/asn1/type/ModuleSpecification.java
jp/bitmeister/asn1/type/builtin/BigENUMERATED.java
jp/bitmeister/asn1/type/builtin/BigINTEGER.java
jp/bitmeister/asn1/type/builtin/ENUMERATED.java
jp/bitmeister/asn1/type/builtin/INTEGER.java

index 3b62b0a..c3052e0 100644 (file)
@@ -54,7 +54,6 @@ import jp.bitmeister.asn1.type.builtin.SEQUENCE;
 import jp.bitmeister.asn1.type.builtin.SEQUENCE_OF;
 import jp.bitmeister.asn1.type.builtin.SET;
 import jp.bitmeister.asn1.type.builtin.SET_OF;
-import jp.bitmeister.asn1.value.HexString;
 
 /**
  * POJO to ASN.1 data decoder.
@@ -324,7 +323,7 @@ public class PojoDecoder implements ASN1Decoder {
                         * asn1.type.builtin.BIT_STRING)
                         */
                        public Void visit(BIT_STRING data) throws IllegalAccessException {
-                               data.set(new HexString((byte[]) element));
+                               data.set((boolean[]) element);
                                return null;
                        }
 
index e288312..f906bcd 100644 (file)
@@ -53,7 +53,6 @@ import jp.bitmeister.asn1.type.builtin.SEQUENCE;
 import jp.bitmeister.asn1.type.builtin.SEQUENCE_OF;
 import jp.bitmeister.asn1.type.builtin.SET;
 import jp.bitmeister.asn1.type.builtin.SET_OF;
-import jp.bitmeister.asn1.value.BinString;
 
 /**
  * ASN.1 to POJO data encoder.
@@ -298,7 +297,7 @@ public class PojoEncoder implements ASN1Encoder {
                         * asn1.type.builtin.BIT_STRING)
                         */
                        public Object visit(BIT_STRING data) throws Exception {
-                               return new BinString(data.value()).toByteArray();
+                               return data.value();
                        }
 
                        /*
@@ -309,9 +308,7 @@ public class PojoEncoder implements ASN1Encoder {
                         * asn1.type.builtin.OCTET_STRING)
                         */
                        public Object visit(OCTET_STRING data) throws Exception {
-                               byte[] value = new byte[data.size()];
-                               System.arraycopy(data.value(), 0, value, 0, value.length);
-                               return value;
+                               return data.value();
                        }
 
                        /*
index c27f6fa..9272cc1 100644 (file)
@@ -26,10 +26,10 @@ import java.lang.annotation.Target;
  * 
  * <p>
  * A field that annotated as {@code @ASN1JavaField} will be translated to a
- * particular element of corresponding ASN.1 type indicated by value parameter.
- * {@code @ASN1JavaField} field must be contained in a class that annotated as
- * {@code @ASN1JavaObject}. An {@code @ASN1JavaField} field must be a public,
- * non-static and non-final field.
+ * particular element of corresponding ASN.1 type indicated by the value
+ * parameter. {@code @ASN1JavaField} field must be contained in a class that
+ * annotated as {@code @ASN1JavaObject}. An {@code @ASN1JavaField} field must be
+ * a public, non-static and non-final field.
  * </p>
  * 
  * <p>
@@ -56,7 +56,7 @@ import java.lang.annotation.Target;
  * </tr>
  * <tr>
  * <td>BIT_STRING</td>
- * <td>byte[]</td>
+ * <td>boolean[]</td>
  * </tr>
  * <tr>
  * <td>OCTET_STRING</td>
index 1026b7e..8c29d8b 100644 (file)
@@ -38,7 +38,6 @@ import jp.bitmeister.asn1.value.HexString;
 public class FrightStatusMain {
 
        public static void main(String[] args) {
-               
                AllFrights frights = new AllFrights(
                                new FrightStatus(
                                                new FrightNumber("JP041"),
index b9d353d..72603e4 100644 (file)
@@ -43,7 +43,7 @@ import jp.bitmeister.asn1.annotation.ASN1ModuleTags;
  * @see ASN1ModuleRef
  */
 public abstract class ASN1Module {
-
+       
        /**
         * Returns the default tagging mode of the ASN.1 module.
         * 
@@ -126,5 +126,5 @@ public abstract class ASN1Module {
                        }
                }
        }
-       
+               
 }
index 16565fd..1701bf9 100644 (file)
@@ -87,7 +87,7 @@ public class ASN1ModuleManager {
         *            The {@code Class} object of an {@code ASN1Module}.
         * @return A {@code ModuleSpecification} instance.
         */
-       static ModuleSpecification specification(Class<? extends ASN1Module> module) {
+       public static ModuleSpecification specification(Class<? extends ASN1Module> module) {
                if (module == null) {
                        module = BuiltInModule.class;
                }
@@ -120,7 +120,7 @@ public class ASN1ModuleManager {
        public static String identifier(Class<? extends ASN1Module> module) {
                return specification(module).identifier();
        }
-
+       
        private Map<Class<? extends ASN1Module>, ModuleSpecification> definedModules = new HashMap<Class<? extends ASN1Module>, ModuleSpecification>();
 
        /**
index 6c79a87..a3632d4 100644 (file)
@@ -87,7 +87,7 @@ public abstract class AbstractInteger<T extends Number & Comparable<T>> extends
                }
                super.set(value);
        }
-
+       
        /**
         * Returns an identifier related to the value of this data if the type has
         * {@code @ASN1Enumeration} fields.
index 7d66523..daca30b 100644 (file)
@@ -70,6 +70,24 @@ class ModuleSpecification {
        }
 
        /**
+        * Returns identifier of this module.
+        * 
+        * @return Identifier.
+        */
+       String identifier() {
+               return identifier;
+       }
+
+       /**
+        * Returns default tag mode of this module.
+        * 
+        * @return Default tag mode.
+        */
+       ASN1TagDefault tagDefault() {
+               return tagDefault;
+       }
+
+       /**
         * Registers an imported module to this module.
         * 
         * @param module
@@ -128,24 +146,6 @@ class ModuleSpecification {
        }
 
        /**
-        * Returns identifier of this module.
-        * 
-        * @return Identifier.
-        */
-       String identifier() {
-               return identifier;
-       }
-
-       /**
-        * Returns default tag mode of this module.
-        * 
-        * @return Default tag mode.
-        */
-       ASN1TagDefault tagDefault() {
-               return tagDefault;
-       }
-
-       /**
         * Instantiates an ASN.1 data specified by the tag.
         * 
         * @param tagClass
index 805e202..b2dada4 100644 (file)
@@ -72,6 +72,17 @@ public abstract class BigENUMERATED extends BigINTEGER {
        public BigENUMERATED(long value) {
                super(value);
        }
+       
+       /**
+        * Instantiates an {@code BigENUMERATED} and initialize it with the value that is
+        * specified by the identifier of namednumber.
+        * 
+        * @param identifier
+        *            Identifier of the number to be assigned.
+        */
+       public BigENUMERATED(String identifier) {
+               set(identifier);
+       }
 
        /*
         * (non-Javadoc)
index 31c5eaa..d5bb087 100644 (file)
@@ -92,13 +92,13 @@ public class BigINTEGER extends AbstractInteger<BigInteger> {
        }
 
        /**
-        * Instantiates an empty {@code INTEGER}.
+        * Instantiates an empty {@code BigINTEGER}.
         */
        public BigINTEGER() {
        }
 
        /**
-        * Instantiates an {@code INTEGER} and initialize it with the
+        * Instantiates an {@code BigINTEGER} and initialize it with the
         * {@code BigInteger} value.
         * 
         * @param value
@@ -109,7 +109,7 @@ public class BigINTEGER extends AbstractInteger<BigInteger> {
        }
 
        /**
-        * Instantiates an {@code INTEGER} and initialize it with the {@code long}
+        * Instantiates an {@code BigINTEGER} and initialize it with the {@code long}
         * value.
         * 
         * @param value
@@ -118,6 +118,17 @@ public class BigINTEGER extends AbstractInteger<BigInteger> {
        public BigINTEGER(long value) {
                set(value);
        }
+       
+       /**
+        * Instantiates an {@code BigINTEGER} and initialize it with the value that is
+        * specified by the identifier of namednumber.
+        * 
+        * @param identifier
+        *            Identifier of the number to be assigned.
+        */
+       public BigINTEGER(String identifier) {
+               set(identifier);
+       }
 
        /**
         * Sets the {@code long} value to this data.
index 486d922..37ab82c 100644 (file)
@@ -59,6 +59,17 @@ public abstract class ENUMERATED extends INTEGER {
        public ENUMERATED(long value) {
                super(value);
        }
+       
+       /**
+        * Instantiates an {@code ENUMERATED} and initialize it with the value that is
+        * specified by the identifier of namednumber.
+        * 
+        * @param identifier
+        *            Identifier of the number to be assigned.
+        */
+       public ENUMERATED(String identifier) {
+               super(identifier);
+       }
 
        /*
         * (non-Javadoc)
index 752fc0d..b4e4b2c 100644 (file)
@@ -80,6 +80,17 @@ public class INTEGER extends AbstractInteger<Long> {
        }
        
        /**
+        * Instantiates an {@code INTEGER} and initialize it with the value that is
+        * specified by the identifier of namednumber.
+        * 
+        * @param identifier
+        *            Identifier of the number to be assigned.
+        */
+       public INTEGER(String identifier) {
+               set(identifier);
+       }
+       
+       /**
         * Sets the int value to this data.
         * 
         * @param value