/** * */ package de.fhswf.in.inf.fit.aufgabe4; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.BodyTagSupport; /** * Handler for the repeat tag. * * @author Stefan Suhren * @version 1.0 */ public class Repeat extends BodyTagSupport { /** * Required attribute for {@link BodyTagSupport}. */ private static final long serialVersionUID = 1L; /** * The number of times the Body will be printed. */ private int times = 0; /** * Getter for property times. * * @return Returns the times. */ public int getTimes() { return times; } /** * Setter for property times. * * @param times * The times to set. */ public void setTimes(int times) { this.times = times; } /* * Make sure that the input body will be printed. * * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag() */ @Override public int doStartTag() throws JspException { if (times <= 0) { return SKIP_BODY; } else { return EVAL_BODY_INCLUDE; } } /* * Repeat the body a given time. * * @see javax.servlet.jsp.tagext.BodyTagSupport#doAfterBody() */ @Override public int doAfterBody() throws JspException { if (--times > 0) { return EVAL_BODY_AGAIN; } else { return SKIP_BODY; } } }