Package com.mapr.baseutils.utils
Class XmlReader
java.lang.Object
com.mapr.baseutils.utils.XmlReader
Utility class to read the value of an attribute from an XML configuration file. The
configuration file is specified at the time of class instantiation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionUtility method to read the value of an attribute captured under specific tags.Utility method to read the value of an attribute captured under specific tags.Reads the value of an attribute from the configuration file with which the class was initialized.voidLocates a configuration file from the classpath and parses the file.
-
Constructor Details
-
XmlReader
public XmlReader(String resourceName) throws IOException, ParserConfigurationException, SAXException, URISyntaxException
-
-
Method Details
-
init
public void init(String resourceName) throws IOException, ParserConfigurationException, SAXException, URISyntaxException Locates a configuration file from the classpath and parses the file.- Parameters:
resourceName- configuration file from which attribute values are read- Throws:
IOExceptionParserConfigurationExceptionSAXExceptionURISyntaxException
-
getValue
Reads the value of an attribute from the configuration file with which the class was initialized.- Parameters:
attribute- the string representing the attribute whose value needs to be readparentTag- the parent xml node under which the attribute is presentattribTag- the tag that captures the attributevalueTag- the tag that captures the value of the attribute- Returns:
- value of the attribute (if present in the config file)
null, otherwise.
Example:
attribute return_value
-
getValue
Utility method to read the value of an attribute captured under specific tags. Not recommended for general use.- Parameters:
attribute-parentTag-- Returns:
-
getValue
Utility method to read the value of an attribute captured under specific tags. Not recommended for general use.- Parameters:
attribute-parentTag-- Returns:
-