<?xml version="1.0" ?>
-<project name="libphonenumber" default="compile">
+<project name="libphonenumber" default="compile">
<property name="src.dir" value="src"/>
<property name="test.dir" value="test"/>
<property name="build.dir" value="build"/>
<exclude name="**/*Test*"/>
</fileset>
<fileset dir="${resources.dir}">
- <include name="**/PhoneNumberMetadataProto"/>
+ <include name="**/PhoneNumberMetadataProto"/>
<include name="**/PhoneNumberMetadataProtoForTesting"/>
</fileset>
</jar>
<mkdir dir="${report.dir}"/>
<junit printsummary="yes">
<classpath refid="test.classpath"/>
- <formatter type="xml"/>
+ <formatter type="xml"/>
<batchtest fork="no" todir="${report.dir}">
<fileset dir="${test.dir}" includes="**/*Test.java"/>
</batchtest>
* ./BuildMetadataProtoFromXml PhoneNumberMetadata.xml PhoneNumberMetadataProto true
*
* When liteBuild flag is set to true, the outputFile generated omits certain metadata which is not
- * needed for clients using liteBuild. At this moment, example numbers information is omitted.
+ * needed for clients using liteBuild. At this moment, example numbers information is omitted.
*
* @author Shaopeng Jia
*/
public class BuildMetadataProtoFromXml {
- private BuildMetadataProtoFromXml() {
+ private BuildMetadataProtoFromXml() {
}
private static final Logger LOGGER = Logger.getLogger(BuildMetadataProtoFromXml.class.getName());
private static Boolean liteBuild;
public static void main(String[] args) {
String inputFile = args[0];
String outputFile = args[1];
- liteBuild = args.length > 2 && Boolean.getBoolean(args[2]);
+ liteBuild = args.length > 2 && Boolean.getBoolean(args[2]);
File xmlFile = new File(inputFile);
try {
FileOutputStream output = new FileOutputStream(outputFile);
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.google.protobuf.MessageLite;
-
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
// The set of countries that share country code 262.
private final Set<String> frenchIndianOceanTerritories = new HashSet<String>(6);
-
+
private static final int FRENCH_INDIAN_OCEAN_COUNTRY_CODE = 262;
// The PLUS_SIGN signifies the international prefix.
// version. There are two regular expressions here: the more generic one starts with optional
// white space and ends with an optional full stop (.), followed by zero or more spaces/tabs and
// then the numbers themselves. The other one covers the special case of American numbers where
- // the extension is written with a hash at the end, such as "- 503#".
+ // the extension is written with a hash at the end, such as "- 503#".
// Note that the only capturing groups should be around the digits that you want to capture as
// part of the extension, or else parsing will fail!
private static final String KNOWN_EXTN_PATTERNS = "[ \\u00A0\\t,]*(?:ext(?:ensio)?n?|" +
private void init(InputStream source) {
// Read in metadata for each country.
- try {
+ try {
PhoneMetadataCollection metadataCollection = PhoneMetadataCollection.parseFrom(source);
for (PhoneMetadata metadata : metadataCollection.getMetadataList()) {
String regionCode = metadata.getId();
* isValidNumber. See isPossibleNumber(PhoneNumber number) for details.
*
* This method first parses the number, then invokes isPossibleNumber(PhoneNumber number) with the
- * resultant PhoneNumber object.
+ * resultant PhoneNumber object.
*
* @param number the number that needs to be checked, in the form of a string
* @param countryDialingFrom the ISO 3166-1 two-letter country code that denotes
/**
* As no equals method is implemented for MessageLite, we implement our own equals method here
* to compare the serialized data.
- */
+ */
@VisibleForTesting
static Boolean areSameMessages(MessageLite message1, MessageLite message2) {
if (message1 == null && message2 == null) {
phoneNumber.setNationalNumber(Long.parseLong(normalizedNationalNumber.toString()));
return phoneNumber.build();
}
-
+
/**
* Takes two phone numbers and compares them for equality.
*
PhoneNumber number3 =
PhoneNumber.newBuilder().setCountryCode(44).setNationalNumber(2070313000L).build();
assertTrue(phoneUtil.isPossibleNumber(number3));
-
assertTrue(phoneUtil.isPossibleNumber("+1 650 253 0000", "US"));
assertTrue(phoneUtil.isPossibleNumber("+1 650 GOO OGLE", "US"));
assertTrue(phoneUtil.isPossibleNumber("(650) 253-0000", "US"));
assertTrue(phoneUtil.isPossibleNumber("3331 6005", "NZ"));
}
-
public void testIsPossibleNumberWithReason() {
// FYI, national numbers for country code +1 that are within 7 to 10 digits are possible.
PhoneNumber number1 =
assertEquals(usNumber, phoneUtil.parse("0~01-650-333-6000", "PL"));
// Check it doesn't use the '1' as a country code when parsing if the phone number was already
// possible.
-
PhoneNumber usNumber2 =
PhoneNumber.newBuilder().setCountryCode(1).setNationalNumber(1234567890L).build();
assertEquals(usNumber2, phoneUtil.parse("123-456-7890", "US"));