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    /**
022     * This class, which implements the {@link BarcodeStrategy} interface,
023     * knows how to encode the
024     * 2:1 (narrow) variant of the Codabar barcode type.
025     */
026    public class Codabar_2to1 extends Codabar implements java.io.Serializable {
027    
028      private static CharacterCode[] codes = {
029        new CharacterCode('0', new byte[] {1,1,1,1,1,2,2,1}, 0),
030        new CharacterCode('1', new byte[] {1,1,1,1,2,2,1,1}, 1),
031        new CharacterCode('2', new byte[] {1,1,1,2,1,1,2,1}, 2),
032        new CharacterCode('3', new byte[] {2,2,1,1,1,1,1,1}, 3),
033        new CharacterCode('4', new byte[] {1,1,2,1,1,2,1,1}, 4),
034        new CharacterCode('5', new byte[] {2,1,1,1,1,2,1,1}, 5),
035        new CharacterCode('6', new byte[] {1,2,1,1,1,1,2,1}, 6),
036        new CharacterCode('7', new byte[] {1,2,1,1,2,1,1,1}, 7),
037        new CharacterCode('8', new byte[] {1,2,2,1,1,1,1,1}, 8),
038        new CharacterCode('9', new byte[] {2,1,1,2,1,1,1,1}, 9),
039        new CharacterCode('-', new byte[] {1,1,1,2,2,1,1,1}, 10),
040        new CharacterCode('$', new byte[] {1,1,2,2,1,1,1,1}, 11),
041        new CharacterCode(':', new byte[] {2,1,1,1,2,1,2,1}, 12),
042        new CharacterCode('/', new byte[] {2,1,2,1,1,1,2,1}, 13),
043        new CharacterCode('.', new byte[] {2,1,2,1,2,1,1,1}, 14),
044        new CharacterCode('+', new byte[] {1,1,2,1,2,1,2,1}, 15),
045        new CharacterCode('A', new byte[] {1,1,2,2,1,2,1,1}, 16),   // Start
046        new CharacterCode('B', new byte[] {1,2,1,2,1,1,2,1}, 17)    // Stop
047      };
048    
049      /**
050       * This implementation of <tt>getCodes</tt> returns an array of
051       * {@link AbstractBarcodeStrategy.CharacterCode CharacterCode} objects
052       * for the narrow Codabar format.
053       */
054      protected CharacterCode[] getCodes() {
055        return codes;
056      }
057    }