Class 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 given XmlElement the name and namespace from the first element and creates a QName.
      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 of SchemaNode 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 of SchemaNode for the given QName in the given SchemaContext.
      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 the SchemaNode 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 the RpcDefinition from the given SchemaContext and given QName.
      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 method rpcAsOutput(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 the RpcDefinition from the given SchemaContext and given QName. The QName of a rpc can be constructed via

        QName.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 the RpcDefinition will be present

        Parameters:
        schemaContext - the schema context used for the RPC resolution
        rpcQName - QName of the RPC
        Returns:
        Optional representation of the RpcDefinition
        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 the SchemaNode for the given Notification.
        Parameters:
        schemaContext - to be used
        notificationQname - yang RPC name
        Returns:
        Optional of SchemaNode
      • getRpcQName

        public static Optional<org.opendaylight.yangtools.yang.common.QName> getRpcQName​(XmlElement xmlElement)
        This method extracts from the given XmlElement the name and namespace from the first element and creates a QName.
        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,
                                            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,
                                             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 of SchemaNode for the given QName in the given SchemaContext.
        Parameters:
        schemaContext - the given schema context which contains the QName
        qname - the given QName
        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 of SchemaNode for the given namespace, revision and localname. The namespace, revision and localname are used to construct the QName which must exist in the SchemaContext.
        Parameters:
        schemaContext - given schema context
        namespace - QName namespace
        revision - QName revision
        localName - QName localname
        Returns:
        instance of SchemaNode
        See Also:
        getSchemaNode(SchemaContext, QName)