Ejemplo n.º 1
0
 public int compare(Object obj1, Object obj2) {
   CollationKey key1 = collator.getCollationKey(((GeopistaMap) obj1).getName());
   CollationKey key2 = collator.getCollationKey(((GeopistaMap) obj2).getName());
   int diferencia = key1.compareTo(key2);
   if (diferencia > 0) return -1;
   else if (diferencia < 0) return 1;
   else return 0;
 }
Ejemplo n.º 2
0
  public int compareTo(java.text.CollationKey other) {
    // Get the bytes from the other collation key.
    final byte[] rhsBytes;
    if (other instanceof CollationKey) {
      rhsBytes = ((CollationKey) other).bytes;
    } else {
      rhsBytes = other.toByteArray();
    }

    if (bytes == null || bytes.length == 0) {
      if (rhsBytes == null || rhsBytes.length == 0) {
        return 0;
      }
      return -1;
    } else {
      if (rhsBytes == null || rhsBytes.length == 0) {
        return 1;
      }
    }

    int count = Math.min(bytes.length, rhsBytes.length);
    for (int i = 0; i < count; ++i) {
      int s = bytes[i] & 0xff;
      int t = rhsBytes[i] & 0xff;
      if (s < t) {
        return -1;
      }
      if (s > t) {
        return 1;
      }
    }
    if (bytes.length < rhsBytes.length) {
      return -1;
    }
    if (bytes.length > rhsBytes.length) {
      return 1;
    }
    return 0;
  }
Ejemplo n.º 3
0
 public int compare(Object obj1, Object obj2) {
   CollationKey key1 = collator.getCollationKey(((GeopistaMap) obj1).getName());
   CollationKey key2 = collator.getCollationKey(((GeopistaMap) obj2).getName());
   return key1.compareTo(key2);
 }