/** * This tells the current loop to stop after the current iteration. * This is different from "break" common to most programming languages, * in that it does not immediately cease activity in the current iteration. * Instead, it merely tells the #foreach loop that this is the last time * around. */ public void stop() { // if we have an iterator on the stack if (!iterators.empty()) { // stop the top one, so #foreach doesn't loop again iterators.peek().stop(); } }
/** * This is just like {@link #stop()} except that the stop command is issued * <strong>only</strong> to the loop/iterator with the specified name. * If no such loop is found with that name, then no stop command is issued. * @param name loop name * @see #stop() */ public void stop(String name) { // just stop the matching one for (ManagedIterator iterator : iterators) { if (iterator.getName().equals(name)) { iterator.stop(); break; } } }
/** * This is just like {@link #stop()} except that the stop command is issued * <strong>all</strong> the loops being watched by this tool. * @see #stop() */ public void stopAll() { // just stop them all for (ManagedIterator iterator : iterators) { iterator.stop(); } }