Top Description Inners Fields Constructors Methods
org.apache.commons.compress.compressors.xz

public Class XZUtils

extends Object
Class Inheritance
Imports
java.util.HashMap, .Map, org.apache.commons.compress.compressors.FileNameUtil, org.apache.commons.compress.utils.OsgiUtils

Utility code for the XZ compression format.
Since
1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
private static volatile XZUtils.CachedAvailability
private static final FileNameUtil
private static final byte[]
HEADER_MAGIC

XZ Header Magic Bytes begin a XZ file.

Constructor Summary

AccessConstructor and Description
private
XZUtils()

Private constructor to prevent instantiation of this utility class.

Method Summary

Modifier and TypeMethod and Description
pack-priv static XZUtils.CachedAvailability
public static String

Returns:

name of the corresponding compressed file
getCompressedFilename
(final String
name of a file
fileName
)

Maps the given file name to the name that the file should have after compression with xz.
public static String

Returns:

name of the corresponding compressed file
getCompressedFileName
(final String
name of a file
fileName
)

Maps the given file name to the name that the file should have after compression with xz.

public static String

Returns:

name of the corresponding uncompressed file
getUncompressedFilename
(final String
name of a file
fileName
)

Maps the given name of a xz-compressed file to the name that the file should have after uncompression.
public static String

Returns:

name of the corresponding uncompressed file
getUncompressedFileName
(final String
name of a file
fileName
)

Maps the given name of a xz-compressed file to the name that the file should have after uncompression.

private static boolean
public static boolean

Returns:

true if the file name has a common xz suffix, false otherwise
isCompressedFilename
(final String
name of a file
fileName
)

Detects common xz suffixes in the given file name.
public static boolean

Returns:

true if the file name has a common xz suffix, false otherwise
isCompressedFileName
(final String
name of a file
fileName
)

Detects common xz suffixes in the given file name.

public static boolean

Returns:

true if the classes required to support XZ compression are available
isXZCompressionAvailable
()

Are the classes required to support XZ compression available?

public static boolean

Returns:

true if signature matches the .xz magic bytes, false otherwise
matches
(final byte[]
the bytes to check
signature
,
final int
the number of bytes to check
length
)

Checks if the signature matches what is expected for a .xz file.

public static void
setCacheXZAvailablity(final boolean
whether to cache the result
doCache
)

Whether to cache the result of the XZ for Java check.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedXZAvailabilityback to summary
private static volatile XZUtils.CachedAvailability cachedXZAvailability
fileNameUtilback to summary
private static final FileNameUtil fileNameUtil
HEADER_MAGICback to summary
private static final byte[] HEADER_MAGIC

XZ Header Magic Bytes begin a XZ file.

This is a copy of org.tukaani.xz.XZ.HEADER_MAGIC in XZ for Java version 1.5.

Constructor Detail

XZUtilsback to summary
private XZUtils()

Private constructor to prevent instantiation of this utility class.

Method Detail

getCachedXZAvailabilityback to summary
pack-priv static XZUtils.CachedAvailability getCachedXZAvailability()
getCompressedFilenameback to summary
public static String getCompressedFilename(final String fileName)

Maps the given file name to the name that the file should have after compression with xz. Common file types with custom suffixes for compressed versions are automatically detected and correctly mapped. For example the name "package.tar" is mapped to "package.txz". If no custom mapping is applicable, then the default ".xz" suffix is appended to the file name.

Parameters
fileName:String

name of a file

Returns:String

name of the corresponding compressed file

Annotations
@Deprecated
getCompressedFileNameback to summary
public static String getCompressedFileName(final String fileName)

Maps the given file name to the name that the file should have after compression with xz. Common file types with custom suffixes for compressed versions are automatically detected and correctly mapped. For example the name "package.tar" is mapped to "package.txz". If no custom mapping is applicable, then the default ".xz" suffix is appended to the file name.

Parameters
fileName:String

name of a file

Returns:String

name of the corresponding compressed file

Since
1.25.0
getUncompressedFilenameback to summary
public static String getUncompressedFilename(final String fileName)

Maps the given name of a xz-compressed file to the name that the file should have after uncompression. Commonly used file type specific suffixes like ".txz" are automatically detected and correctly mapped. For example the name "package.txz" is mapped to "package.tar". And any file names with the generic ".xz" suffix (or any other generic xz suffix) is mapped to a name without that suffix. If no xz suffix is detected, then the file name is returned unmapped.

Parameters
fileName:String

name of a file

Returns:String

name of the corresponding uncompressed file

Annotations
@Deprecated
getUncompressedFileNameback to summary
public static String getUncompressedFileName(final String fileName)

Maps the given name of a xz-compressed file to the name that the file should have after uncompression. Commonly used file type specific suffixes like ".txz" are automatically detected and correctly mapped. For example the name "package.txz" is mapped to "package.tar". And any file names with the generic ".xz" suffix (or any other generic xz suffix) is mapped to a name without that suffix. If no xz suffix is detected, then the file name is returned unmapped.

Parameters
fileName:String

name of a file

Returns:String

name of the corresponding uncompressed file

Since
1.25.0
internalIsXZCompressionAvailableback to summary
private static boolean internalIsXZCompressionAvailable()
isCompressedFilenameback to summary
public static boolean isCompressedFilename(final String fileName)

Detects common xz suffixes in the given file name.

Parameters
fileName:String

name of a file

Returns:boolean

true if the file name has a common xz suffix, false otherwise

Annotations
@Deprecated
isCompressedFileNameback to summary
public static boolean isCompressedFileName(final String fileName)

Detects common xz suffixes in the given file name.

Parameters
fileName:String

name of a file

Returns:boolean

true if the file name has a common xz suffix, false otherwise

Since
1.25.0
isXZCompressionAvailableback to summary
public static boolean isXZCompressionAvailable()

Are the classes required to support XZ compression available?

Returns:boolean

true if the classes required to support XZ compression are available

Since
1.5
matchesback to summary
public static boolean matches(final byte[] signature, final int length)

Checks if the signature matches what is expected for a .xz file.

This is more or less a copy of the version found in XZCompressorInputStream but doesn't depend on the presence of XZ for Java.

Parameters
signature:byte[]

the bytes to check

length:int

the number of bytes to check

Returns:boolean

true if signature matches the .xz magic bytes, false otherwise

Since
1.9
setCacheXZAvailablityback to summary
public static void setCacheXZAvailablity(final boolean doCache)

Whether to cache the result of the XZ for Java check.

This defaults to false in an OSGi environment and true otherwise.

Parameters
doCache:boolean

whether to cache the result

Since
1.9
org.apache.commons.compress.compressors.xz back to summary

pack-priv final Enum XZUtils.CachedAvailability

extends Enum<XZUtils.CachedAvailability>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final XZUtils.CachedAvailability
public static final XZUtils.CachedAvailability
public static final XZUtils.CachedAvailability

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static XZUtils.CachedAvailability
public static XZUtils.CachedAvailability[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CACHED_AVAILABLEback to summary
public static final XZUtils.CachedAvailability CACHED_AVAILABLE
CACHED_UNAVAILABLEback to summary
public static final XZUtils.CachedAvailability CACHED_UNAVAILABLE
DONT_CACHEback to summary
public static final XZUtils.CachedAvailability DONT_CACHE

Constructor Detail

CachedAvailabilityback to summary
private CachedAvailability()

Method Detail

valueOfback to summary
public static XZUtils.CachedAvailability valueOf(String name)
valuesback to summary
public static XZUtils.CachedAvailability[] values()