FileDocCategorySizeDatePackage
ForTokensTag.javaAPI DocGlassfish v2 API6986Sat May 05 19:17:56 BST 2007org.apache.taglibs.standard.tag.el.core

ForTokensTag

public class ForTokensTag extends org.apache.taglibs.standard.tag.common.core.ForTokensSupport implements javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.jstl.core.LoopTag

A handler for <forTokens> that accepts attributes as Strings and evaluates them as expressions at runtime.

author
Shawn Bayern

Fields Summary
private String
begin_
private String
end_
private String
step_
private String
items_
private String
delims_
Constructors Summary
public ForTokensTag()

        super();
        init();
    
Methods Summary
public intdoStartTag()


        // evaluate any expressions we were passed, once per invocation
        evaluateExpressions();

	// chain to the parent implementation
	return super.doStartTag();
    
private voidevaluateExpressions()

        /*
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

       if (begin_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                "begin", begin_, Integer.class, this, pageContext);
            if (r == null)
                throw new NullAttributeException("forTokens", "begin");
            begin = ((Integer) r).intValue();
            validateBegin();
        }

        if (end_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                "end", end_, Integer.class, this, pageContext);
            if (r == null)
                throw new NullAttributeException("forTokens", "end");
            end = ((Integer) r).intValue();
            validateEnd();
        }

        if (step_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                "step", step_, Integer.class, this, pageContext);
            if (r == null)
                throw new NullAttributeException("forTokens", "step");
            step = ((Integer) r).intValue();
            validateStep();
        }

        if (items_ != null) {
            items = (String) ExpressionEvaluatorManager.evaluate(
                "items", items_, String.class, this, pageContext);
	    // use the empty string to indicate "no iteration"
	    if (items == null)
		items = "";
	}

        if (delims_ != null) {
            delims = (String) ExpressionEvaluatorManager.evaluate(
                "delims", delims_, String.class, this, pageContext);
	    // use the empty string to cause monolithic tokenization
	    if (delims == null)
		delims = "";
	}
    
private voidinit()

        // defaults for interface with page author
        begin_ = null;          // (no expression)
        end_ = null;            // (no expression)
        step_ = null;           // (no expression)
	items_ = null;		// (no expression)
	delims_ = null;		// (no expression)
    
public voidrelease()

        super.release();
        init();
    
public voidsetBegin(java.lang.String begin_)

        this.begin_ = begin_;
        this.beginSpecified = true;
    
public voidsetDelims(java.lang.String delims_)

	this.delims_ = delims_;
    
public voidsetEnd(java.lang.String end_)

        this.end_ = end_;
        this.endSpecified = true;
    
public voidsetItems(java.lang.String items_)

        this.items_ = items_;
    
public voidsetStep(java.lang.String step_)

        this.step_ = step_;
        this.stepSpecified = true;