1 16 17 package org.apache.taglibs.standard.tag.el.fmt; 18 19 import java.util.Locale ; 20 21 import javax.servlet.jsp.JspException ; 22 23 import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager; 24 import org.apache.taglibs.standard.tag.common.fmt.ParseNumberSupport; 25 import org.apache.taglibs.standard.tag.common.fmt.SetLocaleSupport; 26 27 33 34 public class ParseNumberTag extends ParseNumberSupport { 35 36 39 private String value_; private String type_; private String pattern_; private String parseLocale_; private String integerOnly_; 45 46 49 54 public ParseNumberTag() { 55 super(); 56 init(); 57 } 58 59 60 63 public int doStartTag() throws JspException { 65 66 evaluateExpressions(); 68 69 return super.doStartTag(); 71 } 72 73 public void release() { 75 super.release(); 76 init(); 77 } 78 79 80 83 public void setValue(String value_) { 85 this.value_ = value_; 86 this.valueSpecified = true; 87 } 88 89 public void setType(String type_) { 91 this.type_ = type_; 92 } 93 94 public void setPattern(String pattern_) { 96 this.pattern_ = pattern_; 97 } 98 99 public void setParseLocale(String parseLocale_) { 101 this.parseLocale_ = parseLocale_; 102 } 103 104 public void setIntegerOnly(String integerOnly_) { 106 this.integerOnly_ = integerOnly_; 107 this.integerOnlySpecified = true; 108 } 109 110 111 114 private void init() { 116 value_ = type_ = pattern_ = parseLocale_ = integerOnly_ = null; 118 } 119 120 private void evaluateExpressions() throws JspException { 122 Object obj = null; 123 124 131 132 if (value_ != null) { 134 value = (String ) ExpressionEvaluatorManager.evaluate( 135 "value", value_, String .class, this, pageContext); 136 } 137 138 if (type_ != null) { 140 type = (String ) ExpressionEvaluatorManager.evaluate( 141 "type", type_, String .class, this, pageContext); 142 } 143 144 if (pattern_ != null) { 146 pattern = (String ) ExpressionEvaluatorManager.evaluate( 147 "pattern", pattern_, String .class, this, pageContext); 148 } 149 150 if (parseLocale_ != null) { 152 obj = ExpressionEvaluatorManager.evaluate( 153 "parseLocale", parseLocale_, Object .class, this, pageContext); 154 if (obj != null) { 155 if (obj instanceof Locale ) { 156 parseLocale = (Locale ) obj; 157 } else { 158 String localeStr = (String ) obj; 159 if (!"".equals(localeStr)) { 160 parseLocale = SetLocaleSupport.parseLocale(localeStr); 161 } 162 } 163 } 164 } 165 166 if (integerOnly_ != null) { 168 obj = ExpressionEvaluatorManager.evaluate( 169 "integerOnly", integerOnly_, Boolean .class, this, pageContext); 170 if (obj != null) { 171 isIntegerOnly = ((Boolean ) obj).booleanValue(); 172 } 173 } 174 } 175 } 176 177 | Popular Tags |