com.mockrunner.tag
Class NestedSimpleTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.SimpleTagSupport
      extended by com.mockrunner.tag.NestedSimpleTag
All Implemented Interfaces:
NestedTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.SimpleTag

public class NestedSimpleTag
extends javax.servlet.jsp.tagext.SimpleTagSupport
implements NestedTag

Implementation of NestedTag wrapping tags of type SimpleTag. NestedSimpleTag 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.


Constructor Summary
NestedSimpleTag(javax.servlet.jsp.tagext.SimpleTag tag, javax.servlet.jsp.JspContext jspContext)
          Constructor for a tag with an empty attribute map.
NestedSimpleTag(javax.servlet.jsp.tagext.SimpleTag tag, javax.servlet.jsp.JspContext jspContext, java.util.Map attributes)
          Constructor for a tag with the specified attribute map.
NestedSimpleTag(javax.servlet.jsp.tagext.SimpleTagSupport tag, javax.servlet.jsp.JspContext jspContext)
          Constructor for a tag with an empty attribute map.
NestedSimpleTag(javax.servlet.jsp.tagext.SimpleTagSupport tag, javax.servlet.jsp.JspContext jspContext, 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 doLifecycle()
          Implementation of NestedTag.doLifecycle() for simple tags.
 void doTag()
          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.
 javax.servlet.jsp.tagext.JspFragment getJspBody()
          Returns the body fragment.
 javax.servlet.jsp.JspContext getJspContext()
          Returns the JspContext.
 javax.servlet.jsp.tagext.JspTag getParent()
          Delegates to wrapped tag.
 javax.servlet.jsp.tagext.TagSupport getTag()
          Implementation of NestedTag.getTag().
 javax.servlet.jsp.tagext.JspTag getWrappedTag()
          Returns the wrapped tag (the testee).
 void populateAttributes()
          Populates the attributes of the underlying tag.
 void removeChilds()
          Removes all childs.
 void setDoRelease(boolean doRelease)
          Implementation of NestedTag.setDoRelease(boolean).
 void setDoReleaseRecursive(boolean doRelease)
          Implementation of NestedTag.setDoReleaseRecursive(boolean).
 void setJspBody(javax.servlet.jsp.tagext.JspFragment jspBody)
          Delegates to wrapped tag.
 void setJspContext(javax.servlet.jsp.JspContext jspContext)
          Delegates to wrapped tag.
 void setParent(javax.servlet.jsp.tagext.JspTag parent)
          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.SimpleTagSupport
findAncestorWithClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NestedSimpleTag

public NestedSimpleTag(javax.servlet.jsp.tagext.SimpleTag tag,
                       javax.servlet.jsp.JspContext jspContext)
Constructor for a tag with an empty attribute map.

Parameters:
tag - the tag
jspContext - the corresponding JspContext

NestedSimpleTag

public NestedSimpleTag(javax.servlet.jsp.tagext.SimpleTag tag,
                       javax.servlet.jsp.JspContext jspContext,
                       java.util.Map attributes)
Constructor for a tag with the specified attribute map.

Parameters:
tag - the tag
jspContext - the corresponding JspContext
attributes - the attribute map

NestedSimpleTag

public NestedSimpleTag(javax.servlet.jsp.tagext.SimpleTagSupport tag,
                       javax.servlet.jsp.JspContext jspContext)
Constructor for a tag with an empty attribute map.

Parameters:
tag - the tag
jspContext - the corresponding JspContext

NestedSimpleTag

public NestedSimpleTag(javax.servlet.jsp.tagext.SimpleTagSupport tag,
                       javax.servlet.jsp.JspContext jspContext,
                       java.util.Map attributes)
Constructor for a tag with the specified attribute map.

Parameters:
tag - the tag
jspContext - the corresponding JspContext
attributes - the attribute map
Method Detail

setDoRelease

public void setDoRelease(boolean doRelease)
Implementation of NestedTag.setDoRelease(boolean). Does nothing in this case.

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

setDoReleaseRecursive

public void setDoReleaseRecursive(boolean doRelease)
Implementation of NestedTag.setDoReleaseRecursive(boolean). Does nothing in this case.

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
Implementation of NestedTag.doLifecycle() for simple tags. Returns -1 in this case, because doTag() does not have a return value.

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()
Implementation of NestedTag.getTag(). Should not be called and throws a RuntimeException, because a simple tag is not an instance of TagSupport.

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

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

doTag

public void doTag()
           throws javax.servlet.jsp.JspException,
                  java.io.IOException
Delegates to wrapped tag.

Specified by:
doTag in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
doTag in class javax.servlet.jsp.tagext.SimpleTagSupport
Throws:
javax.servlet.jsp.JspException
java.io.IOException

getJspBody

public javax.servlet.jsp.tagext.JspFragment getJspBody()
Returns the body fragment.

Overrides:
getJspBody in class javax.servlet.jsp.tagext.SimpleTagSupport
Returns:
the body fragment

getJspContext

public javax.servlet.jsp.JspContext getJspContext()
Returns the JspContext.

Overrides:
getJspContext in class javax.servlet.jsp.tagext.SimpleTagSupport
Returns:
the JspContext

getParent

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

Specified by:
getParent in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
getParent in class javax.servlet.jsp.tagext.SimpleTagSupport

setJspBody

public void setJspBody(javax.servlet.jsp.tagext.JspFragment jspBody)
Delegates to wrapped tag.

Specified by:
setJspBody in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
setJspBody in class javax.servlet.jsp.tagext.SimpleTagSupport

setJspContext

public void setJspContext(javax.servlet.jsp.JspContext jspContext)
Delegates to wrapped tag. Also calls setJspContext on the body fragment, if the body fragment is an instance of MockJspFragment

Specified by:
setJspContext in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
setJspContext in class javax.servlet.jsp.tagext.SimpleTagSupport

setParent

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

Specified by:
setParent in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
setParent in class javax.servlet.jsp.tagext.SimpleTagSupport

toString

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

Overrides:
toString in class java.lang.Object