com.raritantechnologies.utils.tree.comparators
Class TreeCountComparator

java.lang.Object
  extended bycom.raritantechnologies.utils.tree.comparators.TreeCountComparator
All Implemented Interfaces:
java.util.Comparator, IComparator, IConfigurable, ITreeNodeComparator

public class TreeCountComparator
extends java.lang.Object
implements ITreeNodeComparator

Sorts TreeNodes by child count. Can be used to determine if a node has children using the minimum / maximum child counts. Set both to 0 to test for leaf nodes.

XML Configuration Template:
  <TreeNodeComparator class="com.raritantechnologies.utils.tree.comparators.TreeCountComparator" 
                         minChildCount="[ optional minimum child count ]"
                         maxChildCount="[ optional maximum child count ]" />
 


Field Summary
 
Fields inherited from interface com.raritantechnologies.utils.comparators.IComparator
TEMPLATE
 
Constructor Summary
TreeCountComparator()
           
TreeCountComparator(boolean useChildCount)
           
 
Method Summary
 int compare(java.lang.Object ob1, java.lang.Object ob2)
           
 boolean equals(java.lang.Object object)
           
 void initialize(org.w3c.dom.Element elem)
          Initializes the object from an XML tag or element.
 void setUseChildCount(boolean useChildCount)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeCountComparator

public TreeCountComparator()

TreeCountComparator

public TreeCountComparator(boolean useChildCount)
Method Detail

setUseChildCount

public void setUseChildCount(boolean useChildCount)

equals

public boolean equals(java.lang.Object object)
Specified by:
equals in interface java.util.Comparator

compare

public int compare(java.lang.Object ob1,
                   java.lang.Object ob2)
Specified by:
compare in interface java.util.Comparator

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