001 /** 002 * This library is free software; you can redistribute it and/or modify it 003 * under the terms of the GNU Lesser General Public License (LGPL) as 004 * published by the Free Software Foundation; either version 3.0 of the 005 * License, or (at your option) any later version. 006 * 007 * This library is distributed in the hope that it will be useful, but 008 * WITHOUT ANY WARRANTY; without even the implied warranty of 009 * MERCHANTABILITY of FITNESS FOR A PARTICULAR PURPOSE. See the GNU 010 * Lesser General Public License for more details. 011 */ 012 013 /** 014 * Title: JBarcodeBean 015 * Description: Barcode JavaBeans Component 016 * Copyright: Copyright (C) 2004 017 * Company: Dafydd Walters 018 */ 019 package net.sourceforge.jbarcodebean.model; 020 021 import net.sourceforge.jbarcodebean.BarcodeException; 022 import net.sourceforge.jbarcodebean.EncodedBarcode; 023 024 /** 025 * Interface which defines the barcode strategy for any 026 * given type of barcode. Classes that implement this interface exist for each 027 * of the barcode types such as Code39, Interleaved25, etc. 028 */ 029 public interface BarcodeStrategy { 030 031 /** 032 * When returned by {@link #requiresChecksum}, indicates that this type of 033 * barcode does not support a checksum. 034 */ 035 public static final int NO_CHECKSUM = 0; 036 037 /** 038 * When returned by {@link #requiresChecksum}, indicates that this type of 039 * barcode always has a checksum. 040 */ 041 public static final int MANDATORY_CHECKSUM = 1; 042 043 /** 044 * When returned by {@link #requiresChecksum}, indicates that this type of 045 * barcode may have an optional checksum. 046 */ 047 public static final int OPTIONAL_CHECKSUM = 2; 048 049 /** 050 * Subclasses implement this method to encode some text into a barcode. 051 * 052 * @param text The raw text to encode. 053 * @param checked <tt>true</tt> if a checksum is to be calculated, <tt>false</tt> if not. 054 * 055 * @return The fully encoded barcode, represented as bars and spaces, wrapped 056 * in a {@link EncodedBarcode} object. 057 * 058 * @throws BarcodeException Typically caused by passing in 059 * a String containing illegal characters (characters that cannot be encoded in 060 * this type of barcode). 061 */ 062 public EncodedBarcode encode(String text, boolean checked) throws BarcodeException; 063 064 /** 065 * Subclasses implement this method to determine whether this type of barcode 066 * has a mandatory, optional or no checksum. Returns one of the constants 067 * defined in the interface. 068 */ 069 public int requiresChecksum(); 070 }