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
- Author:
- Alexey Stashok
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AttributeBuilder
protected final Attribute<AbstractTransformer.LastResultAwareState<K,
L>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractTransformer.LastResultAwareState<K,
L> final TransformationResult<K,
L> getLastResult
(AttributeStorage storage) Gets the last returned Transformer result.protected String
static <T> T
getValue
(AttributeStorage storage, Attribute<T> attribute, T defaultValue) protected MemoryManager
obtainMemoryManager
(AttributeStorage storage) protected final AbstractTransformer.LastResultAwareState<K,
L> obtainStateObject
(AttributeStorage storage) void
release
(AttributeStorage storage) The Transformer has done its work and can release all associated resource.protected final TransformationResult<K,
L> saveLastResult
(AttributeStorage storage, TransformationResult<K, L> result) void
setMemoryManager
(MemoryManager memoryManager) final 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
Methods inherited from interface org.glassfish.grizzly.Transformer
getName, hasInputRemaining
-
Field Details
-
attributeBuilder
-
stateAttr
-
-
Constructor Details
-
AbstractTransformer
public AbstractTransformer()
-
-
Method Details
-
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 interfaceTransformer<K,
L> - Parameters:
storage
- the external state storage, where Transformer could get/put a state.input
- data to transform- Returns:
- the result
TransformationResult
- Throws:
TransformationException
- if failed to transport i.e. invalid types
-
transformImpl
protected abstract TransformationResult<K,L> transformImpl(AttributeStorage storage, K input) throws TransformationException - Throws:
TransformationException
-
getLastResult
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 interfaceTransformer<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
Description copied from interface:Transformer
The Transformer has done its work and can release all associated resource.- Specified by:
release
in interfaceTransformer<K,
L> - Parameters:
storage
- the external state storage, where Transformer could retrieve or store its state.
-
obtainMemoryManager
-
getMemoryManager
-
setMemoryManager
-
getValue
-
obtainStateObject
protected final AbstractTransformer.LastResultAwareState<K,L> obtainStateObject(AttributeStorage storage) -
createStateObject
-