// @VisibleForTesting static void SetRelevantDescPatterns(PhoneMetadata.Builder metadata, XElement element, bool isShortNumberMetadata) { var generalDescBuilder = ProcessPhoneNumberDescElement(null, element, GENERAL_DESC); // Calculate the possible lengths for the general description. This will be based on the // possible lengths of the child elements. SetPossibleLengthsGeneralDesc( generalDescBuilder, metadata.Id, element, isShortNumberMetadata); metadata.SetGeneralDesc(generalDescBuilder); var generalDesc = metadata.GeneralDesc; if (!isShortNumberMetadata) { // Set fields used by regular length phone numbers. metadata.SetFixedLine(ProcessPhoneNumberDescElement(generalDesc, element, FIXED_LINE)); metadata.SetMobile(ProcessPhoneNumberDescElement(generalDesc, element, MOBILE)); metadata.SetSharedCost(ProcessPhoneNumberDescElement(generalDesc, element, SHARED_COST)); metadata.SetVoip(ProcessPhoneNumberDescElement(generalDesc, element, VOIP)); metadata.SetPersonalNumber(ProcessPhoneNumberDescElement(generalDesc, element, PERSONAL_NUMBER)); metadata.SetPager(ProcessPhoneNumberDescElement(generalDesc, element, PAGER)); metadata.SetUan(ProcessPhoneNumberDescElement(generalDesc, element, UAN)); metadata.SetVoicemail(ProcessPhoneNumberDescElement(generalDesc, element, VOICEMAIL)); metadata.SetNoInternationalDialling(ProcessPhoneNumberDescElement(generalDesc, element, NO_INTERNATIONAL_DIALLING)); var mobileAndFixedAreSame = metadata.Mobile.NationalNumberPattern .Equals(metadata.FixedLine.NationalNumberPattern); if (metadata.SameMobileAndFixedLinePattern != mobileAndFixedAreSame) { // Set this if it is not the same as the default. metadata.SetSameMobileAndFixedLinePattern(mobileAndFixedAreSame); } metadata.SetTollFree(ProcessPhoneNumberDescElement(generalDesc, element, TOLL_FREE)); metadata.SetPremiumRate(ProcessPhoneNumberDescElement(generalDesc, element, PREMIUM_RATE)); } else { // Set fields used by short numbers. metadata.SetStandardRate(ProcessPhoneNumberDescElement(generalDesc, element, STANDARD_RATE)); metadata.SetShortCode(ProcessPhoneNumberDescElement(generalDesc, element, SHORT_CODE)); metadata.SetCarrierSpecific(ProcessPhoneNumberDescElement(generalDesc, element, CARRIER_SPECIFIC)); metadata.SetEmergency(ProcessPhoneNumberDescElement(generalDesc, element, EMERGENCY)); metadata.SetTollFree(ProcessPhoneNumberDescElement(generalDesc, element, TOLL_FREE)); metadata.SetPremiumRate(ProcessPhoneNumberDescElement(generalDesc, element, PREMIUM_RATE)); metadata.SetSmsServices(ProcessPhoneNumberDescElement(generalDesc, element, SMS_SERVICES)); } }
// @VisibleForTesting public static void LoadGeneralDesc(PhoneMetadata.Builder metadata, XElement element) { var generalDescBuilder = ProcessPhoneNumberDescElement(null, element, GENERAL_DESC); SetPossibleLengthsGeneralDesc(generalDescBuilder, metadata.Id, element, false); var generalDesc = generalDescBuilder.Build(); metadata.SetFixedLine(ProcessPhoneNumberDescElement(generalDesc, element, FIXED_LINE)); metadata.SetMobile(ProcessPhoneNumberDescElement(generalDesc, element, MOBILE)); metadata.SetTollFree(ProcessPhoneNumberDescElement(generalDesc, element, TOLL_FREE)); metadata.SetPremiumRate(ProcessPhoneNumberDescElement(generalDesc, element, PREMIUM_RATE)); metadata.SetSharedCost(ProcessPhoneNumberDescElement(generalDesc, element, SHARED_COST)); metadata.SetVoip(ProcessPhoneNumberDescElement(generalDesc, element, VOIP)); metadata.SetPersonalNumber(ProcessPhoneNumberDescElement(generalDesc, element, PERSONAL_NUMBER)); metadata.SetPager(ProcessPhoneNumberDescElement(generalDesc, element, PAGER)); metadata.SetUan(ProcessPhoneNumberDescElement(generalDesc, element, UAN)); metadata.SetVoicemail(ProcessPhoneNumberDescElement(generalDesc, element, VOICEMAIL)); metadata.SetEmergency(ProcessPhoneNumberDescElement(generalDesc, element, EMERGENCY)); metadata.SetNoInternationalDialling(ProcessPhoneNumberDescElement(generalDesc, element, NO_INTERNATIONAL_DIALLING)); metadata.SetSameMobileAndFixedLinePattern( metadata.Mobile.NationalNumberPattern.Equals( metadata.FixedLine.NationalNumberPattern)); }
// @VisibleForTesting public static void LoadGeneralDesc(PhoneMetadata.Builder metadata, XElement element, bool liteBuild) { var generalDesc = ProcessPhoneNumberDescElement(null, element, GENERAL_DESC, liteBuild); metadata.SetGeneralDesc(generalDesc); metadata.SetFixedLine(ProcessPhoneNumberDescElement(generalDesc, element, FIXED_LINE, liteBuild)); metadata.SetMobile(ProcessPhoneNumberDescElement(generalDesc, element, MOBILE, liteBuild)); metadata.SetTollFree(ProcessPhoneNumberDescElement(generalDesc, element, TOLL_FREE, liteBuild)); metadata.SetPremiumRate(ProcessPhoneNumberDescElement(generalDesc, element, PREMIUM_RATE, liteBuild)); metadata.SetSharedCost(ProcessPhoneNumberDescElement(generalDesc, element, SHARED_COST, liteBuild)); metadata.SetVoip(ProcessPhoneNumberDescElement(generalDesc, element, VOIP, liteBuild)); metadata.SetPersonalNumber(ProcessPhoneNumberDescElement(generalDesc, element, PERSONAL_NUMBER, liteBuild)); metadata.SetPager(ProcessPhoneNumberDescElement(generalDesc, element, PAGER, liteBuild)); metadata.SetUan(ProcessPhoneNumberDescElement(generalDesc, element, UAN, liteBuild)); metadata.SetVoicemail(ProcessPhoneNumberDescElement(generalDesc, element, VOICEMAIL, liteBuild)); metadata.SetEmergency(ProcessPhoneNumberDescElement(generalDesc, element, EMERGENCY, liteBuild)); metadata.SetNoInternationalDialling(ProcessPhoneNumberDescElement(generalDesc, element, NO_INTERNATIONAL_DIALLING, liteBuild)); metadata.SetSameMobileAndFixedLinePattern( metadata.Mobile.NationalNumberPattern.Equals( metadata.FixedLine.NationalNumberPattern)); }