- java.lang.Object
-
- java.lang.Enum<CompressedHttpServletResponse.Algorithm>
-
- org.omnifaces.servlet.CompressedHttpServletResponse.Algorithm
-
- All Implemented Interfaces:
Serializable
,Comparable<CompressedHttpServletResponse.Algorithm>
- Enclosing class:
- CompressedHttpServletResponse
public static enum CompressedHttpServletResponse.Algorithm extends Enum<CompressedHttpServletResponse.Algorithm>
Available compression algorithms.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BROTLI
It will use one of the following Brotli compression output streams, whichever is available first:com.aayushatharva.brotli4j.encoder.BrotliOutputStream
com.nixxcode.jvmbrotli.enc.BrotliOutputStream
DEFLATE
It will useDeflaterOutputStream
as compression output stream.GZIP
It will useGZIPOutputStream
as compression output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accepts(HttpServletRequest request)
Returnstrue
if the given request accepts this algorithm.OutputStream
createOutputStream(HttpServletResponse response)
Returns an output stream which is compressed using this algorithm for the given HTTP servlet response.static Optional<CompressedHttpServletResponse.Algorithm>
find(HttpServletRequest request)
Returns the best algorithm matching the given HTTP servlet request.String
getEncodingDirective()
Returns the encoding directive.Class<? extends OutputStream>
getOutputStreamClass()
Returns the output stream class being used.boolean
isAvailable()
Returnstrue
if this algorithm is available.static CompressedHttpServletResponse.Algorithm
valueOf(String name)
Returns the enum constant of this type with the specified name.static CompressedHttpServletResponse.Algorithm[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
BROTLI
public static final CompressedHttpServletResponse.Algorithm BROTLI
It will use one of the following Brotli compression output streams, whichever is available first:com.aayushatharva.brotli4j.encoder.BrotliOutputStream
com.nixxcode.jvmbrotli.enc.BrotliOutputStream
-
GZIP
public static final CompressedHttpServletResponse.Algorithm GZIP
It will useGZIPOutputStream
as compression output stream.
-
DEFLATE
public static final CompressedHttpServletResponse.Algorithm DEFLATE
It will useDeflaterOutputStream
as compression output stream.
-
-
Method Detail
-
values
public static CompressedHttpServletResponse.Algorithm[] 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 (CompressedHttpServletResponse.Algorithm c : CompressedHttpServletResponse.Algorithm.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CompressedHttpServletResponse.Algorithm 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
-
getEncodingDirective
public String getEncodingDirective()
Returns the encoding directive. This basically represents the unique identifier of the algorithm in the HTTPAccept-Encoding
header as well as the HTTPContent-Encoding
header.- Returns:
- The directive.
-
getOutputStreamClass
public Class<? extends OutputStream> getOutputStreamClass()
Returns the output stream class being used.- Returns:
- The output stream class being used.
-
isAvailable
public boolean isAvailable()
Returnstrue
if this algorithm is available.- Returns:
true
if this algorithm is available.
-
accepts
public boolean accepts(HttpServletRequest request)
Returnstrue
if the given request accepts this algorithm.- Parameters:
request
- The involved HTTP servlet request.- Returns:
true
if the given request accepts this algorithm.
-
createOutputStream
public OutputStream createOutputStream(HttpServletResponse response)
Returns an output stream which is compressed using this algorithm for the given HTTP servlet response.- Parameters:
response
- The HTTP servlet response to be compressed with this algorithm.- Returns:
- An output stream which is compressed using this algorithm.
- Throws:
UnsupportedOperationException
- When the output stream cannot be constructed for some reason.
-
find
public static Optional<CompressedHttpServletResponse.Algorithm> find(HttpServletRequest request)
Returns the best algorithm matching the given HTTP servlet request.- Parameters:
request
- The HTTP servlet request to find the best algorithm for.- Returns:
- The best algorithm matching the given HTTP servlet request.
-
-