Package com.jidesoft.comparator
Class CharSequenceComparator
- java.lang.Object
-
- com.jidesoft.comparator.CharSequenceComparator
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Comparator<java.lang.Object>
public class CharSequenceComparator extends java.lang.Object implements java.util.Comparator<java.lang.Object>, java.io.Serializable
A Comparator that compares CharSequence objects (including String and StringBuffer as both extend CharSequence. Throws ClassCastExceptions if the objects are not CharSequence, or if they are null. If both objects are null, they will be treated as equal. If one is null and the other is not, the null value will be treated as smaller then non-null value.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ComparatorContext
CONTEXT
static ComparatorContext
CONTEXT_IGNORE_CASE
-
Constructor Summary
Constructors Constructor Description CharSequenceComparator()
Constructs a CharSequenceComparator.CharSequenceComparator(boolean caseSensitive)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(java.lang.Object o1, java.lang.Object o2)
boolean
isCaseSensitive()
Checks if the case is sensitive when comparing.void
setCaseSensitive(boolean caseSensitive)
Sets the case sensitive flag.
-
-
-
Field Detail
-
CONTEXT
public static final ComparatorContext CONTEXT
-
CONTEXT_IGNORE_CASE
public static final ComparatorContext CONTEXT_IGNORE_CASE
-
-
Method Detail
-
isCaseSensitive
public boolean isCaseSensitive()
Checks if the case is sensitive when comparing.- Returns:
- true if the comparator is case sensitive.
-
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive)
Sets the case sensitive flag. By default, it's true meaning the comparator is case sensitive.- Parameters:
caseSensitive
- true or false.
-
compare
public int compare(java.lang.Object o1, java.lang.Object o2)
- Specified by:
compare
in interfacejava.util.Comparator<java.lang.Object>
-
-