summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-03-11 11:14:25 (GMT)
committerSwift Review <review@swift.im>2014-05-26 17:16:33 (GMT)
commitdb8568aa6a9bbfa8dca9cdae696e8428a0068d89 (patch)
tree38ab6981542192128711049cb551dc03cf6f97a7 /src/com/isode/stroke/parser/payloadparsers/MAMArchivedParser.java
parentcafd510a0efc9df985999ceded57efa1d411de2e (diff)
downloadstroke-db8568aa6a9bbfa8dca9cdae696e8428a0068d89.zip
stroke-db8568aa6a9bbfa8dca9cdae696e8428a0068d89.tar.bz2
Added MAM parsers, serializers and tests.
Change-Id: I4e5368f9ac86446b7ebf976e2cb63d64ebefe7b2
Diffstat (limited to 'src/com/isode/stroke/parser/payloadparsers/MAMArchivedParser.java')
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/MAMArchivedParser.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/payloadparsers/MAMArchivedParser.java b/src/com/isode/stroke/parser/payloadparsers/MAMArchivedParser.java
new file mode 100644
index 0000000..5547a87
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/MAMArchivedParser.java
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2014 Kevin Smith and Remko Tronçon
+* All rights reserved.
+*/
+
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.MAMArchived;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class MAMArchivedParser extends GenericPayloadParser<MAMArchived> {
+ public MAMArchivedParser() {
+ super(new MAMArchived());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue = attributes.getAttributeValue("by");
+ if (attributeValue != null) {
+ getPayloadInternal().setBy(JID.fromString(attributeValue));
+ }
+ attributeValue = attributes.getAttributeValue("id");
+ if (attributeValue != null) {
+ getPayloadInternal().setID(attributeValue);
+ }
+ }
+
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ }
+
+ public void handleCharacterData(String data) {
+ }
+
+ private int level_;
+}