From 7382e3af9769f76fe4e19934a59e45a3f9858332 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Sun, 3 May 2015 22:25:46 +0200 Subject: renaming eu.siacs.conversations to de.thedevstack.conversationsplus "renaming eu.siacs.conversations to de.thedevstack.conversationsplus" package renaming completed --- .../conversationsplus/xmpp/forms/Field.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/de/thedevstack/conversationsplus/xmpp/forms/Field.java (limited to 'src/main/java/de/thedevstack/conversationsplus/xmpp/forms/Field.java') diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/forms/Field.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/forms/Field.java new file mode 100644 index 00000000..9eb2d08d --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/forms/Field.java @@ -0,0 +1,50 @@ +package de.thedevstack.conversationsplus.xmpp.forms; + +import java.util.Collection; +import java.util.Iterator; + +import de.thedevstack.conversationsplus.xml.Element; + +public class Field extends Element { + + public Field(String name) { + super("field"); + this.setAttribute("var",name); + } + + private Field() { + super("field"); + } + + public String getName() { + return this.getAttribute("var"); + } + + public void setValue(String value) { + this.children.clear(); + this.addChild("value").setContent(value); + } + + public void setValues(Collection values) { + this.children.clear(); + for(String value : values) { + this.addChild("value").setContent(value); + } + } + + public void removeNonValueChildren() { + for(Iterator iterator = this.children.iterator(); iterator.hasNext();) { + Element element = iterator.next(); + if (!element.getName().equals("value")) { + iterator.remove(); + } + } + } + + public static Field parse(Element element) { + Field field = new Field(); + field.setAttributes(element.getAttributes()); + field.setChildren(element.getChildren()); + return field; + } +} -- cgit v1.2.3