Top Description Inners Methods
javax.websocket

public Interface Decoder

Known Direct Subinterfaces
javax.websocket.Decoder.Binary, javax.websocket.Decoder.BinaryStream, javax.websocket.Decoder.Text, javax.websocket.Decoder.TextStream
Imports
java.io.IOException, .InputStream, .Reader, java.nio.ByteBuffer

The Decoder interface holds member interfaces that define how a developer can provide the web socket container a way web socket messages into developer defined custom objects. The websocket implementation creates a new instance of the decoder per endpoint instance per connection. The lifecycle of the Decoder instance is governed by the container calls to the Decoder#init(javax.websocket.EndpointConfig) and Decoder#destroy() methods.
Author
dannycoward

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Decoder.Binary<T>

This interface defines how a custom object (of type T) is decoded from a web socket message in the form of a byte buffer.

public static interface
Decoder.BinaryStream<T>

This interface defines how a custom object is decoded from a web socket message in the form of a binary stream.

public static interface
Decoder.Text<T>

This interface defines how a custom object is decoded from a web socket message in the form of a string.

public static interface
Decoder.TextStream<T>

This interface defines how a custom object of type T is decoded from a web socket message in the form of a character stream.

Method Summary

Modifier and TypeMethod and Description
public void
destroy()

This method is called when the decoder is about to be removed from service in order that any resources the encoder used may be closed gracefully.

public void
init(EndpointConfig
the endpoint configuration object when being brought into service
config
)

This method is called with the endpoint configuration object of the endpoint this decoder is intended for when it is about to be brought into service.

Method Detail

destroyback to summary
public void destroy()

This method is called when the decoder is about to be removed from service in order that any resources the encoder used may be closed gracefully.

initback to summary
public void init(EndpointConfig config)

This method is called with the endpoint configuration object of the endpoint this decoder is intended for when it is about to be brought into service.

Parameters
config:EndpointConfig

the endpoint configuration object when being brought into service

javax.websocket back to summary

public Interface Decoder.Binary<T>

extends Decoder

This interface defines how a custom object (of type T) is decoded from a web socket message in the form of a byte buffer.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the decoded object.
decode
(ByteBuffer
the bytes to be decoded.
bytes
)

Decode the given bytes into an object of type T.

public boolean

Returns:

whether or not the bytes can be decoded by this decoder.
willDecode
(ByteBuffer
the bytes to be decoded.
bytes
)

Answer whether the given bytes can be decoded into an object of type T.

Inherited from javax.websocket.Decoder:
destroyinit

Method Detail

decodeback to summary
public T decode(ByteBuffer bytes) throws DecodeException

Decode the given bytes into an object of type T.

Parameters
bytes:ByteBuffer

the bytes to be decoded.

Returns:T

the decoded object.

willDecodeback to summary
public boolean willDecode(ByteBuffer bytes)

Answer whether the given bytes can be decoded into an object of type T.

Parameters
bytes:ByteBuffer

the bytes to be decoded.

Returns:boolean

whether or not the bytes can be decoded by this decoder.

javax.websocket back to summary

public Interface Decoder.BinaryStream<T>

extends Decoder

This interface defines how a custom object is decoded from a web socket message in the form of a binary stream.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the decoded object.
decode
(InputStream
the input stream carrying the bytes.
is
)

Decode the given bytes read from the input stream into an object of type T.

Inherited from javax.websocket.Decoder:
destroyinit

Method Detail

decodeback to summary
public T decode(InputStream is) throws DecodeException, IOException

Decode the given bytes read from the input stream into an object of type T.

Parameters
is:InputStream

the input stream carrying the bytes.

Returns:T

the decoded object.

javax.websocket back to summary

public Interface Decoder.Text<T>

extends Decoder

This interface defines how a custom object is decoded from a web socket message in the form of a string.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the decoded message as an object of type T
decode
(String
string to be decoded.
s
)

Decode the given String into an object of type T.

public boolean

Returns:

whether this decoder can decoded the supplied string.
willDecode
(String
the string being tested for decodability.
s
)

Answer whether the given String can be decoded into an object of type T.

Inherited from javax.websocket.Decoder:
destroyinit

Method Detail

decodeback to summary
public T decode(String s) throws DecodeException

Decode the given String into an object of type T.

Parameters
s:String

string to be decoded.

Returns:T

the decoded message as an object of type T

willDecodeback to summary
public boolean willDecode(String s)

Answer whether the given String can be decoded into an object of type T.

Parameters
s:String

the string being tested for decodability.

Returns:boolean

whether this decoder can decoded the supplied string.

javax.websocket back to summary

public Interface Decoder.TextStream<T>

extends Decoder

This interface defines how a custom object of type T is decoded from a web socket message in the form of a character stream.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the instance of the object that is the decoded web socket message.
decode
(Reader
the reader from which to read the web socket message.
reader
)

Reads the websocket message from the implementation provided Reader and decodes it into an instance of the supplied object type.

Inherited from javax.websocket.Decoder:
destroyinit

Method Detail

decodeback to summary
public T decode(Reader reader) throws DecodeException, IOException

Reads the websocket message from the implementation provided Reader and decodes it into an instance of the supplied object type.

Parameters
reader:Reader

the reader from which to read the web socket message.

Returns:T

the instance of the object that is the decoded web socket message.