com.sun.mdm.index.matching
Class ScoreElement

java.lang.Object
  extended bycom.sun.mdm.index.matching.ScoreElement
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class ScoreElement
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Represents the results of a match against a particular object, represented by it's EUID.

See Also:
Serialized Form

Constructor Summary
ScoreElement(java.lang.String aEUID, double aWeight)
          Create a new ScoreElement given a euid and weight
 
Method Summary
 int compareTo(java.lang.Object o)
          Defines the natural ordering of ScoreElements for sorting - ScoreElement with the highest weight first.
 boolean equals(java.lang.Object o)
          Defines when a ScoreElements is considered equals to another ScoreElement.
 java.lang.String getEUID()
          Accessor for EUID
 double getWeight()
          Accessor for the score weight
 int hashCode()
          Calculate the hashcode of this object, based on the equals definition above, just based on the euid
 void setEUID(java.lang.String aEUID)
          Accessor for EUID
 void setWeight(double aWeight)
          Accessor for EUID
 java.lang.String toString()
          Simple toString for debugging purposes
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

ScoreElement

public ScoreElement(java.lang.String aEUID,
                    double aWeight)
Create a new ScoreElement given a euid and weight

Parameters:
aEUID - the euid
aWeight - the weight calculated for the match of the given euid
Method Detail

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Defines the natural ordering of ScoreElements for sorting - ScoreElement with the highest weight first. Can only compare itself against instances of ScoreElement

Parameters:
o - the ScoreElement to compare it to
Returns:
an int indicating whether the incoming object is considered lower/higher or the same for ordering
Throws:
java.lang.ClassCastException - if comparing against an object that can not be cast to ScoreElement

equals

public boolean equals(java.lang.Object o)
               throws java.lang.ClassCastException
Defines when a ScoreElements is considered equals to another ScoreElement. This defines a ScoreElement to be considered equal to another ScoreElement instance if they are for the same EUID - even if they have different weights. In terms of the API documentation this means that this equals implementation is 'inconsistent' with the above a comparator capable of imposing an ordering (equals is defined on EUID, sort on weights), making it important to consult the API documentation about the consequences of using this class in Sets

Parameters:
o - the ScoreElement to compare to
Returns:
true if the EUID matches
Throws:
java.lang.ClassCastException - if comparing against an object that can not be cast to ScoreElement

getEUID

public java.lang.String getEUID()
Accessor for EUID

Returns:
the euid of the ScoreElement

getWeight

public double getWeight()
Accessor for the score weight

Returns:
the score weight of the ScoreElement

hashCode

public int hashCode()
Calculate the hashcode of this object, based on the equals definition above, just based on the euid

Returns:
the hashcode

setEUID

public void setEUID(java.lang.String aEUID)
Accessor for EUID

Parameters:
aEUID - sets the euid of the ScoreElement

setWeight

public void setWeight(double aWeight)
Accessor for EUID

Parameters:
aWeight - sets the score weight of the ScoreElement

toString

public java.lang.String toString()
Simple toString for debugging purposes

Returns:
a string with state information for debugging purposes


Sun Microsystems, Inc.