com.raritantechnologies.utils.tree
Class FlatFileTreeBuilder

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

public class FlatFileTreeBuilder
extends java.lang.Object
implements ITreeBuilder

Builds a tree from a flat file - for example an Excel spreadheet saved as a CSV file).

Assumes that the file is organized hierarchically so that the delimiter '|' is used to count the level of the child node:

  Root Name|Root ID
  |Child Name|Child ID
  ||Grandkid Name|Grandkid ID
  |Child2 Name|child2 ID
  ||Grand Kid2a Name|Grandkid 2a ID
  |||Great-grandkid Name|Great-grandkid ID
  

Level and parent coded by depth of columns and context.

XML Configuration Template:
  <TreeBuilder class="com.raritantechnologies.utils.tree.FlatFileTreeBuilder"
                  fileName="[ name of file containing tree data ]"
                  delimiter="[ character to use for flat file path delimiter default is '|' ]"
                  treeName="[ name of output TreeRoot object ]"
                  treeRootClass="[ optional class name of TreeRoot extension class ]"
                  treeNodeClass="[ optional class name of TreeNode extension class ]" >

     <Columns>
       <!-- Columns can be specified one of three ways: -->
       <Column ID="[ '_ID_': column value used as nodeID]" />
       <Column ID="[ '_NAME_': column value used as name]" />
       <Column ID="[ fixed name of column ]" />
     </Columns>

     <!-- Optional NodeList generators - uses an external SearchSource to add a list -->
     <!-- of TreeNodes to a node. Linked via a placehoder in the flat file with the  -->
     <!-- pattern 'NODE_LIST:[ search source name ]'                                 -->

     <NodeListSource sourceName="[ name of search source ]" nameField="[ field in result that provides treeNode name ]"
                        nestedResultsField="[ field name that can contain nested results ]" >
       <Query>
        
          <!-- Fixed query params: passed to search source 'as is' -->
          <FixedParam ID="[ name of query param ]"     value="[ value of query param ]" />

          <!-- Dynamic query param: pass 
          <RequestParam ID="[ name of query param ]"   request="[ name of request param ]"      />
       </Query>
     </NodeListSource>

  </TreeBuilder>
 

Developed by Raritan Technologies Inc..

Author:
Ted Sullivan

Field Summary
 
Fields inherited from interface com.raritantechnologies.utils.tree.ITreeBuilder
TEMPLATE
 
Constructor Summary
FlatFileTreeBuilder()
           
 
Method Summary
 TreeRoot buildTree(RaritanPageContext pContext)
           
 java.lang.String[] getColumnNames()
           
 java.lang.String getConfigurationXML()
           
 java.lang.String getConfigurationXML(java.lang.String configurationTemplate)
           
 void getConfigurationXML(java.io.Writer writer)
           
 java.lang.String getDelimiter()
           
 java.lang.String getFileName()
           
 java.lang.String getTreeName()
           
 java.lang.String getTreeNodeClass()
           
 java.lang.String getTreeRootClass()
           
 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 setColumnNames(java.lang.String[] columnNames)
           
 void setDelimiter(java.lang.String delimiter)
          sets the flat file path delimiter
 void setFileName(java.lang.String fileName)
           
 void setTreeName(java.lang.String treeName)
           
 void setTreeNodeClass(java.lang.String treeNodeClass)
           
 void setTreeRootClass(java.lang.String treeRootClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlatFileTreeBuilder

public FlatFileTreeBuilder()
Method Detail

buildTree

public TreeRoot buildTree(RaritanPageContext pContext)
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

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

setFileName

public void setFileName(java.lang.String fileName)

getFileName

public java.lang.String getFileName()

setDelimiter

public void setDelimiter(java.lang.String delimiter)
sets the flat file path delimiter


getDelimiter

public java.lang.String getDelimiter()

setTreeName

public void setTreeName(java.lang.String treeName)

getTreeName

public java.lang.String getTreeName()

setTreeRootClass

public void setTreeRootClass(java.lang.String treeRootClass)

getTreeRootClass

public java.lang.String getTreeRootClass()

setTreeNodeClass

public void setTreeNodeClass(java.lang.String treeNodeClass)

getTreeNodeClass

public java.lang.String getTreeNodeClass()

setColumnNames

public void setColumnNames(java.lang.String[] columnNames)

getColumnNames

public java.lang.String[] getColumnNames()

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)