Class NodeUtils

java.lang.Object
net.adoptopenjdk.icedteaweb.xmlparser.NodeUtils

public class NodeUtils extends Object
Utilities method for XmlNode.
  • Constructor Details

    • NodeUtils

      public NodeUtils()
  • Method Details

    • getChildNode

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

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

      public static 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 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 String getAttribute(XmlNode node, String name, 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 String getRequiredAttribute(XmlNode node, String name, 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 URL getRequiredURL(XmlNode node, String name, 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 URL getURL(XmlNode node, String name, 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 URL getURL(String href, String nodeName, URL base, boolean strict) throws ParseException
      Throws:
      ParseException