@ThreadSafe
public interface Marshaller
ReplicableCommands, their parameters and their
response values, as well as any other arbitraty Object <--> byte[] conversions, such as those used in client/server
communications.
A single instance of any implementation is shared by multiple threads, so implementations need to be threadsafe,
and preferably immutable.| Modifier and Type | Method and Description |
|---|---|
BufferSizePredictor |
getBufferSizePredictor(java.lang.Object o)
Returns a marshalled payload size predictor for a particular type.
|
boolean |
isMarshallable(java.lang.Object o)
A method that checks whether the given object is marshallable as per the rules of this marshaller.
|
MediaType |
mediaType() |
java.lang.Object |
objectFromByteBuffer(byte[] buf)
Unmarshalls an object from a byte array.
|
java.lang.Object |
objectFromByteBuffer(byte[] buf,
int offset,
int length)
Unmarshalls an object from a specific portion of a byte array.
|
ByteBuffer |
objectToBuffer(java.lang.Object o)
A method that returns an instance of
ByteBuffer, which allows direct access to the byte
array with minimal array copying |
byte[] |
objectToByteBuffer(java.lang.Object obj)
Marshalls an object to a byte array.
|
byte[] |
objectToByteBuffer(java.lang.Object obj,
int estimatedSize)
Marshalls an object to a byte array.
|
byte[] objectToByteBuffer(java.lang.Object obj,
int estimatedSize)
throws java.io.IOException,
java.lang.InterruptedException
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.byte[] objectToByteBuffer(java.lang.Object obj)
throws java.io.IOException,
java.lang.InterruptedException
obj - 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.java.lang.Object objectFromByteBuffer(byte[] buf)
throws java.io.IOException,
java.lang.ClassNotFoundException
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 unknownjava.lang.Object objectFromByteBuffer(byte[] buf,
int offset,
int length)
throws java.io.IOException,
java.lang.ClassNotFoundException
buf - byte array containing the binary representation of an object. Must not be null.offset - point in buffer to start readinglength - number of bytes to considerjava.io.IOException - if unmarshalling cannot complete due to some I/O errorjava.lang.ClassNotFoundException - if the class of the object trying to unmarshall is unknownByteBuffer objectToBuffer(java.lang.Object o) throws java.io.IOException, java.lang.InterruptedException
ByteBuffer, which allows direct access to the byte
array with minimal array copyingo - 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.boolean isMarshallable(java.lang.Object o)
throws java.lang.Exception
o - object to verify whether it's marshallable or notjava.lang.Exception - if while checking whether the object was serializable or not, an exception aroseBufferSizePredictor getBufferSizePredictor(java.lang.Object o)
o - Object for which serialized predictor will be returnedBufferSizePredictorjava.lang.NullPointerException - if o is null