Package org.apache.commons.jelly.impl
Class TagScript
java.lang.Object
org.apache.commons.jelly.impl.TagScript
- All Implemented Interfaces:
Script
- Direct Known Subclasses:
StaticTagScript
TagScript is a Script that evaluates a custom tag.
- Version:
- $Revision: 227285 $
- Author:
- James Strachan
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String,ExpressionAttribute> The attribute expressions that are created -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String name, String prefix, String nsURI, Expression expression) Add an initialization attribute for the tag.voidaddAttribute(String name, Expression expression) Add an initialization attribute for the tag.protected voidapplyLocation(LocationAware locationAware) protected voidclearTag()Flushes the current cached tag so that it will be created, lazily, next invocationcompile()Compiles the tags bodyprotected voidconfigureTag(Tag tag, JellyContext context) Compiles a newly created tag if required, sets its parent and body.protected ObjectconvertType(Object value, Class requiredType) Converts the given value to the required type.protected JellyExceptioncreateJellyException(String reason) Creates a new Jelly exception, adorning it with location informationprotected JellyExceptioncreateJellyException(String reason, Exception cause) Creates a new Jelly exception, adorning it with location informationprotected TagFactory method to create a new Tag instance.protected voidendNamespacePrefixes(XMLOutput output) End the new namespace prefixes mapped for the current elementprotected ExpressiongetAttribute(String name) Retrieves the expression of the given attribute name.protected StringgetBodyText(JellyContext context, boolean shouldEscape) Evaluates the body and obtains it as a string.intintReturns the local, non namespaced XML name of this tagReturns the namespace context of this tag.getNsUri()Returns the parent.Returns the SAX attributes of this tagBase URL from which the script (that uses this tag) is loaded.getTag(JellyContext context) Returns the tagBody.Returns the Factory of Tag instances.protected voidA helper method to handle this non-Jelly exception.protected voidA helper method to handle this non-Jelly exception.protected voidA helper method to handle this Jelly exception.protected voidA helper method to handle this Jelly exception.static TagScriptnewInstance(Class tagClass) voidrun(JellyContext context, XMLOutput output) Evaluates the body of a tagvoidsetColumnNumber(int columnNumber) Sets the column number of the tagprotected voidsetContextURLs(JellyContext context) Set the context's root and current URL if not presentvoidsetElementName(String elementName) Sets the element name which caused the problemvoidsetFileName(String fileName) Sets the Jelly file which caused the problemvoidsetLineNumber(int lineNumber) Sets the line number of the tagvoidsetLocalName(String localName) Sets the local, non namespaced name of this tag.voidsetLocator(Locator locator) Configures this TagScript from the SAX Locator, setting the column and line numbersvoidvoidSets the parent.voidsetSaxAttributes(Attributes saxAttributes) Sets the SAX attributes of this tagprotected voidsetTag(Tag tag, JellyContext context) Allows the script to set the tag instance to be used, such as in a StaticTagScript when a StaticTag is switched with a DynamicTagvoidsetTagBody(Script tagBody) Sets the tagBody.voidsetTagFactory(TagFactory tagFactory) Sets the Factory of Tag instances.voidsetTagNamespacesMap(Map tagNamespacesMap) Sets the optional namespaces prefix -> URI map of the namespaces attached to this Tagprotected voidstartNamespacePrefixes(XMLOutput output) Output the new namespace prefixes used for this elementtoString()
-
Field Details
-
attributes
The attribute expressions that are created
-
-
Constructor Details
-
TagScript
public TagScript() -
TagScript
-
-
Method Details
-
newInstance
- Returns:
- a new TagScript based on whether the given Tag class is a bean tag or DynaTag
-
toString
-
compile
Compiles the tags body- Specified by:
compilein interfaceScript- Throws:
JellyException
-
setTagNamespacesMap
Sets the optional namespaces prefix -> URI map of the namespaces attached to this Tag -
setLocator
Configures this TagScript from the SAX Locator, setting the column and line numbers -
addAttribute
Add an initialization attribute for the tag. This method must be called after the setTag() method -
addAttribute
Add an initialization attribute for the tag. This method must be called after the setTag() method -
run
Evaluates the body of a tag- Specified by:
runin interfaceScript- Throws:
JellyTagException
-
setContextURLs
Set the context's root and current URL if not present- Parameters:
context-- Throws:
JellyTagException
-
getTag
- Returns:
- the tag to be evaluated, creating it lazily if required.
- Throws:
JellyException
-
getTagFactory
Returns the Factory of Tag instances.- Returns:
- the factory
-
setTagFactory
Sets the Factory of Tag instances.- Parameters:
tagFactory- The factory to set
-
getParent
Returns the parent.- Returns:
- TagScript
-
getTagBody
Returns the tagBody.- Returns:
- Script
-
setParent
Sets the parent.- Parameters:
parent- The parent to set
-
setTagBody
Sets the tagBody.- Parameters:
tagBody- The tagBody to set
-
getFileName
- Returns:
- the Jelly file which caused the problem
-
setFileName
Sets the Jelly file which caused the problem -
getScriptURL
Base URL from which the script (that uses this tag) is loaded. Useful fo resolving other resources/scripts that are placed side-by-side. -
getElementName
- Returns:
- the element name which caused the problem
-
setElementName
Sets the element name which caused the problem -
getLineNumber
public int getLineNumber()- Returns:
- the line number of the tag
-
setLineNumber
public void setLineNumber(int lineNumber) Sets the line number of the tag -
getColumnNumber
public int getColumnNumber()- Returns:
- the column number of the tag
-
setColumnNumber
public void setColumnNumber(int columnNumber) Sets the column number of the tag -
getSaxAttributes
Returns the SAX attributes of this tag- Returns:
- Attributes
-
setSaxAttributes
Sets the SAX attributes of this tag- Parameters:
saxAttributes- The saxAttributes to set
-
getLocalName
Returns the local, non namespaced XML name of this tag- Returns:
- String
-
setLocalName
Sets the local, non namespaced name of this tag.- Parameters:
localName- The localName to set
-
getNsUri
-
setNsUri
-
getNamespaceContext
Returns the namespace context of this tag. This is all the prefixes in scope in the document where this tag is used which are mapped to their namespace URIs.- Returns:
- a Map with the keys are namespace prefixes and the values are namespace URIs.
-
createTag
Factory method to create a new Tag instance. The default implementation is to delegate to the TagFactory- Throws:
JellyException
-
configureTag
Compiles a newly created tag if required, sets its parent and body.- Throws:
JellyException
-
clearTag
protected void clearTag()Flushes the current cached tag so that it will be created, lazily, next invocation -
setTag
Allows the script to set the tag instance to be used, such as in a StaticTagScript when a StaticTag is switched with a DynamicTag -
startNamespacePrefixes
Output the new namespace prefixes used for this element- Throws:
SAXException
-
endNamespacePrefixes
End the new namespace prefixes mapped for the current element- Throws:
SAXException
-
convertType
Converts the given value to the required type.- Parameters:
value- is the value to be converted. This will not be nullrequiredType- the type that the value should be converted to- Throws:
JellyException
-
createJellyException
Creates a new Jelly exception, adorning it with location information -
createJellyException
Creates a new Jelly exception, adorning it with location information -
handleException
A helper method to handle this Jelly exception. This method adorns the JellyException with location information such as adding line number information etc.- Throws:
JellyTagException
-
handleException
A helper method to handle this Jelly exception. This method adorns the JellyException with location information such as adding line number information etc.- Throws:
JellyTagException
-
applyLocation
-
handleException
A helper method to handle this non-Jelly exception. This method will rethrow the exception, wrapped in a JellyException while adding line number information etc.- Throws:
JellyTagException
-
handleException
A helper method to handle this non-Jelly exception. This method will rethrow the exception, wrapped in a JellyException while adding line number information etc. Is this method wise?- Throws:
ErrorJellyTagException
-
getAttribute
Retrieves the expression of the given attribute name. If no such attribute exists, this method returnsExpression.NULLso that the caller doesn't have to do the null check. -
getBodyText
Evaluates the body and obtains it as a string. Uses standard XMLOutput.createXMLOutput() to generate output unless the JellyContext contains a variable named org.apache.commons.jelly.XMLOutputFactory which is an object of that type.- Throws:
JellyTagException
-