1 16 17 package org.apache.taglibs.standard.tag.el.core; 18 19 import javax.servlet.jsp.JspException ; 20 import javax.servlet.jsp.jstl.core.LoopTag; 21 import javax.servlet.jsp.tagext.IterationTag ; 22 23 import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager; 24 import org.apache.taglibs.standard.tag.common.core.ForTokensSupport; 25 import org.apache.taglibs.standard.tag.common.core.NullAttributeException; 26 27 33 public class ForTokensTag 34 extends ForTokensSupport 35 implements LoopTag, IterationTag 36 { 37 38 41 private String begin_; private String end_; private String step_; private String items_; private String delims_; 47 48 51 public ForTokensTag() { 52 super(); 53 init(); 54 } 55 56 57 60 61 public int doStartTag() throws JspException { 62 63 evaluateExpressions(); 65 66 return super.doStartTag(); 68 } 69 70 71 public void release() { 73 super.release(); 74 init(); 75 } 76 77 78 81 public void setBegin(String begin_) { 83 this.begin_ = begin_; 84 this.beginSpecified = true; 85 } 86 87 public void setEnd(String end_) { 89 this.end_ = end_; 90 this.endSpecified = true; 91 } 92 93 public void setStep(String step_) { 95 this.step_ = step_; 96 this.stepSpecified = true; 97 } 98 99 public void setItems(String items_) { 101 this.items_ = items_; 102 } 103 104 public void setDelims(String delims_) { 106 this.delims_ = delims_; 107 } 108 109 110 113 private void init() { 115 begin_ = null; end_ = null; step_ = null; items_ = null; delims_ = null; } 122 123 124 private void evaluateExpressions() throws JspException { 125 132 133 if (begin_ != null) { 134 Object r = ExpressionEvaluatorManager.evaluate( 135 "begin", begin_, Integer .class, this, pageContext); 136 if (r == null) 137 throw new NullAttributeException("forTokens", "begin"); 138 begin = ((Integer ) r).intValue(); 139 validateBegin(); 140 } 141 142 if (end_ != null) { 143 Object r = ExpressionEvaluatorManager.evaluate( 144 "end", end_, Integer .class, this, pageContext); 145 if (r == null) 146 throw new NullAttributeException("forTokens", "end"); 147 end = ((Integer ) r).intValue(); 148 validateEnd(); 149 } 150 151 if (step_ != null) { 152 Object r = ExpressionEvaluatorManager.evaluate( 153 "step", step_, Integer .class, this, pageContext); 154 if (r == null) 155 throw new NullAttributeException("forTokens", "step"); 156 step = ((Integer ) r).intValue(); 157 validateStep(); 158 } 159 160 if (items_ != null) { 161 items = (String ) ExpressionEvaluatorManager.evaluate( 162 "items", items_, String .class, this, pageContext); 163 if (items == null) 165 items = ""; 166 } 167 168 if (delims_ != null) { 169 delims = (String ) ExpressionEvaluatorManager.evaluate( 170 "delims", delims_, String .class, this, pageContext); 171 if (delims == null) 173 delims = ""; 174 } 175 } 176 } 177 | Popular Tags |