aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/xml/Element.java
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-06 19:42:55 +0100
committerlookshe <github@lookshe.org>2016-03-06 19:42:55 +0100
commit3c400703e082a1b180b35d891b8fb3460c7d5b87 (patch)
tree28738dd90fc41b4ab71897f38d324828778ad2e3 /src/main/java/de/thedevstack/conversationsplus/xml/Element.java
parent72114d732427266024cdd6e27cd8d1aa60afae2f (diff)
parentf28d77dc42f6bac5a026e0b1c78562dee8de45ac (diff)
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/xml/Element.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xml/Element.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/xml/Element.java b/src/main/java/de/thedevstack/conversationsplus/xml/Element.java
index 3d2c75b0..429f98db 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xml/Element.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xml/Element.java
@@ -11,15 +11,20 @@ import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
public class Element {
- protected String name;
- protected Hashtable<String, String> attributes = new Hashtable<>();
- protected String content;
+ private final String name;
+ private Hashtable<String, String> attributes = new Hashtable<>();
+ private String content;
protected List<Element> children = new ArrayList<>();
public Element(String name) {
this.name = name;
}
+ public Element(String name, String xmlns) {
+ this.name = name;
+ this.setAttribute("xmlns", xmlns);
+ }
+
public Element addChild(Element child) {
this.content = null;
children.add(child);
@@ -63,10 +68,9 @@ public class Element {
public Element findChild(String name, String xmlns) {
for (Element child : this.children) {
- if (child.getName().equals(name)
- && (child.getAttribute("xmlns").equals(xmlns))) {
+ if (name.equals(child.getName()) && xmlns.equals(child.getAttribute("xmlns"))) {
return child;
- }
+ }
}
return null;
}
@@ -93,7 +97,7 @@ public class Element {
return this;
}
- public String getContent() {
+ public final String getContent() {
return content;
}
@@ -157,7 +161,7 @@ public class Element {
return elementOutput.toString();
}
- public String getName() {
+ public final String getName() {
return name;
}
@@ -177,4 +181,8 @@ public class Element {
String attr = getAttribute(name);
return (attr != null && (attr.equalsIgnoreCase("true") || attr.equalsIgnoreCase("1")));
}
+
+ public String getNamespace() {
+ return getAttribute("xmlns");
+ }
}