Module dev.metaschema.databind
Package dev.metaschema.databind.io.json
Class DefaultJsonDeserializer<CLASS extends dev.metaschema.core.model.IBoundObject>
java.lang.Object
dev.metaschema.databind.io.AbstractDeserializer<CLASS>
dev.metaschema.databind.io.json.DefaultJsonDeserializer<CLASS>
- Type Parameters:
CLASS- the Java type of the bound object representing the root node to read
- All Implemented Interfaces:
dev.metaschema.core.configuration.IConfiguration<DeserializationFeature<?>>,dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>>,IDeserializer<CLASS>
- Direct Known Subclasses:
DefaultYamlDeserializer
public class DefaultJsonDeserializer<CLASS extends dev.metaschema.core.model.IBoundObject>
extends AbstractDeserializer<CLASS>
Provides support for reading JSON-based data based on a bound Metaschema
module.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultJsonDeserializer(IBoundDefinitionModelAssembly definition) Construct a new JSON deserializer that will parse the bound class identified by theclassBinding. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigurationChanged(dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>> config) Callback method invoked when the configuration has been changed.protected dev.metaschema.core.metapath.item.node.INodeItemdeserializeToNodeItemInternal(Reader reader, URI documentUri) This abstract method delegates parsing to the concrete implementation.deserializeToValueInternal(Reader reader, URI documentUri) This abstract method delegates parsing to the concrete implementation, returning the deserialized value directly.<V> Vget(DeserializationFeature<?> feature) protected IBindingContextRetrieve the binding context associated with the serializer.protected dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>>Get the current configuration of the serializer/deserializer.protected IBoundDefinitionModelAssemblyRetrieve the bound class information associated with the assembly that the serializer/deserializer will write/read data from.protected com.fasterxml.jackson.core.JsonFactoryGet the parser factory associated with this deserializer.booleanisFeatureEnabled(DeserializationFeature<?> feature) protected com.fasterxml.jackson.core.JsonFactoryGet a JSON factory instance.protected final com.fasterxml.jackson.core.JsonParsernewJsonParser(Reader reader) Using the managed JSON factory, create a new JSON parser instance using the provided reader.protected final voidFor use by subclasses to reset the underlying JSON factory when an important change has occurred that will change how the factory produces aJsonParser.Methods inherited from class dev.metaschema.databind.io.AbstractDeserializer
applyConfiguration, deserializeToNodeItem, deserializeToValue, disableFeature, enableFeature, getConstraintValidationHandler, set, setConstraintValidationHandlerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.metaschema.core.configuration.IConfiguration
get, getFeatureValues, isFeatureEnabledMethods inherited from interface dev.metaschema.databind.io.IDeserializer
deserialize, deserialize, deserialize, deserialize, deserialize, deserializeToNodeItem, isValidating
-
Constructor Details
-
DefaultJsonDeserializer
Construct a new JSON deserializer that will parse the bound class identified by theclassBinding.- Parameters:
definition- the bound class information for the Java type this deserializer is operating on
-
-
Method Details
-
resetFactory
For use by subclasses to reset the underlying JSON factory when an important change has occurred that will change how the factory produces aJsonParser. -
configurationChanged
protected void configurationChanged(dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>> config) Callback method invoked when the configuration has been changed.Subclasses can override this method to handle configuration changes, such as resetting cached factory instances.
- Parameters:
config- the updated configuration
-
newFactoryInstance
Get a JSON factory instance.This method can be used by sub-classes to create a customized factory instance.
- Returns:
- the factory
-
getJsonFactory
Get the parser factory associated with this deserializer.- Returns:
- the factory instance
-
newJsonParser
@NonNull protected final com.fasterxml.jackson.core.JsonParser newJsonParser(@NonNull Reader reader) throws IOException Using the managed JSON factory, create a new JSON parser instance using the provided reader.- Parameters:
reader- the reader for the parser to read data from- Returns:
- the new parser
- Throws:
IOException- if an error occurred while creating the parser
-
deserializeToNodeItemInternal
protected dev.metaschema.core.metapath.item.node.INodeItem deserializeToNodeItemInternal(@NonNull Reader reader, @NonNull URI documentUri) throws IOException Description copied from class:AbstractDeserializerThis abstract method delegates parsing to the concrete implementation.- Specified by:
deserializeToNodeItemInternalin classAbstractDeserializer<CLASS extends dev.metaschema.core.model.IBoundObject>- Parameters:
reader- the reader instance to read data fromdocumentUri- the URI of the document that is being read- Returns:
- a new node item containing the read contents
- Throws:
IOException- if an error occurred while reading data from the stream
-
deserializeToValueInternal
public CLASS deserializeToValueInternal(@NonNull Reader reader, @NonNull URI documentUri) throws IOException Description copied from class:AbstractDeserializerThis abstract method delegates parsing to the concrete implementation, returning the deserialized value directly.- Specified by:
deserializeToValueInternalin classAbstractDeserializer<CLASS extends dev.metaschema.core.model.IBoundObject>- Parameters:
reader- the reader instance to read data fromdocumentUri- the URI of the document that is being read- Returns:
- the deserialized object
- Throws:
IOException- if an error occurred while reading data from the stream
-
getBindingContext
Retrieve the binding context associated with the serializer.- Returns:
- the binding context
-
getDefinition
Retrieve the bound class information associated with the assembly that the serializer/deserializer will write/read data from.- Returns:
- the class binding for the Module assembly
-
getConfiguration
@NonNull protected dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>> getConfiguration()Get the current configuration of the serializer/deserializer.- Returns:
- the configuration
-
isFeatureEnabled
- Specified by:
isFeatureEnabledin interfacedev.metaschema.core.configuration.IConfiguration<T extends dev.metaschema.core.configuration.IConfigurationFeature<?>>
-
getFeatureValues
- Specified by:
getFeatureValuesin interfacedev.metaschema.core.configuration.IConfiguration<T extends dev.metaschema.core.configuration.IConfigurationFeature<?>>
-
get
- Specified by:
getin interfacedev.metaschema.core.configuration.IConfiguration<T extends dev.metaschema.core.configuration.IConfigurationFeature<?>>
-