Commit MetaInfo

Revision4601f7ee74152abaa6df2bcbb6c4643bc3a59f5e (tree)
Time2012-11-19 14:27:47
Authorjwat <jwat@user...>
Commiterjwat

Log Message

* Add constructor with a String to INTEGER classes (INTEGER, ENUMERATED, BigINTEGER and BigENUMERATED)

Change Summary

Incremental Difference

--- a/jp/bitmeister/asn1/pojo/PojoDecoder.java
+++ b/jp/bitmeister/asn1/pojo/PojoDecoder.java
@@ -54,7 +54,6 @@ import jp.bitmeister.asn1.type.builtin.SEQUENCE;
5454 import jp.bitmeister.asn1.type.builtin.SEQUENCE_OF;
5555 import jp.bitmeister.asn1.type.builtin.SET;
5656 import jp.bitmeister.asn1.type.builtin.SET_OF;
57-import jp.bitmeister.asn1.value.HexString;
5857
5958 /**
6059 * POJO to ASN.1 data decoder.
@@ -324,7 +323,7 @@ public class PojoDecoder implements ASN1Decoder {
324323 * asn1.type.builtin.BIT_STRING)
325324 */
326325 public Void visit(BIT_STRING data) throws IllegalAccessException {
327- data.set(new HexString((byte[]) element));
326+ data.set((boolean[]) element);
328327 return null;
329328 }
330329
--- a/jp/bitmeister/asn1/pojo/PojoEncoder.java
+++ b/jp/bitmeister/asn1/pojo/PojoEncoder.java
@@ -53,7 +53,6 @@ import jp.bitmeister.asn1.type.builtin.SEQUENCE;
5353 import jp.bitmeister.asn1.type.builtin.SEQUENCE_OF;
5454 import jp.bitmeister.asn1.type.builtin.SET;
5555 import jp.bitmeister.asn1.type.builtin.SET_OF;
56-import jp.bitmeister.asn1.value.BinString;
5756
5857 /**
5958 * ASN.1 to POJO data encoder.
@@ -298,7 +297,7 @@ public class PojoEncoder implements ASN1Encoder {
298297 * asn1.type.builtin.BIT_STRING)
299298 */
300299 public Object visit(BIT_STRING data) throws Exception {
301- return new BinString(data.value()).toByteArray();
300+ return data.value();
302301 }
303302
304303 /*
@@ -309,9 +308,7 @@ public class PojoEncoder implements ASN1Encoder {
309308 * asn1.type.builtin.OCTET_STRING)
310309 */
311310 public Object visit(OCTET_STRING data) throws Exception {
312- byte[] value = new byte[data.size()];
313- System.arraycopy(data.value(), 0, value, 0, value.length);
314- return value;
311+ return data.value();
315312 }
316313
317314 /*
--- a/jp/bitmeister/asn1/pojo/annotation/ASN1JavaField.java
+++ b/jp/bitmeister/asn1/pojo/annotation/ASN1JavaField.java
@@ -26,10 +26,10 @@ import java.lang.annotation.Target;
2626 *
2727 * <p>
2828 * A field that annotated as {@code @ASN1JavaField} will be translated to a
29- * particular element of corresponding ASN.1 type indicated by value parameter.
30- * {@code @ASN1JavaField} field must be contained in a class that annotated as
31- * {@code @ASN1JavaObject}. An {@code @ASN1JavaField} field must be a public,
32- * non-static and non-final field.
29+ * particular element of corresponding ASN.1 type indicated by the value
30+ * parameter. {@code @ASN1JavaField} field must be contained in a class that
31+ * annotated as {@code @ASN1JavaObject}. An {@code @ASN1JavaField} field must be
32+ * a public, non-static and non-final field.
3333 * </p>
3434 *
3535 * <p>
@@ -56,7 +56,7 @@ import java.lang.annotation.Target;
5656 * </tr>
5757 * <tr>
5858 * <td>BIT_STRING</td>
59- * <td>byte[]</td>
59+ * <td>boolean[]</td>
6060 * </tr>
6161 * <tr>
6262 * <td>OCTET_STRING</td>
--- a/jp/bitmeister/asn1/sample/FrightStatusMain.java
+++ b/jp/bitmeister/asn1/sample/FrightStatusMain.java
@@ -38,7 +38,6 @@ import jp.bitmeister.asn1.value.HexString;
3838 public class FrightStatusMain {
3939
4040 public static void main(String[] args) {
41-
4241 AllFrights frights = new AllFrights(
4342 new FrightStatus(
4443 new FrightNumber("JP041"),
--- a/jp/bitmeister/asn1/type/ASN1Module.java
+++ b/jp/bitmeister/asn1/type/ASN1Module.java
@@ -43,7 +43,7 @@ import jp.bitmeister.asn1.annotation.ASN1ModuleTags;
4343 * @see ASN1ModuleRef
4444 */
4545 public abstract class ASN1Module {
46-
46+
4747 /**
4848 * Returns the default tagging mode of the ASN.1 module.
4949 *
@@ -126,5 +126,5 @@ public abstract class ASN1Module {
126126 }
127127 }
128128 }
129-
129+
130130 }
--- a/jp/bitmeister/asn1/type/ASN1ModuleManager.java
+++ b/jp/bitmeister/asn1/type/ASN1ModuleManager.java
@@ -87,7 +87,7 @@ public class ASN1ModuleManager {
8787 * The {@code Class} object of an {@code ASN1Module}.
8888 * @return A {@code ModuleSpecification} instance.
8989 */
90- static ModuleSpecification specification(Class<? extends ASN1Module> module) {
90+ public static ModuleSpecification specification(Class<? extends ASN1Module> module) {
9191 if (module == null) {
9292 module = BuiltInModule.class;
9393 }
@@ -120,7 +120,7 @@ public class ASN1ModuleManager {
120120 public static String identifier(Class<? extends ASN1Module> module) {
121121 return specification(module).identifier();
122122 }
123-
123+
124124 private Map<Class<? extends ASN1Module>, ModuleSpecification> definedModules = new HashMap<Class<? extends ASN1Module>, ModuleSpecification>();
125125
126126 /**
--- a/jp/bitmeister/asn1/type/AbstractInteger.java
+++ b/jp/bitmeister/asn1/type/AbstractInteger.java
@@ -87,7 +87,7 @@ public abstract class AbstractInteger<T extends Number & Comparable<T>> extends
8787 }
8888 super.set(value);
8989 }
90-
90+
9191 /**
9292 * Returns an identifier related to the value of this data if the type has
9393 * {@code @ASN1Enumeration} fields.
--- a/jp/bitmeister/asn1/type/ModuleSpecification.java
+++ b/jp/bitmeister/asn1/type/ModuleSpecification.java
@@ -70,6 +70,24 @@ class ModuleSpecification {
7070 }
7171
7272 /**
73+ * Returns identifier of this module.
74+ *
75+ * @return Identifier.
76+ */
77+ String identifier() {
78+ return identifier;
79+ }
80+
81+ /**
82+ * Returns default tag mode of this module.
83+ *
84+ * @return Default tag mode.
85+ */
86+ ASN1TagDefault tagDefault() {
87+ return tagDefault;
88+ }
89+
90+ /**
7391 * Registers an imported module to this module.
7492 *
7593 * @param module
@@ -128,24 +146,6 @@ class ModuleSpecification {
128146 }
129147
130148 /**
131- * Returns identifier of this module.
132- *
133- * @return Identifier.
134- */
135- String identifier() {
136- return identifier;
137- }
138-
139- /**
140- * Returns default tag mode of this module.
141- *
142- * @return Default tag mode.
143- */
144- ASN1TagDefault tagDefault() {
145- return tagDefault;
146- }
147-
148- /**
149149 * Instantiates an ASN.1 data specified by the tag.
150150 *
151151 * @param tagClass
--- a/jp/bitmeister/asn1/type/builtin/BigENUMERATED.java
+++ b/jp/bitmeister/asn1/type/builtin/BigENUMERATED.java
@@ -72,6 +72,17 @@ public abstract class BigENUMERATED extends BigINTEGER {
7272 public BigENUMERATED(long value) {
7373 super(value);
7474 }
75+
76+ /**
77+ * Instantiates an {@code BigENUMERATED} and initialize it with the value that is
78+ * specified by the identifier of namednumber.
79+ *
80+ * @param identifier
81+ * Identifier of the number to be assigned.
82+ */
83+ public BigENUMERATED(String identifier) {
84+ set(identifier);
85+ }
7586
7687 /*
7788 * (non-Javadoc)
--- a/jp/bitmeister/asn1/type/builtin/BigINTEGER.java
+++ b/jp/bitmeister/asn1/type/builtin/BigINTEGER.java
@@ -92,13 +92,13 @@ public class BigINTEGER extends AbstractInteger<BigInteger> {
9292 }
9393
9494 /**
95- * Instantiates an empty {@code INTEGER}.
95+ * Instantiates an empty {@code BigINTEGER}.
9696 */
9797 public BigINTEGER() {
9898 }
9999
100100 /**
101- * Instantiates an {@code INTEGER} and initialize it with the
101+ * Instantiates an {@code BigINTEGER} and initialize it with the
102102 * {@code BigInteger} value.
103103 *
104104 * @param value
@@ -109,7 +109,7 @@ public class BigINTEGER extends AbstractInteger<BigInteger> {
109109 }
110110
111111 /**
112- * Instantiates an {@code INTEGER} and initialize it with the {@code long}
112+ * Instantiates an {@code BigINTEGER} and initialize it with the {@code long}
113113 * value.
114114 *
115115 * @param value
@@ -118,6 +118,17 @@ public class BigINTEGER extends AbstractInteger<BigInteger> {
118118 public BigINTEGER(long value) {
119119 set(value);
120120 }
121+
122+ /**
123+ * Instantiates an {@code BigINTEGER} and initialize it with the value that is
124+ * specified by the identifier of namednumber.
125+ *
126+ * @param identifier
127+ * Identifier of the number to be assigned.
128+ */
129+ public BigINTEGER(String identifier) {
130+ set(identifier);
131+ }
121132
122133 /**
123134 * Sets the {@code long} value to this data.
--- a/jp/bitmeister/asn1/type/builtin/ENUMERATED.java
+++ b/jp/bitmeister/asn1/type/builtin/ENUMERATED.java
@@ -59,6 +59,17 @@ public abstract class ENUMERATED extends INTEGER {
5959 public ENUMERATED(long value) {
6060 super(value);
6161 }
62+
63+ /**
64+ * Instantiates an {@code ENUMERATED} and initialize it with the value that is
65+ * specified by the identifier of namednumber.
66+ *
67+ * @param identifier
68+ * Identifier of the number to be assigned.
69+ */
70+ public ENUMERATED(String identifier) {
71+ super(identifier);
72+ }
6273
6374 /*
6475 * (non-Javadoc)
--- a/jp/bitmeister/asn1/type/builtin/INTEGER.java
+++ b/jp/bitmeister/asn1/type/builtin/INTEGER.java
@@ -80,6 +80,17 @@ public class INTEGER extends AbstractInteger<Long> {
8080 }
8181
8282 /**
83+ * Instantiates an {@code INTEGER} and initialize it with the value that is
84+ * specified by the identifier of namednumber.
85+ *
86+ * @param identifier
87+ * Identifier of the number to be assigned.
88+ */
89+ public INTEGER(String identifier) {
90+ set(identifier);
91+ }
92+
93+ /**
8394 * Sets the int value to this data.
8495 *
8596 * @param value
Show on old repository browser