|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Uniform
org.restlet.Restlet
org.restlet.Filter
com.noelios.restlet.application.Encoder
public class Encoder
Filter compressing entities. The best encoding is automatically selected
based on the preferences of the client and on the encoding supported by NRE:
GZip, Zip and Deflate.
If the Representation
has an unknown size, it
will always be a candidate for encoding. Candidate representations need to
respect media type criteria by the lists of accepted and ignored media types.
Concurrency note: instances of this class or its subclasses can be invoked by
several threads at the same time and therefore must be thread-safe. You
should be especially careful when storing state in member variables.
Field Summary | |
---|---|
static int |
ENCODE_ALL_SIZES
Indicates if the encoding should always occur, regardless of the size. |
Fields inherited from class org.restlet.Filter |
---|
CONTINUE, SKIP, STOP |
Constructor Summary | |
---|---|
Encoder(Context context)
Constructor using the default media types and with ENCODE_ALL_SIZES setting. |
|
Encoder(Context context,
boolean encodeInput,
boolean encodeOutput,
long minimumSize,
java.util.List<MediaType> acceptedMediaTypes,
java.util.List<MediaType> ignoredMediaTypes)
Constructor. |
Method Summary | |
---|---|
void |
afterHandle(Request request,
Response response)
Allows filtering after its handling by the target Restlet. |
int |
beforeHandle(Request request,
Response response)
Allows filtering before its handling by the target Restlet. |
boolean |
canEncode(Representation representation)
Indicates if a representation can be encoded. |
Representation |
encode(ClientInfo client,
Representation representation)
Encodes a given representation if an encoding is supported by the client. |
java.util.List<MediaType> |
getAcceptedMediaTypes()
Returns the media types that should be encoded. |
Encoding |
getBestEncoding(ClientInfo client)
Returns the best supported encoding for a given client. |
static java.util.List<MediaType> |
getDefaultAcceptedMediaTypes()
Returns the list of default encoded media types. |
static java.util.List<MediaType> |
getDefaultIgnoredMediaTypes()
Returns the list of default ignored media types. |
java.util.List<MediaType> |
getIgnoredMediaTypes()
Returns the media types that should be ignored. |
long |
getMinimumSize()
Returns the minimum size a representation must have before compression is done. |
boolean |
isEncodeRequest()
Indicates if the request entity should be encoded. |
boolean |
isEncodeResponse()
Indicates if the response entity should be encoded. |
void |
setEncodeRequest(boolean encodeRequest)
Indicates if the request entity should be encoded. |
void |
setEncodeResponse(boolean encodeResponse)
Indicates if the response entity should be encoded. |
void |
setMinimumSize(long mininumSize)
Sets the minimum size a representation must have before compression is done. |
Methods inherited from class org.restlet.Filter |
---|
doHandle, getNext, handle, hasNext, setNext, setNext |
Methods inherited from class org.restlet.Restlet |
---|
getApplication, getContext, getLogger, init, isStarted, isStopped, setContext, start, stop |
Methods inherited from class org.restlet.Uniform |
---|
delete, delete, get, get, handle, head, head, options, options, post, post, put, put |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ENCODE_ALL_SIZES
Constructor Detail |
---|
public Encoder(Context context)
ENCODE_ALL_SIZES
setting. This constructor will only encode
response entities after call handling.
context
- The context.public Encoder(Context context, boolean encodeInput, boolean encodeOutput, long minimumSize, java.util.List<MediaType> acceptedMediaTypes, java.util.List<MediaType> ignoredMediaTypes)
context
- The context.encodeInput
- Indicates if the request entities should be encoded.encodeOutput
- Indicates if the response entities should be encoded.minimumSize
- The minimal size of the representation where compression
should be used.acceptedMediaTypes
- The media types that should be encoded.ignoredMediaTypes
- The media types that should be ignored.Method Detail |
---|
public static java.util.List<MediaType> getDefaultAcceptedMediaTypes()
public static java.util.List<MediaType> getDefaultIgnoredMediaTypes()
public void afterHandle(Request request, Response response)
afterHandle
in class Filter
request
- The request to filter.response
- The response to filter.public int beforeHandle(Request request, Response response)
beforeHandle
in class Filter
request
- The request to filter.response
- The response to filter.
public boolean canEncode(Representation representation)
representation
- The representation to test.
public Representation encode(ClientInfo client, Representation representation)
client
- The client preferences to use.representation
- The representation to encode.
public java.util.List<MediaType> getAcceptedMediaTypes()
public Encoding getBestEncoding(ClientInfo client)
client
- The client preferences to use.
public java.util.List<MediaType> getIgnoredMediaTypes()
public long getMinimumSize()
public boolean isEncodeRequest()
public boolean isEncodeResponse()
public void setEncodeRequest(boolean encodeRequest)
encodeRequest
- True if the request entity should be encoded.public void setEncodeResponse(boolean encodeResponse)
encodeResponse
- True if the response entity should be encoded.public void setMinimumSize(long mininumSize)
mininumSize
- The minimum size a representation must have before compression
is done.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |