OSDN Git Service

cd9c0d9d933c277e03528332e4fdb31ce4070b92
[bm-asn1/bm-asn1.git] / jp / bitmeister / asn1 / annotation / ASN1NamedBit.java
1 /*
2  * Copyright 2011 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.annotation;
17
18 import java.lang.annotation.ElementType;
19 import java.lang.annotation.Retention;
20 import java.lang.annotation.RetentionPolicy;
21 import java.lang.annotation.Target;
22
23 import jp.bitmeister.asn1.type.builtin.BIT_STRING;
24
25 /**
26  * Indicates that a field represents a named bit of a 'BIT STRING' type.
27  * 
28  * <p>
29  * If a field annotated as {@code @ASN1NamedBit} is present in a definition of
30  * sub-class of {@code BIT_STRING}, the value of the field is the index number
31  * of a distinguished bit in a bitstring value. An {@code @ASN1NamedBit} field
32  * must be a {@code public} {@code static} {@code final} field and the type
33  * shall be {@code int}. Each value of {@code @ASN1NamedBit} fields appearing in
34  * definition of a type must be distinct from the others.
35  * </p>
36  * <p>
37  * For example, following ASN.1 definition :
38  * 
39  * <pre>
40  * Sample ::= BIT STRING { read(0), write(1) }
41  * </pre>
42  * 
43  * can be translated as :
44  * 
45  * <code><pre>
46  * public class Sample extends BIT_STRING {
47  * 
48  *      &#064;ASN1NamedBit
49  *      public static final int read = 0;
50  * 
51  *      &#064;ASN1NamedBit
52  *      public static final int write = 1;
53  * 
54  * }
55  * </pre></code>
56  * 
57  * </p>
58  * 
59  * @author WATANABE, Jun. <jwat at bitmeister.jp>
60  * 
61  * @see BIT_STRING
62  */
63 @Target(ElementType.FIELD)
64 @Retention(RetentionPolicy.RUNTIME)
65 public @interface ASN1NamedBit {
66 }