Devsphere.com


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

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
                          |
                          +--com.devsphere.xml.taglib.process.tag.Element
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

public class Element
extends ProcessSupport

Handler for the <p:element> tag, whose body may process a DOM sub-tree or may contain sub-tags that process the SAX events that are generated between a startElement() event and an endElement() event. It exports variables that hold the element's namespace URI, local name, qualified name and attributes. It may also export a variable holding the root of a DOM sub-tree, in which case the body may not contain any tags of this library. If the varDom attribute isn't present, no DOM variable is exported and the body may contain a <p:start> tag for processing the startElement() SAX event, followed by one or more <p:element> and <p:data> tags for processing the sub-elements and the character data, followed by an optional <p:end> tag for processing the endElement() SAX event.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.devsphere.xml.taglib.process.tag.ProcessSupport
ancestor, event, handler, indentLevel
 
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
Element()
           
 
Method Summary
protected  boolean continueLoop()
          Returns true if the current event could be processed by a sub-tag.
protected  boolean evalTests()
          Evaluates the test conditions.
protected  void exportVariables()
          Exports the element variables.
protected  java.util.List getAllowedAncestors()
          Returns the list of names of the tags that may contain the tag that is handled by this class.
 java.lang.String getTagName()
          Returns the name of the handled tag
 boolean getWantDOM()
          Returns true if the body of this tag will process a DOM tree.
protected  void init()
          Initializes the fields of this tag handler.
protected  void initLoop()
          Initializes the loop to process element events.
 void setScope(java.lang.String scope)
          Sets the default scope for the variables exported by this tag handler.
 void setScopeAttr(java.lang.String scopeAttr)
          Sets the scope of the attr variable exported by this tag handler.
 void setScopeDom(java.lang.String scopeDom)
          Sets the scope of the dom variable exported by this tag handler.
 void setScopeName(java.lang.String scopeName)
          Sets the scope of the name variable exported by this tag handler.
 void setScopeQname(java.lang.String scopeQname)
          Sets the scope of the qname variable exported by this tag handler.
 void setScopeUri(java.lang.String scopeUri)
          Sets the scope of the uri variable exported by this tag handler.
 void setTest(java.lang.String testExpr)
          If this expression is present and it evaluates to false (the test is negative), the event loop will not be started.
 void setTestName(java.lang.String testNameExpr)
          Sets the expression whose value will be compared with the element's local name.
 void setTestQname(java.lang.String testQnameExpr)
          Sets the expression whose value will be compared with the element's qualified name.
 void setTestUri(java.lang.String testUriExpr)
          Sets the expression whose value will be compared with the element's namespace URI.
 void setVarAttr(java.lang.String varAttr)
          Sets the name of the attr variable exported by this tag handler.
 void setVarDom(java.lang.String varDom)
          Sets the name of the dom variable exported by this tag handler.
 void setVarName(java.lang.String varName)
          Sets the name of the name variable exported by this tag handler.
 void setVarQname(java.lang.String varQname)
          Sets the name of the qname variable exported by this tag handler.
 void setVarUri(java.lang.String varUri)
          Sets the name of the uri variable exported by this tag handler.
protected  boolean startLoop()
          Returns true if the current event is a StartElement instance and all tests are passed.
 
Methods inherited from class com.devsphere.xml.taglib.process.tag.ProcessSupport
doAfterBody, doEndTag, doFinally, doStartTag, finalizeLoop, getEvent, logEvent, logEvent, removeEvent, validate
 
Methods inherited from class com.devsphere.xml.taglib.support.tag.CommonSupport
checkVarName, checkVarScope, doCatch, eval, evalBoolean, evalDouble, evalInt, evalString, export, export, getDebug, getLogger, 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
 

Constructor Detail

Element

public Element()
Method Detail

init

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

Overrides:
init in class ProcessSupport

getTagName

public java.lang.String getTagName()
Returns the name of the handled tag

Specified by:
getTagName in class CommonSupport
Returns:
the name of the handled tag

getWantDOM

public boolean getWantDOM()
Returns true if the body of this tag will process a DOM tree.

Returns:
true if the dom variable must be exported.

getAllowedAncestors

protected java.util.List getAllowedAncestors()
Returns the list of names of the tags that may contain the tag that is handled by this class.

Specified by:
getAllowedAncestors in class CommonSupport
Returns:
the list of names of the allowed ancestor tags or null if the tag context doesn't matter.

setVarUri

public void setVarUri(java.lang.String varUri)
               throws javax.servlet.jsp.JspException
Sets the name of the uri variable exported by this tag handler. The element's namespace URI will be the value of the uri variable. The default name of this variable is uri.

Parameters:
varUri - the name of the uri variable
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setScopeUri

