下面列出了org.apache.commons.io.IOCase#SENSITIVE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Checks whether two filenames are equal, optionally normalizing and providing
* control over the case-sensitivity.
*
* @param filename1 the first filename to query, may be null
* @param filename2 the second filename to query, may be null
* @param normalized whether to normalize the filenames
* @param caseSensitivity what case sensitivity rule to use, null means case-sensitive
* @return true if the filenames are equal, null equals null
* @since Commons IO 1.3
*/
public static boolean equals(
String filename1, String filename2,
boolean normalized, IOCase caseSensitivity) {
if (filename1 == null || filename2 == null) {
return (filename1 == null && filename2 == null);
}
if (normalized) {
filename1 = normalize(filename1);
filename2 = normalize(filename2);
if (filename1 == null || filename2 == null) {
throw new NullPointerException(
"Error normalizing one or both of the file names");
}
}
if (caseSensitivity == null) {
caseSensitivity = IOCase.SENSITIVE;
}
return caseSensitivity.checkEquals(filename1, filename2);
}
/**
* Construct a new wildcard filter for a single wildcard specifying case-sensitivity.
*
* @param wildcard the wildcard to match, not null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the pattern is null
*/
public WildcardFileFilter(final String wildcard, final IOCase caseSensitivity) {
if (wildcard == null) {
throw new IllegalArgumentException("The wildcard must not be null");
}
this.wildcards = new String[] { wildcard };
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Constructs a new name file filter for an array of names specifying case-sensitivity.
*
* @param names the names to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the names array is null
*/
public NameFileFilter(final String[] names, final IOCase caseSensitivity) {
if (names == null) {
throw new IllegalArgumentException("The array of names must not be null");
}
this.names = new String[names.length];
System.arraycopy(names, 0, this.names, 0, names.length);
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Construct a case sensitive file path comparator instance.
*/
public PathFileComparator() {
this.caseSensitivity = IOCase.SENSITIVE;
}
/**
* Constructs a new Prefix file filter for any of an array of prefixes
* specifying case-sensitivity.
* <p>
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
*
* @param prefixes the prefixes to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the prefix is null
* @since 1.4
*/
public PrefixFileFilter(String[] prefixes, IOCase caseSensitivity) {
if (prefixes == null) {
throw new IllegalArgumentException("The array of prefixes must not be null");
}
this.prefixes = new String[prefixes.length];
System.arraycopy(prefixes, 0, this.prefixes, 0, prefixes.length);
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Construct a new wildcard filter for a list of wildcards specifying case-sensitivity.
*
* @param wildcards the list of wildcards to match, not null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the pattern list is null
* @throws ClassCastException if the list does not contain Strings
*/
public WildcardFileFilter(final List<String> wildcards, final IOCase caseSensitivity) {
if (wildcards == null) {
throw new IllegalArgumentException("The wildcard list must not be null");
}
this.wildcards = wildcards.toArray(new String[wildcards.size()]);
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Constructs a new Suffix file filter for a single extension
* specifying case-sensitivity.
*
* @param suffix the suffix to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the suffix is null
* @since 1.4
*/
public SuffixFileFilter(final String suffix, final IOCase caseSensitivity) {
if (suffix == null) {
throw new IllegalArgumentException("The suffix must not be null");
}
this.suffixes = new String[] {suffix};
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Constructs a new Suffix file filter for a single extension
* specifying case-sensitivity.
*
* @param suffix the suffix to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the suffix is null
* @since 1.4
*/
public SuffixFileFilter(String suffix, IOCase caseSensitivity) {
if (suffix == null) {
throw new IllegalArgumentException("The suffix must not be null");
}
this.suffixes = new String[] {suffix};
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Constructs a new Suffix file filter for an array of suffixs
* specifying case-sensitivity.
* <p>
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
*
* @param suffixes the suffixes to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the suffix array is null
* @since 1.4
*/
public SuffixFileFilter(String[] suffixes, IOCase caseSensitivity) {
if (suffixes == null) {
throw new IllegalArgumentException("The array of suffixes must not be null");
}
this.suffixes = new String[suffixes.length];
System.arraycopy(suffixes, 0, this.suffixes, 0, suffixes.length);
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Constructs a new Prefix file filter for a single prefix.
*
* @param prefix the prefix to allow, must not be null
* @throws IllegalArgumentException if the prefix is null
*/
public PrefixFileFilter(String prefix) {
this(prefix, IOCase.SENSITIVE);
}
/**
* Constructs a new Prefix file filter for a list of prefixes.
*
* @param prefixes the prefixes to allow, must not be null
* @throws IllegalArgumentException if the prefix list is null
* @throws ClassCastException if the list does not contain Strings
*/
public PrefixFileFilter(List<String> prefixes) {
this(prefixes, IOCase.SENSITIVE);
}
/**
* Construct a file extension comparator instance with the specified case-sensitivity.
*
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
*/
public ExtensionFileComparator(final IOCase caseSensitivity) {
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Construct a file name comparator instance with the specified case-sensitivity.
*
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
*/
public NameFileComparator(IOCase caseSensitivity) {
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Constructs a new Suffix file filter for a single extension.
*
* @param suffix the suffix to allow, must not be null
* @throws IllegalArgumentException if the suffix is null
*/
public SuffixFileFilter(final String suffix) {
this(suffix, IOCase.SENSITIVE);
}
/**
* Constructs a new Suffix file filter for a single extension.
*
* @param suffix the suffix to allow, must not be null
* @throws IllegalArgumentException if the suffix is null
*/
public SuffixFileFilter(String suffix) {
this(suffix, IOCase.SENSITIVE);
}
/**
* Constructs a new Prefix file filter for a list of prefixes.
*
* @param prefixes the prefixes to allow, must not be null
* @throws IllegalArgumentException if the prefix list is null
* @throws ClassCastException if the list does not contain Strings
*/
public PrefixFileFilter(final List<String> prefixes) {
this(prefixes, IOCase.SENSITIVE);
}
/**
* Constructs a new Suffix file filter for a list of suffixes.
*
* @param suffixes the suffixes to allow, must not be null
* @throws IllegalArgumentException if the suffix list is null
* @throws ClassCastException if the list does not contain Strings
*/
public SuffixFileFilter(List<String> suffixes) {
this(suffixes, IOCase.SENSITIVE);
}
/**
* Constructs a new Prefix file filter for a single prefix.
*
* @param prefix the prefix to allow, must not be null
* @throws IllegalArgumentException if the prefix is null
*/
public PrefixFileFilter(final String prefix) {
this(prefix, IOCase.SENSITIVE);
}
/**
* Construct a file path comparator instance with the specified case-sensitivity.
*
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
*/
public PathFileComparator(final IOCase caseSensitivity) {
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}
/**
* Construct a file extension comparator instance with the specified case-sensitivity.
*
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
*/
public ExtensionFileComparator(IOCase caseSensitivity) {
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
}