Class JacksonFragmentTranscoder

    • Constructor Detail

      • JacksonFragmentTranscoder

        public JacksonFragmentTranscoder​(com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper mapper)
    • Method Detail

      • byteArrayToGenericObject

        protected Object byteArrayToGenericObject​(byte[] byteArray,
                                                  int offset,
                                                  int length)
                                           throws IOException
        Description copied from class: AbstractByteArrayFragmentTranscoder
        Deserializes a byte array into a generic Object. The provided offset and length must be considered when processing the array, which may hold more data that just the value to deserialize. Note that he byte array should not be considered reliable for long-term usage (eg. backing a String) as it might be tied to the original ByteBuf, which will get released from the heap. If the array represents a non-scalar value, implementations may choose different classes like a JsonObject or a Map to instantiate it. This method is called by AbstractByteArrayFragmentTranscoder.decodeWithMessage(ByteBuf, Class, String) when the clazz parameter is Object.class.
        Specified by:
        byteArrayToGenericObject in class AbstractByteArrayFragmentTranscoder
        Parameters:
        byteArray - the array of bytes containing the value to deserialize (you'll need to copy it if long term usage is needed).
        offset - the offset in the array at which the value starts.
        length - the number of bytes after the offset that represents the value.
        Returns:
        an instance of a suitable generic Object representation of the value.
        Throws:
        IOException
      • byteArrayToClass

        protected <T> T byteArrayToClass​(byte[] byteArray,
                                         int offset,
                                         int length,
                                         Class<? extends T> clazz)
                                  throws IOException
        Description copied from class: AbstractByteArrayFragmentTranscoder
        Deserializes a byte array into a specific class instance. The provided offset and length must be considered when processing the array, which may hold more data that just the value to deserialize. Note that he byte array should not be considered reliable for long-term usage (eg. backing a String) as it might be tied to the original ByteBuf, which will get released from the heap. This method is called by AbstractByteArrayFragmentTranscoder.decodeWithMessage(ByteBuf, Class, String) when the clazz parameter isn't Object.class.
        Specified by:
        byteArrayToClass in class AbstractByteArrayFragmentTranscoder
        Parameters:
        byteArray - the array of bytes containing the value to deserialize (you'll need to copy it if long term usage is needed).
        offset - the offset in the array at which the value starts.
        length - the number of bytes after the offset that represents the value.
        clazz - the Class to deserialize to.
        Returns:
        an instance of a suitable generic Object representation of the value.
        Throws:
        IOException