org.glassfish.grizzly
Class AbstractTransformer<K,L>
java.lang.Object
org.glassfish.grizzly.AbstractTransformer<K,L>
- All Implemented Interfaces:
- Transformer<K,L>
- Direct Known Subclasses:
- ChunkingFilter.ChunkingTransformer, GZipDecoder, GZipEncoder, LZMADecoder, LZMAEncoder, SSLDecoderTransformer, SSLEncoderTransformer, StringDecoder, StringEncoder
public abstract class AbstractTransformer<K,L>
- extends java.lang.Object
- implements Transformer<K,L>
- Author:
- Alexey Stashok
|
Method Summary |
protected AbstractTransformer.LastResultAwareState<K,L> |
createStateObject()
|
TransformationResult<K,L> |
getLastResult(AttributeStorage storage)
Gets the last returned Transformer result. |
MemoryManager |
getMemoryManager()
|
protected java.lang.String |
getNamePrefix()
|
static
|
getValue(AttributeStorage storage,
Attribute<T> attribute,
T defaultValue)
|
protected MemoryManager |
obtainMemoryManager(AttributeStorage storage)
|
protected AbstractTransformer.LastResultAwareState<K,L> |
obtainStateObject(AttributeStorage storage)
|
void |
release(AttributeStorage storage)
The Transformer has done its work and can release all
associated resource. |
protected TransformationResult<K,L> |
saveLastResult(AttributeStorage storage,
TransformationResult<K,L> result)
|
void |
setMemoryManager(MemoryManager memoryManager)
|
TransformationResult<K,L> |
transform(AttributeStorage storage,
K input)
Transforms an input data to some custom representation. |
protected abstract TransformationResult<K,L> |
transformImpl(AttributeStorage storage,
K input)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
attributeBuilder
protected final AttributeBuilder attributeBuilder
stateAttr
protected final Attribute<AbstractTransformer.LastResultAwareState<K,L>> stateAttr
AbstractTransformer
public AbstractTransformer()
getNamePrefix
protected java.lang.String getNamePrefix()
transform
public final TransformationResult<K,L> transform(AttributeStorage storage,
K input)
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<K,L>
- Parameters:
storage - the external state storage, where Transformer could
get/put a state.
- Returns:
- the result
TransformationResult
- Throws:
TransformationException
transformImpl
protected abstract TransformationResult<K,L> transformImpl(AttributeStorage storage,
K input)
throws TransformationException
- Throws:
TransformationException
getLastResult
public final TransformationResult<K,L> getLastResult(AttributeStorage storage)
- 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<K,L>
- Parameters:
storage - the external state storage, where Transformer
could retrieve or store its state.
- Returns:
- the last returned Transformer result.
saveLastResult
protected final TransformationResult<K,L> saveLastResult(AttributeStorage storage,
TransformationResult<K,L> result)
release
public void release(AttributeStorage storage)
- Description copied from interface:
Transformer
- The Transformer has done its work and can release all
associated resource.
- Specified by:
release in interface Transformer<K,L>
- Parameters:
storage - the external state storage, where Transformer
could retrieve or store its state.
obtainMemoryManager
protected MemoryManager obtainMemoryManager(AttributeStorage storage)
getMemoryManager
public MemoryManager getMemoryManager()
setMemoryManager
public void setMemoryManager(MemoryManager memoryManager)
getValue
public static <T> T getValue(AttributeStorage storage,
Attribute<T> attribute,
T defaultValue)
obtainStateObject
protected final AbstractTransformer.LastResultAwareState<K,L> obtainStateObject(AttributeStorage storage)
createStateObject
protected AbstractTransformer.LastResultAwareState<K,L> createStateObject()
Copyright © 2012 Oracle Corporation. All Rights Reserved.