org.apache.commons.jelly
Class TagSupport

java.lang.Object
  |
  +--org.apache.commons.jelly.TagSupport
All Implemented Interfaces:
Tag
Direct Known Subclasses:
AntlrTag, ApplyTemplatesTag, AskTag, AttributeTag, AttributeTag, BrokerTag, CaseTag, CatchTag, ChooseTag, ConnectionTag, DateParamTag, DefineTagSupport, DestinationTag, DriverTag, DynabeanTag, DynaBeanTagSupport, DynaclassTag, DynamicTag, ElementTag, ExprTag, FileScannerTag, FileTag, ForEachTag, GrammarTag, HeaderTag, IfTag, ImportTag, IncludeTag, IntrospectorTag, InvokeBodyTag, InvokeTag, JellyTag, LogTagSupport, MapEntryTag, MapTagSupport, MessageOperationTag, MessageTag, MethodSupportTag, NewTag, OtherwiseTag, ParamTag, ParseTag, ParseTagSupport, PropertyTag, PropertyTag, QuartzTagSupport, ResultSetTag, RunTag, ScriptTag, SetDataSourceTag, SetTag, SetTag, SqlTagSupport, StaticTag, StoreTag, SuiteTag, TaglibTag, TemplateTag, ThreadTag, TokenizeTag, TransactionTag, ValidateTag, VerifierTag, WerkzTagSupport, WhenTag, WhitespaceTag, WindowListenerTag, XPathTagSupport

public abstract class TagSupport
extends java.lang.Object
implements Tag

TagSupport an abstract base class which is useful to inherit from if developing your own tag.

Version:
$Revision: 1.17 $
Author:
James Strachan

Field Summary
protected  Script body
          the body of the tag
protected  JellyContext context
           
protected  boolean hasTrimmed
           
protected  Tag parent
          the parent of this tag
protected  java.lang.Boolean shouldTrim
          The current context
 
Constructor Summary
TagSupport()
           
TagSupport(boolean shouldTrim)
           
 
Method Summary
protected  Tag findAncestorWithClass(java.lang.Class parentClass)
          Searches up the parent hierarchy for a Tag of the given type
static Tag findAncestorWithClass(Tag from, java.lang.Class tagClass)
          Searches up the parent hierarchy from the given tag for a Tag of the given type
 Script getBody()
           
protected  java.lang.String getBodyText()
          Evaluates the given body using a buffer and returns the String of the result.
protected  java.lang.String getBodyText(boolean shouldEscape)
          Evaluates the given body using a buffer and returns the String of the result.
 JellyContext getContext()
          Gets the context in which the tag will be run
 Tag getParent()
           
 void invokeBody(XMLOutput output)
          Invokes the body of this tag using the given output
 boolean isTrim()
           
 void setBody(Script body)
          Sets the body of the tag
 void setContext(JellyContext context)
          Sets the context in which the tag will be run
 void setParent(Tag parent)
          Sets the parent of this tag
 void setTrim(boolean shouldTrim)
          Sets whether whitespace inside this tag should be trimmed or not.
protected  void trimBody()
          Find all text nodes inside the top level of this body and if they are just whitespace then remove them
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jelly.Tag
doTag
 

Field Detail

parent

protected Tag parent
the parent of this tag

body

protected Script body
the body of the tag

shouldTrim

protected java.lang.Boolean shouldTrim
The current context

hasTrimmed

protected boolean hasTrimmed

context

protected JellyContext context
Constructor Detail

TagSupport

public TagSupport()

TagSupport

public TagSupport(boolean shouldTrim)
Method Detail

findAncestorWithClass

public static Tag findAncestorWithClass(Tag from,
                                        java.lang.Class tagClass)
Searches up the parent hierarchy from the given tag for a Tag of the given type
Parameters:
from - the tag to start searching from
tagClass - the type of the tag to find
Returns:
the tag of the given type or null if it could not be found

setTrim

public void setTrim(boolean shouldTrim)
Sets whether whitespace inside this tag should be trimmed or not. Defaults to true so whitespace is trimmed

isTrim

public boolean isTrim()

getParent

public Tag getParent()
Specified by:
getParent in interface Tag
Returns:
the parent of this tag

setParent

public void setParent(Tag parent)
Sets the parent of this tag
Specified by:
setParent in interface Tag

getBody

public Script getBody()
Specified by:
getBody in interface Tag
Returns:
the body of the tag

setBody

public void setBody(Script body)
Sets the body of the tag
Specified by:
setBody in interface Tag

getContext

public JellyContext getContext()
Description copied from interface: Tag
Gets the context in which the tag will be run
Specified by:
getContext in interface Tag
Returns:
the context in which the tag will be run

setContext

public void setContext(JellyContext context)
                throws java.lang.Exception
Sets the context in which the tag will be run
Specified by:
setContext in interface Tag

invokeBody

public void invokeBody(XMLOutput output)
                throws java.lang.Exception
Invokes the body of this tag using the given output
Specified by:
invokeBody in interface Tag

findAncestorWithClass

protected Tag findAncestorWithClass(java.lang.Class parentClass)
Searches up the parent hierarchy for a Tag of the given type
Returns:
the tag of the given type or null if it could not be found

getBodyText

protected java.lang.String getBodyText()
                                throws java.lang.Exception
Evaluates the given body using a buffer and returns the String of the result.
Returns:
the text evaluation of the body

getBodyText

protected java.lang.String getBodyText(boolean shouldEscape)
                                throws java.lang.Exception
Evaluates the given body using a buffer and returns the String of the result.
Parameters:
shouldEscape - Signal if the text should be escaped.
Returns:
the text evaluation of the body

trimBody

protected void trimBody()
Find all text nodes inside the top level of this body and if they are just whitespace then remove them


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