org.infinispan.marshall
Class AbstractMarshaller

java.lang.Object
  extended by org.infinispan.marshall.AbstractMarshaller
All Implemented Interfaces:
Marshaller
Direct Known Subclasses:
AbstractStreamingMarshaller, GenericJBossMarshaller

public abstract class AbstractMarshaller
extends Object
implements Marshaller

Abstract Marshaller implementation containing shared implementations.

Since:
4.1
Author:
Galder ZamarreƱo

Field Summary
protected static int DEFAULT_BUF_SIZE
           
 
Constructor Summary
AbstractMarshaller()
           
 
Method Summary
 Object objectFromByteBuffer(byte[] buf)
          Unmarshalls an object from a byte array.
 ByteBuffer objectToBuffer(Object obj)
          A method that returns an instance of ByteBuffer, which allows direct access to the byte array with minimal array copying
protected abstract  ByteBuffer objectToBuffer(Object o, int estimatedSize)
          This is a convenience method for converting an object into a ByteBuffer which takes an estimated size as parameter.
 byte[] objectToByteBuffer(Object o)
          Marshalls an object to a byte array.
 byte[] objectToByteBuffer(Object obj, int estimatedSize)
          Marshalls an object to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.infinispan.marshall.Marshaller
isMarshallable, objectFromByteBuffer
 

Field Detail

DEFAULT_BUF_SIZE

protected static final int DEFAULT_BUF_SIZE
See Also:
Constant Field Values
Constructor Detail

AbstractMarshaller

public AbstractMarshaller()
Method Detail

objectToBuffer

protected abstract ByteBuffer objectToBuffer(Object o,
                                             int estimatedSize)
                                      throws IOException,
                                             InterruptedException
This is a convenience method for converting an object into a ByteBuffer which takes an estimated size as parameter. A ByteBuffer allows direct access to the byte array with minimal array copying

Parameters:
o - object to marshall
estimatedSize - an estimate of how large the resulting byte array may be
Returns:
a ByteBuffer
Throws:
Exception
IOException
InterruptedException

objectToBuffer

public ByteBuffer objectToBuffer(Object obj)
                          throws IOException,
                                 InterruptedException
Description copied from interface: Marshaller
A method that returns an instance of ByteBuffer, which allows direct access to the byte array with minimal array copying

Specified by:
objectToBuffer in interface Marshaller
Parameters:
obj - object to marshall
Returns:
a ByteBuffer
Throws:
IOException - if marshalling cannot complete due to some I/O error
InterruptedException - if the marshalling process was interrupted. Clients should take this as a sign that the marshaller is no longer available, maybe due to shutdown, and so no more marshalling should be attempted.

objectToByteBuffer

public byte[] objectToByteBuffer(Object o)
                          throws IOException,
                                 InterruptedException
Description copied from interface: Marshaller
Marshalls an object to a byte array.

Specified by:
objectToByteBuffer in interface Marshaller
Parameters:
o - object to convert to a byte array. Must not be null.
Returns:
a byte array
Throws:
IOException - if marshalling cannot complete due to some I/O error
InterruptedException - if the marshalling process was interrupted. Clients should take this as a sign that the marshaller is no longer available, maybe due to shutdown, and so no more marshalling should be attempted.

objectToByteBuffer

public byte[] objectToByteBuffer(Object obj,
                                 int estimatedSize)
                          throws IOException,
                                 InterruptedException
Description copied from interface: Marshaller
Marshalls an object to a byte array. The estimatedSize parameter is a hint that can be passed in to allow for efficient sizing of the byte array before attempting to marshall the object. The more accurate this estimate is, the less likely byte[]s will need to be resized to hold the byte stream generated by marshalling the object.

Specified by:
objectToByteBuffer in interface Marshaller
Parameters:
obj - object to convert to a byte array. Must not be null.
estimatedSize - an estimate of how large the resulting byte array may be
Returns:
a byte array with the marshalled form of the object
Throws:
IOException - if marshalling cannot complete due to some I/O error
InterruptedException - if the marshalling was interrupted. Clients should take this as a sign that the marshaller is no longer available, maybe due to shutdown, and so no more unmarshalling should be attempted.

objectFromByteBuffer

public Object objectFromByteBuffer(byte[] buf)
                            throws IOException,
                                   ClassNotFoundException
Description copied from interface: Marshaller
Unmarshalls an object from a byte array.

Specified by:
objectFromByteBuffer in interface Marshaller
Parameters:
buf - byte array containing the binary representation of an object. Must not be null.
Returns:
an object
Throws:
IOException - if unmarshalling cannot complete due to some I/O error
ClassNotFoundException - if the class of the object trying to unmarshall is unknown


Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.