com.sun.grizzly.smart.transformers
Class SequenceDecoder<E>

java.lang.Object
  extended by com.sun.grizzly.AbstractTransformer<Buffer,E>
      extended by com.sun.grizzly.smart.transformers.AbstractSmartMemberDecoder<E>
          extended by com.sun.grizzly.smart.transformers.SequenceDecoder<E>
All Implemented Interfaces:
SmartMemberTransformer<Buffer,E>, Transformer<Buffer,E>
Direct Known Subclasses:
ArrayDecoder

public abstract class SequenceDecoder<E>
extends AbstractSmartMemberDecoder<E>

Author:
oleksiys

Field Summary
protected  Transformer componentDecoder
           
protected  Class componentType
           
protected  Sequence config
           
protected  Attribute<E> sequenceAttribute
           
 
Fields inherited from class com.sun.grizzly.smart.transformers.AbstractSmartMemberDecoder
messageProcessingTreeAttribute
 
Fields inherited from class com.sun.grizzly.AbstractTransformer
attributeBuilder, incompletedResult, inputBufferAttribute, lastResultAttribute, outputBufferAttribute
 
Constructor Summary
SequenceDecoder()
           
 
Method Summary
protected  int checkSize(AttributeStorage storage)
           
protected abstract  E createSequence(AttributeStorage storage, int size)
          Creates a sequence object with certain size.
protected  int getAnnotatedLimit(AttributeStorage storage)
           
protected  int getAnnotatedSize(AttributeStorage storage)
           
 Transformer getComponentDecoder()
           
 Class getComponentType()
           
 Sequence getConfig()
           
protected  E getSequence(AttributeStorage storage)
          Returns the processing sequence object
 void initialize(SmartTransformer parentTransformer, Field field)
           
protected abstract  boolean next(AttributeStorage storage, E sequence)
          Moves to next sequence element and makes it current.
 void release(AttributeStorage storage)
          The Transformer has done its work and can release all associated resource.
protected  void saveState(AttributeStorage storage, E sequence, TransformationResult<E> lastResult)
          Save the transformer state.
protected abstract  void set(AttributeStorage storage, E sequence, Object component)
          Stores an element into the sequence.
 void setComponentDecoder(Transformer elementDecoder)
           
 void setComponentType(Class componentClass)
           
 void setConfig(Sequence config)
           
protected abstract  int size(AttributeStorage storage, E sequence)
          Returns the size of the sequence.
 TransformationResult<E> transform(AttributeStorage storage, Buffer input, E output)
          Transforms an input data to some custom representation.
 
Methods inherited from class com.sun.grizzly.smart.transformers.AbstractSmartMemberDecoder
getCurrentMessageProcessingObject, getMessageProcessingTree
 
Methods inherited from class com.sun.grizzly.AbstractTransformer
getInput, getLastResult, getMemoryManager, getOutput, getProperties, getValue, hibernate, obtainMemoryManager, setInput, setMemoryManager, setOutput, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.grizzly.Transformer
getInput, getLastResult, getOutput, getProperties, hibernate, setInput, setOutput, transform
 

Field Detail

config

protected Sequence config

componentType

protected Class componentType

componentDecoder

protected Transformer componentDecoder

sequenceAttribute

protected Attribute<E> sequenceAttribute
Constructor Detail

SequenceDecoder

public SequenceDecoder()
Method Detail

createSequence

protected abstract E createSequence(AttributeStorage storage,
                                    int size)
Creates a sequence object with certain size.

Parameters:
storage - attribute storage
size - the sequence size

set

protected abstract void set(AttributeStorage storage,
                            E sequence,
                            Object component)
Stores an element into the sequence.

Parameters:
storage - attribute storage.
sequence - sequence object.
component - sequence element.

next

protected abstract boolean next(AttributeStorage storage,
                                E sequence)
Moves to next sequence element and makes it current. Returns true, if there is next elements in sequence, or false otherwise.

Parameters:
storage - attribute storage.
sequence - sequence object.
Returns:
true, if there is next elements in sequence, or false otherwise.

size

protected abstract int size(AttributeStorage storage,
                            E sequence)
Returns the size of the sequence.

Parameters:
storage - attribute storage.
sequence - sequence object.
Returns:
the size of the sequence.

initialize

public void initialize(SmartTransformer parentTransformer,
                       Field field)
Specified by:
initialize in interface SmartMemberTransformer<Buffer,E>
Overrides:
initialize in class AbstractSmartMemberDecoder<E>

transform

public TransformationResult<E> transform(AttributeStorage storage,
                                         Buffer input,
                                         E output)
                                  throws TransformationException
Description copied from interface: Transformer
Transforms an input data to some custom representation.

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

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<Buffer,E>
Overrides:
release in class AbstractTransformer<Buffer,E>
Parameters:
storage - the external state storage, where Transformer could retrieve or store its state.

getComponentType

public Class getComponentType()

setComponentType

public void setComponentType(Class componentClass)

getComponentDecoder

public Transformer getComponentDecoder()

setComponentDecoder

public void setComponentDecoder(Transformer elementDecoder)

getConfig

public Sequence getConfig()

setConfig

public void setConfig(Sequence config)

saveState

protected void saveState(AttributeStorage storage,
                         E sequence,
                         TransformationResult<E> lastResult)
Save the transformer state.

Parameters:
storage - attribute storage

getSequence

protected E getSequence(AttributeStorage storage)
Returns the processing sequence object

Parameters:
storage - attribute storage
Returns:
the processing sequence object

checkSize

protected int checkSize(AttributeStorage storage)

getAnnotatedSize

protected int getAnnotatedSize(AttributeStorage storage)

getAnnotatedLimit

protected int getAnnotatedLimit(AttributeStorage storage)


Copyright © 2009 SUN Microsystems. All Rights Reserved.