cookxml.core.taglibrary
Class InheritableTagLibrary

java.lang.Object
  extended by cookxml.core.taglibrary.SingleNSTagLibrary
      extended by cookxml.core.taglibrary.InheritableTagLibrary
All Implemented Interfaces:
DocletTagLibrary, TagLibrary

public class InheritableTagLibrary
extends SingleNSTagLibrary

This tag library class avoids the hassele of setting up all the things (adders and setters) for a tag. It suited perfectly for Swing in which most components inherit JComponent.

Since:
CookXml 1.0
Version:
$Id: InheritableTagLibrary.java 254 2007-06-10 06:51:35Z coconut $

Constructor Summary
InheritableTagLibrary()
          Construct a tag library that doesn't have a parent.
InheritableTagLibrary(TagLibrary parentTagLibrary)
          Construct a tag library with a parent.
 
Method Summary
 void addAdder(String tag, Adder adder)
          Instead of creating an adder that does it all, this function internally creates a compound adder that combine the functionalities of individual specialized adders.
 Adder getAdder(String ns, String tag)
          Get the Adder delegate associated with the namespace and tag.
 Map getAttributes(String ns, String tag)
          This function reports the attributes associated with a particular tag.
 LinkedList getParentTags(String tag)
          Retrieve the direct parent tags.
 LinkedList getParentTags(String ns, String tag)
          This for documentation purpose to retrieve the direct parent tags.
 Setter getSetter(String ns, String tag, String attrNS, String attr)
          Get the Setter delegate associated with the namespace and tag.
 void inheritTag(String parentTag, String thisTag)
          create a tag inheritance.
 void inheritTag(String parentNs, String parentTag, String thisTag)
          Create a tag inheritance.
 
Methods inherited from class cookxml.core.taglibrary.SingleNSTagLibrary
getConverter, getConverters, getCreator, getNameSpace, getNameSpaces, getParent, getSpecialCreator, getTags, setAdder, setConverter, setCreator, setNameSpace, setSetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InheritableTagLibrary

public InheritableTagLibrary()
Construct a tag library that doesn't have a parent.


InheritableTagLibrary

public InheritableTagLibrary(TagLibrary parentTagLibrary)
Construct a tag library with a parent.

Parameters:
parentTagLibrary - the parent tag library.
Method Detail

inheritTag

public void inheritTag(String parentNs,
                       String parentTag,
                       String thisTag)
Create a tag inheritance. Adder and setters are inherited.

Cycles must not exist!

Parameters:
parentNs - the optional namespace of the parent tag. If null, then use the same name space as the childTag.
parentTag - the parent tag name
thisTag - the child tag name

inheritTag

public void inheritTag(String parentTag,
                       String thisTag)
create a tag inheritance. Adder and setters are inherited. Cycles must not exist!

Parameters:
parentTag - the parent tag name
thisTag - the child tag name

getSetter

public Setter getSetter(String ns,
                        String tag,
                        String attrNS,
                        String attr)
Description copied from interface: TagLibrary
Get the Setter delegate associated with the namespace and tag.

Specified by:
getSetter in interface TagLibrary
Overrides:
getSetter in class SingleNSTagLibrary
Parameters:
ns - the namespace.
tag - the tag name.
attrNS - the attribute namespace.
attr - the attribute name @return the Setter delegate.

getAdder

public Adder getAdder(String ns,
                      String tag)
Description copied from interface: TagLibrary
Get the Adder delegate associated with the namespace and tag.

Specified by:
getAdder in interface TagLibrary
Overrides:
getAdder in class SingleNSTagLibrary
Parameters:
ns - the tag namespace.
tag - the tag name.
Returns:
the Adder delegate.

addAdder

public void addAdder(String tag,
                     Adder adder)
Instead of creating an adder that does it all, this function internally creates a compound adder that combine the functionalities of individual specialized adders. The adder added later has precedence over adders added earlier.

Parameters:
tag - the tag name.
adder - the individual Adder.

getParentTags

public LinkedList getParentTags(String tag)
Retrieve the direct parent tags. If the parent tag is in a different namespace, the entry will be in tag:ns format.

Parameters:
tag - the tag name
Returns:
direct parent tags

getParentTags

public LinkedList getParentTags(String ns,
                                String tag)
This for documentation purpose to retrieve the direct parent tags.

If the parent tag is in a different namespace, the entry will be in tag:ns format.

Parameters:
ns - the namespace of the tag.
tag - the tag name
Returns:
direct parent tags

getAttributes

public Map getAttributes(String ns,
                         String tag)
Description copied from interface: DocletTagLibrary
This function reports the attributes associated with a particular tag.

The returned map uses XML namespace as the key, and a string array of attribute names as the value as its entries.

Specified by:
getAttributes in interface DocletTagLibrary
Overrides:
getAttributes in class SingleNSTagLibrary
Parameters:
ns - the namespace of the tag.
tag - the tag name.
Returns:
a map using XML namespace string as the key, and String[] as value for the tag names.