2 * Copyright 2011-2012 BitMeister Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package jp.bitmeister.asn1.type.builtin;
18 import jp.bitmeister.asn1.annotation.ASN1Alternative;
19 import jp.bitmeister.asn1.annotation.ASN1BuiltIn;
20 import jp.bitmeister.asn1.processor.ASN1Visitor;
21 import jp.bitmeister.asn1.type.ASN1TagClass;
22 import jp.bitmeister.asn1.type.ASN1Type;
23 import jp.bitmeister.asn1.type.SelectiveType;
26 * Represents ASN.1 'CHOICE' type.
29 * This is the base class used for defining 'CHOICE' types. A sub-class of
30 * {@code CHOICE} shall have one or more fields annotated as
31 * {@code @ASN1Alternative}. When a value is assigned to one of the
32 * {@code @ASN1Alternative} fields of an instance, the field becomes selected
33 * field. If an instance has more than two fields which assigned value, the
34 * instance can't be encoded.
37 * @author WATANABE, Jun. <jwat at bitmeister.jp>
39 * @see ASN1Alternative
42 public abstract class CHOICE extends SelectiveType {
45 * Instantiates an empty {@code CHOICE}.
51 * Instantiates a {@code CHOICE} and initialize it with the parameter. The
52 * ASN.1 type of the data is used for select an alternative.
55 * The data to be assigned.
57 public CHOICE(ASN1Type data) {
62 * Instantiates a {@code CHOICE} and initialize it with parameters.
65 * The tag class used for select an alternative.
67 * The tag number used for select an alternative.
69 * The data to be assigned.
71 public CHOICE(ASN1TagClass tagClass, int tagNumber, ASN1Type data) {
72 super(tagClass, tagNumber, data);
76 * Instantiates a {@code CHOICE} and initialize it with parameters.
79 * The element name used for select an alternative.
81 * The data to be assigned.
83 public CHOICE(String elementName, ASN1Type data) {
84 super(elementName, data);
91 * jp.bitmeister.asn1.type.ASN1Type#accept(jp.bitmeister.asn1.processor.
95 public <R, E extends Throwable> R accept(ASN1Visitor<R, E> visitor)
97 return visitor.visit(this);