diff options
author | steckbrief <steckbrief@chefmail.de> | 2018-05-05 20:28:04 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2018-05-06 13:46:22 +0200 |
commit | 132b27adeef3ab4d305facda7dd035015b00766f (patch) | |
tree | ce90c05d96d747ea1f6cf80129462119a1291dc1 /src/main/java/de/thedevstack/conversationsplus/xml | |
parent | 853f50e43f68599774469dd12240f35800144991 (diff) |
introduces new message state model
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/xml')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/Element.java | 29 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/XmlHelper.java | 2 |
2 files changed, 28 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 23836365..0b8c2035 100644 --- a/src/main/java/de/thedevstack/conversationsplus/xml/Element.java +++ b/src/main/java/de/thedevstack/conversationsplus/xml/Element.java @@ -74,6 +74,22 @@ public class Element { return null; } + public Element findChildRecursive(String name, String xmlns) { + Element foundChild = null; + for (Element child : this.children) { + if (name.equals(child.getName()) && xmlns.equals(child.getAttribute("xmlns"))) { + foundChild = child; + break; + } else { + foundChild = findChildRecursive(name, xmlns); + if (null != foundChild) { + break; + } + } + } + return foundChild; + } + public Element findChild(XmlElementContainer container) { Element element = container.getXmlElement(); return findChild(element.getName(), element.getNamespace()); @@ -92,9 +108,18 @@ public class Element { return findChild(name, xmlns) != null; } - public boolean hasChild(XmlElementContainer container) { + public boolean hasChildRecursive(String name, String xmlns) { + return null != findChildRecursive(name, xmlns); + } + + public boolean hasChildRecursive(XmlElementContainer container) { + Element element = container.getXmlElement(); + return hasChildRecursive(element.getName(), element.getNamespace()); + } + + public boolean hasChild(XmlElementContainer container) { Element element = container.getXmlElement(); - return hasChild(element.getName(), element.getNamespace()); + return hasChild(element.getName(), element.getNamespace()); } public List<Element> getChildren() { diff --git a/src/main/java/de/thedevstack/conversationsplus/xml/XmlHelper.java b/src/main/java/de/thedevstack/conversationsplus/xml/XmlHelper.java index 1287f73f..36a536aa 100644 --- a/src/main/java/de/thedevstack/conversationsplus/xml/XmlHelper.java +++ b/src/main/java/de/thedevstack/conversationsplus/xml/XmlHelper.java @@ -1,4 +1,4 @@ -package de.thedevstack.conversationsplus.utils; +package de.thedevstack.conversationsplus.xml; public class XmlHelper { public static String encodeEntities(String content) { |