I am working with "binary notes" a ASN.1 environment in Java. First I created a class of an asn.1 sequence by hand.
@ASN1String(name = "", isUCS = false, stringType = UniversalTag.PrintableString)
@ASN1Element(name = "firstName", isOptional = false, hasTag = false, hasDefaultValue = false)
private String firstName = null;
Now I am wondering what that "@" sign means? I tried to find hints in the source of binary notes, and found the following:
package org.bn.annotati开发者_StackOverflow社区ons;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ASN1String {
String name();
boolean isUCS();
int stringType();
}
Can someone explain the notation to me? Would be nice. Thanks in advance.
nyyrikki
In Java, "@Foo" is an annotation. It's intended for a part of your particular build environment to interpret it. Generally annotations get replaced with chunks of Java code.
More information on annotations: http://download.oracle.com/javase/1.5.0/docs/guide/language/annotations.html
My guess is that you need to look up documentation on ASN.1 to know what those specific annotations do.
I'm author this framework. This is Java annotation feature (meta information) for your fields/classes used to control some ASN.1 features. For your sample it's a string field encoding to ASN.1 byte stream as ASCII string (not unicode string) without tag and it's not optional (required) for parent structure (ASN.1 sequence).
For details you can start read it http://en.wikipedia.org/wiki/ASN.1#Standards
精彩评论