org.apache.cocoon.taglib.core
Class ForEachSupport

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.taglib.TagSupport
          extended by org.apache.cocoon.taglib.VarTagSupport
              extended by org.apache.cocoon.taglib.core.LoopTagSupport
                  extended by org.apache.cocoon.taglib.core.ForEachSupport
All Implemented Interfaces:
Poolable, Recyclable, Component, LogEnabled, Serviceable, LoopTag, IterationTag, Tag
Direct Known Subclasses:
ForEachTag

public abstract class ForEachSupport
extends LoopTagSupport

Support for tag handlers for <forEach>, the core iteration tag in JSTL 1.0. This class extends LoopTagSupport and provides ForEach-specific functionality. The rtexprvalue library and the expression-evaluating library each have handlers that extend this class.

Localized here is the logic for handling the veritable smorgasbord of types supported by <forEach>, including arrays, Collections, and others. To see how the actual iteration is controlled, review the org.apache.cocoon.taglib.core.LoopTagSupport class instead.

Version:
CVS $Id: ForEachSupport.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Volker Schmitt
See Also:
Migration from JSTL1.0, org.apache.taglibs.standard.tag.common.core

Nested Class Summary
protected static interface ForEachSupport.ForEachIterator
           
protected static class ForEachSupport.SimpleForEachIterator
           
 
Field Summary
protected  ForEachSupport.ForEachIterator items
           
protected  Object rawItems
           
 
Fields inherited from class org.apache.cocoon.taglib.core.LoopTagSupport
begin, beginSpecified, count, end, endSpecified, index, last, statusId, step, stepSpecified
 
Fields inherited from class org.apache.cocoon.taglib.VarTagSupport
manager, var
 
Fields inherited from class org.apache.cocoon.taglib.TagSupport
objectModel, parameters, parent, resolver
 
Fields inherited from interface org.apache.cocoon.taglib.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface org.apache.cocoon.taglib.Tag
EVAL_BODY, EVAL_PAGE, ROLE, SKIP_BODY
 
Constructor Summary
ForEachSupport()
           
 
Method Summary
protected  boolean hasNext()
          Returns information concerning the availability of more items over which to iterate.
protected  Object next()
          Returns the next object over which the tag should iterate.
protected  void prepare()
          Prepares for a single tag invocation.
 void recycle()
           
protected  ForEachSupport.ForEachIterator supportedTypeForEachIterator(Object o)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(boolean[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(byte[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(char[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(Collection c)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(double[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(Enumeration e)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(float[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(int[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(Iterator i)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(long[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(Map m)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(Object o)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(Object[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(ResultSet rs)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(short[] a)
           
protected  ForEachSupport.ForEachIterator toForEachIterator(String s)
           
 
Methods inherited from class org.apache.cocoon.taglib.core.LoopTagSupport
doAfterBody, doCatch, doFinally, doStartTag, getCurrent, getIteratorStatus, setVarStatus, validateBegin, validateEnd, validateStep
 
Methods inherited from class org.apache.cocoon.taglib.VarTagSupport
getRequest, getVar, getVariable, removeVariable, service, setVar, setVariable
 
Methods inherited from class org.apache.cocoon.taglib.TagSupport
doEndTag, findAncestorWithClass, findAttribute, getParent, setParent, setup
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.taglib.Tag
doEndTag, getParent, setParent, setup
 

Field Detail

items

protected ForEachSupport.ForEachIterator items

rawItems

protected Object rawItems
Constructor Detail

ForEachSupport

public ForEachSupport()
Method Detail

hasNext

protected boolean hasNext()
                   throws SAXException
Description copied from class: LoopTagSupport

Returns information concerning the availability of more items over which to iterate. This method must be provided by concrete subclasses of LoopTagSupport to assist the iterative logic provided by the supporting base class.

See next for more information about the purpose and expectations behind this tag.

Specified by:
hasNext in class LoopTagSupport
Returns:
true if there is at least one more item to iterate over, false otherwise
Throws:
SAXException
See Also:
LoopTagSupport.next()

next

protected Object next()
               throws SAXException
Description copied from class: LoopTagSupport

Returns the next object over which the tag should iterate. This method must be provided by concrete subclasses of LoopTagSupport to inform the base logic about what objects it should iterate over.

It is expected that this method will generally be backed by an Iterator, but this will not always be the case. In particular, if retrieving the next object raises the possibility of an exception being thrown, this method allows that exception to propagate back to the container as a SAXException; a standalone Iterator would not be able to do this. (This explains why LoopTagSupport does not simply call for an Iterator from its subtags.)

Specified by:
next in class LoopTagSupport
Returns:
the java.lang.Object to use in the next round of iteration
Throws:
SAXException - for other, unexpected exceptions

prepare

protected void prepare()
                throws SAXException
Description copied from class: LoopTagSupport

Prepares for a single tag invocation. Specifically, allows subclasses to prepare for calls to hasNext() and next(). Subclasses can assume that prepare() will be called once for each invocation of doStartTag() in the superclass.

Specified by:
prepare in class LoopTagSupport
Throws:
SAXException

recycle

public void recycle()
Specified by:
recycle in interface Recyclable
Overrides:
recycle in class LoopTagSupport

supportedTypeForEachIterator

protected ForEachSupport.ForEachIterator supportedTypeForEachIterator(Object o)
                                                               throws SAXException
Throws:
SAXException

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(Object o)
                                                    throws SAXException
Throws:
SAXException

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(Object[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(boolean[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(byte[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(char[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(short[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(int[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(long[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(float[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(double[] a)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(Collection c)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(Iterator i)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(Enumeration e)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(Map m)

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(ResultSet rs)
                                                    throws SAXException
Throws:
SAXException

toForEachIterator

protected ForEachSupport.ForEachIterator toForEachIterator(String s)


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.