* @param localNumber the local number to normalize
* @param phoneContext the phone-context
* @return the normalized number
*/
String normalize(String localNumber, String phoneContext) {
PhoneContextHandler handler = null;
Map<String, PatternMapping<PhoneContextHandler>> mappings;
synchronized (this) {
mappings = phoneContextHandlerMappings;
}
for (PatternMapping<PhoneContextHandler> mapping : mappings.values()) {
if (mapping.regexpPattern.matcher(phoneContext).find()) {
handler = mapping.mappedObject;
break;
}
}
String normalizedNumber = (handler != null)
? handler.normalize(localNumber, phoneContext) : null;
if ((normalizedNumber != null) && (normalizedNumber.charAt(0) != '+')) {
// Be nice and make it correct :-)
normalizedNumber = "+" + normalizedNumber;
if (logger.isLoggable(Level.WARNING)) {
logger.log(Level.WARNING,
"The result of phone number normalization using: \"" +
handler.getClass() +
"\", was not a number prefixed with '+'. This has been fixed by the container.");
}
}
return UriUtil.cleanupPhonenumber(normalizedNumber);