@Singleton @Internal public class TextStreamCodec extends Object implements MediaTypeCodec
MediaTypeCodec that will encode Event objects in order to support Server Sent Events.| Modifier and Type | Field and Description |
|---|---|
static String |
CONFIGURATION_QUALIFIER |
| Modifier | Constructor and Description |
|---|---|
|
TextStreamCodec(ApplicationConfiguration applicationConfiguration,
ByteBufferFactory byteBufferFactory,
Provider<MediaTypeCodecRegistry> codecRegistryProvider,
CodecConfiguration codecConfiguration) |
protected |
TextStreamCodec(Charset defaultCharset,
ByteBufferFactory byteBufferFactory,
Provider<MediaTypeCodecRegistry> codecRegistryProvider,
CodecConfiguration codecConfiguration) |
|
TextStreamCodec(HttpServerConfiguration serverConfiguration,
ByteBufferFactory byteBufferFactory,
Provider<MediaTypeCodecRegistry> codecRegistryProvider,
CodecConfiguration codecConfiguration)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
decode(Argument<T> type,
InputStream inputStream)
Decode the given type from the given
InputStream. |
<T> T |
decode(Class<T> type,
InputStream inputStream)
Decode the given type from the given
InputStream. |
<T> byte[] |
encode(T object)
Encode the given type returning the object as a byte[].
|
<T> ByteBuffer |
encode(T object,
ByteBufferFactory allocator)
Encode the given type returning the object as a
ByteBuffer. |
<T> void |
encode(T object,
OutputStream outputStream)
Encode the given type to the given
OutputStream. |
Collection<MediaType> |
getMediaTypes() |
protected void |
writeAttribute(ByteBuffer eventData,
byte[] attribute,
String value) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdecode, decode, decode, decode, decode, decode, supportsTypepublic static final String CONFIGURATION_QUALIFIER
@Deprecated public TextStreamCodec(HttpServerConfiguration serverConfiguration, ByteBufferFactory byteBufferFactory, Provider<MediaTypeCodecRegistry> codecRegistryProvider, @Named(value="text-stream") @Nullable CodecConfiguration codecConfiguration)
serverConfiguration - The HTTP server configurationbyteBufferFactory - A byte buffer factorycodecRegistryProvider - A media type codec registrycodecConfiguration - The configuration for the codec@Inject public TextStreamCodec(ApplicationConfiguration applicationConfiguration, ByteBufferFactory byteBufferFactory, Provider<MediaTypeCodecRegistry> codecRegistryProvider, @Named(value="text-stream") @Nullable CodecConfiguration codecConfiguration)
applicationConfiguration - The application configurationbyteBufferFactory - A byte buffer factorycodecRegistryProvider - A media type codec registrycodecConfiguration - The configuration for the codecprotected TextStreamCodec(Charset defaultCharset, ByteBufferFactory byteBufferFactory, Provider<MediaTypeCodecRegistry> codecRegistryProvider, @Named(value="text-stream") @Nullable CodecConfiguration codecConfiguration)
defaultCharset - The default charsetbyteBufferFactory - A byte buffer factorycodecRegistryProvider - A media type codec registrycodecConfiguration - The configuration for the codecpublic Collection<MediaType> getMediaTypes()
getMediaTypes in interface MediaTypeCodecpublic <T> T decode(Argument<T> type, InputStream inputStream) throws CodecException
MediaTypeCodecInputStream.decode in interface MediaTypeCodecT - The generic typetype - The typeinputStream - The input streamCodecException - When the result cannot be decodedpublic <T> T decode(Class<T> type, InputStream inputStream) throws CodecException
MediaTypeCodecInputStream.decode in interface MediaTypeCodecT - The generic typetype - The typeinputStream - The input streamCodecException - When the result cannot be decodedpublic <T> void encode(T object,
OutputStream outputStream)
throws CodecException
MediaTypeCodecOutputStream.encode in interface MediaTypeCodecT - The generic typeobject - The object to encodeoutputStream - The output streamCodecException - When the result cannot be encodedpublic <T> byte[] encode(T object)
throws CodecException
MediaTypeCodecencode in interface MediaTypeCodecT - The generic typeobject - The object to encodeCodecException - When the result cannot be encodedpublic <T> ByteBuffer encode(T object, ByteBufferFactory allocator) throws CodecException
MediaTypeCodecByteBuffer.encode in interface MediaTypeCodecT - The generic typeobject - The object to encodeallocator - The allocatorCodecException - When the result cannot be encodedprotected void writeAttribute(ByteBuffer eventData, byte[] attribute, String value)
eventData - The byte bufferattribute - The attributevalue - The value