Package org.openstreetmap.josm.io
Enum Compression
- java.lang.Object
-
- java.lang.Enum<Compression>
-
- org.openstreetmap.josm.io.Compression
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Compression>
public enum Compression extends java.lang.Enum<Compression>
An enum representing the compression type of a resource.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Compression()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Compression
byExtension(java.lang.String name)
Determines the compression type depending on the suffix ofname
.static Compression
forContentType(java.lang.String contentType)
Determines the compression type based on the content type (MIME type).static org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream
getBZip2InputStream(java.io.InputStream in)
Returns a Bzip2 input stream wrapping given input stream.static java.io.OutputStream
getCompressedFileOutputStream(java.io.File file)
Returns a compressingOutputStream
for theFile
file
.static java.io.OutputStream
getCompressedFileOutputStream(java.nio.file.Path path)
Returns a compressingOutputStream
for thePath
path
.java.io.OutputStream
getCompressedOutputStream(java.io.OutputStream out)
Returns a compressingOutputStream
forout
.static java.util.zip.GZIPInputStream
getGZipInputStream(java.io.InputStream in)
Returns a Gzip input stream wrapping given input stream.static java.io.InputStream
getUncompressedFileInputStream(java.io.File file)
Returns an un-compressingInputStream
for theFile
file
.static java.io.InputStream
getUncompressedFileInputStream(java.nio.file.Path path)
Returns an un-compressingInputStream
for thePath
path
.java.io.InputStream
getUncompressedInputStream(java.io.InputStream in)
Returns an un-compressingInputStream
forin
.static org.apache.commons.compress.compressors.xz.XZCompressorInputStream
getXZInputStream(java.io.InputStream in)
Returns a XZ input stream wrapping given input stream.static java.util.zip.ZipInputStream
getZipInputStream(java.io.InputStream in)
Returns a Zip input stream wrapping given input stream.static Compression
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Compression[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NONE
public static final Compression NONE
no compression
-
BZIP2
public static final Compression BZIP2
bzip2 compression
-
GZIP
public static final Compression GZIP
gzip compression
-
ZIP
public static final Compression ZIP
zip compression
-
XZ
public static final Compression XZ
xz compression
-
-
Constructor Detail
-
Compression
private Compression()
-
-
Method Detail
-
values
public static Compression[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Compression c : Compression.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Compression valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
byExtension
public static Compression byExtension(java.lang.String name)
Determines the compression type depending on the suffix ofname
.- Parameters:
name
- File name including extension- Returns:
- the compression type
-
forContentType
public static Compression forContentType(java.lang.String contentType)
Determines the compression type based on the content type (MIME type).- Parameters:
contentType
- the content type- Returns:
- the compression type
-
getUncompressedInputStream
public java.io.InputStream getUncompressedInputStream(java.io.InputStream in) throws java.io.IOException
Returns an un-compressingInputStream
forin
.- Parameters:
in
- raw input stream- Returns:
- un-compressing input stream
- Throws:
java.io.IOException
- if any I/O error occurs
-
getXZInputStream
public static org.apache.commons.compress.compressors.xz.XZCompressorInputStream getXZInputStream(java.io.InputStream in) throws java.io.IOException
Returns a XZ input stream wrapping given input stream.- Parameters:
in
- The raw input stream- Returns:
- a XZ input stream wrapping given input stream, or
null
ifin
isnull
- Throws:
java.io.IOException
- if the given input stream does not contain valid BZ2 header- Since:
- 13350
-
getBZip2InputStream
public static org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream getBZip2InputStream(java.io.InputStream in) throws java.io.IOException
Returns a Bzip2 input stream wrapping given input stream.- Parameters:
in
- The raw input stream- Returns:
- a Bzip2 input stream wrapping given input stream, or
null
ifin
isnull
- Throws:
java.io.IOException
- if the given input stream does not contain valid BZ2 header- Since:
- 12772 (moved from
Utils
, there since 7867)
-
getGZipInputStream
public static java.util.zip.GZIPInputStream getGZipInputStream(java.io.InputStream in) throws java.io.IOException
Returns a Gzip input stream wrapping given input stream.- Parameters:
in
- The raw input stream- Returns:
- a Gzip input stream wrapping given input stream, or
null
ifin
isnull
- Throws:
java.io.IOException
- if an I/O error has occurred- Since:
- 12772 (moved from
Utils
, there since 7119)
-
getZipInputStream
public static java.util.zip.ZipInputStream getZipInputStream(java.io.InputStream in) throws java.io.IOException
Returns a Zip input stream wrapping given input stream.- Parameters:
in
- The raw input stream- Returns:
- a Zip input stream wrapping given input stream, or
null
ifin
isnull
- Throws:
java.io.IOException
- if an I/O error has occurred- Since:
- 12772 (moved from
Utils
, there since 7119)
-
getUncompressedFileInputStream
public static java.io.InputStream getUncompressedFileInputStream(java.io.File file) throws java.io.IOException
Returns an un-compressingInputStream
for theFile
file
.- Parameters:
file
- file- Returns:
- un-compressing input stream
- Throws:
java.io.IOException
- if any I/O error occurs
-
getUncompressedFileInputStream
public static java.io.InputStream getUncompressedFileInputStream(java.nio.file.Path path) throws java.io.IOException
Returns an un-compressingInputStream
for thePath
path
.- Parameters:
path
- path- Returns:
- un-compressing input stream
- Throws:
java.io.IOException
- if any I/O error occurs- Since:
- 16816
-
getCompressedOutputStream
public java.io.OutputStream getCompressedOutputStream(java.io.OutputStream out) throws java.io.IOException
Returns a compressingOutputStream
forout
.- Parameters:
out
- raw output stream- Returns:
- compressing output stream
- Throws:
java.io.IOException
- if any I/O error occurs
-
getCompressedFileOutputStream
public static java.io.OutputStream getCompressedFileOutputStream(java.io.File file) throws java.io.IOException
Returns a compressingOutputStream
for theFile
file
.- Parameters:
file
- file- Returns:
- compressing output stream
- Throws:
java.io.IOException
- if any I/O error occursjava.nio.file.InvalidPathException
- if a Path object cannot be constructed from the abstract path
-
getCompressedFileOutputStream
public static java.io.OutputStream getCompressedFileOutputStream(java.nio.file.Path path) throws java.io.IOException
Returns a compressingOutputStream
for thePath
path
.- Parameters:
path
- path- Returns:
- compressing output stream
- Throws:
java.io.IOException
- if any I/O error occursjava.nio.file.InvalidPathException
- if a Path object cannot be constructed from the abstract path- Since:
- 16816
-
-