org.apache.commons.jelly

## Class TagSupport

- java.lang.Object
- - org.apache.commons.jelly.TagSupport

All Implemented Interfaces:
  Tag

Direct Known Subclasses:
  AttributeTag, AttributeTag, BaseClassLoaderTag, BreakTag, BundleTag, CaseTag, CaseTag, CatchTag, ChooseTag, DefaultTag, DefineTagSupport, DynabeanTag, DynaclassTag, DynaTagSupport, ElementTag, ExprTag, FileTag, ForEachTag, FormatDateTag, GetStaticTag, IfTag, ImportTag, IncludeTag, InvokeBodyTag, InvokeStaticTag, InvokeTag, InvokeTag, JellyTag, LogTagSupport, MessageTag, MuteTag, OtherwiseTag, ParamTag, ParamTag, ParseTag, ParseTagSupport, PropertyTag, RemoveTag, ReplaceNamespaceTag, RunTag, ScopeTag, ScriptTag, SetBundleTag, SetLocaleTag, SetTag, SetTag, SetTimeZoneTag, SuiteTag, SuperTag, SwitchTag, TaglibTag, ThreadTag, TimeZoneTag, WhenTag, WhileTag, WhitespaceTag, XPathTagSupport

    public abstract class TagSupport
    extends Object
    implements Tag

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

Version:
  $Revision: 155420 $
Author:
  James Strachan

### Field Summary

Fields
`protected Script` `body` the body of the tag
`protected JellyContext` `context` The current context
`protected Tag` `parent` the parent of this tag

### Constructor Summary

Constructors
Constructor and Description
`TagSupport()`
`TagSupport(boolean shouldTrim)`

### Method Summary

Methods
`protected Tag` `findAncestorWithClass(Class parentClass)` Searches up the parent hierarchy for a Tag of the given type.
`protected Tag` `findAncestorWithClass(Class[] parentClasses)` Searches up the parent hierarchy for a Tag of one of the given types.
`protected Tag` `findAncestorWithClass(Collection parentClasses)` Searches up the parent hierarchy for a Tag of one of the given types.
`static Tag` `findAncestorWithClass(Tag from, Class tagClass)` Searches up the parent hierarchy from the given tag for a Tag of the given type
`static Tag` `findAncestorWithClass(Tag from, Class[] tagClasses)` Searches up the parent hierarchy from the given tag for a Tag matching one or more of given types.
`static Tag` `findAncestorWithClass(Tag from, Collection tagClasses)` Searches up the parent hierarchy from the given tag for a Tag matching one or more of given types.
`Script` `getBody()`
`protected String` `getBodyText()` Executes the body of the tag and returns the result as a String.
`protected String` `getBodyText(boolean shouldEscape)` Executes the body of the tag and returns the result as a String.
`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` `isEscapeText()` Returns whether the body of this tag will be escaped or not.
`boolean` `isTrim()` Deprecated. Trimming is now handled during parsing of the script, like it does in XSLT.
`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` `setEscapeText(boolean escapeText)` Sets whether the body of the tag should be escaped as text (so that < and > are escaped as &lt; and &gt;), which is the default or leave the text as XML.
`void` `setParent(Tag parent)` Sets the parent of this tag
`void` `setTrim(boolean shouldTrim)` Deprecated. Trimming is now handled during parsing of the script, like it does in XSLT.
`protected void` `trimBody()` Deprecated. Trimming is now handled during parsing of the script, like it does in XSLT.

### 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

#### context

    protected JellyContext context

The current context

### Constructor Detail

#### TagSupport

    public TagSupport()

#### TagSupport

    public TagSupport(boolean shouldTrim)

### Method Detail

#### findAncestorWithClass

    public static Tag findAncestorWithClass(Tag from,
                            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

#### findAncestorWithClass

    public static Tag findAncestorWithClass(Tag from,
                            Collection tagClasses)

Searches up the parent hierarchy from the given tag for a Tag matching one or more of given types.

Parameters:
  `from` - the tag to start searching from
  `tagClasses` - a Collection of Class types that might match
Returns:
  the tag of the given type or null if it could not be found

#### findAncestorWithClass

    public static Tag findAncestorWithClass(Tag from,
                            Class[] tagClasses)

Searches up the parent hierarchy from the given tag for a Tag matching one or more of given types.

Parameters:
  `from` - the tag to start searching from
  `tagClasses` - an array of types that might match
Returns:
  the tag of the given type or null if it could not be found
See Also:
  `findAncestorWithClass(Tag,Collection)`

#### setTrim

    public void setTrim(boolean shouldTrim)

Deprecated. Trimming is now handled during parsing of the script, like it does in XSLT.
Sets whether whitespace inside this tag should be trimmed or not. Defaults to true so whitespace is trimmed

#### isTrim

    public boolean isTrim()

Deprecated. Trimming is now handled during parsing of the script, like it does in XSLT.

#### 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 JellyTagException

Sets the context in which the tag will be run

Specified by:
  `setContext` in interface `Tag`
Throws:
  `JellyTagException`

#### invokeBody

    public void invokeBody(XMLOutput output)
                    throws JellyTagException

Invokes the body of this tag using the given output

Specified by:
  `invokeBody` in interface `Tag`
Throws:
  `JellyTagException`

#### findAncestorWithClass

    protected Tag findAncestorWithClass(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

#### findAncestorWithClass

    protected Tag findAncestorWithClass(Class[] parentClasses)

Searches up the parent hierarchy for a Tag of one of the given types.

Returns:
  the tag of the given type or null if it could not be found
See Also:
  `findAncestorWithClass(Collection)`

#### findAncestorWithClass

    protected Tag findAncestorWithClass(Collection parentClasses)

Searches up the parent hierarchy for a Tag of one of the given types.

Returns:
  the tag of the given type or null if it could not be found

#### getBodyText

    protected String getBodyText()
                          throws JellyTagException

Executes the body of the tag and returns the result as a String.

Returns:
  the text evaluation of the body
Throws:
  `JellyTagException`

#### getBodyText

    protected String getBodyText(boolean shouldEscape)
                          throws JellyTagException

Executes the body of the tag and returns the result as a String.

Parameters:
  `shouldEscape` - Signal if the text should be escaped.
Returns:
  the text evaluation of the body
Throws:
  `JellyTagException`

#### trimBody

    protected void trimBody()

Deprecated. Trimming is now handled during parsing of the script, like it does in XSLT.
Find all text nodes inside the top level of this body and if they are just whitespace then remove them

#### isEscapeText

    public boolean isEscapeText()

Returns whether the body of this tag will be escaped or not.

#### setEscapeText

    public void setEscapeText(boolean escapeText)

Sets whether the body of the tag should be escaped as text (so that < and > are escaped as &lt; and &gt;), which is the default or leave the text as XML.