gishur.core
Class SweepEventComparitor

java.lang.Object
  |
  +--gishur.core.SweepEventComparitor
All Implemented Interfaces:
Comparitor, java.io.Serializable

public class SweepEventComparitor
extends java.lang.Object
implements Comparitor, java.io.Serializable

A SweepEventComparitor compares SweepEvents using another Comparitor (which must at least be able to compare KeyValueHolder-objects). If the comparison of the events' keys returns true, the events' IDs are compared. Events with bigger IDs are supposed to be 'bigger'. This enables ordering of events with equal keys.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Fields inherited from interface gishur.core.Comparitor
BIGGER, EQUAL, SMALLER
 
Constructor Summary
SweepEventComparitor(Comparitor comparitor)
          Creates a new SweepEventComparitor basing upon the Comparitor comparitor.
 
Method Summary
 short compare(java.lang.Object o1, java.lang.Object o2)
          Compares the objects o1 and o2 using the Comparitor defined in construction of this SweepEventComparitor.
 Comparitor comparitor()
          Returns the Comparitor which performs the comparison of keys in this SweepEventComparitor.
 java.lang.String toString()
          Overrides java.lang.Object.toString().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SweepEventComparitor

public SweepEventComparitor(Comparitor comparitor)
Creates a new SweepEventComparitor basing upon the Comparitor comparitor.
Parameters:
comparitor - a Comparitor, whose Comparitor.compare(java.lang.Object, java.lang.Object) -method shall be used for comparisons of the SweepEvents' keys.
Method Detail

toString

public java.lang.String toString()
Overrides java.lang.Object.toString().
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

comparitor

public Comparitor comparitor()
Returns the Comparitor which performs the comparison of keys in this SweepEventComparitor.
Returns:
the key-Comparitor

compare

public short compare(java.lang.Object o1,
                     java.lang.Object o2)
Compares the objects o1 and o2 using the Comparitor defined in construction of this SweepEventComparitor.
Specified by:
compare in interface Comparitor
Parameters:
o1,o2 - two objects to compare
Returns:
a comparison constant (Comparitor.BIGGER, Comparitor.EQUAL or Comparitor.SMALLER)