Class PathUtils


  • public class PathUtils
    extends java.lang.Object
    Normalizes a path into an XML document.
    Author:
    Holger Eichelberger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SEPARATOR
      The separator between element names.
    • Constructor Summary

      Constructors 
      Constructor Description
      PathUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String normalize​(java.lang.String path)
      Normalizes the given path (removes superfluous separators).
      (package private) static Set<XmlElement> selectByPath​(IXmlContainer container, java.lang.String path)
      Selects XML elements from container according to a given path.
      static Set<XmlElement> selectByXPath​(java.lang.String path, java.lang.Object root, IXmlContainer container)
      Selects XML elements based on a given XPath expression.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SEPARATOR

        public static final java.lang.String SEPARATOR
        The separator between element names.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PathUtils

        public PathUtils()
    • Method Detail

      • normalize

        public static java.lang.String normalize​(java.lang.String path)
        Normalizes the given path (removes superfluous separators).
        Parameters:
        path - the path to be normalized
        Returns:
        the normalized path
      • selectByPath

        static Set<XmlElement> selectByPath​(IXmlContainer container,
                                            java.lang.String path)
                                     throws VilException
        Selects XML elements from container according to a given path. We may go for XPath expressions in future.
        Parameters:
        container - the container to select from
        path - the normalized (!) path to the elements (use normalize(String) before calling)
        Returns:
        the matching elements (may be empty)
        Throws:
        VilException - in case invalid XmlElements are used.
      • selectByXPath

        public static Set<XmlElement> selectByXPath​(java.lang.String path,
                                                    java.lang.Object root,
                                                    IXmlContainer container)
                                             throws VilException
        Selects XML elements based on a given XPath expression.
        Parameters:
        path - the XPath expression
        root - the XML element to start evaluating the XPath expression at
        container - the XML container
        Returns:
        the resulting elements
        Throws:
        VilException - in case invalid XmlElements are used or path is invalid.