Class 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 Detail

      • UnpackerConfig

        public UnpackerConfig()
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.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 of MessageUnpacker.

        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 objects
        offset - The index of the first byte
        length - 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()
      • 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()