pair = (EntryPair)list.lastElement();
int maxLength = pair.entryName.length();
// (the Normalizer is cloned here so that the seeking we do in the next loop
// won't affect our real position in the text)
NormalizerBase tempText = (NormalizerBase)text.clone();
// extract the next maxLength characters in the string (we have to do this using the
// Normalizer to ensure that our offsets correspond to those the rest of the
// iterator is using) and store it in "fragment".
tempText.previous();
key.setLength(0);
int c = tempText.next();
while (maxLength > 0 && c != NormalizerBase.DONE) {
if (Character.isSupplementaryCodePoint(c)) {
key.append(Character.toChars(c));
maxLength -= 2;
} else {
key.append((char)c);
--maxLength;
}
c = tempText.next();
}
String fragment = key.toString();
// now that we have that fragment, iterate through this list looking for the
// longest sequence that matches the characters in the actual text. (maxLength
// is used here to keep track of the length of the longest sequence)