Devsphere.com


com.devsphere.xml.taglib.process.tag
Class ProcessSupport

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--javax.servlet.jsp.tagext.BodyTagSupport
              |
              +--com.devsphere.xml.taglib.support.tag.CommonSupport
                    |
                    +--com.devsphere.xml.taglib.process.tag.ProcessSupport
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally
Direct Known Subclasses:
Data, Element, End, Parse, PI, Start

public abstract class ProcessSupport
extends CommonSupport

This class provides support for XML processing tag handlers. It provides methods for looping over a sequence of SAX events.

See Also:
Serialized Form

Field Summary
protected  ProcessSupport ancestor
          The tag handler of the nearest ancestor tag
protected  EventSupport event
          The event handled by this object
protected  Handler handler
          The event handler
protected  int indentLevel
          The indent level of the tag
 
Fields inherited from class com.devsphere.xml.taglib.support.tag.CommonSupport
cachedDebug, cachedLogger, DEBUG_ATTR, DEFAULT_DEBUG, DEFAULT_RESTORE_VALUE, DEFAULT_SCOPE, LOGGER_ATTR, originalValues
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
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
ProcessSupport()
           
 
Method Summary
protected abstract  boolean continueLoop()
          Subclasses must implement this method and return true if the event loop should be continued.
 int doAfterBody()
          Calls continueLoop().
 int doEndTag()
          Returns EVAL_PAGE.
 void doFinally()
          Calls finalizeLoop()
 int doStartTag()
          Calls initLoop() and then startLoop().
protected  void finalizeLoop()
          Subclasses may override this method if they need to execute some operations after the event loop is finished.
protected  boolean getEvent()
          Gets the current parsing event and returns true if this isn't null.
protected  void init()
          Initializes the fields of this tag handler.
protected  void initLoop()
          Initializes the event loop, finding the nearest ancestor tag so that the current tag can be validated and handled within its context.
protected  void logEvent()
          Logs an event if the debug flag is true.
protected  void logEvent(java.lang.String status)
          Logs an event if the debug flag is true.
protected  boolean removeEvent()
          Tries to removes the current parsing event in order to make room for another event.
protected abstract  boolean startLoop()
          Subclasses must implement this method and return true if the event loop should be started.
protected  void validate(CommonSupport ancestor)
          Verify if the handled tag was placed in the right context.
 
Methods inherited from class com.devsphere.xml.taglib.support.tag.CommonSupport
checkVarName, checkVarScope, doCatch, eval, evalBoolean, evalDouble, evalInt, evalString, export, export, getAllowedAncestors, getDebug, getLogger, getTagName, log, log, log, restore
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

ancestor

protected ProcessSupport ancestor
The tag handler of the nearest ancestor tag


handler

protected Handler handler
The event handler


event

protected EventSupport event
The event handled by this object


indentLevel

protected int indentLevel
The indent level of the tag

Constructor Detail

ProcessSupport

public ProcessSupport()
Method Detail

init

protected void init()
Initializes the fields of this tag handler.

Overrides:
init in class CommonSupport

validate

protected void validate(CommonSupport ancestor)
                 throws javax.servlet.jsp.JspException
Verify if the handled tag was placed in the right context. This methods throws a JspException if

Overrides:
validate in class CommonSupport
Parameters:
ancestor - the tag handler of an ancestor whose name is searched in the list of allowed ancestors
Throws:
javax.servlet.jsp.JspException - to signal a tag validation error

getEvent

protected boolean getEvent()
Gets the current parsing event and returns true if this isn't null.

Returns:
true if an event is available for processing

removeEvent

protected boolean removeEvent()
Tries to removes the current parsing event in order to make room for another event.

Returns:
true if the event was removed

logEvent

protected void logEvent()
Logs an event if the debug flag is true.


logEvent

protected void logEvent(java.lang.String status)
Logs an event if the debug flag is true.

Parameters:
status - a string describing the status of the event

initLoop

protected void initLoop()
                 throws javax.servlet.jsp.JspException
Initializes the event loop, finding the nearest ancestor tag so that the current tag can be validated and handled within its context.

Throws:
javax.servlet.jsp.JspException - to signal a tag validation error

startLoop

protected abstract boolean startLoop()
                              throws javax.servlet.jsp.JspException
Subclasses must implement this method and return true if the event loop should be started.

Returns:
true if the event loop should be started
Throws:
javax.servlet.jsp.JspException - to signal an error

continueLoop

protected abstract boolean continueLoop()
                                 throws javax.servlet.jsp.JspException
Subclasses must implement this method and return true if the event loop should be continued.

Returns:
true if the event loop should be continued
Throws:
javax.servlet.jsp.JspException - to signal an error

finalizeLoop

protected void finalizeLoop()
Subclasses may override this method if they need to execute some operations after the event loop is finished.


doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Calls initLoop() and then startLoop(). If the latter returns true, this method returns EVAL_BODY_INCLUDE so that the body of the tag is evaluated getting the chance to process one or more parsing events. Otherwise it returns SKIP_BODY.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_BODY_INCLUDE or SKIP_BODY depending on the value returned by startLoop()
Throws:
javax.servlet.jsp.JspException - to signal an error

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Calls continueLoop(). If that returns true, this method returns EVAL_BODY_AGAIN so that the body of the tag is re-evaluated getting the chance to process new events. Otherwise it returns SKIP_BODY.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_BODY_AGAIN or SKIP_BODY depending on the value returned by continueLoop()
Throws:
javax.servlet.jsp.JspException - to signal an error

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Returns EVAL_PAGE.

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

doFinally

public void doFinally()
Calls finalizeLoop()

Specified by:
doFinally in interface javax.servlet.jsp.tagext.TryCatchFinally
Overrides:
doFinally in class CommonSupport

 Devsphere.com