org.glassfish.grizzly.util
Class StringDecoder

java.lang.Object
  extended by org.glassfish.grizzly.AbstractTransformer<Buffer,String>
      extended by org.glassfish.grizzly.util.StringDecoder
All Implemented Interfaces:
Transformer<Buffer,String>
Direct Known Subclasses:
SmartStringDecoder

public class StringDecoder
extends AbstractTransformer<Buffer,String>

String decoder, which decodes Buffer to String

Author:
Alexey Stashok

Field Summary
protected  Charset charset
           
protected  Attribute<Integer> stateAttribute
           
protected  byte[] stringTerminateBytes
           
 
Fields inherited from class org.glassfish.grizzly.AbstractTransformer
attributeBuilder, incompletedResult, inputBufferAttribute, lastResultAttribute, outputBufferAttribute
 
Constructor Summary
StringDecoder()
           
StringDecoder(Charset charset)
           
StringDecoder(Charset charset, String stringTerminator)
           
StringDecoder(String stringTerminator)
           
 
Method Summary
 Charset getCharset()
           
protected  TransformationResult<String> parseWithLengthPrefix(AttributeStorage storage, Buffer input)
           
protected  TransformationResult<String> parseWithTerminatingSeq(AttributeStorage storage, Buffer input)
           
 void release(AttributeStorage storage)
          The Transformer has done its work and can release all associated resource.
protected  void saveState(AttributeStorage storage, TransformationResult<String> result, Integer state)
           
 void setCharset(Charset charset)
           
 TransformationResult<String> transform(AttributeStorage storage, Buffer input, String output)
          Transforms an input data to some custom representation.
 
Methods inherited from class org.glassfish.grizzly.AbstractTransformer
getInput, getLastResult, getMemoryManager, getOutput, getProperties, getValue, getValue, hibernate, obtainMemoryManager, removeValue, setInput, setMemoryManager, setOutput, setValue, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

charset

protected Charset charset

stateAttribute

protected Attribute<Integer> stateAttribute

stringTerminateBytes

protected byte[] stringTerminateBytes
Constructor Detail

StringDecoder

public StringDecoder()

StringDecoder

public StringDecoder(String stringTerminator)

StringDecoder

public StringDecoder(Charset charset)

StringDecoder

public StringDecoder(Charset charset,
                     String stringTerminator)
Method Detail

transform

public TransformationResult<String> transform(AttributeStorage storage,
                                              Buffer input,
                                              String 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

parseWithLengthPrefix

protected TransformationResult<String> parseWithLengthPrefix(AttributeStorage storage,
                                                             Buffer input)

parseWithTerminatingSeq

protected TransformationResult<String> parseWithTerminatingSeq(AttributeStorage storage,
                                                               Buffer input)

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

getCharset

public Charset getCharset()

setCharset

public void setCharset(Charset charset)

saveState

protected void saveState(AttributeStorage storage,
                         TransformationResult<String> result,
                         Integer state)


Copyright © 2009 SUN Microsystems. All Rights Reserved.