com.mockrunner.mock.web
Class MockJspFragment

java.lang.Object
  extended by javax.servlet.jsp.tagext.JspFragment
      extended by com.mockrunner.mock.web.MockJspFragment

public class MockJspFragment
extends javax.servlet.jsp.tagext.JspFragment

Mock implementation of JspFragment. The body of a simple tag is a JspFragment. All child handling methods of NestedSimpleTag delegate to an underlying instance of this class.


Constructor Summary
MockJspFragment(javax.servlet.jsp.JspContext jspContext)
           
MockJspFragment(javax.servlet.jsp.JspContext jspContext, javax.servlet.jsp.tagext.JspTag parent)
           
 
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.
 void addTextChild(java.lang.String text)
          Adds a text child simulating static body content.
 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.JspContext getJspContext()
          Returns the JspContext.
 javax.servlet.jsp.tagext.JspTag getParent()
          Returns the parent tag.
 void invoke(java.io.Writer writer)
          Executes the fragment and directs all output to the given Writer, or the JspWriter returned by the getOut() method of the JspContext associated with the fragment if out is null (copied from JspFragment JavaDoc).
 void removeChilds()
          Removes all childs.
 void setJspContext(javax.servlet.jsp.JspContext jspContext)
          Sets the JspContext.
 void setParent(javax.servlet.jsp.tagext.JspTag parent)
          Sets the parent tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockJspFragment

public MockJspFragment(javax.servlet.jsp.JspContext jspContext)

MockJspFragment

public MockJspFragment(javax.servlet.jsp.JspContext jspContext,
                       javax.servlet.jsp.tagext.JspTag parent)
Method Detail

getParent

public javax.servlet.jsp.tagext.JspTag getParent()
Returns the parent tag.

Returns:
the parent tag

setParent

public void setParent(javax.servlet.jsp.tagext.JspTag parent)
Sets the parent tag.

Parameters:
parent - the parent tag

getJspContext

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

Specified by:
getJspContext in class javax.servlet.jsp.tagext.JspFragment
Returns:
the JspContext

setJspContext

public void setJspContext(javax.servlet.jsp.JspContext jspContext)
Sets the JspContext. Also calls setJspContext (or setPageContext) for all child tags. setPageContext is only called if the specified JspContext is an instance of PageContext.

Parameters:
jspContext - the JspContext

invoke

public void invoke(java.io.Writer writer)
            throws javax.servlet.jsp.JspException,
                   java.io.IOException
Executes the fragment and directs all output to the given Writer, or the JspWriter returned by the getOut() method of the JspContext associated with the fragment if out is null (copied from JspFragment JavaDoc).

Specified by:
invoke in class javax.servlet.jsp.tagext.JspFragment
Parameters:
writer - the Writer to output the fragment to, or null if output should be sent to JspContext.getOut().
Throws:
javax.servlet.jsp.JspException
java.io.IOException

removeChilds

public void removeChilds()
Removes all childs.


getChilds

public java.util.List getChilds()
Returns the List of childs.

Returns:
the List of childs

getChild

public java.lang.Object getChild(int index)
Returns a child specified by its index.

Parameters:
index - the index
Returns:
the child

addTextChild

public void addTextChild(java.lang.String text)
Adds a text child simulating static body content.

Parameters:
text - the static text

addDynamicChild

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

Parameters:
child - the dynamic child instance

addTagChild

public NestedTag addTagChild(java.lang.Class tag)
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.

Parameters:
tag - the tag class

addTagChild

public NestedTag addTagChild(java.lang.Class tag,
                             java.util.Map attributeMap)
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).

Parameters:
tag - the tag class
attributeMap - the attribute map

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag)
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.

Parameters:
tag - the tag

addTagChild

public NestedTag addTagChild(javax.servlet.jsp.tagext.JspTag tag,
                             java.util.Map attributeMap)
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).

Parameters:
tag - the tag
attributeMap - the attribute map