org.apache.commons.jelly.impl
Class TagScript

java.lang.Object
  |
  +--org.apache.commons.jelly.impl.TagScript
All Implemented Interfaces:
Script
Direct Known Subclasses:
BeanTagScript, DynaTagScript

public abstract class TagScript
extends java.lang.Object
implements Script

TagScript abstract base class for a script that evaluates a custom tag.

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

Version:
$Revision: 1.19 $
Author:
James Strachan

Field Summary
protected  java.util.Map attributes
          The attribute expressions that are created
 
Constructor Summary
TagScript()
           
TagScript(TagFactory tagFactory)
           
 
Method Summary
 void addAttribute(java.lang.String name, Expression expression)
          Add an initialization attribute for the tag.
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)
          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  JellyException createJellyException(java.lang.String reason)
          Creates a new Jelly exception, adorning it with location information
protected  JellyException createJellyException(java.lang.String reason, java.lang.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
 int getColumnNumber()
           
 java.lang.String getElementName()
           
 java.lang.String getFileName()
           
 int getLineNumber()
           
 TagScript getParent()
          Returns the parent.
 Tag getTag()
           
 Script getTagBody()
          Returns the tagBody.
 TagFactory getTagFactory()
          Returns the Factory of Tag instances.
protected  void handleException(java.lang.Exception e)
          A helper method to handle this non-Jelly exception.
protected  void handleException(JellyException e)
          A helper method to handle this Jelly exception.
static TagScript newInstance(java.lang.Class tagClass)
           
 void setColumnNumber(int columnNumber)
          Sets the column number of the tag
 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 setLocator(org.xml.sax.Locator locator)
          Configures this TagScript from the SAX Locator, setting the column and line numbers
 void setNamespacesMap(java.util.Map namespacesMap)
          Sets the optional namespaces prefix -> URI map
 void setParent(TagScript parent)
          Sets the parent.
protected  void setTag(Tag tag)
          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.
protected  void startNamespacePrefixes(XMLOutput output)
          Output the new namespace prefixes used for this element
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jelly.Script
run
 

Field Detail

attributes

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

TagScript

public TagScript()

TagScript

public TagScript(TagFactory tagFactory)
Method Detail

newInstance

public static TagScript newInstance(java.lang.Class tagClass)
Returns:
a new TagScript based on whether the given Tag class is a bean tag or DynaTag

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compile

public Script compile()
               throws java.lang.Exception
Compiles the tags body
Specified by:
compile in interface Script

setNamespacesMap

public void setNamespacesMap(java.util.Map namespacesMap)
Sets the optional namespaces prefix -> URI map

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,
                         Expression expression)
Add an initialization attribute for the tag. This method must be called after the setTag() method

getTag

public Tag getTag()
           throws java.lang.Exception
Returns:
the tag to be evaluated, creating it lazily if required.

getTagFactory

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

setTagFactory

public void setTagFactory(TagFactory tagFactory)
Sets the Factory of Tag instances.
Parameters:
tagFactory - The factory to set

getParent

public TagScript getParent()
Returns the parent.
Returns:
TagScript

getTagBody

public Script getTagBody()
Returns the tagBody.
Returns:
Script

setParent

public void setParent(TagScript parent)
Sets the parent.
Parameters:
parent - The parent to set

setTagBody

public void setTagBody(Script tagBody)
Sets the tagBody.
Parameters:
tagBody - The tagBody to set

getFileName

public java.lang.String getFileName()
Returns:
the Jelly file which caused the problem

setFileName

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

getElementName

public java.lang.String getElementName()
Returns:
the element name which caused the problem

setElementName

public void setElementName(java.lang.String elementName)
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

createTag

protected Tag createTag()
                 throws java.lang.Exception
Factory method to create a new Tag instance. The default implementation is to delegate to the TagFactory

configureTag

protected void configureTag(Tag tag)
                     throws java.lang.Exception
Compiles a newly created tag if required, sets its parent and body.

clearTag

protected void clearTag()
Flushes the current cached tag so that it will be created, lazily, next invocation

setTag

protected void setTag(Tag tag)
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(XMLOutput output)
                               throws org.xml.sax.SAXException
Output the new namespace prefixes used for this element

endNamespacePrefixes

protected void endNamespacePrefixes(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 java.lang.Exception
Converts the given value to the required type.
Parameters:
value - is the value to be converted. This will not be null
requiredType - the type that the value should be converted to

handleException

protected void handleException(java.lang.Exception e)
                        throws java.lang.Exception
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.

createJellyException

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

createJellyException

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

handleException

protected void handleException(JellyException e)
                        throws java.lang.Exception
A helper method to handle this Jelly exception. This method adorns the JellyException with location information such as adding line number information etc.


Copyright © 2002-2002 Apache Software Foundation. All Rights Reserved.