summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/isode/stroke/parser/payloadparsers')
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/ForwardedParser.java15
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java27
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/IdleParser.java44
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/MAMQueryParser.java11
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/MAMResultParser.java9
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/MUCInvitationPayloadParser.java9
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PrivateStorageParser.java57
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PrivateStorageParserFactory.java29
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java18
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubOwnerPubSubParser.java95
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/PubSubParser.java34
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/ReplaceParser.java39
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/ResultSetParser.java21
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/StatusParser.java35
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/StatusShowParser.java49
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/StorageParser.java76
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/SubjectParser.java35
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/VCardParser.java301
18 files changed, 816 insertions, 88 deletions
diff --git a/src/com/isode/stroke/parser/payloadparsers/ForwardedParser.java b/src/com/isode/stroke/parser/payloadparsers/ForwardedParser.java
index b7a023e..2819566 100644
--- a/src/com/isode/stroke/parser/payloadparsers/ForwardedParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/ForwardedParser.java
@@ -1,10 +1,5 @@
/*
- * Copyright (c) 2014 Kevin Smith and Remko Tronçon
- * All rights reserved.
- */
-
-/*
- * Copyright (c) 2014, Isode Limited, London, England.
+ * Copyright (c) 2014-2015, Isode Limited, London, England.
* All rights reserved.
*/
@@ -28,13 +23,13 @@ public class ForwardedParser extends GenericPayloadParser<Forwarded> {
public void handleStartElement(String element, String ns, AttributeMap attributes) {
if (level_ == 1) {
- if (element == "iq") { /* begin parsing a nested stanza? */
+ if ("iq".equals(element)) { /* begin parsing a nested stanza? */
childParser_ = new IQParser(factories_);
- } else if (element == "message") {
+ } else if ("message".equals(element)) {
childParser_ = new MessageParser(factories_);
- } else if (element == "presence") {
+ } else if ("presence".equals(element)) {
childParser_ = new PresenceParser(factories_);
- } else if (element == "delay" && ns == "urn:xmpp:delay") {
+ } else if ("delay".equals(element) && "urn:xmpp:delay".equals(ns)) {
delayParser_ = new DelayParser();
}
}
diff --git a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
index 5236d42..e443a00 100644
--- a/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
+++ b/src/com/isode/stroke/parser/payloadparsers/FullPayloadParserFactoryCollection.java
@@ -1,9 +1,5 @@
/*
- * Copyright (c) 2010-2012, Isode Limited, London, England.
- * All rights reserved.
- */
-/*
- * Copyright (c) 2010, Remko Tronçon.
+ * Copyright (c) 2010-2015, Isode Limited, London, England.
* All rights reserved.
*/
package com.isode.stroke.parser.payloadparsers;
@@ -12,27 +8,27 @@ 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;
+import com.isode.stroke.parser.payloadparsers.PubSubOwnerPubSubParser;
public class FullPayloadParserFactoryCollection extends PayloadParserFactoryCollection {
public FullPayloadParserFactoryCollection() {
/* TODO: Port more */
//addFactory(new GenericPayloadParserFactory<IBBParser>("", "http://jabber.org/protocol/ibb"));
- //addFactory(new GenericPayloadParserFactory<StatusShowParser>("show", StatusShowParser.class));
- //addFactory(new GenericPayloadParserFactory<StatusParser>("status", StatusParser.class));
- //addFactory(new GenericPayloadParserFactory<ReplaceParser>("replace", "http://swift.im/protocol/replace"));
+ addFactory(new GenericPayloadParserFactory<StatusShowParser>("show", StatusShowParser.class));
+ addFactory(new GenericPayloadParserFactory<StatusParser>("status", StatusParser.class));
+ addFactory(new GenericPayloadParserFactory<ReplaceParser>("replace", "http://swift.im/protocol/replace", ReplaceParser.class));
+ addFactory(new GenericPayloadParserFactory<ReplaceParser>("replace", "urn:xmpp:message-correct:0", ReplaceParser.class));
addFactory(new GenericPayloadParserFactory<LastParser>("query", "jabber:iq:last", LastParser.class));
addFactory(new GenericPayloadParserFactory<BodyParser>("body", BodyParser.class));
- //addFactory(new GenericPayloadParserFactory<SubjectParser>("subject", SubjectParser.class));
+ addFactory(new GenericPayloadParserFactory<SubjectParser>("subject", SubjectParser.class));
//addFactory(new GenericPayloadParserFactory<PriorityParser>("priority", PriorityParser.class));
addFactory(new ErrorParserFactory(this));
addFactory(new SoftwareVersionParserFactory());
- //addFactory(new StorageParserFactory());
+ addFactory(new GenericPayloadParserFactory<StorageParser>("storage", "storage:bookmarks", StorageParser.class));
addFactory(new RosterParserFactory());
addFactory(new GenericPayloadParserFactory<DiscoInfoParser>("query", "http://jabber.org/protocol/disco#info", DiscoInfoParser.class));
addFactory(new GenericPayloadParserFactory<DiscoItemsParser>("query", "http://jabber.org/protocol/disco#items", DiscoItemsParser.class));
addFactory(new GenericPayloadParserFactory<CapsInfoParser> ("c", "http://jabber.org/protocol/caps", CapsInfoParser.class));
- //addFactory(new CapsInfoParserFactory());
addFactory(new ResourceBindParserFactory());
addFactory(new StartSessionParserFactory());
//addFactory(new SecurityLabelParserFactory());
@@ -45,9 +41,9 @@ public class FullPayloadParserFactoryCollection extends PayloadParserFactoryColl
//addFactory(new StreamInitiationParserFactory());
//addFactory(new BytestreamsParserFactory());
//addFactory(new VCardUpdateParserFactory());
- //addFactory(new VCardParserFactory());
- //addFactory(new PrivateStorageParserFactory(this));
- addFactory(new ChatStateParserFactory());
+ addFactory(new GenericPayloadParserFactory<VCardParser>("vCard", "vcard-temp", VCardParser.class));
+ addFactory(new PrivateStorageParserFactory(this));
+ addFactory(new ChatStateParserFactory());
//addFactory(new DelayParserFactory());
addFactory(new MUCUserPayloadParserFactory(this));
addFactory(new MUCOwnerPayloadParserFactory(this));
@@ -59,6 +55,7 @@ public class FullPayloadParserFactoryCollection extends PayloadParserFactoryColl
"http://jabber.org/protocol/muc#user",MUCDestroyPayloadParser.class));
addFactory(new GenericPayloadParserFactory<MUCDestroyPayloadParser>("destroy",
"http://jabber.org/protocol/muc#owner",MUCDestroyPayloadParser.class));
+ addFactory(new GenericPayloadParserFactory<IdleParser>("idle", "urn:xmpp:idle:1",IdleParser.class));
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));
diff --git a/src/com/isode/stroke/parser/payloadparsers/IdleParser.java b/src/com/isode/stroke/parser/payloadparsers/IdleParser.java
new file mode 100644
index 0000000..3986168
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/IdleParser.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011-2015, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2013 Tobias Markmann
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import java.util.Date;
+
+import com.isode.stroke.base.DateTime;
+import com.isode.stroke.elements.Idle;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class IdleParser extends GenericPayloadParser<Idle> {
+
+ private int level_ = 0;
+
+ public IdleParser() {
+ super(new Idle());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ Date since = DateTime.stringToDate(attributes.getAttribute("since"));
+ getPayloadInternal().setSince(since);
+ }
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ }
+
+ public void handleCharacterData(String data) {
+
+ }
+
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/MAMQueryParser.java b/src/com/isode/stroke/parser/payloadparsers/MAMQueryParser.java
index 2543a68..dc41e9d 100644
--- a/src/com/isode/stroke/parser/payloadparsers/MAMQueryParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/MAMQueryParser.java
@@ -1,10 +1,5 @@
/*
-* Copyright (c) 2014 Kevin Smith and Remko Tronçon
-* All rights reserved.
-*/
-
-/*
-* Copyright (c) 2014, Isode Limited, London, England.
+* Copyright (c) 2014-2015, Isode Limited, London, England.
* All rights reserved.
*/
@@ -34,9 +29,9 @@ public class MAMQueryParser extends GenericPayloadParser<MAMQuery> {
payloadInternal.setNode(nodeValue);
}
} else if (level_ == 1) {
- if (element == "x" && ns == "jabber:x:data") {
+ if ("x".equals(element) && "jabber:x:data".equals(ns)) {
formParser_ = new FormParser();
- } else if (element == "set" && ns == "http://jabber.org/protocol/rsm") {
+ } else if ("set".equals(element) && "http://jabber.org/protocol/rsm".equals(ns)) {
resultSetParser_ = new ResultSetParser();
}
}
diff --git a/src/com/isode/stroke/parser/payloadparsers/MAMResultParser.java b/src/com/isode/stroke/parser/payloadparsers/MAMResultParser.java
index cb3d7fd..3e71712 100644
--- a/src/com/isode/stroke/parser/payloadparsers/MAMResultParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/MAMResultParser.java
@@ -1,10 +1,5 @@
/*
-* Copyright (c) 2014 Kevin Smith and Remko Tronçon
-* All rights reserved.
-*/
-
-/*
-* Copyright (c) 2014, Isode Limited, London, England.
+* Copyright (c) 2014-2015, Isode Limited, London, England.
* All rights reserved.
*/
@@ -33,7 +28,7 @@ public class MAMResultParser extends GenericPayloadParser<MAMResult> {
getPayloadInternal().setQueryID(attributeValue);
}
} else if (level_ == 1) {
- if (element == "forwarded" && ns == "urn:xmpp:forward:0") {
+ if ("forwarded".equals(element) && "urn:xmpp:forward:0".equals(ns)) {
payloadParser_ = new ForwardedParser(factories_);
}
}
diff --git a/src/com/isode/stroke/parser/payloadparsers/MUCInvitationPayloadParser.java b/src/com/isode/stroke/parser/payloadparsers/MUCInvitationPayloadParser.java
index 27ab0d8..473bcdd 100644
--- a/src/com/isode/stroke/parser/payloadparsers/MUCInvitationPayloadParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/MUCInvitationPayloadParser.java
@@ -1,9 +1,5 @@
/*
- * Copyright (c) 2012, Isode Limited, London, England.
- * All rights reserved.
- */
-/*
- * Copyright (c) 2011, Kevin Smith
+ * Copyright (c) 2011-2015, Isode Limited, London, England.
* All rights reserved.
*/
package com.isode.stroke.parser.payloadparsers;
@@ -11,6 +7,7 @@ package com.isode.stroke.parser.payloadparsers;
import com.isode.stroke.elements.MUCInvitationPayload;
import com.isode.stroke.jid.JID;
import com.isode.stroke.parser.GenericPayloadTreeParser;
+import com.isode.stroke.parser.tree.NullParserElement;
import com.isode.stroke.parser.tree.ParserElement;
/**
@@ -31,5 +28,7 @@ public class MUCInvitationPayloadParser extends GenericPayloadTreeParser<MUCInvi
invite.setPassword(root.getAttributes().getAttribute("password"));
invite.setReason(root.getAttributes().getAttribute("reason"));
invite.setThread(root.getAttributes().getAttribute("thread"));
+ ParserElement impromptuNode = root.getChild("impromptu", "http://swift.im/impromptu");
+ invite.setIsImpromptu(!(impromptuNode instanceof NullParserElement));
}
}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PrivateStorageParser.java b/src/com/isode/stroke/parser/payloadparsers/PrivateStorageParser.java
new file mode 100644
index 0000000..df62938
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PrivateStorageParser.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2010-2015, Isode Limited, London, England.
+ * All rights reserved.
+ */
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.PrivateStorage;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.PayloadParser;
+import com.isode.stroke.parser.PayloadParserFactory;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+
+public class PrivateStorageParser extends GenericPayloadParser<PrivateStorage> {
+
+ private PayloadParserFactoryCollection factories;
+ private int level;
+ private PayloadParser currentPayloadParser;
+
+ public PrivateStorageParser(PayloadParserFactoryCollection factories) {
+ super(new PrivateStorage());
+ this.factories = factories;
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level == 1) {
+ PayloadParserFactory payloadParserFactory = factories.getPayloadParserFactory(element, ns, attributes);
+ if (payloadParserFactory != null) {
+ currentPayloadParser = payloadParserFactory.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) {
+ getPayloadInternal().setPayload(currentPayloadParser.getPayload());
+ }
+ }
+ }
+
+ public void handleCharacterData(String data) {
+ if (level > 1 && currentPayloadParser != null) {
+ currentPayloadParser.handleCharacterData(data);
+ }
+ }
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PrivateStorageParserFactory.java b/src/com/isode/stroke/parser/payloadparsers/PrivateStorageParserFactory.java
new file mode 100644
index 0000000..b2b3db0
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PrivateStorageParserFactory.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010-2015 Isode Limited, London, England.
+ * 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;
+import com.isode.stroke.parser.PayloadParserFactoryCollection;
+
+public class PrivateStorageParserFactory implements PayloadParserFactory {
+
+ private PayloadParserFactoryCollection factories;
+
+ public PrivateStorageParserFactory(PayloadParserFactoryCollection factories) {
+ this.factories = factories;
+ }
+
+ @Override
+ public boolean canParse(String element, String ns, AttributeMap map) {
+ return "query".equals(element) && "jabber:iq:private".equals(ns);
+ }
+
+ @Override
+ public PayloadParser createPayloadParser() {
+ return new PrivateStorageParser(factories);
+ }
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java
index d7bdbe6..f1f7701 100644
--- a/src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubEventParser.java
@@ -1,9 +1,5 @@
/*
-* Copyright (c) 2014, Isode Limited, London, England.
-* All rights reserved.
-*/
-/*
-* Copyright (c) 2014, Remko Tronçon.
+* Copyright (c) 2013-2015, Isode Limited, London, England.
* All rights reserved.
*/
@@ -25,22 +21,22 @@ public PubSubEventParser(PayloadParserFactoryCollection parser) {
@Override
public void handleStartElement(String element, String ns, AttributeMap attributes) {
if (level_ == 1) {
- if (element == "items" && ns == "http://jabber.org/protocol/pubsub#event") {
+ if ("items".equals(element) && "http://jabber.org/protocol/pubsub#event".equals(ns)) {
currentPayloadParser_ = new PubSubEventItemsParser(parsers_);
}
- if (element == "collection" && ns == "http://jabber.org/protocol/pubsub#event") {
+ if ("collection".equals(element) && "http://jabber.org/protocol/pubsub#event".equals(ns)) {
currentPayloadParser_ = new PubSubEventCollectionParser(parsers_);
}
- if (element == "purge" && ns == "http://jabber.org/protocol/pubsub#event") {
+ if ("purge".equals(element) && "http://jabber.org/protocol/pubsub#event".equals(ns)) {
currentPayloadParser_ = new PubSubEventPurgeParser(parsers_);
}
- if (element == "configuration" && ns == "http://jabber.org/protocol/pubsub#event") {
+ if ("configuration".equals(element) && "http://jabber.org/protocol/pubsub#event".equals(ns)) {
currentPayloadParser_ = new PubSubEventConfigurationParser(parsers_);
}
- if (element == "delete" && ns == "http://jabber.org/protocol/pubsub#event") {
+ if ("delete".equals(element) && "http://jabber.org/protocol/pubsub#event".equals(ns)) {
currentPayloadParser_ = new PubSubEventDeleteParser(parsers_);
}
- if (element == "subscription" && ns == "http://jabber.org/protocol/pubsub#event") {
+ if ("subscription".equals(element) && "http://jabber.org/protocol/pubsub#event".equals(ns)) {
currentPayloadParser_ = new PubSubEventSubscriptionParser(parsers_);
}
}
diff --git a/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerPubSubParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerPubSubParser.java
new file mode 100644
index 0000000..d711cf1
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubOwnerPubSubParser.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2015, Isode Limited, London, England.
+ * All rights reserved.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.PubSubOwnerPayload;
+import com.isode.stroke.elements.PubSubOwnerPubSub;
+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.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 ("configure".equals(element)
+ && "http://jabber.org/protocol/pubsub#owner".equals(ns)) {
+ currentPayloadParser_ = new PubSubOwnerConfigureParser(parsers_);
+ }
+ if ("subscriptions".equals(element)
+ && "http://jabber.org/protocol/pubsub#owner".equals(ns)) {
+ currentPayloadParser_ = new PubSubOwnerSubscriptionsParser(
+ parsers_);
+ }
+ if ("default".equals(element)
+ && "http://jabber.org/protocol/pubsub#owner".equals(ns)) {
+ currentPayloadParser_ = new PubSubOwnerDefaultParser(parsers_);
+ }
+ if ("purge".equals(element)
+ && "http://jabber.org/protocol/pubsub#owner".equals(ns)) {
+ currentPayloadParser_ = new PubSubOwnerPurgeParser(parsers_);
+ }
+ if ("affiliations".equals(element)
+ && "http://jabber.org/protocol/pubsub#owner".equals(ns)) {
+ currentPayloadParser_ = new PubSubOwnerAffiliationsParser(
+ parsers_);
+ }
+ if ("delete".equals(element)
+ && "http://jabber.org/protocol/pubsub#owner".equals(ns)) {
+ 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/payloadparsers/PubSubParser.java b/src/com/isode/stroke/parser/payloadparsers/PubSubParser.java
index 134d654..8497555 100644
--- a/src/com/isode/stroke/parser/payloadparsers/PubSubParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/PubSubParser.java
@@ -1,9 +1,5 @@
/*
-* Copyright (c) 2014, Isode Limited, London, England.
-* All rights reserved.
-*/
-/*
-* Copyright (c) 2014, Remko Tronçon.
+* Copyright (c) 2013-2015, Isode Limited, London, England.
* All rights reserved.
*/
@@ -30,40 +26,40 @@ public class PubSubParser extends GenericPayloadParser<PubSub> {
public void handleStartElement(String element, String ns, AttributeMap attributes) {
if (level_ == 1) {
- if (element == "items" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("items".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubItemsParser(parsers_);
}
- if (element == "create" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("create".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubCreateParser(parsers_);
}
- if (element == "publish" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("publish".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubPublishParser(parsers_);
}
- if (element == "affiliations" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("affiliations".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubAffiliationsParser(parsers_);
}
- if (element == "retract" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("retract".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubRetractParser(parsers_);
}
- if (element == "options" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("options".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubOptionsParser(parsers_);
}
- if (element == "configure" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("configure".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubConfigureParser(parsers_);
}
- if (element == "default" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("default".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubDefaultParser(parsers_);
}
- if (element == "subscriptions" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("subscriptions".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubSubscriptionsParser(parsers_);
}
- if (element == "subscribe" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("subscribe".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubSubscribeParser(parsers_);
}
- if (element == "unsubscribe" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("unsubscribe".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubUnsubscribeParser(parsers_);
}
- if (element == "subscription" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("subscription".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
currentPayloadParser_ = new PubSubSubscriptionParser(parsers_);
}
}
@@ -83,10 +79,10 @@ public class PubSubParser extends GenericPayloadParser<PubSub> {
if (level_ == 1) {
if (currentPayloadParser_ != null) {
- if (element == "options" && ns == "http://jabber.org/protocol/pubsub") {
+ if ("options".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
optionsPayload_ = (PubSubOptions)currentPayloadParser_.getPayload();
}
- else if (element == "configure" && ns == "http://jabber.org/protocol/pubsub") {
+ else if ("configure".equals(element) && "http://jabber.org/protocol/pubsub".equals(ns)) {
configurePayload_ = (PubSubConfigure)currentPayloadParser_.getPayload();
}
else {
diff --git a/src/com/isode/stroke/parser/payloadparsers/ReplaceParser.java b/src/com/isode/stroke/parser/payloadparsers/ReplaceParser.java
new file mode 100644
index 0000000..601ab7d
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/ReplaceParser.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2014-2015, Isode Limited, London, England.
+* All rights reserved.
+*/
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.Replace;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class ReplaceParser extends GenericPayloadParser<Replace> {
+
+ public ReplaceParser() {
+ super(new Replace());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ String id = attributes.getAttribute("id");
+ getPayloadInternal().setID(id);
+ }
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ }
+
+ public void handleCharacterData(String data) {
+ }
+
+ private int level_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/ResultSetParser.java b/src/com/isode/stroke/parser/payloadparsers/ResultSetParser.java
index 26343a0..628c522 100644
--- a/src/com/isode/stroke/parser/payloadparsers/ResultSetParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/ResultSetParser.java
@@ -1,10 +1,5 @@
/*
-* Copyright (c) 2014 Kevin Smith and Remko Tronçon
-* All rights reserved.
-*/
-
-/*
-* Copyright (c) 2014, Isode Limited, London, England.
+* Copyright (c) 2014-2015, Isode Limited, London, England.
* All rights reserved.
*/
@@ -23,7 +18,7 @@ public class ResultSetParser extends GenericPayloadParser<ResultSet> {
public void handleStartElement(String element, String ns, AttributeMap attributes) {
currentText_ = "";
if (level_ == 1) {
- if (element == "first" && ns == "http://jabber.org/protocol/rsm") {
+ if ("first".equals(element) && "http://jabber.org/protocol/rsm".equals(ns)) {
String attributeValue = attributes.getAttributeValue("index");
if (attributeValue != null) {
getPayloadInternal().setFirstIDIndex(Long.parseLong(attributeValue));
@@ -36,17 +31,17 @@ public class ResultSetParser extends GenericPayloadParser<ResultSet> {
public void handleEndElement(String element, String ns) {
--level_;
if (level_ == 1) {
- if (element == "max") {
+ if ("max".equals(element)) {
getPayloadInternal().setMaxItems(Long.parseLong(currentText_));
- } else if (element == "count") {
+ } else if ("count".equals(element)) {
getPayloadInternal().setCount(Long.parseLong(currentText_));
- } else if (element == "first") {
+ } else if ("first".equals(element)) {
getPayloadInternal().setFirstID(currentText_);
- } else if (element == "last") {
+ } else if ("last".equals(element)) {
getPayloadInternal().setLastID(currentText_);
- } else if (element == "after") {
+ } else if ("after".equals(element)) {
getPayloadInternal().setAfter(currentText_);
- } else if (element == "before") {
+ } else if ("before".equals(element)) {
getPayloadInternal().setBefore(currentText_);
}
}
diff --git a/src/com/isode/stroke/parser/payloadparsers/StatusParser.java b/src/com/isode/stroke/parser/payloadparsers/StatusParser.java
new file mode 100644
index 0000000..5a463ef
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/StatusParser.java
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2010-2015, Isode Limited, London, England.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.Status;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class StatusParser extends GenericPayloadParser<Status> {
+
+ public StatusParser() {
+ super(new Status());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ if (level_ == 0) {
+ getPayloadInternal().setText(text_);
+ }
+ }
+
+ public void handleCharacterData(String data) {
+ text_ += data;
+ }
+
+ private int level_;
+ private String text_ = "";
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/StatusShowParser.java b/src/com/isode/stroke/parser/payloadparsers/StatusShowParser.java
new file mode 100644
index 0000000..abe8692
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/StatusShowParser.java
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2010-2015, Isode Limited, London, England.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.StatusShow;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class StatusShowParser extends GenericPayloadParser<StatusShow> {
+
+ public StatusShowParser() {
+ super(new StatusShow());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ if (level_ == 0) {
+ if ("away".equals(text_)) {
+ getPayloadInternal().setType(StatusShow.Type.Away);
+ }
+ else if ("chat".equals(text_)) {
+ getPayloadInternal().setType(StatusShow.Type.FFC);
+ }
+ else if ("xa".equals(text_)) {
+ getPayloadInternal().setType(StatusShow.Type.XA);
+ }
+ else if ("dnd".equals(text_)) {
+ getPayloadInternal().setType(StatusShow.Type.DND);
+ }
+ else {
+ getPayloadInternal().setType(StatusShow.Type.Online);
+ }
+ }
+ }
+
+ public void handleCharacterData(String data) {
+ text_ = text_ == null ? data : text_ + data;
+ }
+
+ private int level_;
+ private String text_;
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/StorageParser.java b/src/com/isode/stroke/parser/payloadparsers/StorageParser.java
new file mode 100644
index 0000000..7898938
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/StorageParser.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2010-2015, Isode Limited, London, England.
+ * All rights reserved.
+ */
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.Storage;
+import com.isode.stroke.elements.Storage.Room;
+import com.isode.stroke.elements.Storage.URL;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class StorageParser extends GenericPayloadParser<Storage> {
+
+ private final static int BookmarkLevel = 1;
+ private static final int DetailLevel = 2;
+ private int level;
+ private String currentText;
+ private Room room;
+ private URL url;
+
+ public StorageParser() {
+ super(new Storage());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level == BookmarkLevel) {
+ if ("conference".equals(element)) {
+ assert(room == null);
+ room = new Storage.Room();
+ room.autoJoin = attributes.getBoolAttribute("autojoin", false);
+ room.jid = new JID(attributes.getAttribute("jid"));
+ room.name = attributes.getAttribute("name");
+ }
+ else if ("url".equals(element)) {
+ assert(url == null);
+ url = new Storage.URL();
+ url.name = attributes.getAttribute("name");
+ url.url = attributes.getAttribute("url");
+ }
+ }
+ else if (level == DetailLevel) {
+ currentText = "";
+ }
+ ++level;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level;
+ if (level == BookmarkLevel) {
+ if ("conference".equals(element)) {
+ assert(room != null);
+ getPayloadInternal().addRoom(room);
+ room = null;
+ }
+ else if ("url".equals(element)) {
+ assert(url != null);
+ getPayloadInternal().addURL(url);
+ url = null;
+ }
+ }
+ else if (level == DetailLevel && room != null) {
+ if ("nick".equals(element)) {
+ room.nick = currentText;
+ }
+ else if ("password".equals(element)) {
+ room.password = currentText;
+ }
+ }
+ }
+
+ public void handleCharacterData(String data) {
+ currentText += data;
+ }
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/SubjectParser.java b/src/com/isode/stroke/parser/payloadparsers/SubjectParser.java
new file mode 100644
index 0000000..5aa69c5
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/SubjectParser.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010-2015, Isode Limited, London, England.
+ * All rights reserved.
+ */
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.Subject;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class SubjectParser extends GenericPayloadParser<Subject> {
+
+
+ private int level_;
+ private String text_ = "";
+
+ public SubjectParser() {
+ super(new Subject());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ if (level_ == 0) {
+ getPayloadInternal().setText(text_);
+ }
+ }
+
+ public void handleCharacterData(String data) {
+ text_ += data;
+ }
+}
diff --git a/src/com/isode/stroke/parser/payloadparsers/VCardParser.java b/src/com/isode/stroke/parser/payloadparsers/VCardParser.java
new file mode 100644
index 0000000..b955dc4
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/VCardParser.java
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2010-2015, Isode Limited, London, England.
+ * All rights reserved.
+ */
+package com.isode.stroke.parser.payloadparsers;
+
+import java.util.Stack;
+
+import com.isode.stroke.base.DateTime;
+import com.isode.stroke.elements.VCard;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+import com.isode.stroke.parser.SerializingParser;
+import com.isode.stroke.stringcodecs.Base64;
+
+public class VCardParser extends GenericPayloadParser<VCard> {
+
+ Stack<String> elementStack_ = new Stack<String>();
+ VCard.EMailAddress currentEMailAddress_;
+ VCard.Telephone currentTelephone_;
+ VCard.Address currentAddress_;
+ VCard.AddressLabel currentAddressLabel_;
+ VCard.Organization currentOrganization_;
+ SerializingParser unknownContentParser_;
+ String currentText_ = "";
+
+ public VCardParser() {
+ super(new VCard());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ elementStack_.add(element);
+ String elementHierarchy = getElementHierarchy();
+ if ("/vCard/EMAIL".equals(elementHierarchy)) {
+ currentEMailAddress_ = new VCard.EMailAddress();
+ }
+ if ("/vCard/TEL".equals(elementHierarchy)) {
+ currentTelephone_ = new VCard.Telephone();
+ }
+ if ("/vCard/ADR".equals(elementHierarchy)) {
+ currentAddress_ = new VCard.Address();
+ }
+ if ("/vCard/LABEL".equals(elementHierarchy)) {
+ currentAddressLabel_ = new VCard.AddressLabel();
+ }
+ if ("/vCard/ORG".equals(elementHierarchy)) {
+ currentOrganization_ = new VCard.Organization();
+ }
+ if (elementStack_.size() == 2) {
+ assert(unknownContentParser_ == null);
+ unknownContentParser_ = new SerializingParser();
+ unknownContentParser_.handleStartElement(element, ns, attributes);
+ }
+ else if (unknownContentParser_ != null) {
+ unknownContentParser_.handleStartElement(element, ns, attributes);
+ }
+
+ currentText_ = "";
+ }
+
+ public void handleEndElement(String element, String ns) {
+ if (unknownContentParser_ != null) {
+ unknownContentParser_.handleEndElement(element, ns);
+ }
+
+ String elementHierarchy = getElementHierarchy();
+ if ("/vCard/VERSION".equals(elementHierarchy)) {
+ getPayloadInternal().setVersion(currentText_);
+ }
+ else if ("/vCard/FN".equals(elementHierarchy)) {
+ getPayloadInternal().setFullName(currentText_);
+ }
+ else if ("/vCard/N/FAMILY".equals(elementHierarchy)) {
+ getPayloadInternal().setFamilyName(currentText_);
+ }
+ else if ("/vCard/N/GIVEN".equals(elementHierarchy)) {
+ getPayloadInternal().setGivenName(currentText_);
+ }
+ else if ("/vCard/N/MIDDLE".equals(elementHierarchy)) {
+ getPayloadInternal().setMiddleName(currentText_);
+ }
+ else if ("/vCard/N/PREFIX".equals(elementHierarchy)) {
+ getPayloadInternal().setPrefix(currentText_);
+ }
+ else if ("/vCard/N/SUFFIX".equals(elementHierarchy)) {
+ getPayloadInternal().setSuffix(currentText_);
+ }
+ else if ("/vCard/N".equals(elementHierarchy)) {
+ }
+ else if ("/vCard/NICKNAME".equals(elementHierarchy)) {
+ getPayloadInternal().setNickname(currentText_);
+ }
+ else if ("/vCard/PHOTO/TYPE".equals(elementHierarchy)) {
+ getPayloadInternal().setPhotoType(currentText_);
+ }
+ else if ("/vCard/PHOTO/BINVAL".equals(elementHierarchy)) {
+ getPayloadInternal().setPhoto(Base64.decode(currentText_.replace("\n", "").replace("\r", "")));
+ }
+ else if ("/vCard/PHOTO".equals(elementHierarchy)) {
+ }
+ else if ("/vCard/EMAIL/USERID".equals(elementHierarchy)) {
+ currentEMailAddress_.address = currentText_;
+ }
+ else if ("/vCard/EMAIL/HOME".equals(elementHierarchy)) {
+ currentEMailAddress_.isHome = true;
+ }
+ else if ("/vCard/EMAIL/WORK".equals(elementHierarchy)) {
+ currentEMailAddress_.isWork = true;
+ }
+ else if ("/vCard/EMAIL/INTERNET".equals(elementHierarchy)) {
+ currentEMailAddress_.isInternet = true;
+ }
+ else if ("/vCard/EMAIL/X400".equals(elementHierarchy)) {
+ currentEMailAddress_.isX400 = true;
+ }
+ else if ("/vCard/EMAIL/PREF".equals(elementHierarchy)) {
+ currentEMailAddress_.isPreferred = true;
+ }
+ else if ("/vCard/EMAIL".equals(elementHierarchy) && currentEMailAddress_.address != null && !currentEMailAddress_.address.isEmpty()) {
+ getPayloadInternal().addEMailAddress(currentEMailAddress_);
+ }
+ else if ("/vCard/BDAY".equals(elementHierarchy) && !currentText_.isEmpty()) {
+ getPayloadInternal().setBirthday(DateTime.stringToDate(currentText_));
+ }
+ else if ("/vCard/TEL/NUMBER".equals(elementHierarchy)) {
+ currentTelephone_.number = currentText_;
+ }
+ else if ("/vCard/TEL/HOME".equals(elementHierarchy)) {
+ currentTelephone_.isHome = true;
+ }
+ else if ("/vCard/TEL/WORK".equals(elementHierarchy)) {
+ currentTelephone_.isWork = true;
+ }
+ else if ("/vCard/TEL/VOICE".equals(elementHierarchy)) {
+ currentTelephone_.isVoice = true;
+ }
+ else if ("/vCard/TEL/FAX".equals(elementHierarchy)) {
+ currentTelephone_.isFax = true;
+ }
+ else if ("/vCard/TEL/PAGER".equals(elementHierarchy)) {
+ currentTelephone_.isPager = true;
+ }
+ else if ("/vCard/TEL/MSG".equals(elementHierarchy)) {
+ currentTelephone_.isMSG = true;
+ }
+ else if ("/vCard/TEL/CELL".equals(elementHierarchy)) {
+ currentTelephone_.isCell = true;
+ }
+ else if ("/vCard/TEL/VIDEO".equals(elementHierarchy)) {
+ currentTelephone_.isVideo = true;
+ }
+ else if ("/vCard/TEL/BBS".equals(elementHierarchy)) {
+ currentTelephone_.isBBS = true;
+ }
+ else if ("/vCard/TEL/MODEM".equals(elementHierarchy)) {
+ currentTelephone_.isModem = true;
+ }
+ else if ("/vCard/TEL/ISDN".equals(elementHierarchy)) {
+ currentTelephone_.isISDN = true;
+ }
+ else if ("/vCard/TEL/PCS".equals(elementHierarchy)) {
+ currentTelephone_.isPCS = true;
+ }
+ else if ("/vCard/TEL/PREF".equals(elementHierarchy)) {
+ currentTelephone_.isPreferred = true;
+ }
+ else if ("/vCard/TEL".equals(elementHierarchy) && currentTelephone_.number != null && !currentTelephone_.number.isEmpty()) {
+ getPayloadInternal().addTelephone(currentTelephone_);
+ }
+ else if ("/vCard/ADR/HOME".equals(elementHierarchy)) {
+ currentAddress_.isHome = true;
+ }
+ else if ("/vCard/ADR/WORK".equals(elementHierarchy)) {
+ currentAddress_.isWork = true;
+ }
+ else if ("/vCard/ADR/POSTAL".equals(elementHierarchy)) {
+ currentAddress_.isPostal = true;
+ }
+ else if ("/vCard/ADR/PARCEL".equals(elementHierarchy)) {
+ currentAddress_.isParcel = true;
+ }
+ else if ("/vCard/ADR/DOM".equals(elementHierarchy)) {
+ currentAddress_.deliveryType = VCard.DeliveryType.DomesticDelivery;
+ }
+ else if ("/vCard/ADR/INTL".equals(elementHierarchy)) {
+ currentAddress_.deliveryType = VCard.DeliveryType.InternationalDelivery;
+ }
+ else if ("/vCard/ADR/PREF".equals(elementHierarchy)) {
+ currentAddress_.isPreferred = true;
+ }
+ else if ("/vCard/ADR/POBOX".equals(elementHierarchy)) {
+ currentAddress_.poBox = currentText_;
+ }
+ else if ("/vCard/ADR/EXTADD".equals(elementHierarchy)) {
+ currentAddress_.addressExtension = currentText_;
+ }
+ else if ("/vCard/ADR/STREET".equals(elementHierarchy)) {
+ currentAddress_.street = currentText_;
+ }
+ else if ("/vCard/ADR/LOCALITY".equals(elementHierarchy)) {
+ currentAddress_.locality = currentText_;
+ }
+ else if ("/vCard/ADR/REGION".equals(elementHierarchy)) {
+ currentAddress_.region = currentText_;
+ }
+ else if ("/vCard/ADR/PCODE".equals(elementHierarchy)) {
+ currentAddress_.postalCode = currentText_;
+ }
+ else if ("/vCard/ADR/CTRY".equals(elementHierarchy)) {
+ currentAddress_.country = currentText_;
+ }
+ else if ("/vCard/ADR".equals(elementHierarchy)) {
+ if (currentAddress_.poBox != null && !currentAddress_.poBox.isEmpty()
+ || currentAddress_.addressExtension != null && !currentAddress_.addressExtension.isEmpty()
+ || currentAddress_.street != null && !currentAddress_.street.isEmpty()
+ || currentAddress_.locality != null && !currentAddress_.locality.isEmpty()
+ || currentAddress_.region != null && !currentAddress_.region.isEmpty()
+ || currentAddress_.postalCode != null && !currentAddress_.postalCode.isEmpty()
+ || currentAddress_.country != null && !currentAddress_.country.isEmpty()) {
+ getPayloadInternal().addAddress(currentAddress_);
+ }
+ }
+ else if ("/vCard/LABEL/HOME".equals(elementHierarchy)) {
+ currentAddressLabel_.isHome = true;
+ }
+ else if ("/vCard/LABEL/WORK".equals(elementHierarchy)) {
+ currentAddressLabel_.isWork = true;
+ }
+ else if ("/vCard/LABEL/POSTAL".equals(elementHierarchy)) {
+ currentAddressLabel_.isPostal = true;
+ }
+ else if ("/vCard/LABEL/PARCEL".equals(elementHierarchy)) {
+ currentAddressLabel_.isParcel = true;
+ }
+ else if ("/vCard/LABEL/DOM".equals(elementHierarchy)) {
+ currentAddressLabel_.deliveryType = VCard.DeliveryType.DomesticDelivery;
+ }
+ else if ("/vCard/LABEL/INTL".equals(elementHierarchy)) {
+ currentAddressLabel_.deliveryType = VCard.DeliveryType.InternationalDelivery;
+ }
+ else if ("/vCard/LABEL/PREF".equals(elementHierarchy)) {
+ currentAddressLabel_.isPreferred = true;
+ }
+ else if ("/vCard/LABEL/LINE".equals(elementHierarchy)) {
+ currentAddressLabel_.lines.add(currentText_);
+ }
+ else if ("/vCard/LABEL".equals(elementHierarchy)) {
+ getPayloadInternal().addAddressLabel(currentAddressLabel_);
+ }
+ else if ("/vCard/JID".equals(elementHierarchy) && !currentText_.isEmpty()) {
+ getPayloadInternal().addJID(new JID(currentText_));
+ }
+ else if ("/vCard/DESC".equals(elementHierarchy)) {
+ getPayloadInternal().setDescription(currentText_);
+ }
+ else if ("/vCard/ORG/ORGNAME".equals(elementHierarchy)) {
+ currentOrganization_.name = currentText_;
+ }
+ else if ("/vCard/ORG/ORGUNIT".equals(elementHierarchy) && !currentText_.isEmpty()) {
+ currentOrganization_.units.add(currentText_);
+ }
+ else if ("/vCard/ORG".equals(elementHierarchy)) {
+ if (!currentOrganization_.name.isEmpty() || !currentOrganization_.units.isEmpty()) {
+ getPayloadInternal().addOrganization(currentOrganization_);
+ }
+ }
+ else if ("/vCard/TITLE".equals(elementHierarchy) && !currentText_.isEmpty()) {
+ getPayloadInternal().addTitle(currentText_);
+ }
+ else if ("/vCard/ROLE".equals(elementHierarchy) && !currentText_.isEmpty()) {
+ getPayloadInternal().addRole(currentText_);
+ }
+ else if ("/vCard/URL".equals(elementHierarchy) && !currentText_.isEmpty()) {
+ getPayloadInternal().addURL(currentText_);
+ }
+ else if (elementStack_.size() == 2 && unknownContentParser_ != null) {
+ getPayloadInternal().addUnknownContent(unknownContentParser_.getResult());
+ }
+
+ if (elementStack_.size() == 2 && unknownContentParser_ != null) {
+ unknownContentParser_ = null;
+ }
+ elementStack_.pop();
+ }
+
+ public void handleCharacterData(String text) {
+ if (unknownContentParser_ != null) {
+ unknownContentParser_.handleCharacterData(text);
+ }
+ currentText_ += text;
+ }
+
+ private String getElementHierarchy() {
+ String result = "";
+ for(String element : elementStack_) {
+ result += "/" + element;
+ }
+ return result;
+ }
+}