Enum FileType
- java.lang.Object
-
- java.lang.Enum<FileType>
-
- org.torproject.metrics.collector.webstats.FileType
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<FileType>
public enum FileType extends java.lang.Enum<FileType>
These enums provide compression functionality.findType(java.lang.String)
determines the compression type by the given extension. Compression can also be zero-compression, which is currently provided by the PLAIN and JSON enums.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
compress(byte[] bytes)
Compresses the given bytes in memory and returns the compressed bytes.java.io.OutputStream
compress(java.io.OutputStream os)
Compresses the given InputStream and returns an OutputStream.byte[]
decompress(byte[] bytes)
Decompresses the given bytes in memory and returns the decompressed bytes.java.io.InputStream
decompress(java.io.InputStream is)
Decompresses the given InputStream and returns an OutputStream.static FileType
findType(java.lang.String ext)
ReturnsvalueOf
or the default enumPLAIN
, i.e., this method doesn't throw any exceptions and allways returns a valid enum.java.io.InputStream
inputStream(java.io.InputStream is)
Return the appropriate input stream.java.io.OutputStream
outputStream(java.io.OutputStream os)
Return the appropriate output stream.static FileType
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static FileType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static FileType[] 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 (FileType c : FileType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static FileType 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
-
findType
public static FileType findType(java.lang.String ext)
ReturnsvalueOf
or the default enumPLAIN
, i.e., this method doesn't throw any exceptions and allways returns a valid enum.
-
inputStream
public java.io.InputStream inputStream(java.io.InputStream is) throws java.lang.Exception
Return the appropriate input stream.- Throws:
java.lang.Exception
-
outputStream
public java.io.OutputStream outputStream(java.io.OutputStream os) throws java.lang.Exception
Return the appropriate output stream.- Throws:
java.lang.Exception
-
compress
public byte[] compress(byte[] bytes) throws java.lang.Exception
Compresses the given bytes in memory and returns the compressed bytes.- Throws:
java.lang.Exception
-
compress
public java.io.OutputStream compress(java.io.OutputStream os) throws java.lang.Exception
Compresses the given InputStream and returns an OutputStream.- Throws:
java.lang.Exception
-
decompress
public java.io.InputStream decompress(java.io.InputStream is) throws java.lang.Exception
Decompresses the given InputStream and returns an OutputStream.- Throws:
java.lang.Exception
-
decompress
public byte[] decompress(byte[] bytes) throws java.lang.Exception
Decompresses the given bytes in memory and returns the decompressed bytes.- Throws:
java.lang.Exception
- Since:
- 2.2.0
-
-