a_vcard.android.telephony
Class PhoneNumberUtils

java.lang.Object
  extended by a_vcard.android.telephony.PhoneNumberUtils

public class PhoneNumberUtils
extends java.lang.Object

Various utilities for dealing with phone number strings.


Field Summary
static int FORMAT_JAPAN
          Japastaticnese formatting
static int FORMAT_NANP
          NANP formatting
static int FORMAT_UNKNOWN
          The current locale is unknown, look for a country code or don't format
 
Constructor Summary
PhoneNumberUtils()
           
 
Method Summary
static void formatJapaneseNumber(Editable text)
          Formats a phone number in-place using the Japanese formatting rules.
static void formatNanpNumber(Editable text)
          Formats a phone number in-place using the NANP formatting rules.
static void formatNumber(Editable text, int defaultFormattingType)
          Formats a phone number in-place.
static java.lang.String formatNumber(java.lang.String source)
          Breaks the given number down and formats it according to the rules for the country the number is from.
static int getFormatTypeForLocale(java.util.Locale locale)
          Returns the phone number formatting type for the given locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT_UNKNOWN

public static final int FORMAT_UNKNOWN
The current locale is unknown, look for a country code or don't format

See Also:
Constant Field Values

FORMAT_NANP

public static final int FORMAT_NANP
NANP formatting

See Also:
Constant Field Values

FORMAT_JAPAN

public static final int FORMAT_JAPAN
Japastaticnese formatting

See Also:
Constant Field Values
Constructor Detail

PhoneNumberUtils

public PhoneNumberUtils()
Method Detail

formatNumber

public static java.lang.String formatNumber(java.lang.String source)
Breaks the given number down and formats it according to the rules for the country the number is from.

Parameters:
source - the phone number to format
Returns:
a locally acceptable formatting of the input, or the raw input if formatting rules aren't known for the number

getFormatTypeForLocale

public static int getFormatTypeForLocale(java.util.Locale locale)
Returns the phone number formatting type for the given locale.

Parameters:
locale - The locale of interest, usually Locale.getDefault()
Returns:
the formatting type for the given locale, or FORMAT_UNKNOWN if the formatting rules are not known for the given locale

formatNumber

public static void formatNumber(Editable text,
                                int defaultFormattingType)
Formats a phone number in-place. Currently only supports NANP formatting.

Parameters:
text - The number to be formatted, will be modified with the formatting
defaultFormattingType - The default formatting rules to apply if the number does not begin with +

formatNanpNumber

public static void formatNanpNumber(Editable text)
Formats a phone number in-place using the NANP formatting rules. Numbers will be formatted as:

xxx-xxxx xxx-xxx-xxxx 1-xxx-xxx-xxxx +1-xxx-xxx-xxxx

Parameters:
text - the number to be formatted, will be modified with the formatting

formatJapaneseNumber

public static void formatJapaneseNumber(Editable text)
Formats a phone number in-place using the Japanese formatting rules. Numbers will be formatted as:

03-xxxx-xxxx 090-xxxx-xxxx 0120-xxx-xxx +81-3-xxxx-xxxx +81-90-xxxx-xxxx

Parameters:
text - the number to be formatted, will be modified with the formatting