Class NodeUtils


  • public class NodeUtils
    extends java.lang.Object
    Utilities method for XmlNode.
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getAttribute​(XmlNode node, java.lang.String name, java.lang.String defaultValue)  
      static XmlNode getChildNode​(XmlNode node, java.lang.String name)
      Returns the first child node with the specified name.
      static XmlNode[] getChildNodes​(XmlNode node, java.lang.String name)
      Returns all child nodes with the specified name.
      static java.lang.String getRequiredAttribute​(XmlNode node, java.lang.String name, java.lang.String defaultValue, boolean strict)  
      static java.net.URL getRequiredURL​(XmlNode node, java.lang.String name, java.net.URL base, boolean strict)  
      static java.lang.String getSpanText​(XmlNode node)
      Returns the implied text under a node, for example "text" in "<description>text</description>".
      static java.lang.String getSpanText​(XmlNode node, boolean preserveSpacing)
      Returns the implied text under a node, for example "text" in "<description>text</description>".
      static java.net.URL getURL​(java.lang.String href, java.lang.String nodeName, java.net.URL base, boolean strict)  
      static java.net.URL getURL​(XmlNode node, java.lang.String name, java.net.URL base, boolean strict)  
      • Methods inherited from class java.lang.Object

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

      • NodeUtils

        public NodeUtils()
    • Method Detail

      • getChildNode

        public static XmlNode getChildNode​(XmlNode node,
                                           java.lang.String name)
        Returns the first child node with the specified name.
      • getChildNodes

        public static XmlNode[] getChildNodes​(XmlNode node,
                                              java.lang.String name)
        Returns all child nodes with the specified name.
      • getSpanText

        public static java.lang.String getSpanText​(XmlNode node)
        Returns the implied text under a node, for example "text" in "<description>text</description>".
        Parameters:
        node - the node with text under it
      • getSpanText

        public static java.lang.String getSpanText​(XmlNode node,
                                                   boolean preserveSpacing)
        Returns the implied text under a node, for example "text" in "<description>text</description>". If preserveSpacing is false, sequences of whitespace characters are turned into a single space character.
        Parameters:
        node - the node with text under it
        preserveSpacing - if true, preserve whitespace
      • getAttribute

        public static java.lang.String getAttribute​(XmlNode node,
                                                    java.lang.String name,
                                                    java.lang.String defaultValue)
        Parameters:
        node - the node
        name - the attribute
        defaultValue - default if no such attribute
        Returns:
        an attribute or the specified defaultValue if there is no such attribute.
      • getRequiredAttribute

        public static java.lang.String getRequiredAttribute​(XmlNode node,
                                                            java.lang.String name,
                                                            java.lang.String defaultValue,
                                                            boolean strict)
                                                     throws ParseException
        Parameters:
        node - the node
        name - the attribute
        defaultValue - default value
        Returns:
        the same result as getAttribute except that if strict mode is enabled or the default value is null a parse exception is thrown instead of returning the default value.
        Throws:
        ParseException - if the attribute does not exist or is empty
      • getRequiredURL

        public static java.net.URL getRequiredURL​(XmlNode node,
                                                  java.lang.String name,
                                                  java.net.URL base,
                                                  boolean strict)
                                           throws ParseException
        Parameters:
        node - the node
        name - the attribute containing an href
        base - the base URL
        Returns:
        the same result as getURL except that a ParseException is thrown if the attribute is null or empty.
        Throws:
        ParseException - if the JNLP file is invalid
      • getURL

        public static java.net.URL getURL​(XmlNode node,
                                          java.lang.String name,
                                          java.net.URL base,
                                          boolean strict)
                                   throws ParseException
        Parameters:
        node - the node
        name - the attribute containing an href
        base - the base URL
        Returns:
        a URL object from a href string relative to the code base. If the href denotes a relative URL, it must reference a location that is a subdirectory of the codebase.
        Throws:
        ParseException - if the JNLP file is invalid
      • getURL

        public static java.net.URL getURL​(java.lang.String href,
                                          java.lang.String nodeName,
                                          java.net.URL base,
                                          boolean strict)
                                   throws ParseException
        Throws:
        ParseException