diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-28 18:46:01 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-28 18:46:01 +0100 |
commit | acf80bddd07d5579cdb20a888b3f9e99e53030a5 (patch) | |
tree | 034a8e364488c89c8e1997f56313d919019afa65 /src/de/gultsch/chat/xml/Element.java | |
parent | 03d96266f8bbb76e25610e903d74a0afa7dcd03b (diff) |
rebranding
Diffstat (limited to 'src/de/gultsch/chat/xml/Element.java')
-rw-r--r-- | src/de/gultsch/chat/xml/Element.java | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/src/de/gultsch/chat/xml/Element.java b/src/de/gultsch/chat/xml/Element.java deleted file mode 100644 index 01deb1d2..00000000 --- a/src/de/gultsch/chat/xml/Element.java +++ /dev/null @@ -1,101 +0,0 @@ -package de.gultsch.chat.xml; - -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; - -import android.util.Log; - -public class Element { - protected String name; - protected Hashtable<String, String> attributes = new Hashtable<String, String>(); - protected String content; - protected List<Element> children = new ArrayList<Element>(); - - public Element(String name) { - this.name = name; - } - - public Element addChild(Element child) { - this.content = null; - children.add(child); - return this; - } - - public Element setContent(String content) { - this.content = content; - this.children.clear(); - return this; - } - - public Element findChild(String name) { - for(Element child : this.children) { - if (child.getName().equals(name)) { - return child; - } - } - return null; - } - - public boolean hasChild(String name) { - for(Element child : this.children) { - if (child.getName().equals(name)) { - return true; - } - } - return false; - } - - public List<Element> getChildren() { - return this.children; - } - - public String getContent() { - return content; - } - - public Element setAttribute(String name, String value) { - this.attributes.put(name, value); - return this; - } - - public Element setAttributes(Hashtable<String, String> attributes) { - this.attributes = attributes; - 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)) { - Tag emptyTag = Tag.empty(name); - emptyTag.setAtttributes(this.attributes); - elementOutput.append(emptyTag.toString()); - } else { - Tag startTag = Tag.start(name); - startTag.setAtttributes(this.attributes); - elementOutput.append(startTag); - if (content!=null) { - elementOutput.append(content); - } else { - for(Element child : children) { - elementOutput.append(child.toString()); - } - } - Tag endTag = Tag.end(name); - elementOutput.append(endTag); - } - return elementOutput.toString(); - } - - public String getName() { - return name; - } -} |