From d9d2ef0cbb83b638cab19d0d16e44ae98cbfa053 Mon Sep 17 00:00:00 2001 From: KarolJakubKrawiec Date: Thu, 6 Feb 2025 09:34:05 +0100 Subject: [PATCH] Solved mistakes for ParseWithOptions Added java doc comments and deleted unnecessary functions --- cpp/src/phonenumbers/parsingoptions.cc | 14 ++++++++++ cpp/src/phonenumbers/parsingoptions.h | 20 +++++++++++-- .../i18n/phonenumbers/ParsingOptions.java | 28 ++++++++++++------- 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/cpp/src/phonenumbers/parsingoptions.cc b/cpp/src/phonenumbers/parsingoptions.cc index e65e97281..655d4c20b 100644 --- a/cpp/src/phonenumbers/parsingoptions.cc +++ b/cpp/src/phonenumbers/parsingoptions.cc @@ -1,3 +1,17 @@ +// Copyright (C) 2009 The Libphonenumber Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + #include "phonenumbers/parsingoptions.h" namespace i18n { diff --git a/cpp/src/phonenumbers/parsingoptions.h b/cpp/src/phonenumbers/parsingoptions.h index dca142fa5..0682f109b 100644 --- a/cpp/src/phonenumbers/parsingoptions.h +++ b/cpp/src/phonenumbers/parsingoptions.h @@ -1,3 +1,17 @@ +// Copyright (C) 2009 The Libphonenumber Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + #ifndef I18N_PHONENUMBERS_PARSINGOPTIONS_H_ #define I18N_PHONENUMBERS_PARSINGOPTIONS_H_ @@ -9,7 +23,7 @@ namespace phonenumbers { // Options for parsing a phone number. To be used with the ParseWithOptions // method. // Example: -// ParsingOptions().SetDefaultRegion(RegionCode::US()).SetKeepRawInput(true); +// ParsingOptions().SetDefaultRegion("US").SetKeepRawInput(true); class ParsingOptions { public: ParsingOptions() : default_region_("ZZ"), keep_raw_input_(false) {}; @@ -28,7 +42,7 @@ class ParsingOptions { // number being parsed is written in international format. In case of national // format, the country_code will be set to the one of this default region. If // the number is guaranteed to start with a '+' followed by the country - // calling code, then RegionCode.ZZ or null can be supplied. + // calling code, then "ZZ" or null can be supplied. std::string default_region_; // Whether the raw input should be kept in the PhoneNumber object. If true, @@ -39,4 +53,4 @@ class ParsingOptions { } // namespace phonenumbers } // namespace i18n -#endif // I1 \ No newline at end of file +#endif // I18N_PHONENUMBERS_PARSINGOPTIONS_H_ \ No newline at end of file diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/ParsingOptions.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/ParsingOptions.java index af3eb1aef..106cd4906 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/ParsingOptions.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/ParsingOptions.java @@ -19,16 +19,22 @@ package com.google.i18n.phonenumbers; /** Options for the phone number parser. */ public class ParsingOptions { + private boolean hasDefaultRegion; /** - * Returns the region we are expecting the number to be from. This is ignored if the number being + * The region we are expecting the number to be from. This is ignored if the number being * parsed is written in international format. In case of national format, the country_code will be * set to the one of this default region. If the number is guaranteed to start with a '+' followed * by the country calling code, then RegionCode.ZZ or null can be supplied. */ - private boolean hasDefaultRegion; private String defaultRegion_ = null; public boolean hasDefaultRegion() { return hasDefaultRegion; } + /** + * Returns the value of {@link #defaultRegion_}. + */ public String getDefaultRegion() { return defaultRegion_; } + /** + * Sets the {@link #defaultRegion_} to the given value. + */ public ParsingOptions setDefaultRegion(String value) { hasDefaultRegion = (value != null); defaultRegion_ = value; @@ -36,23 +42,25 @@ public class ParsingOptions { } /** - * Returns whether the raw input should be kept in the PhoneNumber object. If true, the raw_input + * Whether the raw input should be kept in the PhoneNumber object. If true, the raw_input * field and country_code_source fields will be populated. */ private boolean hasKeepRawInput; private boolean keepRawInput_ = false; + /** + * Returns the value of {@link #hasKeepRawInput}. + */ public boolean hasKeepRawInput() { return hasKeepRawInput; } + /** + * Returns the value of {@link #keepRawInput_}. + */ public boolean isKeepRawInput() { return keepRawInput_; } + /** + * Decides with the given value if it should keep the raw input. + */ public ParsingOptions setKeepRawInput(boolean value) { - if(value == false) { - - } hasKeepRawInput = true; keepRawInput_ = value; return this; } - - public ParsingOptions withDefaultRegion(String regionCode) { - return setDefaultRegion(regionCode); - } } \ No newline at end of file