Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.commons.jelly.impl
Class TagScript  view TagScript download TagScript.java

java.lang.Object
  extended byorg.apache.commons.jelly.impl.TagScript
All Implemented Interfaces:
org.apache.commons.jelly.Script
Direct Known Subclasses:
StaticTagScript

public class TagScript
extends java.lang.Object
implements org.apache.commons.jelly.Script

TagScript is a Script that evaluates a custom tag.

Note that this class should be re-entrant and used concurrently by multiple threads.

Version:
$Revision: 165507 $

Field Summary
protected  java.util.Map attributes
          The attribute expressions that are created
private  int columnNumber
          the column number of the tag
private  java.lang.String elementName
          the qualified element name which caused the problem
private  java.lang.String fileName
          the Jelly file which caused the problem
private  int lineNumber
          the line number of the tag
private  java.lang.String localName
          the local (non-namespaced) tag name
private static org.apache.commons.logging.Log log
          The Log to which logging calls will be made.
private  java.util.Map namespaceContext
          The optional namespace context mapping all prefixes -> URIs in scope at the point this tag is used.
private  TagScript parent
          the parent TagScript
private  org.xml.sax.Attributes saxAttributes
          the SAX attributes
private  java.net.URL scriptURL
          the url of the script when parsed
private  org.apache.commons.jelly.Script tagBody
          the body script used for this tag
private  TagFactory tagFactory
          the factory of Tag instances
private  java.util.Map tagNamespacesMap
          the optional namespaces Map of prefix -> URI of this single Tag
private  java.util.Map threadLocalTagCache
          A synchronized WeakHashMap from the current Thread (key) to a Tag object (value).
 
Constructor Summary
TagScript()
           
TagScript(TagFactory tagFactory)
           
 
Method Summary
 void addAttribute(java.lang.String name, org.apache.commons.jelly.expression.Expression expression)
          Add an initialization attribute for the tag.
protected  void applyLocation(org.apache.commons.jelly.LocationAware locationAware)
           
 org.apache.commons.jelly.Script compile()
          Compiles the tags body
protected  void configureTag(org.apache.commons.jelly.Tag tag, org.apache.commons.jelly.JellyContext context)
          Compiles a newly created tag if required, sets its parent and body.
protected  java.lang.Object convertType(java.lang.Object value, java.lang.Class requiredType)
          Converts the given value to the required type.
protected  org.apache.commons.jelly.JellyException createJellyException(java.lang.String reason)
          Creates a new Jelly exception, adorning it with location information
protected  org.apache.commons.jelly.JellyException createJellyException(java.lang.String reason, java.lang.Exception cause)
          Creates a new Jelly exception, adorning it with location information
protected  org.apache.commons.jelly.Tag createTag()
          Factory method to create a new Tag instance.
protected  void endNamespacePrefixes(org.apache.commons.jelly.XMLOutput output)
          End the new namespace prefixes mapped for the current element
 int getColumnNumber()
           
 java.lang.String getElementName()
           
 java.lang.String getFileName()
           
private  java.net.URL getJellyContextURL(java.net.URL url)
          Strips off the name of a script to create a new context URL FIXME: Copied from JellyContext
 int getLineNumber()
           
 java.lang.String getLocalName()
          Returns the local, non namespaced XML name of this tag
 java.util.Map getNamespaceContext()
          Returns the namespace context of this tag.
 TagScript getParent()
          Returns the parent.
 org.xml.sax.Attributes getSaxAttributes()
          Returns the SAX attributes of this tag
 org.apache.commons.jelly.Tag getTag(org.apache.commons.jelly.JellyContext context)
           
 org.apache.commons.jelly.Script getTagBody()
          Returns the tagBody.
 TagFactory getTagFactory()
          Returns the Factory of Tag instances.
protected  void handleException(java.lang.Error e)
          A helper method to handle this non-Jelly exception.
protected  void handleException(java.lang.Exception e)
          A helper method to handle this non-Jelly exception.
protected  void handleException(org.apache.commons.jelly.JellyException e)
          A helper method to handle this Jelly exception.
protected  void handleException(org.apache.commons.jelly.JellyTagException e)
          A helper method to handle this Jelly exception.
