summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-06-17 20:29:48 (GMT)
committerTarun Gupta <tarun1995gupta@gmail.com>2015-06-23 14:50:06 (GMT)
commit45e302d354d663eed61de58325ac162182497046 (patch)
treeb5115b957fc2d0d7ffecc43d6cf3c3cf64c94493 /src/com/isode/stroke/elements
parentbb52f4e377fac262fe5b4f0ca2e1f6ed3669ee7d (diff)
downloadstroke-45e302d354d663eed61de58325ac162182497046.zip
stroke-45e302d354d663eed61de58325ac162182497046.tar.bz2
Add Roster Elements.
Adds RosterItemExchangePayload Element, its Parser and Serializer. Updates RosterItemPayload, its Parser and Serializer. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Tests added for: RosterItemPayload Parser and Serializer. RosterItemExchangePayload Parser and Serializer. All tests passes. Change-Id: I8d16a18290d9820cea6839af1f075da00a25db09
Diffstat (limited to 'src/com/isode/stroke/elements')
-rw-r--r--src/com/isode/stroke/elements/RosterItemExchangePayload.java137
-rw-r--r--src/com/isode/stroke/elements/RosterItemPayload.java10
2 files changed, 147 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/RosterItemExchangePayload.java b/src/com/isode/stroke/elements/RosterItemExchangePayload.java
new file mode 100644
index 0000000..a94040f
--- /dev/null
+++ b/src/com/isode/stroke/elements/RosterItemExchangePayload.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2011 Jan Kaluza
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.Payload;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.base.NotNull;
+import java.util.Vector;
+
+public class RosterItemExchangePayload extends Payload {
+
+ public static class Item {
+
+ public enum Action {
+ Add, Modify, Delete
+ };
+
+ private Action action;
+ private JID jid = new JID();
+ private String name = "";
+ private Vector<String> groups = new Vector<String>();
+
+ /**
+ * Default Constructor.
+ */
+ public Item() {
+ this(Item.Action.Add);
+ }
+
+ /**
+ * Parameterized Constructor.
+ * @param action, Not Null.
+ */
+ public Item(Action action) {
+ NotNull.exceptIfNull(action, "action");
+ this.action = action;
+ }
+
+ /**
+ * @return action, Not Null.
+ */
+ public Action getAction() {
+ return action;
+ }
+
+ /**
+ * @param action, Not Null.
+ */
+ public void setAction(Action action) {
+ NotNull.exceptIfNull(action, "action");
+ this.action = action;
+ }
+
+ /**
+ * @return jid, Not Null.
+ */
+ public JID getJID() {
+ return jid;
+ }
+
+ /**
+ * @param jid, Not Null.
+ */
+ public void setJID(JID jid) {
+ NotNull.exceptIfNull(jid, "jid");
+ this.jid = jid;
+ }
+
+ /**
+ * @return name, Not Null.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name, Not Null.
+ */
+ public void setName(String name) {
+ NotNull.exceptIfNull(name, "name");
+ this.name = name;
+ }
+
+ /**
+ * @return groups, Not Null.
+ */
+ public Vector<String> getGroups() {
+ return groups;
+ }
+
+ /**
+ * @param groups, Not Null.
+ */
+ public void setGroups(Vector<String> groups) {
+ NotNull.exceptIfNull(groups, "groups");
+ this.groups = groups;
+ }
+
+ /**
+ * @param group, Not Null.
+ */
+ public void addGroup(String group) {
+ NotNull.exceptIfNull(group, "group");
+ groups.add(group);
+ }
+ }
+
+ private Vector<RosterItemExchangePayload.Item> items_ = new Vector<RosterItemExchangePayload.Item>();
+
+ public RosterItemExchangePayload() {
+
+ }
+
+ /**
+ * @param item, Not Null.
+ */
+ public void addItem(RosterItemExchangePayload.Item item) {
+ NotNull.exceptIfNull(item, "item");
+ items_.add(item);
+ }
+
+ /**
+ * @return items, Not Null.
+ */
+ public Vector<RosterItemExchangePayload.Item> getItems() {
+ return items_;
+ }
+}
diff --git a/src/com/isode/stroke/elements/RosterItemPayload.java b/src/com/isode/stroke/elements/RosterItemPayload.java
index c080915..1ede267 100644
--- a/src/com/isode/stroke/elements/RosterItemPayload.java
+++ b/src/com/isode/stroke/elements/RosterItemPayload.java
@@ -86,9 +86,19 @@ public class RosterItemPayload {
public boolean getSubscriptionRequested() {
return ask_;
}
+
+ public String getUnknownContent() {
+ return unknownContent_;
+ }
+
+ public void addUnknownContent(String c) {
+ unknownContent_ += c;
+ }
+
private JID jid_;
private String name_;
private Subscription subscription_;
private Collection<String> groups_;
private boolean ask_;
+ private String unknownContent_ = "";
}