Package org.rauschig.jarchivelib
Class FileType
- java.lang.Object
-
- org.rauschig.jarchivelib.FileType
-
public final class FileType extends java.lang.ObjectHolds the file extension as String and the correspondingArchiveFormatand/orCompressionType.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FileTypeget(java.io.File file)Checks the suffix of the givenFilefor an entry in the map.static FileTypeget(java.lang.String filename)Checks the suffix of the given string for an entry in the map.ArchiveFormatgetArchiveFormat()Returns the archive format corresponding to this file extension if any.CompressionTypegetCompressionType()Returns the compression type corresponding to this file extension if any.java.lang.StringgetSuffix()Returns the file extension suffix (e.g.booleanisArchive()Returns true if the given file extension denotes an archive.booleanisCompressed()Returns true if the given file extension denotes a compressed file.java.lang.StringtoString()
-
-
-
Field Detail
-
UNKNOWN
public static final FileType UNKNOWN
Special case object for an unknown archive/compression file type.
-
-
Method Detail
-
isArchive
public boolean isArchive()
Returns true if the given file extension denotes an archive.- Returns:
- true if file extension is an archive, false otherwise
-
isCompressed
public boolean isCompressed()
Returns true if the given file extension denotes a compressed file.- Returns:
- true if file extension is a compressed type, false otherwise
-
getSuffix
public java.lang.String getSuffix()
Returns the file extension suffix (e.g. ".zip" or ".tar.gz").- Returns:
- the file extension suffix
-
getArchiveFormat
public ArchiveFormat getArchiveFormat()
Returns the archive format corresponding to this file extension if any.- Returns:
- the archive format or null if the file extension does not denote an archive
-
getCompressionType
public CompressionType getCompressionType()
Returns the compression type corresponding to this file extension if any.- Returns:
- the compression type or null if the file extension does not denote a compressed file
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
get
public static FileType get(java.lang.String filename)
Checks the suffix of the given string for an entry in the map. If it exists, the correspondingFileTypeentry will be returned.- Parameters:
filename- the filename to check- Returns:
- a
FileTypeentry for the file extension of the given name, or the UNKNOWN type if it does not exist
-
get
public static FileType get(java.io.File file)
Checks the suffix of the givenFilefor an entry in the map. If it exists, the correspondingFileTypeentry will be returned.- Parameters:
file- the file to check- Returns:
- a
FileTypeentry for the file extension of the given file, or the UNKNOWN type if it does not exist
-
-