static TagScript newInstance(java.lang.Class tagClass)
           
 void run(org.apache.commons.jelly.JellyContext context, org.apache.commons.jelly.XMLOutput output)
          Evaluates the body of a tag
 void setColumnNumber(int columnNumber)
          Sets the column number of the tag
protected  void setContextURLs(org.apache.commons.jelly.JellyContext context)
          Set the context's root and current URL if not present
 void setElementName(java.lang.String elementName)
          Sets the element name which caused the problem
 void setFileName(java.lang.String fileName)
          Sets the Jelly file which caused the problem
 void setLineNumber(int lineNumber)
          Sets the line number of the tag
 void setLocalName(java.lang.String localName)
          Sets the local, non namespaced name of this tag.
 void setLocator(org.xml.sax.Locator locator)
          Configures this TagScript from the SAX Locator, setting the column and line numbers
 void setParent(TagScript parent)
          Sets the parent.
 void setSaxAttributes(org.xml.sax.Attributes saxAttributes)
          Sets the SAX attributes of this tag
protected  void setTag(org.apache.commons.jelly.Tag tag, org.apache.commons.jelly.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(org.apache.commons.jelly.Script tagBody)
          Sets the tagBody.
 void setTagFactory(TagFactory tagFactory)
          Sets the Factory of Tag instances.
 void setTagNamespacesMap(java.util.Map tagNamespacesMap)
          Sets the optional namespaces prefix -> URI map of the namespaces attached to this Tag
protected  void startNamespacePrefixes(org.apache.commons.jelly.XMLOutput output)
          Output the new namespace prefixes used for this element
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log
The Log to which logging calls will be made.


attributes

protected java.util.Map attributes
The attribute expressions that are created


tagNamespacesMap

private java.util.Map tagNamespacesMap
the optional namespaces Map of prefix -> URI of this single Tag


namespaceContext

private java.util.Map namespaceContext
The optional namespace context mapping all prefixes -> URIs in scope at the point this tag is used. This Map is only created lazily if it is required by the NamespaceAwareTag.


fileName

private java.lang.String fileName
the Jelly file which caused the problem


elementName

private java.lang.String elementName
the qualified element name which caused the problem


localName

private java.lang.String localName
the local (non-namespaced) tag name


lineNumber

private int lineNumber
the line number of the tag


columnNumber

private int columnNumber
the column number of the tag


tagFactory

private TagFactory tagFactory
the factory of Tag instances


tagBody

private org.apache.commons.jelly.Script tagBody
the body script used for this tag


parent

private TagScript parent
the parent TagScript


saxAttributes

private org.xml.sax.Attributes saxAttributes
the SAX attributes


scriptURL

private java.net.URL scriptURL
the url of the script when parsed


threadLocalTagCache

private java.util.Map threadLocalTagCache
A synchronized WeakHashMap from the current Thread (key) to a Tag object (value).

Constructor Detail

TagScript

public TagScript()

TagScript

public TagScript(TagFactory tagFactory)
Method Detail

newInstance

public static TagScript newInstance(java.lang.Class tagClass)

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


compile

public org.apache.commons.jelly.Script compile()
                                        throws org.apache.commons.jelly.JellyException
Compiles the tags body

Specified by:
compile in interface org.apache.commons.jelly.Script

setTagNamespacesMap

public void setTagNamespacesMap(java.util.Map tagNamespacesMap)
Sets the optional namespaces prefix -> URI map of the namespaces attached to this Tag


setLocator

public void setLocator(org.xml.sax.Locator locator)
Configures this TagScript from the SAX Locator, setting the column and line numbers


addAttribute

public void addAttribute(java.lang.String name,
                         org.apache.commons.jelly.expression.Expression expression)
Add an initialization attribute for the tag. This method must be called after the setTag() method


getJellyContextURL

private java.net.URL getJellyContextURL(java.net.URL url)
                                 throws java.net.MalformedURLException
Strips off the name of a script to create a new context URL FIXME: Copied from JellyContext


run

public void run(org.apache.commons.jelly.JellyContext context,
                org.apache.commons.jelly.XMLOutput output)
         throws org.apache.commons.jelly.JellyTagException
Evaluates the body of a tag

Specified by:
run in interface org.apache.commons.jelly.Script

setContextURLs

protected void setContextURLs(org.apache.commons.jelly.JellyContext context)
                       throws org.apache.commons.jelly.JellyTagException
Set the context's root and current URL if not present


getTag

public org.apache.commons.jelly.Tag getTag(org.apache.commons.jelly.JellyContext context)
                                    throws org.apache.commons.jelly.JellyException

getTagFactory

public TagFactory getTagFactory()
Returns the Factory of Tag instances.


setTagFactory

public void setTagFactory(TagFactory tagFactory)
Sets the Factory of Tag instances.


getParent

public TagScript getParent()
Returns the parent.


getTagBody

public org.apache.commons.jelly.Script getTagBody()
Returns the tagBody.


setParent

public void setParent(TagScript parent)
Sets the parent.


setTagBody

public void setTagBody(org.apache.commons.jelly.Script tagBody)
Sets the tagBody.


getFileName

public java.lang.String getFileName()

setFileName

public void setFileName(java.lang.String fileName)
Sets the Jelly file which caused the problem


getElementName

public java.lang.String getElementName()

setElementName

public void setElementName(java.lang.String elementName)
Sets the element name which caused the problem


getLineNumber

public int getLineNumber()

setLineNumber

public void setLineNumber(int lineNumber)
Sets the line number of the tag


getColumnNumber

public int getColumnNumber()

setColumnNumber

public void setColumnNumber(int columnNumber)
Sets the column number of the tag


getSaxAttributes

public org.xml.sax.Attributes getSaxAttributes()
Returns the SAX attributes of this tag


setSaxAttributes

public void setSaxAttributes(org.xml.sax.Attributes saxAttributes)
Sets the SAX attributes of this tag


getLocalName

public java.lang.String getLocalName()
Returns the local, non namespaced XML name of this tag


setLocalName

public void setLocalName(java.lang.String localName)
Sets the local, non namespaced name of this tag.


getNamespaceContext

public java.util.Map 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.


createTag

protected org.apache.commons.jelly.Tag createTag()
                                          throws org.apache.commons.jelly.JellyException
Factory method to create a new Tag instance. The default implementation is to delegate to the TagFactory


configureTag

protected void configureTag(org.apache.commons.jelly.Tag tag,
                            org.apache.commons.jelly.JellyContext context)
                     throws org.apache.commons.jelly.JellyException
Compiles a newly created tag if required, sets its parent and body.


setTag

protected void setTag(org.apache.commons.jelly.Tag tag,
                      org.apache.commons.jelly.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


startNamespacePrefixes

protected void startNamespacePrefixes(org.apache.commons.jelly.XMLOutput output)
                               throws org.xml.sax.SAXException
Output the new namespace prefixes used for this element


endNamespacePrefixes

protected void endNamespacePrefixes(org.apache.commons.jelly.XMLOutput output)
                             throws org.xml.sax.SAXException
End the new namespace prefixes mapped for the current element


convertType

protected java.lang.Object convertType(java.lang.Object value,
                                       java.lang.Class requiredType)
                                throws org.apache.commons.jelly.JellyException
Converts the given value to the required type.


createJellyException

protected org.apache.commons.jelly.JellyException createJellyException(java.lang.String reason)
Creates a new Jelly exception, adorning it with location information


createJellyException

protected org.apache.commons.jelly.JellyException createJellyException(java.lang.String reason,
                                                                       java.lang.Exception cause)
Creates a new Jelly exception, adorning it with location information


handleException

protected void handleException(org.apache.commons.jelly.JellyTagException e)
                        throws org.apache.commons.jelly.JellyTagException
A helper method to handle this Jelly exception. This method adorns the JellyException with location information such as adding line number information etc.


handleException

protected void handleException(org.apache.commons.jelly.JellyException e)
                        throws org.apache.commons.jelly.JellyTagException
A helper method to handle this Jelly exception. This method adorns the JellyException with location information such as adding line number information etc.


applyLocation

protected void applyLocation(org.apache.commons.jelly.LocationAware locationAware)

handleException

protected void handleException(java.lang.Exception e)
                        throws org.apache.commons.jelly.JellyTagException
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.


handleException

protected void handleException(java.lang.Error e)
                        throws java.lang.Error,
                               org.apache.commons.jelly.JellyTagException
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?