From 43531113b798cda6b2f76257641f38b0af986437 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 1 Feb 2014 01:25:56 +0100 Subject: more code cleanup for xmpp parser. more eventy. nice unknown contact pictures --- src/de/gultsch/chat/xml/Element.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/de/gultsch/chat/xml') diff --git a/src/de/gultsch/chat/xml/Element.java b/src/de/gultsch/chat/xml/Element.java index d6d1b23d..af3d8f1f 100644 --- a/src/de/gultsch/chat/xml/Element.java +++ b/src/de/gultsch/chat/xml/Element.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import android.util.Log; + public class Element { protected String name; protected Hashtable attributes = new Hashtable(); @@ -26,6 +28,15 @@ public class Element { return this; } + public boolean hasChild(String name) { + for(Element child : this.children) { + if (child.getName().equals(name)) { + return true; + } + } + return false; + } + public Element setAttribute(String name, String value) { this.attributes.put(name, value); return this; @@ -36,6 +47,14 @@ public class Element { return this; } + public String getAttribute(String name) { + if (this.attributes.containsKey(name)) { + return this.attributes.get(name); + } else { + return null; + } + } + public String toString() { StringBuilder elementOutput = new StringBuilder(); if ((content==null)&&(children.size() == 0)) { -- cgit v1.2.3