public static E164CountryCode lookup ( String address ) { // analyze just the first few chars -- max of 4 or length of address int len = ( address . length ( ) > maxPrefixLength ? maxPrefixLength : address . length ( ) ) ; // search backwards first, return the first result for ( int i = len ; i > 0 ; i -- ) { String prefix = address . substring ( 0 , i ) ; E164CountryCode entry = byPrefix . get ( prefix ) ; if ( entry != null ) { return entry ; } } // nothing found return null ; }
Looks up an E164CountryCode object by analyzing the address and returning the best match . For example 12125551212 will return an entry for the US .