1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 31 public class MemberValuePair extends ASTNode { 32 33 36 public static final ChildPropertyDescriptor NAME_PROPERTY = 37 new ChildPropertyDescriptor(MemberValuePair.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 39 42 public static final ChildPropertyDescriptor VALUE_PROPERTY = 43 new ChildPropertyDescriptor(MemberValuePair.class, "value", Expression.class, MANDATORY, CYCLE_RISK); 45 50 private static final List PROPERTY_DESCRIPTORS; 51 52 static { 53 List propertyList = new ArrayList (3); 54 createPropertyList(MemberValuePair.class, propertyList); 55 addProperty(NAME_PROPERTY, propertyList); 56 addProperty(VALUE_PROPERTY, propertyList); 57 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 58 } 59 60 68 public static List propertyDescriptors(int apiLevel) { 69 return PROPERTY_DESCRIPTORS; 70 } 71 72 76 private SimpleName name = null; 77 78 82 private Expression value = null; 83 84 94 MemberValuePair(AST ast) { 95 super(ast); 96 unsupportedIn2(); 97 } 98 99 102 final List internalStructuralPropertiesForType(int apiLevel) { 103 return propertyDescriptors(apiLevel); 104 } 105 106 109 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 110 if (property == NAME_PROPERTY) { 111 if (get) { 112 return getName(); 113 } else { 114 setName((SimpleName) child); 115 return null; 116 } 117 } 118 if (property == VALUE_PROPERTY) { 119 if (get) { 120 return getValue(); 121 } else { 122 setValue((Expression) child); 123 return null; 124 } 125 } 126 return super.internalGetSetChildProperty(property, get, child); 128 } 129 130 133 final int getNodeType0() { 134 return MEMBER_VALUE_PAIR; 135 } 136 137 140 ASTNode clone0(AST target) { 141 MemberValuePair result = new MemberValuePair(target); 142 result.setSourceRange(this.getStartPosition(), this.getLength()); 143 result.setName((SimpleName) ASTNode.copySubtree(target, getName())); 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, getName()); 164 acceptChild(visitor, getValue()); 165 } 166 visitor.endVisit(this); 167 } 168 169 174 public SimpleName getName() { 175 if (this.name == null) { 176 synchronized (this) { 178 if (this.name == null) { 179 preLazyInit(); 180 this.name = new SimpleName(this.ast); 181 postLazyInit(this.name, NAME_PROPERTY); 182 } 183 } 184 } 185 return this.name; 186 } 187 188 198 public void setName(SimpleName name) { 199 if (name == null) { 200 throw new IllegalArgumentException (); 201 } 202 ASTNode oldChild = this.name; 203 preReplaceChild(oldChild, name, NAME_PROPERTY); 204 this.name = name; 205 postReplaceChild(oldChild, name, NAME_PROPERTY); 206 } 207 208 213 public Expression getValue() { 214 if (this.value == null) { 215 synchronized (this) { 217 if (this.value == null) { 218 preLazyInit(); 219 this.value= new SimpleName(this.ast); 220 postLazyInit(this.value, VALUE_PROPERTY); 221 } 222 } 223 } 224 return this.value; 225 } 226 227 238 public void setValue(Expression value) { 239 if (value == null) { 240 throw new IllegalArgumentException (); 241 } 242 ASTNode oldChild = this.value; 243 preReplaceChild(oldChild, value, VALUE_PROPERTY); 244 this.value = value; 245 postReplaceChild(oldChild, value, VALUE_PROPERTY); 246 } 247 248 251 int memSize() { 252 return BASE_NODE_SIZE + 2 * 4; 253 } 254 255 258 int treeSize() { 259 return 260 memSize() 261 + (this.name == null ? 0 : getName().treeSize()) 262 + (this.value == null ? 0 : getValue().treeSize()); 263 } 264 } 265 | Popular Tags |