1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 57 public abstract class BodyDeclaration extends ASTNode { 58 59 63 Javadoc optionalDocComment = null; 64 65 70 private int modifierFlags = Modifier.NONE; 71 72 79 ASTNode.NodeList modifiers = null; 80 81 87 abstract SimplePropertyDescriptor internalModifiersProperty(); 88 89 95 abstract ChildListPropertyDescriptor internalModifiers2Property(); 96 97 104 public final ChildListPropertyDescriptor getModifiersProperty() { 105 return internalModifiers2Property(); 107 } 108 109 115 abstract ChildPropertyDescriptor internalJavadocProperty(); 116 117 124 public final ChildPropertyDescriptor getJavadocProperty() { 125 return internalJavadocProperty(); 126 } 127 128 134 static final ChildPropertyDescriptor internalJavadocPropertyFactory(Class nodeClass) { 135 return new ChildPropertyDescriptor(nodeClass, "javadoc", Javadoc.class, OPTIONAL, NO_CYCLE_RISK); } 137 138 144 static final SimplePropertyDescriptor internalModifiersPropertyFactory(Class nodeClass) { 145 return new SimplePropertyDescriptor(nodeClass, "modifiers", int.class, MANDATORY); } 147 148 154 static final ChildListPropertyDescriptor internalModifiers2PropertyFactory(Class nodeClass) { 155 return new ChildListPropertyDescriptor(nodeClass, "modifiers", IExtendedModifier.class, CYCLE_RISK); } 157 158 167 BodyDeclaration(AST ast) { 168 super(ast); 169 if (ast.apiLevel >= AST.JLS3) { 170 this.modifiers = new ASTNode.NodeList(internalModifiers2Property()); 171 } 172 } 173 174 179 public Javadoc getJavadoc() { 180 return this.optionalDocComment; 181 } 182 183 189 public void setJavadoc(Javadoc docComment) { 190 ChildPropertyDescriptor p = internalJavadocProperty(); 191 ASTNode oldChild = this.optionalDocComment; 192 preReplaceChild(oldChild, docComment, p); 193 this.optionalDocComment = docComment; 194 postReplaceChild(oldChild, docComment, p); 195 } 196 197 207 public int getModifiers() { 208 if (this.modifiers == null) { 210 return this.modifierFlags; 212 } else { 213 int computedmodifierFlags = Modifier.NONE; 217 for (Iterator it = modifiers().iterator(); it.hasNext(); ) { 218 Object x = it.next(); 219 if (x instanceof Modifier) { 220 computedmodifierFlags |= ((Modifier) x).getKeyword().toFlagValue(); 221 } 222 } 223 return computedmodifierFlags; 224 } 225 } 226 227 237 public void setModifiers(int modifiers) { 238 internalSetModifiers(modifiers); 239 } 240 241 246 final void internalSetModifiers(int pmodifiers) { 247 if (this.modifiers != null) { 249 supportedOnlyIn2(); 250 } 251 SimplePropertyDescriptor p = internalModifiersProperty(); 252 preValueChange(p); 253 this.modifierFlags = pmodifiers; 254 postValueChange(p); 255 } 256 257 267 public List modifiers() { 268 if (this.modifiers == null) { 270 unsupportedIn2(); 271 } 272 return this.modifiers; 273 } 274 275 278 int memSize() { 279 return BASE_NODE_SIZE + 3 * 4; 280 } 281 } 282 283 | Popular Tags |