summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGurmeen Bindra <gurmeen.bindra@isode.com>2012-04-16 11:08:41 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-04-19 10:45:37 (GMT)
commitbae6e6298a617b801a15cbdba13d6759d8b44f31 (patch)
tree8508bd612b8ace3ba25311d2fad181ca5761662a /src/com/isode/stroke/elements/Presence.java
parent00b0f316b9125031f30151cacdf2dcf217b8fa01 (diff)
downloadstroke-bae6e6298a617b801a15cbdba13d6759d8b44f31.zip
stroke-bae6e6298a617b801a15cbdba13d6759d8b44f31.tar.bz2
Add a copy constructor to Presence and Stanza + compare method in JID
This patch adds a copy constructor to the Presence class(and hence base class Staza as well). It also ports the compare method to JID class. Also added javadocs to Presence and Stanza classes. Test-information: tested using the Work In Progress code that ports MUC Admin to stroke Reviewer: Kevin Smith <kevin.smith@isode.com>
Diffstat (limited to 'src/com/isode/stroke/elements/Presence.java')
-rw-r--r--src/com/isode/stroke/elements/Presence.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/Presence.java b/src/com/isode/stroke/elements/Presence.java
index acf0a40..392573f 100644
--- a/src/com/isode/stroke/elements/Presence.java
+++ b/src/com/isode/stroke/elements/Presence.java
@@ -8,28 +8,61 @@
*/
package com.isode.stroke.elements;
+/**
+ * Class representing Presence stanza
+ *
+ */
public class Presence extends Stanza {
private Type type_;
+ /**
+ * Presence Stanza Type
+ *
+ */
public enum Type {
Available, Error, Probe, Subscribe, Subscribed, Unavailable, Unsubscribe, Unsubscribed
};
+ /**
+ * Create the Presence object
+ */
public Presence() {
type_ = Type.Available;
}
+
+ /**
+ * Create a Presence object from the specified object by
+ * creating a copy
+ * @param copy presence object to be copied, not null
+ */
+ public Presence(Presence copy) {
+ super(copy);
+ this.type_ = copy.type_;
+ }
+ /**
+ * Create the Presence object using the status string
+ * @param status status string, not null
+ */
public Presence(String status) {
type_ = Type.Available;
setStatus(status);
}
+ /**
+ * Get the Presence Stanza type
+ * @return presence type, not null
+ */
public Type getType() {
return type_;
}
+ /**
+ * Set the Presence stanza type
+ * @param type stanza type, not null
+ */
public void setType(Type type) {
type_ = type;
}
@@ -42,10 +75,18 @@ public class Presence extends Stanza {
return type_ == Type.Available ? StatusShow.Type.Online : StatusShow.Type.None;
}
+ /**
+ * Set the show status type
+ * @param show status type, not null
+ */
public void setShow(StatusShow.Type show) {
updatePayload(new StatusShow(show));
}
+ /**
+ * Get the status message
+ * @return status message, not null but can be empty
+ */
public String getStatus() {
Status status = getPayload(new Status());
if (status != null) {
@@ -54,15 +95,27 @@ public class Presence extends Stanza {
return "";
}
+ /**
+ * Set the status string
+ * @param status status string, not null
+ */
public void setStatus(String status) {
updatePayload(new Status(status));
}
+ /**
+ * Get the priority of presence stanza
+ * @return priority of presence stanza
+ */
public int getPriority() {
Priority priority = getPayload(new Priority());
return (priority != null ? priority.getPriority() : 0);
}
+ /**
+ * Set the priority of presence message.
+ * @param priority priority value (allowed values -127 to 128)
+ */
public void setPriority(int priority) {
updatePayload(new Priority(priority));
}