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: Matthias Hanisch 018 */ 019 package net.sourceforge.jbarcodebean.model; 020 021 import net.sourceforge.jbarcodebean.BarcodeException; 022 023 public class Code93Extended extends Code93 { 024 025 static class MappedCode{ 026 char character; 027 String encoded; 028 MappedCode(char character, String encoded){ 029 this.character=character; 030 this.encoded=encoded; 031 } 032 } 033 private String getEncoded(char character){ 034 for(int i=0;i<CODES_EXTENDED.length;i++){ 035 if(CODES_EXTENDED[i].character==character){ 036 return CODES_EXTENDED[i].encoded; 037 } 038 } 039 return ""; 040 } 041 042 protected String preprocess(String text) throws BarcodeException { 043 StringBuffer buffer=new StringBuffer(); 044 for(int i=0;i<text.length();i++){ 045 buffer.append(getEncoded(text.charAt(i))); 046 } 047 return buffer.toString(); 048 } 049 050 051 private static MappedCode[] CODES_EXTENDED={ 052 new MappedCode((char)0 , SHIFT_DOLLAR+"U"), 053 new MappedCode((char)1 , SHIFT_PERCENT+"A"), 054 new MappedCode((char)2 , SHIFT_PERCENT+"B"), 055 new MappedCode((char)3 , SHIFT_PERCENT+"C"), 056 new MappedCode((char)4 , SHIFT_PERCENT+"D"), 057 new MappedCode((char)5 , SHIFT_PERCENT+"E"), 058 new MappedCode((char)6 , SHIFT_PERCENT+"F"), 059 new MappedCode((char)7 , SHIFT_PERCENT+"G"), 060 new MappedCode((char)8 , SHIFT_PERCENT+"H"), 061 new MappedCode((char)9 , SHIFT_PERCENT+"I"), 062 new MappedCode((char)10 , SHIFT_PERCENT+"J"), 063 new MappedCode((char)11 , SHIFT_PERCENT+"K"), 064 new MappedCode((char)12 , SHIFT_PERCENT+"L"), 065 new MappedCode((char)13 , SHIFT_PERCENT+"M"), 066 new MappedCode((char)14 , SHIFT_PERCENT+"N"), 067 new MappedCode((char)15 , SHIFT_PERCENT+"O"), 068 new MappedCode((char)16 , SHIFT_PERCENT+"P"), 069 new MappedCode((char)17 , SHIFT_PERCENT+"Q"), 070 new MappedCode((char)18 , SHIFT_PERCENT+"R"), 071 new MappedCode((char)19 , SHIFT_PERCENT+"S"), 072 new MappedCode((char)20 , SHIFT_PERCENT+"T"), 073 new MappedCode((char)21 , SHIFT_PERCENT+"U"), 074 new MappedCode((char)22 , SHIFT_PERCENT+"V"), 075 new MappedCode((char)23 , SHIFT_PERCENT+"W"), 076 new MappedCode((char)24 , SHIFT_PERCENT+"X"), 077 new MappedCode((char)25 , SHIFT_PERCENT+"Y"), 078 new MappedCode((char)26 , SHIFT_PERCENT+"Z"), 079 new MappedCode((char)27 , SHIFT_DOLLAR+"A"), 080 new MappedCode((char)28 , SHIFT_DOLLAR+"B"), 081 new MappedCode((char)29 , SHIFT_DOLLAR+"C"), 082 new MappedCode((char)30 , SHIFT_DOLLAR+"D"), 083 new MappedCode((char)31 , SHIFT_DOLLAR+"E"), 084 new MappedCode(' ' , " "), 085 new MappedCode('!' , SHIFT_SLASH+"A"), 086 new MappedCode('"' , SHIFT_SLASH+"B"), 087 new MappedCode('#' , SHIFT_SLASH+"C"), 088 new MappedCode('$' , SHIFT_SLASH+"D"), 089 new MappedCode('%' , SHIFT_SLASH+"E"), 090 new MappedCode('&' , SHIFT_SLASH+"F"), 091 new MappedCode('\'' , SHIFT_SLASH+"G"), 092 new MappedCode('(' , SHIFT_SLASH+"H"), 093 new MappedCode(')' , SHIFT_SLASH+"I"), 094 new MappedCode('*' , SHIFT_SLASH+"J"), 095 new MappedCode('+' , SHIFT_SLASH+"K"), 096 new MappedCode(',' , SHIFT_SLASH+"L"), 097 new MappedCode('-' , "-"), 098 new MappedCode('.' , "."), 099 new MappedCode('/' , SHIFT_SLASH+"O"), 100 new MappedCode('0' , "0"), 101 new MappedCode('1' , "1"), 102 new MappedCode('2' , "2"), 103 new MappedCode('3' , "3"), 104 new MappedCode('4' , "4"), 105 new MappedCode('5' , "5"), 106 new MappedCode('6' , "6"), 107 new MappedCode('7' , "7"), 108 new MappedCode('8' , "8"), 109 new MappedCode('9' , "9"), 110 new MappedCode(':' , SHIFT_SLASH+"Z"), 111 new MappedCode(';' , SHIFT_DOLLAR+"F"), 112 new MappedCode('<' , SHIFT_DOLLAR+"G"), 113 new MappedCode('=' , SHIFT_DOLLAR+"H"), 114 new MappedCode('>' , SHIFT_DOLLAR+"I"), 115 new MappedCode('?' , SHIFT_DOLLAR+"J"), 116 new MappedCode('@' , SHIFT_DOLLAR+"V"), 117 new MappedCode('A' , "A"), 118 new MappedCode('B' , "B"), 119 new MappedCode('C' , "C"), 120 new MappedCode('D' , "D"), 121 new MappedCode('E' , "E"), 122 new MappedCode('F' , "F"), 123 new MappedCode('G' , "G"), 124 new MappedCode('H' , "H"), 125 new MappedCode('I' , "I"), 126 new MappedCode('J' , "J"), 127 new MappedCode('K' , "K"), 128 new MappedCode('L' , "L"), 129 new MappedCode('M' , "M"), 130 new MappedCode('N' , "N"), 131 new MappedCode('O' , "O"), 132 new MappedCode('P' , "P"), 133 new MappedCode('Q' , "Q"), 134 new MappedCode('R' , "R"), 135 new MappedCode('S' , "S"), 136 new MappedCode('T' , "T"), 137 new MappedCode('U' , "U"), 138 new MappedCode('V' , "V"), 139 new MappedCode('W' , "W"), 140 new MappedCode('X' , "X"), 141 new MappedCode('Y' , "Y"), 142 new MappedCode('Z' , "Z"), 143 new MappedCode('[' , SHIFT_DOLLAR+"K"), 144 new MappedCode('\\' , SHIFT_DOLLAR+"L"), 145 new MappedCode(']' , SHIFT_DOLLAR+"M"), 146 new MappedCode('^' , SHIFT_DOLLAR+"N"), 147 new MappedCode('_' , SHIFT_DOLLAR+"O"), 148 new MappedCode('`' , SHIFT_DOLLAR+"W"), 149 new MappedCode('a' , SHIFT_PLUS+"A"), 150 new MappedCode('b' , SHIFT_PLUS+"B"), 151 new MappedCode('c' , SHIFT_PLUS+"C"), 152 new MappedCode('d' , SHIFT_PLUS+"D"), 153 new MappedCode('e' , SHIFT_PLUS+"E"), 154 new MappedCode('f' , SHIFT_PLUS+"F"), 155 new MappedCode('g' , SHIFT_PLUS+"G"), 156 new MappedCode('h' , SHIFT_PLUS+"H"), 157 new MappedCode('i' , SHIFT_PLUS+"I"), 158 new MappedCode('j' , SHIFT_PLUS+"J"), 159 new MappedCode('k' , SHIFT_PLUS+"K"), 160 new MappedCode('l' , SHIFT_PLUS+"L"), 161 new MappedCode('m' , SHIFT_PLUS+"M"), 162 new MappedCode('n' , SHIFT_PLUS+"N"), 163 new MappedCode('o' , SHIFT_PLUS+"O"), 164 new MappedCode('p' , SHIFT_PLUS+"P"), 165 new MappedCode('q' , SHIFT_PLUS+"Q"), 166 new MappedCode('r' , SHIFT_PLUS+"R"), 167 new MappedCode('s' , SHIFT_PLUS+"S"), 168 new MappedCode('t' , SHIFT_PLUS+"T"), 169 new MappedCode('u' , SHIFT_PLUS+"U"), 170 new MappedCode('v' , SHIFT_PLUS+"V"), 171 new MappedCode('w' , SHIFT_PLUS+"W"), 172 new MappedCode('x' , SHIFT_PLUS+"X"), 173 new MappedCode('y' , SHIFT_PLUS+"Y"), 174 new MappedCode('z' , SHIFT_PLUS+"Z"), 175 new MappedCode('{' , SHIFT_DOLLAR+"P"), 176 new MappedCode('|' , SHIFT_DOLLAR+"Q"), 177 new MappedCode('}' , SHIFT_DOLLAR+"R"), 178 new MappedCode('~' , SHIFT_DOLLAR+"S"), 179 new MappedCode((char)127 , SHIFT_DOLLAR+"T") 180 }; 181 182 }