diff options
Diffstat (limited to 'src/com/isode/stroke/elements/Presence.java')
-rw-r--r-- | src/com/isode/stroke/elements/Presence.java | 53 |
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)); } |