public void setScopeUri(java.lang.String scopeUri)
                 throws javax.servlet.jsp.JspException
Sets the scope of the uri variable exported by this tag handler.

Parameters:
scopeUri - the scope of the uri variable
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setTestUri

public void setTestUri(java.lang.String testUriExpr)
                throws javax.servlet.jsp.JspException
Sets the expression whose value will be compared with the element's namespace URI. If this expression is present and the URI test is negative, the event loop will not be started.

Parameters:
testUriExpr - the expression for testing the URI
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setVarName

public void setVarName(java.lang.String varName)
                throws javax.servlet.jsp.JspException
Sets the name of the name variable exported by this tag handler. The element's local name will be the value of the name variable. The default name of this variable is name.

Parameters:
varName - the name of the name variable
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setScopeName

public void setScopeName(java.lang.String scopeName)
                  throws javax.servlet.jsp.JspException
Sets the scope of the name variable exported by this tag handler.

Parameters:
scopeName - the scope of the name variable
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setTestName

public void setTestName(java.lang.String testNameExpr)
                 throws javax.servlet.jsp.JspException
Sets the expression whose value will be compared with the element's local name. If this expression is present and the name test is negative, the event loop will not be started.

Parameters:
testNameExpr - the expression for testing the local name
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setVarQname

public void setVarQname(java.lang.String varQname)
                 throws javax.servlet.jsp.JspException
Sets the name of the qname variable exported by this tag handler. The element's qualified name will be the value of the qname variable. The default name of this variable is qname.

Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setScopeQname

public void setScopeQname(java.lang.String scopeQname)
                   throws javax.servlet.jsp.JspException
Sets the scope of the qname variable exported by this tag handler.

Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setTestQname

public void setTestQname(java.lang.String testQnameExpr)
                  throws javax.servlet.jsp.JspException
Sets the expression whose value will be compared with the element's qualified name. If this expression is present and the qname test is negative, the event loop will not be started.

Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setVarAttr

public void setVarAttr(java.lang.String varAttr)
                throws javax.servlet.jsp.JspException
Sets the name of the attr variable exported by this tag handler. The element's attributes will be the value of the attr variable. The default name of this variable is attr.

Parameters:
varAttr - the name of the attr variable
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setScopeAttr

public void setScopeAttr(java.lang.String scopeAttr)
                  throws javax.servlet.jsp.JspException
Sets the scope of the attr variable exported by this tag handler.

Parameters:
scopeAttr - the scope of the attr variable
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setTest

public void setTest(java.lang.String testExpr)
             throws javax.servlet.jsp.JspException
If this expression is present and it evaluates to false (the test is negative), the event loop will not be started.

Parameters:
testExpr - the expression that will be evaluated
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setVarDom

public void setVarDom(java.lang.String varDom)
               throws javax.servlet.jsp.JspException
Sets the name of the dom variable exported by this tag handler. The presence of this variable indicates that the application wants a DOM tree for processing rather than a sequence of SAX events. The root node of the DOM sub-tree will be the value of the dom variable.

Parameters:
varDom - the name of the dom variable
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setScopeDom

public void setScopeDom(java.lang.String scopeDom)
                 throws javax.servlet.jsp.JspException
Sets the scope of the dom variable exported by this tag handler.

Parameters:
scopeDom - the scope of the dom variable
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

setScope

public void setScope(java.lang.String scope)
              throws javax.servlet.jsp.JspException
Sets the default scope for the variables exported by this tag handler.

Parameters:
scope - the default scope of the exported variables
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

initLoop

protected void initLoop()
                 throws javax.servlet.jsp.JspException
Initializes the loop to process element events.

Overrides:
initLoop in class ProcessSupport
Throws:
javax.servlet.jsp.JspException - to signal any tag validation error

exportVariables

protected void exportVariables()
Exports the element variables.


evalTests

protected boolean evalTests()
                     throws javax.servlet.jsp.JspException
Evaluates the test conditions.

Returns:
true is all tests are passed
Throws:
javax.servlet.jsp.JspException - to signal any error that might occur

startLoop

protected boolean startLoop()
                     throws javax.servlet.jsp.JspException
Returns true if the current event is a StartElement instance and all tests are passed.

Specified by:
startLoop in class ProcessSupport
Returns:
true if the event loop should be started
Throws:
javax.servlet.jsp.JspException - to signal an error

continueLoop

protected boolean continueLoop()
                        throws javax.servlet.jsp.JspException
Returns true if the current event could be processed by a sub-tag.

Specified by:
continueLoop in class ProcessSupport
Returns:
true if the event loop should be continued
Throws:
javax.servlet.jsp.JspException - to signal an error

 Devsphere.com