summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-02-04 09:49:24 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-03-07 14:28:58 (GMT)
commita511087b1f57f1f6372374f41d0b4b7ebeef9930 (patch)
treea319c6c65f4c4722635f78ac564a823a370d011c /src/com/isode/stroke/parser/PubSubOwnerPubSubParser.java
parent535e1a979a164f807aa64bf2df2bb36e7015ff17 (diff)
downloadstroke-a511087b1f57f1f6372374f41d0b4b7ebeef9930.zip
stroke-a511087b1f57f1f6372374f41d0b4b7ebeef9930.tar.bz2
PubSub parsers and serializers, plus manager and test code.
Change-Id: Ie8ca77ba8dbcd83926d46307ad0e73d804ff7422
Diffstat (limited to 'src/com/isode/stroke/parser/PubSubOwnerPubSubParser.java')
-rw-r--r--src/com/isode/stroke/parser/PubSubOwnerPubSubParser.java95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/PubSubOwnerPubSubParser.java b/src/com/isode/stroke/parser/PubSubOwnerPubSubParser.java
new file mode 100644
index 0000000..ac0c4fe
--- /dev/null
+++ b/src/com/isode/stroke/parser/PubSubOwnerPubSubParser.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2014, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2014, Remko Tronçon.
+ * All rights reserved.
+ */
+
+package com.isode.stroke.parser;
+
+import com.isode.stroke.elements.PubSubOwnerPayload;
+import com.isode.stroke.elements.PubSubOwnerPubSub;
+import com.isode.stroke.parser.payloadparsers.PubSubOwnerAffiliationsParser;
+import com.isode.stroke.parser.payloadparsers.PubSubOwnerConfigureParser;
+import com.isode.stroke.parser.payloadparsers.PubSubOwnerDefaultParser;
+import com.isode.stroke.parser.payloadparsers.PubSubOwnerDeleteParser;
+import com.isode.stroke.parser.payloadparsers.PubSubOwnerPurgeParser;
+import com.isode.stroke.parser.payloadparsers.PubSubOwnerSubscriptionsParser;
+
+public class PubSubOwnerPubSubParser extends
+ GenericPayloadParser<PubSubOwnerPubSub> {
+
+ public PubSubOwnerPubSubParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerPubSub());
+ parsers_ = parsers;
+ level_ = 0;
+ }
+
+ public void handleStartElement(String element, String ns,
+ AttributeMap attributes) {
+ if (level_ == 1) {
+ if (element == "configure"
+ && ns == "http://jabber.org/protocol/pubsub#owner") {
+ currentPayloadParser_ = new PubSubOwnerConfigureParser(parsers_);
+ }
+ if (element == "subscriptions"
+ && ns == "http://jabber.org/protocol/pubsub#owner") {
+ currentPayloadParser_ = new PubSubOwnerSubscriptionsParser(
+ parsers_);
+ }
+ if (element == "default"
+ && ns == "http://jabber.org/protocol/pubsub#owner") {
+ currentPayloadParser_ = new PubSubOwnerDefaultParser(parsers_);
+ }
+ if (element == "purge"
+ && ns == "http://jabber.org/protocol/pubsub#owner") {
+ currentPayloadParser_ = new PubSubOwnerPurgeParser(parsers_);
+ }
+ if (element == "affiliations"
+ && ns == "http://jabber.org/protocol/pubsub#owner") {
+ currentPayloadParser_ = new PubSubOwnerAffiliationsParser(
+ parsers_);
+ }
+ if (element == "delete"
+ && ns == "http://jabber.org/protocol/pubsub#owner") {
+ currentPayloadParser_ = new PubSubOwnerDeleteParser(parsers_);
+ }
+ }
+
+ if (level_ >= 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleStartElement(element, ns, attributes);
+ }
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ if (currentPayloadParser_ != null) {
+ if (level_ >= 1) {
+ currentPayloadParser_.handleEndElement(element, ns);
+ }
+
+ if (level_ == 1) {
+ if (currentPayloadParser_ != null) {
+ getPayloadInternal().setPayload(
+ (PubSubOwnerPayload) currentPayloadParser_
+ .getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+ }
+ }
+
+ public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+ }
+
+ PayloadParserFactoryCollection parsers_;
+ int level_;
+ PayloadParser currentPayloadParser_;
+
+}