public final class Case extends Object implements Serializable
This class captures difference case sensitivity, providing an enumeration to control how filename comparisons should be performed. It also provides methods that use the enumeration to perform comparisons.
Wherever possible, you should use the check methods in this
class to compare filenames.
| Modifier and Type | Field and Description |
|---|---|
static Case |
INSENSITIVE
The constant for case insensitive regardless of operating system.
|
static Case |
SENSITIVE
The constant for case sensitive regardless of operating system.
|
| Modifier and Type | Method and Description |
|---|---|
int |
checkCompareTo(String str1,
String str2)
Compares two strings using the case-sensitivity rule.
|
boolean |
checkEndsWith(String str,
String end)
Checks if one string ends with another using the case-sensitivity rule.
|
boolean |
checkEquals(String str1,
String str2)
Compares two strings using the case-sensitivity rule.
|
int |
checkIndexOf(String str,
int strStartIndex,
String search)
Checks if one string contains another starting at a specific index using
the case-sensitivity rule.
|
boolean |
checkRegionMatches(String str,
int strStartIndex,
String search)
Checks if one string contains another at a specific index using the
case-sensitivity rule.
|
boolean |
checkStartsWith(String str,
String start)
Checks if one string starts with another using the case-sensitivity rule.
|
static Case |
forName(String name)
Factory method to create a Case from a name.
|
String |
getName()
Gets the name of the constant.
|
boolean |
isCaseSensitive()
Does the object represent case sensitive comparison.
|
String |
toString()
Gets a string describing the sensitivity.
|
public static final Case SENSITIVE
public static final Case INSENSITIVE
public static Case forName(String name)
name - the name to findIllegalArgumentException - if the name is invalidpublic String getName()
public boolean isCaseSensitive()
public int checkCompareTo(String str1, String str2)
This method mimics String.compareTo(java.lang.String) but takes case-sensitivity
into account.
str1 - the first string to compare, not nullstr2 - the second string to compare, not nullNullPointerException - if either string is nullpublic boolean checkEquals(String str1, String str2)
This method mimics String.equals(java.lang.Object) but takes case-sensitivity into
account.
str1 - the first string to compare, not nullstr2 - the second string to compare, not nullNullPointerException - if either string is nullpublic boolean checkStartsWith(String str, String start)
This method mimics String.startsWith(String) but takes
case-sensitivity into account.
str - the string to check, not nullstart - the start to compare against, not nullNullPointerException - if either string is nullpublic boolean checkEndsWith(String str, String end)
This method mimics String.endsWith(java.lang.String) but takes case-sensitivity
into account.
str - the string to check, not nullend - the end to compare against, not nullNullPointerException - if either string is nullpublic int checkIndexOf(String str, int strStartIndex, String search)
This method mimics parts of String.indexOf(String, int) but takes
case-sensitivity into account.
str - the string to check, not nullstrStartIndex - the index to start at in strsearch - the start to search for, not nullnull string inputNullPointerException - if either string is nullpublic boolean checkRegionMatches(String str, int strStartIndex, String search)
This method mimics parts of
String.regionMatches(boolean, int, String, int, int) but takes
case-sensitivity into account.
str - the string to check, not nullstrStartIndex - the index to start at in strsearch - the start to search for, not nullNullPointerException - if either string is nullCopyright © 2013-2017 XENEI.com. All Rights Reserved.