summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/isode/stroke/parser/payloadparsers/PubSubOwnerRedirectParser.java')
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerRedirectParser.java63
1 files changed, 63 insertions, 0 deletions
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_;
+}