<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class InfixExpression extends Expression { public static class Operator { private String token ; private Operator ( String token ) { this . token = token ; } public String toString ( ) { return this . token ; } public static final Operator TIMES = new Operator ( "*" ) ; public static final Operator DIVIDE = new Operator ( "/" ) ; public static final Operator REMAINDER = new Operator ( "%" ) ; public static final Operator PLUS = new Operator ( "+" ) ; public static final Operator MINUS = new Operator ( "-" ) ; public static final Operator LEFT_SHIFT = new Operator ( "<<" ) ; public static final Operator RIGHT_SHIFT_SIGNED = new Operator ( ">>" ) ; public static final Operator RIGHT_SHIFT_UNSIGNED = new Operator ( ">>>" ) ; public static final Operator LESS = new Operator ( "<" ) ; public static final Operator GREATER = new Operator ( ">" ) ; public static final Operator LESS_EQUALS = new Operator ( "<=" ) ; public static final Operator GREATER_EQUALS = new Operator ( ">=" ) ; public static final Operator EQUALS = new Operator ( "==" ) ; public static final Operator NOT_EQUALS = new Operator ( "!=" ) ; public static final Operator XOR = new Operator ( "^" ) ; public static final Operator OR = new Operator ( "|" ) ; public static final Operator AND = new Operator ( "&" ) ; public static final Operator CONDITIONAL_OR = new Operator ( "||" ) ; public static final Operator CONDITIONAL_AND = new Operator ( "&&" ) ; private static final Map CODES ; static { CODES = new HashMap ( 20 ) ; Operator [ ] ops = { TIMES , DIVIDE , REMAINDER , PLUS , MINUS , LEFT_SHIFT , RIGHT_SHIFT_SIGNED , RIGHT_SHIFT_UNSIGNED , LESS , GREATER , LESS_EQUALS , GREATER_EQUALS , EQUALS , NOT_EQUALS , XOR , OR , AND , CONDITIONAL_OR , CONDITIONAL_AND , } ; for ( int i = 0 ; i < ops . length ; i ++ ) { CODES . put ( ops [ i ] . toString ( ) , ops [ i ] ) ; } } public static Operator toOperator ( String token ) { return ( Operator ) CODES . get ( token ) ; } } public static final ChildPropertyDescriptor LEFT_OPERAND_PROPERTY = new ChildPropertyDescriptor ( InfixExpression . class , "leftOperand" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final SimplePropertyDescriptor OPERATOR_PROPERTY = new SimplePropertyDescriptor ( InfixExpression . class , "operator" , InfixExpression . Operator . class , MANDATORY ) ; public static final ChildPropertyDescriptor RIGHT_OPERAND_PROPERTY = new ChildPropertyDescriptor ( InfixExpression . class , "rightOperand" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor EXTENDED_OPERANDS_PROPERTY = new ChildListPropertyDescriptor ( InfixExpression . class , "" , Expression . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( 5 ) ; createPropertyList ( InfixExpression . class , properyList ) ; addProperty ( LEFT_OPERAND_PROPERTY , properyList ) ; addProperty ( OPERATOR_PROPERTY , properyList ) ; addProperty ( RIGHT_OPERAND_PROPERTY , properyList ) ; addProperty ( EXTENDED_OPERANDS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private InfixExpression . Operator operator = InfixExpression . Operator . PLUS ; private Expression leftOperand = null ; private Expression rightOperand = null ; private ASTNode . NodeList extendedOperands = null ; InfixExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == OPERATOR_PROPERTY ) { if ( get ) { return getOperator ( ) ; } else { setOperator ( ( Operator ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == LEFT_OPERAND_PROPERTY ) { if ( get ) { return getLeftOperand ( ) ; } else { setLeftOperand ( ( Expression ) child ) ; return null ; } } if ( property == RIGHT_OPERAND_PROPERTY ) { if ( get ) { return getRightOperand ( ) ; } else { setRightOperand ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == EXTENDED_OPERANDS_PROPERTY ) { return extendedOperands ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return INFIX_EXPRESSION ; } ASTNode clone0 ( AST target ) { InfixExpression result = new InfixExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setOperator ( getOperator ( ) ) ; result . setLeftOperand ( ( Expression ) getLeftOperand ( ) . clone ( target ) ) ; result . setRightOperand ( ( Expression ) getRightOperand ( ) . clone ( target ) ) ; if ( this . extendedOperands != null ) { result . extendedOperands ( ) . addAll ( ASTNode . copySubtrees ( target , extendedOperands ( ) ) ) ; } return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getLeftOperand ( ) ) ; acceptChild ( visitor , getRightOperand ( ) ) ; if ( this . extendedOperands != null ) { acceptChildren ( visitor , this . extendedOperands ) ; } } visitor . endVisit ( this ) ; } public InfixExpression . Operator getOperator ( ) { return this . operator ; } public void setOperator ( InfixExpression . Operator operator ) { if ( operator == null ) { throw new IllegalArgumentException ( ) ; } preValueChange ( OPERATOR_PROPERTY ) ; this . operator = operator ; postValueChange ( OPERATOR_PROPERTY ) ; } public Expression getLeftOperand ( ) { if ( this . leftOperand == null ) { synchronized ( this ) { if ( this . leftOperand == null ) { preLazyInit ( ) ; this . leftOperand = new SimpleName ( this . ast ) ; postLazyInit ( this . leftOperand , LEFT_OPERAND_PROPERTY ) ; } } } return this . leftOperand ; } public void setLeftOperand ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . leftOperand ; preReplaceChild ( oldChild , expression , LEFT_OPERAND_PROPERTY ) ; this . leftOperand = expression ; postReplaceChild ( oldChild , expression , LEFT_OPERAND_PROPERTY ) ; } public Expression getRightOperand ( ) { if ( this . rightOperand == null ) { synchronized ( this ) { if ( this . rightOperand == null ) { preLazyInit ( ) ; this . rightOperand = new SimpleName ( this . ast ) ; postLazyInit ( this . rightOperand , RIGHT_OPERAND_PROPERTY ) ; } } } return this . rightOperand ; } public void setRightOperand ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . rightOperand ; preReplaceChild ( oldChild , expression , RIGHT_OPERAND_PROPERTY ) ; this . rightOperand = expression ; postReplaceChild ( oldChild , expression , RIGHT_OPERAND_PROPERTY ) ; } public boolean hasExtendedOperands ( ) { return ( this . extendedOperands != null ) && this . extendedOperands . size ( ) > 0 ; } public List extendedOperands ( ) { if ( this . extendedOperands == null ) { this . extendedOperands = new ASTNode . NodeList ( EXTENDED_OPERANDS_PROPERTY ) ; } return this . extendedOperands ; } int memSize ( ) { return BASE_NODE_SIZE + 4 * 4 ; } int treeSize ( ) { return memSize ( ) + ( this . leftOperand == null ? 0 : getLeftOperand ( ) . treeSize ( ) ) + ( this . rightOperand == null ? 0 : getRightOperand ( ) . treeSize ( ) ) + ( this . extendedOperands == null ? 0 : this . extendedOperands . listSize ( ) ) ; } } </s>