1 package net.sourceforge.barbecue.linear.ean;
2
3 import net.sourceforge.barbecue.BarcodeException;
4
5 public class BooklandBarcode extends EAN13Barcode {
6
7 public BooklandBarcode(String isbn) throws BarcodeException {
8 super(processIsbn(isbn));
9 }
10
11 private static String processIsbn(String isbn) throws BarcodeException {
12
13 if (isbn.indexOf('-') > -1) {
14 StringBuffer sb = new StringBuffer();
15
16 for (int i = 0; i < isbn.length(); i++) {
17 if (isbn.charAt(i) != '-') {
18 sb.append(isbn.charAt(i));
19 }
20 }
21 isbn = sb.toString();
22 }
23
24
25 if (isbn.length() != EAN13Barcode.ISBN_SIZE) {
26 throw new BarcodeException("ISBN is an invalid length");
27 }
28
29
30
31 return EAN13Barcode.ISBN_NUMBER_SYSTEM + isbn.substring(0, isbn.length() - 1);
32 }
33 }