Package org.openstreetmap.josm.io
Enum Compression
- java.lang.Object
-
- java.lang.Enum<Compression>
-
- org.openstreetmap.josm.io.Compression
-
- All Implemented Interfaces:
Serializable
,Comparable<Compression>
public enum Compression extends 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(String name)
Determines the compression type depending on the suffix ofname
.static Compression
forContentType(String contentType)
Determines the compression type based on the content type (MIME type).static org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream
getBZip2InputStream(InputStream in)
Returns a Bzip2 input stream wrapping given input stream.static OutputStream
getCompressedFileOutputStream(File file)
static OutputStream
getCompressedFileOutputStream(Path path)
OutputStream
getCompressedOutputStream(OutputStream out)
Returns a compressingOutputStream
forout
.static GZIPInputStream
getGZipInputStream(InputStream in)
Returns a Gzip input stream wrapping given input stream.static InputStream
getUncompressedFileInputStream(File file)
static InputStream
getUncompressedFileInputStream(Path path)
InputStream
getUncompressedInputStream(InputStream in)
Returns an un-compressingInputStream
forin
.static org.apache.commons.compress.compressors.xz.XZCompressorInputStream
getXZInputStream(InputStream in)
Returns a XZ input stream wrapping given input stream.static ZipInputStream
getZipInputStream(InputStream in)
Returns a Zip input stream wrapping given input stream.static Compression
valueOf(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(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:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
byExtension
public static Compression byExtension(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(String contentType)
Determines the compression type based on the content type (MIME type).- Parameters:
contentType
- the content type- Returns:
- the compression type
-
getUncompressedInputStream
public InputStream getUncompressedInputStream(InputStream in) throws IOException
Returns an un-compressingInputStream
forin
.- Parameters:
in
- raw input stream- Returns:
- un-compressing input stream
- Throws:
IOException
- if any I/O error occurs
-
getXZInputStream
public static org.apache.commons.compress.compressors.xz.XZCompressorInputStream getXZInputStream(InputStream in) throws 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:
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(InputStream in) throws 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:
IOException
- if the given input stream does not contain valid BZ2 header- Since:
- 12772 (moved from
Utils
, there since 7867)
-
getGZipInputStream
public static GZIPInputStream getGZipInputStream(InputStream in) throws 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:
IOException
- if an I/O error has occurred- Since:
- 12772 (moved from
Utils
, there since 7119)
-
getZipInputStream
public static ZipInputStream getZipInputStream(InputStream in) throws 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:
IOException
- if an I/O error has occurred- Since:
- 12772 (moved from
Utils
, there since 7119)
-
getUncompressedFileInputStream
public static InputStream getUncompressedFileInputStream(File file) throws IOException
- Parameters:
file
- file- Returns:
- un-compressing input stream
- Throws:
IOException
- if any I/O error occurs
-
getUncompressedFileInputStream
public static InputStream getUncompressedFileInputStream(Path path) throws IOException
- Parameters:
path
- path- Returns:
- un-compressing input stream
- Throws:
IOException
- if any I/O error occurs- Since:
- 16816
-
getCompressedOutputStream
public OutputStream getCompressedOutputStream(OutputStream out) throws IOException
Returns a compressingOutputStream
forout
.- Parameters:
out
- raw output stream- Returns:
- compressing output stream
- Throws:
IOException
- if any I/O error occurs
-
getCompressedFileOutputStream
public static OutputStream getCompressedFileOutputStream(File file) throws IOException
- Parameters:
file
- file- Returns:
- compressing output stream
- Throws:
IOException
- if any I/O error occursInvalidPathException
- if a Path object cannot be constructed from the abstract path
-
getCompressedFileOutputStream
public static OutputStream getCompressedFileOutputStream(Path path) throws IOException
- Parameters:
path
- path- Returns:
- compressing output stream
- Throws:
IOException
- if any I/O error occursInvalidPathException
- if a Path object cannot be constructed from the abstract path- Since:
- 16816
-
-