summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMili Verma <mili.verma@isode.com>2012-01-10 15:55:29 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-01-11 13:44:37 (GMT)
commitbe94e872d9423501c688c84c6cb945a420a5cb18 (patch)
tree77986e9e30282b526c0246bb6344c175b54ffb5f /src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java
parentc9ff80a46b13b7d1987bf54cae87738a9baf552b (diff)
downloadstroke-be94e872d9423501c688c84c6cb945a420a5cb18.zip
stroke-be94e872d9423501c688c84c6cb945a420a5cb18.tar.bz2
Update review comment related stuff
This patch addresses some review comments: 1. Updates the Javadoc. 2. Disallows arguments from being null - throws NullPointerException. 3. Updates each test to use its own DummyEventLoop. Test-information: Unit tests pass.
Diffstat (limited to 'src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java')
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java
index 6a3760b..c2a2189 100644
--- a/src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java
+++ b/src/com/isode/stroke/serializer/payloadserializers/FormSerializer.java
@@ -42,6 +42,10 @@ public class FormSerializer extends GenericPayloadSerializer<Form> {
}
public String serializePayload(Form form) {
+ if (form == null) {
+ throw new NullPointerException("'form' must not be null");
+ }
+
XMLElement formElement = new XMLElement("x", "jabber:x:data");
String type = form.getType().getStringForm();
formElement.setAttribute(Form.FORM_ATTRIBUTE_TYPE, type);
@@ -59,6 +63,10 @@ public class FormSerializer extends GenericPayloadSerializer<Form> {
}
private XMLElement fieldToXML(FormField field) {
+ if (field == null) {
+ throw new NullPointerException("'field' must not be null");
+ }
+
XMLElement fieldElement = new XMLElement(Form.FORM_ELEMENT_FIELD);
if (!field.getName().isEmpty()) {
fieldElement.setAttribute(FormField.FORM_FIELD_ATTRIBUTE_VAR, field
@@ -164,6 +172,13 @@ public class FormSerializer extends GenericPayloadSerializer<Form> {
private void multiLineify(String text, String elementName,
XMLElement element) {
+ if (text == null) {
+ throw new NullPointerException("'text' must not be null");
+ }
+ if (elementName == null) {
+ throw new NullPointerException("'elementName' must not be null");
+ }
+
String unRdText = text.replaceAll("\r", "");
String[] lines = unRdText.split("\n");
for (String line : lines) {