Class AbstractDeserializer<CLASS>
- java.lang.Object
-
- gov.nist.secauto.metaschema.databind.io.AbstractDeserializer<CLASS>
-
- Type Parameters:
CLASS
- the bound class to deserialize to
- All Implemented Interfaces:
IConfiguration<DeserializationFeature<?>>
,IMutableConfiguration<DeserializationFeature<?>>
,IDeserializer<CLASS>
- Direct Known Subclasses:
DefaultJsonDeserializer
,DefaultXmlDeserializer
public abstract class AbstractDeserializer<CLASS> extends Object implements IDeserializer<CLASS>
The base class of all format-specific deserializers.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractDeserializer(IAssemblyClassBinding classBinding)
Construct a new deserializer.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description IDeserializer<CLASS>
applyConfiguration(IConfiguration<DeserializationFeature<?>> other)
protected void
configurationChanged(IMutableConfiguration<T> config)
INodeItem
deserializeToNodeItem(Reader reader, URI documentUri)
Read data from theReader
into a node item instance.protected abstract INodeItem
deserializeToNodeItemInternal(Reader reader, URI documentUri)
This abstract method delegates parsing to the concrete implementation.IDeserializer<CLASS>
disableFeature(DeserializationFeature<?> feature)
IDeserializer<CLASS>
enableFeature(DeserializationFeature<?> feature)
<V> V
get(T feature)
protected IBindingContext
getBindingContext()
Retrieve the binding context associated with the serializer.protected IAssemblyClassBinding
getClassBinding()
Retrieve the bound class information associated with the assembly that the serializer/deserializer will write/read data from.protected IMutableConfiguration<T>
getConfiguration()
Get the current configuration of the serializer/deserializer.IConstraintValidationHandler
getConstraintValidationHandler()
Get the constraint validation handler configured for this deserializer, which will be used to validate loaded data.Map<T,Object>
getFeatureValues()
boolean
isFeatureEnabled(T feature)
IDeserializer<CLASS>
set(DeserializationFeature<?> feature, Object value)
void
setConstraintValidationHandler(IConstraintValidationHandler constraintValidationHandler)
Set the constraint violation handler for constraint validation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nist.secauto.metaschema.core.configuration.IConfiguration
get, getFeatureValues, isFeatureEnabled
-
Methods inherited from interface gov.nist.secauto.metaschema.databind.io.IDeserializer
deserialize, deserialize, deserialize, deserialize, deserialize, deserializeToNodeItem, deserializeToValue, isValidating
-
-
-
-
Constructor Detail
-
AbstractDeserializer
protected AbstractDeserializer(@NonNull IAssemblyClassBinding classBinding)
Construct a new deserializer.- Parameters:
classBinding
- the bound class information for the Java type this deserializer is operating on
-
-
Method Detail
-
getConstraintValidationHandler
@NonNull public IConstraintValidationHandler getConstraintValidationHandler()
Get the constraint validation handler configured for this deserializer, which will be used to validate loaded data.- Specified by:
getConstraintValidationHandler
in interfaceIDeserializer<CLASS>
- Returns:
- the deserializer
-
setConstraintValidationHandler
public void setConstraintValidationHandler(@NonNull IConstraintValidationHandler constraintValidationHandler)
Description copied from interface:IDeserializer
Set the constraint violation handler for constraint validation.- Specified by:
setConstraintValidationHandler
in interfaceIDeserializer<CLASS>
- Parameters:
constraintValidationHandler
- the handler to use
-
deserializeToNodeItem
public INodeItem deserializeToNodeItem(Reader reader, URI documentUri) throws IOException
Description copied from interface:IDeserializer
Read data from theReader
into a node item instance.- Specified by:
deserializeToNodeItem
in interfaceIDeserializer<CLASS>
- Parameters:
reader
- the reader to read fromdocumentUri
- the URI of the document to read from- Returns:
- a new node item
- Throws:
IOException
- if an error occurred while reading data from the stream
-
deserializeToNodeItemInternal
@NonNull protected abstract INodeItem deserializeToNodeItemInternal(@NonNull Reader reader, @NonNull URI documentUri) throws IOException
This abstract method delegates parsing to the concrete implementation.- 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
-
enableFeature
public IDeserializer<CLASS> enableFeature(DeserializationFeature<?> feature)
- Specified by:
enableFeature
in interfaceIDeserializer<CLASS>
- Specified by:
enableFeature
in interfaceIMutableConfiguration<CLASS>
-
disableFeature
public IDeserializer<CLASS> disableFeature(DeserializationFeature<?> feature)
- Specified by:
disableFeature
in interfaceIDeserializer<CLASS>
- Specified by:
disableFeature
in interfaceIMutableConfiguration<CLASS>
-
applyConfiguration
public IDeserializer<CLASS> applyConfiguration(@NonNull IConfiguration<DeserializationFeature<?>> other)
- Specified by:
applyConfiguration
in interfaceIDeserializer<CLASS>
- Specified by:
applyConfiguration
in interfaceIMutableConfiguration<CLASS>
-
set
public IDeserializer<CLASS> set(DeserializationFeature<?> feature, Object value)
- Specified by:
set
in interfaceIDeserializer<CLASS>
- Specified by:
set
in interfaceIMutableConfiguration<CLASS>
-
getBindingContext
@NonNull protected IBindingContext getBindingContext()
Retrieve the binding context associated with the serializer.- Returns:
- the binding context
-
getClassBinding
@NonNull protected IAssemblyClassBinding getClassBinding()
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
-
configurationChanged
protected void configurationChanged(@NonNull IMutableConfiguration<T> config)
-
getConfiguration
@NonNull protected IMutableConfiguration<T> getConfiguration()
Get the current configuration of the serializer/deserializer.- Returns:
- the configuration
-
isFeatureEnabled
public boolean isFeatureEnabled(T feature)
- Specified by:
isFeatureEnabled
in interfaceIConfiguration<T extends IConfigurationFeature<?>>
-
getFeatureValues
public Map<T,Object> getFeatureValues()
- Specified by:
getFeatureValues
in interfaceIConfiguration<T extends IConfigurationFeature<?>>
-
get
public <V> V get(T feature)
- Specified by:
get
in interfaceIConfiguration<T extends IConfigurationFeature<?>>
-
-