Package 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 Object implements Transformer<K,L>
- Author:
- Alexey Stashok
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractTransformer.LastResultAwareState<K,L>
-
Field Summary
Fields Modifier and Type Field Description protected AttributeBuilderattributeBuilderprotected Attribute<AbstractTransformer.LastResultAwareState<K,L>>stateAttr
-
Constructor Summary
Constructors Constructor Description AbstractTransformer()
-
Method Summary
-
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 Detail
-
attributeBuilder
protected final AttributeBuilder attributeBuilder
-
stateAttr
protected final Attribute<AbstractTransformer.LastResultAwareState<K,L>> stateAttr
-
-
Method Detail
-
getNamePrefix
protected String getNamePrefix()
-
transform
public final TransformationResult<K,L> transform(AttributeStorage storage, K input) throws TransformationException
Description copied from interface:TransformerTransforms 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:
transformin 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
public final TransformationResult<K,L> getLastResult(AttributeStorage storage)
Description copied from interface:TransformerGets 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:
getLastResultin 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
public void release(AttributeStorage storage)
Description copied from interface:TransformerThe Transformer has done its work and can release all associated resource.- Specified by:
releasein interfaceTransformer<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()
-
-