Skip to content

Commit

Permalink
MONDRIAN: retro fix for JDK 1.4 non-Comparable Boolean
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 8462]
  • Loading branch information
jsichi committed Jan 6, 2007
1 parent 6cbc57a commit 2ade390
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/main/mondrian/olap/Util.java
Expand Up @@ -222,6 +222,22 @@ public static String normalizeName(String s) {
s.toUpperCase();
}

/**
* Returns the result of ((Comparable) k1).compareTo(k2), with
* special-casing for the fact that Boolean only became
* comparable in JDK 1.5.
*
* @see Comparable#compareTo
*/
public static int compareKey(Object k1, Object k2) {
if (k1 instanceof Boolean) {
// Luckily, "F" comes before "T" in the alphabet.
k1 = k1.toString();
k2 = k2.toString();
}
return ((Comparable) k1).compareTo(k2);
}

/**
* Returns a string with every occurrence of a seek string replaced with
* another.
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/RolapMember.java
Expand Up @@ -605,7 +605,7 @@ public int compareTo(Object o) {
if (this.key instanceof String) {
return Util.compareName((String) this.key, (String) other.key);
} else {
return ((Comparable) this.key).compareTo(other.key);
return Util.compareKey(this.key, other.key);
}
}
// Compare by unique name in case of different key classes.
Expand Down

0 comments on commit 2ade390

Please sign in to comment.