Package io.lighty.codecs.util
Class ConverterUtils
java.lang.Object
io.lighty.codecs.util.ConverterUtils
A utility class which may be helpful while manipulating with binding independent nodes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<org.opendaylight.yangtools.yang.common.QName>getRpcQName(String inputString) Create RPC QName.static Optional<org.opendaylight.yangtools.yang.common.QName>getRpcQName(org.opendaylight.netconf.api.xml.XmlElement xmlElement) This method extracts from the givenXmlElementthe name and namespace from the first element and creates aQName.static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>>getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, String namespace, String revision, String localName) Finds theDataSchemaContextNodefor the given namespace, revision and local name inEffectiveModelContext.static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>>getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName qname) Finds theDataSchemaContextNodefor the givenQNameinEffectiveModelContext.static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>>getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier) Finds theDataSchemaContextNodefor the givenYangInstanceIdentifierinEffectiveModelContext.static Optional<? extends org.opendaylight.yangtools.yang.model.api.NotificationDefinition>loadNotification(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName notificationQname) Utility method to extract theSchemaNodefor the given Notification.static Optional<? extends org.opendaylight.yangtools.yang.model.api.RpcDefinition>loadRpc(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName rpcQName) Returns theRpcDefinitionfrom the givenEffectiveModelContextand givenQName.static org.opendaylight.netconf.api.xml.XmlElementrpcAsInput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement) static org.opendaylight.netconf.api.xml.XmlElementrpcAsInput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement, String namespace) Removes the first XML tag and replaces it with an<input>element.static org.opendaylight.netconf.api.xml.XmlElementrpcAsOutput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement) Calls the methodrpcAsOutput(XmlElement, String)with an empty namespace.static org.opendaylight.netconf.api.xml.XmlElementrpcAsOutput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement, String namespace) Removes the first XML tag and replaces it with an<output>element.static org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.InferencetoInference(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier, org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext) Converts providedYangInstanceIdentifiertoSchemaInferenceStack.Inference.
-
Method Details
-
loadRpc
public static Optional<? extends org.opendaylight.yangtools.yang.model.api.RpcDefinition> loadRpc(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName rpcQName) Returns theRpcDefinitionfrom the givenEffectiveModelContextand givenQName. TheQNameof 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
EffectiveModelContexttheRpcDefinitionwill be returned- Parameters:
effectiveModelContext- the effective model context used for the RPC resolutionrpcQName-QNameof the RPC- Returns:
Optionalrepresentation of theRpcDefinition- See Also:
-
QName
-
loadNotification
public static Optional<? extends org.opendaylight.yangtools.yang.model.api.NotificationDefinition> loadNotification(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName notificationQname) Utility method to extract theSchemaNodefor the given Notification.- Parameters:
effectiveModelContext- to be usednotificationQname- yang RPC name- Returns:
OptionalofSchemaNode
-
getRpcQName
public static Optional<org.opendaylight.yangtools.yang.common.QName> getRpcQName(org.opendaylight.netconf.api.xml.XmlElement xmlElement) This method extracts from the givenXmlElementthe name and namespace from the first element and creates aQName.- Parameters:
xmlElement- input data.- Returns:
QNamefor 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:
QNamefor RPC name or empty.- Throws:
IllegalArgumentException- if there was a problem during parsing the XML document- See Also:
-
rpcAsInput
public static org.opendaylight.netconf.api.xml.XmlElement rpcAsInput(org.opendaylight.netconf.api.xml.XmlElement inputXmlElement) -
rpcAsInput
public static org.opendaylight.netconf.api.xml.XmlElement rpcAsInput(org.opendaylight.netconf.api.xml.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 org.opendaylight.netconf.api.xml.XmlElement rpcAsOutput(org.opendaylight.netconf.api.xml.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 org.opendaylight.netconf.api.xml.XmlElement rpcAsOutput(org.opendaylight.netconf.api.xml.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 Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>> getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.common.QName qname) Finds theDataSchemaContextNodefor the givenQNameinEffectiveModelContext.Search is performed only on first level nodes of the modules, for recursive search, the
YangInstanceIdentifieris needed, thus consider usinggetSchemaNode(EffectiveModelContext, YangInstanceIdentifier).- Parameters:
effectiveModelContext- model context to searchqname-QNameof node to search for- Returns:
- optional found
DataSchemaContextNode
-
getSchemaNode
public static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>> getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier) Finds theDataSchemaContextNodefor the givenYangInstanceIdentifierinEffectiveModelContext.- Parameters:
effectiveModelContext- model context to searchyangInstanceIdentifier-YangInstanceIdentifierof the node to search for- Returns:
- optional found
DataSchemaContextNode
-
getSchemaNode
public static Optional<@NonNull org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode<?>> getSchemaNode(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext, String namespace, String revision, String localName) Finds theDataSchemaContextNodefor the given namespace, revision and local name inEffectiveModelContext.Search is performed only on first level nodes of the modules, for recursive search, the
YangInstanceIdentifieris needed, thus consider usinggetSchemaNode(EffectiveModelContext, YangInstanceIdentifier).- Parameters:
effectiveModelContext- model context to searchnamespace-QNamemodule namespace of the node to search forrevision-QNamemodule revision of the node to search forlocalName-QNamelocal name of the node to search for- Returns:
- optional found
DataSchemaContextNode
-
toInference
public static org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference toInference(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier yangInstanceIdentifier, org.opendaylight.yangtools.yang.model.api.EffectiveModelContext effectiveModelContext) Converts providedYangInstanceIdentifiertoSchemaInferenceStack.Inference.- Parameters:
yangInstanceIdentifier- yang instance identifiereffectiveModelContext- current model context- Returns:
SchemaInferenceStack.Inference
-