|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Restlet
org.restlet.routing.Filter
org.restlet.engine.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.routing.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 encodingInput,
boolean encodingOutput,
long minimumSize,
List<MediaType> acceptedMediaTypes,
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. |
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 List<MediaType> |
getDefaultAcceptedMediaTypes()
Returns the list of default encoded media types. |
static List<MediaType> |
getDefaultIgnoredMediaTypes()
Returns the list of default ignored media types. |
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. |
List<Encoding> |
getSupportedEncodings()
Returns the list of supported encodings. |
boolean |
isEncodeRequest()
Deprecated. Use isEncodingRequest() instead. |
boolean |
isEncodeResponse()
Deprecated. Use isEncodingResponse() instead. |
boolean |
isEncodingRequest()
Indicates if the request entity should be encoded. |
boolean |
isEncodingResponse()
Indicates if the response entity should be encoded. |
void |
setEncodeRequest(boolean encodingRequest)
Deprecated. Use setEncodingRequest(boolean) instead. |
void |
setEncodeResponse(boolean encodingResponse)
Deprecated. Use setEncodingResponse(boolean) instead. |
void |
setEncodingRequest(boolean encodingRequest)
Indicates if the request entity should be encoded. |
void |
setEncodingResponse(boolean encodingResponse)
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.routing.Filter |
---|
doHandle, getNext, handle, hasNext, setNext, setNext, start, stop |
Methods inherited from class org.restlet.Restlet |
---|
finalize, getApplication, getAuthor, getContext, getDescription, getLogger, getName, getOwner, isStarted, isStopped, setAuthor, setContext, setDescription, setName, setOwner |
Methods inherited from class java.lang.Object |
---|
clone, equals, 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 encodingInput, boolean encodingOutput, long minimumSize, List<MediaType> acceptedMediaTypes, List<MediaType> ignoredMediaTypes)
context
- The context.encodingInput
- Indicates if the request entities should be encoded.encodingOutput
- 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 List<MediaType> getDefaultAcceptedMediaTypes()
public static 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 List<MediaType> getAcceptedMediaTypes()
public Encoding getBestEncoding(ClientInfo client)
client
- The client preferences to use.
public List<MediaType> getIgnoredMediaTypes()
public long getMinimumSize()
public List<Encoding> getSupportedEncodings()
EncodeRepresentation.getSupportedEncodings()
static method.
@Deprecated public boolean isEncodeRequest()
isEncodingRequest()
instead.
@Deprecated public boolean isEncodeResponse()
isEncodingResponse()
instead.
public boolean isEncodingRequest()
public boolean isEncodingResponse()
@Deprecated public void setEncodeRequest(boolean encodingRequest)
setEncodingRequest(boolean)
instead.
encodingRequest
- True if the request entity should be encoded.@Deprecated public void setEncodeResponse(boolean encodingResponse)
setEncodingResponse(boolean)
instead.
encodingResponse
- True if the response entity should be encoded.public void setEncodingRequest(boolean encodingRequest)
encodingRequest
- True if the request entity should be encoded.public void setEncodingResponse(boolean encodingResponse)
encodingResponse
- 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 |