public enum IOCase extends java.lang.Enum<IOCase>
Different filing systems have different rules for case-sensitivity. Windows is case-insensitive, UNIX is case-sensitive.
This class captures that difference, providing an enumeration to control how file name 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 file names.
| Enum Constant and Description |
|---|
INSENSITIVE
The constant for case-insensitive regardless of operating system.
|
SENSITIVE
The constant for case-sensitive regardless of operating system.
|
SYSTEM
The constant for case sensitivity determined by the current operating system.
|
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
name
The enumeration name.
|
private boolean |
sensitive
The sensitivity flag.
|
private static long |
serialVersionUID
Serialization version.
|
| Modifier and Type | Method and Description |
|---|---|
int |
checkCompareTo(java.lang.String str1,
java.lang.String str2)
Compares two strings using the case-sensitivity rule.
|
boolean |
checkEndsWith(java.lang.String str,
java.lang.String end)
Checks if one string ends with another using the case-sensitivity rule.
|
boolean |
checkEquals(java.lang.String str1,
java.lang.String str2)
Compares two strings using the case-sensitivity rule.
|
int |
checkIndexOf(java.lang.String str,
int strStartIndex,
java.lang.String search)
Checks if one string contains another starting at a specific index using the
case-sensitivity rule.
|
boolean |
checkRegionMatches(java.lang.String str,
int strStartIndex,
java.lang.String search)
Checks if one string contains another at a specific index using the case-sensitivity rule.
|
boolean |
checkStartsWith(java.lang.String str,
java.lang.String start)
Checks if one string starts with another using the case-sensitivity rule.
|
static IOCase |
forName(java.lang.String name)
Looks up an IOCase by name.
|
java.lang.String |
getName()
Gets the name of the constant.
|
boolean |
isCaseSensitive()
Does the object represent case-sensitive comparison.
|
static boolean |
isCaseSensitive(IOCase ioCase)
Tests for cases sensitivity in a null-safe manner.
|
private java.lang.Object |
readResolve()
Replaces the enumeration from the stream with a real one.
|
java.lang.String |
toString()
Gets a string describing the sensitivity.
|
static IOCase |
value(IOCase value,
IOCase defaultValue)
Returns the given value if not-null, the defaultValue if null.
|
static IOCase |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static IOCase[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final IOCase SENSITIVE
public static final IOCase INSENSITIVE
public static final IOCase SYSTEM
Note: This only caters for Windows and Unix. Other operating
systems (e.g. OSX and OpenVMS) are treated as case-sensitive if they use the
UNIX file separator and case-insensitive if they use the Windows file separator
(see File.separatorChar).
If you serialize this constant on Windows, and deserialize on Unix, or vice versa, then the value of the case-sensitivity flag will change.
private static final long serialVersionUID
private final java.lang.String name
private final transient boolean sensitive
public static IOCase[] values()
for (IOCase c : IOCase.values()) System.out.println(c);
public static IOCase valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic static IOCase forName(java.lang.String name)
name - the name to findjava.lang.IllegalArgumentException - if the name is invalidpublic static boolean isCaseSensitive(IOCase ioCase)
ioCase - an IOCase.isCaseSensitive().public static IOCase value(IOCase value, IOCase defaultValue)
value - the value to test.defaultValue - the default value.public int checkCompareTo(java.lang.String str1,
java.lang.String str2)
This method mimics String.compareTo(java.lang.String) but takes case-sensitivity
into account.
str1 - the first string to compare, not null.str2 - the second string to compare, not null.java.lang.NullPointerException - if either string is null.public boolean checkEndsWith(java.lang.String str,
java.lang.String end)
This method mimics String.endsWith(java.lang.String) but takes case-sensitivity
into account.
str - the string to check.end - the end to compare against.public boolean checkEquals(java.lang.String str1,
java.lang.String str2)
This method mimics String.equals(java.lang.Object) but takes case-sensitivity
into account.
str1 - the first string to compare.str2 - the second string to compare.public int checkIndexOf(java.lang.String str,
int strStartIndex,
java.lang.String search)
This method mimics parts of String.indexOf(String, int)
but takes case-sensitivity into account.
str - the string to check.strStartIndex - the index to start at in str.search - the start to search for.null string input.public boolean checkRegionMatches(java.lang.String str,
int strStartIndex,
java.lang.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.strStartIndex - the index to start at in str.search - the start to search for,.public boolean checkStartsWith(java.lang.String str,
java.lang.String start)
This method mimics String.startsWith(String) but takes case-sensitivity
into account.
str - the string to check.start - the start to compare against.public java.lang.String getName()
public boolean isCaseSensitive()
private java.lang.Object readResolve()
public java.lang.String toString()
toString in class java.lang.Enum<IOCase>