Browse Source

Make canBeInternationallyDialled API public in Java and CPP (#1739)

* Make canBeInternationallyDialled_API public in Java and CPP
* update notes in pending_code_changes.txt
* Remove TODO on canBeInternationallyDialled as it is already an public API in JS
* Make JS canBeInternationallyDialled API doc consistent with Java and CPP
pull/999/merge
penmetsaa 9 years ago
committed by GitHub
parent
commit
f9e9424769
7 changed files with 23 additions and 23 deletions
  1. +7
    -6
      cpp/src/phonenumbers/phonenumberutil.h
  2. +5
    -9
      cpp/test/phonenumbers/phonenumberutil_test.cc
  3. +3
    -4
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  4. +3
    -3
      javascript/i18n/phonenumbers/phonenumberutil.js
  5. +5
    -1
      pending_code_changes.txt
  6. BIN
      tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar
  7. BIN
      tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar

+ 7
- 6
cpp/src/phonenumbers/phonenumberutil.h View File

@ -579,6 +579,13 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
const string& number,
const string& region_dialing_from) const;
// Returns true if the number can be dialled from outside the region, or
// unknown. If the number can only be dialled from within the region, returns
// false. Does not check the number is a valid number. Note that, at the
// moment, this method does not handle short numbers (which are currently all
// presumed to not be diallable from outside their country).
bool CanBeInternationallyDialled(const PhoneNumber& number) const;
// Tests whether a phone number has a geographical association. It checks if
// the number is associated to a certain region in the country where it
// belongs to. Note that this doesn't verify if the number is actually in use.
@ -940,12 +947,6 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
bool IsShorterThanPossibleNormalNumber(const PhoneMetadata* country_metadata,
const string& number) const;
// Returns true if the number can be dialled from outside the region, or
// unknown. If the number can only be dialled from within the region, returns
// false. Does not check the number is a valid number. Note that, at the
// moment, this method does not handle short numbers.
bool CanBeInternationallyDialled(const PhoneNumber& number) const;
DISALLOW_COPY_AND_ASSIGN(PhoneNumberUtil);
};


+ 5
- 9
cpp/test/phonenumbers/phonenumberutil_test.cc View File

@ -67,10 +67,6 @@ class PhoneNumberUtilTest : public testing::Test {
phone_util_.ExtractPossibleNumber(number, extracted_number);
}
bool CanBeInternationallyDialled(const PhoneNumber& number) const {
return phone_util_.CanBeInternationallyDialled(number);
}
bool IsViablePhoneNumber(const string& number) const {
return phone_util_.IsViablePhoneNumber(number);
}
@ -4443,24 +4439,24 @@ TEST_F(PhoneNumberUtilTest, CanBeInternationallyDialled) {
// We have no-international-dialling rules for the US in our test metadata
// that say that toll-free numbers cannot be dialled internationally.
test_number.set_national_number(8002530000ULL);
EXPECT_FALSE(CanBeInternationallyDialled(test_number));
EXPECT_FALSE(phone_util_.CanBeInternationallyDialled(test_number));
// Normal US numbers can be internationally dialled.
test_number.set_national_number(6502530000ULL);
EXPECT_TRUE(CanBeInternationallyDialled(test_number));
EXPECT_TRUE(phone_util_.CanBeInternationallyDialled(test_number));
// Invalid number.
test_number.set_national_number(2530000ULL);
EXPECT_TRUE(CanBeInternationallyDialled(test_number));
EXPECT_TRUE(phone_util_.CanBeInternationallyDialled(test_number));
// We have no data for NZ - should return true.
test_number.set_country_code(64);
test_number.set_national_number(33316005ULL);
EXPECT_TRUE(CanBeInternationallyDialled(test_number));
EXPECT_TRUE(phone_util_.CanBeInternationallyDialled(test_number));
test_number.set_country_code(800);
test_number.set_national_number(12345678ULL);
EXPECT_TRUE(CanBeInternationallyDialled(test_number));
EXPECT_TRUE(phone_util_.CanBeInternationallyDialled(test_number));
}
TEST_F(PhoneNumberUtilTest, IsAlphaNumber) {


+ 3
- 4
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -3491,14 +3491,13 @@ public class PhoneNumberUtil {
/**
* Returns true if the number can be dialled from outside the region, or unknown. If the number
* can only be dialled from within the region, returns false. Does not check the number is a valid
* number. Note that, at the moment, this method does not handle short numbers.
* TODO: Make this method public when we have enough metadata to make it worthwhile.
* number. Note that, at the moment, this method does not handle short numbers (which are
* currently all presumed to not be diallable from outside their country).
*
* @param number the phone-number for which we want to know whether it is diallable from
* outside the region
*/
// @VisibleForTesting
boolean canBeInternationallyDialled(PhoneNumber number) {
public boolean canBeInternationallyDialled(PhoneNumber number) {
PhoneMetadata metadata = getMetadataForRegion(getRegionCodeForNumber(number));
if (metadata == null) {
// Note numbers belonging to non-geographical entities (e.g. +800 numbers) are always


+ 3
- 3
javascript/i18n/phonenumbers/phonenumberutil.js View File

@ -4530,9 +4530,9 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.isNationalNumberSuffixOfTheOther_ =
/**
* Returns true if the number can be dialled from outside the region, or
* unknown. If the number can only be dialled from within the region, returns
* false. Does not check the number is a valid number.
* TODO: Make this method public when we have enough metadata to make it
* worthwhile. Currently visible for testing purposes only.
* false. Does not check the number is a valid number. Note that, at the
* moment, this method does not handle short numbers (which are currently
* all presumed to not be diallable from outside their country).
*
* @param {i18n.phonenumbers.PhoneNumber} number the phone-number for which we
* want to know whether it is diallable from outside the region.


+ 5
- 1
pending_code_changes.txt View File

@ -1 +1,5 @@
Code changes:
- PhoneNumberUtil.canBeInternationallyDialled() API is made public (in
Java and CPP) now as it is useful for clients if they want to make
sure they only allow internationally-accessible numbers for a
particular use-case. In JS this API is already public.

BIN
tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar View File


BIN
tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar View File


Loading…
Cancel
Save