1 16 17 package org.apache.taglibs.standard.tag.el.fmt; 18 19 import javax.servlet.jsp.JspException ; 20 21 import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager; 22 import org.apache.taglibs.standard.tag.common.fmt.FormatNumberSupport; 23 24 30 31 public class FormatNumberTag extends FormatNumberSupport { 32 33 36 private String value_; private String type_; private String pattern_; private String currencyCode_; private String currencySymbol_; private String groupingUsed_; private String maxIntegerDigits_; private String minIntegerDigits_; private String maxFractionDigits_; private String minFractionDigits_; 47 48 51 56 public FormatNumberTag() { 57 super(); 58 init(); 59 } 60 61 62 65 public int doStartTag() throws JspException { 67 68 evaluateExpressions(); 70 71 return super.doStartTag(); 73 } 74 75 public void release() { 77 super.release(); 78 init(); 79 } 80 81 82 85 public void setValue(String value_) { 87 this.value_ = value_; 88 this.valueSpecified = true; 89 } 90 91 public void setType(String type_) { 93 this.type_ = type_; 94 } 95 96 public void setPattern(String pattern_) { 98 this.pattern_ = pattern_; 99 } 100 101 public void setCurrencyCode(String currencyCode_) { 103 this.currencyCode_ = currencyCode_; 104 } 105 106 public void setCurrencySymbol(String currencySymbol_) { 108 this.currencySymbol_ = currencySymbol_; 109 } 110 111 public void setGroupingUsed(String groupingUsed_) { 113 this.groupingUsed_ = groupingUsed_; 114 this.groupingUsedSpecified = true; 115 } 116 117 public void setMaxIntegerDigits(String maxIntegerDigits_) { 119 this.maxIntegerDigits_ = maxIntegerDigits_; 120 this.maxIntegerDigitsSpecified = true; 121 } 122 123 public void setMinIntegerDigits(String minIntegerDigits_) { 125 this.minIntegerDigits_ = minIntegerDigits_; 126 this.minIntegerDigitsSpecified = true; 127 } 128 129 public void setMaxFractionDigits(String maxFractionDigits_) { 131 this.maxFractionDigits_ = maxFractionDigits_; 132 this.maxFractionDigitsSpecified = true; 133 } 134 135 public void setMinFractionDigits(String minFractionDigits_) { 137 this.minFractionDigits_ = minFractionDigits_; 138 this.minFractionDigitsSpecified = true; 139 } 140 141 142 145 private void init() { 147 value_ = type_ = pattern_ = null; 149 currencyCode_ = currencySymbol_ = null; 150 groupingUsed_ = null; 151 maxIntegerDigits_ = minIntegerDigits_ = null; 152 maxFractionDigits_ = minFractionDigits_ = null; 153 } 154 155 private void evaluateExpressions() throws JspException { 157 Object obj = null; 158 159 166 167 if (value_ != null) { 169 value = ExpressionEvaluatorManager.evaluate( 170 "value", value_, Object .class, this, pageContext); 171 } 172 173 if (type_ != null) { 175 type = (String ) ExpressionEvaluatorManager.evaluate( 176 "type", type_, String .class, this, pageContext); 177 } 178 179 if (pattern_ != null) { 181 pattern = (String ) ExpressionEvaluatorManager.evaluate( 182 "pattern", pattern_, String .class, this, pageContext); 183 } 184 185 if (currencyCode_ != null) { 187 currencyCode = (String ) ExpressionEvaluatorManager.evaluate( 188 "currencyCode", currencyCode_, String .class, this, 189 pageContext); 190 } 191 192 if (currencySymbol_ != null) { 194 currencySymbol = (String ) ExpressionEvaluatorManager.evaluate( 195 "currencySymbol", currencySymbol_, String .class, this, 196 pageContext); 197 } 198 199 if (groupingUsed_ != null) { 201 obj = ExpressionEvaluatorManager.evaluate( 202 "groupingUsed", groupingUsed_, Boolean .class, this, 203 pageContext); 204 if (obj != null) { 205 isGroupingUsed = ((Boolean ) obj).booleanValue(); 206 } 207 } 208 209 if (maxIntegerDigits_ != null) { 211 obj = ExpressionEvaluatorManager.evaluate( 212 "maxIntegerDigits", maxIntegerDigits_, Integer .class, this, 213 pageContext); 214 if (obj != null) { 215 maxIntegerDigits = ((Integer ) obj).intValue(); 216 } 217 } 218 219 if (minIntegerDigits_ != null) { 221 obj = ExpressionEvaluatorManager.evaluate( 222 "minIntegerDigits", minIntegerDigits_, Integer .class, this, 223 pageContext); 224 if (obj != null) { 225 minIntegerDigits = ((Integer ) obj).intValue(); 226 } 227 } 228 229 if (maxFractionDigits_ != null) { 231 obj = ExpressionEvaluatorManager.evaluate( 232 "maxFractionDigits", maxFractionDigits_, Integer .class, this, 233 pageContext); 234 if (obj != null) { 235 maxFractionDigits = ((Integer ) obj).intValue(); 236 } 237 } 238 239 if (minFractionDigits_ != null) { 241 obj = ExpressionEvaluatorManager.evaluate( 242 "minFractionDigits", minFractionDigits_, Integer .class, this, 243 pageContext); 244 if (obj != null) { 245 minFractionDigits = ((Integer ) obj).intValue(); 246 } 247 } 248 } 249 } 250 251 | Popular Tags |