Browse Source

Add parsingOptions to OpenSource

I have added the new parsing methode ParsingOptions to the OpenSource version.
pull/3730/head
karoljk 1 year ago
parent
commit
809f889145
2 changed files with 16 additions and 1 deletions
  1. +4
    -1
      java/libphonenumber/src/com/google/i18n/phonenumbers/ParsingOptions.java
  2. +12
    -0
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java

+ 4
- 1
java/libphonenumber/src/com/google/i18n/phonenumbers/ParsingOptions.java View File

@ -30,7 +30,10 @@ public class ParsingOptions {
public boolean hasDefaultRegion() { return hasDefaultRegion; }
public String getDefaultRegion() { return defaultRegion_; }
public ParsingOptions setDefaultRegion(String value) {
hasDefaultRegion = (value != null);
if (value == null) {
throw new NullPointerException();
}
hasDefaultRegion = true;
defaultRegion_ = value;
return this;
}


+ 12
- 0
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -3249,6 +3249,18 @@ public class PhoneNumberUtil {
parseHelper(numberToParse, options.getDefaultRegion(), options.isKeepRawInput(), true, phoneNumber);
}
public PhoneNumber parseWithOptions(CharSequence numberToParse, ParsingOptions options)
throws NumberParseException {
PhoneNumber phoneNumber = new PhoneNumber();
parseHelper(numberToParse, options.getDefaultRegion(), options.hasKeepRawInput(), options.hasDefaultRegion(), phoneNumber);
return phoneNumber;
}
public void parseWithOptions(CharSequence numberToParse, ParsingOptions options, PhoneNumber phoneNumber)
throws NumberParseException {
parseHelper(numberToParse, options.getDefaultRegion(), options.hasKeepRawInput(), options.hasDefaultRegion(), phoneNumber);
}
/**
* Returns an iterable over all {@link PhoneNumberMatch PhoneNumberMatches} in {@code text}. This
* is a shortcut for {@link #findNumbers(CharSequence, String, Leniency, long)


Loading…
Cancel
Save