com.raritantechnologies.utils.tree
Class XMLTreeBuilder

java.lang.Object
  extended bycom.raritantechnologies.utils.tree.XMLTreeBuilder
All Implemented Interfaces:
IConfigurable, ITreeBuilder, IXMLTreeBuilder

public class XMLTreeBuilder
extends java.lang.Object
implements IXMLTreeBuilder

Builds TreeNode nodes from "flat" XML - i.e. XML in which nodes hierarchy is determined by parent or child ID links. (For hierarchical XML use the SAXTreeBuilder).

Uses an XMLResultProcessor to process the initial XML into a format appropriate for the final tree.

XML Configuration Template:
 <TreeBuilder class="com.raritantechnologies.utils.tree.XMLTreeBuilder"
               fileName="BASE_PATH/data/TheTree.xml"
               fileNameParam="[ name of request param that includes fileName - can include {SESSION:<sesssion param>} or {REQUEST:<request param>} sections ]"
               treeName="Some Taxonomy"
               useFirstNodeAsRoot="[ true|false(default) - alternative to specifying root treeName ]"
               resultTag="[ tag name in XML with TreeNode data ]"
               nodeIDField="[field in XMLResult to get ID]"
               parentIDField="[field in XMLResult to get parentID]"
               alternateParentIDFields="[ list of alternate parent ID field names ]"
               rootIDValue="[value of root node ID]"
               multipleParents="true/false" 
               nameField="[field for node name - use fieldName[n] if multiple values]"
               debug="true|false(default)"
               debugMemory="[ true|false(default) ]"
               refreshTreeParam="[ parameter to use to determine if tree should be refreshed ]" >

   <!-- applies SAX filter to pre-process the XML input -->
   <XMLResultProcessor>
      <!-- See XMLResultProcessor for configuration details.  -->
   </XMLResultProcessor>

    <!-- Optionally: can specify the tree XML in the configuration -->
    <TreeXML>
      <!-- Tree Data here... -->
    </TreeXML>

 </TreeBuilder>
 

Developed by Raritan Technologies Inc..

Author:
Ted Sullivan

Field Summary
 
Fields inherited from interface com.raritantechnologies.utils.tree.ITreeBuilder
TEMPLATE
 
Constructor Summary
XMLTreeBuilder()
           
 
Method Summary
 TreeRoot buildTree(org.w3c.dom.Document xmlDoc)
           
 TreeRoot buildTree(RaritanPageContext rpc)
           
 TreeRoot buildTree(java.lang.String xmlString)
           
 TreeRoot buildTree(XMLResultSet xmlResSet)
           
 java.lang.String getConfigurationXML()
           
 java.lang.String getConfigurationXML(java.lang.String configurationTemplate)
           
 void getConfigurationXML(java.io.Writer writer)
           
 void initialize(org.w3c.dom.Element elem)
          Initializes the object from an XML tag or element.
 TreeRoot refreshTree(TreeRoot theTree, RaritanPageContext pContext)
          Method to enable dynamic or refreshable trees.
 void setXMLResultSet(XMLResultSet xmlResSet)
           
 void setXMLString(java.lang.String xmlString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTreeBuilder

public XMLTreeBuilder()
Method Detail

buildTree

public TreeRoot buildTree(RaritanPageContext rpc)
Specified by:
buildTree in interface ITreeBuilder

refreshTree

public TreeRoot refreshTree(TreeRoot theTree,
                            RaritanPageContext pContext)
Description copied from interface: ITreeBuilder

Method to enable dynamic or refreshable trees. Static tree builders should implement this by returning the passed in tree object. Dynamic tree builders should implement this by returning the output of their buildTree( ) method or by pruning/growing the given tree as appropriate.

ITreeBuilders that support "lazy tree node evaluation" should use this method to determine which nodes in the tree need to be updated (TreeNode.needsUpdate( ) method returns true.

Specified by:
refreshTree in interface ITreeBuilder

buildTree

public TreeRoot buildTree(org.w3c.dom.Document xmlDoc)

buildTree

public TreeRoot buildTree(java.lang.String xmlString)
Specified by:
buildTree in interface IXMLTreeBuilder

buildTree

public TreeRoot buildTree(XMLResultSet xmlResSet)
Specified by:
buildTree in interface IXMLTreeBuilder

initialize

public void initialize(org.w3c.dom.Element elem)
Description copied from interface: IConfigurable
Initializes the object from an XML tag or element. This method is called by the Framework as part of the application initializtion. see ConfigurationManager, XMLConfigurationManager, XMLSearchFieldMapFactory, XMLSearchSourceFactory. Configurable objects that are owned or contained by other configurable objects will be initialized in by the parent object.

Specified by:
initialize in interface IConfigurable

setXMLResultSet

public void setXMLResultSet(XMLResultSet xmlResSet)
Specified by:
setXMLResultSet in interface IXMLTreeBuilder

setXMLString

public void setXMLString(java.lang.String xmlString)
Specified by:
setXMLString in interface IXMLTreeBuilder

getConfigurationXML

public void getConfigurationXML(java.io.Writer writer)
                         throws java.io.IOException
Throws:
java.io.IOException

getConfigurationXML

public java.lang.String getConfigurationXML()

getConfigurationXML

public java.lang.String getConfigurationXML(java.lang.String configurationTemplate)