public class XmlNodeConverter extends Object implements NodeConverter
NodeConverter
which serializes and deserializes binding independent
representation into/from XML representation.JsonNodeConverter
Constructor and Description |
---|
XmlNodeConverter(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext)
The only constructor will create an instance of
XmlNodeConverter with the given
SchemaContext . |
Modifier and Type | Method and Description |
---|---|
static void |
closeQuietly(XMLStreamReader xmlStreamReader)
This method is similar to the
Closeables.closeQuietly(Reader) or other 'closeQuietly
methods. |
org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> |
deserialize(org.opendaylight.yangtools.yang.model.api.SchemaNode schemaNode,
Reader inputData)
This method deserializes the provided XML string representation (via
Reader ) interface
into NormalizedNode s. |
Writer |
serializeData(org.opendaylight.yangtools.yang.model.api.SchemaNode schemaNode,
org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> normalizedNode)
This method serializes the given
NormalizedNode into its XML string representation. |
Writer |
serializeRpc(org.opendaylight.yangtools.yang.model.api.SchemaNode schemaNode,
org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> normalizedNode)
This method serializes the input or output of a RPC given as
NormalizedNode
representation into XML string representation. |
public XmlNodeConverter(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext)
XmlNodeConverter
with the given
SchemaContext
. This schema context will be used for proper RPC and Node resolution.schemaContext
- initial schema contextpublic Writer serializeData(org.opendaylight.yangtools.yang.model.api.SchemaNode schemaNode, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> normalizedNode) throws SerializationException
NormalizedNode
into its XML string representation.serializeData
in interface NodeConverter
schemaNode
- the parent schema node where the nodes existnormalizedNode
- NormalizedNode
to be serializedStringWriter
implementation of Writer
is returnedSerializationException
- if it was not possible to serialize the normalized nodes into XMLNodeConverter.serializeData(SchemaNode, NormalizedNode)
public Writer serializeRpc(org.opendaylight.yangtools.yang.model.api.SchemaNode schemaNode, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> normalizedNode) throws SerializationException
NormalizedNode
representation into XML string representation.
To obtain correct SchemaNode
use ConverterUtils.loadRpc(SchemaContext, QName)
method
serializeRpc
in interface NodeConverter
schemaNode
- input or output SchemaNode
normalizedNode
- NormalizedNode
representation of input or outputStringWriter
SerializationException
- may be thrown if there was a problem during serializationConverterUtils.rpcAsInput(XmlElement)
,
ConverterUtils.rpcAsOutput(XmlElement)
,
ConverterUtils.getRpcQName(XmlElement)
public org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> deserialize(org.opendaylight.yangtools.yang.model.api.SchemaNode schemaNode, Reader inputData) throws SerializationException
Reader
) interface
into NormalizedNode
s. During deserialization of RPC input and output a proper
SchemaNode
(given for input or output) must be passed. This may be obtained via
ConverterUtils.loadRpc(SchemaContext, QName)
deserialize
in interface NodeConverter
schemaNode
- parent schema node which contains information about the input datainputData
- XML inputOptional
representation of NormalizedNode
. If the deserialization
process finished incorrectly an empty value will be presentSerializationException
- if it was not possible to deserialize the input dataIllegalArgumentException
- if a problem occurs during reading the inputConverterUtils.loadRpc(SchemaContext, QName)
,
ConverterUtils.rpcAsInput(XmlElement)
,
ConverterUtils.rpcAsOutput(XmlElement)
public static void closeQuietly(XMLStreamReader xmlStreamReader)
Closeables.closeQuietly(Reader)
or other 'closeQuietly
methods. It takes the XMLStreamReader
as parameter checks for null and tries to close it
while consuming the IOException
. If the IOException
occurs it will be logged.xmlStreamReader
- the given XMLStreamReader
may be nullCopyright © 2020. All rights reserved.