OSDN Git Service

* Add constructor with a String to INTEGER classes (INTEGER, ENUMERATED, BigINTEGER...
[bm-asn1/bm-asn1.git] / jp / bitmeister / asn1 / type / builtin / ENUMERATED.java
index 1db4dc2..37ab82c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
  */
 package jp.bitmeister.asn1.type.builtin;
 
-import java.math.BigInteger;
-
 import jp.bitmeister.asn1.annotation.ASN1BuiltIn;
 import jp.bitmeister.asn1.annotation.ASN1Enumeration;
 import jp.bitmeister.asn1.annotation.ASN1Tag;
@@ -25,17 +23,21 @@ import jp.bitmeister.asn1.type.ASN1TagClass;
 import jp.bitmeister.asn1.type.ASN1TagMode;
 
 /**
- * Represents ASN.1 'ENUMERATED' type.
+ * An implementation of ASN.1 'ENUMERATED' type that contains {@code Long}
+ * value.
  * 
  * <p>
- * This is the base class used for defining 'ENUMERATED' types. A sub-class of
- * {@code ENUMERATED} must contain one or more fields annotated as
- * {@code @ASN1Enumeration}.
+ * This is the base class used for defining 'ENUMERATED' types, and has a
+ * {@link java.lang.Long} value. If the data needs to contain value which is
+ * bigger than {@code Long.MAX_VALUE} or smaller than {@code Long.MIN_VALUE},
+ * {@code BigENUMERATED} type shall be used. A sub-class of {@code ENUMERATED}
+ * must contain one or more fields annotated as {@code @ASN1Enumeration}.
  * </p>
  * 
  * @author WATANABE, Jun. <jwat at bitmeister.jp>
  * 
  * @see ASN1Enumeration
+ * @see BigENUMERATED
  */
 @ASN1BuiltIn
 @ASN1Tag(tagClass = ASN1TagClass.UNIVERSAL, value = 10, tagMode = ASN1TagMode.IMPLICIT)
@@ -48,25 +50,25 @@ public abstract class ENUMERATED extends INTEGER {
        }
 
        /**
-        * Instantiates an {@code ENUMERATED} and initialize it with the
-        * {@code BigInteger} value.
+        * Instantiates an {@code ENUMERATED} and initialize it with the {@code long}
+        * value.
         * 
         * @param value
         *            The value to be assigned.
         */
-       public ENUMERATED(BigInteger value) {
+       public ENUMERATED(long value) {
                super(value);
        }
-
+       
        /**
-        * Instantiates an {@code ENUMERATED} and initialize it with the {@code long}
-        * value.
+        * Instantiates an {@code ENUMERATED} and initialize it with the value that is
+        * specified by the identifier of namednumber.
         * 
-        * @param value
-        *            The value to be assigned.
+        * @param identifier
+        *            Identifier of the number to be assigned.
         */
-       public ENUMERATED(long value) {
-               super(value);
+       public ENUMERATED(String identifier) {
+               super(identifier);
        }
 
        /*
@@ -77,8 +79,18 @@ public abstract class ENUMERATED extends INTEGER {
         * .ASN1Visitor)
         */
        @Override
-       public <E extends Throwable> void accept(ASN1Visitor<E> visitor) throws E {
-               visitor.visit(this);
+       public <R, E extends Throwable> R accept(ASN1Visitor<R, E> visitor) throws E {
+               return visitor.visit(this);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see jp.bitmeister.asn1.type.AbstractInteger#isEnum()
+        */
+       @Override
+       protected boolean isEnum() {
+               return true;
        }
 
 }