Package io.toro.martini.util
Class FilenameUtils
- java.lang.Object
-
- org.apache.commons.io.FilenameUtils
-
- io.toro.martini.util.FilenameUtils
-
public class FilenameUtils extends FilenameUtils
General filename and file path manipulation utilities.
-
-
Field Summary
Fields Modifier and Type Field Description static String[]
OS_SPECIFIC_FILES
Names of OS-specific files.static String[]
OS_SPECIFIC_FOLDERS
Names of OS-specific folders.-
Fields inherited from class org.apache.commons.io.FilenameUtils
EXTENSION_SEPARATOR, EXTENSION_SEPARATOR_STR
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
anyWildcardMatch(String[] filenames, String wildcardMatcher, IOCase caseSensitivity)
Checks if any of the entries infilenames
matcheswildcardMatcher
.static boolean
isOSSpecificFile(String filename)
Checks if given argumentfilename
represents an OS-specific file/folder.static Collection<String>
normalize(Collection<String> filenames)
Normalizes all entries offilenames
.static String
replaceExtension(String fileName, String ext)
-
Methods inherited from class org.apache.commons.io.FilenameUtils
concat, directoryContains, equals, equals, equalsNormalized, equalsNormalizedOnSystem, equalsOnSystem, getBaseName, getExtension, getFullPath, getFullPathNoEndSeparator, getName, getPath, getPathNoEndSeparator, getPrefix, getPrefixLength, indexOfExtension, indexOfLastSeparator, isExtension, isExtension, isExtension, normalize, normalize, normalizeNoEndSeparator, normalizeNoEndSeparator, removeExtension, separatorsToSystem, separatorsToUnix, separatorsToWindows, wildcardMatch, wildcardMatch, wildcardMatchOnSystem
-
-
-
-
Field Detail
-
OS_SPECIFIC_FILES
public static final String[] OS_SPECIFIC_FILES
Names of OS-specific files. Note: uses the characters '?' and '*' to represent a single or multiple wildcard characters.
-
OS_SPECIFIC_FOLDERS
public static final String[] OS_SPECIFIC_FOLDERS
Names of OS-specific folders. Note: uses the characters '?' and '*' to represent a single or multiple wildcard characters.
-
-
Method Detail
-
isOSSpecificFile
public static boolean isOSSpecificFile(String filename)
Checks if given argumentfilename
represents an OS-specific file/folder. A file/folder is deemed OS-specific if:- it's a folder and its name matches any of the entries in
OS_SPECIFIC_FOLDERS
- it's a file and its name matches any of the entries in
OS_SPECIFIC_FILES
- it's a file and it's contained in a folder whose name matches any of the entries in
OS_SPECIFIC_FOLDERS
filename
can be in either Unix or Windows format and is additionally, normalized before the actual check, so paths with single or double path steps are welcome.- Parameters:
filename
- to check- Returns:
true
iffilename
represents an OS-specific file; otherwisefalse
- it's a folder and its name matches any of the entries in
-
anyWildcardMatch
public static boolean anyWildcardMatch(String[] filenames, String wildcardMatcher, IOCase caseSensitivity)
Checks if any of the entries infilenames
matcheswildcardMatcher
. Delegates individual entry matching toFilenameUtils.wildcardMatch(String, String, IOCase)
.- Parameters:
filenames
- the filenames to match onwildcardMatcher
- the wildcard string to match againstcaseSensitivity
- what case sensitivity rule to use, null means case-sensitive- Returns:
true
if any of the entries infilenames
matcheswildcardMatcher
-
normalize
public static Collection<String> normalize(Collection<String> filenames)
Normalizes all entries offilenames
. Delegates toFilenameUtils.normalize(String)
.- Parameters:
filenames
- the filenames to normalize,null
returnsnull
- Returns:
- a new collection containing the normalized filenames,
null
whenever invalid - See Also:
FilenameUtils.normalize(String)
-
-