1 13 package com.tonbeller.jpivot.olap.model.impl; 14 15 import java.util.ArrayList ; 16 import java.util.List ; 17 18 import com.tonbeller.jpivot.olap.model.Expression; 19 import com.tonbeller.jpivot.olap.model.FunCallExpr; 20 import com.tonbeller.jpivot.olap.model.PropertyExpr; 21 import com.tonbeller.jpivot.olap.model.StringExpr; 22 import com.tonbeller.jpivot.olap.model.Visitor; 23 import com.tonbeller.jpivot.olap.model.VisitorSupportSloppy; 24 25 28 public class PropertyExprImpl implements PropertyExpr { 29 30 private Expression valueExpr; 31 private String name; 32 33 37 public PropertyExprImpl(String name, Expression valueExpr) { 38 this.name = name; 39 this.valueExpr = valueExpr; 40 } 41 42 46 public Expression getValueExpr() { 47 return valueExpr; 48 } 49 50 54 public String getName() { 55 return name; 56 } 57 58 62 public String [] getChoices() { 63 64 final List choices = new ArrayList (); 65 66 this.accept(new VisitorSupportSloppy() { 67 public void visitStringExpr(StringExpr v) { 69 choices.add(v.getValue()); 70 } 71 72 public void visitFunCallExpr(FunCallExpr v) { 73 Expression[] args = v.getArgs(); 74 for (int i = 0; i < args.length; i++) { 75 args[i].accept(this); 76 } 77 } 78 79 public void visitPropertyExpr(PropertyExpr v) { 80 Expression exp = v.getValueExpr(); 81 exp.accept(this); 82 } 83 84 }); 85 86 return (String []) choices.toArray(new String [0]); 87 } 88 89 93 public void accept(Visitor visitor) { 94 visitor.visitPropertyExpr(this); 95 } 96 97 } | Popular Tags |