Skip to content

Commit 1eea8ec

Browse files
Add parsingOptions to OpenSource
I have added the new parsing methode ParsingOptions to the OpenSource version.
1 parent 6e8efa7 commit 1eea8ec

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

java/libphonenumber/src/com/google/i18n/phonenumbers/ParsingOptions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public class ParsingOptions {
3030
public boolean hasDefaultRegion() { return hasDefaultRegion; }
3131
public String getDefaultRegion() { return defaultRegion_; }
3232
public ParsingOptions setDefaultRegion(String value) {
33-
hasDefaultRegion = (value != null);
33+
if (value == null) {
34+
throw new NullPointerException();
35+
}
36+
hasDefaultRegion = true;
3437
defaultRegion_ = value;
3538
return this;
3639
}

java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,6 +3257,18 @@ public void parseWithOptions(CharSequence numberToParse, ParsingOptions options,
32573257
parseHelper(numberToParse, options.getDefaultRegion(), options.isKeepRawInput(), true, phoneNumber);
32583258
}
32593259

3260+
public PhoneNumber parseWithOptions(CharSequence numberToParse, ParsingOptions options)
3261+
throws NumberParseException {
3262+
PhoneNumber phoneNumber = new PhoneNumber();
3263+
parseHelper(numberToParse, options.getDefaultRegion(), options.hasKeepRawInput(), options.hasDefaultRegion(), phoneNumber);
3264+
return phoneNumber;
3265+
}
3266+
3267+
public void parseWithOptions(CharSequence numberToParse, ParsingOptions options, PhoneNumber phoneNumber)
3268+
throws NumberParseException {
3269+
parseHelper(numberToParse, options.getDefaultRegion(), options.hasKeepRawInput(), options.hasDefaultRegion(), phoneNumber);
3270+
}
3271+
32603272
/**
32613273
* Returns an iterable over all {@link PhoneNumberMatch PhoneNumberMatches} in {@code text}. This
32623274
* is a shortcut for {@link #findNumbers(CharSequence, String, Leniency, long)

0 commit comments

Comments
 (0)