1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 18 34 public class QualifiedName extends Name { 35 36 40 public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = 41 new ChildPropertyDescriptor(QualifiedName.class, "qualifier", Name.class, MANDATORY, CYCLE_RISK); 43 47 public static final ChildPropertyDescriptor NAME_PROPERTY = 48 new ChildPropertyDescriptor(QualifiedName.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 50 55 private static final List PROPERTY_DESCRIPTORS; 56 57 static { 58 List propertyList = new ArrayList (3); 59 createPropertyList(QualifiedName.class, propertyList); 60 addProperty(QUALIFIER_PROPERTY, propertyList); 61 addProperty(NAME_PROPERTY, propertyList); 62 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 63 } 64 65 75 public static List propertyDescriptors(int apiLevel) { 76 return PROPERTY_DESCRIPTORS; 77 } 78 79 83 private Name qualifier = null; 84 85 89 private SimpleName name = null; 90 91 101 QualifiedName(AST ast) { 102 super(ast); 103 } 104 105 108 final List internalStructuralPropertiesForType(int apiLevel) { 109 return propertyDescriptors(apiLevel); 110 } 111 112 115 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 116 if (property == QUALIFIER_PROPERTY) { 117 if (get) { 118 return getQualifier(); 119 } else { 120 setQualifier((Name) child); 121 return null; 122 } 123 } 124 if (property == NAME_PROPERTY) { 125 if (get) { 126 return getName(); 127 } else { 128 setName((SimpleName) child); 129 return null; 130 } 131 } 132 return super.internalGetSetChildProperty(property, get, child); 134 } 135 136 139 final int getNodeType0() { 140 return QUALIFIED_NAME; 141 } 142 143 146 ASTNode clone0(AST target) { 147 QualifiedName result = new QualifiedName(target); 148 result.setSourceRange(this.getStartPosition(), this.getLength()); 149 result.setQualifier((Name) getQualifier().clone(target)); 150 result.setName((SimpleName) getName().clone(target)); 151 return result; 152 } 153 154 157 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 158 return matcher.match(this, other); 160 } 161 162 165 void accept0(ASTVisitor visitor) { 166 boolean visitChildren = visitor.visit(this); 167 if (visitChildren) { 168 acceptChild(visitor, getQualifier()); 170 acceptChild(visitor, getName()); 171 } 172 visitor.endVisit(this); 173 } 174 175 180 public Name getQualifier() { 181 if (this.qualifier == null) { 182 synchronized (this) { 184 if (this.qualifier == null) { 185 preLazyInit(); 186 this.qualifier = new SimpleName(this.ast); 187 postLazyInit(this.qualifier, QUALIFIER_PROPERTY); 188 } 189 } 190 } 191 return this.qualifier; 192 } 193 194 205 public void setQualifier(Name qualifier) { 206 if (qualifier == null) { 207 throw new IllegalArgumentException (); 208 } 209 ASTNode oldChild = this.qualifier; 210 preReplaceChild(oldChild, qualifier, QUALIFIER_PROPERTY); 211 this.qualifier = qualifier; 212 postReplaceChild(oldChild, qualifier, QUALIFIER_PROPERTY); 213 } 214 215 220 public SimpleName getName() { 221 if (this.name == null) { 222 synchronized (this) { 224 if (this.name == null) { 225 preLazyInit(); 226 this.name = new SimpleName(this.ast); 227 postLazyInit(this.name, NAME_PROPERTY); 228 } 229 } 230 } 231 return this.name; 232 } 233 234 244 public void setName(SimpleName name) { 245 if (name == null) { 246 throw new IllegalArgumentException (); 247 } 248 ASTNode oldChild = this.name; 249 preReplaceChild(oldChild, name, NAME_PROPERTY); 250 this.name = name; 251 postReplaceChild(oldChild, name, NAME_PROPERTY); 252 } 253 254 257 void appendName(StringBuffer buffer) { 258 getQualifier().appendName(buffer); 259 buffer.append('.'); 260 getName().appendName(buffer); 261 } 262 263 266 int memSize() { 267 return BASE_NAME_NODE_SIZE + 3 * 4; 268 } 269 270 273 int treeSize() { 274 return 275 memSize() 276 + (this.name == null ? 0 : getName().treeSize()) 277 + (this.qualifier == null ? 0 : getQualifier().treeSize()); 278 } 279 } 280 281 | Popular Tags |