Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http

public final Class CompressionConfig

extends Object
Class Inheritance
Imports
java.util.Arrays, .Collections, .Set, org.glassfish.grizzly.http.util.DataChunk, .Header, .HttpUtils, org.glassfish.grizzly.utils.ArraySet

Compression configuration class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static interface
CompressionConfig.CompressionModeI

Common CompressionMode interface.

Field Summary

Modifier and TypeField and Description
private final ArraySet<String>
private int
private CompressionConfig.CompressionMode
private boolean
private final ArraySet<String>

Constructor Summary

AccessConstructor and Description
public
public
CompressionConfig(final CompressionConfig compression)

The copy constructor.

public
CompressionConfig(final CompressionConfig.CompressionMode compressionMode, final int compressionMinSize, final Set<String> compressibleMimeTypes, final Set<String> noCompressionUserAgents)

public
CompressionConfig(final CompressionConfig.CompressionMode compressionMode, final int compressionMinSize, final Set<String> compressibleMimeTypes, final Set<String> noCompressionUserAgents, final boolean decompressionEnabled)

Method Summary

Modifier and TypeMethod and Description
public boolean
checkMimeType(final String contentType)

Returns true if the resource with the given content-type could be compressed, or false otherwise.

public boolean
checkUserAgent(final HttpRequestPacket request)

Returns true if based on this configuration user-agent, specified in the HttpRequestPacket, can receive compressed data.

public Set<String>
getCompressableMimeTypes()

Returns the read-only set of the mime-types, which are allowed to be compressed.

public Set<String>
getCompressibleMimeTypes()

Returns the read-only set of the mime-types, which are allowed to be compressed.

public int
getCompressionMinSize()

Returns the minimum size of an entity, which will be compressed.

public CompressionConfig.CompressionMode
public Set<String>
getNoCompressionUserAgents()

Returns the read-only set of the user-agents, which will be always responded with uncompressed are.

private static int
indexOf(String[] aliases, DataChunk dc)

private static int
public static boolean

Returns:

true if a client, based on its HttpRequestPacket, could be responded with compressed data, or false otherwise
isClientSupportCompression
(final CompressionConfig compressionConfig, final HttpRequestPacket
client-side HttpRequestPacket
request
,
final String[]
compression algorithm aliases (to match with Accept-Encoding header)
aliases
)

Returns true if a client, based on its HttpRequestPacket, could be responded with compressed data, or false otherwise.

private static boolean
public boolean
isDecompressionEnabled()

Returns: true if decompression of incoming data is enabled.

public void
set(final CompressionConfig compression)

Copies the source CompressionConfig object value into this object.

public void
setCompressableMimeTypes(final Set<String> compressibleMimeTypes)

Sets the set of the mime-types, which are allowed to be compressed.

public void
setCompressableMimeTypes(final String... compressibleMimeTypes)

Sets the set of the mime-types, which are allowed to be compressed.

public void
setCompressibleMimeTypes(final Set<String> compressibleMimeTypes)

Sets the set of the mime-types, which are allowed to be compressed.

public void
setCompressibleMimeTypes(final String... compressibleMimeTypes)

Sets the set of the mime-types, which are allowed to be compressed.

public void
setCompressionMinSize(int compressionMinSize)

Sets the minimum size of an entity, which will be compressed.

public void
public void
setDecompressionEnabled(boolean decompressionEnabled)

If set to true content-encoding header for incoming data will be respected and data will be decompressed and the decompressed stream will be passed on.

public void
setNoCompressionUserAgents(final Set<String> noCompressionUserAgents)

Sets the set of the user-agents, which will be always responded with uncompressed data.

public void
setNoCompressionUserAgents(final String... noCompressionUserAgents)

Sets the set of the user-agents, which will be always responded with uncompressed data.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compressibleMimeTypesback to summary
private final ArraySet<String> compressibleMimeTypes
compressionMinSizeback to summary
private int compressionMinSize
compressionModeback to summary
private CompressionConfig.CompressionMode compressionMode
decompressionEnabledback to summary
private boolean decompressionEnabled
noCompressionUserAgentsback to summary
private final ArraySet<String> noCompressionUserAgents

Constructor Detail

CompressionConfigback to summary
public CompressionConfig()
CompressionConfigback to summary
public CompressionConfig(final CompressionConfig compression)

The copy constructor. The newly constructed CompressionConfig object will have the same settings as the source one, but actual values will be independent, so changes to one CompressionConfig object will not affect the other one.

Annotations
@SuppressWarnings:IncompleteCopyConstructor
CompressionConfigback to summary
public CompressionConfig(final CompressionConfig.CompressionMode compressionMode, final int compressionMinSize, final Set<String> compressibleMimeTypes, final Set<String> noCompressionUserAgents)
CompressionConfigback to summary
public CompressionConfig(final CompressionConfig.CompressionMode compressionMode, final int compressionMinSize, final Set<String> compressibleMimeTypes, final Set<String> noCompressionUserAgents, final boolean decompressionEnabled)

Method Detail

checkMimeTypeback to summary
public boolean checkMimeType(final String contentType)

Returns true if the resource with the given content-type could be compressed, or false otherwise.

checkUserAgentback to summary
public boolean checkUserAgent(final HttpRequestPacket request)

Returns true if based on this configuration user-agent, specified in the HttpRequestPacket, can receive compressed data.

getCompressableMimeTypesback to summary
public Set<String> getCompressableMimeTypes()

