org.apache.commons.io
public final class IOCase extends Object implements Serializable
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 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.
Since: Commons IO 1.3
Version: $Id: IOCase.java 606345 2007-12-21 23:43:01Z ggregory $
Field Summary | |
---|---|
static IOCase | INSENSITIVE
The constant for case insensitive regardless of operating system. |
String | name The enumeration name. |
boolean | sensitive The sensitivity flag. |
static long | serialVersionUID Serialization version. |
static IOCase | SENSITIVE
The constant for case sensitive regardless of operating system. |
static IOCase | SYSTEM
The constant for case sensitivity determined by the current operating system.
|
Constructor Summary | |
---|---|
IOCase(String name, boolean sensitive)
Private constructor.
|
Method Summary | |
---|---|
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.
|
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.
|
String | convertCase(String str)
Converts the case of the input String to a standard format.
|
static IOCase | forName(String name)
Factory method to create an IOCase from a name.
|
String | getName()
Gets the name of the constant.
|
boolean | isCaseSensitive()
Does the object represent case sensitive comparison.
|
Object | readResolve()
Replaces the enumeration from the stream with a real one.
|
String | toString()
Gets a string describing the sensitivity.
|
If you derialize this constant of Windows, and deserialize on Unix, or vice versa, then the value of the case-sensitivity flag will change.
Parameters: name the name sensitive the sensitivity
This method mimics String#compareTo but takes case-sensitivity into account.
Parameters: str1 the first string to compare, not null str2 the second string to compare, not null
Returns: true if equal using the case rules
Throws: NullPointerException if either string is null
This method mimics String#endsWith but takes case-sensitivity into account.
Parameters: str the string to check, not null end the end to compare against, not null
Returns: true if equal using the case rules
Throws: NullPointerException if either string is null
This method mimics String#equals but takes case-sensitivity into account.
Parameters: str1 the first string to compare, not null str2 the second string to compare, not null
Returns: true if equal using the case rules
Throws: NullPointerException if either string is null
This method mimics parts of String#regionMatches(boolean, int, String, int, int) but takes case-sensitivity into account.
Parameters: str the string to check, not null strStartIndex the index to start at in str search the start to search for, not null
Returns: true if equal using the case rules
Throws: NullPointerException if either string is null
This method mimics String#startsWith(String) but takes case-sensitivity into account.
Parameters: str the string to check, not null start the start to compare against, not null
Returns: true if equal using the case rules
Throws: NullPointerException if either string is null
Parameters: str the string to convert, null returns null
Returns: the lower-case version if case-insensitive
Parameters: name the name to find
Returns: the IOCase object
Throws: IllegalArgumentException if the name is invalid
Returns: the name of the constant
Returns: true if case sensitive
Returns: the resolved object
Returns: a string describing the sensitivity