@Override public void formatValue(final ValueWithPos<String> pvalue, final boolean fireEvents) { setTextWithPos(IbanUtil.ibanFormatWithPos(pvalue), fireEvents); }
/** * get account number of iban. * * @param pstring string with iban * @return account number */ public static String getAccountNumberOfIban(final String pstring) { final String compressedIban = ibanCompress(pstring); final String country = StringUtils.substring(compressedIban, 0, 2); final IbanLengthDefinition length = IBAN_LENGTH_MAP.ibanLengths().get(country); return length == null ? null : StringUtils.substring(compressedIban, length.getAccountNumberStart(), length.getAccountNumberEnd()); }
@Override public String formatValueSynchron(final String pvalue) { return IbanUtil.ibanFormat(pvalue); }
@Override protected void setTextWithPos(final ValueWithPos<String> formatedEntry, final boolean fireEvents) { super.setTextWithPos(formatedEntry, fireEvents); if (bicInput != null && StringUtils.isEmpty(bicInput.getValue())) { final String bic = IbanUtil.getBicOfIban(formatedEntry.getValue()); if (StringUtils.isNotEmpty(bic)) { bicInput.setValue(bic); } } }
/** * test formating iban. */ @Test public void testIbanFormat() { Assert.assertNull("iban format should be null", IbanUtil.ibanFormatWithPos(null)); for (final Entry<String, String> entry : IbanUtilTestCases.getFormatCases().entrySet()) { Assert.assertEquals("iban format failed", entry.getKey(), IbanUtil.ibanFormat(entry.getValue())); } }
/** * get bic of iban. * * @param pstring string with iban * @return bic */ public static String getBicOfIban(final String pstring) { final String country = StringUtils.substring(pstring, 0, 2); final String bankNumber = getBankNumberOfIban(pstring); return BANK_ACCOINT_BIC_MAP.bankAccounts().get(new CountryBankAccountData(country, bankNumber)); } }
@Override protected void setTextWithPos(final ValueWithPos<String> formatedEntry) { super.setTextWithPos(formatedEntry); if (bicInput != null && StringUtils.isEmpty(bicInput.getValue())) { final String bic = IbanUtil.getBicOfIban(formatedEntry.getValue()); if (StringUtils.isNotEmpty(bic)) { bicInput.setValue(bic); } } }
/** * test formating iban. */ @Test public void testIbanFormat() { Assert.assertNull("iban format should be null", IbanUtil.ibanFormatWithPos(null)); for (final Entry<String, String> entry : IbanUtilTestCases.getFormatCases().entrySet()) { Assert.assertEquals("iban format failed", entry.getKey(), IbanUtil.ibanFormat(entry.getValue())); } }
/** * get bic of iban. * * @param pstring string with iban * @return bic */ public static String getBicOfIban(final String pstring) { final String country = StringUtils.substring(pstring, 0, 2); final String bankNumber = getBankNumberOfIban(pstring); return BANK_ACCOINT_BIC_MAP.bankAccounts().get(new CountryBankAccountData(country, bankNumber)); } }
/** * test iban to bic transformation. */ @Test public void testIbanToBic() { Assert.assertNull("iban to bic should be null", IbanUtil.getBicOfIban(null)); for (final Entry<String, String> entry : IbanUtilTestCases.getIbanToBic().entrySet()) { Assert.assertEquals("iban to bic failed", entry.getValue(), IbanUtil.getBicOfIban(entry.getKey())); } } }
@Override public void formatValue(final ValueWithPos<String> pvalue) { setTextWithPos(IbanUtil.ibanFormatWithPos(pvalue)); }
/** * get bank number of iban. * * @param pstring string with iban * @return bank number */ public static String getBankNumberOfIban(final String pstring) { final String compressedIban = ibanCompress(pstring); final String country = StringUtils.substring(compressedIban, 0, 2); final IbanLengthDefinition length = IBAN_LENGTH_MAP.ibanLengths().get(country); return length == null ? null : StringUtils.substring(compressedIban, length.getBankNumberStart(), length.getBankNumberEnd()); }
/** * test iban to bic transformation. */ @Test public void testIbanToBic() { Assert.assertNull("iban to bic should be null", IbanUtil.getBicOfIban(null)); for (final Entry<String, String> entry : IbanUtilTestCases.getIbanToBic().entrySet()) { Assert.assertEquals("iban to bic failed", entry.getValue(), IbanUtil.getBicOfIban(entry.getKey())); } } }
/** * format iban to four character blocks. * * @param pstring string to format * @return formated string */ public static String ibanFormat(final String pstring) { if (pstring == null) { return null; } final ValueWithPos<String> formatedValue = ibanFormatWithPos(new ValueWithPos<>(pstring, -1)); return formatedValue.getValue(); }
/** * get account number of iban. * * @param pstring string with iban * @return account number */ public static String getAccountNumberOfIban(final String pstring) { final String compressedIban = ibanCompress(pstring); final String country = StringUtils.substring(compressedIban, 0, 2); final IbanLengthDefinition length = IBAN_LENGTH_MAP.ibanLengths().get(country); return length == null ? null : StringUtils.substring(compressedIban, length.getAccountNumberStart(), length.getAccountNumberEnd()); }
final String valueBic = BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, this.fieldBic); final String bicOfIban = IbanUtil.getBicOfIban(valueIban);
/** * format iban to four character blocks. * * @param pstring string to format * @return formated string */ public static String ibanFormat(final String pstring) { if (pstring == null) { return null; } final ValueWithPos<String> formatedValue = ibanFormatWithPos(new ValueWithPos<>(pstring, -1)); return formatedValue.getValue(); }
/** * get bank number of iban. * * @param pstring string with iban * @return bank number */ public static String getBankNumberOfIban(final String pstring) { final String compressedIban = ibanCompress(pstring); final String country = StringUtils.substring(compressedIban, 0, 2); final IbanLengthDefinition length = IBAN_LENGTH_MAP.ibanLengths().get(country); return length == null ? null : StringUtils.substring(compressedIban, length.getBankNumberStart(), length.getBankNumberEnd()); }
final String valueBic = BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, this.fieldBic); final String bicOfIban = IbanUtil.getBicOfIban(valueIban);
/** * test formating iban with position. */ @Test public void testIbanFormatWithPos() { Assert.assertNull("iban format should be null", IbanUtil.ibanFormatWithPos(null)); for (final Entry<ValueWithPos<String>, ValueWithPos<String>> entry : IbanUtilTestCases .getFormatWithPosCases().entrySet()) { Assert.assertEquals("iban format failed", entry.getKey(), IbanUtil.ibanFormatWithPos(entry.getValue())); } }