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/Element.java | |
parent | 853f50e43f68599774469dd12240f35800144991 (diff) |
introduces new message state model
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/xml/Element.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/Element.java | 29 |
1 files changed, 27 insertions, 2 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() { |