You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1405 lines
74 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0-google-v3) on Wed May 04 18:24:03 CEST 2011 -->
<TITLE>
PhoneNumberUtil
</TITLE>
<META NAME="date" CONTENT="2011-05-04">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="PhoneNumberUtil";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../com/google/i18n/phonenumbers/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberMatch.html" title="class in com.google.i18n.phonenumbers"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.Leniency.html" title="enum in com.google.i18n.phonenumbers"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?com/google/i18n/phonenumbers/PhoneNumberUtil.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="PhoneNumberUtil.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.google.i18n.phonenumbers</FONT>
<BR>
Class PhoneNumberUtil</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.i18n.phonenumbers.PhoneNumberUtil</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>PhoneNumberUtil</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
Utility for international phone numbers. Functionality includes formatting, parsing and
validation.
<p>If you use this library, and want to be notified about important changes, please sign up to
our <a href="http://groups.google.com/group/libphonenumber-discuss/about">mailing list</a>.
<P>
<P>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<A NAME="nested_class_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Nested Class Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.Leniency.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.Leniency</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Leniency when finding potential phone numbers in text
segments.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.MatchType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.MatchType</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Types of phone number matches.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberFormat.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberFormat</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTERNATIONAL and NATIONAL formats are consistent with the definition in ITU-T Recommendation
E.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberType</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type of phone numbers.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.ValidationResult.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.ValidationResult</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Possible outcomes when testing if a PhoneNumber is possible.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#convertAlphaCharactersInNumber(java.lang.String)">convertAlphaCharactersInNumber</A></B>(java.lang.String&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Converts all alpha characters in a number to their respective digits on a keypad, but retains
existing formatting.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Iterable&lt;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberMatch.html" title="class in com.google.i18n.phonenumbers">PhoneNumberMatch</A>&gt;</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#findNumbers(java.lang.CharSequence, java.lang.String)">findNumbers</A></B>(java.lang.CharSequence&nbsp;text,
java.lang.String&nbsp;defaultRegion)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an iterable over all <CODE>PhoneNumberMatches</CODE> in <code>text</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Iterable&lt;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberMatch.html" title="class in com.google.i18n.phonenumbers">PhoneNumberMatch</A>&gt;</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#findNumbers(java.lang.CharSequence, java.lang.String, com.google.i18n.phonenumbers.PhoneNumberUtil.Leniency, long)">findNumbers</A></B>(java.lang.CharSequence&nbsp;text,
java.lang.String&nbsp;defaultRegion,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.Leniency.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.Leniency</A>&nbsp;leniency,
long&nbsp;maxTries)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an iterable over all <CODE>PhoneNumberMatches</CODE> in <code>text</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#format(PhoneNumber, com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat)">format</A></B>(PhoneNumber&nbsp;number,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberFormat.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberFormat</A>&nbsp;numberFormat)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a phone number in the specified format using default rules.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#format(PhoneNumber, com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat, java.lang.StringBuilder)">format</A></B>(PhoneNumber&nbsp;number,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberFormat.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberFormat</A>&nbsp;numberFormat,
java.lang.StringBuilder&nbsp;formattedNumber)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#formatByPattern(PhoneNumber, com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat, java.util.List)">formatByPattern</A></B>(PhoneNumber&nbsp;number,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberFormat.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberFormat</A>&nbsp;numberFormat,
java.util.List&lt;NumberFormat&gt;&nbsp;userDefinedFormats)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a phone number in the specified format using client-defined formatting rules.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#formatInOriginalFormat(PhoneNumber, java.lang.String)">formatInOriginalFormat</A></B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;regionCallingFrom)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a phone number using the original phone number format that the number is parsed from.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#formatNationalNumberWithCarrierCode(PhoneNumber, java.lang.String)">formatNationalNumberWithCarrierCode</A></B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;carrierCode)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a phone number in national format for dialing using the carrier as specified in the
<code>carrierCode</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#formatNationalNumberWithPreferredCarrierCode(PhoneNumber, java.lang.String)">formatNationalNumberWithPreferredCarrierCode</A></B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;fallbackCarrierCode)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a phone number in national format for dialing using the carrier as specified in the
preferredDomesticCarrierCode field of the PhoneNumber object passed in.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#formatOutOfCountryCallingNumber(PhoneNumber, java.lang.String)">formatOutOfCountryCallingNumber</A></B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;regionCallingFrom)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a phone number for out-of-country dialing purposes.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#formatOutOfCountryKeepingAlphaChars(PhoneNumber, java.lang.String)">formatOutOfCountryKeepingAlphaChars</A></B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;regionCallingFrom)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a phone number for out-of-country dialing purposes.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/AsYouTypeFormatter.html" title="class in com.google.i18n.phonenumbers">AsYouTypeFormatter</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getAsYouTypeFormatter(java.lang.String)">getAsYouTypeFormatter</A></B>(java.lang.String&nbsp;regionCode)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets an <A HREF="../../../../com/google/i18n/phonenumbers/AsYouTypeFormatter.html" title="class in com.google.i18n.phonenumbers"><CODE>AsYouTypeFormatter</CODE></A> for the specific region.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getCountryCodeForRegion(java.lang.String)">getCountryCodeForRegion</A></B>(java.lang.String&nbsp;regionCode)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the country calling code for a specific region.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;PhoneNumber</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getExampleNumber(java.lang.String)">getExampleNumber</A></B>(java.lang.String&nbsp;regionCode)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets a valid number for the specified region.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;PhoneNumber</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getExampleNumberForType(java.lang.String, com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType)">getExampleNumberForType</A></B>(java.lang.String&nbsp;regionCode,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberType</A>&nbsp;type)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets a valid number for the specified region and number type.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html" title="class in com.google.i18n.phonenumbers">PhoneNumberUtil</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getInstance()">getInstance</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets a <CODE>PhoneNumberUtil</CODE> instance to carry out international phone number formatting,
parsing, or validation.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getLengthOfGeographicalAreaCode(PhoneNumber)">getLengthOfGeographicalAreaCode</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the length of the geographical area code in the <code>nationalNumber_</code> field of the
PhoneNumber object passed in, so that clients could use it to split a national significant
number into geographical area code and subscriber number.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getLengthOfNationalDestinationCode(PhoneNumber)">getLengthOfNationalDestinationCode</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the length of the national destination code (NDC) from the PhoneNumber object passed in,
so that clients could use it to split a national significant number into NDC and subscriber
number.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getNationalSignificantNumber(PhoneNumber)">getNationalSignificantNumber</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the national significant number of the a phone number.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getNddPrefixForRegion(java.lang.String, boolean)">getNddPrefixForRegion</A></B>(java.lang.String&nbsp;regionCode,
boolean&nbsp;stripNonDigits)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the national dialling prefix for a specific region.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberType</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getNumberType(PhoneNumber)">getNumberType</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the type of a phone number.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getRegionCodeForCountryCode(int)">getRegionCodeForCountryCode</A></B>(int&nbsp;countryCallingCode)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the region code that matches the specific country calling code.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getRegionCodeForNumber(PhoneNumber)">getRegionCodeForNumber</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the region where a phone number is from.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.util.Set&lt;java.lang.String&gt;</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#getSupportedRegions()">getSupportedRegions</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Convenience method to enable tests to get a list of what regions the library has metadata for.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isAlphaNumber(java.lang.String)">isAlphaNumber</A></B>(java.lang.String&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks if the number is a valid vanity (alpha) number such as 800 MICROSOFT.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isNANPACountry(java.lang.String)">isNANPACountry</A></B>(java.lang.String&nbsp;regionCode)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks if this is a region under the North American Numbering Plan Administration (NANPA).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.MatchType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.MatchType</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isNumberMatch(PhoneNumber, PhoneNumber)">isNumberMatch</A></B>(PhoneNumber&nbsp;firstNumberIn,
PhoneNumber&nbsp;secondNumberIn)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Takes two phone numbers and compares them for equality.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.MatchType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.MatchType</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isNumberMatch(PhoneNumber, java.lang.String)">isNumberMatch</A></B>(PhoneNumber&nbsp;firstNumber,
java.lang.String&nbsp;secondNumber)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Takes two phone numbers and compares them for equality.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isPossibleNumber(PhoneNumber)">isPossibleNumber</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Convenience wrapper around <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isPossibleNumberWithReason(PhoneNumber)"><CODE>isPossibleNumberWithReason(PhoneNumber)</CODE></A>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isPossibleNumber(java.lang.String, java.lang.String)">isPossibleNumber</A></B>(java.lang.String&nbsp;number,
java.lang.String&nbsp;regionDialingFrom)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Check whether a phone number is a possible number given a number in the form of a string, and
the region where the number could be dialed from.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.ValidationResult.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.ValidationResult</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isPossibleNumberWithReason(PhoneNumber)">isPossibleNumberWithReason</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Check whether a phone number is a possible number.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isValidNumber(PhoneNumber)">isValidNumber</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tests whether a phone number matches a valid pattern.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isValidNumberForRegion(PhoneNumber, java.lang.String)">isValidNumberForRegion</A></B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;regionCode)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tests whether a phone number is valid for a certain region.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#normalizeDigitsOnly(java.lang.String)">normalizeDigitsOnly</A></B>(java.lang.String&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Normalizes a string of characters representing a phone number.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;PhoneNumber</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#parse(java.lang.String, java.lang.String)">parse</A></B>(java.lang.String&nbsp;numberToParse,
java.lang.String&nbsp;defaultRegion)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parses a string and returns it in proto buffer format.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#parse(java.lang.String, java.lang.String, PhoneNumber)">parse</A></B>(java.lang.String&nbsp;numberToParse,
java.lang.String&nbsp;defaultRegion,
PhoneNumber&nbsp;phoneNumber)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;PhoneNumber</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#parseAndKeepRawInput(java.lang.String, java.lang.String)">parseAndKeepRawInput</A></B>(java.lang.String&nbsp;numberToParse,
java.lang.String&nbsp;defaultRegion)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parses a string and returns it in proto buffer format.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#parseAndKeepRawInput(java.lang.String, java.lang.String, PhoneNumber)">parseAndKeepRawInput</A></B>(java.lang.String&nbsp;numberToParse,
java.lang.String&nbsp;defaultRegion,
PhoneNumber&nbsp;phoneNumber)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#truncateTooLongNumber(PhoneNumber)">truncateTooLongNumber</A></B>(PhoneNumber&nbsp;number)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Attempts to extract a valid number from a phone number that is too long to be valid, and resets
the PhoneNumber object passed in to that valid version.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="normalizeDigitsOnly(java.lang.String)"><!-- --></A><H3>
normalizeDigitsOnly</H3>
<PRE>
public static java.lang.String <B>normalizeDigitsOnly</B>(java.lang.String&nbsp;number)</PRE>
<DL>
<DD>Normalizes a string of characters representing a phone number. This converts wide-ascii and
arabic-indic numerals to European numerals, and strips punctuation and alpha characters.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - a string of characters representing a phone number
<DT><B>Returns:</B><DD>the normalized string version of the phone number</DL>
</DD>
</DL>
<HR>
<A NAME="convertAlphaCharactersInNumber(java.lang.String)"><!-- --></A><H3>
convertAlphaCharactersInNumber</H3>
<PRE>
public static java.lang.String <B>convertAlphaCharactersInNumber</B>(java.lang.String&nbsp;number)</PRE>
<DL>
<DD>Converts all alpha characters in a number to their respective digits on a keypad, but retains
existing formatting. This Java implementation of this function also converts wide-ascii digits
to normal ascii digits, and converts Arabic-Indic numerals to European numerals.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getLengthOfGeographicalAreaCode(PhoneNumber)"><!-- --></A><H3>
getLengthOfGeographicalAreaCode</H3>
<PRE>
public int <B>getLengthOfGeographicalAreaCode</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Gets the length of the geographical area code in the <code>nationalNumber_</code> field of the
PhoneNumber object passed in, so that clients could use it to split a national significant
number into geographical area code and subscriber number. It works in such a way that the
resultant subscriber number should be diallable, at least on some devices. An example of how
this could be used:
<pre>
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
PhoneNumber number = phoneUtil.parse("16502530000", "US");
String nationalSignificantNumber = phoneUtil.getNationalSignificantNumber(number);
String areaCode;
String subscriberNumber;
int areaCodeLength = phoneUtil.getLengthOfGeographicalAreaCode(number);
if (areaCodeLength > 0) {
areaCode = nationalSignificantNumber.substring(0, areaCodeLength);
subscriberNumber = nationalSignificantNumber.substring(areaCodeLength);
} else {
areaCode = "";
subscriberNumber = nationalSignificantNumber;
}
</pre>
N.B.: area code is a very ambiguous concept, so the I18N team generally recommends against
using it for most purposes. Read the following carefully before deciding to use this method:
- geographical area codes change over time, and this method honors those changes; therefore,
it doesn't guarantee the stability of the result it produces.
- subscriber numbers may not be diallable from all devices (notably mobile devices, which
typically requires the full national_number to be dialled in most countries).
- most non-geographical numbers have no area codes.
- some geographical numbers have no area codes.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the PhoneNumber object for which clients want to know the length of the area
code.
<DT><B>Returns:</B><DD>the length of area code of the PhoneNumber object passed in.</DL>
</DD>
</DL>
<HR>
<A NAME="getLengthOfNationalDestinationCode(PhoneNumber)"><!-- --></A><H3>
getLengthOfNationalDestinationCode</H3>
<PRE>
public int <B>getLengthOfNationalDestinationCode</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Gets the length of the national destination code (NDC) from the PhoneNumber object passed in,
so that clients could use it to split a national significant number into NDC and subscriber
number. The NDC of a phone number is normally the first group of digit(s) right after the
country calling code when the number is formatted in the international format, if there is a
subscriber number part that follows. An example of how this could be used:
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
PhoneNumber number = phoneUtil.parse("18002530000", "US");
String nationalSignificantNumber = phoneUtil.getNationalSignificantNumber(number);
String nationalDestinationCode;
String subscriberNumber;
int nationalDestinationCodeLength = phoneUtil.getLengthOfNationalDestinationCode(number);
if (nationalDestinationCodeLength > 0) {
nationalDestinationCode = nationalSignificantNumber.substring(0,
nationalDestinationCodeLength);
subscriberNumber = nationalSignificantNumber.substring(nationalDestinationCodeLength);
} else {
nationalDestinationCode = "";
subscriberNumber = nationalSignificantNumber;
}
</pre>
Refer to the unittests to see the difference between this function and
<CODE>getLengthOfGeographicalAreaCode()</CODE>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the PhoneNumber object for which clients want to know the length of the NDC.
<DT><B>Returns:</B><DD>the length of NDC of the PhoneNumber object passed in.</DL>
</DD>
</DL>
<HR>
<A NAME="getSupportedRegions()"><!-- --></A><H3>
getSupportedRegions</H3>
<PRE>
public java.util.Set&lt;java.lang.String&gt; <B>getSupportedRegions</B>()</PRE>
<DL>
<DD>Convenience method to enable tests to get a list of what regions the library has metadata for.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getInstance()"><!-- --></A><H3>
getInstance</H3>
<PRE>
public static <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html" title="class in com.google.i18n.phonenumbers">PhoneNumberUtil</A> <B>getInstance</B>()</PRE>
<DL>
<DD>Gets a <CODE>PhoneNumberUtil</CODE> instance to carry out international phone number formatting,
parsing, or validation. The instance is loaded with phone number metadata for a number of most
commonly used regions.
<p>The <CODE>PhoneNumberUtil</CODE> is implemented as a singleton. Therefore, calling getInstance
multiple times will only result in one instance being created.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a PhoneNumberUtil instance</DL>
</DD>
</DL>
<HR>
<A NAME="format(PhoneNumber, com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat)"><!-- --></A><H3>
format</H3>
<PRE>
public java.lang.String <B>format</B>(PhoneNumber&nbsp;number,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberFormat.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberFormat</A>&nbsp;numberFormat)</PRE>
<DL>
<DD>Formats a phone number in the specified format using default rules. Note that this does not
promise to produce a phone number that the user can dial from where they are - although we do
format in either 'national' or 'international' format depending on what the client asks for, we
do not currently support a more abbreviated format, such as for users in the same "area" who
could potentially dial the number without area code. Note that if the phone number has a
country calling code of 0 or an otherwise invalid country calling code, we cannot work out
which formatting rules to apply so we return the national significant number with no formatting
applied.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number to be formatted<DD><CODE>numberFormat</CODE> - the format the phone number should be formatted into
<DT><B>Returns:</B><DD>the formatted phone number</DL>
</DD>
</DL>
<HR>
<A NAME="format(PhoneNumber, com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat, java.lang.StringBuilder)"><!-- --></A><H3>
format</H3>
<PRE>
public void <B>format</B>(PhoneNumber&nbsp;number,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberFormat.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberFormat</A>&nbsp;numberFormat,
java.lang.StringBuilder&nbsp;formattedNumber)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="formatByPattern(PhoneNumber, com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat, java.util.List)"><!-- --></A><H3>
formatByPattern</H3>
<PRE>
public java.lang.String <B>formatByPattern</B>(PhoneNumber&nbsp;number,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberFormat.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberFormat</A>&nbsp;numberFormat,
java.util.List&lt;NumberFormat&gt;&nbsp;userDefinedFormats)</PRE>
<DL>
<DD>Formats a phone number in the specified format using client-defined formatting rules. Note that
if the phone number has a country calling code of zero or an otherwise invalid country calling
code, we cannot work out things like whether there should be a national prefix applied, or how
to format extensions, so we return the national significant number with no formatting applied.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number to be formatted<DD><CODE>numberFormat</CODE> - the format the phone number should be formatted into<DD><CODE>userDefinedFormats</CODE> - formatting rules specified by clients
<DT><B>Returns:</B><DD>the formatted phone number</DL>
</DD>
</DL>
<HR>
<A NAME="formatNationalNumberWithCarrierCode(PhoneNumber, java.lang.String)"><!-- --></A><H3>
formatNationalNumberWithCarrierCode</H3>
<PRE>
public java.lang.String <B>formatNationalNumberWithCarrierCode</B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;carrierCode)</PRE>
<DL>
<DD>Formats a phone number in national format for dialing using the carrier as specified in the
<code>carrierCode</code>. The <code>carrierCode</code> will always be used regardless of whether the
phone number already has a preferred domestic carrier code stored. If <code>carrierCode</code>
contains an empty string, returns the number in national format without any carrier code.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number to be formatted<DD><CODE>carrierCode</CODE> - the carrier selection code to be used
<DT><B>Returns:</B><DD>the formatted phone number in national format for dialing using the carrier as
specified in the <code>carrierCode</code></DL>
</DD>
</DL>
<HR>
<A NAME="formatNationalNumberWithPreferredCarrierCode(PhoneNumber, java.lang.String)"><!-- --></A><H3>
formatNationalNumberWithPreferredCarrierCode</H3>
<PRE>
public java.lang.String <B>formatNationalNumberWithPreferredCarrierCode</B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;fallbackCarrierCode)</PRE>
<DL>
<DD>Formats a phone number in national format for dialing using the carrier as specified in the
preferredDomesticCarrierCode field of the PhoneNumber object passed in. If that is missing,
use the <code>fallbackCarrierCode</code> passed in instead. If there is no
<code>preferredDomesticCarrierCode</code>, and the <code>fallbackCarrierCode</code> contains an empty
string, return the number in national format without any carrier code.
<p>Use <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#formatNationalNumberWithCarrierCode(PhoneNumber, java.lang.String)"><CODE>formatNationalNumberWithCarrierCode(PhoneNumber, java.lang.String)</CODE></A> instead if the carrier code passed in
should take precedence over the number's <code>preferredDomesticCarrierCode</code> when formatting.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number to be formatted<DD><CODE>fallbackCarrierCode</CODE> - the carrier selection code to be used, if none is found in the
phone number itself
<DT><B>Returns:</B><DD>the formatted phone number in national format for dialing using the number's
<code>preferredDomesticCarrierCode</code>, or the <code>fallbackCarrierCode</code> passed in if
none is found</DL>
</DD>
</DL>
<HR>
<A NAME="formatOutOfCountryCallingNumber(PhoneNumber, java.lang.String)"><!-- --></A><H3>
formatOutOfCountryCallingNumber</H3>
<PRE>
public java.lang.String <B>formatOutOfCountryCallingNumber</B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;regionCallingFrom)</PRE>
<DL>
<DD>Formats a phone number for out-of-country dialing purposes. If no regionCallingFrom is
supplied, we format the number in its INTERNATIONAL format. If the country calling code is the
same as the region where the number is from, then NATIONAL formatting will be applied.
<p>If the number itself has a country calling code of zero or an otherwise invalid country
calling code, then we return the number with no formatting applied.
<p>Note this function takes care of the case for calling inside of NANPA and between Russia and
Kazakhstan (who share the same country calling code). In those cases, no international prefix
is used. For regions which have multiple international prefixes, the number in its
INTERNATIONAL format will be returned instead.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number to be formatted<DD><CODE>regionCallingFrom</CODE> - the ISO 3166-1 two-letter region code that denotes the region
where the call is being placed
<DT><B>Returns:</B><DD>the formatted phone number</DL>
</DD>
</DL>
<HR>
<A NAME="formatInOriginalFormat(PhoneNumber, java.lang.String)"><!-- --></A><H3>
formatInOriginalFormat</H3>
<PRE>
public java.lang.String <B>formatInOriginalFormat</B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;regionCallingFrom)</PRE>
<DL>
<DD>Formats a phone number using the original phone number format that the number is parsed from.
The original format is embedded in the country_code_source field of the PhoneNumber object
passed in. If such information is missing, the number will be formatted into the NATIONAL
format by default.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number that needs to be formatted in its original number format<DD><CODE>regionCallingFrom</CODE> - the region whose IDD needs to be prefixed if the original number
has one
<DT><B>Returns:</B><DD>the formatted phone number in its original number format</DL>
</DD>
</DL>
<HR>
<A NAME="formatOutOfCountryKeepingAlphaChars(PhoneNumber, java.lang.String)"><!-- --></A><H3>
formatOutOfCountryKeepingAlphaChars</H3>
<PRE>
public java.lang.String <B>formatOutOfCountryKeepingAlphaChars</B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;regionCallingFrom)</PRE>
<DL>
<DD>Formats a phone number for out-of-country dialing purposes.
Note that in this version, if the number was entered originally using alpha characters and
this version of the number is stored in raw_input, this representation of the number will be
used rather than the digit representation. Grouping information, as specified by characters
such as "-" and " ", will be retained.
<p><b>Caveats:</b></p>
<ul>
<li> This will not produce good results if the country calling code is both present in the raw
input _and_ is the start of the national number. This is not a problem in the regions
which typically use alpha numbers.
<li> This will also not produce good results if the raw input has any grouping information
within the first three digits of the national number, and if the function needs to strip
preceding digits/words in the raw input before these digits. Normally people group the
first three digits together so this is not a huge problem - and will be fixed if it
proves to be so.
</ul>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number that needs to be formatted<DD><CODE>regionCallingFrom</CODE> - the region where the call is being placed
<DT><B>Returns:</B><DD>the formatted phone number</DL>
</DD>
</DL>
<HR>
<A NAME="getNationalSignificantNumber(PhoneNumber)"><!-- --></A><H3>
getNationalSignificantNumber</H3>
<PRE>
public java.lang.String <B>getNationalSignificantNumber</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Gets the national significant number of the a phone number. Note a national significant number
doesn't contain a national prefix or any formatting.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the PhoneNumber object for which the national significant number is needed
<DT><B>Returns:</B><DD>the national significant number of the PhoneNumber object passed in</DL>
</DD>
</DL>
<HR>
<A NAME="getExampleNumber(java.lang.String)"><!-- --></A><H3>
getExampleNumber</H3>
<PRE>
public PhoneNumber <B>getExampleNumber</B>(java.lang.String&nbsp;regionCode)</PRE>
<DL>
<DD>Gets a valid number for the specified region.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>regionCode</CODE> - the ISO 3166-1 two-letter region code that denotes
the region for which an example number is needed
<DT><B>Returns:</B><DD>a valid fixed-line number for the specified region. Returns null when the metadata
does not contain such information.</DL>
</DD>
</DL>
<HR>
<A NAME="getExampleNumberForType(java.lang.String, com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType)"><!-- --></A><H3>
getExampleNumberForType</H3>
<PRE>
public PhoneNumber <B>getExampleNumberForType</B>(java.lang.String&nbsp;regionCode,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberType</A>&nbsp;type)</PRE>
<DL>
<DD>Gets a valid number for the specified region and number type.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>regionCode</CODE> - the ISO 3166-1 two-letter region code that denotes
the region for which an example number is needed<DD><CODE>type</CODE> - the type of number that is needed
<DT><B>Returns:</B><DD>a valid number for the specified region and type. Returns null when the metadata
does not contain such information.</DL>
</DD>
</DL>
<HR>
<A NAME="getNumberType(PhoneNumber)"><!-- --></A><H3>
getNumberType</H3>
<PRE>
public <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.PhoneNumberType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.PhoneNumberType</A> <B>getNumberType</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Gets the type of a phone number.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number that we want to know the type
<DT><B>Returns:</B><DD>the type of the phone number</DL>
</DD>
</DL>
<HR>
<A NAME="isValidNumber(PhoneNumber)"><!-- --></A><H3>
isValidNumber</H3>
<PRE>
public boolean <B>isValidNumber</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Tests whether a phone number matches a valid pattern. Note this doesn't verify the number
is actually in use, which is impossible to tell by just looking at a number itself.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number that we want to validate
<DT><B>Returns:</B><DD>a boolean that indicates whether the number is of a valid pattern</DL>
</DD>
</DL>
<HR>
<A NAME="isValidNumberForRegion(PhoneNumber, java.lang.String)"><!-- --></A><H3>
isValidNumberForRegion</H3>
<PRE>
public boolean <B>isValidNumberForRegion</B>(PhoneNumber&nbsp;number,
java.lang.String&nbsp;regionCode)</PRE>
<DL>
<DD>Tests whether a phone number is valid for a certain region. Note this doesn't verify the number
is actually in use, which is impossible to tell by just looking at a number itself. If the
country calling code is not the same as the country calling code for the region, this
immediately exits with false. After this, the specific number pattern rules for the region are
examined. This is useful for determining for example whether a particular number is valid for
Canada, rather than just a valid NANPA number.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number that we want to validate<DD><CODE>regionCode</CODE> - the ISO 3166-1 two-letter region code that denotes the region that we want
to validate the phone number for
<DT><B>Returns:</B><DD>a boolean that indicates whether the number is of a valid pattern</DL>
</DD>
</DL>
<HR>
<A NAME="getRegionCodeForNumber(PhoneNumber)"><!-- --></A><H3>
getRegionCodeForNumber</H3>
<PRE>
public java.lang.String <B>getRegionCodeForNumber</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Returns the region where a phone number is from. This could be used for geocoding at the region
level.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the phone number whose origin we want to know
<DT><B>Returns:</B><DD>the region where the phone number is from, or null if no region matches this calling
code</DL>
</DD>
</DL>
<HR>
<A NAME="getRegionCodeForCountryCode(int)"><!-- --></A><H3>
getRegionCodeForCountryCode</H3>
<PRE>
public java.lang.String <B>getRegionCodeForCountryCode</B>(int&nbsp;countryCallingCode)</PRE>
<DL>
<DD>Returns the region code that matches the specific country calling code. In the case of no
region code being found, ZZ will be returned. In the case of multiple regions, the one
designated in the metadata as the "main" region for this calling code will be returned.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getCountryCodeForRegion(java.lang.String)"><!-- --></A><H3>
getCountryCodeForRegion</H3>
<PRE>
public int <B>getCountryCodeForRegion</B>(java.lang.String&nbsp;regionCode)</PRE>
<DL>
<DD>Returns the country calling code for a specific region. For example, this would be 1 for the
United States, and 64 for New Zealand.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>regionCode</CODE> - the ISO 3166-1 two-letter region code that denotes
the region that we want to get the country calling code for
<DT><B>Returns:</B><DD>the country calling code for the region denoted by regionCode</DL>
</DD>
</DL>
<HR>
<A NAME="getNddPrefixForRegion(java.lang.String, boolean)"><!-- --></A><H3>
getNddPrefixForRegion</H3>
<PRE>
public java.lang.String <B>getNddPrefixForRegion</B>(java.lang.String&nbsp;regionCode,
boolean&nbsp;stripNonDigits)</PRE>
<DL>
<DD>Returns the national dialling prefix for a specific region. For example, this would be 1 for
the United States, and 0 for New Zealand. Set stripNonDigits to true to strip symbols like "~"
(which indicates a wait for a dialling tone) from the prefix returned. If no national prefix is
present, we return null.
<p>Warning: Do not use this method for do-your-own formatting - for some regions, the
national dialling prefix is used only for certain types of numbers. Use the library's
formatting functions to prefix the national prefix when required.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>regionCode</CODE> - the ISO 3166-1 two-letter region code that denotes
the region that we want to get the dialling prefix for<DD><CODE>stripNonDigits</CODE> - true to strip non-digits from the national dialling prefix
<DT><B>Returns:</B><DD>the dialling prefix for the region denoted by regionCode</DL>
</DD>
</DL>
<HR>
<A NAME="isNANPACountry(java.lang.String)"><!-- --></A><H3>
isNANPACountry</H3>
<PRE>
public boolean <B>isNANPACountry</B>(java.lang.String&nbsp;regionCode)</PRE>
<DL>
<DD>Checks if this is a region under the North American Numbering Plan Administration (NANPA).
<P>
<DD><DL>
<DT><B>Returns:</B><DD>true if regionCode is one of the regions under NANPA</DL>
</DD>
</DL>
<HR>
<A NAME="isAlphaNumber(java.lang.String)"><!-- --></A><H3>
isAlphaNumber</H3>
<PRE>
public boolean <B>isAlphaNumber</B>(java.lang.String&nbsp;number)</PRE>
<DL>
<DD>Checks if the number is a valid vanity (alpha) number such as 800 MICROSOFT. A valid vanity
number will start with at least 3 digits and will have three or more alpha characters. This
does not do region-specific checks - to work out if this number is actually valid for a region,
it should be parsed and methods such as <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isPossibleNumberWithReason(PhoneNumber)"><CODE>isPossibleNumberWithReason(PhoneNumber)</CODE></A> and
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isValidNumber(PhoneNumber)"><CODE>isValidNumber(PhoneNumber)</CODE></A> should be used.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the number that needs to be checked
<DT><B>Returns:</B><DD>true if the number is a valid vanity number</DL>
</DD>
</DL>
<HR>
<A NAME="isPossibleNumber(PhoneNumber)"><!-- --></A><H3>
isPossibleNumber</H3>
<PRE>
public boolean <B>isPossibleNumber</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Convenience wrapper around <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isPossibleNumberWithReason(PhoneNumber)"><CODE>isPossibleNumberWithReason(PhoneNumber)</CODE></A>. Instead of returning the reason
for failure, this method returns a boolean value.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the number that needs to be checked
<DT><B>Returns:</B><DD>true if the number is possible</DL>
</DD>
</DL>
<HR>
<A NAME="isPossibleNumberWithReason(PhoneNumber)"><!-- --></A><H3>
isPossibleNumberWithReason</H3>
<PRE>
public <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.ValidationResult.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.ValidationResult</A> <B>isPossibleNumberWithReason</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Check whether a phone number is a possible number. It provides a more lenient check than
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isValidNumber(PhoneNumber)"><CODE>isValidNumber(PhoneNumber)</CODE></A> in the following sense:
<ol>
<li> It only checks the length of phone numbers. In particular, it doesn't check starting
digits of the number.
<li> It doesn't attempt to figure out the type of the number, but uses general rules which
applies to all types of phone numbers in a region. Therefore, it is much faster than
isValidNumber.
<li> For fixed line numbers, many regions have the concept of area code, which together with
subscriber number constitute the national significant number. It is sometimes okay to dial
the subscriber number only when dialing in the same area. This function will return
true if the subscriber-number-only version is passed in. On the other hand, because
isValidNumber validates using information on both starting digits (for fixed line
numbers, that would most likely be area codes) and length (obviously includes the
length of area codes for fixed line numbers), it will return false for the
subscriber-number-only version.
</ol
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the number that needs to be checked
<DT><B>Returns:</B><DD>a ValidationResult object which indicates whether the number is possible</DL>
</DD>
</DL>
<HR>
<A NAME="isPossibleNumber(java.lang.String, java.lang.String)"><!-- --></A><H3>
isPossibleNumber</H3>
<PRE>
public boolean <B>isPossibleNumber</B>(java.lang.String&nbsp;number,
java.lang.String&nbsp;regionDialingFrom)</PRE>
<DL>
<DD>Check whether a phone number is a possible number given a number in the form of a string, and
the region where the number could be dialed from. It provides a more lenient check than
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isValidNumber(PhoneNumber)"><CODE>isValidNumber(PhoneNumber)</CODE></A>. See <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isPossibleNumber(PhoneNumber)"><CODE>isPossibleNumber(PhoneNumber)</CODE></A> for details.
<p>This method first parses the number, then invokes <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isPossibleNumber(PhoneNumber)"><CODE>isPossibleNumber(PhoneNumber
number)</CODE></A> with the resultant PhoneNumber object.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - the number that needs to be checked, in the form of a string<DD><CODE>regionDialingFrom</CODE> - the ISO 3166-1 two-letter region code that denotes the region that
we are expecting the number to be dialed from.
Note this is different from the region where the number belongs. For example, the number
+1 650 253 0000 is a number that belongs to US. When written in this form, it can be
dialed from any region. When it is written as 00 1 650 253 0000, it can be dialed from any
region which uses an international dialling prefix of 00. When it is written as
650 253 0000, it can only be dialed from within the US, and when written as 253 0000, it
can only be dialed from within a smaller area in the US (Mountain View, CA, to be more
specific).
<DT><B>Returns:</B><DD>true if the number is possible</DL>
</DD>
</DL>
<HR>
<A NAME="truncateTooLongNumber(PhoneNumber)"><!-- --></A><H3>
truncateTooLongNumber</H3>
<PRE>
public boolean <B>truncateTooLongNumber</B>(PhoneNumber&nbsp;number)</PRE>
<DL>
<DD>Attempts to extract a valid number from a phone number that is too long to be valid, and resets
the PhoneNumber object passed in to that valid version. If no valid number could be extracted,
the PhoneNumber object passed in will not be modified.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>number</CODE> - a PhoneNumber object which contains a number that is too long to be valid.
<DT><B>Returns:</B><DD>true if a valid phone number can be successfully extracted.</DL>
</DD>
</DL>
<HR>
<A NAME="getAsYouTypeFormatter(java.lang.String)"><!-- --></A><H3>
getAsYouTypeFormatter</H3>
<PRE>
public <A HREF="../../../../com/google/i18n/phonenumbers/AsYouTypeFormatter.html" title="class in com.google.i18n.phonenumbers">AsYouTypeFormatter</A> <B>getAsYouTypeFormatter</B>(java.lang.String&nbsp;regionCode)</PRE>
<DL>
<DD>Gets an <A HREF="../../../../com/google/i18n/phonenumbers/AsYouTypeFormatter.html" title="class in com.google.i18n.phonenumbers"><CODE>AsYouTypeFormatter</CODE></A> for the specific region.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>regionCode</CODE> - the ISO 3166-1 two-letter region code that denotes the region where
the phone number is being entered
<DT><B>Returns:</B><DD>an <A HREF="../../../../com/google/i18n/phonenumbers/AsYouTypeFormatter.html" title="class in com.google.i18n.phonenumbers"><CODE>AsYouTypeFormatter</CODE></A> object, which can be used
to format phone numbers in the specific region "as you type"</DL>
</DD>
</DL>
<HR>
<A NAME="parse(java.lang.String, java.lang.String)"><!-- --></A><H3>
parse</H3>
<PRE>
public PhoneNumber <B>parse</B>(java.lang.String&nbsp;numberToParse,
java.lang.String&nbsp;defaultRegion)
throws <A HREF="../../../../com/google/i18n/phonenumbers/NumberParseException.html" title="class in com.google.i18n.phonenumbers">NumberParseException</A></PRE>
<DL>
<DD>Parses a string and returns it in proto buffer format. This method will throw a
<A HREF="../../../../com/google/i18n/phonenumbers/NumberParseException.html" title="class in com.google.i18n.phonenumbers"><CODE>NumberParseException</CODE></A> if the number is not considered to be
a possible number. Note that validation of whether the number is actually a valid number for a
particular region is not performed. This can be done separately with <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#isValidNumber(PhoneNumber)"><CODE>isValidNumber(PhoneNumber)</CODE></A>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>numberToParse</CODE> - number that we are attempting to parse. This can contain formatting
such as +, ( and -, as well as a phone number extension.<DD><CODE>defaultRegion</CODE> - the ISO 3166-1 two-letter region code that denotes the region that we
are expecting the number to be from. This is only used if the number
being parsed is not written in international format.
The country_code for the number in this case would be stored as that
of the default region supplied. If the number is guaranteed to
start with a '+' followed by the country calling code, then "ZZ" or
null can be supplied.
<DT><B>Returns:</B><DD>a phone number proto buffer filled with the parsed number
<DT><B>Throws:</B>
<DD><CODE>NumberParseException</CODE> - if the string is not considered to be a viable phone number or if
no default region was supplied and the number is not in
international format (does not start with +)</DL>
</DD>
</DL>
<HR>
<A NAME="parse(java.lang.String, java.lang.String, PhoneNumber)"><!-- --></A><H3>
parse</H3>
<PRE>
public void <B>parse</B>(java.lang.String&nbsp;numberToParse,
java.lang.String&nbsp;defaultRegion,
PhoneNumber&nbsp;phoneNumber)
throws <A HREF="../../../../com/google/i18n/phonenumbers/NumberParseException.html" title="class in com.google.i18n.phonenumbers">NumberParseException</A></PRE>
<DL>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../../../com/google/i18n/phonenumbers/NumberParseException.html" title="class in com.google.i18n.phonenumbers">NumberParseException</A></CODE></DL>
</DD>
</DL>
<HR>
<A NAME="parseAndKeepRawInput(java.lang.String, java.lang.String)"><!-- --></A><H3>
parseAndKeepRawInput</H3>
<PRE>
public PhoneNumber <B>parseAndKeepRawInput</B>(java.lang.String&nbsp;numberToParse,
java.lang.String&nbsp;defaultRegion)
throws <A HREF="../../../../com/google/i18n/phonenumbers/NumberParseException.html" title="class in com.google.i18n.phonenumbers">NumberParseException</A></PRE>
<DL>
<DD>Parses a string and returns it in proto buffer format. This method differs from <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#parse(java.lang.String, java.lang.String)"><CODE>parse(java.lang.String, java.lang.String)</CODE></A>
in that it always populates the raw_input field of the protocol buffer with numberToParse as
well as the country_code_source field.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>numberToParse</CODE> - number that we are attempting to parse. This can contain formatting
such as +, ( and -, as well as a phone number extension.<DD><CODE>defaultRegion</CODE> - the ISO 3166-1 two-letter region code that denotes the region that
we are expecting the number to be from. This is only used if the
number being parsed is not written in international format. The
country calling code for the number in this case would be stored as
that of the default region supplied.
<DT><B>Returns:</B><DD>a phone number proto buffer filled with the parsed number
<DT><B>Throws:</B>
<DD><CODE>NumberParseException</CODE> - if the string is not considered to be a viable phone number or if
no default region was supplied</DL>
</DD>
</DL>
<HR>
<A NAME="parseAndKeepRawInput(java.lang.String, java.lang.String, PhoneNumber)"><!-- --></A><H3>
parseAndKeepRawInput</H3>
<PRE>
public void <B>parseAndKeepRawInput</B>(java.lang.String&nbsp;numberToParse,
java.lang.String&nbsp;defaultRegion,
PhoneNumber&nbsp;phoneNumber)
throws <A HREF="../../../../com/google/i18n/phonenumbers/NumberParseException.html" title="class in com.google.i18n.phonenumbers">NumberParseException</A></PRE>
<DL>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../../../com/google/i18n/phonenumbers/NumberParseException.html" title="class in com.google.i18n.phonenumbers">NumberParseException</A></CODE></DL>
</DD>
</DL>
<HR>
<A NAME="findNumbers(java.lang.CharSequence, java.lang.String)"><!-- --></A><H3>
findNumbers</H3>
<PRE>
public java.lang.Iterable&lt;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberMatch.html" title="class in com.google.i18n.phonenumbers">PhoneNumberMatch</A>&gt; <B>findNumbers</B>(java.lang.CharSequence&nbsp;text,
java.lang.String&nbsp;defaultRegion)</PRE>
<DL>
<DD>Returns an iterable over all <CODE>PhoneNumberMatches</CODE> in <code>text</code>. This
is a shortcut for <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.html#findNumbers(java.lang.CharSequence, java.lang.String, com.google.i18n.phonenumbers.PhoneNumberUtil.Leniency, long)"><CODE>getMatcher(text, defaultRegion, Leniency.VALID, Long.MAX_VALUE)</CODE></A>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the text to search for phone numbers, null for no text<DD><CODE>defaultRegion</CODE> - the ISO 3166-1 two-letter region code that denotes the region that
we are expecting the number to be from. This is only used if the
number being parsed is not written in international format. The
country calling code for the number in this case would be stored as
that of the default region supplied. May be null if only international
numbers are expected.</DL>
</DD>
</DL>
<HR>
<A NAME="findNumbers(java.lang.CharSequence, java.lang.String, com.google.i18n.phonenumbers.PhoneNumberUtil.Leniency, long)"><!-- --></A><H3>
findNumbers</H3>
<PRE>
public java.lang.Iterable&lt;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberMatch.html" title="class in com.google.i18n.phonenumbers">PhoneNumberMatch</A>&gt; <B>findNumbers</B>(java.lang.CharSequence&nbsp;text,
java.lang.String&nbsp;defaultRegion,
<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.Leniency.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.Leniency</A>&nbsp;leniency,
long&nbsp;maxTries)</PRE>
<DL>
<DD>Returns an iterable over all <CODE>PhoneNumberMatches</CODE> in <code>text</code>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the text to search for phone numbers, null for no text<DD><CODE>defaultRegion</CODE> - the ISO 3166-1 two-letter region code that denotes the region that
we are expecting the number to be from. This is only used if the
number being parsed is not written in international format. The
country calling code for the number in this case would be stored as
that of the default region supplied. May be null if only international
numbers are expected.<DD><CODE>leniency</CODE> - the leniency to use when evaluating candidate phone numbers<DD><CODE>maxTries</CODE> - the maximum number of invalid numbers to try before giving up on the
text. This is to cover degenerate cases where the text has a lot of
false positives in it. Must be <code>&gt;= 0</code>.</DL>
</DD>
</DL>
<HR>
<A NAME="isNumberMatch(PhoneNumber, PhoneNumber)"><!-- --></A><H3>
isNumberMatch</H3>
<PRE>
public <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.MatchType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.MatchType</A> <B>isNumberMatch</B>(PhoneNumber&nbsp;firstNumberIn,
PhoneNumber&nbsp;secondNumberIn)</PRE>
<DL>
<DD>Takes two phone numbers and compares them for equality.
<p>Returns EXACT_MATCH if the country_code, NSN, presence of a leading zero for Italian numbers
and any extension present are the same.
Returns NSN_MATCH if either or both has no region specified, and the NSNs and extensions are
the same.
Returns SHORT_NSN_MATCH if either or both has no region specified, or the region specified is
the same, and one NSN could be a shorter version of the other number. This includes the case
where one has an extension specified, and the other does not.
Returns NO_MATCH otherwise.
For example, the numbers +1 345 657 1234 and 657 1234 are a SHORT_NSN_MATCH.
The numbers +1 345 657 1234 and 345 657 are a NO_MATCH.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>firstNumberIn</CODE> - first number to compare<DD><CODE>secondNumberIn</CODE> - second number to compare
<DT><B>Returns:</B><DD>NO_MATCH, SHORT_NSN_MATCH, NSN_MATCH or EXACT_MATCH depending on the level of equality
of the two numbers, described in the method definition.</DL>
</DD>
</DL>
<HR>
<A NAME="isNumberMatch(PhoneNumber, java.lang.String)"><!-- --></A><H3>
isNumberMatch</H3>
<PRE>
public <A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.MatchType.html" title="enum in com.google.i18n.phonenumbers">PhoneNumberUtil.MatchType</A> <B>isNumberMatch</B>(PhoneNumber&nbsp;firstNumber,
java.lang.String&nbsp;secondNumber)</PRE>
<DL>
<DD>Takes two phone numbers and compares them for equality. This is a convenience wrapper for
isNumberMatch(PhoneNumber firstNumber, PhoneNumber secondNumber). No default region is known.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>firstNumber</CODE> - first number to compare in proto buffer format.<DD><CODE>secondNumber</CODE> - second number to compare. Can contain formatting, and can have country
calling code specified with + at the start.
<DT><B>Returns:</B><DD>NOT_A_NUMBER, NO_MATCH, SHORT_NSN_MATCH, NSN_MATCH, EXACT_MATCH. See
isNumberMatch(PhoneNumber firstNumber, PhoneNumber secondNumber) for more details.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../com/google/i18n/phonenumbers/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberMatch.html" title="class in com.google.i18n.phonenumbers"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/google/i18n/phonenumbers/PhoneNumberUtil.Leniency.html" title="enum in com.google.i18n.phonenumbers"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?com/google/i18n/phonenumbers/PhoneNumberUtil.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="PhoneNumberUtil.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>