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.mindswap.pellet.utils
Class AlphaNumericComparator

    java.lang.Object
      org.mindswap.pellet.utils.AlphaNumericComparator

All Implemented Interfaces:
  java.util.Comparator

    public class AlphaNumericComparator

extends java.lang.Object
implements java.util.Comparator

This is a comparator to perform a mix of alphabetical+numeric comparison. For example, if there is a list {"test10", "test2", "test150", "test25", "test1"} then what we generally expect from the ordering is the result {"test1", "test2", "test10", "test25", "test150"}. However, standard lexigraphic ordering does not do that and "test10" comes before "test2". This class is provided to overcome that problem. This functionality is useful to sort the benchmark files (like the ones in in DL-benchmark-suite) from smallest to the largest. Comparisons are done on the String values retuned by toString() so care should be taken when this comparator is used to sort arbitrary Java objects.

Author:
  Evren Sirin

Field Summary
`static AlphaNumericComparator` | `CASE_INSENSITIVE` A static instantiation of a case insensitive AlphaNumericComparator
`static AlphaNumericComparator` | `CASE_SENSITIVE` A static instantiation of a case sensitive AlphaNumericComparator

Constructor Summary
`AlphaNumericComparator()` Create a case sensitive AlphaNumericComparator
`AlphaNumericComparator(boolean caseSensitive)` Create an AlphaNumericComparator

Method Summary
`int` | `compare(java.lang.Object o1, java.lang.Object o2)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Comparator
`equals`

Field Detail

### CASE_SENSITIVE

    public static final AlphaNumericComparator CASE_SENSITIVE

  A static instantiation of a case sensitive AlphaNumericComparator

### CASE_INSENSITIVE

    public static final AlphaNumericComparator CASE_INSENSITIVE

  A static instantiation of a case insensitive AlphaNumericComparator

Constructor Detail

### AlphaNumericComparator

    public AlphaNumericComparator()

  Create a case sensitive AlphaNumericComparator

### AlphaNumericComparator

    public AlphaNumericComparator(boolean caseSensitive)

  Create an AlphaNumericComparator

  Parameters:
    `caseSensitive` - if true comparisons are case sensitive

Method Detail

### compare

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

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

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

Copyright © 2004 Evren Sirin. All Rights Reserved.