Class DomUtil


  • public final class DomUtil
    extends Object
    Helper methods which abstract some gruesome DOM specifics. It does not provide synchronization when invoked in parallel with the same objects.
    Author:
    Daniel Meyer, Sebastian Menski
    • Constructor Detail

      • DomUtil

        public DomUtil()
    • Method Detail

      • filterNodeListForElements

        public static List<DomElement> filterNodeListForElements​(NodeList nodeList)
        Filters a NodeList retaining all elements
        Parameters:
        nodeList - the the NodeList to filter
        Returns:
        the list of all elements
      • filterNodeListByName

        public static List<DomElement> filterNodeListByName​(NodeList nodeList,
                                                            String namespaceUri,
                                                            String localName)
        Filter a NodeList retaining all elements with a specific name
        Parameters:
        nodeList - the NodeList to filter
        namespaceUri - the namespace for the elements
        localName - the local element name to filter for
        Returns:
        the List of all Elements which match the filter
      • filterNodeListByType

        public static List<DomElement> filterNodeListByType​(NodeList nodeList,
                                                            ModelInstanceImpl modelInstance,
                                                            Class<?> type)
        Filter a NodeList retaining all elements with a specific type
        Parameters:
        nodeList - the NodeList to filter
        modelInstance - the model instance
        type - the type class to filter for
        Returns:
        the list of all Elements which match the filter
      • getEmptyDocument

        public static DomDocument getEmptyDocument​(DocumentBuilderFactory documentBuilderFactory)
        Get an empty DOM document
        Parameters:
        documentBuilderFactory - the factory to build to DOM document
        Returns:
        the new empty document
        Throws:
        ModelParseException - if unable to create a new document
      • parseInputStream

        public static DomDocument parseInputStream​(DocumentBuilderFactory documentBuilderFactory,
                                                   InputStream inputStream)
        Create a new DOM document from the input stream
        Parameters:
        documentBuilderFactory - the factory to build to DOM document
        inputStream - the input stream to parse
        Returns:
        the new DOM document
        Throws:
        ModelParseException - if a parsing or IO error is triggered