cookxml.core.taglibrary
Class SingleNSTagLibrary

java.lang.Object
  extended bycookxml.core.taglibrary.SingleNSTagLibrary
All Implemented Interfaces:
TagLibrary
Direct Known Subclasses:
InheritableTagLibrary

public class SingleNSTagLibrary
extends Object
implements TagLibrary

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

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.
 Converter getConverter(String ns, Class targetClass)
          Get the Converter that converts a string attribute value into the target class.
 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.
 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.
 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.