Class XMLSystemDataLoader

java.lang.Object
org.deltava.util.system.XMLSystemDataLoader
All Implemented Interfaces:
SystemDataLoader

public class XMLSystemDataLoader extends Object implements SystemDataLoader
A SystemData loader that parses an XML file.
Since:
1.0
Version:
11.1
Author:
Luke
  • Constructor Details

    • XMLSystemDataLoader

      public XMLSystemDataLoader()
  • Method Details

    • load

      public Map<String,Object> load() throws IOException
      Load XML data from the disk. This uses the class loader to load the default file, etc/systemConfig.xml.
      Specified by:
      load in interface SystemDataLoader
      Returns:
      a Map of properties
      Throws:
      FileNotFoundException - if the file cannot be found
      IOException - if an error occurs reading the file
    • getElementWithType

      protected static Object getElementWithType(Element e)
      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

      protected static List<? extends Object> processList(Element root)
      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

      protected static Map<String,Object> processMap(Element root)
      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

      protected void process(String rName, Element re)
      Recusrively process an XML entry that may have child entries.
      Parameters:
      rName - the hierarchical root entry name
      re - the XML element to process