Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ascape.util.data
Class DataPointComparator

    java.lang.Object
      org.ascape.util.data.DataPointComparator

All Implemented Interfaces:
  java.io.Serializable, java.util.Comparator, DataPoint, HasName

    public class DataPointComparator

extends java.lang.Object
implements java.util.Comparator, DataPoint, java.io.Serializable

An interface for a class comparing objects using a data point. The datapoint can be set, or this getValue method may be overridden and the class used as the DataPoint itself.

Since:
  2.0
Version:
  2.0
Author:
  Miles Parker
See Also:
  `DataPoint`, Serialized Form

Constructor Summary
`DataPointComparator()` Constructs a new data point comparator.
`DataPointComparator(DataPoint dataPoint)` Constructs a new data point using the supplied data point as the interpretor of any supplied object's value.

Method Summary
`int` | `compare(java.lang.Object o1, java.lang.Object o2)` Compares two object using the data point to interpret their values.
`boolean` | `equals(java.lang.Object o)` Returns true if the compared comparator uses the same data point.
`java.lang.String` | `getName()` Returns the name of this data point comparator.
`double` | `getValue(java.lang.Object object)` Returns the value of a given data point from a given object.
`void` | `setDataPoint(DataPoint dataPoint)` Sets the data point to be sued by this comparator.
`java.lang.String` | `toString()` Returns the name of this data point comparator.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DataPointComparator

    public DataPointComparator()

  Constructs a new data point comparator.

### DataPointComparator

    public DataPointComparator(DataPoint dataPoint)

  Constructs a new data point using the supplied data point as the interpretor of any supplied object's value.

Method Detail

### compare

    public int compare(java.lang.Object o1,
                       java.lang.Object o2)

  Compares two object using the data point to interpret their values. Note that DataPoint.equals is used to determine the 0 (equivalence) case -- _not_ the default doubles compare method -- so it is possible that doubles that are very close in value will not maintain consistent order. We do this so that searches for specific double values will produce expected results, but if you want to ensure a guranteed sorting order, override this method using the Double.compare method.

  Specified by:
    `compare` in interface `java.util.Comparator`

### equals

    public boolean equals(java.lang.Object o)

  Returns true if the compared comparator uses the same data point.

  Specified by:
    `equals` in interface `java.util.Comparator`
  Overrides:
    `equals` in class `java.lang.Object`

### getValue

    public double getValue(java.lang.Object object)

  Returns the value of a given data point from a given object.

  Specified by:
    `getValue` in interface `DataPoint`
  Parameters:
    `object` - the object to extract the value from.

### setDataPoint

    public void setDataPoint(DataPoint dataPoint)

  Sets the data point to be sued by this comparator. (By default, the data point is the comparator itself.)

### getName

    public java.lang.String getName()

  Returns the name of this data point comparator.

  Specified by:
    `getName` in interface `DataPoint`
  Specified by:
    `getName` in interface `HasName`

### toString

    public java.lang.String toString()

  Returns the name of this data point comparator.

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD