com.flat502.rox.encoding
Interface Encoding

All Known Implementing Classes:
DeflaterEncoding, GZipEncoding

public interface Encoding

An interface representing an arbitrary HTTP encoding.

An implementation of this interface can be specified on the client API for request encoding, or on the server API for handling encoded requests.

An implementation essentially exposes the ability to wrap an OutputStream and an InputStream. These are expected to encode and decode data written and read on those streams respectively.

See Also:
GZipEncoding, DeflaterEncoding

Method Summary
 java.io.InputStream getDecoder(java.io.InputStream in)
          Implementations should return a stream ready for decoding.
 java.io.OutputStream getEncoder(java.io.OutputStream out)
          Implementations should return a stream ready for encoding.
 java.lang.String getName()
          Implementations should return the canonical name of this encoding.
 

Method Detail

getName

java.lang.String getName()
Implementations should return the canonical name of this encoding.

This name is sent as the value in the Content-Encoding and Accept-Encoding HTTP headers where required, and is used when locating an encoding handler on the server side.

Returns:
The canonical name of this encoding.
See Also:
HttpConstants.ContentEncoding

getDecoder

java.io.InputStream getDecoder(java.io.InputStream in)
                               throws java.io.IOException
Implementations should return a stream ready for decoding.

Parameters:
in - The stream from which encoded data may be read.
Returns:
A decoding stream.
Throws:
java.io.IOException

getEncoder

java.io.OutputStream getEncoder(java.io.OutputStream out)
                                throws java.io.IOException
Implementations should return a stream ready for encoding.

The returned stream will be closed before the encoded data is marshalled.

Parameters:
out - The stream to which encoded data should ultimately be written.
Returns:
An encoding stream.
Throws:
java.io.IOException