get rid of the stream parsing that occurs in the Layer III decoder. BitStream.readFra...
[IRC.git] / Robust / src / IR / AnnotationDescriptor.java
1 package IR;
2
3 import java.util.Set;
4
5 public class AnnotationDescriptor extends Descriptor {
6
7   public static final int MARKER_ANNOTATION = 1;
8   public static final int SINGLE_ANNOTATION = 2;
9   public static final int FULL_ANNOTATION = 3;
10
11   private String marker;
12   private String value; // for single annotation
13   private int type;
14
15   public AnnotationDescriptor(String annotationName) {
16     // constructor for marker annotation
17     super(annotationName);
18     this.marker = annotationName;
19     this.type = MARKER_ANNOTATION;
20   }
21
22   public AnnotationDescriptor(String annotationName, String value) {
23     // constructor for marker annotation
24     super(annotationName);
25     this.marker = annotationName;
26     this.type = SINGLE_ANNOTATION;
27     this.value = value;
28   }
29
30   public int getType() {
31     return type;
32   }
33
34   public boolean isMarkerAnnotation() {
35     return type == MARKER_ANNOTATION;
36   }
37
38   public boolean isSingleAnnotation() {
39     return type == SINGLE_ANNOTATION;
40   }
41
42   public boolean isFullAnnotation() {
43     return type == FULL_ANNOTATION;
44   }
45
46   public String getMarker() {
47     return marker;
48   }
49
50   public String getValue() {
51     return value;
52   }
53
54   public boolean equals(Object o) {
55     if (o instanceof AnnotationDescriptor) {
56       AnnotationDescriptor a = (AnnotationDescriptor) o;
57       if (a.getType() != type)
58         return false;
59       if (!a.getMarker().equals(getMarker()))
60         return false;
61
62       return true;
63     }
64     return false;
65   }
66
67   public String toString() {
68     if (type == MARKER_ANNOTATION) {
69       return "@" + name;
70     } else {
71       return "@" + name + "(\""+getValue()+"\")";
72     }
73   }
74
75 }