OSDN Git Service

* Add size restricted 'INTEGER' and 'ENUMERATED' types which contain a Long value.
[bm-asn1/bm-asn1.git] / jp / bitmeister / asn1 / type / builtin / ENUMERATED.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 jp.bitmeister.asn1.annotation.ASN1BuiltIn;
19 import jp.bitmeister.asn1.annotation.ASN1Enumeration;
20 import jp.bitmeister.asn1.annotation.ASN1Tag;
21 import jp.bitmeister.asn1.processor.ASN1Visitor;
22 import jp.bitmeister.asn1.type.ASN1TagClass;
23 import jp.bitmeister.asn1.type.ASN1TagMode;
24
25 /**
26  * An implementation of ASN.1 'ENUMERATED' type that contains {@code Long}
27  * value.
28  * 
29  * <p>
30  * This is the base class used for defining 'ENUMERATED' types, and has a
31  * {@link java.lang.Long} value. If the data needs to contain value which is
32  * bigger than {@code Long.MAX_VALUE} or smaller than {@code Long.MIN_VALUE},
33  * {@code BigENUMERATED} type shall be used. A sub-class of {@code ENUMERATED}
34  * must contain one or more fields annotated as {@code @ASN1Enumeration}.
35  * </p>
36  * 
37  * @author WATANABE, Jun. <jwat at bitmeister.jp>
38  * 
39  * @see ASN1Enumeration
40  * @see BigENUMERATED
41  */
42 @ASN1BuiltIn
43 @ASN1Tag(tagClass = ASN1TagClass.UNIVERSAL, value = 10, tagMode = ASN1TagMode.IMPLICIT)
44 public abstract class ENUMERATED extends INTEGER {
45
46         /**
47          * Instantiates an empty {@code ENUMERATED}.
48          */
49         public ENUMERATED() {
50         }
51
52         /**
53          * Instantiates an {@code ENUMERATED} and initialize it with the {@code long}
54          * value.
55          * 
56          * @param value
57          *            The value to be assigned.
58          */
59         public ENUMERATED(long value) {
60                 super(value);
61         }
62
63         /*
64          * (non-Javadoc)
65          * 
66          * @see
67          * jp.bitmeister.asn1.type.builtin.INTEGER#accept(jp.bitmeister.asn1.processor
68          * .ASN1Visitor)
69          */
70         @Override
71         public <R, E extends Throwable> R accept(ASN1Visitor<R, E> visitor) throws E {
72                 return visitor.visit(this);
73         }
74
75         /*
76          * (non-Javadoc)
77          * 
78          * @see jp.bitmeister.asn1.type.AbstractInteger#isEnum()
79          */
80         @Override
81         protected boolean isEnum() {
82                 return true;
83         }
84
85 }