| java.lang.Object org.mmbase.util.NodeComparator
NodeComparator | public class NodeComparator implements Comparator(Code) | | This class implements the Comparator interface for comparing MMObjectNodes.
At forhand you specify in which fields a specified nodes should be compared,
these fields may not have a null value.
author: Pierre van Rooden version: $Id: NodeComparator.java,v 1.6 2004/10/12 11:17:44 pierre Exp $ |
Constructor Summary | |
public | NodeComparator(Vector fields) Simple constructor that uses the default sort order (UP). | public | NodeComparator(Vector fields, Vector sortDirs) Constructor in which you spercify the sort order (UP or DOWN) per field. |
Method Summary | |
public int | compare(Object o1, Object o2) The two message nodes will be compared using the compare function of
the values of their fields. | public boolean | equals(Object obj) Returns whether another object is equal to this comparator (that is,
compare the same fields in the same order). | public int | hashCode() Returns the comparator's hash code. |
NodeComparator | public NodeComparator(Vector fields)(Code) | | Simple constructor that uses the default sort order (UP).
Parameters: fields - the fields on which the message nodes get compared. |
NodeComparator | public NodeComparator(Vector fields, Vector sortDirs)(Code) | | Constructor in which you spercify the sort order (UP or DOWN) per field.
Parameters: fields - the fields on which the message nodes get compared. Parameters: sortDirs - the sort directions (UP or DOWN) for each field. |
compare | public int compare(Object o1, Object o2)(Code) | | The two message nodes will be compared using the compare function of
the values of their fields.
Only Comparable values can be used (String, Numbers, Date), as well as
Boolean values.
In other cases it's assumed that the values cannot be ordered.
Note: this class assumes that values in fields are of similar types
(comparable to each other).
Parameters: o1 - the first object to compare Parameters: o2 - the second object to compare 0 if both objects are equal, -1 if object 1 is 'less than'object 2, and +1 if object 1 is 'greater than' object 2. |
equals | public boolean equals(Object obj)(Code) | | Returns whether another object is equal to this comparator (that is,
compare the same fields in the same order).
Parameters: obj - the object to compare true if the objects are equal throws: ClassCastException - |
hashCode | public int hashCode()(Code) | | Returns the comparator's hash code.
|
|
|