@Test public void testCompareToLatin_false() throws Exception { byte[] key = {0x21, 0x23, 0x44, '\0'}; byte[] pattern = {0x21, 0x23}; boolean presearch = false; assertEquals(CompareUtil.compareToLatin(key, pattern, presearch), 0x44); }
public static int compareToLatin(final byte[] key, final byte[] pattern, final boolean presearch) { int klen = key.length; int plen = pattern.length; int kByte, pByte; for (int i=0; i<klen; i++) { if (i >= plen) { if (presearch) { return 0; } else { return key[i] & 0xff; } } if (key[i] == '\0') { while (i < plen && (pattern[i] == ' ' || pattern[i] == '\0')) { i++; } return i - plen; } kByte = key[i] & 0xff; pByte = pattern[i] & 0xff; if (kByte != pByte) { return kByte - pByte; } } if (klen < plen) { while (klen < plen && (pattern[klen] == ' ' || pattern[klen] == '\0')) { klen++; } return klen - plen; } return 0; }
CompareUtil { public static int compareToLatin(final byte[] key, final byte[] pattern, final boolean presearch) { int klen = key.length; int plen = pattern.length; int kByte, pByte; for (int i=0; i<klen; i++) { if (i >= plen) { if (presearch) { return 0; } else { return key[i] & 0xff; } } if (key[i] == '\0') { while (i < plen && (pattern[i] == ' ' || pattern[i] == '\0')) { i++; } return i - plen; } kByte = key[i] & 0xff; pByte = pattern[i] & 0xff; if (kByte != pByte) { return kByte - pByte; } } if (klen < plen) { while (klen < plen && (pattern[klen] == ' ' || pattern[klen] == '\0')) { klen++; } return klen - plen; } return 0; } }
CompareUtil { public static int compareToLatin(final byte[] key, final byte[] pattern, final boolean presearch) { int klen = key.length; int plen = pattern.length; int kByte, pByte; for (int i=0; i<klen; i++) { if (i >= plen) { if (presearch) { return 0; } else { return key[i] & 0xff; } } if (key[i] == '\0') { while (i < plen && (pattern[i] == ' ' || pattern[i] == '\0')) { i++; } return i - plen; } kByte = key[i] & 0xff; pByte = pattern[i] & 0xff; if (kByte != pByte) { return kByte - pByte; } } if (klen < plen) { while (klen < plen && (pattern[klen] == ' ' || pattern[klen] == '\0')) { klen++; } return klen - plen; } return 0; } private  CompareUtil(); }
CompareUtil { public static int compareToLatin(final byte[] key, final byte[] pattern, final boolean presearch) { int klen = key.length; int plen = pattern.length; int kByte, pByte; for (int i=0; i<klen; i++) { if (i >= plen) { if (presearch) { return 0; } else { return key[i] & 0xff; } } if (key[i] == '\0') { while (i < plen && (pattern[i] == ' ' || pattern[i] == '\0')) { i++; } return i - plen; } kByte = key[i] & 0xff; pByte = pattern[i] & 0xff; if (kByte != pByte) { return kByte - pByte; } } if (klen < plen) { while (klen < plen && (pattern[klen] == ' ' || pattern[klen] == '\0')) { klen++; } return klen - plen; } return 0; } private  CompareUtil(); static int compareToByte(final byte[] key, final byte[] pattern,
                                    final boolean presearch); static int compareToJISX0208(final byte[] key, final byte[] pattern,
                                        final boolean presearch); static int compareToLatin(final byte[] key, final byte[] pattern,
                                     final boolean presearch); static int compareToKanaGroup(final byte[] key, final byte[] pattern,
                                         final boolean exact); static int compareToKanaSingle(final byte[] key, final byte[] pattern,
                                          final boolean exact); }
CompareUtil { public static int compareToLatin(final byte[] key, final byte[] pattern, final boolean presearch) { int klen = key.length; int plen = pattern.length; int kByte, pByte; for (int i=0; i<klen; i++) { if (i >= plen) { if (presearch) { return 0; } else { return key[i] & 0xff; } } if (key[i] == '\0') { while (i < plen && (pattern[i] == ' ' || pattern[i] == '\0')) { i++; } return i - plen; } kByte = key[i] & 0xff; pByte = pattern[i] & 0xff; if (kByte != pByte) { return kByte - pByte; } } if (klen < plen) { while (klen < plen && (pattern[klen] == ' ' || pattern[klen] == '\0')) { klen++; } return klen - plen; } return 0; } private  CompareUtil(); static int compareToByte(final byte[] key, final byte[] pattern,
                                    final boolean presearch); static int compareToJISX0208(final byte[] key, final byte[] pattern,
                                        final boolean presearch); static int compareToLatin(final byte[] key, final byte[] pattern,
                                     final boolean presearch); static int compareToKanaGroup(final byte[] key, final byte[] pattern,
                                         final boolean exact); static int compareToKanaSingle(final byte[] key, final byte[] pattern,
                                          final boolean exact);  }