org.glassfish.grizzly
Interface Transformer<K,L>

All Known Implementing Classes:
AbstractTransformer, ChunkingFilter.ChunkingDecoder, ChunkingFilter.ChunkingEncoder, ChunkingFilter.ChunkingTransformer, GZipDecoder, GZipEncoder, LZMADecoder, LZMAEncoder, SSLDecoderTransformer, SSLEncoderTransformer, StringDecoder, StringEncoder

public interface Transformer<K,L>

Transformer interface, which knows how to transform the original data to some custom representation. A Transformer implementation could be stateful or stateless. However it's very easy to write stateful Transformer, which actaully doesn't save any state internally, but uses AttributeStorage as an external state storage. Please note, that AttributeStorage is being passed as the parameter to all Transformer methods. This way it's possible to reuse single instance of a stateful Transformer to process lots of concurrent transformations.

Author:
Alexey Stashok

Method Summary
 TransformationResult<K,L> getLastResult(AttributeStorage storage)
          Gets the last returned Transformer result.
 String getName()
          Get the Transformer name.
 boolean hasInputRemaining(AttributeStorage storage, K input)
           
 void release(AttributeStorage storage)
          The Transformer has done its work and can release all associated resource.
 TransformationResult<K,L> transform(AttributeStorage storage, K input)
          Transforms an input data to some custom representation.
 

Method Detail

getName

String getName()
Get the Transformer name. The name is used to store Transformer associated data.

Returns:
The Transformer name.

transform

TransformationResult<K,L> transform(AttributeStorage storage,
                                    K input)
                                    throws TransformationException
Transforms an input data to some custom representation. Input and output are not passed implicitly, which means that Transformer is able to retrieve input and output from its internal state or from external storage (AttributeStorage).

Parameters:
storage - the external state storage, where Transformer could get/put a state.
Returns:
the result TransformationResult
Throws:
TransformationException

getLastResult

TransformationResult<K,L> getLastResult(AttributeStorage storage)
Gets the last returned Transformer result. Last result could be either retrieved from internal state, or external storage, which is passed as the parameter.

Parameters:
storage - the external state storage, where Transformer could retrieve or store its state.
Returns:
the last returned Transformer result.

release

void release(AttributeStorage storage)
The Transformer has done its work and can release all associated resource.

Parameters:
storage - the external state storage, where Transformer could retrieve or store its state.

hasInputRemaining

boolean hasInputRemaining(AttributeStorage storage,
                          K input)


Copyright © 2013 Oracle Corporation. All Rights Reserved.