Class MessagePack.UnpackerConfig
- java.lang.Object
-
- org.msgpack.core.MessagePack.UnpackerConfig
-
- All Implemented Interfaces:
java.lang.Cloneable
- Enclosing class:
- MessagePack
public static class MessagePack.UnpackerConfig extends java.lang.Object implements java.lang.Cloneable
MessageUnpacker configuration.
-
-
Constructor Summary
Constructors Constructor Description UnpackerConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessagePack.UnpackerConfig
clone()
boolean
equals(java.lang.Object obj)
java.nio.charset.CodingErrorAction
getActionOnMalformedString()
java.nio.charset.CodingErrorAction
getActionOnUnmappableString()
boolean
getAllowReadingBinaryAsString()
boolean
getAllowReadingStringAsBinary()
int
getBufferSize()
int
getStringDecoderBufferSize()
int
getStringSizeLimit()
int
hashCode()
MessageUnpacker
newUnpacker(byte[] contents)
Creates an unpacker that deserializes objects from a specified byte array.MessageUnpacker
newUnpacker(byte[] contents, int offset, int length)
Creates an unpacker that deserializes objects from subarray of a specified byte array.MessageUnpacker
newUnpacker(java.io.InputStream in)
Creates an unpacker that deserializes objects from a specified input stream.MessageUnpacker
newUnpacker(java.nio.ByteBuffer contents)
Creates an unpacker that deserializes objects from a specified ByteBuffer.MessageUnpacker
newUnpacker(java.nio.channels.ReadableByteChannel channel)
Creates an unpacker that deserializes objects from a specified readable channel.MessageUnpacker
newUnpacker(MessageBufferInput in)
Creates an unpacker that deserializes objects from a specified input.MessagePack.UnpackerConfig
withActionOnMalformedString(java.nio.charset.CodingErrorAction action)
Sets action when encountered a malformed input (default: REPLACE)MessagePack.UnpackerConfig
withActionOnUnmappableString(java.nio.charset.CodingErrorAction action)
Sets action when an unmappable character is found (default: REPLACE)MessagePack.UnpackerConfig
withAllowReadingBinaryAsString(boolean enable)
Allows unpackString and unpackRawStringHeader and unpackString to read bin format family (default: true)MessagePack.UnpackerConfig
withAllowReadingStringAsBinary(boolean enable)
Allows unpackBinaryHeader to read str format family (default: true)MessagePack.UnpackerConfig
withBufferSize(int bytes)
When a packer is created with newUnpacker(OutputStream) or newUnpacker(WritableByteChannel), the stream will be buffered with this size of buffer (default: 8192).MessagePack.UnpackerConfig
withStringDecoderBufferSize(int bytes)
MessagePack.UnpackerConfig
withStringSizeLimit(int bytes)
unpackString size limit (default: Integer.MAX_VALUE).
-
-
-
Method Detail
-
clone
public MessagePack.UnpackerConfig clone()
- Overrides:
clone
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
newUnpacker
public MessageUnpacker newUnpacker(MessageBufferInput in)
Creates an unpacker that deserializes objects from a specified input.MessageBufferInput
is an interface that lets applications customize memory allocation of internal buffer ofMessageUnpacker
.- Parameters:
in
- The input stream that provides sequence of buffer chunks and optionally reuses them when MessageUnpacker consumed one completely- Returns:
- A new MessageUnpacker instance
-
newUnpacker
public MessageUnpacker newUnpacker(java.io.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 buffering internally.
- Parameters:
in
- The input stream that provides sequence of bytes- Returns:
- A new MessageUnpacker instance
-
newUnpacker
public MessageUnpacker newUnpacker(java.nio.channels.ReadableByteChannel channel)
Creates an unpacker that deserializes objects from a specified readable channel.- Parameters:
channel
- The input channel that provides sequence of bytes- Returns:
- A new MessageUnpacker instance
-
newUnpacker
public MessageUnpacker newUnpacker(byte[] contents)
Creates an unpacker that deserializes objects from a specified byte array.This method provides an optimized implementation of
newDefaultUnpacker(new ByteArrayInputStream(contents))
.- Parameters:
contents
- The byte array that contains packed objects in MessagePack format- Returns:
- A new MessageUnpacker instance that will never throw IOException
-
newUnpacker
public MessageUnpacker newUnpacker(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))
.- Parameters:
contents
- The byte array that contains packed objectsoffset
- The index of the first bytelength
- The number of bytes- Returns:
- A new MessageUnpacker instance that will never throw IOException
-
newUnpacker
public MessageUnpacker newUnpacker(java.nio.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
MessageUnpacker.getTotalReadBytes()
to get actual amount of bytes used in ByteBuffer.- Parameters:
contents
- The byte buffer that contains packed objects- Returns:
- A new MessageUnpacker instance that will never throw IOException
-
withAllowReadingStringAsBinary
public MessagePack.UnpackerConfig withAllowReadingStringAsBinary(boolean enable)
Allows unpackBinaryHeader to read str format family (default: true)
-
getAllowReadingStringAsBinary
public boolean getAllowReadingStringAsBinary()
-
withAllowReadingBinaryAsString
public MessagePack.UnpackerConfig withAllowReadingBinaryAsString(boolean enable)
Allows unpackString and unpackRawStringHeader and unpackString to read bin format family (default: true)
-
getAllowReadingBinaryAsString
public boolean getAllowReadingBinaryAsString()
-
withActionOnMalformedString
public MessagePack.UnpackerConfig withActionOnMalformedString(java.nio.charset.CodingErrorAction action)
Sets action when encountered a malformed input (default: REPLACE)
-
getActionOnMalformedString
public java.nio.charset.CodingErrorAction getActionOnMalformedString()
-
withActionOnUnmappableString
public MessagePack.UnpackerConfig withActionOnUnmappableString(java.nio.charset.CodingErrorAction action)
Sets action when an unmappable character is found (default: REPLACE)
-
getActionOnUnmappableString
public java.nio.charset.CodingErrorAction getActionOnUnmappableString()
-
withStringSizeLimit
public MessagePack.UnpackerConfig withStringSizeLimit(int bytes)
unpackString size limit (default: Integer.MAX_VALUE).
-
getStringSizeLimit
public int getStringSizeLimit()
-
withStringDecoderBufferSize
public MessagePack.UnpackerConfig withStringDecoderBufferSize(int bytes)
-
getStringDecoderBufferSize
public int getStringDecoderBufferSize()
-
withBufferSize
public MessagePack.UnpackerConfig withBufferSize(int bytes)
When a packer is created with newUnpacker(OutputStream) or newUnpacker(WritableByteChannel), the stream will be buffered with this size of buffer (default: 8192).
-
getBufferSize
public int getBufferSize()
-
-