diff options
author | Sam Whited <sam@samwhited.com> | 2014-11-05 15:55:47 -0500 |
---|---|---|
committer | Sam Whited <sam@samwhited.com> | 2014-11-09 07:00:40 -0500 |
commit | 9053f4aca0c232db77dbd0a1e5b9b09bf41bec22 (patch) | |
tree | d44820f93e139f696228c6abcbac02b75a9f7c44 /src/main/java/eu/siacs/conversations/xmpp/jid | |
parent | a9908613162f753ad71ac25890fb7cc067925764 (diff) |
Move a chunk of classes over to using JID objects
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp/jid')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java index 7d8f702f0..2bbde7aba 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java @@ -19,7 +19,7 @@ public final class Jid { private final String displayjid; public String getLocalpart() { - return IDN.toUnicode(localpart); + return localpart; } public String getDomainpart() { @@ -27,10 +27,10 @@ public final class Jid { } public String getResourcepart() { - return IDN.toUnicode(resourcepart); + return resourcepart; } - public Jid fromString(final String jid) throws InvalidJidException { + public static Jid fromString(final String jid) throws InvalidJidException { return new Jid(jid); } @@ -121,11 +121,20 @@ public final class Jid { this.displayjid = finaljid; } - public Jid getBareJid() { + public Jid toBareJid() { try { return resourcepart.isEmpty() ? this : fromParts(localpart, domainpart, ""); } catch (final InvalidJidException e) { - // This should never happen due to the contracts we have in place. + // This should never happen. + return null; + } + } + + public Jid toDomainJid() { + try { + return resourcepart.isEmpty() && localpart.isEmpty() ? this : fromString(getDomainpart()); + } catch (final InvalidJidException e) { + // This should never happen. return null; } } |