com.mockrunner.tag
Class TagUtil

java.lang.Object
  extended bycom.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.
static void dumpTagTree(java.util.List bodyList, java.lang.StringBuffer buffer, int level)
          Helper method to dump tags incl.
static void evalBody(java.util.List bodyList, java.lang.Object pageContext)
          Handles body evaluation of a tag.
static void populateTag(java.lang.Object tag, java.util.Map attributes, boolean doRelease)
          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 resp. 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 resp. 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

populateTag

public static void populateTag(java.lang.Object tag,
                               java.util.Map attributes,
                               boolean doRelease)
Populates the specified attributes to the specified tag. Calls the release method before populating, if doRelease is set to true.

Parameters:
tag - the tag
attributes - the attribute map
doRelease - should release be called

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.