org.mmbase.bridge.util
Class NodeFieldComparator

java.lang.Object
  extended by org.mmbase.bridge.util.NodeFieldComparator
All Implemented Interfaces:
Comparator<Node>

public class NodeFieldComparator
extends Object
implements Comparator<Node>

Comparator two nodes based on the string value in the specified field.


Field Summary
protected  boolean ascending
           
protected  String field
           
 
Constructor Summary
NodeFieldComparator(String field)
          Basic constructor.
NodeFieldComparator(String field, boolean ascending)
          Basic constructor.
 
Method Summary
 int compare(Node n1, Node n2)
          Two external source objects are said to be equal only when the two type fields match.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

field

protected String field

ascending

protected boolean ascending
Constructor Detail

NodeFieldComparator

public NodeFieldComparator(String field)
Basic constructor.

Parameters:
field - the node field to compare the nodes on

NodeFieldComparator

public NodeFieldComparator(String field,
                           boolean ascending)
Basic constructor.

Parameters:
field - the node field to compare the nodes on
ascending - sort the list ascending or descending
Method Detail

compare

public int compare(Node n1,
                   Node n2)
Two external source objects are said to be equal only when the two type fields match. The objects to compare can be of type Node.

Specified by:
compare in interface Comparator<Node>
Parameters:
n1 - the first node.
n2 - the second node
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)


MMBase 2.0-SNAPSHOT - null