org.atmosphere.wasync
Interface Decoder<U,T>

Type Parameters:
U -
T -
All Known Subinterfaces:
ReplayDecoder
All Known Implementing Classes:
TrackMessageSizeDecoder

public interface Decoder<U,T>

A decoder can be used to 'decode' the response's body. Decoder's can be used to decode the response body and match them with Function's implementation. This library will try to match the decoded Object to its associated Function. For example, the Decoder's type will be mapped, by the FunctionResolver to the Function of the same type if no function message has been defined:


   Decoder<String, POJO> d = new Decoder<String, POJO>() {
             @Override
             public POJO decode(Event e, String s) {
                 return new POJO(s);
             }
         }
 
Important: Decoder cannot be chained, e.g the result of a Decoder will never be passed to another Decoder, like Encoder

Author:
Jeanfrancois Arcand

Nested Class Summary
static class Decoder.Decoded<T>
          A Decoder may return an instance of a Decoded object to prevent some messages from being delivered to a Function, by returning a Decoder.Decoded.ABORT instance.
 
Method Summary
 T decode(Event e, U s)
          Decode the specified object of type U into object of type T.
 

Method Detail

decode

T decode(Event e,
         U s)
Decode the specified object of type U into object of type T.

Parameters:
e - an Event type. This can be used to differentiate event received.
s - a object of type U
Returns:
a new object of type T


Copyright © 2014. All Rights Reserved.