@ Deprecated public static String parse ( ULocale locale , String text , int type , ParsePosition pos ) { List < TextTrieMap < CurrencyStringInfo >> currencyTrieVec = CURRENCY_NAME_CACHE . get ( locale ) ; if ( currencyTrieVec == null ) { TextTrieMap < CurrencyStringInfo > currencyNameTrie = new TextTrieMap < CurrencyStringInfo > ( true ) ; TextTrieMap < CurrencyStringInfo > currencySymbolTrie = new TextTrieMap < CurrencyStringInfo > ( false ) ; currencyTrieVec = new ArrayList < TextTrieMap < CurrencyStringInfo > > ( ) ; currencyTrieVec . add ( currencySymbolTrie ) ; currencyTrieVec . add ( currencyNameTrie ) ; setupCurrencyTrieVec ( locale , currencyTrieVec ) ; CURRENCY_NAME_CACHE . put ( locale , currencyTrieVec ) ; } int maxLength = 0 ; String isoResult = null ; // look for the names TextTrieMap < CurrencyStringInfo > currencyNameTrie = currencyTrieVec . get ( 1 ) ; CurrencyNameResultHandler handler = new CurrencyNameResultHandler ( ) ; currencyNameTrie . find ( text , pos . getIndex ( ) , handler ) ; isoResult = handler . getBestCurrencyISOCode ( ) ; maxLength = handler . getBestMatchLength ( ) ; if ( type != Currency . LONG_NAME ) { // not long name only TextTrieMap < CurrencyStringInfo > currencySymbolTrie = currencyTrieVec . get ( 0 ) ; handler = new CurrencyNameResultHandler ( ) ; currencySymbolTrie . find ( text , pos . getIndex ( ) , handler ) ; if ( handler . getBestMatchLength ( ) > maxLength ) { isoResult = handler . getBestCurrencyISOCode ( ) ; maxLength = handler . getBestMatchLength ( ) ; } } int start = pos . getIndex ( ) ; pos . setIndex ( start + maxLength ) ; return isoResult ; }
Attempt to parse the given string as a currency either as a display name in the given locale or as a 3 - letter ISO 4217 code . If multiple display names match then the longest one is selected . If both a display name and a 3 - letter ISO code match then the display name is preferred unless it s length is less than 3 .