removed unused private methods.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / dom / NormalAnnotation.java
1 /*******************************************************************************
2  * Copyright (c) 2004, 2008 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 net.sourceforge.phpdt.core.dom;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 /**
17  * Normal annotation node (added in JLS3 API).
18  * <p>
19  * <pre>
20  * NormalAnnotation:
21  *   <b>@</b> TypeName <b>(</b> [ MemberValuePair { <b>,</b> MemberValuePair } ] <b>)</b>
22  * </pre>
23  * </p>
24  * 
25  * @since 3.1
26  * @noinstantiate This class is not intended to be instantiated by clients.
27  */
28 public final class NormalAnnotation extends Annotation {
29         
30         /**
31          * The "typeName" structural property of this node type.
32          */
33         public static final ChildPropertyDescriptor TYPE_NAME_PROPERTY = 
34                 internalTypeNamePropertyFactory(NormalAnnotation.class);
35
36         /**
37          * The "values" structural property of this node type.
38          */
39         public static final ChildListPropertyDescriptor VALUES_PROPERTY = 
40                 new ChildListPropertyDescriptor(NormalAnnotation.class, "values", MemberValuePair.class, CYCLE_RISK); //$NON-NLS-1$
41
42         /**
43          * A list of property descriptors (element type: 
44          * {@link StructuralPropertyDescriptor}),
45          * or null if uninitialized.
46          */
47         private static final List PROPERTY_DESCRIPTORS;
48         
49         static {
50                 List propertyList = new ArrayList(3);
51                 createPropertyList(NormalAnnotation.class, propertyList);
52                 addProperty(TYPE_NAME_PROPERTY, propertyList);
53                 addProperty(VALUES_PROPERTY, propertyList);
54                 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
55         }
56         
57         /**
58          * Returns a list of structural property descriptors for this node type.
59          * Clients must not modify the result.
60          * 
61          * @param apiLevel the API level; one of the AST.JLS* constants
62          * @return a list of property descriptors (element type: 
63          * {@link StructuralPropertyDescriptor})
64          */
65         public static List propertyDescriptors(int apiLevel) {
66                 return PROPERTY_DESCRIPTORS;
67         }
68         
69         /**
70          * The list of member value pairs (element type: 
71          * <code MemberValuePair</code>). Defaults to an empty list.
72          */
73         private ASTNode.NodeList values = 
74                 new ASTNode.NodeList(VALUES_PROPERTY);
75
76         /**
77          * Creates a new unparented normal annotation node owned 
78          * by the given AST.  By default, the annotation has an
79          * unspecified type name and an empty list of member value
80          * pairs.
81          * <p>
82          * N.B. This constructor is package-private.
83          * </p>
84          * 
85          * @param ast the AST that is to own this node
86          */
87         NormalAnnotation(AST ast) {
88                 super(ast);
89             unsupportedIn2();
90         }
91
92         /* (omit javadoc for this method)
93          * Method declared on ASTNode.
94          */
95         final List internalStructuralPropertiesForType(int apiLevel) {
96                 return propertyDescriptors(apiLevel);
97         }
98         
99         /* (omit javadoc for this method)
100          * Method declared on ASTNode.
101          */
102         final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
103                 if (property == TYPE_NAME_PROPERTY) {
104                         if (get) {
105                                 return getTypeName();
106                         } else {
107                                 setTypeName((Name) child);
108                                 return null;
109                         }
110                 }
111                 // allow default implementation to flag the error
112                 return super.internalGetSetChildProperty(property, get, child);
113         }
114         
115         /* (omit javadoc for this method)
116          * Method declared on ASTNode.
117          */
118         final List internalGetChildListProperty(ChildListPropertyDescriptor property) {
119                 if (property == VALUES_PROPERTY) {
120                         return values();
121                 }
122                 // allow default implementation to flag the error
123                 return super.internalGetChildListProperty(property);
124         }
125
126         /* (omit javadoc for this method)
127          * Method declared on BodyDeclaration.
128          */
129         final ChildPropertyDescriptor internalTypeNameProperty() {
130                 return TYPE_NAME_PROPERTY;
131         }
132
133         /* (omit javadoc for this method)
134          * Method declared on ASTNode.
135          */
136         final int getNodeType0() {
137                 return NORMAL_ANNOTATION;
138         }
139
140         /* (omit javadoc for this method)
141          * Method declared on ASTNode.
142          */
143         ASTNode clone0(AST target) {
144                 NormalAnnotation result = new NormalAnnotation(target);
145                 result.setSourceRange(this.getStartPosition(), this.getLength());
146                 result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName()));
147                 result.values().addAll(ASTNode.copySubtrees(target, values()));
148                 return result;
149         }
150         
151         /* (omit javadoc for this method)
152          * Method declared on ASTNode.
153          */
154         final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
155                 // dispatch to correct overloaded match method
156                 return matcher.match(this, other);
157         }
158         
159         /* (omit javadoc for this method)
160          * Method declared on ASTNode.
161          */
162         void accept0(ASTVisitor visitor) {
163                 boolean visitChildren = visitor.visit(this);
164                 if (visitChildren) {
165                         // visit children in normal left to right reading order
166                         acceptChild(visitor, getTypeName());
167                         acceptChildren(visitor, this.values);
168                 }
169                 visitor.endVisit(this);
170         }
171         
172         /**
173          * Returns the live list of member value pairs in this annotation.
174          * Adding and removing nodes from this list affects this node
175          * dynamically. All nodes in this list must be 
176          * {@link MemberValuePair}s; attempts to add any other 
177          * type of node will trigger an exception.
178          * 
179          * @return the live list of member value pairs in this 
180          *    annotation (element type: <code>MemberValuePair</code>)
181          */ 
182         public List values() {
183                 return this.values;
184         }
185                 
186         /* (omit javadoc for this method)
187          * Method declared on ASTNode.
188          */
189         int memSize() {
190                 return super.memSize() + 1 * 4;
191         }
192         
193         /* (omit javadoc for this method)
194          * Method declared on ASTNode.
195          */
196         int treeSize() {
197                 return
198                         memSize()
199                         + (this.typeName == null ? 0 : getTypeName().treeSize())
200                         + this.values.listSize();
201         }
202 }