From: Travis Keep Date: Mon, 13 May 2013 23:41:55 +0000 (+0000) Subject: ICU-10069 Add comments per Markus' review. X-Git-Tag: milestone-59-0-1~2901 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c43fdd0dce79fbdf4a27285368f1b4340516351c;p=icu ICU-10069 Add comments per Markus' review. X-SVN-Rev: 33645 --- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java b/icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java index 04b2eb86512..a57976d718b 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java @@ -689,6 +689,8 @@ public class Currency extends MeasureUnit implements Serializable { for (Map.Entry e : names.symbolMap().entrySet()) { String symbol = e.getKey(); String isoCode = e.getValue(); + // Register under not just symbol, but under every equivalent symbol as well + // e.g short width yen and long width yen. for (String equivalentSymbol : EQUIVALENT_CURRENCY_SYMBOLS.get(symbol)) { symTrie.put(equivalentSymbol, new CurrencyStringInfo(isoCode, symbol)); } @@ -720,11 +722,18 @@ public class Currency extends MeasureUnit implements Serializable { private static class CurrencyNameResultHandler implements TextTrieMap.ResultHandler { + // The length of longest matching key private int bestMatchLength; + // The currency ISO code of longest matching key private String bestCurrencyISOCode; + // As the trie is traversed, handlePrefixMatch is called at each node. matchLength is the + // length length of the key at the current node; values is the list of all the values mapped to + // that key. matchLength increases with each call as trie is traversed. public boolean handlePrefixMatch(int matchLength, Iterator values) { if (values.hasNext()) { + // Since the best match criteria is only based on length of key in trie and since all the + // values are mapped to the same key, we only need to examine the first value. bestCurrencyISOCode = values.next().getISOCode(); bestMatchLength = matchLength; }