Browse Source

Minor documentation update.

pull/567/head
Shaopeng Jia 16 years ago
committed by Mihaela Rosca
parent
commit
302f7bf6db
5 changed files with 12 additions and 16 deletions
  1. +3
    -3
      java/build.xml
  2. +0
    -0
      java/lib/protobuf-lite.jar
  3. +3
    -3
      java/src/com/google/i18n/phonenumbers/BuildMetadataProtoFromXml.java
  4. +6
    -7
      java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  5. +0
    -3
      java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java

+ 3
- 3
java/build.xml View File

@ -1,6 +1,6 @@
<?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"/>
@ -49,7 +49,7 @@
<exclude name="**/*Test*"/>
</fileset>
<fileset dir="${resources.dir}">
<include name="**/PhoneNumberMetadataProto"/>
<include name="**/PhoneNumberMetadataProto"/>
<include name="**/PhoneNumberMetadataProtoForTesting"/>
</fileset>
</jar>
@ -59,7 +59,7 @@
<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>


java/lib/protobuf-java-2.3.0-lite.jar → java/lib/protobuf-lite.jar View File


+ 3
- 3
java/src/com/google/i18n/phonenumbers/BuildMetadataProtoFromXml.java View File

@ -43,12 +43,12 @@ import javax.xml.parsers.ParserConfigurationException;
* ./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;
@ -56,7 +56,7 @@ public class BuildMetadataProtoFromXml {
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);


+ 6
- 7
java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -25,7 +25,6 @@ import com.google.i18n.phonenumbers.Phonemetadata.PhoneNumberDesc;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.google.protobuf.MessageLite;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
@ -74,7 +73,7 @@ public class PhoneNumberUtil {
// 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.
@ -223,7 +222,7 @@ public class PhoneNumberUtil {
// 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?|" +
@ -319,7 +318,7 @@ public class PhoneNumberUtil {
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();
@ -1167,7 +1166,7 @@ public class PhoneNumberUtil {
* 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
@ -1463,7 +1462,7 @@ public class PhoneNumberUtil {
/**
* 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) {
@ -1560,7 +1559,7 @@ public class PhoneNumberUtil {
phoneNumber.setNationalNumber(Long.parseLong(normalizedNationalNumber.toString()));
return phoneNumber.build();
}
/**
* Takes two phone numbers and compares them for equality.
*


+ 0
- 3
java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java View File

@ -761,7 +761,6 @@ public class PhoneNumberUtilTest extends TestCase {
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"));
@ -773,7 +772,6 @@ public class PhoneNumberUtilTest extends TestCase {
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 =
@ -1072,7 +1070,6 @@ public class PhoneNumberUtilTest extends TestCase {
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"));


Loading…
Cancel
Save