org.norther.tammi.acorn.util
Class AlphaNumericComparator<T>

java.lang.Object
  extended by org.norther.tammi.acorn.util.AlphaNumericComparator<T>
Type Parameters:
T - the type to compare.
All Implemented Interfaces:
Serializable, Comparator<T>

public class AlphaNumericComparator<T>
extends Object
implements Comparator<T>, Serializable

A string token comparator recognizing numbers.

Version:
$Id: AlphaNumericComparator.java,v 1.7 2009/09/28 15:08:48 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
AlphaNumericComparator()
          Constructs a new comparator.
AlphaNumericComparator(boolean casep)
          Constructs a new comparator with order.
 
Method Summary
protected  int compare(String token1, String token2)
          Compares two string tokens with embedded numerical sequences in ascending order.
 int compare(T object1, T object2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

AlphaNumericComparator

public AlphaNumericComparator()
Constructs a new comparator.


AlphaNumericComparator

public AlphaNumericComparator(boolean casep)
Constructs a new comparator with order.

Parameters:
casep - true for case-sensitive.
Method Detail

compare

public int compare(T object1,
                   T object2)
Specified by:
compare in interface Comparator<T>

compare

protected int compare(String token1,
                      String token2)
Compares two string tokens with embedded numerical sequences in ascending order.

Parameters:
token1 - the first token to be compared.
token2 - the second token to be compared.
Returns:
-1, 0 or 1 based on comparison.


Copyright © 2004 The Norther Organization. All rights reserved.