Package org.glassfish.jersey.spi
Class ContentEncoder
- java.lang.Object
-
- org.glassfish.jersey.spi.ContentEncoder
-
- All Implemented Interfaces:
javax.ws.rs.ext.ReaderInterceptor
,javax.ws.rs.ext.WriterInterceptor
- Direct Known Subclasses:
DeflateEncoder
,GZipEncoder
@Priority(4000) @Contract public abstract class ContentEncoder extends java.lang.Object implements javax.ws.rs.ext.ReaderInterceptor, javax.ws.rs.ext.WriterInterceptor
Standard contract for plugging in content encoding support. Provides a standard way of implementing encodingWriterInterceptor
and decodingReaderInterceptor
. Implementing this class ensures the encoding supported by the implementation will be considered during the content negotiation phase when deciding which encoding should be used based on the accepted encodings (and the associated quality parameters) in the request headers.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.String>
supportedEncodings
-
Constructor Summary
Constructors Modifier Constructor Description protected
ContentEncoder(java.lang.String... supportedEncodings)
Initializes this encoder implementation with the list of supported content encodings.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Object
aroundReadFrom(javax.ws.rs.ext.ReaderInterceptorContext context)
void
aroundWriteTo(javax.ws.rs.ext.WriterInterceptorContext context)
abstract java.io.InputStream
decode(java.lang.String contentEncoding, java.io.InputStream encodedStream)
Implementations of this method should take the encoded stream, wrap it and return a stream that can be used to read the decoded entity.abstract java.io.OutputStream
encode(java.lang.String contentEncoding, java.io.OutputStream entityStream)
Implementations of this method should take the entity stream, wrap it and return a stream that is encoded using the specified encoding.java.util.Set<java.lang.String>
getSupportedEncodings()
Returns values of Content-Encoding header supported by this encoder.
-
-
-
Method Detail
-
getSupportedEncodings
public final java.util.Set<java.lang.String> getSupportedEncodings()
Returns values of Content-Encoding header supported by this encoder.- Returns:
- Set of supported Content-Encoding values.
-
decode
public abstract java.io.InputStream decode(java.lang.String contentEncoding, java.io.InputStream encodedStream) throws java.io.IOException
Implementations of this method should take the encoded stream, wrap it and return a stream that can be used to read the decoded entity.- Parameters:
contentEncoding
- Encoding to be used to decode the stream - guaranteed to be one of the supported encoding values.encodedStream
- Encoded input stream.- Returns:
- Decoded entity stream.
- Throws:
java.io.IOException
- if an IO error arises.
-
encode
public abstract java.io.OutputStream encode(java.lang.String contentEncoding, java.io.OutputStream entityStream) throws java.io.IOException
Implementations of this method should take the entity stream, wrap it and return a stream that is encoded using the specified encoding.- Parameters:
contentEncoding
- Encoding to be used to encode the entity - guaranteed to be one of the supported encoding values.entityStream
- Entity stream to be encoded.- Returns:
- Encoded stream.
- Throws:
java.io.IOException
- if an IO error arises.
-
aroundReadFrom
public final java.lang.Object aroundReadFrom(javax.ws.rs.ext.ReaderInterceptorContext context) throws java.io.IOException, javax.ws.rs.WebApplicationException
- Specified by:
aroundReadFrom
in interfacejavax.ws.rs.ext.ReaderInterceptor
- Throws:
java.io.IOException
javax.ws.rs.WebApplicationException
-
aroundWriteTo
public final void aroundWriteTo(javax.ws.rs.ext.WriterInterceptorContext context) throws java.io.IOException, javax.ws.rs.WebApplicationException
- Specified by:
aroundWriteTo
in interfacejavax.ws.rs.ext.WriterInterceptor
- Throws:
java.io.IOException
javax.ws.rs.WebApplicationException
-
-