Package io.permazen.spring
Class KVStoreHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<KVStore>
io.permazen.spring.KVStoreHttpMessageConverter
- All Implemented Interfaces:
HttpMessageConverter<KVStore>
Spring
HttpMessageConverter
capable of encoding and decoding a KVStore
. The KeyListEncoder
class is used
to compress common prefixes of consecutive keys.
See PermazenObjectHttpMessageConverter
for a higher level API.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MediaType
Default MIME type supported by this instance:application/x-permazen-kvstore
.Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger
-
Constructor Summary
ConstructorDescriptionConstructor.KVStoreHttpMessageConverter
(MediaType... mimeTypes) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected Long
getContentLength
(KVStore kvstore, MediaType mediaType) static Long
getKVStoreContentLength
(KVStore kvstore) Determine the content length of the given key/value store when encoded as payload.protected KVStore
readInternal
(Class<? extends KVStore> clazz, HttpInputMessage input) static void
readKVStore
(KVStore kvstore, HttpInputMessage input) Decode a key/value store HTTP payload.protected boolean
protected void
writeInternal
(KVStore kvstore, HttpOutputMessage output) static void
writeKVStore
(KVStore kvstore, HttpOutputMessage output) Encode a key/value store HTTP payload.Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canRead, canWrite, canWrite, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, supportsRepeatableWrites, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.http.converter.HttpMessageConverter
getSupportedMediaTypes
-
Field Details
-
DEFAULT_MIME_TYPE
Default MIME type supported by this instance:application/x-permazen-kvstore
.
-
-
Constructor Details
-
KVStoreHttpMessageConverter
public KVStoreHttpMessageConverter()Constructor.Configures this instance for the
DEFAULT_MIME_TYPE
. -
KVStoreHttpMessageConverter
Constructor.- Parameters:
mimeTypes
- supported MIME type(s)
-
-
Method Details
-
getContentLength
- Overrides:
getContentLength
in classAbstractHttpMessageConverter<KVStore>
-
supports
- Specified by:
supports
in classAbstractHttpMessageConverter<KVStore>
-
readInternal
protected KVStore readInternal(Class<? extends KVStore> clazz, HttpInputMessage input) throws IOException - Specified by:
readInternal
in classAbstractHttpMessageConverter<KVStore>
- Throws:
IOException
-
writeInternal
- Specified by:
writeInternal
in classAbstractHttpMessageConverter<KVStore>
- Throws:
IOException
-
getKVStoreContentLength
Determine the content length of the given key/value store when encoded as payload.- Parameters:
kvstore
- key/value store to encode- Returns:
- payload content length
- Throws:
IllegalArgumentException
- ifkvstore
is null
-
readKVStore
Decode a key/value store HTTP payload.- Parameters:
kvstore
- key/value store to populate from inputinput
- HTTP payload input- Throws:
HttpMessageNotReadableException
- ifinput
contains invalid contentIOException
- if an I/O error occursIllegalArgumentException
- if either parameter is null
-
writeKVStore
Encode a key/value store HTTP payload.- Parameters:
kvstore
- key/value store to encodeoutput
- HTTP payload output- Throws:
IOException
- if an I/O error occursIllegalArgumentException
- if either parameter is null
-