1 11 package org.eclipse.jdt.core.dom; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 30 public final class SingleMemberAnnotation extends Annotation { 31 32 35 public static final ChildPropertyDescriptor TYPE_NAME_PROPERTY = 36 internalTypeNamePropertyFactory(SingleMemberAnnotation.class); 37 38 41 public static final ChildPropertyDescriptor VALUE_PROPERTY = 42 new ChildPropertyDescriptor(SingleMemberAnnotation.class, "value", Expression.class, MANDATORY, CYCLE_RISK); 44 49 private static final List PROPERTY_DESCRIPTORS; 50 51 static { 52 List propertyList = new ArrayList (3); 53 createPropertyList(SingleMemberAnnotation.class, propertyList); 54 addProperty(TYPE_NAME_PROPERTY, propertyList); 55 addProperty(VALUE_PROPERTY, propertyList); 56 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 57 } 58 59 67 public static List propertyDescriptors(int apiLevel) { 68 return PROPERTY_DESCRIPTORS; 69 } 70 71 75 private Expression value = null; 76 77 87 SingleMemberAnnotation(AST ast) { 88 super(ast); 89 unsupportedIn2(); 90 } 91 92 95 final List internalStructuralPropertiesForType(int apiLevel) { 96 return propertyDescriptors(apiLevel); 97 } 98 99 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 if (property == VALUE_PROPERTY) { 112 if (get) { 113 return getValue(); 114 } else { 115 setValue((Expression) child); 116 return null; 117 } 118 } 119 return super.internalGetSetChildProperty(property, get, child); 121 } 122 123 126 final ChildPropertyDescriptor internalTypeNameProperty() { 127 return TYPE_NAME_PROPERTY; 128 } 129 130 133 final int getNodeType0() { 134 return SINGLE_MEMBER_ANNOTATION; 135 } 136 137 140 ASTNode clone0(AST target) { 141 SingleMemberAnnotation result = new SingleMemberAnnotation(target); 142 result.setSourceRange(this.getStartPosition(), this.getLength()); 143 result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); 144 result.setValue((Expression) ASTNode.copySubtree(target, getValue())); 145 return result; 146 } 147 148 151 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 152 return matcher.match(this, other); 154 } 155 156 159 void accept0(ASTVisitor visitor) { 160 boolean visitChildren = visitor.visit(this); 161 if (visitChildren) { 162 acceptChild(visitor, getTypeName()); 164 acceptChild(visitor, getValue()); 165 } 166 visitor.endVisit(this); 167 } 168 169 174 public Expression getValue() { 175 if (this.value == null) { 176 synchronized (this) { 178 if (this.value == null) { 179 preLazyInit(); 180 this.value = new SimpleName(this.ast); 181 postLazyInit(this.value, VALUE_PROPERTY); 182 } 183 } 184 } 185 return this.value; 186 } 187 188 199 public void setValue(Expression value) { 200 if (value == null) { 201 throw new IllegalArgumentException (); 202 } 203 ASTNode oldChild = this.value; 204 preReplaceChild(oldChild, value, VALUE_PROPERTY); 205 this.value = value; 206 postReplaceChild(oldChild, value, VALUE_PROPERTY); 207 } 208 209 212 int memSize() { 213 return super.memSize() + 1 * 4; 214 } 215 216 219 int treeSize() { 220 return 221 memSize() 222 + (this.typeName == null ? 0 : getTypeName().treeSize()) 223 + (this.value == null ? 0 : getValue().treeSize()); 224 } 225 } 226 | Popular Tags |