Enum IOCase
- java.lang.Object
 - 
- java.lang.Enum<IOCase>
 - 
- org.apache.commons.io.IOCase
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable,java.lang.Comparable<IOCase>
public enum IOCase extends java.lang.Enum<IOCase>
Enumeration of IO case sensitivity.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
checkmethods in this class to compare file names.- Since:
 - 1.3
 
 
- 
- 
Enum Constant Summary
Enum Constants Enum Constant Description INSENSITIVEThe constant for case-insensitive regardless of operating system.SENSITIVEThe constant for case-sensitive regardless of operating system.SYSTEMThe constant for case sensitivity determined by the current operating system. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcheckCompareTo(java.lang.String str1, java.lang.String str2)Compares two strings using the case-sensitivity rule.booleancheckEndsWith(java.lang.String str, java.lang.String end)Checks if one string ends with another using the case-sensitivity rule.booleancheckEquals(java.lang.String str1, java.lang.String str2)Compares two strings using the case-sensitivity rule.intcheckIndexOf(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.booleancheckRegionMatches(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.booleancheckStartsWith(java.lang.String str, java.lang.String start)Checks if one string starts with another using the case-sensitivity rule.static IOCaseforName(java.lang.String name)Looks up an IOCase by name.java.lang.StringgetName()Gets the name of the constant.booleanisCaseSensitive()Does the object represent case-sensitive comparison.static booleanisCaseSensitive(IOCase ioCase)Tests for cases sensitivity in a null-safe manner.java.lang.StringtoString()Gets a string describing the sensitivity.static IOCasevalue(IOCase value, IOCase defaultValue)Returns the given value if not-null, the defaultValue if null.static IOCasevalueOf(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. 
 - 
 
- 
- 
Enum Constant Detail
- 
SENSITIVE
public static final IOCase SENSITIVE
The constant for case-sensitive regardless of operating system. 
- 
INSENSITIVE
public static final IOCase INSENSITIVE
The constant for case-insensitive regardless of operating system. 
- 
SYSTEM
public static final IOCase SYSTEM
The constant for case sensitivity determined by the current operating system. Windows is case-insensitive when comparing file names, UNIX is case-sensitive.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.
 
 - 
 
- 
Method Detail
- 
values
public static IOCase[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (IOCase c : IOCase.values()) System.out.println(c);
- Returns:
 - an array containing the constants of this enum type, in the order they are declared
 
 
- 
valueOf
public static IOCase valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
 name- the name of the enum constant to be returned.- Returns:
 - the enum constant with the specified name
 - Throws:
 java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
 
- 
forName
public static IOCase forName(java.lang.String name)
Looks up an IOCase by name.- Parameters:
 name- the name to find- Returns:
 - the IOCase object
 - Throws:
 java.lang.IllegalArgumentException- if the name is invalid
 
- 
isCaseSensitive
public static boolean isCaseSensitive(IOCase ioCase)
Tests for cases sensitivity in a null-safe manner.- Parameters:
 ioCase- an IOCase.- Returns:
 - true if the input is non-null and 
isCaseSensitive(). - Since:
 - 2.10.0
 
 
- 
value
public static IOCase value(IOCase value, IOCase defaultValue)
Returns the given value if not-null, the defaultValue if null.- Parameters:
 value- the value to test.defaultValue- the default value.- Returns:
 - the given value if not-null, the defaultValue if null.
 - Since:
 - 2.12.0
 
 
- 
checkCompareTo
public int checkCompareTo(java.lang.String str1, java.lang.String str2)Compares two strings using the case-sensitivity rule.This method mimics
String.compareTo(java.lang.String)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:
 java.lang.NullPointerException- if either string is null.
 
- 
checkEndsWith
public boolean checkEndsWith(java.lang.String str, java.lang.String end)Checks if one string ends with another using the case-sensitivity rule.This method mimics
String.endsWith(java.lang.String)but takes case-sensitivity into account.- Parameters:
 str- the string to check.end- the end to compare against.- Returns:
 - true if equal using the case rules, false if either input is null.
 
 
- 
checkEquals
public boolean checkEquals(java.lang.String str1, java.lang.String str2)Compares two strings using the case-sensitivity rule.This method mimics
String.equals(java.lang.Object)but takes case-sensitivity into account.- Parameters:
 str1- the first string to compare.str2- the second string to compare.- Returns:
 - true if equal using the case rules.
 
 
- 
checkIndexOf
public 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.This method mimics parts of
String.indexOf(String, int)but takes case-sensitivity into account.- Parameters:
 str- the string to check.strStartIndex- the index to start at in str.search- the start to search for.- Returns:
 - the first index of the search String,
  -1 if no match or 
nullstring input. - Since:
 - 2.0
 
 
- 
checkRegionMatches
public 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.This method mimics parts of
String.regionMatches(boolean, int, String, int, int)but takes case-sensitivity into account.- Parameters:
 str- the string to check.strStartIndex- the index to start at in str.search- the start to search for,.- Returns:
 - true if equal using the case rules.
 
 
- 
checkStartsWith
public boolean checkStartsWith(java.lang.String str, java.lang.String start)Checks if one string starts with another using the case-sensitivity rule.This method mimics
String.startsWith(String)but takes case-sensitivity into account.- Parameters:
 str- the string to check.start- the start to compare against.- Returns:
 - true if equal using the case rules, false if either input is null.
 
 
- 
getName
public java.lang.String getName()
Gets the name of the constant.- Returns:
 - the name of the constant
 
 
- 
isCaseSensitive
public boolean isCaseSensitive()
Does the object represent case-sensitive comparison.- Returns:
 - true if case-sensitive.
 
 
- 
toString
public java.lang.String toString()
Gets a string describing the sensitivity.- Overrides:
 toStringin classjava.lang.Enum<IOCase>- Returns:
 - a string describing the sensitivity.
 
 
 - 
 
 -