Class XMLUtils

Object
com.wowza.util.XMLUtils

public class XMLUtils extends Object

XMLUtils: utility class for parsing XML files.

  • Constructor Details

    • XMLUtils

      public XMLUtils()
  • Method Details

    • getNodeValueByTagName

      public static String getNodeValueByTagName(Element node, String name)
      Get a child Node value by tag name. Return null if does not exist.
      Parameters:
      node - parent node
      name - tag name
      Returns:
      node value or null if does not exist
    • getNodeByTagName

      public static Node getNodeByTagName(Element node, String name)
      Return a child Node by tag name. Return null if does not exist.
      Parameters:
      node - parent node
      name - tag name
      Returns:
      Node or null if does not exist
    • getNodeValue

      public static String getNodeValue(Node node)
      Return the text value of a node. Return concatenated value of all children nodes that are text nodes.
      Parameters:
      node - parent node
      Returns:
      concatenated text nodes or empty string if not found or no children
    • loadConfigProperies

      public static void loadConfigProperies(Element root, String propertiesXPath, WMSProperties properties)
      Loads <Properties> elemnt by xpath into properties object.
      Parameters:
      root - root node
      propertiesXPath - xpath to search for <Properties> element
      properties - properties to add values to
    • loadConfigProperies

      public static void loadConfigProperies(NodeList resultList, WMSProperties properties)
      Given a nodeList load children as properties.
      Parameters:
      resultList - node list
      properties - properties to add values to
    • getXMLPropertyStr

      public static String getXMLPropertyStr(XPath xpath, String xpathStr, Element root)
      Get a single string value pointed to by xpath or null if not found.
      Parameters:
      xpath - XPath interface
      xpathStr - xpath string
      root - root node to start search
      Returns:
      single string value pointed to by xpath or null if not found
    • getXMLPropertyStr

      public static String getXMLPropertyStr(XPath xpath, String xpathStr, Element root, String defaultVal)
      Get a single string value pointed to by xpath or defaultVal if not found.
      Parameters:
      xpath - XPath interface
      xpathStr - xpath string
      root - node to start search
      defaultVal - default value
      Returns:
      single string value pointed to by xpath or defaultVal if not found
    • getXMLPropertyExists

      public static boolean getXMLPropertyExists(XPath xpath, String xpathStr, Element root)
    • getXMLPropertyInt

      public static int getXMLPropertyInt(XPath xpath, String xpathStr, Element root, int defaultVal)
      Get a single int value pointed to by xpath or defaultVal if not found.
      Parameters:
      xpath - XPath interface
      xpathStr - xpath string
      root - node to start search
      defaultVal - default value
      Returns:
      int value or defaultVal if not found
    • getXMLPropertyIntSize

      public static int getXMLPropertyIntSize(XPath xpath, String xpathStr, Element root, int defaultVal)
    • getXMLPropertyLong

      public static long getXMLPropertyLong(XPath xpath, String xpathStr, Element root, long defaultVal)
      Get a single long value pointed to by xpath or defaultVal if not found.
      Parameters:
      xpath - XPath interface
      xpathStr - xpath string
      root - node to start search
      defaultVal - default value
      Returns:
      long value or defaultVal if not found
    • getXMLPropertyLongSize

      public static long getXMLPropertyLongSize(XPath xpath, String xpathStr, Element root, long defaultVal)
    • getXMLPropertyDouble

      public static double getXMLPropertyDouble(XPath xpath, String xpathStr, Element root, double defaultVal)
      Get a single double value pointed to by xpath or defaultVal if not found.
      Parameters:
      xpath - XPath interface
      xpathStr - xpath string
      root - node to start search
      defaultVal - default value
      Returns:
      double value or defaultVal if not found
    • getXMLPropertyBool

      public static boolean getXMLPropertyBool(XPath xpath, String xpathStr, Element root, boolean defaultVal)
      Get a boolean int value pointed to by xpath or defaultVal if not found.
      Parameters:
      xpath - XPath interface
      xpathStr - xpath string
      root - node to start search
      defaultVal - default value
      Returns:
      boolean value or defaultVal if not found
    • newXPathFactory

      public static XPathFactory newXPathFactory()
      Get a new XPath factory object. There is a bug in certain implementations of the Sun VM that forces an explicit creation of the "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl". This method will try the correct method for creation and if fails will directly create "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl" object.
      Returns:
      XPathFactory or null if not found
    • getVersion

      public static String getVersion(Element root)
      Given a Wowza XML file's root element, parse the version attribute
      Parameters:
      root -
      Returns:
      version or "0" if not specified