summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-01-12 16:48:02 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-01-16 15:54:31 (GMT)
commit839db071f46d083b86996f514f5fe0f2d6aee80a (patch)
tree9f14beb42dcd82fa4deba10f516a0ba0368e57b5 /src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java
parent3adee817bfcbd54fd13c4d946bedadeca661e9b1 (diff)
downloadstroke-839db071f46d083b86996f514f5fe0f2d6aee80a.zip
stroke-839db071f46d083b86996f514f5fe0f2d6aee80a.tar.bz2
Add support for DiscoItems and DiscoInfo.
Updates requisite classes in line with Swiften. Also fixes bugs in the EventLoops not using handleEvent.
Diffstat (limited to 'src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java')
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java b/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java
new file mode 100644
index 0000000..caf75cf
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2010, Kevin Smith.
+ * All rights reserved.
+ */
+package com.isode.stroke.parser.payloadparsers;
+
+import com.isode.stroke.elements.DiscoItems;
+import com.isode.stroke.elements.DiscoItems.Item;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+class DiscoItemsParser extends GenericPayloadParser<DiscoItems> {
+ public DiscoItemsParser() {
+ super(new DiscoItems());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == PayloadLevel) {
+ if (element.equals("item")) {
+ Item item = new Item(attributes.getAttribute("name"), new JID(attributes.getAttribute("jid")), attributes.getAttribute("node"));
+ getPayloadInternal().addItem(item);
+ }
+ }
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ }
+
+ public void handleCharacterData(String data) {
+ }
+ private static final int TopLevel = 0;
+ private static final int PayloadLevel = 1;
+ private int level_ = TopLevel;
+}