public class TagScript extends Object implements Script
TagScript
is a Script that evaluates a custom tag.
Modifier and Type | Field and Description |
---|---|
protected Map<String,ExpressionAttribute> |
attributes
The attribute expressions that are created
|
Constructor and Description |
---|
TagScript() |
TagScript(TagFactory tagFactory) |
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(String name,
Expression expression)
Add an initialization attribute for the tag.
|
void |
addAttribute(String name,
String prefix,
String nsURI,
Expression expression)
Add an initialization attribute for the tag.
|
protected void |
applyLocation(LocationAware locationAware) |
protected void |
clearTag()
Flushes the current cached tag so that it will be created, lazily, next invocation
|
Script |
compile()
Compiles the tags body
|
protected void |
configureTag(Tag tag,
JellyContext context)
Compiles a newly created tag if required, sets its parent and body.
|
protected Object |
convertType(Object value,
Class requiredType)
Converts the given value to the required type.
|
protected JellyException |
createJellyException(String reason)
Creates a new Jelly exception, adorning it with location information
|
protected JellyException |
createJellyException(String reason,
Exception cause)
Creates a new Jelly exception, adorning it with location information
|
protected Tag |
createTag()
Factory method to create a new Tag instance.
|
protected void |
endNamespacePrefixes(XMLOutput output)
End the new namespace prefixes mapped for the current element
|
protected Expression |
getAttribute(String name)
Retrieves the expression of the given attribute name.
|
protected String |
getBodyText(JellyContext context,
boolean shouldEscape)
Evaluates the body and obtains it as a string.
|
int |
getColumnNumber() |
String |
getElementName() |
String |
getFileName() |
int |
getLineNumber() |
String |
getLocalName()
Returns the local, non namespaced XML name of this tag
|
Map |
getNamespaceContext()
Returns the namespace context of this tag.
|
String |
getNsUri() |
TagScript |
getParent()
Returns the parent.
|
Attributes |
getSaxAttributes()
Returns the SAX attributes of this tag
|
URL |
getScriptURL()
Base URL from which the script (that uses this tag) is loaded.
|
Tag |
getTag(JellyContext context) |
Script |
getTagBody()
Returns the tagBody.
|
TagFactory |
getTagFactory()
Returns the Factory of Tag instances.
|
protected void |
handleException(Error e)
A helper method to handle this non-Jelly exception.
|
protected void |
handleException(Exception e)
A helper method to handle this non-Jelly exception.
|
protected void |
handleException(JellyException e)
A helper method to handle this Jelly exception.
|
protected void |
handleException(JellyTagException e)
A helper method to handle this Jelly exception.
|
static TagScript |
newInstance(Class tagClass) |
void |
run(JellyContext context,
XMLOutput output)
Evaluates the body of a tag
|
void |
setColumnNumber(int columnNumber)
Sets the column number of the tag
|
protected void |
setContextURLs(JellyContext context)
Set the context's root and current URL if not present
|
void |
setElementName(String elementName)
Sets the element name which caused the problem
|
void |
setFileName(String fileName)
Sets the Jelly file which caused the problem
|
void |
setLineNumber(int lineNumber)
Sets the line number of the tag
|
void |
setLocalName(String localName)
Sets the local, non namespaced name of this tag.
|
void |
setLocator(Locator locator)
Configures this TagScript from the SAX Locator, setting the column
and line numbers
|
void |
setNsUri(String nsUri) |
void |
setParent(TagScript parent)
Sets the parent.
|
void |
setSaxAttributes(Attributes saxAttributes)
Sets the SAX attributes of this tag
|
protected void |
setTag(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 DynamicTag
|
void |
setTagBody(Script tagBody)
Sets the tagBody.
|
void |
setTagFactory(TagFactory tagFactory)
Sets the Factory of Tag instances.
|
void |
setTagNamespacesMap(Map tagNamespacesMap)
Sets the optional namespaces prefix -> URI map of
the namespaces attached to this Tag
|
protected void |
startNamespacePrefixes(XMLOutput output)
Output the new namespace prefixes used for this element
|
String |
toString() |
protected Map<String,ExpressionAttribute> attributes
public TagScript()
public TagScript(TagFactory tagFactory)
public static TagScript newInstance(Class tagClass)
public Script compile() throws JellyException
compile
in interface Script
JellyException
public void setTagNamespacesMap(Map tagNamespacesMap)
public void setLocator(Locator locator)
public void addAttribute(String name, Expression expression)
public void addAttribute(String name, String prefix, String nsURI, Expression expression)
public void run(JellyContext context, XMLOutput output) throws JellyTagException
run
in interface Script
JellyTagException
protected void setContextURLs(JellyContext context) throws JellyTagException
context
- JellyTagException
public Tag getTag(JellyContext context) throws JellyException
JellyException
public TagFactory getTagFactory()
public void setTagFactory(TagFactory tagFactory)
tagFactory
- The factory to setpublic TagScript getParent()
public Script getTagBody()
public void setParent(TagScript parent)
parent
- The parent to setpublic void setTagBody(Script tagBody)
tagBody
- The tagBody to setpublic String getFileName()
public void setFileName(String fileName)
public URL getScriptURL()
public String getElementName()
public void setElementName(String elementName)
public int getLineNumber()
public void setLineNumber(int lineNumber)
public int getColumnNumber()
public void setColumnNumber(int columnNumber)
public Attributes getSaxAttributes()
public void setSaxAttributes(Attributes saxAttributes)
saxAttributes
- The saxAttributes to setpublic String getLocalName()
public void setLocalName(String localName)
localName
- The localName to setpublic String getNsUri()
public void setNsUri(String nsUri)
public Map getNamespaceContext()
protected Tag createTag() throws JellyException
JellyException
protected void configureTag(Tag tag, JellyContext context) throws JellyException
JellyException
protected void clearTag()
protected void setTag(Tag tag, JellyContext context)
protected void startNamespacePrefixes(XMLOutput output) throws SAXException
SAXException
protected void endNamespacePrefixes(XMLOutput output) throws SAXException
SAXException
protected Object convertType(Object value, Class requiredType) throws JellyException
value
- is the value to be converted. This will not be nullrequiredType
- the type that the value should be converted toJellyException
protected JellyException createJellyException(String reason)
protected JellyException createJellyException(String reason, Exception cause)
protected void handleException(JellyTagException e) throws JellyTagException
JellyTagException
protected void handleException(JellyException e) throws JellyTagException
JellyTagException
protected void applyLocation(LocationAware locationAware)
protected void handleException(Exception e) throws JellyTagException
JellyTagException
protected void handleException(Error e) throws Error, JellyTagException
Error
JellyTagException
protected Expression getAttribute(String name)
Expression.NULL
so that the caller doesn't have to do the null check.protected String getBodyText(JellyContext context, boolean shouldEscape) throws JellyTagException
JellyTagException
Copyright © 2014 Apache Software Foundation. All rights reserved.