Package uk.ac.starlink.datanode.nodes

# Class StringComparator

java.lang.Object
uk.ac.starlink.datanode.nodes.StringComparator

All Implemented Interfaces:
  `Comparator`

public class StringComparator extends Object implements Comparator
A very simple implementation of the `Comparator` interface. It is suitable for use on any objects for which the `toString` method provides a suitable basis for object comparison.

You might think that calling `java.text.Collator.getInstance` ought to provide much the same thing; however that gives you a `compare` method which casts to `String` rather than calling the `toString` method on its arguments, leading to a `ClassCastException` in most useful cases. I wonder why it does that?

Version:
  $Id$
Author:
  Mark Taylor (Starlink)

## Constructor Summary

Constructors
Constructor
Description
`StringComparator()`

## Method Summary

Modifier and Type
Method
Description
`int`
`compare(Object o1, Object o2)`
`boolean`
`equals(Object obj)`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Comparator

`reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

## Constructor Details

### StringComparator

public StringComparator()

## Method Details

### compare

public int compare(Object o1, Object o2)

Specified by:
  `compare` in interface `Comparator`

### equals

public boolean equals(Object obj)

Specified by:
  `equals` in interface `Comparator`
Overrides:
  `equals` in class `Object`