com.mockrunner.tag
Class NestedBodyTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.mockrunner.tag.NestedBodyTag
All Implemented Interfaces:
NestedTag, java.io.Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class NestedBodyTag
extends javax.servlet.jsp.tagext.BodyTagSupport
implements NestedTag

Implementation of NestedTag wrapping tags of type BodyTag. NestedBodyTag instances are created with the help of TagTestModule.createNestedTag(java.lang.Class). You do not need to create them on your own in the tests.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
NestedBodyTag(javax.servlet.jsp.tagext.BodyTag tag, javax.servlet.jsp.PageContext pageContext)
          Constructor for a tag with an empty attribute map.
NestedBodyTag(javax.servlet.jsp.tagext.BodyTag tag, javax.servlet.jsp.PageContext pageContext, java.util.Map attributes)
          Constructor for a tag with the specified attribute map.
NestedBodyTag(javax.servlet.jsp.tagext.BodyTagSupport tag, javax.servlet.jsp.PageContext pageContext)
          Constructor for a tag with an empty attribute map.
NestedBodyTag(javax.servlet.jsp.tagext.BodyTagSupport tag, javax.servlet.jsp.PageContext pageContext, java.util.Map attributes)
          Constructor for a tag with the specified attribute map.
 
Method Summary
 void addDynamicChild(DynamicChild child)
          Adds a dynamic child simulating scriptlets and EL expressions.
 NestedTag addTagChild(java.lang.Class tag)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(java.lang.Class tag, java.util.Map attributeMap)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag, java.util.Map attributeMap)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(javax.servlet.jsp.tagext.TagSupport tag)
          Adds a tag child simulating nested tags.
 NestedTag addTagChild(javax.servlet.jsp.tagext.TagSupport tag, java.util.Map attributeMap)
          Adds a tag child simulating nested tags.
 void addTextChild(java.lang.String text)
          Adds a text child simulating static body content.
 int doAfterBody()
          Delegates to wrapped tag.
 int doEndTag()
          Delegates to wrapped tag.
 void doInitBody()
          Delegates to wrapped tag.
 int doLifecycle()
          Performs the tag lifecycle.
 int doStartTag()
          Delegates to wrapped tag.
 javax.servlet.jsp.tagext.BodyContent getBodyContent()
          Delegates to wrapped tag.
 java.lang.Object getChild(int index)
          Returns a child specified by its index.
 java.util.List getChilds()
          Returns the List of childs.
 java.lang.String getId()
          Delegates to wrapped tag.
 javax.servlet.jsp.tagext.Tag getParent()
          Delegates to wrapped tag.
 javax.servlet.jsp.JspWriter getPreviousOut()
          Delegates to wrapped tag.
 javax.servlet.jsp.tagext.TagSupport getTag()
          Returns the wrapped tag (the testee).
 java.lang.Object getValue(java.lang.String key)
          Delegates to wrapped tag.
 java.util.Enumeration getValues()
          Delegates to wrapped tag.
 javax.servlet.jsp.tagext.JspTag getWrappedTag()
          Returns the wrapped tag (the testee).
 void populateAttributes()
          Populates the attributes of the underlying tag.
 void release()
          Delegates to wrapped tag.
 void removeChilds()
          Removes all childs.
 void removeValue(java.lang.String value)
          Delegates to wrapped tag.
 void setBodyContent(javax.servlet.jsp.tagext.BodyContent content)
          Delegates to wrapped tag.
 void setDoRelease(boolean doRelease)
          Specify if the release method should be called after processing the tag lifecycle.
 void setDoReleaseRecursive(boolean doRelease)
          Specify if the release method should be called after processing the tag lifecycle.
 void setId(java.lang.String id)
          Delegates to wrapped tag.
 void setPageContext(javax.servlet.jsp.PageContext pageContext)
          Delegates to wrapped tag.
 void setParent(javax.servlet.jsp.tagext.Tag parent)
          Delegates to wrapped tag.
 void setValue(java.lang.String key, java.lang.Object value)
          Delegates to wrapped tag.
 java.lang.String toString()
          Dumps the content of this and the nested tags.
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NestedBodyTag

public NestedBodyTag(javax.servlet.jsp.tagext.BodyTag tag,
                     javax.servlet.jsp.PageContext pageContext)
Constructor for a tag with an empty attribute map. If the specified tag is not an instance of BodyTagSupport, the methods that delegate to BodyTagSupport specific methods throw an exception.

Parameters:
tag - the tag
pageContext - the corresponding PageContext

NestedBodyTag

public NestedBodyTag(javax.servlet.jsp.tagext.BodyTag tag,
                     javax.servlet.jsp.PageContext pageContext,
                     java.util.Map attributes)
Constructor for a tag with the specified attribute map. If the specified tag is not an instance of BodyTagSupport, the methods that delegate to BodyTagSupport specific methods throw an exception.

Parameters:
tag - the tag
pageContext - the corresponding PageContext
attributes - the attribute map

NestedBodyTag

public NestedBodyTag(javax.servlet.jsp.tagext.BodyTagSupport tag,
                     javax.servlet.jsp.PageContext pageContext)
Constructor for a tag with an empty attribute map.

Parameters:
tag - the tag
pageContext - the corresponding PageContext

NestedBodyTag

public NestedBodyTag(javax.servlet.jsp.tagext.BodyTagSupport tag,
                     javax.servlet.jsp.PageContext pageContext,
                     java.util.Map attributes)
Constructor for a tag with the specified attribute map.

Parameters:
tag - the tag
pageContext - the corresponding PageContext
attributes - the attribute map
Method Detail

setDoRelease

public void setDoRelease(boolean doRelease)
Description copied from interface: NestedTag
Specify if the release method should be called after processing the tag lifecycle. Defaults to false. It's the container behaviour to call release when the tag goes back to the pool. It's usually not necessary in the tests to call this method, because the tag instances are not pooled and reused during a test run. This method sets the doRelease flag for this tag but does not set the flag for child tags.

Specified by:
setDoRelease in interface NestedTag
Parameters:
doRelease - should release be called, default is false

setDoReleaseRecursive

public void setDoReleaseRecursive(boolean doRelease)
Description copied from interface: NestedTag
Specify if the release method should be called after processing the tag lifecycle. Defaults to false. It's the container behaviour to call release when the tag goes back to the pool. It's usually not necessary in the tests to call this method, because the tag instances are not pooled and reused during a test run. This method sets the doRelease flag for this tag and all child tags recursively.

Specified by:
setDoReleaseRecursive in interface NestedTag
Parameters:
doRelease - should release be called, default is false

populateAttributes

public void populateAttributes()
Description copied from interface: NestedTag
Populates the attributes of the underlying tag. The setters of the tag are called. Please note that child tags are not populated.

Specified by:
populateAttributes in interface NestedTag

doLifecycle

public int doLifecycle()
                throws javax.servlet.jsp.JspException
Description copied from interface: NestedTag
Performs the tag lifecycle. All doBody and doTag methods are called as in the real web container. The evaluation of the body is simulated by performing the lifecycle recursively for all childs of the NestedTag. Calls release on the tag after processing the tag lifecycle, if doRelease is true (use NestedTag.setDoRelease(boolean)).

Specified by:
doLifecycle in interface NestedTag
Returns:
the result of the final doEndTag call
Throws:
javax.servlet.jsp.JspException

getTag

public javax.servlet.jsp.tagext.TagSupport getTag()
Description copied from interface: NestedTag
Returns the wrapped tag (the testee).

Specified by:
getTag in interface NestedTag
Returns:
the wrapped tag
Throws:
RuntimeException, - if the wrapped tag is not an instance of TagSupport

getWrappedTag

public javax.servlet.jsp.tagext.JspTag getWrappedTag()
Description copied from interface: NestedTag
Returns the wrapped tag (the testee).

Specified by:
getWrappedTag in interface NestedTag
Returns:
the wrapped tag

removeChilds

public void removeChilds()
Description copied from interface: NestedTag
Removes all childs.

Specified by:
removeChilds in interface NestedTag

getChilds

public java.util.List getChilds()
Description copied from interface: NestedTag
Returns the List of childs.

Specified by:
getChilds in interface NestedTag
Returns:
the List of childs

getChild

public java.lang.Object getChild(int index)
Description copied from interface: NestedTag
Returns a child specified by its index.

Specified by:
getChild in interface NestedTag
Parameters:
index - the index
Returns:
the child

addTextChild

public void addTextChild(java.lang.String text)
Description copied from interface: NestedTag
Adds a text child simulating static body content.

Specified by:
addTextChild in interface NestedTag
Parameters:
text - the static text

addDynamicChild

public void addDynamicChild(DynamicChild child)
Description copied from interface: NestedTag
Adds a dynamic child simulating scriptlets and EL expressions. Check out TagUtil.evalBody(List, Object) for details about child handling.

Specified by:
addDynamicChild in interface NestedTag
Parameters:
child - the dynamic child instance

addTagChild

public NestedTag addTagChild(java.lang.Class tag)
Description copied from interface: NestedTag
Adds a tag child simulating nested tags. The corresponding NestedTag will be created automatically wrapping the specified tag. An empty attribute Map will be used for the tag.

Specified by:
addTagChild in interface NestedTag
Parameters:
tag - the tag class

addTagChild

public NestedTag addTagChild(java.lang.Class tag,
                             java.util.Map attributeMap)
Description copied from interface: NestedTag
Adds a tag child simulating nested tags. The corresponding NestedTag will be created automatically wrapping the specified tag. The attributes Map contains the attributes of this tag (propertyname maps to propertyvalue).

