diff --git a/core/src/main/java/com/openeggbert/core/fbox/api/FBoxUtilsInterface.java b/core/src/main/java/com/openeggbert/core/fbox/api/FBoxUtilsInterface.java
index be17bd9..ae0b098 100644
--- a/core/src/main/java/com/openeggbert/core/fbox/api/FBoxUtilsInterface.java
+++ b/core/src/main/java/com/openeggbert/core/fbox/api/FBoxUtilsInterface.java
@@ -24,5 +24,5 @@ package com.openeggbert.core.fbox.api;
* @author robertvokac
*/
public interface FBoxUtilsInterface {
-
+ XmlElement parseXml(String xmlString);
}
diff --git a/core/src/main/java/com/openeggbert/core/fbox/api/XmlElement.java b/core/src/main/java/com/openeggbert/core/fbox/api/XmlElement.java
new file mode 100644
index 0000000..e74da08
--- /dev/null
+++ b/core/src/main/java/com/openeggbert/core/fbox/api/XmlElement.java
@@ -0,0 +1,33 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+package com.openeggbert.core.fbox.api;
+
+/**
+ *
+ * @author robertvokac
+ */
+public interface XmlElement {
+ XmlElement getChildByName(String name);
+ String get(String elementName);
+ int getChildCount();
+ XmlElement getChild(int i);
+ String getText();
+
+}
diff --git a/core/src/main/java/com/openeggbert/core/fbox/impl/libgdx/ElementLibGDXImpl.java b/core/src/main/java/com/openeggbert/core/fbox/impl/libgdx/ElementLibGDXImpl.java
new file mode 100644
index 0000000..d159bd9
--- /dev/null
+++ b/core/src/main/java/com/openeggbert/core/fbox/impl/libgdx/ElementLibGDXImpl.java
@@ -0,0 +1,62 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+package com.openeggbert.core.fbox.impl.libgdx;
+
+import com.badlogic.gdx.utils.XmlReader;
+import com.openeggbert.core.fbox.api.XmlElement;
+
+/**
+ *
+ * @author robertvokac
+ */
+public class ElementLibGDXImpl implements XmlElement {
+
+ private final XmlReader.Element element;
+
+ public ElementLibGDXImpl(com.badlogic.gdx.utils.XmlReader.Element element) {
+ this.element = element;
+ }
+
+ @Override
+ public XmlElement getChildByName(String name) {
+ XmlReader.Element child = element.getChildByName(name);
+ return child == null ? null : new ElementLibGDXImpl(child);
+ }
+
+ @Override
+ public String get(String elementName) {
+ return element.get(elementName);
+ }
+
+ @Override
+ public int getChildCount() {
+ return element.getChildCount();
+ }
+
+ @Override
+ public XmlElement getChild(int i) {
+ XmlReader.Element child = element.getChild(i);
+ return child == null ? null : new ElementLibGDXImpl(child); }
+
+ @Override
+ public String getText() {
+ return element.getText();
+ }
+}
diff --git a/core/src/main/java/com/openeggbert/core/fbox/impl/libgdx/FBoxUtilsLibGDXImpl.java b/core/src/main/java/com/openeggbert/core/fbox/impl/libgdx/FBoxUtilsLibGDXImpl.java
index 2643537..1d9df69 100644
--- a/core/src/main/java/com/openeggbert/core/fbox/impl/libgdx/FBoxUtilsLibGDXImpl.java
+++ b/core/src/main/java/com/openeggbert/core/fbox/impl/libgdx/FBoxUtilsLibGDXImpl.java
@@ -19,7 +19,9 @@
///////////////////////////////////////////////////////////////////////////////////////////////
package com.openeggbert.core.fbox.impl.libgdx;
+import com.badlogic.gdx.utils.XmlReader;
import com.openeggbert.core.fbox.api.FBoxUtilsInterface;
+import com.openeggbert.core.fbox.api.XmlElement;
/**
*
@@ -27,6 +29,13 @@ import com.openeggbert.core.fbox.api.FBoxUtilsInterface;
*/
public class FBoxUtilsLibGDXImpl implements FBoxUtilsInterface {
+ @Override
+ public XmlElement parseXml(String xmlString) {
+ XmlReader.Element root = new XmlReader().parse(xmlString);
+ return new ElementLibGDXImpl(root);
+
+ }
+
}
diff --git a/core/src/main/java/com/openeggbert/core/mod/Mod.java b/core/src/main/java/com/openeggbert/core/mod/Mod.java
index aacdb0b..bbb84b2 100644
--- a/core/src/main/java/com/openeggbert/core/mod/Mod.java
+++ b/core/src/main/java/com/openeggbert/core/mod/Mod.java
@@ -19,8 +19,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////
package com.openeggbert.core.mod;
-import com.badlogic.gdx.utils.XmlReader;
-import com.badlogic.gdx.utils.XmlReader.Element;
+import com.openeggbert.core.fbox.api.XmlElement;
+import com.openeggbert.core.fbox.core.FBox;
import com.openeggbert.core.release.Release;
import java.util.ArrayList;
import java.util.List;
@@ -34,8 +34,8 @@ import lombok.Data;
public class Mod {
public Mod(String xml) {
- Element root = new XmlReader().parse(xml);
- Element parentElement = root.getChildByName("parent");
+ XmlElement root = FBox.get().utils().parseXml(xml);
+ XmlElement parentElement = root.getChildByName("parent");
if (parentElement != null) {
parent = new ModIdentification(parentElement);
}
@@ -48,25 +48,25 @@ public class Mod {
featureLevel = Release.valueOf(root.get("featureLevel"));
name = root.get("name");
description = root.get("description");
- Element imports = root.getChildByName("imports");
+ XmlElement imports = root.getChildByName("imports");
if (imports != null) {
for (int i = 0; i < imports.getChildCount(); i++) {
- Element import_ = imports.getChild(i);
+ XmlElement import_ = imports.getChild(i);
importedMods.add(new ModIdentification(import_));
}
}
- Element files_ = root.getChildByName("files");
+ XmlElement files_ = root.getChildByName("files");
if (files_ != null) {
for (int i = 0; i < files_.getChildCount(); i++) {
- Element file = files_.getChild(i);
+ XmlElement file = files_.getChild(i);
files.add(file.getText());
}
}
- Element stores_ = root.getChildByName("stores");
+ XmlElement stores_ = root.getChildByName("stores");
if (stores_ != null) {
for (int i = 0; i < stores_.getChildCount(); i++) {
- Element store = stores_.getChild(i);
+ XmlElement store = stores_.getChild(i);
stores.add(new Store(store));
}
}
diff --git a/core/src/main/java/com/openeggbert/core/mod/ModIdentification.java b/core/src/main/java/com/openeggbert/core/mod/ModIdentification.java
index 753fe68..d80be93 100644
--- a/core/src/main/java/com/openeggbert/core/mod/ModIdentification.java
+++ b/core/src/main/java/com/openeggbert/core/mod/ModIdentification.java
@@ -19,7 +19,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////
package com.openeggbert.core.mod;
-import com.badlogic.gdx.utils.XmlReader.Element;
+import com.openeggbert.core.fbox.api.XmlElement;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -35,7 +35,7 @@ public class ModIdentification {
private final String modId;
private final String version;
- public ModIdentification(Element element) {
+ public ModIdentification(XmlElement element) {
groupId = element.get("groupId");
modId = element.get("modId");
version = element.get("version");
diff --git a/core/src/main/java/com/openeggbert/core/mod/Store.java b/core/src/main/java/com/openeggbert/core/mod/Store.java
index f56737d..a4a60fb 100644
--- a/core/src/main/java/com/openeggbert/core/mod/Store.java
+++ b/core/src/main/java/com/openeggbert/core/mod/Store.java
@@ -19,7 +19,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////
package com.openeggbert.core.mod;
-import com.badlogic.gdx.utils.XmlReader;
+import com.openeggbert.core.fbox.api.XmlElement;
/**
*
@@ -31,7 +31,7 @@ public class Store {
String name;
String url;
- Store(XmlReader.Element store) {
+ Store(XmlElement store) {
id = store.get("id");
name = store.get("name");
url = store.get("url");