public class XZUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
XZUtils.CachedAvailability |
Modifier and Type | Field and Description |
---|---|
private static XZUtils.CachedAvailability |
cachedXZAvailability |
private static FileNameUtil |
fileNameUtil |
private static byte[] |
HEADER_MAGIC
XZ Header Magic Bytes begin a XZ file.
|
Modifier | Constructor and Description |
---|---|
private |
XZUtils()
Private constructor to prevent instantiation of this utility class.
|
Modifier and Type | Method and Description |
---|---|
(package private) static XZUtils.CachedAvailability |
getCachedXZAvailability() |
static java.lang.String |
getCompressedFilename(java.lang.String filename)
Maps the given filename to the name that the file should have after
compression with xz.
|
static java.lang.String |
getUncompressedFilename(java.lang.String filename)
Maps the given name of a xz-compressed file to the name that the
file should have after uncompression.
|
private static boolean |
internalIsXZCompressionAvailable() |
static boolean |
isCompressedFilename(java.lang.String filename)
Detects common xz suffixes in the given filename.
|
static boolean |
isXZCompressionAvailable()
Are the classes required to support XZ compression available?
|
static boolean |
matches(byte[] signature,
int length)
Checks if the signature matches what is expected for a .xz file.
|
static void |
setCacheXZAvailablity(boolean doCache)
Whether to cache the result of the XZ for Java check.
|
private static final FileNameUtil fileNameUtil
private static final byte[] HEADER_MAGIC
This is a copy of org.tukaani.xz.XZ.HEADER_MAGIC
in
XZ for Java version 1.5.
private static volatile XZUtils.CachedAvailability cachedXZAvailability
private XZUtils()
public static boolean matches(byte[] signature, int length)
This is more or less a copy of the version found in XZCompressorInputStream
but doesn't depend on the presence of
XZ for Java.
signature
- the bytes to checklength
- the number of bytes to checkpublic static boolean isXZCompressionAvailable()
private static boolean internalIsXZCompressionAvailable()
public static boolean isCompressedFilename(java.lang.String filename)
filename
- name of a filetrue
if the filename has a common xz suffix,
false
otherwisepublic static java.lang.String getUncompressedFilename(java.lang.String filename)
filename
- name of a filepublic static java.lang.String getCompressedFilename(java.lang.String filename)
filename
- name of a filepublic static void setCacheXZAvailablity(boolean doCache)
This defaults to false
in an OSGi environment and true
otherwise.
doCache
- whether to cache the resultstatic XZUtils.CachedAvailability getCachedXZAvailability()