diff options
author | steckbrief <steckbrief@chefmail.de> | 2018-03-29 19:15:56 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2018-03-29 19:15:56 +0200 |
commit | d222611abb64a99f78ce1289532a397849fb91c3 (patch) | |
tree | 0a253aa1a87b80c0e4a99a68e1a3866d53d6ebb7 /src | |
parent | 4ea955d8fe47d6943f7e46f3c8d5485147780609 (diff) |
introduces XmlContainerElement to ease searching for child elements and moves XmlHelper to xml package because it is only needed for xml handling
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/Element.java | 11 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/Tag.java | 2 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/XmlElementContainer.java | 7 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/XmlHelper.java (renamed from src/main/java/de/thedevstack/conversationsplus/utils/XmlHelper.java) | 0 |
4 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/xml/Element.java b/src/main/java/de/thedevstack/conversationsplus/xml/Element.java index 429f98db..23836365 100644 --- a/src/main/java/de/thedevstack/conversationsplus/xml/Element.java +++ b/src/main/java/de/thedevstack/conversationsplus/xml/Element.java @@ -6,7 +6,6 @@ import java.util.List; import de.thedevstack.android.logcat.Logging; import de.thedevstack.conversationsplus.Config; -import de.thedevstack.conversationsplus.utils.XmlHelper; import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException; import de.thedevstack.conversationsplus.xmpp.jid.Jid; @@ -75,6 +74,11 @@ public class Element { return null; } + public Element findChild(XmlElementContainer container) { + Element element = container.getXmlElement(); + return findChild(element.getName(), element.getNamespace()); + } + public String findChildContent(String name, String xmlns) { Element element = findChild(name,xmlns); return element == null ? null : element.getContent(); @@ -88,6 +92,11 @@ public class Element { return findChild(name, xmlns) != null; } + public boolean hasChild(XmlElementContainer container) { + Element element = container.getXmlElement(); + return hasChild(element.getName(), element.getNamespace()); + } + public List<Element> getChildren() { return this.children; } diff --git a/src/main/java/de/thedevstack/conversationsplus/xml/Tag.java b/src/main/java/de/thedevstack/conversationsplus/xml/Tag.java index 84e37363..7072b56f 100644 --- a/src/main/java/de/thedevstack/conversationsplus/xml/Tag.java +++ b/src/main/java/de/thedevstack/conversationsplus/xml/Tag.java @@ -5,8 +5,6 @@ import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; -import de.thedevstack.conversationsplus.utils.XmlHelper; - public class Tag { public static final int NO = -1; public static final int START = 0; diff --git a/src/main/java/de/thedevstack/conversationsplus/xml/XmlElementContainer.java b/src/main/java/de/thedevstack/conversationsplus/xml/XmlElementContainer.java new file mode 100644 index 00000000..543e032d --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/xml/XmlElementContainer.java @@ -0,0 +1,7 @@ +package de.thedevstack.conversationsplus.xml; + +/** + */ +public interface XmlElementContainer { + Element getXmlElement(); +} diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/XmlHelper.java b/src/main/java/de/thedevstack/conversationsplus/xml/XmlHelper.java index 1287f73f..1287f73f 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/XmlHelper.java +++ b/src/main/java/de/thedevstack/conversationsplus/xml/XmlHelper.java |