OSDN Git Service

X.690 Amendment1 (10/2003)
[bm-asn1/bm-asn1.git] / jp / bitmeister / asn1 / annotation / ASN1Identifier.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.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 /**
24  * Indicates identifier used for ASN.1 definition.
25  * 
26  * <p>
27  * If an {@code @ASN1Identifier} annotation is present on a type or a field,
28  * this value is used as ASN.1 identifier instead of their class name that taken
29  * by calling {@code Class.getSimpleName()} or field name that taken by calling
30  * {@code Field.getName()}. If an ASN.1 identifier can't be used for Java
31  * identifier because of syntax restriction, this annotation shall be used.
32  * </p>
33  * <p>
34  * For example, following ASN.1 definition :
35  * 
36  * <pre>
37  * Signed-Number ::= SEQUENCE { -- '-' can't be used for identifier.
38  *      int INTEGER             -- 'int' is a reserved word.
39  * }
40  * </pre>
41  * 
42  * can be translated as :
43  * 
44  * <code><pre>
45  * &#064;ASN1Identifier(&quot;Signed-Number&quot;)
46  * public class Signed_Number extends SEQUENCE {
47  * 
48  *      &#064;ASN1Identifier(&quot;int&quot;)
49  *      &#064;ASN1Element(0)
50  *      public INTEGER _int;
51  * 
52  * }
53  * </pre></code>
54  * 
55  * </p>
56  * 
57  * @author WATANABE, Jun. <jwat at bitmeister.jp>
58  */
59 @Target({ ElementType.TYPE, ElementType.FIELD })
60 @Retention(RetentionPolicy.RUNTIME)
61 public @interface ASN1Identifier {
62
63         /**
64          * Indicates the identifier used in ASN.1 definitions.
65          * 
66          * @return The ASN.1 identifier.
67          */
68         public String value();
69
70 }