diff options
| -rw-r--r-- | src/com/isode/stroke/jid/JID.java | 36 | ||||
| -rw-r--r-- | test/com/isode/stroke/jid/JIDTest.java | 2 |
2 files changed, 14 insertions, 24 deletions
diff --git a/src/com/isode/stroke/jid/JID.java b/src/com/isode/stroke/jid/JID.java index 8b62ca1..07b2084 100644 --- a/src/com/isode/stroke/jid/JID.java +++ b/src/com/isode/stroke/jid/JID.java @@ -48,6 +48,5 @@ public class JID implements Comparable<JID> { private boolean valid_ = true; - private boolean hasResource_ = true; private String node_ = ""; private String domain_ = ""; - private String resource_ = ""; + private String resource_ = null; private static IDNConverter idnConverter = new ICUConverter(); @@ -83,4 +82,3 @@ public class JID implements Comparable<JID> { public JID(String jid) { - NotNull.exceptIfNull(jid, "jid"); - valid_ = true; + NotNull.exceptIfNull(jid, "jid"); initializeFromString(jid); @@ -93,3 +91,3 @@ public class JID implements Comparable<JID> { domain_ = ""; - resource_ = ""; + resource_ = null; return; @@ -104,3 +102,2 @@ public class JID implements Comparable<JID> { } else { - hasResource_ = false; resource = null; @@ -147,7 +144,2 @@ public class JID implements Comparable<JID> { NotNull.exceptIfNull(domain, "domain"); - valid_ = true; - hasResource_ = (resource != null); - if (hasResource_ && resource.isEmpty()) { - valid_ = false; - } nameprepAndSetComponents(node, domain, resource); @@ -169,2 +161,5 @@ public class JID implements Comparable<JID> { } + if (resource_ != null && resource_.isEmpty()) { + valid_ = false; + } if (domain_.isEmpty()) { @@ -174,3 +169,3 @@ public class JID implements Comparable<JID> { } - + /** @@ -211,3 +206,3 @@ public class JID implements Comparable<JID> { public boolean isBare() { - return !hasResource_; + return resource_ == null; } @@ -311,5 +306,2 @@ public class JID implements Comparable<JID> { public String toString() { - if (!valid_) { - return ""; - } String string = new String(); @@ -350,10 +342,8 @@ public class JID implements Comparable<JID> { if (compareType == CompareType.WithResource) { - String res1 = resource_; - String res2 = o.resource_; - if(res1 != null && res2 != null) { - return res1.compareTo(res2); + if (isBare() != o.isBare()) { + return !isBare() ? 1 : -1; + } + if (!isBare()) { + return resource_.compareTo(o.resource_); } - if(res1 == null && res2 == null) { return 0; } - if (res1 == null) { return -1; } - if (res2 == null) { return 1; } } diff --git a/test/com/isode/stroke/jid/JIDTest.java b/test/com/isode/stroke/jid/JIDTest.java index 69bee05..758bd5f 100644 --- a/test/com/isode/stroke/jid/JIDTest.java +++ b/test/com/isode/stroke/jid/JIDTest.java @@ -53,3 +53,3 @@ public class JIDTest { - assertTrue(testling.isValid()); + assertFalse(testling.isValid()); assertFalse(testling.isBare()); |
Swift