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

public Class LZMAUtils

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 LZMA compression format.
Since
1.10

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

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

LZMA Header Magic Bytes begin a LZMA file.

Constructor Summary

AccessConstructor and Description
private
LZMAUtils()

Private constructor to prevent instantiation of this utility class.

Method Summary

Modifier and TypeMethod and Description
pack-priv static LZMAUtils.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 LZMA.
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 LZMA.

public static String

Returns:

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

Maps the given name of a LZMA-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 LZMA-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 LZMA suffix, false otherwise
isCompressedFilename
(final String
name of a file
fileName
)

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

Returns:

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

Detects common LZMA suffixes in the given file name.

public static boolean

Returns:

true if the classes required to support LZMA compression are available
isLZMACompressionAvailable
()

Are the classes required to support LZMA compression available?

public static boolean

Returns:

true if signature matches the .lzma 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 .lzma file.

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

Whether to cache the result of the LZMA check.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedLZMAAvailabilityback to summary
private static volatile LZMAUtils.CachedAvailability cachedLZMAAvailability
fileNameUtilback to summary
private static final FileNameUtil fileNameUtil
HEADER_MAGICback to summary
private static final byte[] HEADER_MAGIC

LZMA Header Magic Bytes begin a LZMA file.

Constructor Detail

LZMAUtilsback to summary
private LZMAUtils()

Private constructor to prevent instantiation of this utility class.

Method Detail

getCachedLZMAAvailabilityback to summary
pack-priv static LZMAUtils.CachedAvailability getCachedLZMAAvailability()
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 LZMA.

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 LZMA.

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 LZMA-compressed file to the name that the file should have after uncompression. Any file names with the generic ".lzma" suffix (or any other generic LZMA suffix) is mapped to a name without that suffix. If no LZMA 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 LZMA-compressed file to the name that the file should have after uncompression. Any file names with the generic ".lzma" suffix (or any other generic LZMA suffix) is mapped to a name without that suffix. If no LZMA 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
internalIsLZMACompressionAvailableback to summary
private static boolean internalIsLZMACompressionAvailable()
isCompressedFilenameback to summary
public static boolean isCompressedFilename(final String fileName)

Detects common LZMA suffixes in the given file name.

Parameters
fileName:String

name of a file

Returns:boolean

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

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

Detects common LZMA suffixes in the given file name.

Parameters
fileName:String

name of a file

Returns:boolean

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

Since
1.25.0
isLZMACompressionAvailableback to summary
public static boolean isLZMACompressionAvailable()

Are the classes required to support LZMA compression available?

Returns:boolean

true if the classes required to support LZMA compression are available

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

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

Parameters
signature:byte[]

the bytes to check

length:int

the number of bytes to check

Returns:boolean

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

setCacheLZMAAvailablityback to summary
public static void setCacheLZMAAvailablity(final boolean doCache)

Whether to cache the result of the LZMA check.

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

Parameters
doCache:boolean

whether to cache the result

org.apache.commons.compress.compressors.lzma back to summary

pack-priv final Enum LZMAUtils.CachedAvailability

extends Enum<LZMAUtils.CachedAvailability>
Class Inheritance

Field Summary

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

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Field Detail

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

Constructor Detail

CachedAvailabilityback to summary
private CachedAvailability()

Method Detail

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