cookxml.core.taglibrary
Class SingleNSTagLibrary

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

public class SingleNSTagLibrary
extends Object
implements DocletTagLibrary

This class by itself can only add creators, adders, setters, and converters for a single namespace. Hence the name SingleNSTagLibrary.

However, this library can inherit tag libraries of different namespaces. If the namespace of the element is null or the same as the this tag library's namespace, then this tag library is used. Otherwise, the parent tag library, if exists, is used for the lookup. Using parent-hiearchy is one way to create a tag library that can handle multiple namespaces.

This class was the TagLibrary class in CookXml 2.0.

Since:
CookXml 1.0
Version:
$Id: SingleNSTagLibrary.java 255 2007-06-10 07:08:13Z coconut $

Constructor Summary
SingleNSTagLibrary()
          The default constructor that creates an instance of SingleNSTagLibrary without a parent.
SingleNSTagLibrary(TagLibrary parentTagLibrary)
          The constructor that creates an instance of SingleNSTagLibrary with a parent tag library.
 
Method Summary
 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.
 Converter getConverter(String ns, Class targetClass)
          Get the Converter that converts a string attribute value into the target class.
 Map getConverters(String ns)
          This function reports the converters associated with a namespace.
 Creator getCreator(String ns, String tag)
          Get the Creator object factory associated with the namespace and tag.
 String getNameSpace()
          Get the namespace of the tag library.
 String[] getNameSpaces()
          This function reports the namespaces this tag library holds.
 TagLibrary getParent()
          This function reports the parent tagLibrary.
 Setter getSetter(String ns, String tag, String attrNS, String attr)
          Get the Setter delegate associated with the namespace and tag.
 SpecialCreator getSpecialCreator()
          Get the SpecialCreator for the TagLibrary.
 Map getTags()
          This function reports the tags having the creators and are located inside this tag library.
 void setAdder(String tag, Adder adder)
          Insert the adder for a tag into the tag library.
 void setConverter(Class targetClass, Converter converter)
          Insert a class converter into the tag library.
 void setCreator(String tag, Creator creator)
          Insert an object factory (Creator) for a tag into the tag library.
 void setNameSpace(String ns)
          Set the namespace of the tag library.
 void setSetter(String tag, String attr, Setter setter)
          Insert a setter delegate for a tag and the attribute into the tag library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleNSTagLibrary

public SingleNSTagLibrary()
The default constructor that creates an instance of SingleNSTagLibrary without a parent.


SingleNSTagLibrary

public SingleNSTagLibrary(TagLibrary parentTagLibrary)
The constructor that creates an instance of SingleNSTagLibrary with a parent tag library.

Note that the namespace for the parent and child tag library can be different.

Parameters:
parentTagLibrary - the parent tag library.
Method Detail

setNameSpace

public void setNameSpace(String ns)
Set the namespace of the tag library.

Parameters:
ns - the namespace of the tag library.
Since:
CookXml 3.0

getNameSpace

public String getNameSpace()
Get the namespace of the tag library.

Returns:
the namespace of the tag library.
Since:
CookXml 3.0

getSpecialCreator

public SpecialCreator getSpecialCreator()
Description copied from interface: TagLibrary
Get the SpecialCreator for the TagLibrary. This function is called only once per DecodeEngine instance.

Most TagLibrary implementations should simply return the parent tag library implementation if it does not handle it for sure. TagLibrary implementations that pool several TagLibraries should pool multiple SpecialCreator instances into one.

Specified by:
getSpecialCreator in interface TagLibrary
Returns:
the creator for the object creation.

getCreator

public Creator getCreator(String ns,
                          String tag)
Description copied from interface: TagLibrary
Get the Creator object factory associated with the namespace and tag.

Specified by:
getCreator in interface TagLibrary
Parameters:
ns - the namespace.
tag - the tag name.
Returns:
the Creator object.

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
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
Parameters:
ns - the tag namespace.
tag - the tag name.
Returns:
the Adder delegate.

getConverter

public Converter getConverter(String ns,
                              Class targetClass)
Description copied from interface: TagLibrary
Get the Converter that converts a string attribute value into the target class.

Specified by:
getConverter in interface TagLibrary
Parameters:
ns - the attribute namespace.
targetClass - the target class type.
Returns:
the Converter delegate.

setCreator

public void setCreator(String tag,
                       Creator creator)
Insert an object factory (Creator) for a tag into the tag library.

Parameters:
tag - the tag name.
creator - the Creator object.

setSetter

public void setSetter(String tag,
                      String attr,
                      Setter setter)
Insert a setter delegate for a tag and the attribute into the tag library.

Parameters:
tag - the tag name.
attr - the tag attribute.
setter - the Setter object.

setAdder

public void setAdder(String tag,
                     Adder adder)
Insert the adder for a tag into the tag library. Note that, this function will associate only one and only one adder with the tag.

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

setConverter

public void setConverter(Class targetClass,
                         Converter converter)
Insert a class converter into the tag library.

Parameters:
targetClass - the tag name.
converter - the Converter object.

getParent

public TagLibrary getParent()
Description copied from interface: DocletTagLibrary
This function reports the parent tagLibrary.

Specified by:
getParent in interface DocletTagLibrary
Returns:
the parent TagLibrary.

getNameSpaces

public String[] getNameSpaces()
Description copied from interface: DocletTagLibrary
This function reports the namespaces this tag library holds. It only reports *this* tag library's namespace, not parent tag library's.

Note that a namespace (a value inside the string array) can be null to indicate that the tag library does not handle namespaces.

Specified by:
getNameSpaces in interface DocletTagLibrary
Returns:
the namespaces this TagLibrary holds. It cannot be null and its size should be at least 1.

getTags

public Map getTags()
Description copied from interface: DocletTagLibrary
This function reports the tags having the creators and are located inside this tag library.

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

Specified by:
getTags in interface DocletTagLibrary
Returns:
a map using XML namespace string as the key, and String[] as value for the tag names.

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

getConverters

public Map getConverters(String ns)
Description copied from interface: DocletTagLibrary
This function reports the converters associated with a namespace.

Specified by:
getConverters in interface DocletTagLibrary
Parameters:
ns - the namespace.
Returns:
a non-null array of converters for the specified namespace.