Top Description Methods
org.glassfish.grizzly

public Interface Transformer<K, L>

Known Direct Implementers
org.glassfish.grizzly.AbstractTransformer
Imports
org.glassfish.grizzly.attributes.AttributeStorage

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 actually 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

Modifier and TypeMethod and Description
public TransformationResult<K, L>

Returns:

the last returned Transformer result.
getLastResult
(AttributeStorage
the external state storage, where Transformer could retrieve or store its state.
storage
)

Gets the last returned Transformer result.

public String

Returns:

The Transformer name.
getName
()

Get the Transformer name.

public boolean
public void
release(AttributeStorage
the external state storage, where Transformer could retrieve or store its state.
storage
)

The Transformer has done its work and can release all associated resource.

public TransformationResult<K, L>

Returns:

the result TransformationResult
transform
(AttributeStorage
the external state storage, where Transformer could get/put a state.
storage
,
K
data to transform
input
)

Transforms an input data to some custom representation.

Method Detail

getLastResultback to summary
public 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:AttributeStorage

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

Returns:TransformationResult<K, L>

the last returned Transformer result.

getNameback to summary
public String getName()

Get the Transformer name. The name is used to store Transformer associated data.

Returns:String

The Transformer name.

hasInputRemainingback to summary
public boolean hasInputRemaining(AttributeStorage storage, K input)
releaseback to summary
public void release(AttributeStorage storage)

The Transformer has done its work and can release all associated resource.

Parameters
storage:AttributeStorage

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

transformback to summary
public 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:AttributeStorage

the external state storage, where Transformer could get/put a state.

input:K

data to transform

Returns:TransformationResult<K, L>

the result TransformationResult

Exceptions
TransformationException:
if failed to transport i.e. invalid types