/** * format isbn10 or 13 with separator signs. * * @param pstring string to format * @return formated string */ public static String isbnFormat(final String pstring) { if (pstring == null) { return null; } final int length = isbnCompress(pstring).length(); if (length > Isbn10Validator.ISBN10_LENGTH) { return isbn13Format(pstring); } else { return isbn10Format(pstring); } }
/** * format isbn10 or 13 with separator signs. * * @param pstring string to format * @return formated string */ public static String isbnFormat(final String pstring) { if (pstring == null) { return null; } final int length = isbnCompress(pstring).length(); if (length > Isbn10Validator.ISBN10_LENGTH) { return isbn13Format(pstring); } else { return isbn10Format(pstring); } }
/** * format isbn10 or 13 with separator signs. * * @param pentry string to format and cursor position * @return formated string with new cursor position */ public static ValueWithPos<String> isbnFormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } final int length = isbnCompress(pentry.getValue()).length(); if (length > Isbn10Validator.ISBN10_LENGTH) { return isbn13FormatWithPos(pentry); } else { return isbn10FormatWithPos(pentry); } }
/** * format isbn10 or 13 with separator signs. * * @param pentry string to format and cursor position * @return formated string with new cursor position */ public static ValueWithPos<String> isbnFormatWithPos(final ValueWithPos<String> pentry) { if (pentry == null) { return null; } final int length = isbnCompress(pentry.getValue()).length(); if (length > Isbn10Validator.ISBN10_LENGTH) { return isbn13FormatWithPos(pentry); } else { return isbn10FormatWithPos(pentry); } }
/** * test compressing isbn. */ @Test public void testIbanCompress() { Assert.assertNull("isbn compress should be null", IsbnUtil.isbnCompress(null)); for (final Entry<String, String> entry : IsbnUtilTestCases.getCompressCases().entrySet()) { Assert.assertEquals("isbn compress failed", entry.getKey(), IsbnUtil.isbnCompress(entry.getValue())); } } }
/** * test compressing isbn. */ @Test public void testIbanCompress() { Assert.assertNull("isbn compress should be null", IsbnUtil.isbnCompress(null)); for (final Entry<String, String> entry : IsbnUtilTestCases.getCompressCases().entrySet()) { Assert.assertEquals("isbn compress failed", entry.getKey(), IsbnUtil.isbnCompress(entry.getValue())); } } }