org.makumba.analyser
Class AnalysableElement

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by org.makumba.analyser.AnalysableElement
All Implemented Interfaces:
Serializable, IterationTag, JspTag, Tag
Direct Known Subclasses:
AnalysableExpression, AnalysableTag

public abstract class AnalysableElement
extends TagSupport

An analyzable element of the page, e.g. a tag or an EL expression.

This class contains a number of utility methods that help retrieving the currently analyzed or running JSP element (tag or EL expression). This is useful when providing accurate error messages to the user.

Version:
$Id: AnalysableElement.java,v 1.1 Jan 27, 2010 11:49:06 AM manu Exp $
Author:
Manuel Gay, Rudolf Mayer
See Also:
Serialized Form

Nested Class Summary
static class AnalysableElement.FilePositionElementComparator
           
 
Field Summary
static String ANALYSIS_STATE
           
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
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
AnalysableElement()
           
 
Method Summary
static AnalysableTag checkTagFound(PageCache pageCache, String attributeName, String attributeValue, Class<? extends AnalysableTag> klass)
           
static void discardJSPParsingData()
          Clears remaining page parsing data, which might be useful for error handling, in order to display the exact line at which the error occured.
static ElementData getAnalyzedElementData()
          Gets the data of the currently analyzed element for this thread
static TagData getCurrentBodyTagData()
          Gets the first tag data found in the stack
protected static TagData getElementAfter(PageCache pageCache, ElementData elData, Class<? extends AnalysableTag> klass)
           
protected static TagData getElementBefore(PageCache pageCache, ElementData elData, Class<? extends AnalysableTag> klass)
           
abstract  ElementData getElementData()
           
static PageCache getPageCache(HttpServletRequest request, String realPath, JspAnalyzer analyzer)
           
static PageCache getPageCache(PageContext pageContext, JspAnalyzer analyzer)
          Static method to get the PageCache object for the current page.
static ElementData getRunningElementData()
          Gets the data of the currently running element for this thread
protected static AnalysableTag getTagByAttribute(PageCache pageCache, String attributeName, String attributeValue, Class<? extends AnalysableTag> klass)
           
protected static AnalysableTag getTagById(PageCache pageCache, String id, Class<? extends AnalysableTag> klass)
           
static Stack<ElementData> getThreadElementStack()
          Gets the stack of elements currently running in this thread
static void initializeThread(HttpSession session)
          Initializes the element data thread stack, and loads previous analysis state if there was any
static void keepAnalysisState(HttpSession session)
           
static void setAnalyzedElementData(ElementData data)
          Sets the element data of the currently analyzed element for this thread
static void setRunningElementData(ElementData data)
          Sets the element data of the currently running element for this thread
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, doStartTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANALYSIS_STATE

public static final String ANALYSIS_STATE
See Also:
Constant Field Values
Constructor Detail

AnalysableElement

public AnalysableElement()
Method Detail

initializeThread

public static void initializeThread(HttpSession session)
Initializes the element data thread stack, and loads previous analysis state if there was any


discardJSPParsingData

public static void discardJSPParsingData()
Clears remaining page parsing data, which might be useful for error handling, in order to display the exact line at which the error occured. This method is only called when there's no error on the page, so that the parsing data is kept as long as necessary.


keepAnalysisState

public static void keepAnalysisState(HttpSession session)

getAnalyzedElementData

public static ElementData getAnalyzedElementData()
Gets the data of the currently analyzed element for this thread

Returns:
an ElementData describing the currently analyzed element

setAnalyzedElementData

public static void setAnalyzedElementData(ElementData data)
Sets the element data of the currently analyzed element for this thread

Parameters:
data - the ElementData of the currently analyzed element

getRunningElementData

public static ElementData getRunningElementData()
Gets the data of the currently running element for this thread

Returns:
an ElementData describing the currently running element

setRunningElementData

public static void setRunningElementData(ElementData data)
Sets the element data of the currently running element for this thread

Parameters:
data - the ElementData of the currently running element

getThreadElementStack

public static Stack<ElementData> getThreadElementStack()
Gets the stack of elements currently running in this thread

Returns:
a Stack of ElementData

getCurrentBodyTagData

public static TagData getCurrentBodyTagData()
Gets the first tag data found in the stack

Returns:
the TagData of the first enclosing tag found in the stack or null if none was found

getElementData

public abstract ElementData getElementData()

getPageCache

public static PageCache getPageCache(HttpServletRequest request,
                                     String realPath,
                                     JspAnalyzer analyzer)
                              throws MakumbaError
Throws:
MakumbaError

getPageCache

public static PageCache getPageCache(PageContext pageContext,
                                     JspAnalyzer analyzer)
Static method to get the PageCache object for the current page. Constructs a new one if none found. We put this as static, as we may have to export it to packages like org.makumba.controller.jsp

Parameters:
pageContext - The PageContext object of the current page
analyzer - the JSP analyzer

getTagById

protected static AnalysableTag getTagById(PageCache pageCache,
                                          String id,
                                          Class<? extends AnalysableTag> klass)

getTagByAttribute

protected static AnalysableTag getTagByAttribute(PageCache pageCache,
                                                 String attributeName,
                                                 String attributeValue,
                                                 Class<? extends AnalysableTag> klass)

checkTagFound

public static AnalysableTag checkTagFound(PageCache pageCache,
                                          String attributeName,
                                          String attributeValue,
                                          Class<? extends AnalysableTag> klass)

getElementBefore

protected static TagData getElementBefore(PageCache pageCache,
                                          ElementData elData,
                                          Class<? extends AnalysableTag> klass)

getElementAfter

protected static TagData getElementAfter(PageCache pageCache,
                                         ElementData elData,
                                         Class<? extends AnalysableTag> klass)