net.sf.mmapps.commons.bridge
Class NodeFieldComparator

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

public class NodeFieldComparator
extends java.lang.Object
implements java.util.Comparator<org.mmbase.bridge.Node>

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


Field Summary
protected  boolean ascending
           
protected  java.lang.String field
           
 
Constructor Summary
NodeFieldComparator(java.lang.String field)
          Basic constructor.
NodeFieldComparator(java.lang.String field, boolean ascending)
          Basic constructor.
 
Method Summary
 int compare(org.mmbase.bridge.Node n1, org.mmbase.bridge.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 java.lang.String field

ascending

protected boolean ascending
Constructor Detail

NodeFieldComparator

public NodeFieldComparator(java.lang.String field)
Basic constructor.

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

NodeFieldComparator

public NodeFieldComparator(java.lang.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(org.mmbase.bridge.Node n1,
                   org.mmbase.bridge.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 java.util.Comparator<org.mmbase.bridge.Node>
Parameters:
o1 - the first external source node.
o2 - the first external source node
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.


Copyright © 2003-2006 mmapps. All Rights Reserved.