private static int compareAsString(byte type1, byte[] b1, int o1, byte type2, byte[] b2, int o2) {
switch (type1 << 8 | type2) {
case STRING_TO_STRING:
return compareAsStringOfUtf(b1, o1, b2, o2);
case STRING_TO_STRING_BYTES:
return -compareAsStringOfByteToUtf(b2, o2, b1, o1);
case STRING_BYTES_TO_STRING:
return compareAsStringOfByteToUtf(b1, o1, b2, o2);
case STRING_BYTES_TO_STRING_BYTES:
return compareAsStringOfByte(b1, o1, b2, o2);
default:
throw new ClassCastException(String.format("Incomparable types: %d %d", type1, type2));
}
}