com.raritantechnologies.utils.tree
Class SAXTreeBuilder

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

public class SAXTreeBuilder
extends java.lang.Object
implements IXMLTreeBuilder

Builds a TreeNode from hierarchically organized XML. (For "flat" XML use the XMLTreeBuilder).

XML Configuration Template:
  <TreeBuilder class="com.raritantechnologies.utils.tree.SAXTreeBuilder"
               fileName="BASE_PATH/data/TheTree.xml"
               treeName="Some Taxonomy" >

    <!-- One or more TreeNode elements: -->
    <TreeNode
             nodeTag="[Tag name if this is to be considered a TreeNode]"
             nameTag="[child tag from which the node gets its name]"
             nameAttribute="[tag attribute used to set the node name]"
             idTag="[ child tag from which the node gets its ID ]"
             idAttribute="[ attribute used for the node ID ]"
             attrTags="[Delimited list of child nodes or node attributes that are added as TreeNode attributes]" >

      <!-- Optional selection criterion for child tag containing node name -->
      <NameTagSelectCriteria>
        <Attribute name="[ name of attribute ]" value="[ value of attribute for match ]" />
      </NameTagSelectCriteria>

      <!-- map tag names (listed in 'attrTags') to TreeNode attribute names -->
      <AttributeMap input="[name of tag or name of tag attribute]" output="[name in TreeNode if Result: use nested Result set]" 
                       delimiter="[ optional delimiter ]" >
          <!-- Optional String filter to apply to attribute -->
          <StringFilter class="[ class of com.raritantechnologies.utils.filter.IStringFilter ]" >

          </StringFilter>

          <!-- (optional) select criteria for the node -->
          <AttributeTagSelectCriteria>
            <Attribute name="[ name of attribute ]" value="[ value of attribute for match ]" />
            <!-- etc...  -->
          </AttributeTagSelectCriteria>

      </AttributeMap>
     
    </TreeNode>

    <!-- Optionally: can specify the tree XML in the configuration -->
    <TreeXML>

    </TreeXML>

  </TreeBuilder>

 

Developed by Raritan Technologies Inc..

Author:
Ted Sullivan

Field Summary
 
Fields inherited from interface com.raritantechnologies.utils.tree.ITreeBuilder
TEMPLATE
 
Constructor Summary
SAXTreeBuilder()
           
 
Method Summary
 TreeRoot buildTree(RaritanPageContext rpc)
           
 TreeRoot buildTree(java.io.Reader xmlReader)
           
 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

SAXTreeBuilder

public SAXTreeBuilder()
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(XMLResultSet xmlResSet)
Specified by:
buildTree in interface IXMLTreeBuilder

buildTree

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

buildTree

public TreeRoot buildTree(java.io.Reader xmlReader)

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)