summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/isode')
-rw-r--r--src/com/isode/stroke/client/Client.java13
-rw-r--r--src/com/isode/stroke/elements/ContainerPayload.java29
-rw-r--r--src/com/isode/stroke/elements/PubSub.java14
-rw-r--r--src/com/isode/stroke/elements/PubSubAffiliation.java47
-rw-r--r--src/com/isode/stroke/elements/PubSubAffiliations.java43
-rw-r--r--src/com/isode/stroke/elements/PubSubConfigure.java30
-rw-r--r--src/com/isode/stroke/elements/PubSubCreate.java38
-rw-r--r--src/com/isode/stroke/elements/PubSubDefault.java44
-rw-r--r--src/com/isode/stroke/elements/PubSubError.java108
-rw-r--r--src/com/isode/stroke/elements/PubSubEventAssociate.java29
-rw-r--r--src/com/isode/stroke/elements/PubSubEventCollection.java47
-rw-r--r--src/com/isode/stroke/elements/PubSubEventConfiguration.java39
-rw-r--r--src/com/isode/stroke/elements/PubSubEventDelete.java38
-rw-r--r--src/com/isode/stroke/elements/PubSubEventDisassociate.java29
-rw-r--r--src/com/isode/stroke/elements/PubSubEventItem.java61
-rw-r--r--src/com/isode/stroke/elements/PubSubEventItems.java56
-rw-r--r--src/com/isode/stroke/elements/PubSubEventPayload.java14
-rw-r--r--src/com/isode/stroke/elements/PubSubEventPurge.java29
-rw-r--r--src/com/isode/stroke/elements/PubSubEventRedirect.java29
-rw-r--r--src/com/isode/stroke/elements/PubSubEventRetract.java29
-rw-r--r--src/com/isode/stroke/elements/PubSubEventSubscription.java74
-rw-r--r--src/com/isode/stroke/elements/PubSubItem.java43
-rw-r--r--src/com/isode/stroke/elements/PubSubItems.java61
-rw-r--r--src/com/isode/stroke/elements/PubSubOptions.java58
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerAffiliation.java48
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerAffiliations.java43
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerConfigure.java39
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerDefault.java30
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerDelete.java38
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerPayload.java14
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerPubSub.java14
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerPurge.java29
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerRedirect.java29
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerSubscription.java46
-rw-r--r--src/com/isode/stroke/elements/PubSubOwnerSubscriptions.java43
-rw-r--r--src/com/isode/stroke/elements/PubSubPayload.java14
-rw-r--r--src/com/isode/stroke/elements/PubSubPublish.java43
-rw-r--r--src/com/isode/stroke/elements/PubSubRetract.java52
-rw-r--r--src/com/isode/stroke/elements/PubSubSubscribe.java48
-rw-r--r--src/com/isode/stroke/elements/PubSubSubscribeOptions.java29
-rw-r--r--src/com/isode/stroke/elements/PubSubSubscription.java73
-rw-r--r--src/com/isode/stroke/elements/PubSubSubscriptions.java43
-rw-r--r--src/com/isode/stroke/elements/PubSubUnsubscribe.java48
-rw-r--r--src/com/isode/stroke/parser/GenericPayloadParserFactory2.java53
-rw-r--r--src/com/isode/stroke/parser/PubSubOwnerPubSubParser.java95
-rw-r--r--src/com/isode/stroke/parser/StanzaParser.java1
-rw-r--r--src/com/isode/stroke/parser/XMPPParser.java109
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java9
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubAffiliationParser.java85
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubAffiliationsParser.java73
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubConfigureParser.java66
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubCreateParser.java64
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubDefaultParser.java79
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubErrorParser.java126
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubErrorParserFactory.java28
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEvent.java17
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventAssociateParser.java63
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventCollectionParser.java80
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventConfigurationParser.java74
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventDeleteParser.java73
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventDisassociateParser.java63
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventItemParser.java81
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventItemsParser.java80
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java81
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventPurgeParser.java63
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventRedirectParser.java63
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventRetractParser.java63
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventSubscriptionParser.java107
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubItemParser.java73
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubItemsParser.java81
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOptionsParser.java83
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerAffiliationParser.java86
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerAffiliationsParser.java73
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerConfigureParser.java74
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerDefaultParser.java66
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerDeleteParser.java73
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerPurgeParser.java63
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerRedirectParser.java63
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerSubscriptionParser.java82
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerSubscriptionsParser.java73
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubParser.java129
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubPublishParser.java73
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubRetractParser.java77
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubSubscribeOptionsParser.java58
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubSubscribeParser.java69
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubSubscriptionParser.java100
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubSubscriptionsParser.java73
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubUnsubscribeParser.java72
-rw-r--r--src/com/isode/stroke/pubsub/PubSubManager.java18
-rw-r--r--src/com/isode/stroke/pubsub/PubSubManagerImpl.java36
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java5
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubAffiliationSerializer.java53
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubAffiliationsSerializer.java45
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubConfigureSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubCreateSerializer.java40
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubDefaultSerializer.java50
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubErrorSerializer.java112
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventAssociateSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventCollectionSerializer.java46
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventConfigurationSerializer.java43
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventDeleteSerializer.java43
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventDisassociateSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventItemSerializer.java53
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventItemsSerializer.java50
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventPurgeSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventRedirectSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventRetractSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventSerializer.java44
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubEventSubscriptionSerializer.java75
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubItemSerializer.java45
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubItemsSerializer.java53
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOptionsSerializer.java51
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerAffiliationSerializer.java53
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerAffiliationsSerializer.java45
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerConfigureSerializer.java43
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerDefaultSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerDeleteSerializer.java43
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerPubSubSerializer.java56
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerPurgeSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerRedirectSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerSubscriptionSerializer.java51
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerSubscriptionsSerializer.java45
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubPublishSerializer.java45
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubRetractSerializer.java47
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubSerializer.java73
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubSubscribeOptionsSerializer.java39
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubSubscribeSerializer.java44
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubSubscriptionSerializer.java63
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubSubscriptionsSerializer.java45
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/PubSubUnsubscribeSerializer.java47
-rw-r--r--src/com/isode/stroke/serializer/payloadserializers/RawXMLPayloadSerializer.java2
131 files changed, 6851 insertions, 65 deletions
diff --git a/src/com/isode/stroke/client/Client.java b/src/com/isode/stroke/client/Client.java
index a4ef619..4f5d6c7 100644
--- a/src/com/isode/stroke/client/Client.java
+++ b/src/com/isode/stroke/client/Client.java
@@ -14,6 +14,8 @@ import com.isode.stroke.muc.MUCRegistry;
import com.isode.stroke.network.NetworkFactories;
import com.isode.stroke.presence.DirectedPresenceSender;
import com.isode.stroke.presence.StanzaChannelPresenceSender;
+import com.isode.stroke.pubsub.PubSubManager;
+import com.isode.stroke.pubsub.PubSubManagerImpl;
import com.isode.stroke.queries.responders.SoftwareVersionResponder;
/**
@@ -30,6 +32,7 @@ public class Client extends CoreClient {
private final DirectedPresenceSender directedPresenceSender; //NOPMD, this is not better as a local variable
private final StanzaChannelPresenceSender stanzaChannelPresenceSender; //NOPMD, this is not better as a local variable
private final SoftwareVersionResponder softwareVersionResponder;
+ private final PubSubManager pubSubManager;
/**
* Constructor.
@@ -57,6 +60,8 @@ public class Client extends CoreClient {
softwareVersionResponder = new SoftwareVersionResponder(getIQRouter());
softwareVersionResponder.start();
+
+ pubSubManager = new PubSubManagerImpl(getStanzaChannel(), getIQRouter());
}
/**
@@ -75,6 +80,14 @@ public class Client extends CoreClient {
return mucRegistry;
}
+ /**
+ * Get the manager for publish-subscribe
+ * @return PubSub manager, not null
+ */
+ public PubSubManager getPubSubManager() {
+ return pubSubManager;
+ }
+
/**
* Sets the software version of the client.
*
diff --git a/src/com/isode/stroke/elements/ContainerPayload.java b/src/com/isode/stroke/elements/ContainerPayload.java
new file mode 100644
index 0000000..16134d0
--- /dev/null
+++ b/src/com/isode/stroke/elements/ContainerPayload.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+public class ContainerPayload<T> extends Payload {
+ public ContainerPayload() {
+ }
+
+ public ContainerPayload(T payload) {
+ payload_ = payload;
+ }
+
+ public void setPayload(T payload) {
+ payload_ = payload;
+ }
+
+ public T getPayload() {
+ return payload_;
+ }
+
+ T payload_;
+}
diff --git a/src/com/isode/stroke/elements/PubSub.java b/src/com/isode/stroke/elements/PubSub.java
new file mode 100644
index 0000000..8a317bd
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSub.java
@@ -0,0 +1,14 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+public class PubSub extends ContainerPayload<PubSubPayload> {
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubAffiliation.java b/src/com/isode/stroke/elements/PubSubAffiliation.java
new file mode 100644
index 0000000..f6f74de
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubAffiliation.java
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class PubSubAffiliation extends Payload {
+public enum Type
+{
+ None,
+ Member,
+ Outcast,
+ Owner,
+ Publisher,
+ PublishOnly
+}
+
+public PubSubAffiliation() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public Type getType() {
+ return type_;
+}
+
+public void setType(Type type) {
+ type_ = type;
+}
+
+String node_;
+Type type_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubAffiliations.java b/src/com/isode/stroke/elements/PubSubAffiliations.java
new file mode 100644
index 0000000..883f078
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubAffiliations.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubAffiliations extends PubSubPayload {
+
+public PubSubAffiliations() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public ArrayList<PubSubAffiliation> getAffiliations() {
+ return affiliations_;
+}
+
+public void setAffiliations(ArrayList<PubSubAffiliation> affiliations) {
+ affiliations_ = affiliations;
+}
+
+public void addAffiliation(PubSubAffiliation value) {
+ affiliations_.add(value);
+}
+
+String node_;
+ArrayList<PubSubAffiliation> affiliations_ = new ArrayList<PubSubAffiliation>();
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubConfigure.java b/src/com/isode/stroke/elements/PubSubConfigure.java
new file mode 100644
index 0000000..2b54374
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubConfigure.java
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.elements.Payload;
+
+public class PubSubConfigure extends Payload {
+
+public PubSubConfigure() {
+}
+
+public Form getData() {
+ return data_;
+}
+
+public void setData(Form data) {
+ data_ = data;
+}
+
+Form data_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubCreate.java b/src/com/isode/stroke/elements/PubSubCreate.java
new file mode 100644
index 0000000..e1ac6c0
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubCreate.java
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubCreate extends PubSubPayload {
+
+public PubSubCreate() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public PubSubConfigure getConfigure() {
+ return configure_;
+}
+
+public void setConfigure(PubSubConfigure configure) {
+ configure_ = configure;
+}
+
+String node_;
+PubSubConfigure configure_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubDefault.java b/src/com/isode/stroke/elements/PubSubDefault.java
new file mode 100644
index 0000000..f5b075a
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubDefault.java
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubDefault extends PubSubPayload {
+public enum Type
+{
+ None,
+ Collection,
+ Leaf
+}
+
+public PubSubDefault() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public Type getType() {
+ return type_;
+}
+
+public void setType(Type type) {
+ type_ = type;
+}
+
+String node_;
+Type type_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubError.java b/src/com/isode/stroke/elements/PubSubError.java
new file mode 100644
index 0000000..cd6aadf
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubError.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2014, Remko Tronçon.
+ * All rights reserved.
+ */
+
+package com.isode.stroke.elements;
+
+public class PubSubError extends Payload {
+ public enum Type {
+ UnknownType,
+ ClosedNode,
+ ConfigurationRequired,
+ InvalidJID,
+ InvalidOptions,
+ InvalidPayload,
+ InvalidSubscriptionID,
+ ItemForbidden,
+ ItemRequired,
+ JIDRequired,
+ MaximumItemsExceeded,
+ MaximumNodesExceeded,
+ NodeIDRequired,
+ NotInRosterGroup,
+ NotSubscribed,
+ PayloadTooBig,
+ PayloadRequired,
+ PendingSubscription,
+ PresenceSubscriptionRequired,
+ SubscriptionIDRequired,
+ TooManySubscriptions,
+ Unsupported,
+ UnsupportedAccessModel
+ };
+
+ public enum UnsupportedFeatureType {
+ UnknownUnsupportedFeatureType,
+ AccessAuthorize,
+ AccessOpen,
+ AccessPresence,
+ AccessRoster,
+ AccessWhitelist,
+ AutoCreate,
+ AutoSubscribe,
+ Collections,
+ ConfigNode,
+ CreateAndConfigure,
+ CreateNodes,
+ DeleteItems,
+ DeleteNodes,
+ FilteredNotifications,
+ GetPending,
+ InstantNodes,
+ ItemIDs,
+ LastPublished,
+ LeasedSubscription,
+ ManageSubscriptions,
+ MemberAffiliation,
+ MetaData,
+ ModifyAffiliations,
+ MultiCollection,
+ MultiSubscribe,
+ OutcastAffiliation,
+ PersistentItems,
+ PresenceNotifications,
+ PresenceSubscribe,
+ Publish,
+ PublishOptions,
+ PublishOnlyAffiliation,
+ PublisherAffiliation,
+ PurgeNodes,
+ RetractItems,
+ RetrieveAffiliations,
+ RetrieveDefault,
+ RetrieveItems,
+ RetrieveSubscriptions,
+ Subscribe,
+ SubscriptionOptions,
+ SubscriptionNotifications
+ };
+
+ public PubSubError(Type type) {
+ type_ = Type.UnknownType;
+ unsupportedType_ = UnsupportedFeatureType.UnknownUnsupportedFeatureType;
+ }
+
+ public Type getType() {
+ return type_;
+ }
+
+ public void setType(Type type) {
+ type_ = type;
+ }
+
+ public UnsupportedFeatureType getUnsupportedFeatureType() {
+ return unsupportedType_;
+ }
+
+ public void setUnsupportedFeatureType(UnsupportedFeatureType unsupportedType) {
+ unsupportedType_ = unsupportedType;
+ }
+
+ Type type_;
+ UnsupportedFeatureType unsupportedType_;
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventAssociate.java b/src/com/isode/stroke/elements/PubSubEventAssociate.java
new file mode 100644
index 0000000..0ba4204
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventAssociate.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class PubSubEventAssociate extends Payload {
+
+public PubSubEventAssociate() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventCollection.java b/src/com/isode/stroke/elements/PubSubEventCollection.java
new file mode 100644
index 0000000..95a7119
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventCollection.java
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.PubSubEventPayload;
+
+public class PubSubEventCollection extends PubSubEventPayload {
+
+public PubSubEventCollection() {
+}
+
+public PubSubEventAssociate getAssociate() {
+ return associate_;
+}
+
+public void setAssociate(PubSubEventAssociate associate) {
+ associate_ = associate;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public PubSubEventDisassociate getDisassociate() {
+ return disassociate_;
+}
+
+public void setDisassociate(PubSubEventDisassociate disassociate) {
+ disassociate_ = disassociate;
+}
+
+PubSubEventAssociate associate_;
+String node_;
+PubSubEventDisassociate disassociate_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventConfiguration.java b/src/com/isode/stroke/elements/PubSubEventConfiguration.java
new file mode 100644
index 0000000..0d13daa
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventConfiguration.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.elements.PubSubEventPayload;
+
+public class PubSubEventConfiguration extends PubSubEventPayload {
+
+public PubSubEventConfiguration() {
+}
+
+public Form getData() {
+ return data_;
+}
+
+public void setData(Form data) {
+ data_ = data;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+Form data_;
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventDelete.java b/src/com/isode/stroke/elements/PubSubEventDelete.java
new file mode 100644
index 0000000..5c6418d
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventDelete.java
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.PubSubEventPayload;
+
+public class PubSubEventDelete extends PubSubEventPayload {
+
+public PubSubEventDelete() {
+}
+
+public PubSubEventRedirect getRedirects() {
+ return redirects_;
+}
+
+public void setRedirects(PubSubEventRedirect redirects) {
+ redirects_ = redirects;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+PubSubEventRedirect redirects_;
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventDisassociate.java b/src/com/isode/stroke/elements/PubSubEventDisassociate.java
new file mode 100644
index 0000000..d6fcb97
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventDisassociate.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class PubSubEventDisassociate extends Payload {
+
+public PubSubEventDisassociate() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventItem.java b/src/com/isode/stroke/elements/PubSubEventItem.java
new file mode 100644
index 0000000..2086106
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventItem.java
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.Payload;
+
+public class PubSubEventItem extends Payload {
+
+public PubSubEventItem() {
+}
+
+public String getPublisher() {
+ return publisher_;
+}
+
+public void setPublisher(String publisher) {
+ publisher_ = publisher;
+}
+
+public ArrayList<Payload> getData() {
+ return data_;
+}
+
+public void setData(ArrayList<Payload> data) {
+ data_ = data;
+}
+
+public void addData(Payload value) {
+ data_.add(value);
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public String getID() {
+ return id_;
+}
+
+public void setID(String id) {
+ id_ = id;
+}
+
+String publisher_;
+ArrayList<Payload> data_ = new ArrayList<Payload>();
+String node_;
+String id_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventItems.java b/src/com/isode/stroke/elements/PubSubEventItems.java
new file mode 100644
index 0000000..f4865ff
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventItems.java
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.PubSubEventPayload;
+
+public class PubSubEventItems extends PubSubEventPayload {
+
+public PubSubEventItems() {
+}
+
+public ArrayList<PubSubEventItem> getItems() {
+ return items_;
+}
+
+public void setItems(ArrayList<PubSubEventItem> items) {
+ items_ = items;
+}
+
+public void addItem(PubSubEventItem value) {
+ items_.add(value);
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public ArrayList<PubSubEventRetract> getRetracts() {
+ return retracts_;
+}
+
+public void setRetracts(ArrayList<PubSubEventRetract> retracts) {
+ retracts_ = retracts;
+}
+
+public void addRetract(PubSubEventRetract value) {
+ retracts_.add(value);
+}
+
+ArrayList<PubSubEventItem> items_ = new ArrayList<PubSubEventItem>();
+String node_;
+ArrayList<PubSubEventRetract> retracts_ = new ArrayList<PubSubEventRetract>();
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventPayload.java b/src/com/isode/stroke/elements/PubSubEventPayload.java
new file mode 100644
index 0000000..d101c6c
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventPayload.java
@@ -0,0 +1,14 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+public class PubSubEventPayload extends Payload {
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventPurge.java b/src/com/isode/stroke/elements/PubSubEventPurge.java
new file mode 100644
index 0000000..451ce09
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventPurge.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.PubSubEventPayload;
+
+public class PubSubEventPurge extends PubSubEventPayload {
+
+public PubSubEventPurge() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventRedirect.java b/src/com/isode/stroke/elements/PubSubEventRedirect.java
new file mode 100644
index 0000000..5f99b19
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventRedirect.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class PubSubEventRedirect extends Payload {
+
+public PubSubEventRedirect() {
+}
+
+public String getURI() {
+ return uri_;
+}
+
+public void setURI(String uri) {
+ uri_ = uri;
+}
+
+String uri_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventRetract.java b/src/com/isode/stroke/elements/PubSubEventRetract.java
new file mode 100644
index 0000000..4eba5ca
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventRetract.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class PubSubEventRetract extends Payload {
+
+public PubSubEventRetract() {
+}
+
+public String getID() {
+ return id_;
+}
+
+public void setID(String id) {
+ id_ = id;
+}
+
+String id_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubEventSubscription.java b/src/com/isode/stroke/elements/PubSubEventSubscription.java
new file mode 100644
index 0000000..7864a65
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubEventSubscription.java
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+import java.util.Date;
+import com.isode.stroke.elements.PubSubEventPayload;
+
+public class PubSubEventSubscription extends PubSubEventPayload {
+public enum SubscriptionType
+{
+ None,
+ Pending,
+ Subscribed,
+ Unconfigured
+}
+
+public PubSubEventSubscription() {
+}
+
+public SubscriptionType getSubscription() {
+ return subscription_;
+}
+
+public void setSubscription(SubscriptionType subscription) {
+ subscription_ = subscription;
+}
+
+public String getSubscriptionID() {
+ return subscriptionID_;
+}
+
+public void setSubscriptionID(String subscriptionID) {
+ subscriptionID_ = subscriptionID;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public JID getJID() {
+ return jid_;
+}
+
+public void setJID(JID jid) {
+ jid_ = jid;
+}
+
+public Date getExpiry() {
+ return expiry_;
+}
+
+public void setExpiry(Date expiry) {
+ expiry_ = expiry;
+}
+
+SubscriptionType subscription_;
+String subscriptionID_;
+String node_;
+JID jid_;
+Date expiry_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubItem.java b/src/com/isode/stroke/elements/PubSubItem.java
new file mode 100644
index 0000000..91d0fe1
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubItem.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.Payload;
+
+public class PubSubItem extends Payload {
+
+public PubSubItem() {
+}
+
+public ArrayList<Payload> getData() {
+ return data_;
+}
+
+public void setData(ArrayList<Payload> data) {
+ data_ = data;
+}
+
+public void addData(Payload value) {
+ data_.add(value);
+}
+
+public String getID() {
+ return id_;
+}
+
+public void setID(String id) {
+ id_ = id;
+}
+
+ArrayList<Payload> data_ = new ArrayList<Payload>();
+String id_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubItems.java b/src/com/isode/stroke/elements/PubSubItems.java
new file mode 100644
index 0000000..ae675e4
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubItems.java
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubItems extends PubSubPayload {
+
+public PubSubItems() {
+}
+
+public Long getMaximumItems() {
+ return maximumItems_;
+}
+
+public void setMaximumItems(Long maximumItems) {
+ maximumItems_ = maximumItems;
+}
+
+public ArrayList<PubSubItem> getItems() {
+ return items_;
+}
+
+public void setItems(ArrayList<PubSubItem> items) {
+ items_ = items;
+}
+
+public void addItem(PubSubItem value) {
+ items_.add(value);
+}
+
+public String getSubscriptionID() {
+ return subscriptionID_;
+}
+
+public void setSubscriptionID(String subscriptionID) {
+ subscriptionID_ = subscriptionID;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+Long maximumItems_;
+ArrayList<PubSubItem> items_ = new ArrayList<PubSubItem>();
+String subscriptionID_;
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOptions.java b/src/com/isode/stroke/elements/PubSubOptions.java
new file mode 100644
index 0000000..085baa7
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOptions.java
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubOptions extends PubSubPayload {
+
+public PubSubOptions() {
+}
+
+public Form getData() {
+ return data_;
+}
+
+public void setData(Form data) {
+ data_ = data;
+}
+
+public String getSubscriptionID() {
+ return subscriptionID_;
+}
+
+public void setSubscriptionID(String subscriptionID) {
+ subscriptionID_ = subscriptionID;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public JID getJID() {
+ return jid_;
+}
+
+public void setJID(JID jid) {
+ jid_ = jid;
+}
+
+Form data_;
+String subscriptionID_;
+String node_;
+JID jid_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerAffiliation.java b/src/com/isode/stroke/elements/PubSubOwnerAffiliation.java
new file mode 100644
index 0000000..d08bd3d
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerAffiliation.java
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.Payload;
+
+public class PubSubOwnerAffiliation extends Payload {
+public enum Type
+{
+ None,
+ Member,
+ Outcast,
+ Owner,
+ Publisher,
+ PublishOnly
+}
+
+public PubSubOwnerAffiliation() {
+}
+
+public JID getJID() {
+ return jid_;
+}
+
+public void setJID(JID jid) {
+ jid_ = jid;
+}
+
+public Type getType() {
+ return type_;
+}
+
+public void setType(Type type) {
+ type_ = type;
+}
+
+JID jid_;
+Type type_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerAffiliations.java b/src/com/isode/stroke/elements/PubSubOwnerAffiliations.java
new file mode 100644
index 0000000..25973f8
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerAffiliations.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.PubSubOwnerPayload;
+
+public class PubSubOwnerAffiliations extends PubSubOwnerPayload {
+
+public PubSubOwnerAffiliations() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public ArrayList<PubSubOwnerAffiliation> getAffiliations() {
+ return affiliations_;
+}
+
+public void setAffiliations(ArrayList<PubSubOwnerAffiliation> affiliations) {
+ affiliations_ = affiliations;
+}
+
+public void addAffiliation(PubSubOwnerAffiliation value) {
+ affiliations_.add(value);
+}
+
+String node_;
+ArrayList<PubSubOwnerAffiliation> affiliations_ = new ArrayList<PubSubOwnerAffiliation>();
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerConfigure.java b/src/com/isode/stroke/elements/PubSubOwnerConfigure.java
new file mode 100644
index 0000000..2807039
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerConfigure.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.elements.PubSubOwnerPayload;
+
+public class PubSubOwnerConfigure extends PubSubOwnerPayload {
+
+public PubSubOwnerConfigure() {
+}
+
+public Form getData() {
+ return data_;
+}
+
+public void setData(Form data) {
+ data_ = data;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+Form data_;
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerDefault.java b/src/com/isode/stroke/elements/PubSubOwnerDefault.java
new file mode 100644
index 0000000..5f9c179
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerDefault.java
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.elements.PubSubOwnerPayload;
+
+public class PubSubOwnerDefault extends PubSubOwnerPayload {
+
+public PubSubOwnerDefault() {
+}
+
+public Form getData() {
+ return data_;
+}
+
+public void setData(Form data) {
+ data_ = data;
+}
+
+Form data_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerDelete.java b/src/com/isode/stroke/elements/PubSubOwnerDelete.java
new file mode 100644
index 0000000..a791fad
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerDelete.java
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.PubSubOwnerPayload;
+
+public class PubSubOwnerDelete extends PubSubOwnerPayload {
+
+public PubSubOwnerDelete() {
+}
+
+public PubSubOwnerRedirect getRedirect() {
+ return redirect_;
+}
+
+public void setRedirect(PubSubOwnerRedirect redirect) {
+ redirect_ = redirect;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+PubSubOwnerRedirect redirect_;
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerPayload.java b/src/com/isode/stroke/elements/PubSubOwnerPayload.java
new file mode 100644
index 0000000..50d3775
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerPayload.java
@@ -0,0 +1,14 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+public class PubSubOwnerPayload extends Payload {
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerPubSub.java b/src/com/isode/stroke/elements/PubSubOwnerPubSub.java
new file mode 100644
index 0000000..63fd592
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerPubSub.java
@@ -0,0 +1,14 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+public class PubSubOwnerPubSub extends ContainerPayload<PubSubOwnerPayload> {
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerPurge.java b/src/com/isode/stroke/elements/PubSubOwnerPurge.java
new file mode 100644
index 0000000..0a9abc7
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerPurge.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.PubSubOwnerPayload;
+
+public class PubSubOwnerPurge extends PubSubOwnerPayload {
+
+public PubSubOwnerPurge() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerRedirect.java b/src/com/isode/stroke/elements/PubSubOwnerRedirect.java
new file mode 100644
index 0000000..c5bda3c
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerRedirect.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class PubSubOwnerRedirect extends Payload {
+
+public PubSubOwnerRedirect() {
+}
+
+public String getURI() {
+ return uri_;
+}
+
+public void setURI(String uri) {
+ uri_ = uri;
+}
+
+String uri_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerSubscription.java b/src/com/isode/stroke/elements/PubSubOwnerSubscription.java
new file mode 100644
index 0000000..2845ffc
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerSubscription.java
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.Payload;
+
+public class PubSubOwnerSubscription extends Payload {
+public enum SubscriptionType
+{
+ None,
+ Pending,
+ Subscribed,
+ Unconfigured
+}
+
+public PubSubOwnerSubscription() {
+}
+
+public SubscriptionType getSubscription() {
+ return subscription_;
+}
+
+public void setSubscription(SubscriptionType subscription) {
+ subscription_ = subscription;
+}
+
+public JID getJID() {
+ return jid_;
+}
+
+public void setJID(JID jid) {
+ jid_ = jid;
+}
+
+SubscriptionType subscription_;
+JID jid_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubOwnerSubscriptions.java b/src/com/isode/stroke/elements/PubSubOwnerSubscriptions.java
new file mode 100644
index 0000000..bd84a2d
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubOwnerSubscriptions.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.PubSubOwnerPayload;
+
+public class PubSubOwnerSubscriptions extends PubSubOwnerPayload {
+
+public PubSubOwnerSubscriptions() {
+}
+
+public ArrayList<PubSubOwnerSubscription> getSubscriptions() {
+ return subscriptions_;
+}
+
+public void setSubscriptions(ArrayList<PubSubOwnerSubscription> subscriptions) {
+ subscriptions_ = subscriptions;
+}
+
+public void addSubscription(PubSubOwnerSubscription value) {
+ subscriptions_.add(value);
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+ArrayList<PubSubOwnerSubscription> subscriptions_ = new ArrayList<PubSubOwnerSubscription>();
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubPayload.java b/src/com/isode/stroke/elements/PubSubPayload.java
new file mode 100644
index 0000000..14d36b5
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubPayload.java
@@ -0,0 +1,14 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+public class PubSubPayload extends Payload {
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubPublish.java b/src/com/isode/stroke/elements/PubSubPublish.java
new file mode 100644
index 0000000..987ba83
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubPublish.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubPublish extends PubSubPayload {
+
+public PubSubPublish() {
+}
+
+public ArrayList<PubSubItem> getItems() {
+ return items_;
+}
+
+public void setItems(ArrayList<PubSubItem> items) {
+ items_ = items;
+}
+
+public void addItem(PubSubItem value) {
+ items_.add(value);
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+ArrayList<PubSubItem> items_ = new ArrayList<PubSubItem>();
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubRetract.java b/src/com/isode/stroke/elements/PubSubRetract.java
new file mode 100644
index 0000000..d8349ea
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubRetract.java
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubRetract extends PubSubPayload {
+
+public PubSubRetract() {
+}
+
+public ArrayList<PubSubItem> getItems() {
+ return items_;
+}
+
+public void setItems(ArrayList<PubSubItem> items) {
+ items_ = items;
+}
+
+public void addItem(PubSubItem value) {
+ items_.add(value);
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public boolean isNotify() {
+ return notify_;
+}
+
+public void setNotify(boolean notify) {
+ notify_ = notify;
+}
+
+ArrayList<PubSubItem> items_ = new ArrayList<PubSubItem>();
+String node_;
+boolean notify_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubSubscribe.java b/src/com/isode/stroke/elements/PubSubSubscribe.java
new file mode 100644
index 0000000..d822bd5
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubSubscribe.java
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubSubscribe extends PubSubPayload {
+
+public PubSubSubscribe() {
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public JID getJID() {
+ return jid_;
+}
+
+public void setJID(JID jid) {
+ jid_ = jid;
+}
+
+public PubSubOptions getOptions() {
+ return options_;
+}
+
+public void setOptions(PubSubOptions options) {
+ options_ = options;
+}
+
+String node_;
+JID jid_;
+PubSubOptions options_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubSubscribeOptions.java b/src/com/isode/stroke/elements/PubSubSubscribeOptions.java
new file mode 100644
index 0000000..54fd72e
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubSubscribeOptions.java
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+
+public class PubSubSubscribeOptions extends Payload {
+
+public PubSubSubscribeOptions() {
+}
+
+public boolean isRequired() {
+ return required_;
+}
+
+public void setRequired(boolean required) {
+ required_ = required;
+}
+
+boolean required_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubSubscription.java b/src/com/isode/stroke/elements/PubSubSubscription.java
new file mode 100644
index 0000000..78d9c17
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubSubscription.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubSubscription extends PubSubPayload {
+public enum SubscriptionType
+{
+ None,
+ Pending,
+ Subscribed,
+ Unconfigured
+}
+
+public PubSubSubscription() {
+}
+
+public SubscriptionType getSubscription() {
+ return subscription_;
+}
+
+public void setSubscription(SubscriptionType subscription) {
+ subscription_ = subscription;
+}
+
+public String getSubscriptionID() {
+ return subscriptionID_;
+}
+
+public void setSubscriptionID(String subscriptionID) {
+ subscriptionID_ = subscriptionID;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public JID getJID() {
+ return jid_;
+}
+
+public void setJID(JID jid) {
+ jid_ = jid;
+}
+
+public PubSubSubscribeOptions getOptions() {
+ return options_;
+}
+
+public void setOptions(PubSubSubscribeOptions options) {
+ options_ = options;
+}
+
+SubscriptionType subscription_;
+String subscriptionID_;
+String node_;
+JID jid_;
+PubSubSubscribeOptions options_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubSubscriptions.java b/src/com/isode/stroke/elements/PubSubSubscriptions.java
new file mode 100644
index 0000000..23bb223
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubSubscriptions.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import java.util.ArrayList;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubSubscriptions extends PubSubPayload {
+
+public PubSubSubscriptions() {
+}
+
+public ArrayList<PubSubSubscription> getSubscriptions() {
+ return subscriptions_;
+}
+
+public void setSubscriptions(ArrayList<PubSubSubscription> subscriptions) {
+ subscriptions_ = subscriptions;
+}
+
+public void addSubscription(PubSubSubscription value) {
+ subscriptions_.add(value);
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+ArrayList<PubSubSubscription> subscriptions_ = new ArrayList<PubSubSubscription>();
+String node_;
+
+}
diff --git a/src/com/isode/stroke/elements/PubSubUnsubscribe.java b/src/com/isode/stroke/elements/PubSubUnsubscribe.java
new file mode 100644
index 0000000..f8d1fae
--- /dev/null
+++ b/src/com/isode/stroke/elements/PubSubUnsubscribe.java
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubPayload;
+
+public class PubSubUnsubscribe extends PubSubPayload {
+
+public PubSubUnsubscribe() {
+}
+
+public String getSubscriptionID() {
+ return subscriptionID_;
+}
+
+public void setSubscriptionID(String subscriptionID) {
+ subscriptionID_ = subscriptionID;
+}
+
+public String getNode() {
+ return node_;
+}
+
+public void setNode(String node) {
+ node_ = node;
+}
+
+public JID getJID() {
+ return jid_;
+}
+
+public void setJID(JID jid) {
+ jid_ = jid;
+}
+
+String subscriptionID_;
+String node_;
+JID jid_;
+
+}
diff --git a/src/com/isode/stroke/parser/GenericPayloadParserFactory2.java b/src/com/isode/stroke/parser/GenericPayloadParserFactory2.java
new file mode 100644
index 0000000..c7bb9d0
--- /dev/null
+++ b/src/com/isode/stroke/parser/GenericPayloadParserFactory2.java
@@ -0,0 +1,53 @@
+/*
+* 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 java.lang.reflect.InvocationTargetException;
+
+public class GenericPayloadParserFactory2<T extends PayloadParser> implements PayloadParserFactory {
+
+ /**
+ * Construct a parser factory that can parse the given top-level tag in the given namespace.
+ */
+ public GenericPayloadParserFactory2(String tag, String xmlns, PayloadParserFactoryCollection parsers, final Class<? extends PayloadParser> payloadClass) {
+ class_ = payloadClass;
+ tag_ = tag;
+ xmlns_ = xmlns;
+ parsers_ = parsers;
+ }
+
+ public boolean canParse(String element, String ns, AttributeMap attributes) {
+ return (tag_.isEmpty() ? true : element == tag_) && (xmlns_.isEmpty() ? true : xmlns_ == ns);
+ }
+
+ public PayloadParser createPayloadParser() {
+ try {
+ return (PayloadParser)class_.getConstructor(PayloadParserFactoryCollection.class).newInstance(parsers_);
+ } catch (InstantiationException e) {
+
+ } catch (IllegalAccessException e) {
+
+ } catch (IllegalArgumentException e) {
+
+ } catch (InvocationTargetException e) {
+
+ } catch (NoSuchMethodException e) {
+
+ } catch (SecurityException e) {
+
+ }
+ return null;
+ }
+
+ String tag_;
+ String xmlns_;
+ PayloadParserFactoryCollection parsers_;
+ Class<? extends PayloadParser> class_;
+}
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_;
+
+}
diff --git a/src/com/isode/stroke/parser/StanzaParser.java b/src/com/isode/stroke/parser/StanzaParser.java
index 2dfb502..cb7647d 100644
--- a/src/com/isode/stroke/parser/StanzaParser.java
+++ b/src/com/isode/stroke/parser/StanzaParser.java
@@ -8,7 +8,6 @@
*/
package com.isode.stroke.parser;
-import com.isode.stroke.elements.Element;
import com.isode.stroke.elements.Payload;
import com.isode.stroke.elements.Stanza;
import com.isode.stroke.jid.JID;
diff --git a/src/com/isode/stroke/parser/XMPPParser.java b/src/com/isode/stroke/parser/XMPPParser.java
index 0e9b202..c2c25e9 100644
--- a/src/com/isode/stroke/parser/XMPPParser.java
+++ b/src/com/isode/stroke/parser/XMPPParser.java
@@ -11,23 +11,23 @@ package com.isode.stroke.parser;
import com.isode.stroke.elements.ProtocolHeader;
import java.util.logging.Logger;
-
public class XMPPParser implements XMLParserClient {
-
- private final XMLParser xmlParser_ ;
+
+ private final XMLParser xmlParser_;
private final XMPPParserClient client_;
private final PayloadParserFactoryCollection payloadParserFactories_;
private int currentDepth_ = 0;
private ElementParser currentElementParser_ = null;
private boolean parseErrorOccurred_ = false;
private Logger logger_ = Logger.getLogger(this.getClass().getName());
-
- public XMPPParser(XMPPParserClient parserClient, PayloadParserFactoryCollection payloadParserFactories) {
+
+ public XMPPParser(XMPPParserClient parserClient,
+ PayloadParserFactoryCollection payloadParserFactories) {
client_ = parserClient;
payloadParserFactories_ = payloadParserFactories;
xmlParser_ = PlatformXMLParserFactory.createXMLParser(this);
}
-
+
public boolean parse(String data) {
parseErrorOccurred_ = false;
boolean xmlParseResult = false;
@@ -38,20 +38,20 @@ public class XMPPParser implements XMLParserClient {
logger_.warning("Data " + data + " caused:\n" + e.getMessage());
}
if (parseErrorOccurred_ || !xmlParseResult) {
- logger_.warning(String.format("When parsing, %b and %b", parseErrorOccurred_, xmlParseResult));
- if(data !=null) {
- logger_.warning("xml that caused failure: " + data);
+ logger_.warning(String.format("When parsing, %b and %b",
+ parseErrorOccurred_, xmlParseResult));
+ if (data != null) {
+ logger_.warning("xml that caused failure: " + data);
}
}
return xmlParseResult && !parseErrorOccurred_;
}
-
- public void handleStartElement(
- String element,
- String ns,
+
+ public void handleStartElement(String element, String ns,
AttributeMap attributes) {
if (!inStream()) {
- if (element.equals("stream") && ns.equals("http://etherx.jabber.org/streams")) {
+ if (element.equals("stream")
+ && ns.equals("http://etherx.jabber.org/streams")) {
ProtocolHeader header = new ProtocolHeader();
header.setFrom(attributes.getAttribute("from"));
header.setTo(attributes.getAttribute("to"));
@@ -70,7 +70,7 @@ public class XMPPParser implements XMLParserClient {
}
++currentDepth_;
}
-
+
public void handleEndElement(String element, String ns) {
assert (inStream());
if (inElement()) {
@@ -87,89 +87,74 @@ public class XMPPParser implements XMLParserClient {
client_.handleStreamEnd();
}
}
-
+
public void handleCharacterData(String data) {
if (currentElementParser_ != null) {
currentElementParser_.handleCharacterData(data);
}
}
-
+
private boolean inStream() {
return currentDepth_ > 0;
}
-
+
private boolean inElement() {
return currentDepth_ > 1;
}
-
+
private ElementParser createElementParser(String element, String xmlns) {
if (element.equals("presence")) {
return new PresenceParser(payloadParserFactories_);
- }
- else if (element.equals("iq")) {
+ } else if (element.equals("iq")) {
return new IQParser(payloadParserFactories_);
- }
- else if (element.equals("message")) {
+ } else if (element.equals("message")) {
return new MessageParser(payloadParserFactories_);
- }
- else if (element.equals("features") && xmlns.equals("http://etherx.jabber.org/streams")) {
+ } else if (element.equals("features")
+ && xmlns.equals("http://etherx.jabber.org/streams")) {
return new StreamFeaturesParser();
- }
- else if (element.equals("auth")) {
+ } else if (element.equals("auth")) {
return new AuthRequestParser();
- }
- else if (element.equals("success")) {
+ } else if (element.equals("success")) {
return new AuthSuccessParser();
- }
- else if (element.equals("failure") && xmlns.equals("urn:ietf:params:xml:ns:xmpp-sasl")) {
+ } else if (element.equals("failure")
+ && xmlns.equals("urn:ietf:params:xml:ns:xmpp-sasl")) {
return new AuthFailureParser();
- }
- else if (element.equals("challenge") && xmlns.equals("urn:ietf:params:xml:ns:xmpp-sasl")) {
+ } else if (element.equals("challenge")
+ && xmlns.equals("urn:ietf:params:xml:ns:xmpp-sasl")) {
return new AuthChallengeParser();
- }
- else if (element.equals("response") && xmlns.equals("urn:ietf:params:xml:ns:xmpp-sasl")) {
+ } else if (element.equals("response")
+ && xmlns.equals("urn:ietf:params:xml:ns:xmpp-sasl")) {
return new AuthResponseParser();
- }
- else if (element.equals("starttls")) {
+ } else if (element.equals("starttls")) {
return new StartTLSParser();
- }
- else if (element.equals("failure") && xmlns.equals("urn:ietf:params:xml:ns:xmpp-tls")) {
+ } else if (element.equals("failure")
+ && xmlns.equals("urn:ietf:params:xml:ns:xmpp-tls")) {
return new StartTLSFailureParser();
- }
- else if (element.equals("compress")) {
+ } else if (element.equals("compress")) {
return new CompressParser();
- }
- else if (element.equals("compressed")) {
+ } else if (element.equals("compressed")) {
return new CompressedParser();
- }
- else if (element.equals("failure") && xmlns.equals("http://jabber.org/protocol/compress")) {
+ } else if (element.equals("failure")
+ && xmlns.equals("http://jabber.org/protocol/compress")) {
return new CompressFailureParser();
- }
- else if (element.equals("proceed")) {
+ } else if (element.equals("proceed")) {
return new TLSProceedParser();
- }
- else if (element.equals("enable") && xmlns.equals("urn:xmpp:sm:2")) {
+ } else if (element.equals("enable") && xmlns.equals("urn:xmpp:sm:2")) {
return new EnableStreamManagementParser();
- }
- else if (element.equals("enabled") && xmlns.equals("urn:xmpp:sm:2")) {
+ } else if (element.equals("enabled") && xmlns.equals("urn:xmpp:sm:2")) {
return new StreamManagementEnabledParser();
- }
- else if (element.equals("failed") && xmlns.equals("urn:xmpp:sm:2")) {
+ } else if (element.equals("failed") && xmlns.equals("urn:xmpp:sm:2")) {
return new StreamManagementFailedParser();
- }
- else if (element.equals("resume") && xmlns.equals("urn:xmpp:sm:2")) {
+ } else if (element.equals("resume") && xmlns.equals("urn:xmpp:sm:2")) {
return new StreamResumeParser();
- }
- else if (element.equals("resumed") && xmlns.equals("urn:xmpp:sm:2")) {
+ } else if (element.equals("resumed") && xmlns.equals("urn:xmpp:sm:2")) {
return new StreamResumedParser();
- }
- else if (element.equals("a") && xmlns.equals("urn:xmpp:sm:2")) {
+ } else if (element.equals("a") && xmlns.equals("urn:xmpp:sm:2")) {
return new StanzaAckParser();
- }
- else if (element.equals("r") && xmlns.equals("urn:xmpp:sm:2")) {
+ } else if (element.equals("r") && xmlns.equals("urn:xmpp:sm:2")) {
return new StanzaAckRequestParser();
}
return new UnknownElementParser();
-
+
}
}
diff --git a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
index 1abce76..cf41338 100644
--- a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
+++ b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
@@ -9,8 +9,10 @@
package com.isode.stroke.parser.payloadparsers;
import com.isode.stroke.parser.GenericPayloadParserFactory;
+import com.isode.stroke.parser.GenericPayloadParserFactory2;
import com.isode.stroke.parser.PayloadParserFactory;
import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.parser.PubSubOwnerPubSubParser;
public class FullPayloadParserFactoryCollection extends PayloadParserFactoryCollection {
public FullPayloadParserFactoryCollection() {
@@ -57,7 +59,12 @@ public class FullPayloadParserFactoryCollection extends PayloadParserFactoryColl
addFactory(new GenericPayloadParserFactory<MUCDestroyPayloadParser>("destroy",
"http://jabber.org/protocol/muc#owner",MUCDestroyPayloadParser.class));
- //addFactory(new NicknameParserFactory());
+ addFactory(new GenericPayloadParserFactory2<PubSubParser>("pubsub", "http://jabber.org/protocol/pubsub", this, PubSubParser.class));
+ addFactory(new GenericPayloadParserFactory2<PubSubOwnerPubSubParser>("pubsub", "http://jabber.org/protocol/pubsub#owner", this, PubSubOwnerPubSubParser.class));
+ addFactory(new GenericPayloadParserFactory2<PubSubEventParser>("event", "http://jabber.org/protocol/pubsub#event", this, PubSubEventParser.class));
+ addFactory(new PubSubErrorParserFactory());
+
+ //addFactory(new NicknameParserFactory());
PayloadParserFactory defaultFactory = new RawXMLPayloadParserFactory();
setDefaultFactory(defaultFactory);
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubAffiliationParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubAffiliationParser.java
new file mode 100644
index 0000000..4037f16
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubAffiliationParser.java
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubAffiliation;
+
+public class PubSubAffiliationParser extends GenericPayloadParser<PubSubAffiliation> {
+public PubSubAffiliationParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubAffiliation());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("affiliation");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setType(parseType(attributeValue));
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+private static PubSubAffiliation.Type parseType(String value) {
+ if (value.equals("none")) {
+ return PubSubAffiliation.Type.None;
+ } else if (value.equals("member")) {
+ return PubSubAffiliation.Type.Member;
+ } else if (value.equals("outcast")) {
+ return PubSubAffiliation.Type.Outcast;
+ } else if (value.equals("owner")) {
+ return PubSubAffiliation.Type.Owner;
+ } else if (value.equals("publisher")) {
+ return PubSubAffiliation.Type.Publisher;
+ } else if (value.equals("publish-only")) {
+ return PubSubAffiliation.Type.PublishOnly;
+ } else {
+ return null;
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubAffiliationsParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubAffiliationsParser.java
new file mode 100644
index 0000000..23cfb3a
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubAffiliationsParser.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubAffiliation;
+import com.isode.stroke.elements.PubSubAffiliations;
+
+public class PubSubAffiliationsParser extends GenericPayloadParser<PubSubAffiliations> {
+public PubSubAffiliationsParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubAffiliations());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("affiliation") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ currentPayloadParser_ = new PubSubAffiliationParser(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) {
+ return;
+ }
+ if (element.equals("affiliation") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ getPayloadInternal().addAffiliation((PubSubAffiliation)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubConfigureParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubConfigureParser.java
new file mode 100644
index 0000000..bceda09
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubConfigureParser.java
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.parser.payloadparsers.FormParser;
+import com.isode.stroke.elements.PubSubConfigure;
+
+public class PubSubConfigureParser extends GenericPayloadParser<PubSubConfigure> {
+public PubSubConfigureParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubConfigure());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 1) {
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ currentPayloadParser_ = new FormParser();
+ }
+ }
+
+ 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) {
+ return;
+ }
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ getPayloadInternal().setData((Form)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubCreateParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubCreateParser.java
new file mode 100644
index 0000000..8c56dc6
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubCreateParser.java
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubConfigure;
+import com.isode.stroke.elements.PubSubCreate;
+
+public class PubSubCreateParser extends GenericPayloadParser<PubSubCreate> {
+public PubSubCreateParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubCreate());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubDefaultParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubDefaultParser.java
new file mode 100644
index 0000000..643383c
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubDefaultParser.java
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubDefault;
+
+public class PubSubDefaultParser extends GenericPayloadParser<PubSubDefault> {
+public PubSubDefaultParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubDefault());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("type");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setType(parseType(attributeValue));
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+private static PubSubDefault.Type parseType(String value) {
+ if (value.equals("none")) {
+ return PubSubDefault.Type.None;
+ } else if (value.equals("collection")) {
+ return PubSubDefault.Type.Collection;
+ } else if (value.equals("leaf")) {
+ return PubSubDefault.Type.Leaf;
+ } else {
+ return null;
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubErrorParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubErrorParser.java
new file mode 100644
index 0000000..e0b5ed0
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubErrorParser.java
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import java.util.HashMap;
+
+import com.isode.stroke.elements.PubSubError;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class PubSubErrorParser extends GenericPayloadParser<PubSubError> {
+
+public PubSubErrorParser()
+{
+ super(new PubSubError(PubSubError.Type.UnknownType));
+
+ typeParser_.put("closed-node", PubSubError.Type.ClosedNode);
+ typeParser_.put("configuration-required", PubSubError.Type.ConfigurationRequired);
+ typeParser_.put("invalid-jid", PubSubError.Type.InvalidJID);
+ typeParser_.put("invalid-options", PubSubError.Type.InvalidOptions);
+ typeParser_.put("invalid-payload", PubSubError.Type.InvalidPayload);
+ typeParser_.put("invalid-subid", PubSubError.Type.InvalidSubscriptionID);
+ typeParser_.put("item-forbidden", PubSubError.Type.ItemForbidden);
+ typeParser_.put("item-required", PubSubError.Type.ItemRequired);
+ typeParser_.put("jid-required", PubSubError.Type.JIDRequired);
+ typeParser_.put("max-items-exceeded", PubSubError.Type.MaximumItemsExceeded);
+ typeParser_.put("max-nodes-exceeded", PubSubError.Type.MaximumNodesExceeded);
+ typeParser_.put("nodeid-required", PubSubError.Type.NodeIDRequired);
+ typeParser_.put("not-in-roster-group", PubSubError.Type.NotInRosterGroup);
+ typeParser_.put("not-subscribed", PubSubError.Type.NotSubscribed);
+ typeParser_.put("payload-too-big", PubSubError.Type.PayloadTooBig);
+ typeParser_.put("payload-required", PubSubError.Type.PayloadRequired);
+ typeParser_.put("pending-subscription", PubSubError.Type.PendingSubscription);
+ typeParser_.put("presence-subscription-required", PubSubError.Type.PresenceSubscriptionRequired);
+ typeParser_.put("subid-required", PubSubError.Type.SubscriptionIDRequired);
+ typeParser_.put("too-many-subscriptions", PubSubError.Type.TooManySubscriptions);
+ typeParser_.put("unsupported", PubSubError.Type.Unsupported);
+ typeParser_.put("unsupported-access-model", PubSubError.Type.UnsupportedAccessModel);
+
+ unsupportedTypeParser_.put("access-authorize", PubSubError.UnsupportedFeatureType.AccessAuthorize);
+ unsupportedTypeParser_.put("access-open", PubSubError.UnsupportedFeatureType.AccessOpen);
+ unsupportedTypeParser_.put("access-presence", PubSubError.UnsupportedFeatureType.AccessPresence);
+ unsupportedTypeParser_.put("access-roster", PubSubError.UnsupportedFeatureType.AccessRoster);
+ unsupportedTypeParser_.put("access-whitelist", PubSubError.UnsupportedFeatureType.AccessWhitelist);
+ unsupportedTypeParser_.put("auto-create", PubSubError.UnsupportedFeatureType.AutoCreate);
+ unsupportedTypeParser_.put("auto-subscribe", PubSubError.UnsupportedFeatureType.AutoSubscribe);
+ unsupportedTypeParser_.put("collections", PubSubError.UnsupportedFeatureType.Collections);
+ unsupportedTypeParser_.put("config-node", PubSubError.UnsupportedFeatureType.ConfigNode);
+ unsupportedTypeParser_.put("create-and-configure", PubSubError.UnsupportedFeatureType.CreateAndConfigure);
+ unsupportedTypeParser_.put("create-nodes", PubSubError.UnsupportedFeatureType.CreateNodes);
+ unsupportedTypeParser_.put("delete-items", PubSubError.UnsupportedFeatureType.DeleteItems);
+ unsupportedTypeParser_.put("delete-nodes", PubSubError.UnsupportedFeatureType.DeleteNodes);
+ unsupportedTypeParser_.put("filtered-notifications", PubSubError.UnsupportedFeatureType.FilteredNotifications);
+ unsupportedTypeParser_.put("get-pending", PubSubError.UnsupportedFeatureType.GetPending);
+ unsupportedTypeParser_.put("instant-nodes", PubSubError.UnsupportedFeatureType.InstantNodes);
+ unsupportedTypeParser_.put("item-ids", PubSubError.UnsupportedFeatureType.ItemIDs);
+ unsupportedTypeParser_.put("last-published", PubSubError.UnsupportedFeatureType.LastPublished);
+ unsupportedTypeParser_.put("leased-subscription", PubSubError.UnsupportedFeatureType.LeasedSubscription);
+ unsupportedTypeParser_.put("manage-subscriptions", PubSubError.UnsupportedFeatureType.ManageSubscriptions);
+ unsupportedTypeParser_.put("member-affiliation", PubSubError.UnsupportedFeatureType.MemberAffiliation);
+ unsupportedTypeParser_.put("meta-data", PubSubError.UnsupportedFeatureType.MetaData);
+ unsupportedTypeParser_.put("modify-affiliations", PubSubError.UnsupportedFeatureType.ModifyAffiliations);
+ unsupportedTypeParser_.put("multi-collection", PubSubError.UnsupportedFeatureType.MultiCollection);
+ unsupportedTypeParser_.put("multi-subscribe", PubSubError.UnsupportedFeatureType.MultiSubscribe);
+ unsupportedTypeParser_.put("outcast-affiliation", PubSubError.UnsupportedFeatureType.OutcastAffiliation);
+ unsupportedTypeParser_.put("persistent-items", PubSubError.UnsupportedFeatureType.PersistentItems);
+ unsupportedTypeParser_.put("presence-notifications", PubSubError.UnsupportedFeatureType.PresenceNotifications);
+ unsupportedTypeParser_.put("presence-subscribe", PubSubError.UnsupportedFeatureType.PresenceSubscribe);
+ unsupportedTypeParser_.put("publish", PubSubError.UnsupportedFeatureType.Publish);
+ unsupportedTypeParser_.put("publish-options", PubSubError.UnsupportedFeatureType.PublishOptions);
+ unsupportedTypeParser_.put("publish-only-affiliation", PubSubError.UnsupportedFeatureType.PublishOnlyAffiliation);
+ unsupportedTypeParser_.put("publisher-affiliation", PubSubError.UnsupportedFeatureType.PublisherAffiliation);
+ unsupportedTypeParser_.put("purge-nodes", PubSubError.UnsupportedFeatureType.PurgeNodes);
+ unsupportedTypeParser_.put("retract-items", PubSubError.UnsupportedFeatureType.RetractItems);
+ unsupportedTypeParser_.put("retrieve-affiliations", PubSubError.UnsupportedFeatureType.RetrieveAffiliations);
+ unsupportedTypeParser_.put("retrieve-default", PubSubError.UnsupportedFeatureType.RetrieveDefault);
+ unsupportedTypeParser_.put("retrieve-items", PubSubError.UnsupportedFeatureType.RetrieveItems);
+ unsupportedTypeParser_.put("retrieve-subscriptions", PubSubError.UnsupportedFeatureType.RetrieveSubscriptions);
+ unsupportedTypeParser_.put("subscribe", PubSubError.UnsupportedFeatureType.Subscribe);
+ unsupportedTypeParser_.put("subscription-options", PubSubError.UnsupportedFeatureType.SubscriptionOptions);
+ unsupportedTypeParser_.put("subscription-notifications", PubSubError.UnsupportedFeatureType.SubscriptionNotifications);
+}
+
+@Override
+public void handleStartElement(String element, String ns, AttributeMap attributes)
+{
+ if (level_ == 1) {
+ PubSubError.Type type = typeParser_.get(element);
+ if (type != null) {
+ getPayloadInternal().setType(type);
+ if (type.equals(PubSubError.Type.Unsupported)) {
+ String feature = attributes.getAttributeValue("feature");
+ if (feature != null) {
+ PubSubError.UnsupportedFeatureType unsupportedType = unsupportedTypeParser_.get(feature);
+ if (unsupportedType != null) {
+ getPayloadInternal().setUnsupportedFeatureType(unsupportedType);
+ }
+ }
+ }
+ }
+ }
+ ++level_;
+}
+
+@Override
+public void handleEndElement(String element, String ns)
+{
+ --level_;
+}
+
+@Override
+public void handleCharacterData(String data)
+{
+}
+
+int level_;
+HashMap<String, PubSubError.Type> typeParser_ = new HashMap<String, PubSubError.Type>();
+HashMap<String, PubSubError.UnsupportedFeatureType> unsupportedTypeParser_ = new HashMap<String, PubSubError.UnsupportedFeatureType>();
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubErrorParserFactory.java b/src/com/isode/stroke/parser/payloadparsers/PubSubErrorParserFactory.java
new file mode 100644
index 0000000..78c07ed
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubErrorParserFactory.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2014, Remko Tronçon.
+ * All rights reserved.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactory;
+
+public class PubSubErrorParserFactory implements PayloadParserFactory {
+
+ @Override
+ public boolean canParse(String element, String ns, AttributeMap attributes) {
+ return ns.equals("http://jabber.org/protocol/pubsub#errors");
+ }
+
+ @Override
+ public PayloadParser createPayloadParser() {
+ return new PubSubErrorParser();
+ }
+
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEvent.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEvent.java
new file mode 100644
index 0000000..6fb9e17
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEvent.java
@@ -0,0 +1,17 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.ContainerPayload;
+import com.isode.stroke.elements.PubSubEventPayload;
+
+public class PubSubEvent extends ContainerPayload<PubSubEventPayload> {
+
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventAssociateParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventAssociateParser.java
new file mode 100644
index 0000000..900e2e6
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventAssociateParser.java
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubEventAssociate;
+
+public class PubSubEventAssociateParser extends GenericPayloadParser<PubSubEventAssociate> {
+public PubSubEventAssociateParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventAssociate());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventCollectionParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventCollectionParser.java
new file mode 100644
index 0000000..467ab5b
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventCollectionParser.java
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubEventAssociate;
+import com.isode.stroke.elements.PubSubEventDisassociate;
+import com.isode.stroke.elements.PubSubEventCollection;
+
+public class PubSubEventCollectionParser extends GenericPayloadParser<PubSubEventCollection> {
+public PubSubEventCollectionParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventCollection());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("associate") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ currentPayloadParser_ = new PubSubEventAssociateParser(parsers_);
+ }
+ if (element.equals("disassociate") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ currentPayloadParser_ = new PubSubEventDisassociateParser(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) {
+ return;
+ }
+ if (element.equals("associate") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ getPayloadInternal().setAssociate((PubSubEventAssociate)(currentPayloadParser_.getPayload()));
+ }
+ if (element.equals("disassociate") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ getPayloadInternal().setDisassociate((PubSubEventDisassociate)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventConfigurationParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventConfigurationParser.java
new file mode 100644
index 0000000..7848328
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventConfigurationParser.java
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.parser.payloadparsers.FormParser;
+import com.isode.stroke.elements.PubSubEventConfiguration;
+
+public class PubSubEventConfigurationParser extends GenericPayloadParser<PubSubEventConfiguration> {
+public PubSubEventConfigurationParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventConfiguration());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ currentPayloadParser_ = new FormParser();
+ }
+ }
+
+ 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) {
+ return;
+ }
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ getPayloadInternal().setData((Form)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventDeleteParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventDeleteParser.java
new file mode 100644
index 0000000..1663e36
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventDeleteParser.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubEventRedirect;
+import com.isode.stroke.elements.PubSubEventDelete;
+
+public class PubSubEventDeleteParser extends GenericPayloadParser<PubSubEventDelete> {
+public PubSubEventDeleteParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventDelete());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("redirect") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ currentPayloadParser_ = new PubSubEventRedirectParser(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) {
+ return;
+ }
+ if (element.equals("redirect") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ getPayloadInternal().setRedirects((PubSubEventRedirect)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventDisassociateParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventDisassociateParser.java
new file mode 100644
index 0000000..90f510f
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventDisassociateParser.java
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubEventDisassociate;
+
+public class PubSubEventDisassociateParser extends GenericPayloadParser<PubSubEventDisassociate> {
+public PubSubEventDisassociateParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventDisassociate());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventItemParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventItemParser.java
new file mode 100644
index 0000000..508f836
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventItemParser.java
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.parser.PayloadParserFactory;
+import com.isode.stroke.elements.PubSubEventItem;
+
+public class PubSubEventItemParser extends GenericPayloadParser<PubSubEventItem> {
+public PubSubEventItemParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventItem());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("publisher");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setPublisher(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("id");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setID(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ PayloadParserFactory factory;
+ factory = parsers_.getPayloadParserFactory(element, ns, attributes);
+ if (factory != null) {
+ currentPayloadParser_ = factory.createPayloadParser();
+ }
+ }
+
+ 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) {
+ return;
+ }
+ getPayloadInternal().addData(currentPayloadParser_.getPayload());
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventItemsParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventItemsParser.java
new file mode 100644
index 0000000..e5d9e47
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventItemsParser.java
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubEventItem;
+import com.isode.stroke.elements.PubSubEventRetract;
+import com.isode.stroke.elements.PubSubEventItems;
+
+public class PubSubEventItemsParser extends GenericPayloadParser<PubSubEventItems> {
+public PubSubEventItemsParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventItems());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("item") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ currentPayloadParser_ = new PubSubEventItemParser(parsers_);
+ }
+ if (element.equals("retract") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ currentPayloadParser_ = new PubSubEventRetractParser(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) {
+ return;
+ }
+ if (element.equals("item") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ getPayloadInternal().addItem((PubSubEventItem)currentPayloadParser_.getPayload());
+ }
+ if (element.equals("retract") && ns.equals("http://jabber.org/protocol/pubsub#event")) {
+ getPayloadInternal().addRetract((PubSubEventRetract)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java
new file mode 100644
index 0000000..d7bdbe6
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.PubSubEventPayload;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+
+public class PubSubEventParser extends GenericPayloadParser<PubSubEvent> {
+
+public PubSubEventParser(PayloadParserFactoryCollection parser) {
+ super(new PubSubEvent());
+ parsers_ = parser;
+}
+
+@Override
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 1) {
+ if (element == "items" && ns == "http://jabber.org/protocol/pubsub#event") {
+ currentPayloadParser_ = new PubSubEventItemsParser(parsers_);
+ }
+ if (element == "collection" && ns == "http://jabber.org/protocol/pubsub#event") {
+ currentPayloadParser_ = new PubSubEventCollectionParser(parsers_);
+ }
+ if (element == "purge" && ns == "http://jabber.org/protocol/pubsub#event") {
+ currentPayloadParser_ = new PubSubEventPurgeParser(parsers_);
+ }
+ if (element == "configuration" && ns == "http://jabber.org/protocol/pubsub#event") {
+ currentPayloadParser_ = new PubSubEventConfigurationParser(parsers_);
+ }
+ if (element == "delete" && ns == "http://jabber.org/protocol/pubsub#event") {
+ currentPayloadParser_ = new PubSubEventDeleteParser(parsers_);
+ }
+ if (element == "subscription" && ns == "http://jabber.org/protocol/pubsub#event") {
+ currentPayloadParser_ = new PubSubEventSubscriptionParser(parsers_);
+ }
+ }
+
+ if (level_>=1 && currentPayloadParser_!=null) {
+ currentPayloadParser_.handleStartElement(element, ns, attributes);
+ }
+ ++level_;
+}
+
+@Override
+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((PubSubEventPayload)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+ }
+}
+
+@Override
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_!=null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventPurgeParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventPurgeParser.java
new file mode 100644
index 0000000..fd4e525
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventPurgeParser.java
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubEventPurge;
+
+public class PubSubEventPurgeParser extends GenericPayloadParser<PubSubEventPurge> {
+public PubSubEventPurgeParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventPurge());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventRedirectParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventRedirectParser.java
new file mode 100644
index 0000000..3e157d5
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventRedirectParser.java
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubEventRedirect;
+
+public class PubSubEventRedirectParser extends GenericPayloadParser<PubSubEventRedirect> {
+public PubSubEventRedirectParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventRedirect());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("uri");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setURI(attributeValue);
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventRetractParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventRetractParser.java
new file mode 100644
index 0000000..5e43e2e
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventRetractParser.java
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubEventRetract;
+
+public class PubSubEventRetractParser extends GenericPayloadParser<PubSubEventRetract> {
+public PubSubEventRetractParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventRetract());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("id");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setID(attributeValue);
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventSubscriptionParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventSubscriptionParser.java
new file mode 100644
index 0000000..eb01301
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventSubscriptionParser.java
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.jid.JID;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import com.isode.stroke.elements.PubSubEventSubscription;
+
+public class PubSubEventSubscriptionParser extends GenericPayloadParser<PubSubEventSubscription> {
+public PubSubEventSubscriptionParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubEventSubscription());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("subscription");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setSubscription(parseSubscriptionType(attributeValue));
+ }
+ attributeValue = attributes.getAttribute("subid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setSubscriptionID(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("jid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setJID(JID.fromString(attributeValue));
+ }
+ attributeValue = attributes.getAttribute("expiry");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setExpiry(stringToDate(attributeValue));
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+private static PubSubEventSubscription.SubscriptionType parseSubscriptionType(String value) {
+ if (value.equals("none")) {
+ return PubSubEventSubscription.SubscriptionType.None;
+ } else if (value.equals("pending")) {
+ return PubSubEventSubscription.SubscriptionType.Pending;
+ } else if (value.equals("subscribed")) {
+ return PubSubEventSubscription.SubscriptionType.Subscribed;
+ } else if (value.equals("unconfigured")) {
+ return PubSubEventSubscription.SubscriptionType.Unconfigured;
+ } else {
+ return null;
+ }
+}
+
+private static Date stringToDate(String date) {
+ String format = "YYYY-MM-ddThh:mm:ssZ";
+ SimpleDateFormat parser = new SimpleDateFormat(format);
+ try {
+ return parser.parse(date);
+ } catch (ParseException e) {
+ return null;
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubItemParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubItemParser.java
new file mode 100644
index 0000000..8eae0a5
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubItemParser.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.parser.PayloadParserFactory;
+import com.isode.stroke.elements.PubSubItem;
+
+public class PubSubItemParser extends GenericPayloadParser<PubSubItem> {
+public PubSubItemParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubItem());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("id");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setID(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ PayloadParserFactory factory;
+ factory = parsers_.getPayloadParserFactory(element, ns, attributes);
+ if (factory != null) {
+ currentPayloadParser_ = factory.createPayloadParser();
+ }
+ }
+
+ 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) {
+ return;
+ }
+ getPayloadInternal().addData(currentPayloadParser_.getPayload());
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubItemsParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubItemsParser.java
new file mode 100644
index 0000000..b69e9b6
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubItemsParser.java
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubItem;
+import com.isode.stroke.elements.PubSubItems;
+
+public class PubSubItemsParser extends GenericPayloadParser<PubSubItems> {
+public PubSubItemsParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubItems());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("max_items");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setMaximumItems(Long.parseLong(attributeValue));
+ }
+ attributeValue = attributes.getAttribute("subid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setSubscriptionID(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("item") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ currentPayloadParser_ = new PubSubItemParser(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) {
+ return;
+ }
+ if (element.equals("item") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ getPayloadInternal().addItem((PubSubItem)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOptionsParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOptionsParser.java
new file mode 100644
index 0000000..97fbd7a
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOptionsParser.java
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.parser.payloadparsers.FormParser;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubOptions;
+
+public class PubSubOptionsParser extends GenericPayloadParser<PubSubOptions> {
+public PubSubOptionsParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOptions());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("subid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setSubscriptionID(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("jid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setJID(JID.fromString(attributeValue));
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ currentPayloadParser_ = new FormParser();
+ }
+ }
+
+ 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) {
+ return;
+ }
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ getPayloadInternal().setData((Form)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerAffiliationParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerAffiliationParser.java
new file mode 100644
index 0000000..2ca3659
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerAffiliationParser.java
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubOwnerAffiliation;
+
+public class PubSubOwnerAffiliationParser extends GenericPayloadParser<PubSubOwnerAffiliation> {
+public PubSubOwnerAffiliationParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerAffiliation());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("jid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setJID(JID.fromString(attributeValue));
+ }
+ attributeValue = attributes.getAttribute("affiliation");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setType(parseType(attributeValue));
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+private static PubSubOwnerAffiliation.Type parseType(String value) {
+ if (value.equals("none")) {
+ return PubSubOwnerAffiliation.Type.None;
+ } else if (value.equals("member")) {
+ return PubSubOwnerAffiliation.Type.Member;
+ } else if (value.equals("outcast")) {
+ return PubSubOwnerAffiliation.Type.Outcast;
+ } else if (value.equals("owner")) {
+ return PubSubOwnerAffiliation.Type.Owner;
+ } else if (value.equals("publisher")) {
+ return PubSubOwnerAffiliation.Type.Publisher;
+ } else if (value.equals("publish-only")) {
+ return PubSubOwnerAffiliation.Type.PublishOnly;
+ } else {
+ return null;
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerAffiliationsParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerAffiliationsParser.java
new file mode 100644
index 0000000..843a834
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerAffiliationsParser.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubOwnerAffiliation;
+import com.isode.stroke.elements.PubSubOwnerAffiliations;
+
+public class PubSubOwnerAffiliationsParser extends GenericPayloadParser<PubSubOwnerAffiliations> {
+public PubSubOwnerAffiliationsParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerAffiliations());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("affiliation") && ns.equals("http://jabber.org/protocol/pubsub#owner")) {
+ currentPayloadParser_ = new PubSubOwnerAffiliationParser(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) {
+ return;
+ }
+ if (element.equals("affiliation") && ns.equals("http://jabber.org/protocol/pubsub#owner")) {
+ getPayloadInternal().addAffiliation((PubSubOwnerAffiliation)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerConfigureParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerConfigureParser.java
new file mode 100644
index 0000000..66b111c
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerConfigureParser.java
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.parser.payloadparsers.FormParser;
+import com.isode.stroke.elements.PubSubOwnerConfigure;
+
+public class PubSubOwnerConfigureParser extends GenericPayloadParser<PubSubOwnerConfigure> {
+public PubSubOwnerConfigureParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerConfigure());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ currentPayloadParser_ = new FormParser();
+ }
+ }
+
+ 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) {
+ return;
+ }
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ getPayloadInternal().setData((Form)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerDefaultParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerDefaultParser.java
new file mode 100644
index 0000000..ca9ea5e
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerDefaultParser.java
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.Form;
+import com.isode.stroke.parser.payloadparsers.FormParser;
+import com.isode.stroke.elements.PubSubOwnerDefault;
+
+public class PubSubOwnerDefaultParser extends GenericPayloadParser<PubSubOwnerDefault> {
+public PubSubOwnerDefaultParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerDefault());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 1) {
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ currentPayloadParser_ = new FormParser();
+ }
+ }
+
+ 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) {
+ return;
+ }
+ if (element.equals("x") && ns.equals("jabber:x:data")) {
+ getPayloadInternal().setData((Form)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerDeleteParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerDeleteParser.java
new file mode 100644
index 0000000..37c4bc7
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerDeleteParser.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubOwnerRedirect;
+import com.isode.stroke.elements.PubSubOwnerDelete;
+
+public class PubSubOwnerDeleteParser extends GenericPayloadParser<PubSubOwnerDelete> {
+public PubSubOwnerDeleteParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerDelete());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("redirect") && ns.equals("http://jabber.org/protocol/pubsub#owner")) {
+ currentPayloadParser_ = new PubSubOwnerRedirectParser(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) {
+ return;
+ }
+ if (element.equals("redirect") && ns.equals("http://jabber.org/protocol/pubsub#owner")) {
+ getPayloadInternal().setRedirect((PubSubOwnerRedirect)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerPurgeParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerPurgeParser.java
new file mode 100644
index 0000000..0ac6e22
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerPurgeParser.java
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubOwnerPurge;
+
+public class PubSubOwnerPurgeParser extends GenericPayloadParser<PubSubOwnerPurge> {
+public PubSubOwnerPurgeParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerPurge());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerRedirectParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerRedirectParser.java
new file mode 100644
index 0000000..5a8f5fe
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerRedirectParser.java
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubOwnerRedirect;
+
+public class PubSubOwnerRedirectParser extends GenericPayloadParser<PubSubOwnerRedirect> {
+public PubSubOwnerRedirectParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerRedirect());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("uri");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setURI(attributeValue);
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerSubscriptionParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerSubscriptionParser.java
new file mode 100644
index 0000000..90d1f3b
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerSubscriptionParser.java
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubOwnerSubscription;
+
+public class PubSubOwnerSubscriptionParser extends GenericPayloadParser<PubSubOwnerSubscription> {
+public PubSubOwnerSubscriptionParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerSubscription());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("subscription");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setSubscription(parseSubscriptionType(attributeValue));
+ }
+ attributeValue = attributes.getAttribute("jid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setJID(JID.fromString(attributeValue));
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+private static PubSubOwnerSubscription.SubscriptionType parseSubscriptionType(String value) {
+ if (value.equals("none")) {
+ return PubSubOwnerSubscription.SubscriptionType.None;
+ } else if (value.equals("pending")) {
+ return PubSubOwnerSubscription.SubscriptionType.Pending;
+ } else if (value.equals("subscribed")) {
+ return PubSubOwnerSubscription.SubscriptionType.Subscribed;
+ } else if (value.equals("unconfigured")) {
+ return PubSubOwnerSubscription.SubscriptionType.Unconfigured;
+ } else {
+ return null;
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerSubscriptionsParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerSubscriptionsParser.java
new file mode 100644
index 0000000..f4f8508
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerSubscriptionsParser.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubOwnerSubscription;
+import com.isode.stroke.elements.PubSubOwnerSubscriptions;
+
+public class PubSubOwnerSubscriptionsParser extends GenericPayloadParser<PubSubOwnerSubscriptions> {
+public PubSubOwnerSubscriptionsParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubOwnerSubscriptions());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("subscription") && ns.equals("http://jabber.org/protocol/pubsub#owner")) {
+ currentPayloadParser_ = new PubSubOwnerSubscriptionParser(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) {
+ return;
+ }
+ if (element.equals("subscription") && ns.equals("http://jabber.org/protocol/pubsub#owner")) {
+ getPayloadInternal().addSubscription((PubSubOwnerSubscription)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubParser.java
new file mode 100644
index 0000000..134d654
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubParser.java
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.PubSub;
+import com.isode.stroke.elements.PubSubConfigure;
+import com.isode.stroke.elements.PubSubCreate;
+import com.isode.stroke.elements.PubSubOptions;
+import com.isode.stroke.elements.PubSubPayload;
+import com.isode.stroke.elements.PubSubSubscribe;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+
+public class PubSubParser extends GenericPayloadParser<PubSub> {
+
+ public PubSubParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSub());
+ parsers_ = parsers;
+ level_ = 0;
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 1) {
+ if (element == "items" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubItemsParser(parsers_);
+ }
+ if (element == "create" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubCreateParser(parsers_);
+ }
+ if (element == "publish" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubPublishParser(parsers_);
+ }
+ if (element == "affiliations" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubAffiliationsParser(parsers_);
+ }
+ if (element == "retract" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubRetractParser(parsers_);
+ }
+ if (element == "options" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubOptionsParser(parsers_);
+ }
+ if (element == "configure" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubConfigureParser(parsers_);
+ }
+ if (element == "default" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubDefaultParser(parsers_);
+ }
+ if (element == "subscriptions" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubSubscriptionsParser(parsers_);
+ }
+ if (element == "subscribe" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubSubscribeParser(parsers_);
+ }
+ if (element == "unsubscribe" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubUnsubscribeParser(parsers_);
+ }
+ if (element == "subscription" && ns == "http://jabber.org/protocol/pubsub") {
+ currentPayloadParser_ = new PubSubSubscriptionParser(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) {
+ if (element == "options" && ns == "http://jabber.org/protocol/pubsub") {
+ optionsPayload_ = (PubSubOptions)currentPayloadParser_.getPayload();
+ }
+ else if (element == "configure" && ns == "http://jabber.org/protocol/pubsub") {
+ configurePayload_ = (PubSubConfigure)currentPayloadParser_.getPayload();
+ }
+ else {
+ getPayloadInternal().setPayload((PubSubPayload)currentPayloadParser_.getPayload());
+ }
+ }
+ currentPayloadParser_ = null;
+ }
+
+ if (level_ == 0) {
+ PubSubCreate create = (PubSubCreate)getPayloadInternal().getPayload();
+ if (create != null) {
+ if (configurePayload_ != null) {
+ create.setConfigure(configurePayload_);
+ }
+ }
+ PubSubSubscribe subscribe = (PubSubSubscribe)getPayloadInternal().getPayload();
+ if (subscribe != null) {
+ if (optionsPayload_ != null) {
+ subscribe.setOptions(optionsPayload_);
+ }
+ }
+ }
+ }
+ }
+
+ public void handleCharacterData(String data) {
+ if (level_>1 && currentPayloadParser_!=null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+ }
+
+
+ PayloadParserFactoryCollection parsers_;
+ int level_;
+ PayloadParser currentPayloadParser_;
+ PubSubConfigure configurePayload_;
+ PubSubOptions optionsPayload_;
+
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubPublishParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubPublishParser.java
new file mode 100644
index 0000000..4fe9af5
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubPublishParser.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubItem;
+import com.isode.stroke.elements.PubSubPublish;
+
+public class PubSubPublishParser extends GenericPayloadParser<PubSubPublish> {
+public PubSubPublishParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubPublish());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("item") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ currentPayloadParser_ = new PubSubItemParser(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) {
+ return;
+ }
+ if (element.equals("item") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ getPayloadInternal().addItem((PubSubItem)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubRetractParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubRetractParser.java
new file mode 100644
index 0000000..5e38361
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubRetractParser.java
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubItem;
+import com.isode.stroke.elements.PubSubRetract;
+
+public class PubSubRetractParser extends GenericPayloadParser<PubSubRetract> {
+public PubSubRetractParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubRetract());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("notify");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNotify(attributeValue.equals("true") ? true : false);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("item") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ currentPayloadParser_ = new PubSubItemParser(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) {
+ return;
+ }
+ if (element.equals("item") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ getPayloadInternal().addItem((PubSubItem)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubSubscribeOptionsParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubSubscribeOptionsParser.java
new file mode 100644
index 0000000..14e3412
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubSubscribeOptionsParser.java
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubSubscribeOptions;
+
+public class PubSubSubscribeOptionsParser extends GenericPayloadParser<PubSubSubscribeOptions> {
+public PubSubSubscribeOptionsParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubSubscribeOptions());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ 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) {
+ return;
+ }
+ if (element.equals("required")) {
+ getPayloadInternal().setRequired(true);
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubSubscribeParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubSubscribeParser.java
new file mode 100644
index 0000000..dbc8449
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubSubscribeParser.java
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubOptions;
+import com.isode.stroke.elements.PubSubSubscribe;
+
+public class PubSubSubscribeParser extends GenericPayloadParser<PubSubSubscribe> {
+public PubSubSubscribeParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubSubscribe());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("jid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setJID(JID.fromString(attributeValue));
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubSubscriptionParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubSubscriptionParser.java
new file mode 100644
index 0000000..5d11f2e
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubSubscriptionParser.java
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubSubscribeOptions;
+import com.isode.stroke.elements.PubSubSubscription;
+
+public class PubSubSubscriptionParser extends GenericPayloadParser<PubSubSubscription> {
+public PubSubSubscriptionParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubSubscription());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("subscription");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setSubscription(parseSubscriptionType(attributeValue));
+ }
+ attributeValue = attributes.getAttribute("subid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setSubscriptionID(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("jid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setJID(JID.fromString(attributeValue));
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("subscribe-options") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ currentPayloadParser_ = new PubSubSubscribeOptionsParser(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) {
+ return;
+ }
+ if (element.equals("subscribe-options") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ getPayloadInternal().setOptions((PubSubSubscribeOptions)(currentPayloadParser_.getPayload()));
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+private static PubSubSubscription.SubscriptionType parseSubscriptionType(String value) {
+ if (value.equals("none")) {
+ return PubSubSubscription.SubscriptionType.None;
+ } else if (value.equals("pending")) {
+ return PubSubSubscription.SubscriptionType.Pending;
+ } else if (value.equals("subscribed")) {
+ return PubSubSubscription.SubscriptionType.Subscribed;
+ } else if (value.equals("unconfigured")) {
+ return PubSubSubscription.SubscriptionType.Unconfigured;
+ } else {
+ return null;
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubSubscriptionsParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubSubscriptionsParser.java
new file mode 100644
index 0000000..f8c3a5c
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubSubscriptionsParser.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.elements.PubSubSubscription;
+import com.isode.stroke.elements.PubSubSubscriptions;
+
+public class PubSubSubscriptionsParser extends GenericPayloadParser<PubSubSubscriptions> {
+public PubSubSubscriptionsParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubSubscriptions());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ }
+
+ if (level_ == 1) {
+ if (element.equals("subscription") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ currentPayloadParser_ = new PubSubSubscriptionParser(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) {
+ return;
+ }
+ if (element.equals("subscription") && ns.equals("http://jabber.org/protocol/pubsub")) {
+ getPayloadInternal().addSubscription((PubSubSubscription)currentPayloadParser_.getPayload());
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubUnsubscribeParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubUnsubscribeParser.java
new file mode 100644
index 0000000..7ef44af
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubUnsubscribeParser.java
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.PubSubUnsubscribe;
+
+public class PubSubUnsubscribeParser extends GenericPayloadParser<PubSubUnsubscribe> {
+public PubSubUnsubscribeParser(PayloadParserFactoryCollection parsers) {
+ super(new PubSubUnsubscribe());
+
+ parsers_ = parsers;
+ level_ = 0;
+}
+
+public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String attributeValue;
+ attributeValue = attributes.getAttribute("subid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setSubscriptionID(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("node");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setNode(attributeValue);
+ }
+ attributeValue = attributes.getAttribute("jid");
+ if (!attributeValue.isEmpty()) {
+ getPayloadInternal().setJID(JID.fromString(attributeValue));
+ }
+ }
+
+ 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) {
+ return;
+ }
+ currentPayloadParser_ = null;
+ }
+}
+
+public void handleCharacterData(String data) {
+ if (level_ > 1 && currentPayloadParser_ != null) {
+ currentPayloadParser_.handleCharacterData(data);
+ }
+}
+
+PayloadParserFactoryCollection parsers_;
+int level_;
+PayloadParser currentPayloadParser_;
+}
diff --git a/src/com/isode/stroke/pubsub/PubSubManager.java b/src/com/isode/stroke/pubsub/PubSubManager.java
new file mode 100644
index 0000000..cd0f2a7
--- /dev/null
+++ b/src/com/isode/stroke/pubsub/PubSubManager.java
@@ -0,0 +1,18 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.pubsub;
+
+import com.isode.stroke.elements.PubSubEventPayload;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.signals.Signal2;
+
+public class PubSubManager {
+public Signal2<JID, PubSubEventPayload> onEvent = new Signal2<JID, PubSubEventPayload>();
+}
diff --git a/src/com/isode/stroke/pubsub/PubSubManagerImpl.java b/src/com/isode/stroke/pubsub/PubSubManagerImpl.java
new file mode 100644
index 0000000..ab1e8c6
--- /dev/null
+++ b/src/com/isode/stroke/pubsub/PubSubManagerImpl.java
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.pubsub;
+
+import com.isode.stroke.client.StanzaChannel;
+import com.isode.stroke.elements.Message;
+import com.isode.stroke.parser.payloadparsers.PubSubEvent;
+import com.isode.stroke.queries.IQRouter;
+import com.isode.stroke.signals.Slot1;
+
+public class PubSubManagerImpl extends PubSubManager {
+
+ public PubSubManagerImpl(StanzaChannel stanzaChannel, IQRouter router) {
+ stanzaChannel_ = stanzaChannel;
+ router_ = router;
+
+ stanzaChannel.onMessageReceived.connect(new Slot1<Message>() {
+ public void call(Message message) {
+ PubSubEvent event = (PubSubEvent)message.getPayload(new PubSubEvent());
+ if (event != null) {
+ onEvent.emit(message.getFrom(), event.getPayload());
+ }
+ }
+ });
+ }
+
+ StanzaChannel stanzaChannel_;
+ IQRouter router_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java
index d8a7a7d..f846d85 100644
--- a/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java
+++ b/src/com/isode/stroke/serializer/payloadserializers/FullPayloadSerializerCollection.java
@@ -56,6 +56,11 @@ public class FullPayloadSerializerCollection extends PayloadSerializerCollection
//addSerializer(new NicknameSerializer());
addSerializer(new SearchPayloadSerializer());
addSerializer(new LastSerializer());
+
+ addSerializer(new PubSubSerializer(this));
+ addSerializer(new PubSubEventSerializer(this));
+ addSerializer(new PubSubOwnerPubSubSerializer(this));
+ addSerializer(new PubSubErrorSerializer());
}
}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubAffiliationSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubAffiliationSerializer.java
new file mode 100644
index 0000000..df26b3a
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubAffiliationSerializer.java
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubAffiliation;
+
+public class PubSubAffiliationSerializer extends GenericPayloadSerializer<PubSubAffiliation> {
+public PubSubAffiliationSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubAffiliation.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubAffiliation payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("affiliation", "http://jabber.org/protocol/pubsub");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ element.setAttribute("affiliation", serializeType(payload.getType()));
+
+ return element.serialize();
+}
+
+private static String serializeType(PubSubAffiliation.Type value) {
+ switch (value) {
+ case None: return "none";
+ case Member: return "member";
+ case Outcast: return "outcast";
+ case Owner: return "owner";
+ case Publisher: return "publisher";
+ case PublishOnly: return "publish-only";
+ }
+ return "undefined-type";
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubAffiliationsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubAffiliationsSerializer.java
new file mode 100644
index 0000000..bceac02
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubAffiliationsSerializer.java
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubAffiliation;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubAffiliations;
+
+public class PubSubAffiliationsSerializer extends GenericPayloadSerializer<PubSubAffiliations> {
+public PubSubAffiliationsSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubAffiliations.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubAffiliations payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("affiliations", "http://jabber.org/protocol/pubsub");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ for (PubSubAffiliation item : payload.getAffiliations()) {
+ element.addNode(new XMLRawTextNode((new PubSubAffiliationSerializer(serializers_)).serialize(item)));
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubConfigureSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubConfigureSerializer.java
new file mode 100644
index 0000000..6f5dd10
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubConfigureSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.payloadserializers.FormSerializer;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubConfigure;
+
+public class PubSubConfigureSerializer extends GenericPayloadSerializer<PubSubConfigure> {
+public PubSubConfigureSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubConfigure.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubConfigure payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("configure", "http://jabber.org/protocol/pubsub");
+
+ element.addNode(new XMLRawTextNode((new FormSerializer()).serialize(payload.getData())));
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubCreateSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubCreateSerializer.java
new file mode 100644
index 0000000..45b4128
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubCreateSerializer.java
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubConfigure;
+import com.isode.stroke.elements.PubSubCreate;
+
+public class PubSubCreateSerializer extends GenericPayloadSerializer<PubSubCreate> {
+public PubSubCreateSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubCreate.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubCreate payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("create", "http://jabber.org/protocol/pubsub");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubDefaultSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubDefaultSerializer.java
new file mode 100644
index 0000000..88efb53
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubDefaultSerializer.java
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubDefault;
+
+public class PubSubDefaultSerializer extends GenericPayloadSerializer<PubSubDefault> {
+public PubSubDefaultSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubDefault.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubDefault payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("default", "http://jabber.org/protocol/pubsub");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ element.setAttribute("type", serializeType(payload.getType()));
+
+ return element.serialize();
+}
+
+private static String serializeType(PubSubDefault.Type value) {
+ switch (value) {
+ case None: return "none";
+ case Collection: return "collection";
+ case Leaf: return "leaf";
+ }
+ return "undefined-type";
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubErrorSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubErrorSerializer.java
new file mode 100644
index 0000000..d4f765f
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubErrorSerializer.java
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.elements.PubSubError;
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.xml.XMLElement;
+
+public class PubSubErrorSerializer extends GenericPayloadSerializer<PubSubError> {
+public PubSubErrorSerializer() {
+ super(PubSubError.class);
+}
+
+@Override
+public String serializePayload(PubSubError payload) {
+ if (payload.getType().equals(PubSubError.Type.UnknownType)) {
+ return "";
+ }
+ XMLElement element = new XMLElement(serializeType(payload.getType()), "http://jabber.org/protocol/pubsub#errors");
+ if (payload.getType().equals(PubSubError.Type.Unsupported)) {
+ if (!payload.getUnsupportedFeatureType().equals(PubSubError.UnsupportedFeatureType.UnknownUnsupportedFeatureType)) {
+ element.setAttribute("feature", serializeUnsupportedFeatureType(payload.getUnsupportedFeatureType()));
+ }
+ }
+ return element.serialize();
+}
+
+static String serializeType(PubSubError.Type value) {
+ switch (value) {
+ case UnknownType: return "";
+ case ClosedNode: return "closed-node";
+ case ConfigurationRequired: return "configuration-required";
+ case InvalidJID: return "invalid-jid";
+ case InvalidOptions: return "invalid-options";
+ case InvalidPayload: return "invalid-payload";
+ case InvalidSubscriptionID: return "invalid-subid";
+ case ItemForbidden: return "item-forbidden";
+ case ItemRequired: return "item-required";
+ case JIDRequired: return "jid-required";
+ case MaximumItemsExceeded: return "max-items-exceeded";
+ case MaximumNodesExceeded: return "max-nodes-exceeded";
+ case NodeIDRequired: return "nodeid-required";
+ case NotInRosterGroup: return "not-in-roster-group";
+ case NotSubscribed: return "not-subscribed";
+ case PayloadTooBig: return "payload-too-big";
+ case PayloadRequired: return "payload-required";
+ case PendingSubscription: return "pending-subscription";
+ case PresenceSubscriptionRequired: return "presence-subscription-required";
+ case SubscriptionIDRequired: return "subid-required";
+ case TooManySubscriptions: return "too-many-subscriptions";
+ case Unsupported: return "unsupported";
+ case UnsupportedAccessModel: return "unsupported-access-model";
+ default: return null;
+ }
+}
+
+static String serializeUnsupportedFeatureType(PubSubError.UnsupportedFeatureType value) {
+ switch (value) {
+ case UnknownUnsupportedFeatureType: assert(false); return "";
+ case AccessAuthorize: return "access-authorize";
+ case AccessOpen: return "access-open";
+ case AccessPresence: return "access-presence";
+ case AccessRoster: return "access-roster";
+ case AccessWhitelist: return "access-whitelist";
+ case AutoCreate: return "auto-create";
+ case AutoSubscribe: return "auto-subscribe";
+ case Collections: return "collections";
+ case ConfigNode: return "config-node";
+ case CreateAndConfigure: return "create-and-configure";
+ case CreateNodes: return "create-nodes";
+ case DeleteItems: return "delete-items";
+ case DeleteNodes: return "delete-nodes";
+ case FilteredNotifications: return "filtered-notifications";
+ case GetPending: return "get-pending";
+ case InstantNodes: return "instant-nodes";
+ case ItemIDs: return "item-ids";
+ case LastPublished: return "last-published";
+ case LeasedSubscription: return "leased-subscription";
+ case ManageSubscriptions: return "manage-subscriptions";
+ case MemberAffiliation: return "member-affiliation";
+ case MetaData: return "meta-data";
+ case ModifyAffiliations: return "modify-affiliations";
+ case MultiCollection: return "multi-collection";
+ case MultiSubscribe: return "multi-subscribe";
+ case OutcastAffiliation: return "outcast-affiliation";
+ case PersistentItems: return "persistent-items";
+ case PresenceNotifications: return "presence-notifications";
+ case PresenceSubscribe: return "presence-subscribe";
+ case Publish: return "publish";
+ case PublishOptions: return "publish-options";
+ case PublishOnlyAffiliation: return "publish-only-affiliation";
+ case PublisherAffiliation: return "publisher-affiliation";
+ case PurgeNodes: return "purge-nodes";
+ case RetractItems: return "retract-items";
+ case RetrieveAffiliations: return "retrieve-affiliations";
+ case RetrieveDefault: return "retrieve-default";
+ case RetrieveItems: return "retrieve-items";
+ case RetrieveSubscriptions: return "retrieve-subscriptions";
+ case Subscribe: return "subscribe";
+ case SubscriptionOptions: return "subscription-options";
+ case SubscriptionNotifications: return "subscription-notifications";
+ default: return null;
+ }
+}
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventAssociateSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventAssociateSerializer.java
new file mode 100644
index 0000000..83b769b
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventAssociateSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubEventAssociate;
+
+public class PubSubEventAssociateSerializer extends GenericPayloadSerializer<PubSubEventAssociate> {
+public PubSubEventAssociateSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventAssociate.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventAssociate payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("associate", "http://jabber.org/protocol/pubsub#event");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventCollectionSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventCollectionSerializer.java
new file mode 100644
index 0000000..194d9bb
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventCollectionSerializer.java
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubEventAssociate;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubEventDisassociate;
+import com.isode.stroke.elements.PubSubEventCollection;
+
+public class PubSubEventCollectionSerializer extends GenericPayloadSerializer<PubSubEventCollection> {
+public PubSubEventCollectionSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventCollection.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventCollection payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("collection", "http://jabber.org/protocol/pubsub#event");
+
+ element.addNode(new XMLRawTextNode((new PubSubEventAssociateSerializer(serializers_)).serialize(payload.getAssociate())));
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ element.addNode(new XMLRawTextNode((new PubSubEventDisassociateSerializer(serializers_)).serialize(payload.getDisassociate())));
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventConfigurationSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventConfigurationSerializer.java
new file mode 100644
index 0000000..0876853
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventConfigurationSerializer.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.payloadserializers.FormSerializer;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubEventConfiguration;
+
+public class PubSubEventConfigurationSerializer extends GenericPayloadSerializer<PubSubEventConfiguration> {
+public PubSubEventConfigurationSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventConfiguration.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventConfiguration payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("configuration", "http://jabber.org/protocol/pubsub#event");
+
+ element.addNode(new XMLRawTextNode((new FormSerializer()).serialize(payload.getData())));
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventDeleteSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventDeleteSerializer.java
new file mode 100644
index 0000000..1c54016
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventDeleteSerializer.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubEventRedirect;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubEventDelete;
+
+public class PubSubEventDeleteSerializer extends GenericPayloadSerializer<PubSubEventDelete> {
+public PubSubEventDeleteSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventDelete.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventDelete payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("delete", "http://jabber.org/protocol/pubsub#event");
+
+ element.addNode(new XMLRawTextNode((new PubSubEventRedirectSerializer(serializers_)).serialize(payload.getRedirects())));
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventDisassociateSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventDisassociateSerializer.java
new file mode 100644
index 0000000..34cb3d0
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventDisassociateSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubEventDisassociate;
+
+public class PubSubEventDisassociateSerializer extends GenericPayloadSerializer<PubSubEventDisassociate> {
+public PubSubEventDisassociateSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventDisassociate.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventDisassociate payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("disassociate", "http://jabber.org/protocol/pubsub#event");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventItemSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventItemSerializer.java
new file mode 100644
index 0000000..939f268
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventItemSerializer.java
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.Payload;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubEventItem;
+
+public class PubSubEventItemSerializer extends GenericPayloadSerializer<PubSubEventItem> {
+public PubSubEventItemSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventItem.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventItem payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("item", "http://jabber.org/protocol/pubsub#event");
+
+ if(payload.getPublisher() != null) {
+ element.setAttribute("publisher", payload.getPublisher());
+ }
+
+ for (Payload item : payload.getData()) {
+ element.addNode(new XMLRawTextNode(serializers_.getPayloadSerializer(item).serialize(item)));
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ if(payload.getID() != null) {
+ element.setAttribute("id", payload.getID());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventItemsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventItemsSerializer.java
new file mode 100644
index 0000000..9b49e59
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventItemsSerializer.java
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubEventItem;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubEventRetract;
+import com.isode.stroke.elements.PubSubEventItems;
+
+public class PubSubEventItemsSerializer extends GenericPayloadSerializer<PubSubEventItems> {
+public PubSubEventItemsSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventItems.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventItems payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("items", "http://jabber.org/protocol/pubsub#event");
+
+ for (PubSubEventItem item : payload.getItems()) {
+ element.addNode(new XMLRawTextNode((new PubSubEventItemSerializer(serializers_)).serialize(item)));
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ for (PubSubEventRetract item : payload.getRetracts()) {
+ element.addNode(new XMLRawTextNode((new PubSubEventRetractSerializer(serializers_)).serialize(item)));
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventPurgeSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventPurgeSerializer.java
new file mode 100644
index 0000000..224f6f0
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventPurgeSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubEventPurge;
+
+public class PubSubEventPurgeSerializer extends GenericPayloadSerializer<PubSubEventPurge> {
+public PubSubEventPurgeSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventPurge.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventPurge payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("purge", "http://jabber.org/protocol/pubsub#event");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventRedirectSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventRedirectSerializer.java
new file mode 100644
index 0000000..53d105c
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventRedirectSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubEventRedirect;
+
+public class PubSubEventRedirectSerializer extends GenericPayloadSerializer<PubSubEventRedirect> {
+public PubSubEventRedirectSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventRedirect.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventRedirect payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("redirect", "http://jabber.org/protocol/pubsub#event");
+
+ if(payload.getURI() != null) {
+ element.setAttribute("uri", payload.getURI());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventRetractSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventRetractSerializer.java
new file mode 100644
index 0000000..dbb6bae
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventRetractSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubEventRetract;
+
+public class PubSubEventRetractSerializer extends GenericPayloadSerializer<PubSubEventRetract> {
+public PubSubEventRetractSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventRetract.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventRetract payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("retract", "http://jabber.org/protocol/pubsub#event");
+
+ if(payload.getID() != null) {
+ element.setAttribute("id", payload.getID());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventSerializer.java
new file mode 100644
index 0000000..e7e09a3
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventSerializer.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2014, Remko Tronçon.
+ * All rights reserved.
+ */
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import java.util.ArrayList;
+
+import com.isode.stroke.elements.PubSubEventPayload;
+import com.isode.stroke.parser.payloadparsers.PubSubEvent;
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+
+public class PubSubEventSerializer extends GenericPayloadSerializer<PubSubEvent> {
+ public PubSubEventSerializer(PayloadSerializerCollection serializer) {
+ super(PubSubEvent.class);
+ }
+
+ protected String serializePayload(PubSubEvent payload) {
+ if (payload == null) {
+ return "";
+ }
+ XMLElement element = new XMLElement("event", "http://jabber.org/protocol/pubsub#event");
+ PubSubEventPayload p = payload.getPayload();
+
+ for (PayloadSerializer serializer : pubsubSerializers_) {
+ if (serializer.canSerialize(p)) {
+ element.addNode(new XMLRawTextNode(serializer.serialize(p)));
+ }
+ }
+ return element.serialize();
+ }
+
+ PayloadSerializerCollection serializers_;
+ ArrayList<PayloadSerializer> pubsubSerializers_ = new ArrayList<PayloadSerializer>();
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubEventSubscriptionSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventSubscriptionSerializer.java
new file mode 100644
index 0000000..d34bfb1
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubEventSubscriptionSerializer.java
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import com.isode.stroke.elements.PubSubEventSubscription;
+
+public class PubSubEventSubscriptionSerializer extends GenericPayloadSerializer<PubSubEventSubscription> {
+public PubSubEventSubscriptionSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubEventSubscription.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubEventSubscription payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("subscription", "http://jabber.org/protocol/pubsub#event");
+
+ element.setAttribute("subscription", serializeSubscriptionType(payload.getSubscription()));
+
+ if(payload.getSubscriptionID() != null) {
+ element.setAttribute("subid", payload.getSubscriptionID());
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ if(payload.getJID() != null) {
+ element.setAttribute("jid", payload.getJID().toString());
+ }
+
+ if(payload.getExpiry() != null) {
+ element.setAttribute("expiry", dateToString(payload.getExpiry()));
+ }
+
+ return element.serialize();
+}
+
+private static String serializeSubscriptionType(PubSubEventSubscription.SubscriptionType value) {
+ switch (value) {
+ case None: return "none";
+ case Pending: return "pending";
+ case Subscribed: return "subscribed";
+ case Unconfigured: return "unconfigured";
+ }
+ return "undefined-subscriptiontype";
+}
+
+private static String dateToString(Date date) {
+ SimpleDateFormat dfm = new SimpleDateFormat("YYYY-MM-dd");
+ SimpleDateFormat tfm = new SimpleDateFormat("hh:mm:ss");
+ dfm.setTimeZone(TimeZone.getTimeZone("UTC"));
+ tfm.setTimeZone(TimeZone.getTimeZone("UTC"));
+ String sinceDateString = dfm.format(date) + "T" + tfm.format(date) + "Z";
+ return sinceDateString;
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubItemSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubItemSerializer.java
new file mode 100644
index 0000000..dc34489
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubItemSerializer.java
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.Payload;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubItem;
+
+public class PubSubItemSerializer extends GenericPayloadSerializer<PubSubItem> {
+public PubSubItemSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubItem.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubItem payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("item", "http://jabber.org/protocol/pubsub");
+
+ for (Payload item : payload.getData()) {
+ element.addNode(new XMLRawTextNode(serializers_.getPayloadSerializer(item).serialize(item)));
+ }
+
+ if(payload.getID() != null) {
+ element.setAttribute("id", payload.getID());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubItemsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubItemsSerializer.java
new file mode 100644
index 0000000..6739e44
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubItemsSerializer.java
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubItem;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubItems;
+
+public class PubSubItemsSerializer extends GenericPayloadSerializer<PubSubItems> {
+public PubSubItemsSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubItems.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubItems payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("items", "http://jabber.org/protocol/pubsub");
+
+ if(payload.getMaximumItems() != null) {
+ element.setAttribute("max_items", payload.getMaximumItems().toString());
+ }
+
+ for (PubSubItem item : payload.getItems()) {
+ element.addNode(new XMLRawTextNode((new PubSubItemSerializer(serializers_)).serialize(item)));
+ }
+
+ if(payload.getSubscriptionID() != null) {
+ element.setAttribute("subid", payload.getSubscriptionID());
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOptionsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOptionsSerializer.java
new file mode 100644
index 0000000..2f3cb54
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOptionsSerializer.java
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.payloadserializers.FormSerializer;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubOptions;
+
+public class PubSubOptionsSerializer extends GenericPayloadSerializer<PubSubOptions> {
+public PubSubOptionsSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOptions.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOptions payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("options", "http://jabber.org/protocol/pubsub");
+
+ element.addNode(new XMLRawTextNode((new FormSerializer()).serialize(payload.getData())));
+
+ if(payload.getSubscriptionID() != null) {
+ element.setAttribute("subid", payload.getSubscriptionID());
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ if(payload.getJID() != null) {
+ element.setAttribute("jid", payload.getJID().toString());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerAffiliationSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerAffiliationSerializer.java
new file mode 100644
index 0000000..144a469
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerAffiliationSerializer.java
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubOwnerAffiliation;
+
+public class PubSubOwnerAffiliationSerializer extends GenericPayloadSerializer<PubSubOwnerAffiliation> {
+public PubSubOwnerAffiliationSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerAffiliation.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerAffiliation payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("affiliation", "http://jabber.org/protocol/pubsub#owner");
+
+ if(payload.getJID() != null) {
+ element.setAttribute("jid", payload.getJID().toString());
+ }
+
+ element.setAttribute("affiliation", serializeType(payload.getType()));
+
+ return element.serialize();
+}
+
+private static String serializeType(PubSubOwnerAffiliation.Type value) {
+ switch (value) {
+ case None: return "none";
+ case Member: return "member";
+ case Outcast: return "outcast";
+ case Owner: return "owner";
+ case Publisher: return "publisher";
+ case PublishOnly: return "publish-only";
+ }
+ return "undefined-type";
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerAffiliationsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerAffiliationsSerializer.java
new file mode 100644
index 0000000..5c9898f
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerAffiliationsSerializer.java
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubOwnerAffiliation;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubOwnerAffiliations;
+
+public class PubSubOwnerAffiliationsSerializer extends GenericPayloadSerializer<PubSubOwnerAffiliations> {
+public PubSubOwnerAffiliationsSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerAffiliations.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerAffiliations payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("affiliations", "http://jabber.org/protocol/pubsub#owner");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ for (PubSubOwnerAffiliation item : payload.getAffiliations()) {
+ element.addNode(new XMLRawTextNode((new PubSubOwnerAffiliationSerializer(serializers_)).serialize(item)));
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerConfigureSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerConfigureSerializer.java
new file mode 100644
index 0000000..bcf03e3
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerConfigureSerializer.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.payloadserializers.FormSerializer;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubOwnerConfigure;
+
+public class PubSubOwnerConfigureSerializer extends GenericPayloadSerializer<PubSubOwnerConfigure> {
+public PubSubOwnerConfigureSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerConfigure.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerConfigure payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("configure", "http://jabber.org/protocol/pubsub#owner");
+
+ element.addNode(new XMLRawTextNode((new FormSerializer()).serialize(payload.getData())));
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerDefaultSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerDefaultSerializer.java
new file mode 100644
index 0000000..3b3fe98
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerDefaultSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.payloadserializers.FormSerializer;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubOwnerDefault;
+
+public class PubSubOwnerDefaultSerializer extends GenericPayloadSerializer<PubSubOwnerDefault> {
+public PubSubOwnerDefaultSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerDefault.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerDefault payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("default", "http://jabber.org/protocol/pubsub#owner");
+
+ element.addNode(new XMLRawTextNode((new FormSerializer()).serialize(payload.getData())));
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerDeleteSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerDeleteSerializer.java
new file mode 100644
index 0000000..6518f56
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerDeleteSerializer.java
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubOwnerRedirect;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubOwnerDelete;
+
+public class PubSubOwnerDeleteSerializer extends GenericPayloadSerializer<PubSubOwnerDelete> {
+public PubSubOwnerDeleteSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerDelete.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerDelete payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("delete", "http://jabber.org/protocol/pubsub#owner");
+
+ element.addNode(new XMLRawTextNode((new PubSubOwnerRedirectSerializer(serializers_)).serialize(payload.getRedirect())));
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerPubSubSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerPubSubSerializer.java
new file mode 100644
index 0000000..6a72af0
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerPubSubSerializer.java
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import java.util.ArrayList;
+
+import com.isode.stroke.elements.PubSubOwnerPayload;
+import com.isode.stroke.elements.PubSubOwnerPubSub;
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+
+public class PubSubOwnerPubSubSerializer extends GenericPayloadSerializer<PubSubOwnerPubSub> {
+
+public PubSubOwnerPubSubSerializer(PayloadSerializerCollection serializers)
+{
+ super(PubSubOwnerPubSub.class);
+
+ serializers_ = serializers;
+
+ pubsubSerializers_.add(new PubSubOwnerConfigureSerializer(serializers));
+ pubsubSerializers_.add(new PubSubOwnerSubscriptionsSerializer(serializers));
+ pubsubSerializers_.add(new PubSubOwnerDefaultSerializer(serializers));
+ pubsubSerializers_.add(new PubSubOwnerPurgeSerializer(serializers));
+ pubsubSerializers_.add(new PubSubOwnerAffiliationsSerializer(serializers));
+ pubsubSerializers_.add(new PubSubOwnerDeleteSerializer(serializers));
+}
+
+protected String serializePayload(PubSubOwnerPubSub payload)
+{
+ if (payload == null) {
+ return "";
+ }
+ XMLElement element = new XMLElement("pubsub", "http://jabber.org/protocol/pubsub#owner");
+ PubSubOwnerPayload p = payload.getPayload();
+ for (PayloadSerializer serializer : pubsubSerializers_) {
+ if (serializer.canSerialize(p)) {
+ element.addNode(new XMLRawTextNode(serializer.serialize(p)));
+ }
+ }
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+ArrayList<PayloadSerializer> pubsubSerializers_ = new ArrayList<PayloadSerializer>();
+
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerPurgeSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerPurgeSerializer.java
new file mode 100644
index 0000000..59d3d39
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerPurgeSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubOwnerPurge;
+
+public class PubSubOwnerPurgeSerializer extends GenericPayloadSerializer<PubSubOwnerPurge> {
+public PubSubOwnerPurgeSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerPurge.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerPurge payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("purge", "http://jabber.org/protocol/pubsub#owner");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerRedirectSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerRedirectSerializer.java
new file mode 100644
index 0000000..a1ad660
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerRedirectSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubOwnerRedirect;
+
+public class PubSubOwnerRedirectSerializer extends GenericPayloadSerializer<PubSubOwnerRedirect> {
+public PubSubOwnerRedirectSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerRedirect.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerRedirect payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("redirect", "http://jabber.org/protocol/pubsub#owner");
+
+ if(payload.getURI() != null) {
+ element.setAttribute("uri", payload.getURI());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerSubscriptionSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerSubscriptionSerializer.java
new file mode 100644
index 0000000..81cbec8
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerSubscriptionSerializer.java
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubOwnerSubscription;
+
+public class PubSubOwnerSubscriptionSerializer extends GenericPayloadSerializer<PubSubOwnerSubscription> {
+public PubSubOwnerSubscriptionSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerSubscription.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerSubscription payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("subscription", "http://jabber.org/protocol/pubsub#owner");
+
+ element.setAttribute("subscription", serializeSubscriptionType(payload.getSubscription()));
+
+ if(payload.getJID() != null) {
+ element.setAttribute("jid", payload.getJID().toString());
+ }
+
+ return element.serialize();
+}
+
+private static String serializeSubscriptionType(PubSubOwnerSubscription.SubscriptionType value) {
+ switch (value) {
+ case None: return "none";
+ case Pending: return "pending";
+ case Subscribed: return "subscribed";
+ case Unconfigured: return "unconfigured";
+ }
+ return "undefined-subscriptiontype";
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerSubscriptionsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerSubscriptionsSerializer.java
new file mode 100644
index 0000000..c66a1b0
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubOwnerSubscriptionsSerializer.java
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubOwnerSubscription;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubOwnerSubscriptions;
+
+public class PubSubOwnerSubscriptionsSerializer extends GenericPayloadSerializer<PubSubOwnerSubscriptions> {
+public PubSubOwnerSubscriptionsSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubOwnerSubscriptions.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubOwnerSubscriptions payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("subscriptions", "http://jabber.org/protocol/pubsub#owner");
+
+ for (PubSubOwnerSubscription item : payload.getSubscriptions()) {
+ element.addNode(new XMLRawTextNode((new PubSubOwnerSubscriptionSerializer(serializers_)).serialize(item)));
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubPublishSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubPublishSerializer.java
new file mode 100644
index 0000000..ec71839
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubPublishSerializer.java
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubItem;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubPublish;
+
+public class PubSubPublishSerializer extends GenericPayloadSerializer<PubSubPublish> {
+public PubSubPublishSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubPublish.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubPublish payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("publish", "http://jabber.org/protocol/pubsub");
+
+ for (PubSubItem item : payload.getItems()) {
+ element.addNode(new XMLRawTextNode((new PubSubItemSerializer(serializers_)).serialize(item)));
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubRetractSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubRetractSerializer.java
new file mode 100644
index 0000000..87f18ce
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubRetractSerializer.java
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubItem;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubRetract;
+
+public class PubSubRetractSerializer extends GenericPayloadSerializer<PubSubRetract> {
+public PubSubRetractSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubRetract.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubRetract payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("retract", "http://jabber.org/protocol/pubsub");
+
+ for (PubSubItem item : payload.getItems()) {
+ element.addNode(new XMLRawTextNode((new PubSubItemSerializer(serializers_)).serialize(item)));
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ element.setAttribute("notify", payload.isNotify() ? "true" : "false");
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubSerializer.java
new file mode 100644
index 0000000..232baa7
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubSerializer.java
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import java.util.ArrayList;
+
+import com.isode.stroke.elements.PubSub;
+import com.isode.stroke.elements.PubSubCreate;
+import com.isode.stroke.elements.PubSubPayload;
+import com.isode.stroke.elements.PubSubSubscribe;
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+
+public class PubSubSerializer extends GenericPayloadSerializer<PubSub> {
+
+public PubSubSerializer(PayloadSerializerCollection serializers) {
+ super(PubSub.class);
+
+ serializers_ = serializers;
+
+ pubsubSerializers_.add(new PubSubItemsSerializer(serializers));
+ pubsubSerializers_.add(new PubSubCreateSerializer(serializers));
+ pubsubSerializers_.add(new PubSubPublishSerializer(serializers));
+ pubsubSerializers_.add(new PubSubOptionsSerializer(serializers));
+ pubsubSerializers_.add(new PubSubAffiliationsSerializer(serializers));
+ pubsubSerializers_.add(new PubSubRetractSerializer(serializers));
+ pubsubSerializers_.add(new PubSubDefaultSerializer(serializers));
+ pubsubSerializers_.add(new PubSubSubscriptionsSerializer(serializers));
+ pubsubSerializers_.add(new PubSubSubscribeSerializer(serializers));
+ pubsubSerializers_.add(new PubSubUnsubscribeSerializer(serializers));
+ pubsubSerializers_.add(new PubSubSubscriptionSerializer(serializers));
+}
+
+@Override
+protected String serializePayload(PubSub payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("pubsub", "http://jabber.org/protocol/pubsub");
+ PubSubPayload p = payload.getPayload();
+
+ for (PayloadSerializer serializer : pubsubSerializers_) {
+ if (serializer.canSerialize(p)) {
+ element.addNode(new XMLRawTextNode(serializer.serialize(p)));
+ PubSubCreate create = null;
+ if(p instanceof PubSubCreate) {
+ create = (PubSubCreate)p;
+ element.addNode(new XMLRawTextNode((new PubSubConfigureSerializer(serializers_)).serialize(create.getConfigure())));
+ }
+ PubSubSubscribe subscribe = null;
+ if (p instanceof PubSubSubscribe) {
+ subscribe = (PubSubSubscribe)p;
+ element.addNode(new XMLRawTextNode((new PubSubConfigureSerializer(serializers_)).serialize(subscribe.getOptions())));
+ }
+ }
+ }
+ return element.serialize();
+}
+
+ArrayList<PayloadSerializer> pubsubSerializers_ = new ArrayList<PayloadSerializer>();
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscribeOptionsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscribeOptionsSerializer.java
new file mode 100644
index 0000000..40c0298
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscribeOptionsSerializer.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubSubscribeOptions;
+
+public class PubSubSubscribeOptionsSerializer extends GenericPayloadSerializer<PubSubSubscribeOptions> {
+public PubSubSubscribeOptionsSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubSubscribeOptions.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubSubscribeOptions payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("subscribe-options", "http://jabber.org/protocol/pubsub");
+
+ if (payload.isRequired()) {
+ element.addNode(new XMLElement("required", ""));
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscribeSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscribeSerializer.java
new file mode 100644
index 0000000..9a886b9
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscribeSerializer.java
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubOptions;
+import com.isode.stroke.elements.PubSubSubscribe;
+
+public class PubSubSubscribeSerializer extends GenericPayloadSerializer<PubSubSubscribe> {
+public PubSubSubscribeSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubSubscribe.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubSubscribe payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("subscribe", "http://jabber.org/protocol/pubsub");
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ if(payload.getJID() != null) {
+ element.setAttribute("jid", payload.getJID().toString());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscriptionSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscriptionSerializer.java
new file mode 100644
index 0000000..41e6f9d
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscriptionSerializer.java
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubSubscribeOptions;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubSubscription;
+
+public class PubSubSubscriptionSerializer extends GenericPayloadSerializer<PubSubSubscription> {
+public PubSubSubscriptionSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubSubscription.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubSubscription payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("subscription", "http://jabber.org/protocol/pubsub");
+
+ element.setAttribute("subscription", serializeSubscriptionType(payload.getSubscription()));
+
+ if(payload.getSubscriptionID() != null) {
+ element.setAttribute("subid", payload.getSubscriptionID());
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ if(payload.getJID() != null) {
+ element.setAttribute("jid", payload.getJID().toString());
+ }
+
+ element.addNode(new XMLRawTextNode((new PubSubSubscribeOptionsSerializer(serializers_)).serialize(payload.getOptions())));
+
+ return element.serialize();
+}
+
+private static String serializeSubscriptionType(PubSubSubscription.SubscriptionType value) {
+ switch (value) {
+ case None: return "none";
+ case Pending: return "pending";
+ case Subscribed: return "subscribed";
+ case Unconfigured: return "unconfigured";
+ }
+ return "undefined-subscriptiontype";
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscriptionsSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscriptionsSerializer.java
new file mode 100644
index 0000000..2092caa
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubSubscriptionsSerializer.java
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubSubscription;
+import com.isode.stroke.serializer.xml.XMLRawTextNode;
+import com.isode.stroke.elements.PubSubSubscriptions;
+
+public class PubSubSubscriptionsSerializer extends GenericPayloadSerializer<PubSubSubscriptions> {
+public PubSubSubscriptionsSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubSubscriptions.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubSubscriptions payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("subscriptions", "http://jabber.org/protocol/pubsub");
+
+ for (PubSubSubscription item : payload.getSubscriptions()) {
+ element.addNode(new XMLRawTextNode((new PubSubSubscriptionSerializer(serializers_)).serialize(item)));
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/PubSubUnsubscribeSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/PubSubUnsubscribeSerializer.java
new file mode 100644
index 0000000..f0a8bb0
--- /dev/null
+++ b/src/com/isode/stroke/serializer/payloadserializers/PubSubUnsubscribeSerializer.java
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+* Copyright (c) 2014, Remko Tronçon.
+* All rights reserved.
+*/
+
+package com.isode.stroke.serializer.payloadserializers;
+
+import com.isode.stroke.serializer.GenericPayloadSerializer;
+import com.isode.stroke.serializer.PayloadSerializerCollection;
+import com.isode.stroke.serializer.xml.XMLElement;
+import com.isode.stroke.elements.PubSubUnsubscribe;
+
+public class PubSubUnsubscribeSerializer extends GenericPayloadSerializer<PubSubUnsubscribe> {
+public PubSubUnsubscribeSerializer(PayloadSerializerCollection serializers) {
+ super(PubSubUnsubscribe.class);
+
+ serializers_ = serializers;
+}
+
+protected String serializePayload(PubSubUnsubscribe payload) {
+ if (payload == null) {
+ return "";
+ }
+
+ XMLElement element = new XMLElement("unsubscribe", "http://jabber.org/protocol/pubsub");
+
+ if(payload.getSubscriptionID() != null) {
+ element.setAttribute("subid", payload.getSubscriptionID());
+ }
+
+ if(payload.getNode() != null) {
+ element.setAttribute("node", payload.getNode());
+ }
+
+ if(payload.getJID() != null) {
+ element.setAttribute("jid", payload.getJID().toString());
+ }
+
+ return element.serialize();
+}
+
+PayloadSerializerCollection serializers_;
+}
diff --git a/src/com/isode/stroke/serializer/payloadserializers/RawXMLPayloadSerializer.java b/src/com/isode/stroke/serializer/payloadserializers/RawXMLPayloadSerializer.java
index 70c405b..a52ab98 100644
--- a/src/com/isode/stroke/serializer/payloadserializers/RawXMLPayloadSerializer.java
+++ b/src/com/isode/stroke/serializer/payloadserializers/RawXMLPayloadSerializer.java
@@ -14,7 +14,7 @@ import com.isode.stroke.serializer.GenericPayloadSerializer;
class RawXMLPayloadSerializer extends GenericPayloadSerializer<RawXMLPayload> {
public RawXMLPayloadSerializer() {
- super(RawXMLPayloadSerializer.class);
+ super(RawXMLPayload.class);
}
@Override