QJCC homepage

biz.chitec.quarterback.util
Class NumberedStringComparator

java.lang.Object
  extended bybiz.chitec.quarterback.util.NumberedStringComparator
All Implemented Interfaces:
java.util.Comparator

public class NumberedStringComparator
extends java.lang.Object
implements java.util.Comparator

Comparator class for NumberedStrings. Can compare them by nr or name, name also in sorted writing...

Version:
$Id: c527297e815c3f0d9384951cd5577c9642ebc74d $
Author:
chitec/Dirk Hillbrecht 2002. Distributed under the terms of the GNU LGPL.

Field Summary
static int BYADDNR
          Sort by additional number
static int BYNAME
          Sort by name field with standard String comparation
static int BYNAMEASNUMBER
          Sort by name field and assume that it starts with a numeric value
static int BYNORMALNAME
          Sort by name field in special database conversion
static int BYNR
          Sort by numerical field
private  int mode
           
private static java.lang.String NUMBERDELIMITERS
           
 
Constructor Summary
NumberedStringComparator()
          Sorts by numerical value
NumberedStringComparator(int mx)
          Sorts by given mode, use constants BYNR, BYNAME, or BYNORMALNAME
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two NumberedStrings.
private  int compareByNameAsNumber(java.lang.String s1, java.lang.String s2)
           
 boolean equals(java.lang.Object o)
           
 int getMode()
          Return sorting mode
 void setMode(int mx)
          Set sorting mode explicitly
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYNR

public static final int BYNR
Sort by numerical field

See Also:
Constant Field Values

BYNAME

public static final int BYNAME
Sort by name field with standard String comparation

See Also:
Constant Field Values

BYNORMALNAME

public static final int BYNORMALNAME
Sort by name field in special database conversion

See Also:
Constant Field Values

BYNAMEASNUMBER

public static final int BYNAMEASNUMBER
Sort by name field and assume that it starts with a numeric value

See Also:
Constant Field Values

BYADDNR

public static final int BYADDNR
Sort by additional number

See Also:
Constant Field Values

NUMBERDELIMITERS

private static final java.lang.String NUMBERDELIMITERS
See Also:
Constant Field Values

mode

private int mode
Constructor Detail

NumberedStringComparator

public NumberedStringComparator(int mx)
Sorts by given mode, use constants BYNR, BYNAME, or BYNORMALNAME

Parameters:
mx - mode for sorting

NumberedStringComparator

public NumberedStringComparator()
Sorts by numerical value

Method Detail

setMode

public void setMode(int mx)
Set sorting mode explicitly


getMode

public int getMode()
Return sorting mode


compare

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

Specified by:
compare in interface java.util.Comparator

compareByNameAsNumber

private int compareByNameAsNumber(java.lang.String s1,
                                  java.lang.String s2)

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Comparator

QJCC homepage