19 package org.sleuthkit.autopsy.communications.relationships;
21 import com.google.i18n.phonenumbers.NumberParseException;
22 import com.google.i18n.phonenumbers.PhoneNumberUtil;
23 import com.google.i18n.phonenumbers.Phonenumber;
24 import java.util.logging.Level;
45 String regionCode = null;
47 PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
48 Phonenumber.PhoneNumber phoneNum = phoneNumberUtil.parse(phoneNumber,
"");
49 regionCode = phoneNumberUtil.getRegionCodeForNumber(phoneNum);
51 if (regionCode == null) {
56 }
catch (NumberParseException ex) {
57 logger.log(Level.WARNING,
"Error getting country code, for phone number: {0}", phoneNumber);
71 PhoneNumberUtil phone_util = PhoneNumberUtil.getInstance();
73 Phonenumber.PhoneNumber phoneProto = phone_util.parse(phoneNumber,
getCountryCode(phoneNumber));
74 if (phone_util.isValidNumber(phoneProto)) {
75 return phone_util.format(phoneProto, PhoneNumberUtil.PhoneNumberFormat.E164);
77 logger.log(Level.WARNING,
"Invalid phone number: {0}", phoneNumber);
80 }
catch (NumberParseException e) {
81 logger.log(Level.WARNING,
"Error parsing phone number: {0}", phoneNumber);
95 PhoneNumberUtil phone_util = PhoneNumberUtil.getInstance();
97 Phonenumber.PhoneNumber phoneProto = phone_util.parse(phoneNumber,
getCountryCode(phoneNumber));
98 if (phone_util.isValidNumber(phoneProto)) {
99 return phone_util.format(phoneProto, PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL);
101 logger.log(Level.WARNING,
"Invalid phone number: {0}", phoneNumber);
104 }
catch (NumberParseException e) {
105 logger.log(Level.WARNING,
"Error parsing phone number: {0}", phoneNumber);
static final Logger logger
static String getCountryCode(String phoneNumber)
static String convertToE164(String phoneNumber)
static String convertToInternational(String phoneNumber)
synchronized static Logger getLogger(String name)