Package io.lighty.codecs.api
Class ConverterUtils
- java.lang.Object
-
- io.lighty.codecs.api.ConverterUtils
-
public final class ConverterUtils extends Object
A utility class which may be helpful while manipulating with binding independent nodes.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<org.opendaylight.yangtools.yang.common.QName>
getRpcQName(XmlElement xmlElement)
This method extracts from the givenXmlElement
the name and namespace from the first element and creates aQName
.static Optional<org.opendaylight.yangtools.yang.common.QName>
getRpcQName(String inputString)
Create RPC QName.static org.opendaylight.yangtools.yang.model.api.SchemaNode
getSchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, String namespace, String revision, String localName)
Creates an instance ofSchemaNode
for the given namespace, revision and localname.static org.opendaylight.yangtools.yang.model.api.SchemaNode
getSchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, org.opendaylight.yangtools.yang.common.QName qname)
Creates an instance ofSchemaNode
for the givenQName
in the givenSchemaContext
.static org.opendaylight.yangtools.yang.model.api.SchemaNode
getSchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier)
static Optional<org.opendaylight.yangtools.yang.model.api.NotificationDefinition>
loadNotification(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, org.opendaylight.yangtools.yang.common.QName notificationQname)
Utility method to extract theSchemaNode
for the given Notification.static Optional<org.opendaylight.yangtools.yang.model.api.RpcDefinition>
loadRpc(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, org.opendaylight.yangtools.yang.common.QName rpcQName)
Returns theRpcDefinition
from the givenSchemaContext
and givenQName
.static XmlElement
rpcAsInput(XmlElement inputXmlElement)
static XmlElement
rpcAsInput(XmlElement inputXmlElement, String namespace)
Removes the first XML tag and replaces it with an<input>
element.static XmlElement
rpcAsOutput(XmlElement inputXmlElement)
Calls the methodrpcAsOutput(XmlElement, String)
with an empty namespace.static XmlElement
rpcAsOutput(XmlElement inputXmlElement, String namespace)
Removes the first XML tag and replaces it with an<output>
element.
-
-
-
Method Detail
-
loadRpc
public static Optional<org.opendaylight.yangtools.yang.model.api.RpcDefinition> loadRpc(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, org.opendaylight.yangtools.yang.common.QName rpcQName)
Returns theRpcDefinition
from the givenSchemaContext
and givenQName
. TheQName
of a rpc can be constructed viaQName.create("http://netconfcentral.org/ns/toaster", "2009-11-20", "make-toast");
, where"make-toast"
is the name of the RPC given in the yang model.If the given RPC was found in the
SchemaContext
theRpcDefinition
will be present- Parameters:
schemaContext
- the schema context used for the RPC resolutionrpcQName
-QName
of the RPC- Returns:
Optional
representation of theRpcDefinition
- See Also:
QName
-
loadNotification
public static Optional<org.opendaylight.yangtools.yang.model.api.NotificationDefinition> loadNotification(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, org.opendaylight.yangtools.yang.common.QName notificationQname)
Utility method to extract theSchemaNode
for the given Notification.- Parameters:
schemaContext
- to be usednotificationQname
- yang RPC name- Returns:
Optional
ofSchemaNode
-
getRpcQName
public static Optional<org.opendaylight.yangtools.yang.common.QName> getRpcQName(XmlElement xmlElement)
This method extracts from the givenXmlElement
the name and namespace from the first element and creates aQName
.- Parameters:
xmlElement
- input data.- Returns:
QName
for input data or empty.
-
getRpcQName
public static Optional<org.opendaylight.yangtools.yang.common.QName> getRpcQName(String inputString)
Create RPC QName.- Parameters:
inputString
- RPC name- Returns:
QName
for RPC name or empty.- Throws:
IllegalArgumentException
- if there was a problem during parsing the XML document- See Also:
getRpcQName(XmlElement)
-
rpcAsInput
public static XmlElement rpcAsInput(XmlElement inputXmlElement)
-
rpcAsInput
public static XmlElement rpcAsInput(XmlElement inputXmlElement, String namespace)
Removes the first XML tag and replaces it with an<input>
element. This method may be useful when converting the input of a rpc. The provided namespace will be used for the input tag document.- Parameters:
inputXmlElement
- input xml data to wrap.namespace
- namespace- Returns:
- wrapped xml data.
-
rpcAsOutput
public static XmlElement rpcAsOutput(XmlElement inputXmlElement)
Calls the methodrpcAsOutput(XmlElement, String)
with an empty namespace.- Parameters:
inputXmlElement
- input rpc element data.- Returns:
- wrapped xml element.
- See Also:
rpcAsOutput(XmlElement, String)
,XmlUtil
-
rpcAsOutput
public static XmlElement rpcAsOutput(XmlElement inputXmlElement, String namespace)
Removes the first XML tag and replaces it with an<output>
element. This method may be useful when the output rpc is created. The namespace will be used for the output tag.- Parameters:
inputXmlElement
- input rpc element data.namespace
- namespace- Returns:
- wrapped xml element.
- See Also:
XmlUtil
-
getSchemaNode
public static org.opendaylight.yangtools.yang.model.api.SchemaNode getSchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, org.opendaylight.yangtools.yang.common.QName qname)
Creates an instance ofSchemaNode
for the givenQName
in the givenSchemaContext
.- Parameters:
schemaContext
- the given schema context which contains theQName
qname
- the givenQName
- Returns:
- instance of
SchemaNode
- See Also:
getSchemaNode(SchemaContext, String, String, String)
-
getSchemaNode
public static org.opendaylight.yangtools.yang.model.api.SchemaNode getSchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier)
-
getSchemaNode
public static org.opendaylight.yangtools.yang.model.api.SchemaNode getSchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext, String namespace, String revision, String localName)
Creates an instance ofSchemaNode
for the given namespace, revision and localname. The namespace, revision and localname are used to construct theQName
which must exist in theSchemaContext
.- Parameters:
schemaContext
- given schema contextnamespace
-QName
namespacerevision
-QName
revisionlocalName
-QName
localname- Returns:
- instance of
SchemaNode
- See Also:
getSchemaNode(SchemaContext, QName)
-
-