Specified by:
addTagChild in interface NestedTag
Parameters:
tag - the tag class
attributeMap - the attribute map

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.TagSupport tag)
Description copied from interface: NestedTag
Adds a tag child simulating nested tags. NestedTag will be created automatically wrapping the specified tag. An empty attribute Map will be used for the tag.

Specified by:
addTagChild in interface NestedTag
Parameters:
tag - the tag

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.TagSupport tag,
                             java.util.Map attributeMap)
Description copied from interface: NestedTag
Adds a tag child simulating nested tags. The corresponding NestedTag will be created automatically wrapping the specified tag. The attributes Map contains the attributes of this tag (propertyname maps to propertyvalue).

Specified by:
addTagChild in interface NestedTag
Parameters:
tag - the tag
attributeMap - the attribute map

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag)
Description copied from interface: NestedTag
Adds a tag child simulating nested tags. NestedTag will be created automatically wrapping the specified tag. An empty attribute Map will be used for the tag.

Specified by:
addTagChild in interface NestedTag
Parameters:
tag - the tag

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag,
                             java.util.Map attributeMap)
Description copied from interface: NestedTag
Adds a tag child simulating nested tags. The corresponding NestedTag will be created automatically wrapping the specified tag. The attributes Map contains the attributes of this tag (propertyname maps to propertyvalue).

Specified by:
addTagChild in interface NestedTag
Parameters:
tag - the tag
attributeMap - the attribute map

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Delegates to wrapped tag.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Delegates to wrapped tag.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Delegates to wrapped tag.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

getId

public java.lang.String getId()
Delegates to wrapped tag.

Overrides:
getId in class javax.servlet.jsp.tagext.TagSupport
Throws:
RuntimeException, - if the wrapped tag is not an instance of TagSupport

getParent

public javax.servlet.jsp.tagext.Tag getParent()
Delegates to wrapped tag.

Specified by:
getParent in interface javax.servlet.jsp.tagext.Tag
Overrides:
getParent in class javax.servlet.jsp.tagext.TagSupport

getValue

public java.lang.Object getValue(java.lang.String key)
Delegates to wrapped tag.

Overrides:
getValue in class javax.servlet.jsp.tagext.TagSupport
Throws:
RuntimeException, - if the wrapped tag is not an instance of TagSupport

getValues

public java.util.Enumeration getValues()
Delegates to wrapped tag.

Overrides:
getValues in class javax.servlet.jsp.tagext.TagSupport
Throws:
RuntimeException, - if the wrapped tag is not an instance of TagSupport

release

public void release()
Delegates to wrapped tag.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.BodyTagSupport

removeValue

public void removeValue(java.lang.String value)
Delegates to wrapped tag.

Overrides:
removeValue in class javax.servlet.jsp.tagext.TagSupport
Throws:
RuntimeException, - if the wrapped tag is not an instance of TagSupport

setId

public void setId(java.lang.String id)
Delegates to wrapped tag.

Overrides:
setId in class javax.servlet.jsp.tagext.TagSupport
Throws:
RuntimeException, - if the wrapped tag is not an instance of TagSupport

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pageContext)
Delegates to wrapped tag. Also calls setPageContext for all child tags.

Specified by:
setPageContext in interface javax.servlet.jsp.tagext.Tag
Overrides:
setPageContext in class javax.servlet.jsp.tagext.TagSupport

setParent

public void setParent(javax.servlet.jsp.tagext.Tag parent)
Delegates to wrapped tag.

Specified by:
setParent in interface javax.servlet.jsp.tagext.Tag
Overrides:
setParent in class javax.servlet.jsp.tagext.TagSupport

setValue

public void setValue(java.lang.String key,
                     java.lang.Object value)
Delegates to wrapped tag.

Overrides:
setValue in class javax.servlet.jsp.tagext.TagSupport
Throws:
RuntimeException, - if the wrapped tag is not an instance of TagSupport

doInitBody

public void doInitBody()
                throws javax.servlet.jsp.JspException
Delegates to wrapped tag.

Specified by:
doInitBody in interface javax.servlet.jsp.tagext.BodyTag
Overrides:
doInitBody in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

getBodyContent

public javax.servlet.jsp.tagext.BodyContent getBodyContent()
Delegates to wrapped tag.

Overrides:
getBodyContent in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
RuntimeException, - if the wrapped tag is not an instance of BodyTagSupport

getPreviousOut

public javax.servlet.jsp.JspWriter getPreviousOut()
Delegates to wrapped tag.

Overrides:
getPreviousOut in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
RuntimeException, - if the wrapped tag is not an instance of BodyTagSupport

setBodyContent

public void setBodyContent(javax.servlet.jsp.tagext.BodyContent content)
Delegates to wrapped tag.

Specified by:
setBodyContent in interface javax.servlet.jsp.tagext.BodyTag
Overrides:
setBodyContent in class javax.servlet.jsp.tagext.BodyTagSupport

toString

public java.lang.String toString()
Dumps the content of this and the nested tags.

Overrides:
toString in class java.lang.Object