cookxml.core.creator
Class GetInstanceCreator

java.lang.Object
  extended by cookxml.core.creator.GetInstanceCreator
All Implemented Interfaces:
DocletActionReporter, Creator

public class GetInstanceCreator
extends Object
implements Creator, DocletActionReporter

This creator creates a new object by calling a static function.

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

Method Summary
 Object create(String parentNS, String parentTag, Element elm, Object parentObj, cookxml.core.DecodeEngine decodeEngine)
          This function is called whenever decodeEngine starts processing an element.
 Object editFinished(String parentNS, String parentTag, Element elm, Object parentObj, Object obj, cookxml.core.DecodeEngine decodeEngine)
          This function is called when the element and its subnodes have all been processed.
 Object[] getActions(TagLibrary tagLibrary, String tagNS, String tag, String attrNS, String attr, Class cl)
          This function returns the related function/constructor/field/methods that is called by creator/setter etc.
static Creator getCreator(Class targetClass, String funcName)
          This function used to generate a creator that creates a new object using the public static function specified.
static Creator getCreator(Class targetClass, String funcName, boolean addAfterFinish)
          This function used to generate a creator that creates a new object using the public static function specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCreator

public static Creator getCreator(Class targetClass,
                                 String funcName)
                          throws CookXmlException
This function used to generate a creator that creates a new object using the public static function specified. The resulting object is added before its setup.

Parameters:
targetClass - the class object
funcName - the name of the static function to be called.
Returns:
a creator if the static function can be found.
Throws:
CookXmlException - in case the function could not be found.

getCreator

public static Creator getCreator(Class targetClass,
                                 String funcName,
                                 boolean addAfterFinish)
                          throws CookXmlException
This function used to generate a creator that creates a new object using the public static function specified.

Parameters:
targetClass - the class object
funcName - the name of the static function to be called.
addAfterFinish - a flag that indicates not to add the object after its creation, but rather wait until all the setup has been done.
Returns:
a creator if the static function can be found.
Throws:
CookXmlException - in case the function could not be found.

create

public Object create(String parentNS,
                     String parentTag,
                     Element elm,
                     Object parentObj,
                     cookxml.core.DecodeEngine decodeEngine)
Description copied from interface: Creator
This function is called whenever decodeEngine starts processing an element. It should return an object that corresponds to the tag, or null to indicate no object could be created. If the object returned is of NoAdd type, then the object is not added to the parent object by decodeEngine.

There can be creative use of this function. For example, one could create another instance of CookXml that process the element differently, then call this instanceof decodeEngine to add the processed object to the parent, and then return null to tell this instance of decodeEngine/CookXml to stop processing the element.

Specified by:
create in interface Creator
Parameters:
parentNS - the parent tag namespace.
parentTag - the parent tag that contains this element
elm - the DOM element that contains all the information regarding this node.
parentObj - the parent object in the node
decodeEngine - the decode engine that is being used @throws CreatorException
Returns:
the object created, or null to tell decodeEngine to stop processing this node

editFinished

public Object editFinished(String parentNS,
                           String parentTag,
                           Element elm,
                           Object parentObj,
                           Object obj,
                           cookxml.core.DecodeEngine decodeEngine)
                    throws CookXmlException
Description copied from interface: Creator
This function is called when the element and its subnodes have all been processed. and about to be returned. For many helper objects that implement NoAdd, this is a great time to generate the real object and call the decodeEngine.addChild to add the real object to the parent.

Specified by:
editFinished in interface Creator
Parameters:
parentNS - the parent tag namespace.
parentTag - the parent element tag
elm - the DOM element that contains all the information regarding this node.
parentObj - the parent object of the parent element
obj - the object that was created by this create function
decodeEngine - the decode engine that is being used.
Returns:
the object. The purpose is to allow a helper object to return the real object.
Throws:
CookXmlException

getActions

public Object[] getActions(TagLibrary tagLibrary,
                           String tagNS,
                           String tag,
                           String attrNS,
                           String attr,
                           Class cl)
Description copied from interface: DocletActionReporter
This function returns the related function/constructor/field/methods that is called by creator/setter etc. CookXmlDoc would then retrieve the JavaDoc associated with Member object and use it in the documentation.

Specified by:
getActions in interface DocletActionReporter
Parameters:
tagLibrary - the tag library being used.
tagNS - the namespace of the tag
tag - possible tag
attrNS - the namespace of the attribute
attr - the attribute
cl - the possible class
Returns:
A non-empty array of actions performed by this object.