@GET @Path(PhoneNumber.FORMAT_DIN5008_INTERNATIONAL) public String formatDin5008International(@QueryParam(Parameters.LANGUAGE) final String planguage, @QueryParam(Parameters.COUNTRY) final String pcountry, @QueryParam(Parameters.PHONE_NUMBER) final String pphoneNumber) { return phoneNumberUtil.formatDin5008International(pphoneNumber, pcountry); }
/** * format phone number in DIN 5008 international format. * * @param pphoneNumber phone number to format * @param pcountryCode iso code of country * @return formated phone number as String */ public final String formatDin5008International(final String pphoneNumber, final String pcountryCode) { return this.formatDin5008International(this.parsePhoneNumber(pphoneNumber, pcountryCode)); }
@RequestMapping(value = PhoneNumber.FORMAT_DIN5008_INTERNATIONAL, method = RequestMethod.GET) @PermitAll public String formatDin5008International( @RequestParam(value = Parameters.LANGUAGE, required = true) final String planguage, @RequestParam(value = Parameters.COUNTRY, required = true) final String pcountry, @RequestParam(value = Parameters.PHONE_NUMBER, required = true) final String pphoneNumber) { return phoneNumberUtil.formatDin5008International(pphoneNumber, pcountry); }
@RequestMapping(value = PhoneNumber.FORMAT_DIN5008_INTERNATIONAL, method = RequestMethod.GET) @PermitAll public String formatDin5008International( @RequestParam(value = Parameters.LANGUAGE, required = true) final String planguage, @RequestParam(value = Parameters.COUNTRY, required = true) final String pcountry, @RequestParam(value = Parameters.PHONE_NUMBER, required = true) final String pphoneNumber) { return phoneNumberUtil.formatDin5008International(pphoneNumber, pcountry); }
/** * format phone number in DIN 5008 international format. * * @param pphoneNumber phone number as String to format * @return formated phone number as String */ public final String formatDin5008International(final String pphoneNumber) { return this.formatDin5008International(this.parsePhoneNumber(pphoneNumber)); }
/** * format phone number in DIN 5008 international format. * * @param pphoneNumber phone number as String to format * @return formated phone number as String */ public final String formatDin5008International(final String pphoneNumber) { return this.formatDin5008International(this.parsePhoneNumber(pphoneNumber)); }
/** * format phone number in DIN 5008 international format. * * @param pphoneNumber phone number to format * @param pcountryCode iso code of country * @return formated phone number as String */ public final String formatDin5008International(final String pphoneNumber, final String pcountryCode) { return this.formatDin5008International(this.parsePhoneNumber(pphoneNumber, pcountryCode)); }
@Override public String formatValueSynchron(final String pvalue) { final String formatedNumber = phoneNumberUtil.formatDin5008International(pvalue, StringUtils.upperCase(Objects.toString(countryCodeField.getValue(), null))); if (StringUtils.startsWith(pvalue, formatedNumber)) { return pvalue; } return StringUtils.defaultString(formatedNumber, pvalue); }
/** * format phone number in DIN 5008 format. * * @param pphoneNumberData phone number to format * @param pcountryData country data * @return formated phone number as String */ public final String formatDin5008(final PhoneNumberInterface pphoneNumberData, final PhoneCountryData pcountryData) { if (pphoneNumberData != null && StringUtils.equals( pcountryData.getCountryCodeData().getCountryCode(), pphoneNumberData.getCountryCode())) { return this.formatDin5008National(pphoneNumberData); } else { return this.formatDin5008International(pphoneNumberData); } }
/** * format phone number in DIN 5008 format. * * @param pphoneNumberData phone number to format * @param pcountryData country data * @return formated phone number as String */ public final String formatDin5008(final PhoneNumberInterface pphoneNumberData, final PhoneCountryData pcountryData) { if (pphoneNumberData != null && StringUtils.equals( pcountryData.getCountryCodeData().getCountryCode(), pphoneNumberData.getCountryCode())) { return this.formatDin5008National(pphoneNumberData); } else { return this.formatDin5008International(pphoneNumberData); } }
return this.formatDin5008International(pphoneNumberData);
/** * test formating phone number in DIN 5008 international format. */ @Test public void testFormatDin5008International() { Assert.assertNull("Should be null", this.phoneNumberUtil.formatDin5008International((PhoneNumberData) null)); for (final Entry<PhoneNumberInterface, String> testCase : PhoneNumberUtilTestCases .getFormatDin5008InternationalCases().entrySet()) { final String formatedNumber = this.phoneNumberUtil.formatDin5008International(testCase.getKey()); Assert.assertEquals("Formating DIN 5008 international " + testCase.getKey().toString(), testCase.getValue(), formatedNumber); } }
return this.formatDin5008International(pphoneNumberData);
&& (StringUtils.equals(pphoneNumber, phoneNumberUtil.formatDin5008National(parsedNumber)) || StringUtils.equals(pphoneNumber, phoneNumberUtil.formatDin5008International(parsedNumber)))) { return Boolean.TRUE;
/** * test formating phone number in DIN 5008 international format. */ @Test public void testFormatDin5008International() { Assert.assertNull("Should be null", this.phoneNumberUtil.formatDin5008International((PhoneNumberData) null)); for (final Entry<PhoneNumberInterface, String> testCase : PhoneNumberUtilTestCases .getFormatDin5008InternationalCases().entrySet()) { final String formatedNumber = this.phoneNumberUtil.formatDin5008International(testCase.getKey()); Assert.assertEquals("Formating DIN 5008 international " + testCase.getKey().toString(), testCase.getValue(), formatedNumber); } }
/** * test formating phone number in DIN 5008 international format with cursor position. */ @Test public void testFormatDin5008InternationalWithPos() { Assert.assertNull("Should be null", this.phoneNumberUtil.formatDin5008International((ValueWithPos<String>) null)); for (final Entry<ValueWithPos<String>, ValueWithPos<String>> testCase : PhoneNumberUtilTestCases .getFormatDin5008InternPosCases().entrySet()) { final ValueWithPos<String> formatedNumber = this.phoneNumberUtil.formatDin5008International(testCase.getKey()); Assert.assertEquals("Formating DIN 5008 international " + testCase.getKey().toString(), testCase.getValue(), formatedNumber); } }
/** * test formating phone number in DIN 5008 international format with cursor position. */ @Test public void testFormatDin5008InternationalWithPos() { Assert.assertNull("Should be null", this.phoneNumberUtil.formatDin5008International((ValueWithPos<String>) null)); for (final Entry<ValueWithPos<String>, ValueWithPos<String>> testCase : PhoneNumberUtilTestCases .getFormatDin5008InternPosCases().entrySet()) { final ValueWithPos<String> formatedNumber = this.phoneNumberUtil.formatDin5008International(testCase.getKey()); Assert.assertEquals("Formating DIN 5008 international " + testCase.getKey().toString(), testCase.getValue(), formatedNumber); } }
/** * parse and reformat the phone number in all available formats. * * @param planguage language to use * @param pcountry default country * @param pphoneNumber phone number to format * @return PhoneNumberDataWithFormats */ @GET @Path(PhoneNumber.PARSE_AND_FORMAT) public PhoneNumberDataWithFormats parseAndFormatPhoneNumber( @QueryParam(Parameters.LANGUAGE) final String planguage, @QueryParam(Parameters.COUNTRY) final String pcountry, @QueryParam(Parameters.PHONE_NUMBER) final String pphoneNumber) { final PhoneNumberDataWithFormats result = new PhoneNumberDataWithFormats(phoneNumberUtil .parsePhoneNumber(pphoneNumber, pcountry, LocaleUtil.convertLanguageToLocale(planguage))); result.setCommonInternational(phoneNumberUtil.formatCommonInternational(result)); result.setCommonNational(phoneNumberUtil.formatCommonNational(result)); result.setDin5008International(phoneNumberUtil.formatDin5008International(result)); result.setDin5008National(phoneNumberUtil.formatDin5008National(result)); result.setE123International(phoneNumberUtil.formatE123International(result)); result.setE123National(phoneNumberUtil.formatE123National(result)); result.setMs(phoneNumberUtil.formatMs(result)); result.setUrl(phoneNumberUtil.formatUrl(result)); return result; }
/** * parse and reformat the phone number in all available formats. * * @param planguage language to use * @param pcountry default country * @param pphoneNumber phone number to format * @return PhoneNumberDataWithFormats */ @RequestMapping(value = PhoneNumber.PARSE_AND_FORMAT, method = RequestMethod.GET) @PermitAll public PhoneNumberDataWithFormats parseAndFormatPhoneNumber( @RequestParam(value = Parameters.LANGUAGE, required = true) final String planguage, @RequestParam(value = Parameters.COUNTRY, required = true) final String pcountry, @RequestParam(value = Parameters.PHONE_NUMBER, required = true) final String pphoneNumber) { final PhoneNumberDataWithFormats result = new PhoneNumberDataWithFormats(phoneNumberUtil .parsePhoneNumber(pphoneNumber, pcountry, LocaleUtil.convertLanguageToLocale(planguage))); result.setCommonInternational(phoneNumberUtil.formatCommonInternational(result)); result.setCommonNational(phoneNumberUtil.formatCommonNational(result)); result.setDin5008International(phoneNumberUtil.formatDin5008International(result)); result.setDin5008National(phoneNumberUtil.formatDin5008National(result)); result.setE123International(phoneNumberUtil.formatE123International(result)); result.setE123National(phoneNumberUtil.formatE123National(result)); result.setMs(phoneNumberUtil.formatMs(result)); result.setUrl(phoneNumberUtil.formatUrl(result)); return result; }
/** * parse and reformat the phone number in all available formats. * * @param planguage language to use * @param pcountry default country * @param pphoneNumber phone number to format * @return PhoneNumberDataWithFormats */ @RequestMapping(value = PhoneNumber.PARSE_AND_FORMAT, method = RequestMethod.GET) @PermitAll public PhoneNumberDataWithFormats parseAndFormatPhoneNumber( @RequestParam(value = Parameters.LANGUAGE, required = true) final String planguage, @RequestParam(value = Parameters.COUNTRY, required = true) final String pcountry, @RequestParam(value = Parameters.PHONE_NUMBER, required = true) final String pphoneNumber) { final PhoneNumberDataWithFormats result = new PhoneNumberDataWithFormats(phoneNumberUtil .parsePhoneNumber(pphoneNumber, pcountry, LocaleUtil.convertLanguageToLocale(planguage))); result.setCommonInternational(phoneNumberUtil.formatCommonInternational(result)); result.setCommonNational(phoneNumberUtil.formatCommonNational(result)); result.setDin5008International(phoneNumberUtil.formatDin5008International(result)); result.setDin5008National(phoneNumberUtil.formatDin5008National(result)); result.setE123International(phoneNumberUtil.formatE123International(result)); result.setE123National(phoneNumberUtil.formatE123National(result)); result.setMs(phoneNumberUtil.formatMs(result)); result.setUrl(phoneNumberUtil.formatUrl(result)); return result; }