diff options
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; |