diff options
author | lookshe <github@lookshe.org> | 2016-03-06 19:42:55 +0100 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2016-03-06 19:42:55 +0100 |
commit | 3c400703e082a1b180b35d891b8fb3460c7d5b87 (patch) | |
tree | 28738dd90fc41b4ab71897f38d324828778ad2e3 /src/main/java/de/thedevstack/conversationsplus/xml | |
parent | 72114d732427266024cdd6e27cd8d1aa60afae2f (diff) | |
parent | f28d77dc42f6bac5a026e0b1c78562dee8de45ac (diff) |
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/xml')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/Element.java | 24 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java | 14 |
2 files changed, 23 insertions, 15 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"); + } } diff --git a/src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java b/src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java index 35425816..e02f4fc0 100644 --- a/src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java +++ b/src/main/java/de/thedevstack/conversationsplus/xml/XmlReader.java @@ -1,19 +1,19 @@ package de.thedevstack.conversationsplus.xml; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import android.os.PowerManager; +import android.os.PowerManager.WakeLock; +import android.util.Xml; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + import de.thedevstack.android.logcat.Logging; import de.thedevstack.conversationsplus.Config; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock; -import android.util.Xml; - public class XmlReader { private XmlPullParser parser; private PowerManager.WakeLock wakeLock; |