Class NodeUtils
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.xmlparser.NodeUtils
-
public class NodeUtils extends java.lang.ObjectUtilities method forXmlNode.
-
-
Constructor Summary
Constructors Constructor Description NodeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetAttribute(XmlNode node, java.lang.String name, java.lang.String defaultValue)static XmlNodegetChildNode(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.StringgetRequiredAttribute(XmlNode node, java.lang.String name, java.lang.String defaultValue, boolean strict)static java.net.URLgetRequiredURL(XmlNode node, java.lang.String name, java.net.URL base, boolean strict)static java.lang.StringgetSpanText(XmlNode node)Returns the implied text under a node, for example "text" in "<description>text</description>".static java.lang.StringgetSpanText(XmlNode node, boolean preserveSpacing)Returns the implied text under a node, for example "text" in "<description>text</description>".static java.net.URLgetURL(java.lang.String href, java.lang.String nodeName, java.net.URL base, boolean strict)static java.net.URLgetURL(XmlNode node, java.lang.String name, java.net.URL base, boolean strict)
-
-
-
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 itpreserveSpacing- if true, preserve whitespace
-
getAttribute
public static java.lang.String getAttribute(XmlNode node, java.lang.String name, java.lang.String defaultValue)
- Parameters:
node- the nodename- the attributedefaultValue- 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 nodename- the attributedefaultValue- 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 nodename- the attribute containing an hrefbase- 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 nodename- the attribute containing an hrefbase- 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
-
-