Class DefaultXmlSerializer<CLASS>
- java.lang.Object
-
- gov.nist.secauto.metaschema.databind.io.AbstractSerializer<CLASS>
-
- gov.nist.secauto.metaschema.databind.io.xml.DefaultXmlSerializer<CLASS>
-
- All Implemented Interfaces:
IConfiguration<SerializationFeature<?>>
,IMutableConfiguration<SerializationFeature<?>>
,ISerializer<CLASS>
public class DefaultXmlSerializer<CLASS> extends AbstractSerializer<CLASS>
-
-
Constructor Summary
Constructors Constructor Description DefaultXmlSerializer(IAssemblyClassBinding classBinding)
Construct a new XML serializer based on the top-level assembly indicated by the providedclassBinding
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configurationChanged(IMutableConfiguration<T> config)
<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.Map<T,Object>
getFeatureValues()
protected org.codehaus.stax2.XMLOutputFactory2
getXMLOutputFactory()
Get the configured XML output factory used to createXMLStreamWriter2
instances.boolean
isFeatureEnabled(T feature)
protected org.codehaus.stax2.XMLStreamWriter2
newXMLStreamWriter(Writer writer)
Create a new stream writer using the provided writer.void
serialize(CLASS data, Writer writer)
Write data from a bound class instance to theWriter
.protected void
setXMLOutputFactory(org.codehaus.stax2.XMLOutputFactory2 xmlOutputFactory)
Override the defaultXMLOutputFactory2
instance with a custom factory.-
Methods inherited from class gov.nist.secauto.metaschema.databind.io.AbstractSerializer
applyConfiguration, disableFeature, enableFeature, set
-
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.ISerializer
serialize, serialize, serialize
-
-
-
-
Constructor Detail
-
DefaultXmlSerializer
public DefaultXmlSerializer(@NonNull IAssemblyClassBinding classBinding)
Construct a new XML serializer based on the top-level assembly indicated by the providedclassBinding
.- Parameters:
classBinding
- the bound Module assembly definition that describes the data to serialize
-
-
Method Detail
-
getXMLOutputFactory
@NonNull protected final org.codehaus.stax2.XMLOutputFactory2 getXMLOutputFactory()
Get the configured XML output factory used to createXMLStreamWriter2
instances.- Returns:
- the factory
-
setXMLOutputFactory
protected void setXMLOutputFactory(@NonNull org.codehaus.stax2.XMLOutputFactory2 xmlOutputFactory)
Override the defaultXMLOutputFactory2
instance with a custom factory.- Parameters:
xmlOutputFactory
- the new factory
-
newXMLStreamWriter
@NonNull protected final org.codehaus.stax2.XMLStreamWriter2 newXMLStreamWriter(@NonNull Writer writer) throws IOException
Create a new stream writer using the provided writer.- Parameters:
writer
- the writer to use for output- Returns:
- the stream writer created by the output factory
- Throws:
IOException
- if an error occurred while creating the writer
-
serialize
public void serialize(CLASS data, Writer writer) throws IOException
Description copied from interface:ISerializer
Write data from a bound class instance to theWriter
.- Parameters:
data
- the instance datawriter
- the writer to write to- Throws:
IOException
- if an error occurred while writing data to the stream
-
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<?>>
-
-