org.fusesource.hawtbuf.codec
Class AbstractBufferCodec<T extends Buffer>

java.lang.Object
  extended by org.fusesource.hawtbuf.codec.VariableCodec<T>
      extended by org.fusesource.hawtbuf.codec.AbstractBufferCodec<T>
All Implemented Interfaces:
Codec<T>
Direct Known Subclasses:
AsciiBufferCodec, BufferCodec, UTF8BufferCodec

public abstract class AbstractBufferCodec<T extends Buffer>
extends VariableCodec<T>

Implementation of a Codec for Buffer objects

Author:
Hiram Chirino

Constructor Summary
AbstractBufferCodec()
           
 
Method Summary
protected abstract  T createBuffer(byte[] data)
           
 T decode(DataInput dataIn)
          Read the payload of the object from the DataInput stream.
 T deepCopy(T source)
           
 void encode(T value, DataOutput dataOut)
          Write the payload of the object to the DataOutput stream.
 int estimatedSize(T object)
           
 boolean isDeepCopySupported()
           
 boolean isEstimatedSizeSupported()
           
 
Methods inherited from class org.fusesource.hawtbuf.codec.VariableCodec
getFixedSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBufferCodec

public AbstractBufferCodec()
Method Detail

encode

public void encode(T value,
                   DataOutput dataOut)
            throws IOException
Description copied from interface: Codec
Write the payload of the object to the DataOutput stream.

Throws:
IOException

decode

public T decode(DataInput dataIn)
                        throws IOException
Description copied from interface: Codec
Read the payload of the object from the DataInput stream.

Returns:
unmarshalled object
Throws:
IOException

createBuffer

protected abstract T createBuffer(byte[] data)

deepCopy

public T deepCopy(T source)
Specified by:
deepCopy in interface Codec<T extends Buffer>
Overrides:
deepCopy in class VariableCodec<T extends Buffer>
Returns:
a deep copy of the source object. If the source is immutable the same source should be returned.

isDeepCopySupported

public boolean isDeepCopySupported()
Specified by:
isDeepCopySupported in interface Codec<T extends Buffer>
Overrides:
isDeepCopySupported in class VariableCodec<T extends Buffer>
Returns:
true if the Codec.deepCopy(Object) operations is supported.

isEstimatedSizeSupported

public boolean isEstimatedSizeSupported()
Specified by:
isEstimatedSizeSupported in interface Codec<T extends Buffer>
Overrides:
isEstimatedSizeSupported in class VariableCodec<T extends Buffer>
Returns:
true if the Codec.estimatedSize(Object) operation is supported.

estimatedSize

public int estimatedSize(T object)
Specified by:
estimatedSize in interface Codec<T extends Buffer>
Overrides:
estimatedSize in class VariableCodec<T extends Buffer>
Returns:
the estimated marshaled size of the object.


Copyright © 2010-2014 FuseSource, Corp.. All Rights Reserved.