1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 26 public class InstanceofExpression extends Expression { 27 28 32 public static final ChildPropertyDescriptor LEFT_OPERAND_PROPERTY = 33 new ChildPropertyDescriptor(InstanceofExpression.class, "leftOperand", Expression.class, MANDATORY, CYCLE_RISK); 35 39 public static final ChildPropertyDescriptor RIGHT_OPERAND_PROPERTY = 40 new ChildPropertyDescriptor(InstanceofExpression.class, "rightOperand", Type.class, MANDATORY, CYCLE_RISK); 42 47 private static final List PROPERTY_DESCRIPTORS; 48 49 static { 50 List properyList = new ArrayList (3); 51 createPropertyList(InstanceofExpression.class, properyList); 52 addProperty(LEFT_OPERAND_PROPERTY, properyList); 53 addProperty(RIGHT_OPERAND_PROPERTY, properyList); 54 PROPERTY_DESCRIPTORS = reapPropertyList(properyList); 55 } 56 57 68 public static List propertyDescriptors(int apiLevel) { 69 return PROPERTY_DESCRIPTORS; 70 } 71 72 76 private Expression leftOperand = null; 77 78 82 private Type rightOperand = null; 83 84 91 InstanceofExpression(AST ast) { 92 super(ast); 93 } 94 95 98 final List internalStructuralPropertiesForType(int apiLevel) { 99 return propertyDescriptors(apiLevel); 100 } 101 102 105 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 106 if (property == LEFT_OPERAND_PROPERTY) { 107 if (get) { 108 return getLeftOperand(); 109 } else { 110 setLeftOperand((Expression) child); 111 return null; 112 } 113 } 114 if (property == RIGHT_OPERAND_PROPERTY) { 115 if (get) { 116 return getRightOperand(); 117 } else { 118 setRightOperand((Type) child); 119 return null; 120 } 121 } 122 return super.internalGetSetChildProperty(property, get, child); 124 } 125 126 129 final int getNodeType0() { 130 return INSTANCEOF_EXPRESSION; 131 } 132 133 136 ASTNode clone0(AST target) { 137 InstanceofExpression result = new InstanceofExpression(target); 138 result.setSourceRange(this.getStartPosition(), this.getLength()); 139 result.setLeftOperand((Expression) getLeftOperand().clone(target)); 140 result.setRightOperand((Type) getRightOperand().clone(target)); 141 return result; 142 } 143 144 147 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 148 return matcher.match(this, other); 150 } 151 152 155 void accept0(ASTVisitor visitor) { 156 boolean visitChildren = visitor.visit(this); 157 if (visitChildren) { 158 acceptChild(visitor, getLeftOperand()); 160 acceptChild(visitor, getRightOperand()); 161 } 162 visitor.endVisit(this); 163 } 164 165 170 public Expression getLeftOperand() { 171 if (this.leftOperand == null) { 172 synchronized (this) { 174 if (this.leftOperand == null) { 175 preLazyInit(); 176 this.leftOperand= new SimpleName(this.ast); 177 postLazyInit(this.leftOperand, LEFT_OPERAND_PROPERTY); 178 } 179 } 180 } 181 return this.leftOperand; 182 } 183 184 195 public void setLeftOperand(Expression expression) { 196 if (expression == null) { 197 throw new IllegalArgumentException (); 198 } 199 ASTNode oldChild = this.leftOperand; 200 preReplaceChild(oldChild, expression, LEFT_OPERAND_PROPERTY); 201 this.leftOperand = expression; 202 postReplaceChild(oldChild, expression, LEFT_OPERAND_PROPERTY); 203 } 204 205 210 public Type getRightOperand() { 211 if (this.rightOperand == null) { 212 synchronized (this) { 214 if (this.rightOperand == null) { 215 preLazyInit(); 216 this.rightOperand= new SimpleType(this.ast); 217 postLazyInit(this.rightOperand, RIGHT_OPERAND_PROPERTY); 218 } 219 } 220 } 221 return this.rightOperand; 222 } 223 224 235 public void setRightOperand(Type referenceType) { 236 if (referenceType == null) { 237 throw new IllegalArgumentException (); 238 } 239 ASTNode oldChild = this.rightOperand; 240 preReplaceChild(oldChild, referenceType, RIGHT_OPERAND_PROPERTY); 241 this.rightOperand = referenceType; 242 postReplaceChild(oldChild, referenceType, RIGHT_OPERAND_PROPERTY); 243 } 244 245 248 int memSize() { 249 return BASE_NODE_SIZE + 2 * 4; 251 } 252 253 256 int treeSize() { 257 return 258 memSize() 259 + (this.leftOperand == null ? 0 : getLeftOperand().treeSize()) 260 + (this.rightOperand == null ? 0 : getRightOperand().treeSize()); 261 } 262 } 263 | Popular Tags |