diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-11-19 23:07:54 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-11-19 23:07:54 +0100 |
commit | d783cec97084a12873ca62b5fcd64620056ec01b (patch) | |
tree | 65e63d03dd4ab7a834c343ba593c8cd8917620cb /src/main/java/de/pixart/messenger/entities/Presence.java | |
parent | 969ba45c56adaaa056f04464cd98aec115c9611b (diff) |
reformat code
Diffstat (limited to 'src/main/java/de/pixart/messenger/entities/Presence.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Presence.java | 170 |
1 files changed, 87 insertions, 83 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Presence.java b/src/main/java/de/pixart/messenger/entities/Presence.java index fe7bac6ee..af467f1f6 100644 --- a/src/main/java/de/pixart/messenger/entities/Presence.java +++ b/src/main/java/de/pixart/messenger/entities/Presence.java @@ -6,87 +6,91 @@ import de.pixart.messenger.xml.Element; public class Presence implements Comparable { - public enum Status { - CHAT, ONLINE, AWAY, XA, DND, OFFLINE; - - public String toShowString() { - switch(this) { - case CHAT: return "chat"; - case AWAY: return "away"; - case XA: return "xa"; - case DND: return "dnd"; - } - return null; - } - - public static Status fromShowString(String show) { - if (show == null) { - return ONLINE; - } else { - switch (show.toLowerCase(Locale.US)) { - case "away": - return AWAY; - case "xa": - return XA; - case "dnd": - return DND; - case "chat": - return CHAT; - default: - return ONLINE; - } - } - } - } - - private final Status status; - private ServiceDiscoveryResult disco; - private final String ver; - private final String hash; - private final String message; - - private Presence(Status status, String ver, String hash, String message) { - this.status = status; - this.ver = ver; - this.hash = hash; - this.message = message; - } - - public static Presence parse(String show, Element caps, String message) { - final String hash = caps == null ? null : caps.getAttribute("hash"); - final String ver = caps == null ? null : caps.getAttribute("ver"); - return new Presence(Status.fromShowString(show), ver, hash, message); - } - - public int compareTo(Object other) { - return this.status.compareTo(((Presence)other).status); - } - - public Status getStatus() { - return this.status; - } - - public boolean hasCaps() { - return ver != null && hash != null; - } - - public String getVer() { - return this.ver; - } - - public String getHash() { - return this.hash; - } - - public String getMessage() { - return this.message; - } - - public void setServiceDiscoveryResult(ServiceDiscoveryResult disco) { - this.disco = disco; - } - - public ServiceDiscoveryResult getServiceDiscoveryResult() { - return disco; - } + public enum Status { + CHAT, ONLINE, AWAY, XA, DND, OFFLINE; + + public String toShowString() { + switch (this) { + case CHAT: + return "chat"; + case AWAY: + return "away"; + case XA: + return "xa"; + case DND: + return "dnd"; + } + return null; + } + + public static Status fromShowString(String show) { + if (show == null) { + return ONLINE; + } else { + switch (show.toLowerCase(Locale.US)) { + case "away": + return AWAY; + case "xa": + return XA; + case "dnd": + return DND; + case "chat": + return CHAT; + default: + return ONLINE; + } + } + } + } + + private final Status status; + private ServiceDiscoveryResult disco; + private final String ver; + private final String hash; + private final String message; + + private Presence(Status status, String ver, String hash, String message) { + this.status = status; + this.ver = ver; + this.hash = hash; + this.message = message; + } + + public static Presence parse(String show, Element caps, String message) { + final String hash = caps == null ? null : caps.getAttribute("hash"); + final String ver = caps == null ? null : caps.getAttribute("ver"); + return new Presence(Status.fromShowString(show), ver, hash, message); + } + + public int compareTo(Object other) { + return this.status.compareTo(((Presence) other).status); + } + + public Status getStatus() { + return this.status; + } + + public boolean hasCaps() { + return ver != null && hash != null; + } + + public String getVer() { + return this.ver; + } + + public String getHash() { + return this.hash; + } + + public String getMessage() { + return this.message; + } + + public void setServiceDiscoveryResult(ServiceDiscoveryResult disco) { + this.disco = disco; + } + + public ServiceDiscoveryResult getServiceDiscoveryResult() { + return disco; + } } |