KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > dom > MarkerAnnotation


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core.dom;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 /**
17  * Marker annotation node (added in JLS3 API). The marker annotation
18  * "@foo" is equivalent to the normal annotation "@foo()".
19  * <p>
20  * <pre>
21  * MarkerAnnotation:
22  * <b>@</b> TypeName
23  * </pre>
24  * </p>
25  *
26  * @since 3.1
27  */

28 public final class MarkerAnnotation extends Annotation {
29
30     /**
31      * The "typeName" structural property of this node type.
32      */

33     public static final ChildPropertyDescriptor TYPE_NAME_PROPERTY =
34         internalTypeNamePropertyFactory(MarkerAnnotation.class);
35
36     /**
37      * A list of property descriptors (element type:
38      * {@link StructuralPropertyDescriptor}),
39      * or null if uninitialized.
40      */

41     private static final List JavaDoc PROPERTY_DESCRIPTORS;
42     
43     static {
44         List JavaDoc propertyList = new ArrayList JavaDoc(2);
45         createPropertyList(MarkerAnnotation.class, propertyList);
46         addProperty(TYPE_NAME_PROPERTY, propertyList);
47         PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
48     }
49     
50     /**
51      * Returns a list of structural property descriptors for this node type.
52      * Clients must not modify the result.
53      *
54      * @param apiLevel the API level; one of the AST.JLS* constants
55      * @return a list of property descriptors (element type:
56      * {@link StructuralPropertyDescriptor})
57      */

58     public static List JavaDoc propertyDescriptors(int apiLevel) {
59         return PROPERTY_DESCRIPTORS;
60     }
61     
62     /**
63      * Creates a new unparented marker annotation node owned
64      * by the given AST. By default, the annotation has an
65      * unspecified type name .
66      * <p>
67      * N.B. This constructor is package-private.
68      * </p>
69      *
70      * @param ast the AST that is to own this node
71      */

72     MarkerAnnotation(AST ast) {
73         super(ast);
74         unsupportedIn2();
75     }
76
77     /* (omit javadoc for this method)
78      * Method declared on ASTNode.
79      */

80     final List JavaDoc internalStructuralPropertiesForType(int apiLevel) {
81         return propertyDescriptors(apiLevel);
82     }
83     
84     /* (omit javadoc for this method)
85      * Method declared on ASTNode.
86      */

87     final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
88         if (property == TYPE_NAME_PROPERTY) {
89             if (get) {
90                 return getTypeName();
91             } else {
92                 setTypeName((Name) child);
93                 return null;
94             }
95         }
96         // allow default implementation to flag the error
97
return super.internalGetSetChildProperty(property, get, child);
98     }
99     
100     /* (omit javadoc for this method)
101      * Method declared on BodyDeclaration.
102      */

103     final ChildPropertyDescriptor internalTypeNameProperty() {
104         return TYPE_NAME_PROPERTY;
105     }
106
107     /* (omit javadoc for this method)
108      * Method declared on ASTNode.
109      */

110     final int getNodeType0() {
111         return MARKER_ANNOTATION;
112     }
113
114     /* (omit javadoc for this method)
115      * Method declared on ASTNode.
116      */

117     ASTNode clone0(AST target) {
118         MarkerAnnotation result = new MarkerAnnotation(target);
119         result.setSourceRange(this.getStartPosition(), this.getLength());
120         result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName()));
121         return result;
122     }
123     
124     /* (omit javadoc for this method)
125      * Method declared on ASTNode.
126      */

127     final boolean subtreeMatch0(ASTMatcher matcher, Object JavaDoc other) {
128         // dispatch to correct overloaded match method
129
return matcher.match(this, other);
130     }
131     
132     /* (omit javadoc for this method)
133      * Method declared on ASTNode.
134      */

135     void accept0(ASTVisitor visitor) {
136         boolean visitChildren = visitor.visit(this);
137         if (visitChildren) {
138             // visit children in normal left to right reading order
139
acceptChild(visitor, getTypeName());
140         }
141         visitor.endVisit(this);
142     }
143     
144     /* (omit javadoc for this method)
145      * Method declared on ASTNode.
146      */

147     int memSize() {
148         return super.memSize();
149     }
150     
151     /* (omit javadoc for this method)
152      * Method declared on ASTNode.
153      */

154     int treeSize() {
155         return
156             memSize()
157             + (this.typeName == null ? 0 : getTypeName().treeSize());
158     }
159 }
160
Popular Tags