public class FileNameUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.String> |
compressSuffix
Map from common filename suffixes to the suffixes that identify compressed
versions of those file types.
|
private java.lang.String |
defaultExtension
The format's default extension.
|
private int |
longestCompressedSuffix
Length of the longest compressed suffix.
|
private int |
longestUncompressedSuffix
Length of the longest uncompressed suffix.
|
private int |
shortestCompressedSuffix
Length of the shortest compressed suffix.
|
private int |
shortestUncompressedSuffix
Length of the shortest uncompressed suffix longer than the
empty string.
|
private java.util.Map<java.lang.String,java.lang.String> |
uncompressSuffix
Map from common filename suffixes of compressed files to the
corresponding suffixes of uncompressed files.
|
Constructor and Description |
---|
FileNameUtil(java.util.Map<java.lang.String,java.lang.String> uncompressSuffix,
java.lang.String defaultExtension)
sets up the utility with a map of known compressed to
uncompressed suffix mappings and the default extension of the
format.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCompressedFilename(java.lang.String filename)
Maps the given filename to the name that the file should have after
compression.
|
java.lang.String |
getUncompressedFilename(java.lang.String filename)
Maps the given name of a compressed file to the name that the
file should have after uncompression.
|
boolean |
isCompressedFilename(java.lang.String filename)
Detects common format suffixes in the given filename.
|
private final java.util.Map<java.lang.String,java.lang.String> compressSuffix
private final java.util.Map<java.lang.String,java.lang.String> uncompressSuffix
This map also contains format-specific suffixes like ".gz" and "-z". These suffixes are mapped to the empty string, as they should simply be removed from the filename when the file is uncompressed.
private final int longestCompressedSuffix
private final int shortestCompressedSuffix
private final int longestUncompressedSuffix
private final int shortestUncompressedSuffix
private final java.lang.String defaultExtension
public FileNameUtil(java.util.Map<java.lang.String,java.lang.String> uncompressSuffix, java.lang.String defaultExtension)
uncompressSuffix
- Map from common filename suffixes of
compressed files to the corresponding suffixes of uncompressed
files. For example: from ".tgz" to ".tar". This map also
contains format-specific suffixes like ".gz" and "-z". These
suffixes are mapped to the empty string, as they should simply
be removed from the filename when the file is uncompressed.defaultExtension
- the format's default extension like ".gz"public boolean isCompressedFilename(java.lang.String filename)
filename
- name of a filetrue
if the filename has a common format suffix,
false
otherwisepublic java.lang.String getUncompressedFilename(java.lang.String filename)
filename
- name of a filepublic java.lang.String getCompressedFilename(java.lang.String filename)
filename
- name of a file