diff options
| author | Alex Clayton <alex.clayton@isode.com> | 2016-03-21 16:22:56 (GMT) |
|---|---|---|
| committer | Alex Clayton <alex.clayton@isode.com> | 2016-03-22 11:32:44 (GMT) |
| commit | 9b518dcdd98d694a4464895fce17a3c7a8caf569 (patch) | |
| tree | f585f40f6ac0c0d829015c68d6d8c8169a4fb252 | |
| parent | 0ec7a2d8ab803b0e2df2c616f61d2b69b042561f (diff) | |
| download | stroke-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
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 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2015 Isode Limited. | 2 | * Copyright (c) 2015-2016 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| @@ -21,7 +21,6 @@ import java.util.Vector; | |||
| 21 | public class FormPage { | 21 | public class FormPage { |
| 22 | 22 | ||
| 23 | private String label_ = ""; | 23 | private String label_ = ""; |
| 24 | private String xmlns_ = ""; | ||
| 25 | private Vector<FormText> textElements_ = new Vector<FormText>(); | 24 | private Vector<FormText> textElements_ = new Vector<FormText>(); |
| 26 | private Vector<FormReportedRef> reportedRefs_ = new Vector<FormReportedRef>(); | 25 | private Vector<FormReportedRef> reportedRefs_ = new Vector<FormReportedRef>(); |
| 27 | private Vector<FormSection> childSections_ = new Vector<FormSection>(); | 26 | private Vector<FormSection> childSections_ = new Vector<FormSection>(); |
| @@ -32,7 +31,7 @@ public class FormPage { | |||
| 32 | * Default Constructor. | 31 | * Default Constructor. |
| 33 | */ | 32 | */ |
| 34 | public FormPage() { | 33 | public FormPage() { |
| 35 | this.xmlns_ = "http://jabber.org/protocol/xdata-layout"; | 34 | |
| 36 | } | 35 | } |
| 37 | 36 | ||
| 38 | /** | 37 | /** |
| @@ -51,13 +50,6 @@ public class FormPage { | |||
| 51 | } | 50 | } |
| 52 | 51 | ||
| 53 | /** | 52 | /** |
| 54 | * @return xmlns, Not Null. | ||
| 55 | */ | ||
| 56 | public String getXMLNS() { | ||
| 57 | return xmlns_; | ||
| 58 | } | ||
| 59 | |||
| 60 | /** | ||
| 61 | * @param textElement, Not Null. | 53 | * @param textElement, Not Null. |
| 62 | */ | 54 | */ |
| 63 | public void addTextElement(FormText textElement) { | 55 | 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> { | |||
| 38 | private String currentText_ = ""; | 38 | private String currentText_ = ""; |
| 39 | private String currentFieldRef_ = ""; | 39 | private String currentFieldRef_ = ""; |
| 40 | private boolean parsingItem_ = false; | 40 | private boolean parsingItem_ = false; |
| 41 | private boolean parseStarted_ = false; | ||
| 42 | private boolean hasReportedRef_ = false; | 41 | private boolean hasReportedRef_ = false; |
| 43 | private FormText currentTextElement_; | 42 | private FormText currentTextElement_; |
| 44 | private FormReportedRef currentReportedRef_; | 43 | private FormReportedRef currentReportedRef_; |
| @@ -242,15 +241,15 @@ public class FormParser extends GenericPayloadParser<Form> { | |||
| 242 | else { | 241 | else { |
| 243 | if (currentPages_.size() > 0) { | 242 | if (currentPages_.size() > 0) { |
| 244 | for (FormPage page : currentPages_) { | 243 | for (FormPage page : currentPages_) { |
| 245 | for (String pRef : page.getFieldRefs()) { | 244 | for (String pageRef : page.getFieldRefs()) { |
| 246 | if (pRef.equals(currentField_.getName())) { | 245 | if (pageRef.equals(currentField_.getName())) { |
| 247 | page.addField(currentField_); | 246 | page.addField(currentField_); |
| 248 | } | 247 | } |
| 249 | } | 248 | } |
| 250 | } | 249 | } |
| 251 | for (FormSection section : currentSections_) { | 250 | for (FormSection section : currentSections_) { |
| 252 | for (String sRef : section.getFieldRefs()) { | 251 | for (String sectionRef : section.getFieldRefs()) { |
| 253 | if (sRef.equals(currentField_.getName())) { | 252 | if (sectionRef.equals(currentField_.getName())) { |
| 254 | section.addField(currentField_); | 253 | section.addField(currentField_); |
| 255 | } | 254 | } |
| 256 | } | 255 | } |
| @@ -270,7 +269,7 @@ public class FormParser extends GenericPayloadParser<Form> { | |||
| 270 | sectionStack_.remove(sectionStack_.size()-1); | 269 | sectionStack_.remove(sectionStack_.size()-1); |
| 271 | } | 270 | } |
| 272 | else if (sectionStack_.size() == 1) { | 271 | else if (sectionStack_.size() == 1) { |
| 273 | // Add the remaining section on the stack to it's parent page | 272 | // Add the remaining section on the stack to its parent page |
| 274 | currentPage_.addChildSection(sectionStack_.get(sectionStack_.size()-1)); | 273 | currentPage_.addChildSection(sectionStack_.get(sectionStack_.size()-1)); |
| 275 | sectionStack_.remove(sectionStack_.size()-1); | 274 | sectionStack_.remove(sectionStack_.size()-1); |
| 276 | } | 275 | } |
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> { | |||
| 153 | 153 | ||
| 154 | private XMLElement pageToXML(FormPage page) { | 154 | private XMLElement pageToXML(FormPage page) { |
| 155 | XMLElement pageElement = new XMLElement("page"); | 155 | XMLElement pageElement = new XMLElement("page"); |
| 156 | pageElement.setAttribute("xmlns", page.getXMLNS()); | 156 | pageElement.setAttribute("xmlns","http://jabber.org/protocol/xdata-layout"); |
| 157 | if (!page.getLabel().isEmpty()) { | 157 | if (!page.getLabel().isEmpty()) { |
| 158 | pageElement.setAttribute("label", page.getLabel()); | 158 | pageElement.setAttribute("label", page.getLabel()); |
| 159 | } | 159 | } |
Swift