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/elements/DiscoItems.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/elements/DiscoItems.java')
-rw-r--r--src/com/isode/stroke/elements/DiscoItems.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/DiscoItems.java b/src/com/isode/stroke/elements/DiscoItems.java
new file mode 100644
index 0000000..ac92cb3
--- /dev/null
+++ b/src/com/isode/stroke/elements/DiscoItems.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2010, Kevin Smith.
+ * All rights reserved.
+ */
+/*
+ * Copyright (c) 2012, Isode Limited, London, England.
+ * All rights reserved.
+ */
+package com.isode.stroke.elements;
+
+import com.isode.stroke.base.NotNull;
+import com.isode.stroke.jid.JID;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Service discovery disco#items from XEP-0030.
+ */
+public class DiscoItems extends Payload {
+
+ /**
+ * A single result item.
+ */
+ public static class Item {
+
+ /**
+ * @param name Item name, not null.
+ * @param jid Item JID, not null.
+ */
+ public Item(String name, JID jid) {
+ this(name, jid, "");
+ }
+
+ /**
+ * @param name Item name, not null.
+ * @param jid Item JID, not null.
+ * @param node Item node, not null.
+ */
+ public Item(String name, JID jid, String node) {
+ NotNull.exceptIfNull(name, "name");
+ NotNull.exceptIfNull(jid, "jid");
+ NotNull.exceptIfNull(node, "node");
+ name_ = name;
+ jid_ = jid;
+ node_ = node;
+ }
+
+ /**
+ *
+ * @return Item name, not null.
+ */
+ public String getName() {
+ return name_;
+ }
+
+ /**
+ *
+ * @return Item node, not null.
+ */
+ public String getNode() {
+ return node_;
+ }
+
+ /**
+ *
+ * @return Item JID, not null.
+ */
+ public JID getJID() {
+ return jid_;
+ }
+ private final String name_;
+ private final JID jid_;
+ private final String node_;
+ };
+
+ public DiscoItems() {
+ }
+
+ public String getNode() {
+ return node_;
+ }
+
+ public void setNode(String node) {
+ node_ = node;
+ }
+
+ public List<Item> getItems() {
+ return new ArrayList(items_);
+ }
+
+ public void addItem(Item item) {
+ items_.add(item);
+ }
+ private String node_;
+ private final List<Item> items_ = new ArrayList<Item>();
+}
+