/** * Sets loop count. */ public void setCount(final int count) { setEnd(count); isCount = true; }
loopTag.setStart(0); loopTag.setEnd(2); loopTag.doTag(); loopTag.setStep(2); loopTag.doTag(); assertEquals(2, jspFragment.count); loopTag.setEnd(5); loopTag.setStep(1); loopTag.doTag(); assertEquals(6, jspFragment.count); loopTag.setStatus("s"); loopTag.doTag(); assertNull(jspContext.getAttribute("s")); // attribute was cleared loopTag.setModulus(3); loopTag.doTag();
@Override public void doTag() throws JspException { if (!isEndSpecified) { throw new IllegalArgumentException("End boundary of the loop is not specified"); } prepareStepDirection(); if (isCount) { if (end < 0) { throw new IllegalArgumentException("Negative count value"); } end = start + step * (end - 1); } prepareStepDirection(autoDirection, false); // exclusive if (isExclusive) { if (step > 0) { this.end--; } else if (step < 0) { this.end++; } } loopBody(); } }
/** * Sets TO loop value (exclusive). */ public void setTo(final int to) { setEnd(to); isExclusive = true; }