@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())); } }
public static ValueWithPos<String> ibanFormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(pentry.getValue().length()); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiAlphaUpper(charCode) || CharUtils.isAsciiNumeric(charCode)) { if (pos > 0 && pos % BLOCK_LENGTH == 0) { ibanSb.append(SEPARATOR); if (posformated <= pentry.getPos()) { pentry.setPos(pentry.getPos() + 1); } posformated++; } ibanSb.append(charCode); pos++; posformated++; } else { if (posformated < pentry.getPos()) { pentry.setPos(pentry.getPos() - 1); } } } pentry.setValue(ibanSb.toString()); if (pentry.getPos() < 0) { pentry.setPos(0); } else if (pentry.getPos() >= ibanSb.length()) { pentry.setPos(ibanSb.length()); } } return pentry; }
IbanUtil { public static ValueWithPos<String> ibanFormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(pentry.getValue().length()); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiAlphaUpper(charCode) || CharUtils.isAsciiNumeric(charCode)) { if (pos > 0 && pos % BLOCK_LENGTH == 0) { ibanSb.append(SEPARATOR); if (posformated <= pentry.getPos()) { pentry.setPos(pentry.getPos() + 1); } posformated++; } ibanSb.append(charCode); pos++; posformated++; } else { if (posformated < pentry.getPos()) { pentry.setPos(pentry.getPos() - 1); } } } pentry.setValue(ibanSb.toString()); if (pentry.getPos() < 0) { pentry.setPos(0); } else if (pentry.getPos() >= ibanSb.length()) { pentry.setPos(ibanSb.length()); } } return pentry; } }
IbanUtil { public static ValueWithPos<String> ibanFormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(pentry.getValue().length()); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiAlphaUpper(charCode) || CharUtils.isAsciiNumeric(charCode)) { if (pos > 0 && pos % BLOCK_LENGTH == 0) { ibanSb.append(SEPARATOR); if (posformated <= pentry.getPos()) { pentry.setPos(pentry.getPos() + 1); } posformated++; } ibanSb.append(charCode); pos++; posformated++; } else { if (posformated < pentry.getPos()) { pentry.setPos(pentry.getPos() - 1); } } } pentry.setValue(ibanSb.toString()); if (pentry.getPos() < 0) { pentry.setPos(0); } else if (pentry.getPos() >= ibanSb.length()) { pentry.setPos(ibanSb.length()); } } return pentry; }  }
IbanUtil { public static ValueWithPos<String> ibanFormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(pentry.getValue().length()); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiAlphaUpper(charCode) || CharUtils.isAsciiNumeric(charCode)) { if (pos > 0 && pos % BLOCK_LENGTH == 0) { ibanSb.append(SEPARATOR); if (posformated <= pentry.getPos()) { pentry.setPos(pentry.getPos() + 1); } posformated++; } ibanSb.append(charCode); pos++; posformated++; } else { if (posformated < pentry.getPos()) { pentry.setPos(pentry.getPos() - 1); } } } pentry.setValue(ibanSb.toString()); if (pentry.getPos() < 0) { pentry.setPos(0); } else if (pentry.getPos() >= ibanSb.length()) { pentry.setPos(ibanSb.length()); } } return pentry; }  static ValueWithPos<String> ibanFormatWithPos(final ValueWithPos<String> pentry); static String ibanFormat(final String pstring); static String ibanCompress(final String pstring); static String getBankNumberOfIban(final String pstring); static String getAccountNumberOfIban(final String pstring); static String getBicOfIban(final String pstring); }
IbanUtil { public static ValueWithPos<String> ibanFormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(pentry.getValue().length()); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiAlphaUpper(charCode) || CharUtils.isAsciiNumeric(charCode)) { if (pos > 0 && pos % BLOCK_LENGTH == 0) { ibanSb.append(SEPARATOR); if (posformated <= pentry.getPos()) { pentry.setPos(pentry.getPos() + 1); } posformated++; } ibanSb.append(charCode); pos++; posformated++; } else { if (posformated < pentry.getPos()) { pentry.setPos(pentry.getPos() - 1); } } } pentry.setValue(ibanSb.toString()); if (pentry.getPos() < 0) { pentry.setPos(0); } else if (pentry.getPos() >= ibanSb.length()) { pentry.setPos(ibanSb.length()); } } return pentry; }  static ValueWithPos<String> ibanFormatWithPos(final ValueWithPos<String> pentry); static String ibanFormat(final String pstring); static String ibanCompress(final String pstring); static String getBankNumberOfIban(final String pstring); static String getAccountNumberOfIban(final String pstring); static String getBicOfIban(final String pstring); static final char SEPARATOR; }