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)
StringComparator
public StringComparator()
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
Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.