Package com.iizix.jetty
Enum Class WSHelper.Type
- All Implemented Interfaces:
Serializable,Comparable<WSHelper.Type>,Constable
- Enclosing class:
WSHelper
The compression types enum.
Overview of each type's file extension, minimum compress size and the candidate source file extensions that are precompressed:
Type Extension Minimum size (bytes) --------- --------- -------------------- GZIP .gz 128 BROTLI .br 48 ZSTANDARD .zst 48
All three types currently share the same candidate source extensions (stored per type in fileExtensionCandidates): .js .mjs .css .htm .html .svg .json .webmanifest .xml .txt .map .wasm .ttf .otf .eot .ico
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>Enum Constant Summary
Enum ConstantsField Summary
FieldsModifier and TypeFieldDescriptionfinal intThe compression level to use for this type, always set to best level of compression for each compression type.final StringThe extension (including the '.').The candidate source file extensions for this compression type (lower-case, each including the leading '.').final intThe minimum size, in bytes, below which a response body of this compression type is passed through uncompressed regardless ofAccept-Encoding.Method Summary
Modifier and TypeMethodDescriptionappendToPath(URI uri) Appends the suffix of this compression type to a URI.static WSHelper.TypeGets the extension type from the string (with or without '.' prefix), case insensitive.booleanChecks if this Jetty instance supports the compression type and is available for use.booleanChecks if this Jetty instance supports the compression type and is available for use.static WSHelper.TypeReturns the enum constant of this class with the specified name.static WSHelper.Type[]values()Returns an array containing the constants of this enum class, in the order they are declared.
Enum Constant Details
GZIP
GZIP compression type. ItsminimumSizeis 128: gzip carries ~18 bytes of header/trailer plus block overhead, so it uses a higher floor than brotli/zstandard; 128 is a conservative, web-common value below which compression is not worthwhile. GZIP compression is set to 9 = Best.BROTLI
Brotli compression type. ItsminimumSizeis 48: brotli's small per-stream overhead and built-in dictionary make it worthwhile on smaller payloads; 48 matches Jetty's brotli module default. Brotli compression is set to 11 = Best.ZSTANDARD
Zstandard compression type. ItsminimumSizeis 48: zstandard's small frame overhead makes it worthwhile on smaller payloads, like brotli; 48 matches Jetty's zstandard module default. Zstandard compression is set to what Jetty can handle as its best, i.e. 19 (and the levels 20-22, so-called "ultra" are not exposed by the Jetty wrapper and cannot be used).
Field Details
extension
The extension (including the '.').compressionLevel
public final int compressionLevelThe compression level to use for this type, always set to best level of compression for each compression type.minimumSize
public final int minimumSizeThe minimum size, in bytes, below which a response body of this compression type is passed through uncompressed regardless ofAccept-Encoding. Wired tosetMinCompressSize(int)on the Jetty Compression instance inWSHelper.createCompressionsHandler(Handler). Declaredpublic finalso it can be read directly without a getter; set before the web server starts.fileExtensionCandidates
The candidate source file extensions for this compression type (lower-case, each including the leading '.'). These are the file types the precompression build script (compress-candidate-files.js) compresses to a 'extension' sibling; already-compressed types (images, media, archives, and the web fonts '.woff'/'.woff2') are deliberately excluded. Informational on the Java side -- the actual filtering happens in the build script, which mirrors this list by convention.
Method Details
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
isAvailable
Checks if this Jetty instance supports the compression type and is available for use.- Returns:
- The availability flag.
- Throws:
Throwable- In case the instance is not supported.
isAvailableSilent
public boolean isAvailableSilent()Checks if this Jetty instance supports the compression type and is available for use. The check is done silently so no exception is thrown, butfalseis returned.- Returns:
- The availability flag.
appendToPath
Appends the suffix of this compression type to a URI.- Parameters:
uri- The URI to append suffix to path.- Throws:
URISyntaxException- If there is an error when creating the new URI (should not occur) if suffix is just a normal file extension.
from
Gets the extension type from the string (with or without '.' prefix), case insensitive.- Parameters:
ext- The file extension.- Returns:
- The type, or
nullif none is found.