org.mmbase.util
Class MultiColCompare

java.lang.Object
  |
  +--org.mmbase.util.MultiColCompare
All Implemented Interfaces:
CompareInterface

public class MultiColCompare
extends java.lang.Object
implements CompareInterface

MultiColCompare compares two Vectors on a given list of column numbers


Constructor Summary
MultiColCompare(int[] posArray)
          Creates a MultiColCompare.
MultiColCompare(java.lang.String posList)
          Constructor for comparing using multiple columns, where column position order is significant.
 
Method Summary
 int compare(java.lang.Object thisOne, java.lang.Object other)
          Make the comparison between to Vectors over all colums specified in the postiton array.
 int compareCol(java.lang.Object thisOne, java.lang.Object other, int comparePosIndex)
          Make the comparison between to Vectors over all columns specified in the postiton array, starting from a specified index in that array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiColCompare

public MultiColCompare(int[] posArray)
Creates a MultiColCompare.
Parameters:
posArray - a list of column numbers

MultiColCompare

public MultiColCompare(java.lang.String posList)
Constructor for comparing using multiple columns, where column position order is significant. First compare is done using first colposnr, if same then 2nd colposnr is compared etc... Column position delimiter character is ':'.
Parameters:
posList - - a String with colpositions syntax "x:y:..." eg. "6:4".
Method Detail

compareCol

public int compareCol(java.lang.Object thisOne,
                      java.lang.Object other,
                      int comparePosIndex)
Make the comparison between to Vectors over all columns specified in the postiton array, starting from a specified index in that array. The result is a negative value if the first object is 'smaller' than the second, a positive value if it is 'larger', and 0 if both objects are 'equal'.
Parameters:
thisOne - the first object to compare. should be a Vector.
other - the second object to compare. should be a Vector.
compareposindex - the index in the positionarray where to start comparing
Returns:
the result of the comparison

compare

public int compare(java.lang.Object thisOne,
                   java.lang.Object other)
Make the comparison between to Vectors over all colums specified in the postiton array. The result is a negative value if the first object is 'smaller' than the second, a positive value if it is 'larger', and 0 if both objects are 'equal'.
Specified by:
compare in interface CompareInterface
Parameters:
thisOne - the first object to compare. should be a Vector.
other - the second object to compare. should be a Vector.
Returns:
the result of the comparison


MMBase 2002