Class DOMUtils


  • public class DOMUtils
    extends Object
    Helper class for DOM operations.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • DOMUtils

        public DOMUtils()
    • Method Detail

      • hasTextContent

        protected static boolean hasTextContent​(Node node)
        Returns whether the node has any text content or just other nested nodes.
        Parameters:
        node - the node to test
        Returns:
        true if actual textual content available
      • flatten

        protected static boolean flatten​(String pathSeparator,
                                         boolean addIndex,
                                         boolean storeAttributes,
                                         boolean skipRoot,
                                         String path,
                                         Node node,
                                         int index,
                                         Properties props)
        Flattens the node structure.
        Parameters:
        path - the current path, null for root element
        node - the current node
        index - the index of the node
        props - the properties to store the data in
        Returns:
        true if node was added
      • toProperties

        public static Properties toProperties​(String pathSeparator,
                                              boolean addIndex,
                                              boolean storeAttributes,
                                              boolean skipRoot,
                                              Node node)
        Flattens the DOM and turns them into properties.
        Parameters:
        pathSeparator - the path separator to use
        addIndex - whether to add the index
        storeAttributes - whether to store the attributes as well
        skipRoot - whether to skip the root
        node - the node to process
        Returns:
        the generated properties