@Test public void testIsbn10FormatWithPos() { Assert.assertNull("isbn format should be null", IsbnUtil.isbn10FormatWithPos(null)); for (final Entry<ValueWithPos<String>, ValueWithPos<String>> entry : IsbnUtilTestCases .getIsbn10FormatWithPosCases().entrySet()) { Assert.assertEquals("isbn format failed", entry.getKey(), IsbnUtil.isbn10FormatWithPos(entry.getValue())); } }
public static ValueWithPos<String> isbn10FormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(Isbn10FormatedValidator.ISBN10_LENGTH); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiNumeric(charCode)) { if (pos == 1 || pos == 3 || pos == 9) { 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; }
IsbnUtil { public static ValueWithPos<String> isbn10FormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(Isbn10FormatedValidator.ISBN10_LENGTH); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiNumeric(charCode)) { if (pos == 1 || pos == 3 || pos == 9) { 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; } }
IsbnUtil { public static ValueWithPos<String> isbn10FormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(Isbn10FormatedValidator.ISBN10_LENGTH); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiNumeric(charCode)) { if (pos == 1 || pos == 3 || pos == 9) { 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; }  }
IsbnUtil { public static ValueWithPos<String> isbn10FormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(Isbn10FormatedValidator.ISBN10_LENGTH); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiNumeric(charCode)) { if (pos == 1 || pos == 3 || pos == 9) { 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> isbnFormatWithPos(final ValueWithPos<String> pentry); static String isbnFormat(final String pstring); static ValueWithPos<String> isbn10FormatWithPos(final ValueWithPos<String> pentry); static String isbn10Format(final String pstring); static ValueWithPos<String> isbn13FormatWithPos(final ValueWithPos<String> pentry); static String isbn13Format(final String pstring); static String isbnCompress(final String pstring); }
IsbnUtil { public static ValueWithPos<String> isbn10FormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } if (StringUtils.isNotEmpty(pentry.getValue())) { final StringBuilder ibanSb = new StringBuilder(Isbn10FormatedValidator.ISBN10_LENGTH); int pos = 0; int posformated = 0; for (final char charCode : pentry.getValue().toCharArray()) { if (CharUtils.isAsciiNumeric(charCode)) { if (pos == 1 || pos == 3 || pos == 9) { 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> isbnFormatWithPos(final ValueWithPos<String> pentry); static String isbnFormat(final String pstring); static ValueWithPos<String> isbn10FormatWithPos(final ValueWithPos<String> pentry); static String isbn10Format(final String pstring); static ValueWithPos<String> isbn13FormatWithPos(final ValueWithPos<String> pentry); static String isbn13Format(final String pstring); static String isbnCompress(final String pstring); static final char SEPARATOR; }