com.mockrunner.tag
Class TagUtil

java.lang.Object
  extended by com.mockrunner.tag.TagUtil

public class TagUtil
extends java.lang.Object

Util class for tag test framework. Please note, that the methods of this class take Object parameters where JspTag or JspContext would be suitable. The reason is, that these classes do not exist in J2EE 1.3. This class is usable with J2EE 1.3 and J2EE 1.4.


Constructor Summary
TagUtil()
           
 
Method Summary
static java.lang.Object createNestedTagInstance(java.lang.Class tag, java.lang.Object pageContext, java.util.Map attributes)
          Creates an NestedTag instance wrapping the specified tag.
static java.lang.Object createNestedTagInstance(java.lang.Object tag, java.lang.Object pageContext, java.util.Map attributes)
          Creates an NestedTag instance wrapping the specified tag.
static java.lang.String dumpTag(NestedTag tag, java.lang.StringBuffer buffer, int level)
          Helper method to dump tags incl. child tags.
static void dumpTagTree(java.util.List bodyList, java.lang.StringBuffer buffer, int level)
          Helper method to dump tags incl. child tags.
static void evalBody(java.util.List bodyList, java.lang.Object pageContext)
          Handles body evaluation of a tag.
static void handleException(javax.servlet.jsp.tagext.Tag tag, java.lang.Throwable exc)
          Handles an exception that is thrown during tag lifecycle processing.
static void handleFinally(javax.servlet.jsp.tagext.Tag tag)
          Handles the finally block of tag lifecycle processing.
static void populateTag(java.lang.Object tag, java.util.Map attributes)
          Populates the specified attributes to the specified tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagUtil

public TagUtil()
Method Detail

createNestedTagInstance

public static java.lang.Object createNestedTagInstance(java.lang.Class tag,
                                                       java.lang.Object pageContext,
                                                       java.util.Map attributes)
Creates an NestedTag instance wrapping the specified tag. Returns an instance of NestedStandardTag or NestedBodyTag depending on the type of specified tag.

Parameters:
tag - the tag class
pageContext - the corresponding PageContext or JspContext
attributes - the attribute map
Returns:
the instance of NestedTag
Throws:
java.lang.IllegalArgumentException - if tag is null

createNestedTagInstance

public static java.lang.Object createNestedTagInstance(java.lang.Object tag,
                                                       java.lang.Object pageContext,
                                                       java.util.Map attributes)
Creates an NestedTag instance wrapping the specified tag. Returns an instance of NestedStandardTag or NestedBodyTag depending on the type of specified tag.

Parameters:
tag - the tag
pageContext - the corresponding PageContext or JspContext
attributes - the attribute map
Returns:
the instance of NestedTag
Throws:
java.lang.IllegalArgumentException - if tag is null

handleException

public static void handleException(javax.servlet.jsp.tagext.Tag tag,
                                   java.lang.Throwable exc)
                            throws javax.servlet.jsp.JspException
Handles an exception that is thrown during tag lifecycle processing. Invokes doCatch(), if the tag implements TryCatchFinally.

Parameters:
tag - the tag
exc - the exception to be handled
Throws:
javax.servlet.jsp.JspException

handleFinally

public static void handleFinally(javax.servlet.jsp.tagext.Tag tag)
Handles the finally block of tag lifecycle processing. Invokes doFinally(), if the tag implements TryCatchFinally.

Parameters:
tag - the tag

populateTag

public static void populateTag(java.lang.Object tag,
                               java.util.Map attributes)
Populates the specified attributes to the specified tag.

Parameters:
tag - the tag
attributes - the attribute map

evalBody

public static void evalBody(java.util.List bodyList,
                            java.lang.Object pageContext)
                     throws javax.servlet.jsp.JspException
Handles body evaluation of a tag. Iterated through the childs. If the child is an instance of NestedTag, the NestedTag.doLifecycle() method of this tag is called. If the child is an instance of DynamicChild, the DynamicChild.evaluate() method is called and the result is written to the out JspWriter as a string. If the result is another object (usually a string) it is written to the out JspWriter (the toString method will be called).

Parameters:
bodyList - the list of body entries
pageContext - the corresponding PageContext or JspContext
Throws:
javax.servlet.jsp.JspException

dumpTag

public static java.lang.String dumpTag(NestedTag tag,
                                       java.lang.StringBuffer buffer,
                                       int level)
Helper method to dump tags incl. child tags.


dumpTagTree

public static void dumpTagTree(java.util.List bodyList,
                               java.lang.StringBuffer buffer,
                               int level)
Helper method to dump tags incl. child tags.