Returns the read-only set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed.

Annotations
@Deprecated
getCompressibleMimeTypesback to summary
public Set<String> getCompressibleMimeTypes()

Returns the read-only set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed.

Since
2.3.29
getCompressionMinSizeback to summary
public int getCompressionMinSize()

Returns the minimum size of an entity, which will be compressed.

getCompressionModeback to summary
public CompressionConfig.CompressionMode getCompressionMode()

Returns the CompressionMode.

getNoCompressionUserAgentsback to summary
public Set<String> getNoCompressionUserAgents()

Returns the read-only set of the user-agents, which will be always responded with uncompressed are. Empty set means that compressed data could be sent to *all* user-agents.

indexOfback to summary
private static int indexOf(String[] aliases, DataChunk dc)
indexOfStartsWithback to summary
private static int indexOfStartsWith(String[] aliases, String s)
isClientSupportCompressionback to summary
public static boolean isClientSupportCompression(final CompressionConfig compressionConfig, final HttpRequestPacket request, final String[] aliases)

Returns true if a client, based on its HttpRequestPacket, could be responded with compressed data, or false otherwise.

Parameters
compressionConfig:CompressionConfig

CompressionConfig

request:HttpRequestPacket

client-side HttpRequestPacket

aliases:String[]

compression algorithm aliases (to match with Accept-Encoding header)

Returns:boolean

true if a client, based on its HttpRequestPacket, could be responded with compressed data, or false otherwise

isClientSupportContentEncodingback to summary
private static boolean isClientSupportContentEncoding(HttpRequestPacket request, final String[] aliases)
isDecompressionEnabledback to summary
public boolean isDecompressionEnabled()
Returns:boolean

true if decompression of incoming data is enabled.

Since
2.3.29
setback to summary
public void set(final CompressionConfig compression)

Copies the source CompressionConfig object value into this object. As the result this CompressionConfig object will have the same settings as the source one, but actual values will be independent, so changes to one CompressionConfig object will not affect the other one.

setCompressableMimeTypesback to summary
public void setCompressableMimeTypes(final Set<String> compressibleMimeTypes)

Sets the set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.

Annotations
@Deprecated
setCompressableMimeTypesback to summary
public void setCompressableMimeTypes(final String... compressibleMimeTypes)

Sets the set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.

Annotations
@Deprecated
setCompressibleMimeTypesback to summary
public void setCompressibleMimeTypes(final Set<String> compressibleMimeTypes)

Sets the set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.

Since
2.3.29
setCompressibleMimeTypesback to summary
public void setCompressibleMimeTypes(final String... compressibleMimeTypes)

Sets the set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.

Since
2.3.29
setCompressionMinSizeback to summary
public void setCompressionMinSize(int compressionMinSize)

Sets the minimum size of an entity, which will be compressed.

setCompressionModeback to summary
public void setCompressionMode(final CompressionConfig.CompressionMode mode)

Sets the CompressionMode.

setDecompressionEnabledback to summary
public void setDecompressionEnabled(boolean decompressionEnabled)

If set to true content-encoding header for incoming data will be respected and data will be decompressed and the decompressed stream will be passed on.

Since
2.3.29
setNoCompressionUserAgentsback to summary
public void setNoCompressionUserAgents(final Set<String> noCompressionUserAgents)

Sets the set of the user-agents, which will be always responded with uncompressed data. Empty set means that compressed data could be sent to *all* user-agents. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.

setNoCompressionUserAgentsback to summary
public void setNoCompressionUserAgents(final String... noCompressionUserAgents)

Sets the set of the user-agents, which will be always responded with uncompressed data. Empty set means that compressed data could be sent to *all* user-agents. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.

org.glassfish.grizzly.http back to summary

public final Enum CompressionConfig.CompressionMode

extends Enum<CompressionConfig.CompressionMode>
implements CompressionModeI
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.http.CompressionConfig.CompressionModeI

Field Summary

Modifier and TypeField and Description
public static final CompressionConfig.CompressionMode
public static final CompressionConfig.CompressionMode
public static final CompressionConfig.CompressionMode

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static CompressionConfig.CompressionMode
fromString(final String mode)

Returns the CompressionMode based on the string representation.

public static CompressionConfig.CompressionMode
public static CompressionConfig.CompressionMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FORCEback to summary
public static final CompressionConfig.CompressionMode FORCE
OFFback to summary
public static final CompressionConfig.CompressionMode OFF
ONback to summary
public static final CompressionConfig.CompressionMode ON

Constructor Detail

CompressionModeback to summary
private CompressionMode()

Method Detail

fromStringback to summary
public static CompressionConfig.CompressionMode fromString(final String mode)

Returns the CompressionMode based on the string representation.

valueOfback to summary
public static CompressionConfig.CompressionMode valueOf(String name)
valuesback to summary
public static CompressionConfig.CompressionMode[] values()
org.glassfish.grizzly.http back to summary

public Interface CompressionConfig.CompressionModeI

Known Direct Implementers
org.glassfish.grizzly.http.CompressionConfig.CompressionMode

Common CompressionMode interface. It is a temporary solution used to deprecate CompressionLevel enum in http-server module. This interface is intended to be used in Grizzly core methods only. Please don't use this interface directly in your code. Please use CompressionMode enum in all the Grizzly core methods, that expect CompressionModeI.
See Also
CompressionMode