/** * 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); } }
@Override public String formatValueSynchron(final String pvalue) { return IsbnUtil.isbnFormat(pvalue); }
@Override public void formatValue(final ValueWithPos<String> pvalue, final boolean fireEvents) { setTextWithPos(IsbnUtil.isbn13FormatWithPos(pvalue), fireEvents); }
@Override public void formatValue(final ValueWithPos<String> pvalue) { setTextWithPos(IsbnUtil.isbn10FormatWithPos(pvalue)); }
@Override public String formatValueSynchron(final String pvalue) { return IsbnUtil.isbn13Format(pvalue); }
@Override public String formatValueSynchron(final String pvalue) { return IsbnUtil.isbn10Format(pvalue); }
@Override public void formatValue(final ValueWithPos<String> pvalue, final boolean fireEvents) { setTextWithPos(IsbnUtil.isbnFormatWithPos(pvalue), fireEvents); }
/** * 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())); } } }
@Override public void formatValue(final ValueWithPos<String> pvalue) { setTextWithPos(IsbnUtil.isbn13FormatWithPos(pvalue)); }
@Override public void formatValue(final ValueWithPos<String> pvalue, final boolean fireEvents) { setTextWithPos(IsbnUtil.isbn10FormatWithPos(pvalue), fireEvents); }
/** * test formating isbn13. */ @Test public void testIsbn13Format() { Assert.assertNull("isbn format should be null", IsbnUtil.isbn13Format(null)); for (final Entry<String, String> entry : IsbnUtilTestCases.getIsbn13FormatCases().entrySet()) { Assert.assertEquals("isbn format failed", entry.getKey(), IsbnUtil.isbn13Format(entry.getValue())); } }
/** * test formating isbn10. */ @Test public void testIsbn10Format() { Assert.assertNull("isbn format should be null", IsbnUtil.isbn10Format(null)); for (final Entry<String, String> entry : IsbnUtilTestCases.getIsbn10FormatCases().entrySet()) { Assert.assertEquals("isbn format failed", entry.getKey(), IsbnUtil.isbn10Format(entry.getValue())); } }
@Override public void formatValue(final ValueWithPos<String> pvalue) { setTextWithPos(IsbnUtil.isbnFormatWithPos(pvalue)); }
/** * 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())); } } }
/** * 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 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 isbn13 with separator signs. * * @param pstring string to format * @return formated string */ public static String isbn13Format(final String pstring) { if (pstring == null) { return null; } final ValueWithPos<String> formatedValue = isbn13FormatWithPos(new ValueWithPos<>(pstring, -1)); return formatedValue.getValue(); }
/** * format isbn10 with separator signs. * * @param pstring string to format * @return formated string */ public static String isbn10Format(final String pstring) { if (pstring == null) { return null; } final ValueWithPos<String> formatedValue = isbn10FormatWithPos(new ValueWithPos<>(pstring, -1)); return formatedValue.getValue(); }
/** * test formating isbn13. */ @Test public void testIsbn13Format() { Assert.assertNull("isbn format should be null", IsbnUtil.isbn13Format(null)); for (final Entry<String, String> entry : IsbnUtilTestCases.getIsbn13FormatCases().entrySet()) { Assert.assertEquals("isbn format failed", entry.getKey(), IsbnUtil.isbn13Format(entry.getValue())); } }