summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Clayton <alex.clayton@isode.com>2016-03-21 16:22:56 (GMT)
committerAlex Clayton <alex.clayton@isode.com>2016-03-22 11:32:44 (GMT)
commit9b518dcdd98d694a4464895fce17a3c7a8caf569 (patch)
treef585f40f6ac0c0d829015c68d6d8c8169a4fb252
parent0ec7a2d8ab803b0e2df2c616f61d2b69b042561f (diff)
downloadstroke-9b518dcdd98d694a4464895fce17a3c7a8caf569.zip
stroke-9b518dcdd98d694a4464895fce17a3c7a8caf569.tar.bz2
Tidy XEP-0141 code
As per swiften patch of the same name. This change addresses some feedback the previous XEP-0141 commit. Test-information: Unit tests stil pass. Change-Id: I3a9f9ec93b56352418f8288371bbd6874e01310d
-rw-r--r--src/com/isode/stroke/elements/FormPage.java12
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/FormParser.java11
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java2
3 files changed, 8 insertions, 17 deletions
diff --git a/src/com/isode/stroke/elements/FormPage.java b/src/com/isode/stroke/elements/FormPage.java
index b23a6e2..ffb35a9 100644
--- a/src/com/isode/stroke/elements/FormPage.java
+++ b/src/com/isode/stroke/elements/FormPage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Isode Limited.
+ * Copyright (c) 2015-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -21,7 +21,6 @@ import java.util.Vector;
public class FormPage {
private String label_ = "";
- private String xmlns_ = "";
private Vector<FormText> textElements_ = new Vector<FormText>();
private Vector<FormReportedRef> reportedRefs_ = new Vector<FormReportedRef>();
private Vector<FormSection> childSections_ = new Vector<FormSection>();
@@ -32,7 +31,7 @@ public class FormPage {
* Default Constructor.
*/
public FormPage() {
- this.xmlns_ = "http://jabber.org/protocol/xdata-layout";
+
}
/**
@@ -51,13 +50,6 @@ public class FormPage {
}
/**
- * @return xmlns, Not Null.
- */
- public String getXMLNS() {
- return xmlns_;
- }
-
- /**
* @param textElement, Not Null.
*/
public void addTextElement(FormText textElement) {
diff --git a/src/com/isode/stroke/parser/payloadparsers/FormParser.java b/src/com/isode/stroke/parser/payloadparsers/FormParser.java
index ab14a4e..bbb04c0 100644
--- a/src/com/isode/stroke/parser/payloadparsers/FormParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/FormParser.java
@@ -38,7 +38,6 @@ public class FormParser extends GenericPayloadParser<Form> {
private String currentText_ = "";
private String currentFieldRef_ = "";
private boolean parsingItem_ = false;
- private boolean parseStarted_ = false;
private boolean hasReportedRef_ = false;
private FormText currentTextElement_;
private FormReportedRef currentReportedRef_;
@@ -242,15 +241,15 @@ public class FormParser extends GenericPayloadParser<Form> {
else {
if (currentPages_.size() > 0) {
for (FormPage page : currentPages_) {
- for (String pRef : page.getFieldRefs()) {
- if (pRef.equals(currentField_.getName())) {
+ for (String pageRef : page.getFieldRefs()) {
+ if (pageRef.equals(currentField_.getName())) {
page.addField(currentField_);
}
}
}
for (FormSection section : currentSections_) {
- for (String sRef : section.getFieldRefs()) {
- if (sRef.equals(currentField_.getName())) {
+ for (String sectionRef : section.getFieldRefs()) {
+ if (sectionRef.equals(currentField_.getName())) {
section.addField(currentField_);
}
}
@@ -270,7 +269,7 @@ public class FormParser extends GenericPayloadParser<Form> {
sectionStack_.remove(sectionStack_.size()-1);
}
else if (sectionStack_.size() == 1) {
- // Add the remaining section on the stack to it's parent page
+ // Add the remaining section on the stack to its parent page
currentPage_.addChildSection(sectionStack_.get(sectionStack_.size()-1));
sectionStack_.remove(sectionStack_.size()-1);
}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java
index 262ba3d..4cd80c9 100644
--- a/src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java
+++ b/src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java
@@ -153,7 +153,7 @@ public class FormSerializer extends GenericPayloadSerializer<Form> {
private XMLElement pageToXML(FormPage page) {
XMLElement pageElement = new XMLElement("page");
- pageElement.setAttribute("xmlns", page.getXMLNS());
+ pageElement.setAttribute("xmlns","http://jabber.org/protocol/xdata-layout");
if (!page.getLabel().isEmpty()) {
pageElement.setAttribute("label", page.getLabel());
}