1 23 24 package org.objectweb.medor.expression.lib; 25 26 import org.objectweb.medor.expression.api.Expression; 27 import org.objectweb.medor.expression.api.UnaryOperator; 28 import org.objectweb.jorm.type.api.PType; 29 30 34 public abstract class BasicUnaryOperator extends BasicOperator 35 implements UnaryOperator { 36 37 public BasicUnaryOperator() { 38 super(new Expression[1]); 39 } 40 41 public BasicUnaryOperator(PType type) { 42 super(type, new Expression[1]); 43 } 44 45 public BasicUnaryOperator(Expression e) { 46 super(new Expression[]{e}); 47 } 48 49 public BasicUnaryOperator(PType type, Expression e) { 50 super(type, new Expression[]{e}); 51 } 52 53 56 public int getOperandNumber() { 57 return 1; 58 } 59 60 public Expression getExpression(int idx) 61 throws ArrayIndexOutOfBoundsException { 62 if (idx == 0) 63 return getExpression(); 64 else 65 throw new ArrayIndexOutOfBoundsException (idx); 66 } 67 68 public void setExpression(int idx, Expression exp) 69 throws ArrayIndexOutOfBoundsException { 70 if (idx == 0) 71 setExpression(exp); 72 else 73 throw new ArrayIndexOutOfBoundsException (idx); 74 } 75 76 79 public void setExpression(Expression e) throws IllegalStateException { 80 if (!verified){ 81 expressions[0] = e; 82 } 83 else 84 throw new IllegalStateException ("Compiled expression can't be modified"); 85 } 86 87 public Expression getExpression() { 88 return expressions[0]; 89 } 90 91 } 92 | Popular Tags |