From 768ec40ad0229804ca1dcc06dc9cdc7c8dab9769 Mon Sep 17 00:00:00 2001 From: Alex Clayton Date: Tue, 19 Aug 2014 13:54:52 +0100 Subject: Add SubjectSerializer Add a SubjectSerializer to Stroke. Test-information: Created a Message object and set its subject. Subject field now turns up in the XMMP telemetry. Change-Id: I7b310d6dc52852e5704696e5e3762bed6a4d53ad diff --git a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java index 9cb3646..ee8ad05 100644 --- a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java +++ b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java @@ -22,7 +22,7 @@ public class FullPayloadSerializerCollection extends PayloadSerializerCollection /*FIXME: Implement what's needed. */ //addSerializer(new IBBSerializer()); addSerializer(new BodySerializer()); - //addSerializer(new SubjectSerializer()); + addSerializer(new SubjectSerializer()); //addSerializer(new ChatStateSerializer()); //addSerializer(new PrioritySerializer()); addSerializer(new ErrorSerializer()); diff --git a/src/com/isode/stroke/serializer/payloadserializers/SubjectSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/SubjectSerializer.java new file mode 100644 index 0000000..885d86c --- /dev/null +++ b/src/com/isode/stroke/serializer/payloadserializers/SubjectSerializer.java @@ -0,0 +1,22 @@ +package com.isode.stroke.serializer.payloadserializers; + +import com.isode.stroke.elements.Subject; +import com.isode.stroke.serializer.GenericPayloadSerializer; +import com.isode.stroke.serializer.xml.XMLTextNode; + +/** + * Subject to String + */ +public class SubjectSerializer extends GenericPayloadSerializer { + + public SubjectSerializer() { + super(Subject.class); + } + + @Override + protected String serializePayload(Subject payload) { + XMLTextNode textNode = new XMLTextNode(payload.getText()); + return ""+textNode.serialize()+""; + } + +} -- cgit v0.10.2-6-g49f6