org.glassfish.grizzly.filterchain
Class DefaultDecoderTransformer

java.lang.Object
  extended by org.glassfish.grizzly.filterchain.DefaultDecoderTransformer
All Implemented Interfaces:
Transformer

public class DefaultDecoderTransformer
extends Object
implements Transformer

Author:
Alexey Stashok

Constructor Summary
protected DefaultDecoderTransformer(DefaultFilterChain filterChain)
           
protected DefaultDecoderTransformer(DefaultFilterChain filterChain, AttributeBuilder attributeBuilder)
           
 
Method Summary
 FilterChainContext getContext(AttributeStorage state)
           
 DefaultFilterChain getFilterChain()
           
 Object getInput(AttributeStorage state)
          Gets the input data, which Transformer will work with.
 TransformationResult getLastResult(AttributeStorage state)
          Gets the last returned Transformer result.
 Object getOutput(AttributeStorage state)
          Gets the output, which Transformer will use for transformed data.
 AttributeHolder getProperties(AttributeStorage state)
          Gets the property storage, using which it's possible to read or update Transformer properties.
 void hibernate(AttributeStorage state)
          Method could be called by framework to let Transformer know, that transformation will be postponed and probably continued in separate Thread, so all resources, which are associated with the current Thread should be detached and stored internally or in the external storage.
 void release(AttributeStorage state)
          The Transformer has done its work and can release all associated resource.
 void setContext(AttributeStorage state, FilterChainContext context)
           
 void setInput(AttributeStorage state, Object input)
          Sets the input data, which Transformer will work with.
 void setOutput(AttributeStorage state, Object outputTarget)
          Gets the output, which Transformer will use for transformed data.
 TransformationResult transform(AttributeStorage state)
          Transforms an input data to some custom representation.
 TransformationResult transform(AttributeStorage state, Object originalMessage, Object targetMessage)
          Transforms an input data to some custom representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDecoderTransformer

protected DefaultDecoderTransformer(DefaultFilterChain filterChain)

DefaultDecoderTransformer

protected DefaultDecoderTransformer(DefaultFilterChain filterChain,
                                    AttributeBuilder attributeBuilder)
Method Detail

getFilterChain

public DefaultFilterChain getFilterChain()

getContext

public FilterChainContext getContext(AttributeStorage state)

setContext

public void setContext(AttributeStorage state,
                       FilterChainContext context)

transform

public TransformationResult transform(AttributeStorage state)
                               throws TransformationException
Description copied from interface: Transformer
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).

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

transform

public TransformationResult transform(AttributeStorage state,
                                      Object originalMessage,
                                      Object targetMessage)
                               throws TransformationException
Description copied from interface: Transformer
Transforms an input data to some custom representation.

Specified by:
transform in interface Transformer
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the result TransformationResult
Throws:
TransformationException

getInput

public Object getInput(AttributeStorage state)
Description copied from interface: Transformer
Gets the input data, which Transformer will work with. Very often Transformers are used together with I/O operations. When Transformer is used with read operation, this method may return a Buffer, where "reader" will read the data to. But note, the returned Buffer should always represent READY data.In other words, if there is no data to be transformed - the Buffer should have 0 remaining bytes.

Specified by:
getInput in interface Transformer
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the Transformer input.

setInput

public void setInput(AttributeStorage state,
                     Object input)
Description copied from interface: Transformer
Sets the input data, which Transformer will work with. Very often Transformers are used together with I/O operations. When Transformer is used with read operation, the input Buffer will be used by "reader" to read the data to. But note, the input Buffer should always represent READY data.In other words, if there is no data to be transformed - the Buffer should have 0 remaining bytes.

Specified by:
setInput in interface Transformer
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
input - Input data

getOutput

public Object getOutput(AttributeStorage state)
Description copied from interface: Transformer
Gets the output, which Transformer will use for transformed data. Although output could be used to get a result of transformation, it is recommended to return transformation result directly from transform method within TransformationResult.

Specified by:
getOutput in interface Transformer
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the Transformer output.

setOutput

public void setOutput(AttributeStorage state,
                      Object outputTarget)
Description copied from interface: Transformer
Gets the output, which Transformer will use for transformed data. Although output could be used to get a result of transformation, it is recommended to return transformation result directly from transform method within TransformationResult.

Specified by:
setOutput in interface Transformer
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
outputTarget - Output

getLastResult

public TransformationResult getLastResult(AttributeStorage state)
Description copied from interface: Transformer
Gets the last returned Transformer result. Last result could be either retrieved from internal state, or external storage, which is passed as the parameter.

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

getProperties

public AttributeHolder getProperties(AttributeStorage state)
Description copied from interface: Transformer
Gets the property storage, using which it's possible to read or update Transformer properties.

Specified by:
getProperties in interface Transformer
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.
Returns:
the property storage.

hibernate

public void hibernate(AttributeStorage state)
Description copied from interface: Transformer
Method could be called by framework to let Transformer know, that transformation will be postponed and probably continued in separate Thread, so all resources, which are associated with the current Thread should be detached and stored internally or in the external storage.

Specified by:
hibernate in interface Transformer
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.

release

public void release(AttributeStorage state)
Description copied from interface: Transformer
The Transformer has done its work and can release all associated resource.

Specified by:
release in interface Transformer
Parameters:
state - the external state storage, where Transformer could retrieve or store its state.


Copyright © 2009 SUN Microsystems. All Rights Reserved.