-
public class MessagePackConvenience class to build packer and unpacker classes.
You can select an appropriate factory method as following.
Deserializing objects from binary:
Serializing objects into binary:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classMessagePack.CodeThe prefix code set of MessagePack format. See also https://github.com/msgpack/msgpack/blob/master/spec.md for details.
public classMessagePack.PackerConfigMessagePacker configuration.
public classMessagePack.UnpackerConfigMessageUnpacker configuration.
-
Field Summary
Fields Modifier and Type Field Description public final static CharsetUTF8public final static MessagePack.PackerConfigDEFAULT_PACKER_CONFIGpublic final static MessagePack.UnpackerConfigDEFAULT_UNPACKER_CONFIG
-
Method Summary
Modifier and Type Method Description static MessagePackernewDefaultPacker(MessageBufferOutput out)Creates a packer that serializes objects into the specified output. static MessagePackernewDefaultPacker(OutputStream out)Creates a packer that serializes objects into the specified output stream. static MessagePackernewDefaultPacker(WritableByteChannel channel)Creates a packer that serializes objects into the specified writable channel. static MessageBufferPackernewDefaultBufferPacker()Creates a packer that serializes objects into byte arrays. static MessageUnpackernewDefaultUnpacker(MessageBufferInput in)Creates an unpacker that deserializes objects from a specified input. static MessageUnpackernewDefaultUnpacker(InputStream in)Creates an unpacker that deserializes objects from a specified input stream. static MessageUnpackernewDefaultUnpacker(ReadableByteChannel channel)Creates an unpacker that deserializes objects from a specified readable channel. static MessageUnpackernewDefaultUnpacker(Array<byte> contents)Creates an unpacker that deserializes objects from a specified byte array. static MessageUnpackernewDefaultUnpacker(Array<byte> contents, int offset, int length)Creates an unpacker that deserializes objects from subarray of a specified byte array. static MessageUnpackernewDefaultUnpacker(ByteBuffer contents)Creates an unpacker that deserializes objects from a specified ByteBuffer. -
-
Method Detail
-
newDefaultPacker
static MessagePacker newDefaultPacker(MessageBufferOutput out)
Creates a packer that serializes objects into the specified output.
com.batch.android.msgpack.core.buffer.MessageBufferOutput is an interface that lets applications customize memoryallocation of internal buffer of MessagePacker. You may prefer newDefaultBufferPacker, newDefaultPacker, or newDefaultPacker methods instead.
This method is equivalent to
DEFAULT_PACKER_CONFIG.newPacker(out).- Parameters:
out- A MessageBufferOutput that allocates buffer chunks and receives the buffer chunks with packed data filled in them
-
newDefaultPacker
static MessagePacker newDefaultPacker(OutputStream out)
Creates a packer that serializes objects into the specified output stream.
Note that you don't have to wrap OutputStream in BufferedOutputStream because MessagePacker has bufferinginternally.
This method is equivalent to
DEFAULT_PACKER_CONFIG.newPacker(out).- Parameters:
out- The output stream that receives sequence of bytes
-
newDefaultPacker
static MessagePacker newDefaultPacker(WritableByteChannel channel)
Creates a packer that serializes objects into the specified writable channel.
This method is equivalent to
DEFAULT_PACKER_CONFIG.newPacker(channel).- Parameters:
channel- The output channel that receives sequence of bytes
-
newDefaultBufferPacker
static MessageBufferPacker newDefaultBufferPacker()
Creates a packer that serializes objects into byte arrays.
This method provides an optimized implementation of
newDefaultBufferPacker(new ByteArrayOutputStream()).This method is equivalent to
DEFAULT_PACKER_CONFIG.newBufferPacker().
-
newDefaultUnpacker
static MessageUnpacker newDefaultUnpacker(MessageBufferInput in)
Creates an unpacker that deserializes objects from a specified input.
com.batch.android.msgpack.core.buffer.MessageBufferInput is an interface that lets applications customize memoryallocation of internal buffer of MessageUnpacker. You may prefer newDefaultUnpacker, newDefaultUnpacker, newDefaultUnpacker, or newDefaultUnpacker methods instead.
This method is equivalent to
DEFAULT_UNPACKER_CONFIG.newDefaultUnpacker(in).- Parameters:
in- The input stream that provides sequence of buffer chunks and optionally reuses them when MessageUnpacker consumed one completely
-
newDefaultUnpacker
static MessageUnpacker newDefaultUnpacker(InputStream in)
Creates an unpacker that deserializes objects from a specified input stream.
Note that you don't have to wrap InputStream in BufferedInputStream because MessageUnpacker has bufferinginternally.
This method is equivalent to
DEFAULT_UNPACKER_CONFIG.newDefaultUnpacker(in).- Parameters:
in- The input stream that provides sequence of bytes
-
newDefaultUnpacker
static MessageUnpacker newDefaultUnpacker(ReadableByteChannel channel)
Creates an unpacker that deserializes objects from a specified readable channel.
This method is equivalent to
DEFAULT_UNPACKER_CONFIG.newDefaultUnpacker(in).- Parameters:
channel- The input channel that provides sequence of bytes
-
newDefaultUnpacker
static MessageUnpacker newDefaultUnpacker(Array<byte> contents)
Creates an unpacker that deserializes objects from a specified byte array.
This method provides an optimized implementation of
newDefaultUnpacker(new ByteArrayInputStream(contents)).This method is equivalent to
DEFAULT_UNPACKER_CONFIG.newDefaultUnpacker(contents).- Parameters:
contents- The byte array that contains packed objects in MessagePack format
-
newDefaultUnpacker
static MessageUnpacker newDefaultUnpacker(Array<byte> contents, int offset, int length)
Creates an unpacker that deserializes objects from subarray of a specified byte array.
This method provides an optimized implementation of
newDefaultUnpacker(new ByteArrayInputStream(contents, offset, length)).This method is equivalent to
DEFAULT_UNPACKER_CONFIG.newDefaultUnpacker(contents).- Parameters:
contents- The byte array that contains packed objectsoffset- The index of the first bytelength- The number of bytes
-
newDefaultUnpacker
static MessageUnpacker newDefaultUnpacker(ByteBuffer contents)
Creates an unpacker that deserializes objects from a specified ByteBuffer.
Note that the returned unpacker reads data from the current position of the ByteBuffer until its limit.However, its position does not change when unpacker reads data. You may use getTotalReadBytes to get actual amount of bytes used in ByteBuffer.
This method supports both non-direct buffer and direct buffer.
- Parameters:
contents- The byte buffer that contains packed objects
-
-
-
-