- 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 BROTLIIt will use one of the following Brotli compression output streams, whichever is available first:com.aayushatharva.brotli4j.encoder.BrotliOutputStreamcom.nixxcode.jvmbrotli.enc.BrotliOutputStreamDEFLATEIt will useDeflaterOutputStreamas compression output stream.GZIPIt will useGZIPOutputStreamas compression output stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccepts(HttpServletRequest request)Returnstrueif the given request accepts this algorithm.OutputStreamcreateOutputStream(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.StringgetEncodingDirective()Returns the encoding directive.Class<? extends OutputStream>getOutputStreamClass()Returns the output stream class being used.booleanisAvailable()Returnstrueif this algorithm is available.static CompressedHttpServletResponse.AlgorithmvalueOf(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.BrotliOutputStreamcom.nixxcode.jvmbrotli.enc.BrotliOutputStream
-
GZIP
public static final CompressedHttpServletResponse.Algorithm GZIP
It will useGZIPOutputStreamas compression output stream.
-
DEFLATE
public static final CompressedHttpServletResponse.Algorithm DEFLATE
It will useDeflaterOutputStreamas 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-Encodingheader as well as the HTTPContent-Encodingheader.- 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()
Returnstrueif this algorithm is available.- Returns:
trueif this algorithm is available.
-
accepts
public boolean accepts(HttpServletRequest request)
Returnstrueif the given request accepts this algorithm.- Parameters:
request- The involved HTTP servlet request.- Returns:
trueif 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.
-
-