summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-06-19 05:56:31 (GMT)
committerTarun Gupta <tarun1995gupta@gmail.com>2015-06-23 14:55:01 (GMT)
commit27212e007077418d18014286a46723fa26693864 (patch)
tree7e70d70f760a2d35617ec8d17c7d6b322a8c3c16 /src
parentbc9dade982d8e8efe66c0fc814dafd8bf079e689 (diff)
downloadstroke-27212e007077418d18014286a46723fa26693864.zip
stroke-27212e007077418d18014286a46723fa26693864.tar.bz2
Adds Carbons Element.
Adds: CarbonsDisable Element, its Parser and Serializer. CarbonsEnable Element, its Parser and Serializer. CarbonsPrivate Element, its Parser and Serializer. CarbonsReceived Element, its Parser and Serializer. CarbonsSent Element, its Parser and Serializer. Thread Element, its Parser and Serializer. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Tests added for CarbonsParser and CarbonsSerializers, which tests all the above functionalities and passes. Change-Id: I101b1b34c24515d5ba19a995254755af77c4e6e1
Diffstat (limited to 'src')
-rw-r--r--src/com/isode/stroke/elements/CarbonsDisable.java19
-rw-r--r--src/com/isode/stroke/elements/CarbonsEnable.java19
-rw-r--r--src/com/isode/stroke/elements/CarbonsPrivate.java19
-rw-r--r--src/com/isode/stroke/elements/CarbonsReceived.java43
-rw-r--r--src/com/isode/stroke/elements/CarbonsSent.java43
-rw-r--r--src/com/isode/stroke/elements/Thread.java78
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/CarbonsDisableParser.java51
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/CarbonsEnableParser.java51
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/CarbonsPrivateParser.java51
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/CarbonsReceivedParser.java80
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/CarbonsSentParser.java80
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java6
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/ThreadParser.java69
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/CarbonsDisableSerializer.java30
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/CarbonsEnableSerializer.java30
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/CarbonsPrivateSerializer.java30
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/CarbonsReceivedSerializer.java37
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/CarbonsSentSerializer.java37
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java7
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/ThreadSerializer.java33
20 files changed, 813 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/CarbonsDisable.java b/src/com/isode/stroke/elements/CarbonsDisable.java
new file mode 100644
index 0000000..d88d14f
--- /dev/null
+++ b/src/com/isode/stroke/elements/CarbonsDisable.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class CarbonsDisable extends Payload {
+
+
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/elements/CarbonsEnable.java b/src/com/isode/stroke/elements/CarbonsEnable.java
new file mode 100644
index 0000000..a637439
--- /dev/null
+++ b/src/com/isode/stroke/elements/CarbonsEnable.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class CarbonsEnable extends Payload {
+
+
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/elements/CarbonsPrivate.java b/src/com/isode/stroke/elements/CarbonsPrivate.java
new file mode 100644
index 0000000..bf8e473
--- /dev/null
+++ b/src/com/isode/stroke/elements/CarbonsPrivate.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class CarbonsPrivate extends Payload {
+
+
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/elements/CarbonsReceived.java b/src/com/isode/stroke/elements/CarbonsReceived.java
new file mode 100644
index 0000000..5e36583
--- /dev/null
+++ b/src/com/isode/stroke/elements/CarbonsReceived.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+import com.isode.stroke.elements.Forwarded;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsReceived extends Payload {
+
+ private Forwarded forwarded_;
+
+ /**
+ * Default Constructor.
+ */
+ public CarbonsReceived() {
+
+ }
+
+ /**
+ * @param forwarded, Not Null.
+ */
+ public void setForwarded(Forwarded forwarded) {
+ NotNull.exceptIfNull(forwarded, "forwarded");
+ forwarded_ = forwarded;
+ }
+
+ /**
+ * @return forwarded, Not Null.
+ */
+ public Forwarded getForwarded() {
+ return forwarded_;
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/elements/CarbonsSent.java b/src/com/isode/stroke/elements/CarbonsSent.java
new file mode 100644
index 0000000..1d7d846
--- /dev/null
+++ b/src/com/isode/stroke/elements/CarbonsSent.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+import com.isode.stroke.elements.Forwarded;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsSent extends Payload {
+
+ private Forwarded forwarded_;
+
+ /**
+ * Default Constructor.
+ */
+ public CarbonsSent() {
+
+ }
+
+ /**
+ * @param forwarded, Not Null.
+ */
+ public void setForwarded(Forwarded forwarded) {
+ NotNull.exceptIfNull(forwarded, "forwarded");
+ forwarded_ = forwarded;
+ }
+
+ /**
+ * @return forwarded, Not Null.
+ */
+ public Forwarded getForwarded() {
+ return forwarded_;
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/elements/Thread.java b/src/com/isode/stroke/elements/Thread.java
new file mode 100644
index 0000000..40eeb8b
--- /dev/null
+++ b/src/com/isode/stroke/elements/Thread.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+import com.isode.stroke.base.NotNull;
+
+public class Thread extends Payload {
+
+ private String text_ = "";
+ private String parent_ = "";
+
+ /**
+ * Default Constructor.
+ */
+ public Thread() {
+ this("", "");
+ }
+
+ /**
+ * Parameterized Constructor.
+ * @param text, Not Null.
+ */
+ public Thread(String text) {
+ this(text, "");
+ }
+
+ /**
+ * Parameterized Constructor.
+ * @param text, Not Null.
+ * @param parent, not Null.
+ */
+ public Thread(String text, String parent) {
+ NotNull.exceptIfNull(text, "text");
+ NotNull.exceptIfNull(parent, "parent");
+ this.text_ = text;
+ this.parent_ = parent;
+ }
+
+ /**
+ * @param text, not Null.
+ */
+ public void setText(String text) {
+ NotNull.exceptIfNull(text, "text");
+ text_ = text;
+ }
+
+ /**
+ * @return text, not Null.
+ */
+ public String getText() {
+ return text_;
+ }
+
+ /**
+ * @param parent, not Null.
+ */
+ public void setParent(String parent) {
+ NotNull.exceptIfNull(parent, "parent");
+ parent_ = parent;
+ }
+
+ /**
+ * @return parent, not Null.
+ */
+ public String getParent() {
+ return parent_;
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/parser/payloadparsers/CarbonsDisableParser.java b/src/com/isode/stroke/parser/payloadparsers/CarbonsDisableParser.java
new file mode 100644
index 0000000..e61a0c6
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/CarbonsDisableParser.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.elements.CarbonsDisable;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsDisableParser extends GenericPayloadParser<CarbonsDisable> {
+
+ public CarbonsDisableParser() {
+ super(new CarbonsDisable());
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ * @param attributes.
+ */
+ @Override
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ */
+ @Override
+ public void handleEndElement(String element, String ns) {
+
+ }
+
+ /**
+ * @param data.
+ */
+ @Override
+ public void handleCharacterData(String data) {
+
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/parser/payloadparsers/CarbonsEnableParser.java b/src/com/isode/stroke/parser/payloadparsers/CarbonsEnableParser.java
new file mode 100644
index 0000000..39240a7
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/CarbonsEnableParser.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.elements.CarbonsEnable;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsEnableParser extends GenericPayloadParser<CarbonsEnable> {
+
+ public CarbonsEnableParser() {
+ super(new CarbonsEnable());
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ * @param attributes.
+ */
+ @Override
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ */
+ @Override
+ public void handleEndElement(String element, String ns) {
+
+ }
+
+ /**
+ * @param data.
+ */
+ @Override
+ public void handleCharacterData(String data) {
+
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/parser/payloadparsers/CarbonsPrivateParser.java b/src/com/isode/stroke/parser/payloadparsers/CarbonsPrivateParser.java
new file mode 100644
index 0000000..be8df74
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/CarbonsPrivateParser.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.elements.CarbonsPrivate;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsPrivateParser extends GenericPayloadParser<CarbonsPrivate> {
+
+ public CarbonsPrivateParser() {
+ super(new CarbonsPrivate());
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ * @param attributes.
+ */
+ @Override
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ */
+ @Override
+ public void handleEndElement(String element, String ns) {
+
+ }
+
+ /**
+ * @param data.
+ */
+ @Override
+ public void handleCharacterData(String data) {
+
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/parser/payloadparsers/CarbonsReceivedParser.java b/src/com/isode/stroke/parser/payloadparsers/CarbonsReceivedParser.java
new file mode 100644
index 0000000..e5ba2b6
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/CarbonsReceivedParser.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.payloadparsers.ForwardedParser;
+import com.isode.stroke.elements.CarbonsReceived;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsReceivedParser extends GenericPayloadParser<CarbonsReceived> {
+
+ private final int TopLevel = 0;
+ private final int PayloadLevel = 1;
+ private int level_ = TopLevel;
+ private PayloadParserFactoryCollection factories_;
+ private ForwardedParser forwardedParser_;
+
+ public CarbonsReceivedParser(PayloadParserFactoryCollection factories) {
+ super(new CarbonsReceived());
+ this.factories_ = factories;
+ this.level_ = TopLevel;
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ * @param attributes.
+ */
+ @Override
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ NotNull.exceptIfNull(element, "element");
+ if (level_ == PayloadLevel) {
+ if (element.equals("forwarded")) {
+ forwardedParser_ = (ForwardedParser)(new ForwardedParser(factories_));
+ }
+ }
+ if (forwardedParser_ != null) {
+ forwardedParser_.handleStartElement(element, ns, attributes);
+ }
+ ++level_;
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ */
+ @Override
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ if (forwardedParser_ != null && level_ >= PayloadLevel) {
+ forwardedParser_.handleEndElement(element, ns);
+ }
+ if (forwardedParser_ != null && level_ == PayloadLevel) {
+ /* done parsing nested stanza */
+ getPayloadInternal().setForwarded(forwardedParser_.getPayloadInternal());
+ forwardedParser_ = null;
+ }
+ }
+
+ /**
+ * @param data.
+ */
+ @Override
+ public void handleCharacterData(String data) {
+ if (forwardedParser_ != null) {
+ forwardedParser_.handleCharacterData(data);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/parser/payloadparsers/CarbonsSentParser.java b/src/com/isode/stroke/parser/payloadparsers/CarbonsSentParser.java
new file mode 100644
index 0000000..879e580
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/CarbonsSentParser.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.payloadparsers.ForwardedParser;
+import com.isode.stroke.elements.CarbonsSent;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsSentParser extends GenericPayloadParser<CarbonsSent> {
+
+ private final int TopLevel = 0;
+ private final int PayloadLevel = 1;
+ private int level_ = TopLevel;
+ private PayloadParserFactoryCollection factories_;
+ private ForwardedParser forwardedParser_;
+
+ public CarbonsSentParser(PayloadParserFactoryCollection factories) {
+ super(new CarbonsSent());
+ this.factories_ = factories;
+ this.level_ = TopLevel;
+ }
+
+ /**
+ * @param element, NotNull.
+ * @param ns.
+ * @param attributes.
+ */
+ @Override
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ NotNull.exceptIfNull(element, "element");
+ if (level_ == PayloadLevel) {
+ if (element.equals("forwarded")) {
+ forwardedParser_ = (ForwardedParser)(new ForwardedParser(factories_));
+ }
+ }
+ if (forwardedParser_ != null) {
+ forwardedParser_.handleStartElement(element, ns, attributes);
+ }
+ ++level_;
+ }
+
+ /**
+ * @param element.
+ * @param ns.
+ */
+ @Override
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ if (forwardedParser_ != null && level_ >= PayloadLevel) {
+ forwardedParser_.handleEndElement(element, ns);
+ }
+ if (forwardedParser_ != null && level_ == PayloadLevel) {
+ /* done parsing nested stanza */
+ getPayloadInternal().setForwarded(forwardedParser_.getPayloadInternal());
+ forwardedParser_ = null;
+ }
+ }
+
+ /**
+ * @param data.
+ */
+ @Override
+ public void handleCharacterData(String data) {
+ if (forwardedParser_ != null) {
+ forwardedParser_.handleCharacterData(data);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
index f5ae485..d6d6483 100644
--- a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
+++ b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
@@ -14,6 +14,11 @@ public class FullPayloadParserFactoryCollection extends PayloadParserFactoryColl
public FullPayloadParserFactoryCollection() {
/* TODO: Port more */
//addFactory(new GenericPayloadParserFactory<IBBParser>("", "http://jabber.org/protocol/ibb"));
+ addFactory(new GenericPayloadParserFactory<CarbonsDisableParser>("disable", "urn:xmpp:carbons:2", CarbonsDisableParser.class));
+ addFactory(new GenericPayloadParserFactory<CarbonsEnableParser>("enable", "urn:xmpp:carbons:2", CarbonsEnableParser.class));
+ addFactory(new GenericPayloadParserFactory<CarbonsPrivateParser>("private", "urn:xmpp:carbons:2", CarbonsPrivateParser.class));
+ addFactory(new GenericPayloadParserFactory2<CarbonsReceivedParser>("received", "urn:xmpp:carbons:2", this, CarbonsReceivedParser.class));
+ addFactory(new GenericPayloadParserFactory2<CarbonsSentParser>("sent", "urn:xmpp:carbons:2", this, CarbonsSentParser.class));
addFactory(new GenericPayloadParserFactory<StatusShowParser>("show", StatusShowParser.class));
addFactory(new GenericPayloadParserFactory<StatusParser>("status", StatusParser.class));
addFactory(new GenericPayloadParserFactory<ReplaceParser>("replace", "http://swift.im/protocol/replace", ReplaceParser.class));
@@ -50,6 +55,7 @@ public class FullPayloadParserFactoryCollection extends PayloadParserFactoryColl
addFactory(new GenericPayloadParserFactory<InBandRegistrationPayloadParser>("query", "jabber:iq:register", InBandRegistrationPayloadParser.class));
addFactory(new SearchPayloadParserFactory());
//addFactory(new StreamInitiationParserFactory());
+ addFactory(new GenericPayloadParserFactory<ThreadParser>("thread", ThreadParser.class));
addFactory(new GenericPayloadParserFactory<BytestreamsParser>("query", "http://jabber.org/protocol/bytestreams", BytestreamsParser.class));
addFactory(new GenericPayloadParserFactory<VCardUpdateParser>("x", "vcard-temp:x:update", VCardUpdateParser.class));
addFactory(new GenericPayloadParserFactory<VCardParser>("vCard", "vcard-temp", VCardParser.class));
diff --git a/src/com/isode/stroke/parser/payloadparsers/ThreadParser.java b/src/com/isode/stroke/parser/payloadparsers/ThreadParser.java
new file mode 100644
index 0000000..094e1e5
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/ThreadParser.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.elements.Thread;
+import com.isode.stroke.base.NotNull;
+
+public class ThreadParser extends GenericPayloadParser<Thread> {
+
+ private int level_ = 0;
+ private String text_ = "";
+
+ public ThreadParser() {
+ super(new Thread());
+ }
+
+ /**
+ * @param element, NotNull.
+ * @param ns.
+ * @param attributes, NotNull.
+ */
+ @Override
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ NotNull.exceptIfNull(element, "element");
+ NotNull.exceptIfNull(attributes, "attributes");
+ ++level_;
+ if (element.equals("thread")) {
+ if(attributes.getAttributeValue("parent") != null) {
+ getPayloadInternal().setParent(attributes.getAttributeValue("parent"));
+ } else {
+ getPayloadInternal().setParent("");
+ }
+ }
+ }
+
+ /**
+ * @param element, NotNull.
+ * @param ns.
+ */
+ @Override
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ if (level_ == 0) {
+ getPayloadInternal().setText(text_);
+ }
+ }
+
+ /**
+ * @param data, NotNull.
+ */
+ @Override
+ public void handleCharacterData(String data) {
+ NotNull.exceptIfNull(data, "data");
+ if (level_ == 1) {
+ text_ += data;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/serializer/payloadserializers/CarbonsDisableSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/CarbonsDisableSerializer.java
new file mode 100644
index 0000000..94cb014
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/CarbonsDisableSerializer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.xml.XMLTextNode;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.CarbonsDisable;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsDisableSerializer extends GenericPayloadSerializer<CarbonsDisable> {
+
+ public CarbonsDisableSerializer() {
+ super(CarbonsDisable.class);
+ }
+
+ public String serializePayload(CarbonsDisable payload) {
+ XMLElement element = new XMLElement("disable", "urn:xmpp:carbons:2");
+ return element.serialize();
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/serializer/payloadserializers/CarbonsEnableSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/CarbonsEnableSerializer.java
new file mode 100644
index 0000000..f88e461
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/CarbonsEnableSerializer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.xml.XMLTextNode;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.CarbonsEnable;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsEnableSerializer extends GenericPayloadSerializer<CarbonsEnable> {
+
+ public CarbonsEnableSerializer() {
+ super(CarbonsEnable.class);
+ }
+
+ public String serializePayload(CarbonsEnable payload) {
+ XMLElement element = new XMLElement("enable", "urn:xmpp:carbons:2");
+ return element.serialize();
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/serializer/payloadserializers/CarbonsPrivateSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/CarbonsPrivateSerializer.java
new file mode 100644
index 0000000..eeb2c3f
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/CarbonsPrivateSerializer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.xml.XMLTextNode;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.CarbonsPrivate;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsPrivateSerializer extends GenericPayloadSerializer<CarbonsPrivate> {
+
+ public CarbonsPrivateSerializer() {
+ super(CarbonsPrivate.class);
+ }
+
+ public String serializePayload(CarbonsPrivate payload) {
+ XMLElement element = new XMLElement("private", "urn:xmpp:carbons:2");
+ return element.serialize();
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/serializer/payloadserializers/CarbonsReceivedSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/CarbonsReceivedSerializer.java
new file mode 100644
index 0000000..aa15010
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/CarbonsReceivedSerializer.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.CarbonsReceived;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsReceivedSerializer extends GenericPayloadSerializer<CarbonsReceived> {
+
+ private PayloadSerializerCollection serializers_;
+
+ public CarbonsReceivedSerializer(PayloadSerializerCollection serializers) {
+ super(CarbonsReceived.class);
+ this.serializers_ = serializers;
+ }
+
+ public String serializePayload(CarbonsReceived received) {
+ XMLElement element = new XMLElement("received", "urn:xmpp:carbons:2");
+ if (received.getForwarded() != null) {
+ element.addNode(new XMLRawTextNode(new ForwardedSerializer(serializers_).serialize(received.getForwarded())));
+ }
+ return element.serialize();
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/serializer/payloadserializers/CarbonsSentSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/CarbonsSentSerializer.java
new file mode 100644
index 0000000..ac4b47a
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/CarbonsSentSerializer.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.CarbonsSent;
+import com.isode.stroke.base.NotNull;
+
+public class CarbonsSentSerializer extends GenericPayloadSerializer<CarbonsSent> {
+
+ private PayloadSerializerCollection serializers_;
+
+ public CarbonsSentSerializer(PayloadSerializerCollection serializers) {
+ super(CarbonsSent.class);
+ this.serializers_ = serializers;
+ }
+
+ public String serializePayload(CarbonsSent sent) {
+ XMLElement element = new XMLElement("sent", "urn:xmpp:carbons:2");
+ if (sent.getForwarded() != null) {
+ element.addNode(new XMLRawTextNode(new ForwardedSerializer(serializers_).serialize(sent.getForwarded())));
+ }
+ return element.serialize();
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java
index 9ad402c..64b17d1 100644
--- a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java
+++ b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java
@@ -20,6 +20,11 @@ public class FullPayloadSerializerCollection extends PayloadSerializerCollection
addSerializer(new BodySerializer());
addSerializer(new SubjectSerializer());
addSerializer(new ChatStateSerializer());
+ addSerializer(new CarbonsDisableSerializer());
+ addSerializer(new CarbonsEnableSerializer());
+ addSerializer(new CarbonsPrivateSerializer());
+ addSerializer(new CarbonsReceivedSerializer(this));
+ addSerializer(new CarbonsSentSerializer(this));
//addSerializer(new PrioritySerializer());
addSerializer(new ErrorSerializer());
addSerializer(new InBandRegistrationPayloadSerializer());
@@ -48,7 +53,9 @@ public class FullPayloadSerializerCollection extends PayloadSerializerCollection
addSerializer(new StartSessionSerializer());
addSerializer(new SecurityLabelSerializer());
addSerializer(new SecurityLabelsCatalogSerializer());
+ //addSerializer(new StreamInitiationFileInfoSerializer());
//addSerializer(new StreamInitiationSerializer());
+ addSerializer(new ThreadSerializer());
addSerializer(new BytestreamsSerializer());
addSerializer(new VCardSerializer());
addSerializer(new VCardUpdateSerializer());
diff --git a/src/com/isode/stroke/serializer/payloadserializers/ThreadSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/ThreadSerializer.java
new file mode 100644
index 0000000..93c6004
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/ThreadSerializer.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.xml.XMLTextNode;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.Thread;
+import com.isode.stroke.base.NotNull;
+
+public class ThreadSerializer extends GenericPayloadSerializer<Thread> {
+
+ public ThreadSerializer() {
+ super(Thread.class);
+ }
+
+ public String serializePayload(Thread thread) {
+ XMLElement threadNode = new XMLElement("thread", "", thread.getText());
+ if (thread.getParent().length() != 0) {
+ threadNode.setAttribute("parent", thread.getParent());
+ }
+ return threadNode.serialize();
+ }
+} \ No newline at end of file