1 16 package org.apache.cocoon.woody.formmodel; 17 18 import org.outerj.expression.ExpressionContext; 19 20 import java.math.BigDecimal ; 21 22 28 public class ExpressionContextImpl implements ExpressionContext { 29 private Widget widget; 30 private boolean referenceChildren; 31 32 public ExpressionContextImpl(Widget widget) { 33 this.widget = widget; 34 this.referenceChildren = false; 35 } 36 37 41 public ExpressionContextImpl(Widget widget, boolean referenceChildren) { 42 this.widget = widget; 43 this.referenceChildren = referenceChildren; 44 } 45 46 64 public Object resolveVariable(String name) { 65 Widget widget; 67 if (!referenceChildren) 68 widget = this.widget.getParent().getWidget(name); 69 else 70 widget = this.widget.getWidget(name); 71 if (widget != null) { 72 Object value = widget.getValue(); 73 74 if (value == null && widget.isRequired()) { 75 throw new CannotYetResolveWarning(); 79 } 80 81 if (value instanceof Long ) 85 return new BigDecimal (((Long )value).longValue()); 86 else if (value instanceof Integer ) 87 return new BigDecimal (((Integer )value).intValue()); 88 else 89 return value; 90 } 91 return null; 92 } 93 94 public Object get(String s) { 95 return null; 96 } 97 98 } 99 | Popular Tags |