Package com.wowza.util
Class XMLUtils
Object
com.wowza.util.XMLUtils
XMLUtils: utility class for parsing XML files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic NodegetNodeByTagName(Element node, String name) Return a child Node by tag name.static StringgetNodeValue(Node node) Return the text value of a node.static StringgetNodeValueByTagName(Element node, String name) Get a child Node value by tag name.static StringgetVersion(Element root) Given a Wowza XML file's root element, parse the version attributestatic booleangetXMLPropertyBool(XPath xpath, String xpathStr, Element root, boolean defaultVal) Get a boolean int value pointed to by xpath or defaultVal if not found.static doublegetXMLPropertyDouble(XPath xpath, String xpathStr, Element root, double defaultVal) Get a single double value pointed to by xpath or defaultVal if not found.static booleangetXMLPropertyExists(XPath xpath, String xpathStr, Element root) static intgetXMLPropertyInt(XPath xpath, String xpathStr, Element root, int defaultVal) Get a single int value pointed to by xpath or defaultVal if not found.static intgetXMLPropertyIntSize(XPath xpath, String xpathStr, Element root, int defaultVal) static longgetXMLPropertyLong(XPath xpath, String xpathStr, Element root, long defaultVal) Get a single long value pointed to by xpath or defaultVal if not found.static longgetXMLPropertyLongSize(XPath xpath, String xpathStr, Element root, long defaultVal) static StringgetXMLPropertyStr(XPath xpath, String xpathStr, Element root) Get a single string value pointed to by xpath or null if not found.static StringgetXMLPropertyStr(XPath xpath, String xpathStr, Element root, String defaultVal) Get a single string value pointed to by xpath or defaultVal if not found.static voidloadConfigProperies(Element root, String propertiesXPath, WMSProperties properties) Loads <Properties> elemnt by xpath into properties object.static voidloadConfigProperies(NodeList resultList, WMSProperties properties) Given a nodeList load children as properties.static XPathFactoryGet a new XPath factory object.
-
Constructor Details
-
XMLUtils
public XMLUtils()
-
-
Method Details
-
getNodeValueByTagName
Get a child Node value by tag name. Return null if does not exist.- Parameters:
node- parent nodename- tag name- Returns:
- node value or null if does not exist
-
getNodeByTagName
Return a child Node by tag name. Return null if does not exist.- Parameters:
node- parent nodename- tag name- Returns:
- Node or null if does not exist
-
getNodeValue
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 nodepropertiesXPath- xpath to search for <Properties> elementproperties- properties to add values to
-
loadConfigProperies
Given a nodeList load children as properties.- Parameters:
resultList- node listproperties- properties to add values to
-
getXMLPropertyStr
Get a single string value pointed to by xpath or null if not found.- Parameters:
xpath- XPath interfacexpathStr- xpath stringroot- 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 interfacexpathStr- xpath stringroot- node to start searchdefaultVal- default value- Returns:
- single string value pointed to by xpath or defaultVal if not found
-
getXMLPropertyExists
-
getXMLPropertyInt
Get a single int value pointed to by xpath or defaultVal if not found.- Parameters:
xpath- XPath interfacexpathStr- xpath stringroot- node to start searchdefaultVal- default value- Returns:
- int value or defaultVal if not found
-
getXMLPropertyIntSize
-
getXMLPropertyLong
Get a single long value pointed to by xpath or defaultVal if not found.- Parameters:
xpath- XPath interfacexpathStr- xpath stringroot- node to start searchdefaultVal- default value- Returns:
- long value or defaultVal if not found
-
getXMLPropertyLongSize
-
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 interfacexpathStr- xpath stringroot- node to start searchdefaultVal- 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 interfacexpathStr- xpath stringroot- node to start searchdefaultVal- default value- Returns:
- boolean value or defaultVal if not found
-
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
Given a Wowza XML file's root element, parse the version attribute- Parameters:
root-- Returns:
- version or "0" if not specified
-