Class BytesOnlyMarshaller
- java.lang.Object
-
- org.infinispan.client.hotrod.marshall.BytesOnlyMarshaller
-
- All Implemented Interfaces:
Marshaller
public class BytesOnlyMarshaller extends java.lang.Object implements Marshaller
Marshaller that only supports byte[] instances writing them as is- Since:
- 10.0
- Author:
- Tristan Tarrant, wburns
-
-
Field Summary
Fields Modifier and Type Field Description static BytesOnlyMarshaller
INSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 ofByteBuffer
, which allows direct access to the byte array with minimal array copyingbyte[]
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.commons.marshall.Marshaller
initialize, start, stop
-
-
-
-
Field Detail
-
INSTANCE
public static final BytesOnlyMarshaller INSTANCE
-
-
Method Detail
-
objectToByteBuffer
public byte[] objectToByteBuffer(java.lang.Object obj, int estimatedSize)
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 interfaceMarshaller
- 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
-
objectToByteBuffer
public byte[] objectToByteBuffer(java.lang.Object obj)
Description copied from interface:Marshaller
Marshalls an object to a byte array.- Specified by:
objectToByteBuffer
in interfaceMarshaller
- Parameters:
obj
- object to convert to a byte array. Must not be null.- Returns:
- a byte array
-
objectFromByteBuffer
public java.lang.Object objectFromByteBuffer(byte[] buf)
Description copied from interface:Marshaller
Unmarshalls an object from a byte array.- Specified by:
objectFromByteBuffer
in interfaceMarshaller
- Parameters:
buf
- byte array containing the binary representation of an object. Must not be null.- Returns:
- an object
-
objectFromByteBuffer
public java.lang.Object objectFromByteBuffer(byte[] buf, int offset, int length)
Description copied from interface:Marshaller
Unmarshalls an object from a specific portion of a byte array.- Specified by:
objectFromByteBuffer
in interfaceMarshaller
- Parameters:
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 consider- Returns:
- an object
-
objectToBuffer
public ByteBuffer objectToBuffer(java.lang.Object o)
Description copied from interface:Marshaller
A method that returns an instance ofByteBuffer
, which allows direct access to the byte array with minimal array copying- Specified by:
objectToBuffer
in interfaceMarshaller
- Parameters:
o
- object to marshall
-
isMarshallable
public boolean isMarshallable(java.lang.Object o)
Description copied from interface:Marshaller
A method that checks whether the given object is marshallable as per the rules of this marshaller.- Specified by:
isMarshallable
in interfaceMarshaller
- Parameters:
o
- object to verify whether it's marshallable or not- Returns:
- true if the object is marshallable, otherwise false
-
getBufferSizePredictor
public BufferSizePredictor getBufferSizePredictor(java.lang.Object o)
Description copied from interface:Marshaller
Returns a marshalled payload size predictor for a particular type. Accurate prediction of a type's serialized payload size helps avoid unnecessary copying and speeds up application performance.- Specified by:
getBufferSizePredictor
in interfaceMarshaller
- Parameters:
o
- Object for which serialized predictor will be returned- Returns:
- an instance of
BufferSizePredictor
-
mediaType
public MediaType mediaType()
- Specified by:
mediaType
in interfaceMarshaller
- Returns:
- the
MediaType
associated with the content produced by the marshaller
-
-