|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cosylab.util.NumericStringComparator
public class NumericStringComparator
NumericStringComparator
... NumericStringComparator represents
class which compares two Strings. Roules are followed:
softEquals
property controls how the strictness of the comparator with regards
to spaces and separators. When softEquals
is set to true
,
the comparator will return 0 even when two strings are not identical, but are equal
numerically. e.g. compare("100","0100") will return 0;
com.cosylab.util.test
Field Summary | |
---|---|
static int |
DEC_SEPARATOR_BOTH
Constant indicating that both dot and comma are treated as decimal separators |
static int |
DEC_SEPARATOR_COMMA
Constant indicating that comma is treated as a decimal separator |
static int |
DEC_SEPARATOR_DOT
Constant indicating that dot is treated as a decimal separator |
static int |
DEC_SEPARATOR_NONE
Constant indicating that decimal separators should not be treated differently than other characters |
Constructor Summary | |
---|---|
NumericStringComparator()
Contructor creates NumericStringComparator. |
|
NumericStringComparator(char[] separators)
Contructor creates NumericStringComparator with specified array of separators. |
|
NumericStringComparator(char[] separators,
int decSeparator)
Contructor creates NumericStringComparator with specified array of separators in decimal separator mode. |
|
NumericStringComparator(int decSeparator)
Contructor creates NumericStringComparator with specified decimal mode. |
Method Summary | |
---|---|
void |
addSeparator(char sep)
Method adds new separator. |
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
int |
getDecSeparatorMode()
Method returns decimal separator mode, represented by int |
static NumericStringComparator |
getDefault()
Convenience method for obtaining a default NumericStringComparator . |
char[] |
getSeparators()
Method returns separators |
boolean |
isSoftEquals()
When softEquals property is set to true, the comparator
will return 0 even when two strings are not identical, but are equal
numerically. |
void |
setSeparators(char[] sep)
Method sets separators |
void |
setSoftEquals(boolean softEquals)
Sets the softEquals property. |
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 |
Field Detail |
---|
public static final int DEC_SEPARATOR_DOT
public static final int DEC_SEPARATOR_COMMA
public static final int DEC_SEPARATOR_BOTH
public static final int DEC_SEPARATOR_NONE
Constructor Detail |
---|
public NumericStringComparator(char[] separators, int decSeparator)
separators
- array of separatorsdecSeparator
- decimal separator modepublic NumericStringComparator(char[] separators)
separators
- array of separatorspublic NumericStringComparator(int decSeparator)
decSeparator
- decimal modepublic NumericStringComparator()
Method Detail |
---|
public static NumericStringComparator getDefault()
NumericStringComparator
. Array of separators has default
value: [' ', '_']. Decimal mode has default value:
DEC_SEPARATOR_DOT
.
public void addSeparator(char sep)
sep
- new separator
java.lang.IllegalArgumentException
- when the separator is an illegal
character such as a digit, a decimal separator or the minus
signpublic void setSeparators(char[] sep)
sep
- array of separators
java.lang.IllegalArgumentException
- when the separators array contains
illegal character such as digits, decimal separators or minus
signpublic char[] getSeparators()
public int getDecSeparatorMode()
public int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator
public boolean isSoftEquals()
softEquals
property is set to true, the comparator
will return 0 even when two strings are not identical, but are equal
numerically. e.g. compare("100","0100") will return 0;
public void setSoftEquals(boolean softEquals)
softEquals
property.
softEquals
- The softEquals to set.isSoftEquals()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |