public abstract class AbstractMarshaller extends java.lang.Object implements Marshaller
Modifier and Type | Field and Description |
---|---|
protected MarshallableTypeHints |
marshallableTypeHints |
Constructor and Description |
---|
AbstractMarshaller() |
Modifier and Type | Method and Description |
---|---|
BufferSizePredictor |
getBufferSizePredictor(java.lang.Object o)
Returns a marshalled payload size predictor for a particular type.
|
java.lang.Object |
objectFromByteBuffer(byte[] buf)
Unmarshalls an object from a byte array.
|
java.lang.Object |
objectFromInputStream(java.io.InputStream inputStream)
This method implements
StreamingMarshaller.objectFromInputStream(java.io.InputStream) , but its
implementation has been moved here rather that keeping under a class that implements StreamingMarshaller
in order to avoid code duplication. |
ByteBuffer |
objectToBuffer(java.lang.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(java.lang.Object o,
int estimatedSize)
This is a convenience method for converting an object into a
org.infinispan.io.ByteBuffer which takes
an estimated size as parameter. |
byte[] |
objectToByteBuffer(java.lang.Object o)
Marshalls an object to a byte array.
|
byte[] |
objectToByteBuffer(java.lang.Object obj,
int estimatedSize)
Marshalls an object to a byte array.
|
private byte[] |
trimBuffer(ByteBuffer b) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isMarshallable, objectFromByteBuffer
protected final MarshallableTypeHints marshallableTypeHints
public BufferSizePredictor getBufferSizePredictor(java.lang.Object o)
Marshaller
getBufferSizePredictor
in interface Marshaller
o
- Object for which serialized predictor will be returnedBufferSizePredictor
protected abstract ByteBuffer objectToBuffer(java.lang.Object o, int estimatedSize) throws java.io.IOException, java.lang.InterruptedException
org.infinispan.io.ByteBuffer
which takes
an estimated size as parameter. A org.infinispan.io.ByteBuffer
allows direct access to the byte
array with minimal array copyingo
- object to marshallestimatedSize
- an estimate of how large the resulting byte array may bejava.io.IOException
java.lang.InterruptedException
public ByteBuffer objectToBuffer(java.lang.Object obj) throws java.io.IOException, java.lang.InterruptedException
Marshaller
ByteBuffer
, which allows direct access to the byte
array with minimal array copyingobjectToBuffer
in interface Marshaller
obj
- object to marshalljava.io.IOException
- if marshalling cannot complete due to some I/O errorjava.lang.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.public byte[] objectToByteBuffer(java.lang.Object o) throws java.io.IOException, java.lang.InterruptedException
Marshaller
objectToByteBuffer
in interface Marshaller
o
- object to convert to a byte array. Must not be null.java.io.IOException
- if marshalling cannot complete due to some I/O errorjava.lang.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.public byte[] objectToByteBuffer(java.lang.Object obj, int estimatedSize) throws java.io.IOException, java.lang.InterruptedException
Marshaller
objectToByteBuffer
in interface Marshaller
obj
- object to convert to a byte array. Must not be null.estimatedSize
- an estimate of how large the resulting byte array may bejava.io.IOException
- if marshalling cannot complete due to some I/O errorjava.lang.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.private byte[] trimBuffer(ByteBuffer b)
public java.lang.Object objectFromByteBuffer(byte[] buf) throws java.io.IOException, java.lang.ClassNotFoundException
Marshaller
objectFromByteBuffer
in interface Marshaller
buf
- byte array containing the binary representation of an object. Must not be null.java.io.IOException
- if unmarshalling cannot complete due to some I/O errorjava.lang.ClassNotFoundException
- if the class of the object trying to unmarshall is unknownpublic java.lang.Object objectFromInputStream(java.io.InputStream inputStream) throws java.io.IOException, java.lang.ClassNotFoundException
StreamingMarshaller.objectFromInputStream(java.io.InputStream)
, but its
implementation has been moved here rather that keeping under a class that implements StreamingMarshaller
in order to avoid code duplication.java.io.IOException
java.lang.ClassNotFoundException