diff options
Diffstat (limited to 'java/src/Ice/Util.java')
-rw-r--r-- | java/src/Ice/Util.java | 116 |
1 files changed, 73 insertions, 43 deletions
diff --git a/java/src/Ice/Util.java b/java/src/Ice/Util.java index d15bf89ba6c..ae40096ebe1 100644 --- a/java/src/Ice/Util.java +++ b/java/src/Ice/Util.java @@ -220,54 +220,84 @@ public final class Util public static int proxyIdentityCompare(ObjectPrx lhs, ObjectPrx rhs) { - Identity lhsIdentity = lhs.ice_getIdentity(); - Identity rhsIdentity = rhs.ice_getIdentity(); - int n; - if((n = lhsIdentity.name.compareTo(rhsIdentity.name)) != 0) - { - return n; - } - return lhsIdentity.category.compareTo(rhsIdentity.category); + if(lhs == null && rhs == null) + { + return 0; + } + else if(lhs == null && rhs != null) + { + return -1; + } + else if(lhs != null && rhs == null) + { + return 1; + } + else + { + Identity lhsIdentity = lhs.ice_getIdentity(); + Identity rhsIdentity = rhs.ice_getIdentity(); + int n; + if((n = lhsIdentity.name.compareTo(rhsIdentity.name)) != 0) + { + return n; + } + return lhsIdentity.category.compareTo(rhsIdentity.category); + } } public static int proxyIdentityAndFacetCompare(ObjectPrx lhs, ObjectPrx rhs) { - Identity lhsIdentity = lhs.ice_getIdentity(); - Identity rhsIdentity = rhs.ice_getIdentity(); - int n; - if((n = lhsIdentity.name.compareTo(rhsIdentity.name)) != 0) - { - return n; - } - if((n = lhsIdentity.category.compareTo(rhsIdentity.category)) != 0) - { - return n; - } - - String[] lhsFacet = lhs.ice_getFacet(); - String[] rhsFacet = rhs.ice_getFacet(); - int i; - for(i = 0; i < lhsFacet.length && i < rhsFacet.length; i++) - { - if((n = lhsFacet[i].compareTo(rhsFacet[i])) != 0) - { - return n; - } - } - - if(lhsFacet.length == rhsFacet.length) - { - return 0; - } - else if(lhsFacet.length < rhsFacet.length) - { - return -1; - } - else - { - return 1; - } + if(lhs == null && rhs == null) + { + return 0; + } + else if(lhs == null && rhs != null) + { + return -1; + } + else if(lhs != null && rhs == null) + { + return 1; + } + else + { + Identity lhsIdentity = lhs.ice_getIdentity(); + Identity rhsIdentity = rhs.ice_getIdentity(); + int n; + if((n = lhsIdentity.name.compareTo(rhsIdentity.name)) != 0) + { + return n; + } + if((n = lhsIdentity.category.compareTo(rhsIdentity.category)) != 0) + { + return n; + } + + String[] lhsFacet = lhs.ice_getFacet(); + String[] rhsFacet = rhs.ice_getFacet(); + int i; + for(i = 0; i < lhsFacet.length && i < rhsFacet.length; i++) + { + if((n = lhsFacet[i].compareTo(rhsFacet[i])) != 0) + { + return n; + } + } + + if(lhsFacet.length == rhsFacet.length) + { + return 0; + } + else if(lhsFacet.length < rhsFacet.length) + { + return -1; + } + else + { + return 1; + } + } } private static Properties _defaultProperties = null; |