aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-20 18:20:42 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-20 18:20:42 +0100
commit0ad6d0616f9663814f6f9f24590833425f6ad372 (patch)
treefa4b9b39accdf10e176b1c34e4f1b4b140cd6eed /src/main/java/eu/siacs/conversations/xmpp/forms/Field.java
parente9948f6b8417803e2856f53482d5a158eb9ffa2e (diff)
brought ad hoc conferences back. fixed #688 fixed #367
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp/forms/Field.java')
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/forms/Field.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java b/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java
new file mode 100644
index 00000000..ee2c51a9
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/xmpp/forms/Field.java
@@ -0,0 +1,50 @@
+package eu.siacs.conversations.xmpp.forms;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import eu.siacs.conversations.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<String> values) {
+ this.children.clear();
+ for(String value : values) {
+ this.addChild("value").setContent(value);
+ }
+ }
+
+ public void removeNonValueChildren() {
+ for(Iterator<Element> 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;
+ }
+}