OSDN Git Service

b2dada4742dfc7880cb106c2fd5a34d2b47fa327
[bm-asn1/bm-asn1.git] / jp / bitmeister / asn1 / type / builtin / BigENUMERATED.java
1 /*
2  * Copyright 2011-2012 BitMeister Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package jp.bitmeister.asn1.type.builtin;
17
18 import java.math.BigInteger;
19
20 import jp.bitmeister.asn1.annotation.ASN1BuiltIn;
21 import jp.bitmeister.asn1.annotation.ASN1Enumeration;
22 import jp.bitmeister.asn1.annotation.ASN1Identifier;
23 import jp.bitmeister.asn1.annotation.ASN1Tag;
24 import jp.bitmeister.asn1.processor.ASN1Visitor;
25 import jp.bitmeister.asn1.type.ASN1TagClass;
26 import jp.bitmeister.asn1.type.ASN1TagMode;
27
28 /**
29  * An implementation of ASN.1 'ENUMERATED' type that can contain
30  * arbitrary-precision integer value.
31  * 
32  * <p>
33  * This is the base class used for defining 'ENUMERATED' types which need to
34  * contain an arbitrary-precision value. A sub-class of {@code BigENUMERATED}
35  * must contain one or more fields annotated as {@code @ASN1Enumeration}.
36  * </p>
37  * 
38  * @author WATANABE, Jun. <jwat at bitmeister.jp>
39  * 
40  * @see ASN1Enumeration
41  * @see ENUMERATED
42  */
43 @ASN1BuiltIn
44 @ASN1Identifier("ENUMERATED")
45 @ASN1Tag(tagClass = ASN1TagClass.UNIVERSAL, value = 10, tagMode = ASN1TagMode.IMPLICIT)
46 public abstract class BigENUMERATED extends BigINTEGER {
47
48         /**
49          * Instantiates an empty {@code BigENUMERATED}.
50          */
51         public BigENUMERATED() {
52         }
53
54         /**
55          * Instantiates an {@code BigENUMERATED} and initialize it with the
56          * {@code BigInteger} value.
57          * 
58          * @param value
59          *            The value to be assigned.
60          */
61         public BigENUMERATED(BigInteger value) {
62                 super(value);
63         }
64
65         /**
66          * Instantiates an {@code BigENUMERATED} and initialize it with the {@code long}
67          * value.
68          * 
69          * @param value
70          *            The value to be assigned.
71          */
72         public BigENUMERATED(long value) {
73                 super(value);
74         }
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         }
86
87         /*
88          * (non-Javadoc)
89          * 
90          * @see
91          * jp.bitmeister.asn1.type.builtin.INTEGER#accept(jp.bitmeister.asn1.processor
92          * .ASN1Visitor)
93          */
94         @Override
95         public <R, E extends Throwable> R accept(ASN1Visitor<R, E> visitor) throws E {
96                 return visitor.visit(this);
97         }
98
99         /*
100          * (non-Javadoc)
101          * 
102          * @see jp.bitmeister.asn1.type.AbstractInteger#isEnum()
103          */
104         @Override
105         protected boolean isEnum() {
106                 return true;
107         }
108
109 }