Class XMLSystemDataLoader
java.lang.Object
org.deltava.util.system.XMLSystemDataLoader
- All Implemented Interfaces:
SystemDataLoader
A SystemData loader that parses an XML file.
- Since:
- 1.0
- Version:
- 11.1
- Author:
- Luke
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static Object
Return an XML element's value, converted to an object based in the type attribute.load()
Load XML data from the disk.protected void
Recusrively process an XML entry that may have child entries.processList
(Element root) Load a list from an XML element's children.processMap
(Element root) Load a map from an XML element's children.
-
Constructor Details
-
XMLSystemDataLoader
public XMLSystemDataLoader()
-
-
Method Details
-
load
Load XML data from the disk. This uses the class loader to load the default file, etc/systemConfig.xml.- Specified by:
load
in interfaceSystemDataLoader
- Returns:
- a Map of properties
- Throws:
FileNotFoundException
- if the file cannot be foundIOException
- if an error occurs reading the file
-
getElementWithType
Return an XML element's value, converted to an object based in the type attribute. The class specified in this attribute needs to implement a static valueOf(String) method.- Parameters:
e
- the XML element to process- Returns:
- the value of the element, primitives are wrapped within their object
- See Also:
-
processList
Load a list from an XML element's children. The attribute sorted determines if the list will be sorted. The attribute attr provides the name of the child elements to get. Internally, this method uses a Set (HashSet or TreeSet) to ensure that all values are unique. This method calls @link { XMLSystemDataLoader#getElementWithType(Element) } to do type conversions.- Parameters:
root
- the XML element to process- Returns:
- a List of child values
- See Also:
-
processMap
Load a map from an XML element's children. The attribute attr determines the name of the child elements to get. Each of this child elements will be inserted into the map with the value of the child element's key attribute if present; otherwise the child's value will be used as the key. This method calls @link { getElementWithType(Element) } to do type conversions.- Parameters:
root
- the XML element to process- Returns:
- a Map of child values
- See Also:
-
process
-