summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGurmeen Bindra <gurmeen.bindra@isode.com>2012-04-17 09:18:20 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-04-19 10:45:50 (GMT)
commitb54bc5406f95902ce2438ac64a19390ae0f2f409 (patch)
treea9fcd31575e3773f26a32b74b0793f43ce3a0cd4 /src/com/isode/stroke/serializer/payloadserializers/MUCItemSerializer.java
parentc040dd31cf285f9e2ffddab859586badf6ae059e (diff)
downloadstroke-b54bc5406f95902ce2438ac64a19390ae0f2f409.zip
stroke-b54bc5406f95902ce2438ac64a19390ae0f2f409.tar.bz2
Port MUC Payload Serializers from Swiften to Stroke
All the serializers for different kind of MUC payloads have been ported from swiften to stroke. Test-information: There is a junit test that's ported which tests the admin payload serialiser. Also executed the other MUC Junits.
Diffstat (limited to 'src/com/isode/stroke/serializer/payloadserializers/MUCItemSerializer.java')
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/MUCItemSerializer.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/com/isode/stroke/serializer/payloadserializers/MUCItemSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/MUCItemSerializer.java
new file mode 100644
index 0000000..a3bf80c
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/MUCItemSerializer.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2011, Kevin Smith
+ * All rights reserved.
+ */
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.elements.MUCItem;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.xml.XMLTextNode;
+
+/**
+ * Class representing a serializer for {@link MUCItem}
+ *
+ */
+public class MUCItemSerializer {
+
+ /**
+ * Create an XMLElement from the given MUC Item
+ * @param item MUC Item, not null
+ * @return XML Element, not null
+ */
+ public static XMLElement itemToElement(MUCItem item) {
+ XMLElement itemElement = new XMLElement("item");
+ if (item.affiliation != null) {
+ itemElement.setAttribute("affiliation", item.affiliation.nodeName);
+ }
+ if (item.role != null) {
+ itemElement.setAttribute("role", item.role.nodeName);
+ }
+ if (item.realJID != null) {
+ itemElement.setAttribute("jid", item.realJID.toString());
+ }
+ if (item.nick != null) {
+ itemElement.setAttribute("nick", item.nick);
+ }
+ if (item.actor != null) {
+ XMLElement actorElement = new XMLElement("actor");
+ actorElement.setAttribute("jid", item.actor.toString());
+ itemElement.addNode(actorElement);
+ }
+ if (item.reason != null) {
+ XMLElement reasonElement = new XMLElement("reason");
+ reasonElement.addNode(new XMLTextNode(item.reason));
+ itemElement.addNode(reasonElement);
+ }
+ return itemElement;
+ }
+} \ No newline at end of file