From d783cec97084a12873ca62b5fcd64620056ec01b Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 19 Nov 2016 23:07:54 +0100 Subject: reformat code --- .../java/de/pixart/messenger/xmpp/forms/Data.java | 174 ++++++++++----------- .../java/de/pixart/messenger/xmpp/forms/Field.java | 116 +++++++------- 2 files changed, 145 insertions(+), 145 deletions(-) (limited to 'src/main/java/de/pixart/messenger/xmpp/forms') diff --git a/src/main/java/de/pixart/messenger/xmpp/forms/Data.java b/src/main/java/de/pixart/messenger/xmpp/forms/Data.java index 8ae70f9c7..f92e468e5 100644 --- a/src/main/java/de/pixart/messenger/xmpp/forms/Data.java +++ b/src/main/java/de/pixart/messenger/xmpp/forms/Data.java @@ -9,91 +9,91 @@ import de.pixart.messenger.xml.Element; public class Data extends Element { - public static final String FORM_TYPE = "FORM_TYPE"; - - public Data() { - super("x"); - this.setAttribute("xmlns","jabber:x:data"); - } - - public List getFields() { - ArrayList fields = new ArrayList(); - for(Element child : getChildren()) { - if (child.getName().equals("field") - && !FORM_TYPE.equals(child.getAttribute("var"))) { - fields.add(Field.parse(child)); - } - } - return fields; - } - - public Field getFieldByName(String needle) { - for(Element child : getChildren()) { - if (child.getName().equals("field") - && needle.equals(child.getAttribute("var"))) { - return Field.parse(child); - } - } - return null; - } - - public void put(String name, String value) { - Field field = getFieldByName(name); - if (field == null) { - field = new Field(name); - this.addChild(field); - } - field.setValue(value); - } - - public void put(String name, Collection values) { - Field field = getFieldByName(name); - if (field == null) { - field = new Field(name); - this.addChild(field); - } - field.setValues(values); - } - - public void submit() { - this.setAttribute("type","submit"); - removeUnnecessaryChildren(); - for(Field field : getFields()) { - field.removeNonValueChildren(); - } - } - - private void removeUnnecessaryChildren() { - for(Iterator iterator = this.children.iterator(); iterator.hasNext();) { - Element element = iterator.next(); - if (!element.getName().equals("field") && !element.getName().equals("title")) { - iterator.remove(); - } - } - } - - public static Data parse(Element element) { - Data data = new Data(); - data.setAttributes(element.getAttributes()); - data.setChildren(element.getChildren()); - return data; - } - - public void setFormType(String formType) { - this.put(FORM_TYPE, formType); - } - - public String getFormType() { - String type = getValue(FORM_TYPE); - return type == null ? "" : type; - } - - public String getValue(String name) { - Field field = this.getFieldByName(name); - return field == null ? null : field.getValue(); - } - - public String getTitle() { - return findChildContent("title"); - } + public static final String FORM_TYPE = "FORM_TYPE"; + + public Data() { + super("x"); + this.setAttribute("xmlns", "jabber:x:data"); + } + + public List getFields() { + ArrayList fields = new ArrayList(); + for (Element child : getChildren()) { + if (child.getName().equals("field") + && !FORM_TYPE.equals(child.getAttribute("var"))) { + fields.add(Field.parse(child)); + } + } + return fields; + } + + public Field getFieldByName(String needle) { + for (Element child : getChildren()) { + if (child.getName().equals("field") + && needle.equals(child.getAttribute("var"))) { + return Field.parse(child); + } + } + return null; + } + + public void put(String name, String value) { + Field field = getFieldByName(name); + if (field == null) { + field = new Field(name); + this.addChild(field); + } + field.setValue(value); + } + + public void put(String name, Collection values) { + Field field = getFieldByName(name); + if (field == null) { + field = new Field(name); + this.addChild(field); + } + field.setValues(values); + } + + public void submit() { + this.setAttribute("type", "submit"); + removeUnnecessaryChildren(); + for (Field field : getFields()) { + field.removeNonValueChildren(); + } + } + + private void removeUnnecessaryChildren() { + for (Iterator iterator = this.children.iterator(); iterator.hasNext(); ) { + Element element = iterator.next(); + if (!element.getName().equals("field") && !element.getName().equals("title")) { + iterator.remove(); + } + } + } + + public static Data parse(Element element) { + Data data = new Data(); + data.setAttributes(element.getAttributes()); + data.setChildren(element.getChildren()); + return data; + } + + public void setFormType(String formType) { + this.put(FORM_TYPE, formType); + } + + public String getFormType() { + String type = getValue(FORM_TYPE); + return type == null ? "" : type; + } + + public String getValue(String name) { + Field field = this.getFieldByName(name); + return field == null ? null : field.getValue(); + } + + public String getTitle() { + return findChildContent("title"); + } } diff --git a/src/main/java/de/pixart/messenger/xmpp/forms/Field.java b/src/main/java/de/pixart/messenger/xmpp/forms/Field.java index 4cf5fc6b7..a05f9538e 100644 --- a/src/main/java/de/pixart/messenger/xmpp/forms/Field.java +++ b/src/main/java/de/pixart/messenger/xmpp/forms/Field.java @@ -9,73 +9,73 @@ import de.pixart.messenger.xml.Element; public class Field extends Element { - public Field(String name) { - super("field"); - this.setAttribute("var",name); - } + public Field(String name) { + super("field"); + this.setAttribute("var", name); + } - private Field() { - super("field"); - } + private Field() { + super("field"); + } - public String getFieldName() { - return this.getAttribute("var"); - } + public String getFieldName() { + return this.getAttribute("var"); + } - public void setValue(String value) { - this.children.clear(); - this.addChild("value").setContent(value); - } + 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 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 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; - } + public static Field parse(Element element) { + Field field = new Field(); + field.setAttributes(element.getAttributes()); + field.setChildren(element.getChildren()); + return field; + } - public String getValue() { - return findChildContent("value"); - } + public String getValue() { + return findChildContent("value"); + } - public List getValues() { - List values = new ArrayList<>(); - for(Element child : getChildren()) { - if ("value".equals(child.getName())) { - String content = child.getContent(); - if (content != null) { - values.add(content); - } - } - } - return values; - } + public List getValues() { + List values = new ArrayList<>(); + for (Element child : getChildren()) { + if ("value".equals(child.getName())) { + String content = child.getContent(); + if (content != null) { + values.add(content); + } + } + } + return values; + } - public String getLabel() { - return getAttribute("label"); - } + public String getLabel() { + return getAttribute("label"); + } - public String getType() { - return getAttribute("type"); - } + public String getType() { + return getAttribute("type"); + } - public boolean isRequired() { - return hasChild("required"); - } + public boolean isRequired() { + return hasChild("required"); + } } -- cgit v1.2.3