1 package org.jacorb.notification.filter.etcl; 2 3 23 24 import org.jacorb.notification.filter.EvaluationContext; 25 import org.jacorb.notification.filter.EvaluationResult; 26 27 import antlr.Token; 28 29 34 35 public class NumberValue extends AbstractTCLNode 36 { 37 38 private Double number_; 39 40 private EvaluationResult result_; 41 42 public Double getNumber() 43 { 44 return number_; 45 } 46 47 public NumberValue(Token tok) 48 { 49 super(tok); 50 51 setName("NumberValue"); 52 53 EvaluationResult _r = new EvaluationResult(); 54 number_ = new Double (tok.getText()); 55 56 int t = getType(); 57 58 switch (t) { 59 case NUMBER: 60 _r.setLong(number_); 61 break; 62 case NUM_FLOAT: 63 _r.setFloat(number_); 64 break; 65 default: 66 throw new RuntimeException (); 67 } 68 69 result_ = EvaluationResult.wrapImmutable(_r); 70 } 71 72 public EvaluationResult evaluate(EvaluationContext context) 73 { 74 return result_; 75 } 76 77 public String toString() 78 { 79 switch (getType()) { 80 case NUM_FLOAT: 81 return "" + number_.floatValue(); 82 default: 83 return "" + number_.longValue(); 84 } 85 } 86 87 public boolean isStatic() 88 { 89 return true; 90 } 91 92 public boolean isNumber() 93 { 94 return true; 95 } 96 97 public void acceptInOrder(AbstractTCLVisitor visitor) throws VisitorException 98 { 99 visitor.visitNumber(this); 100 } 101 102 public void acceptPostOrder(AbstractTCLVisitor visitor) throws VisitorException 103 { 104 visitor.visitNumber(this); 105 } 106 107 public void acceptPreOrder(AbstractTCLVisitor visitor) throws VisitorException 108 { 109 visitor.visitNumber(this); 110 } 111 } | Popular Tags |