Class SchemaUtils


  • public final class SchemaUtils
    extends Object
    • Method Detail

      • findFirstSchema

        public static Optional<DataSchemaNode> findFirstSchema​(QName qname,
                                                               Iterable<? extends DataSchemaNode> dataSchemaNode)
        Find the first schema with specified QName.
        Parameters:
        qname - schema node to find
        dataSchemaNode - Iterable of schemaNodes to look through
        Returns:
        schema node with newest revision or absent if no schema node with matching qname is found
      • findSchemaForChild

        public static DataSchemaNode findSchemaForChild​(DataNodeContainer schema,
                                                        QName qname)
        Find child schema node identified by its QName within a provided schema node.
        Parameters:
        schema - schema for parent node - search root
        qname - qname(with or without a revision) of a child node to be found in the parent schema
        Returns:
        found schema node
        Throws:
        IllegalStateException - if the child was not found in parent schema node
      • mapChildElementsFromChoices

        public static Map<QName,​ChoiceSchemaNode> mapChildElementsFromChoices​(DataNodeContainer schema)
        Recursively find all child nodes that come from choices.
        Parameters:
        schema - schema
        Returns:
        Map with all child nodes, to their most top augmentation
      • mapChildElementsFromAugments

        public static Map<QName,​AugmentationSchemaNode> mapChildElementsFromAugments​(AugmentationTarget schema)
        Recursively find all child nodes that come from augmentations.
        Parameters:
        schema - schema
        Returns:
        Map with all child nodes, to their most top augmentation
      • getChildNodesRecursive

        public static Set<QName> getChildNodesRecursive​(DataNodeContainer nodeContainer)
        Recursively list all child nodes. In case of choice, augment and cases, step in.
        Parameters:
        nodeContainer - node container
        Returns:
        set of QNames
      • getRealSchemasForAugment

        public static Set<DataSchemaNode> getRealSchemasForAugment​(AugmentationTarget targetSchema,
                                                                   AugmentationSchemaNode augmentSchema)
        Retrieves real schemas for augmented child node.

        Schema of the same child node from augment, and directly from target is not the same. Schema of child node from augment is incomplete, therefore its useless for XML/NormalizedNode translation.

        Parameters:
        targetSchema - target schema
        augmentSchema - augment schema
        Returns:
        set of nodes
      • findCorrespondingAugment

        public static AugmentationSchemaNode findCorrespondingAugment​(DataSchemaNode parent,
                                                                      DataSchemaNode child)
        Tries to find in parent which is dealed as augmentation target node with QName as child. If such node is found then it is returned, else null.
        Parameters:
        parent - parent node
        child - child node
        Returns:
        augmentation schema
      • findDataParentSchemaOnPath

        public static SchemaNode findDataParentSchemaOnPath​(SchemaContext schemaContext,
                                                            SchemaPath path)
        Finds schema node for given path in schema context. This method performs lookup in the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas, and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
        Parameters:
        schemaContext - schema context
        path - path
        Returns:
        schema node on path
      • findDataChildSchemaByQName

        public static @Nullable SchemaNode findDataChildSchemaByQName​(SchemaNode node,
                                                                      QName qname)
        Find child data schema node identified by its QName within a provided schema node. This method performs lookup in the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas and anyxmls according to RFC6050/RFC7950 section 6.2.1.
        Parameters:
        node - schema node
        qname - QName
        Returns:
        data child schema node
        Throws:
        IllegalArgumentException - if the schema node does not allow children
      • findParentSchemaNodesOnPath

        public static Collection<SchemaNode> findParentSchemaNodesOnPath​(SchemaContext schemaContext,
                                                                         SchemaPath path)
        Finds schema node for given path in schema context. This method performs lookup in both the namespace of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.

        This method returns collection of SchemaNodes, because name conflicts can occur between the namespace of groupings and namespace of data nodes. This method finds and collects all schema nodes that matches supplied SchemaPath and returns them all as collection of schema nodes.

        Parameters:
        schemaContext - schema context
        path - path
        Returns:
        collection of schema nodes on path
      • findParentSchemaNodesOnPath

        public static Collection<SchemaNode> findParentSchemaNodesOnPath​(SchemaContext schemaContext,
                                                                         Iterable<QName> path)
        Finds schema node for given path in schema context. This method performs lookup in both the namespace of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.

        This method returns collection of SchemaNodes, because name conflicts can occur between the namespace of groupings and namespace of data nodes. This method finds and collects all schema nodes that matches supplied SchemaPath and returns them all as collection of schema nodes.

        Parameters:
        schemaContext - schema context
        path - path
        Returns:
        collection of schema nodes on path
      • findChildSchemaNodesByQName

        public static Collection<SchemaNode> findChildSchemaNodesByQName​(SchemaNode node,
                                                                         QName qname)
        Find child schema node identified by its QName within a provided schema node. This method performs lookup in both the namespace of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas and anyxmls according to RFC6050/RFC7950 section 6.2.1.

        This method returns collection of SchemaNodes, because name conflicts can occur between the namespace of groupings and namespace of data nodes. This method finds and collects all schema nodes with supplied QName and returns them all as collection of schema nodes.

        Parameters:
        node - schema node
        qname - QName
        Returns:
        collection of child schema nodes
        Throws:
        IllegalArgumentException - if the schema node does not allow children