1 package de.lathanda.eos.config;
4 import java.util.LinkedList;
5 import javax.xml.parsers.DocumentBuilder;
6 import javax.xml.parsers.DocumentBuilderFactory;
8 import org.w3c.dom.Document;
9 import org.w3c.dom.Node;
10 import org.w3c.dom.NodeList;
14 private LinkedList<Document> docs =
new LinkedList<>();
23 public void load(File base)
throws Exception {
24 File[] configs = base.listFiles((File f) -> {
25 return f.getName().endsWith(
".xml");
27 for (File f : configs) {
28 if (f.exists() && f.isFile()) {
29 DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
30 DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
31 Document doc = dBuilder.parse(f);
38 for (Document doc : docs) {
43 private void apply(Document doc) {
44 NodeList n = doc.getChildNodes();
45 for (
int i = 0; i < n.getLength(); i++) {
46 switch (n.item(i).getNodeName()) {
48 applyTypes(n.item(i));
56 private void applyTypes(Node e) {
57 NodeList n = e.getChildNodes();
58 for (
int i = 0; i < n.getLength(); i++) {
59 switch (n.item(i).getNodeName()) {
61 applyClass(n.item(i));
69 private void applyClass(Node e) {
70 var attributes = e.getAttributes();
71 attributes.getNamedItem(
"class").getNodeValue();
72 attributes.getNamedItem(
"class").getNodeValue();
73 NodeList n = e.getChildNodes();
74 for (
int i = 0; i < n.getLength(); i++) {
75 switch (n.item(i).getNodeName()) {
ConfigLoader getInstance()