Decode a key segment as an Object value. This method is invoked when {@link Key#decode(Object)} attempts to decode a key segment that waspreviously append by the {@link #appendKeySegment} method. Thus theimplementation of this method must precisely decode the same bytes that were generated by the companion appendKeySegment
method of this ValueCoder
.
This method will be called only if this KeyCoder
is registered with the current {@link CoderManager} to encode and decodeobjects of the class that is actually represented in the Key
. The class with which the key was encoded is provided as an argument. This permits one KeyCoder
to handle multiple classes because the implementation can dispatch to code appropriate for the particular supplied class. The implementation should construct and return an Object having the same class as the supplied class.
When this method is called the value {@link Key#getIndex()} will be theoffset within the key of the first encoded byte. The key segment is zero-byte terminated.
@param key The {@link Key} from which data should be decoded
@param clazz The expected
Class
of the returned object
@param context An arbitrary object that can optionally be supplied by the application to convey an application-specific context for the operation. (See {@link CoderContext}.) The default value is
null
.
@throws ConversionException