Decision Center API

ilog.rules.teamserver.web.tree.impl
Class IlrDefaultTreeSorter

java.lang.Object
  extended by ilog.rules.teamserver.web.tree.impl.IlrDefaultTreeSorter
All Implemented Interfaces:
IlrTreeSorter

public class IlrDefaultTreeSorter
extends Object
implements IlrTreeSorter

A default implementation of the IlrTreeSorter class.

See Also:
IlrTreeSorter

Constructor Summary
IlrDefaultTreeSorter()
          Creates a tree sorter with no comparator.
IlrDefaultTreeSorter(Comparator<String> comparator)
          Creates a tree sorter with a comparator.
 
Method Summary
 int category(IlrTreeNode node)
          Returns the category of a node.
 int compare(IlrTreeController controller, IlrTreeNode node1, IlrTreeNode node2, boolean ignoreCase)
          Returns a negative, zero, or positive number depending on whether the first element is less than, equal to, or greater than the second element.
protected  Comparator<String> getComparator()
          Returns a comparator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlrDefaultTreeSorter

public IlrDefaultTreeSorter()
Creates a tree sorter with no comparator.

See Also:
IlrDefaultTreeSorter(Comparator)

IlrDefaultTreeSorter

public IlrDefaultTreeSorter(Comparator<String> comparator)
Creates a tree sorter with a comparator.

Parameters:
comparator - The comparator.
Method Detail

category

public int category(IlrTreeNode node)
Description copied from interface: IlrTreeSorter
Returns the category of a node.

A common use is to categorize the node to optimize the sorting.

Specified by:
category in interface IlrTreeSorter
Parameters:
node - The node.
Returns:
A category.

getComparator

protected Comparator<String> getComparator()
Returns a comparator.

Returns:
A comparator, or null if no comparator has been set.
See Also:
Comparator

compare

public int compare(IlrTreeController controller,
                   IlrTreeNode node1,
                   IlrTreeNode node2,
                   boolean ignoreCase)
Returns a negative, zero, or positive number depending on whether the first element is less than, equal to, or greater than the second element.

Note: The ignoreCase argument is relevant in case of string comparisons.

The method returns a negative or positive number depending on whether the first category is less than or greater than the second category.

If the categories are equal, the comparison is done on the label of the nodes according to a comparator. If no comparator is specified, the compare method of java.lang.String is called.

Note: If specified in the tree controller, the labels of the nodes are computed with the tree label provider if specified. Otherwise the IlrTreeNode.getLabel() is called.

Specified by:
compare in interface IlrTreeSorter
Parameters:
controller - The tree controller.
node1 - The first node.
node2 - The second node.
ignoreCase - true if the method should not be case sensitive, and false otherwise.
Returns:
A negative number if the first element is less than the second element; the value 0 if the first element is equal to the second element; and a positive number if the first element is greater than the second element.

Decision Center API

© Copyright IBM Corp. 1987, 2013