@@ -67,148 +67,148 @@ public class Barcode128 extends Barcode1D {
6767 /**
6868 * The bars to generate the code.
6969 */
70- private static final byte [][] BARS =
70+ private static final byte [][] BARS = new byte [][]
7171 {
72- {2 , 1 , 2 , 2 , 2 , 2 },
73- {2 , 2 , 2 , 1 , 2 , 2 },
74- {2 , 2 , 2 , 2 , 2 , 1 },
75- {1 , 2 , 1 , 2 , 2 , 3 },
76- {1 , 2 , 1 , 3 , 2 , 2 },
77- {1 , 3 , 1 , 2 , 2 , 2 },
78- {1 , 2 , 2 , 2 , 1 , 3 },
79- {1 , 2 , 2 , 3 , 1 , 2 },
80- {1 , 3 , 2 , 2 , 1 , 2 },
81- {2 , 2 , 1 , 2 , 1 , 3 },
82- {2 , 2 , 1 , 3 , 1 , 2 },
83- {2 , 3 , 1 , 2 , 1 , 2 },
84- {1 , 1 , 2 , 2 , 3 , 2 },
85- {1 , 2 , 2 , 1 , 3 , 2 },
86- {1 , 2 , 2 , 2 , 3 , 1 },
87- {1 , 1 , 3 , 2 , 2 , 2 },
88- {1 , 2 , 3 , 1 , 2 , 2 },
89- {1 , 2 , 3 , 2 , 2 , 1 },
90- {2 , 2 , 3 , 2 , 1 , 1 },
91- {2 , 2 , 1 , 1 , 3 , 2 },
92- {2 , 2 , 1 , 2 , 3 , 1 },
93- {2 , 1 , 3 , 2 , 1 , 2 },
94- {2 , 2 , 3 , 1 , 1 , 2 },
95- {3 , 1 , 2 , 1 , 3 , 1 },
96- {3 , 1 , 1 , 2 , 2 , 2 },
97- {3 , 2 , 1 , 1 , 2 , 2 },
98- {3 , 2 , 1 , 2 , 2 , 1 },
99- {3 , 1 , 2 , 2 , 1 , 2 },
100- {3 , 2 , 2 , 1 , 1 , 2 },
101- {3 , 2 , 2 , 2 , 1 , 1 },
102- {2 , 1 , 2 , 1 , 2 , 3 },
103- {2 , 1 , 2 , 3 , 2 , 1 },
104- {2 , 3 , 2 , 1 , 2 , 1 },
105- {1 , 1 , 1 , 3 , 2 , 3 },
106- {1 , 3 , 1 , 1 , 2 , 3 },
107- {1 , 3 , 1 , 3 , 2 , 1 },
108- {1 , 1 , 2 , 3 , 1 , 3 },
109- {1 , 3 , 2 , 1 , 1 , 3 },
110- {1 , 3 , 2 , 3 , 1 , 1 },
111- {2 , 1 , 1 , 3 , 1 , 3 },
112- {2 , 3 , 1 , 1 , 1 , 3 },
113- {2 , 3 , 1 , 3 , 1 , 1 },
114- {1 , 1 , 2 , 1 , 3 , 3 },
115- {1 , 1 , 2 , 3 , 3 , 1 },
116- {1 , 3 , 2 , 1 , 3 , 1 },
117- {1 , 1 , 3 , 1 , 2 , 3 },
118- {1 , 1 , 3 , 3 , 2 , 1 },
119- {1 , 3 , 3 , 1 , 2 , 1 },
120- {3 , 1 , 3 , 1 , 2 , 1 },
121- {2 , 1 , 1 , 3 , 3 , 1 },
122- {2 , 3 , 1 , 1 , 3 , 1 },
123- {2 , 1 , 3 , 1 , 1 , 3 },
124- {2 , 1 , 3 , 3 , 1 , 1 },
125- {2 , 1 , 3 , 1 , 3 , 1 },
126- {3 , 1 , 1 , 1 , 2 , 3 },
127- {3 , 1 , 1 , 3 , 2 , 1 },
128- {3 , 3 , 1 , 1 , 2 , 1 },
129- {3 , 1 , 2 , 1 , 1 , 3 },
130- {3 , 1 , 2 , 3 , 1 , 1 },
131- {3 , 3 , 2 , 1 , 1 , 1 },
132- {3 , 1 , 4 , 1 , 1 , 1 },
133- {2 , 2 , 1 , 4 , 1 , 1 },
134- {4 , 3 , 1 , 1 , 1 , 1 },
135- {1 , 1 , 1 , 2 , 2 , 4 },
136- {1 , 1 , 1 , 4 , 2 , 2 },
137- {1 , 2 , 1 , 1 , 2 , 4 },
138- {1 , 2 , 1 , 4 , 2 , 1 },
139- {1 , 4 , 1 , 1 , 2 , 2 },
140- {1 , 4 , 1 , 2 , 2 , 1 },
141- {1 , 1 , 2 , 2 , 1 , 4 },
142- {1 , 1 , 2 , 4 , 1 , 2 },
143- {1 , 2 , 2 , 1 , 1 , 4 },
144- {1 , 2 , 2 , 4 , 1 , 1 },
145- {1 , 4 , 2 , 1 , 1 , 2 },
146- {1 , 4 , 2 , 2 , 1 , 1 },
147- {2 , 4 , 1 , 2 , 1 , 1 },
148- {2 , 2 , 1 , 1 , 1 , 4 },
149- {4 , 1 , 3 , 1 , 1 , 1 },
150- {2 , 4 , 1 , 1 , 1 , 2 },
151- {1 , 3 , 4 , 1 , 1 , 1 },
152- {1 , 1 , 1 , 2 , 4 , 2 },
153- {1 , 2 , 1 , 1 , 4 , 2 },
154- {1 , 2 , 1 , 2 , 4 , 1 },
155- {1 , 1 , 4 , 2 , 1 , 2 },
156- {1 , 2 , 4 , 1 , 1 , 2 },
157- {1 , 2 , 4 , 2 , 1 , 1 },
158- {4 , 1 , 1 , 2 , 1 , 2 },
159- {4 , 2 , 1 , 1 , 1 , 2 },
160- {4 , 2 , 1 , 2 , 1 , 1 },
161- {2 , 1 , 2 , 1 , 4 , 1 },
162- {2 , 1 , 4 , 1 , 2 , 1 },
163- {4 , 1 , 2 , 1 , 2 , 1 },
164- {1 , 1 , 1 , 1 , 4 , 3 },
165- {1 , 1 , 1 , 3 , 4 , 1 },
166- {1 , 3 , 1 , 1 , 4 , 1 },
167- {1 , 1 , 4 , 1 , 1 , 3 },
168- {1 , 1 , 4 , 3 , 1 , 1 },
169- {4 , 1 , 1 , 1 , 1 , 3 },
170- {4 , 1 , 1 , 3 , 1 , 1 },
171- {1 , 1 , 3 , 1 , 4 , 1 },
172- {1 , 1 , 4 , 1 , 3 , 1 },
173- {3 , 1 , 1 , 1 , 4 , 1 },
174- {4 , 1 , 1 , 1 , 3 , 1 },
175- {2 , 1 , 1 , 4 , 1 , 2 },
176- {2 , 1 , 1 , 2 , 1 , 4 },
177- {2 , 1 , 1 , 2 , 3 , 2 }
72+ new byte [] {2 , 1 , 2 , 2 , 2 , 2 },
73+ new byte [] {2 , 2 , 2 , 1 , 2 , 2 },
74+ new byte [] {2 , 2 , 2 , 2 , 2 , 1 },
75+ new byte [] {1 , 2 , 1 , 2 , 2 , 3 },
76+ new byte [] {1 , 2 , 1 , 3 , 2 , 2 },
77+ new byte [] {1 , 3 , 1 , 2 , 2 , 2 },
78+ new byte [] {1 , 2 , 2 , 2 , 1 , 3 },
79+ new byte [] {1 , 2 , 2 , 3 , 1 , 2 },
80+ new byte [] {1 , 3 , 2 , 2 , 1 , 2 },
81+ new byte [] {2 , 2 , 1 , 2 , 1 , 3 },
82+ new byte [] {2 , 2 , 1 , 3 , 1 , 2 },
83+ new byte [] {2 , 3 , 1 , 2 , 1 , 2 },
84+ new byte [] {1 , 1 , 2 , 2 , 3 , 2 },
85+ new byte [] {1 , 2 , 2 , 1 , 3 , 2 },
86+ new byte [] {1 , 2 , 2 , 2 , 3 , 1 },
87+ new byte [] {1 , 1 , 3 , 2 , 2 , 2 },
88+ new byte [] {1 , 2 , 3 , 1 , 2 , 2 },
89+ new byte [] {1 , 2 , 3 , 2 , 2 , 1 },
90+ new byte [] {2 , 2 , 3 , 2 , 1 , 1 },
91+ new byte [] {2 , 2 , 1 , 1 , 3 , 2 },
92+ new byte [] {2 , 2 , 1 , 2 , 3 , 1 },
93+ new byte [] {2 , 1 , 3 , 2 , 1 , 2 },
94+ new byte [] {2 , 2 , 3 , 1 , 1 , 2 },
95+ new byte [] {3 , 1 , 2 , 1 , 3 , 1 },
96+ new byte [] {3 , 1 , 1 , 2 , 2 , 2 },
97+ new byte [] {3 , 2 , 1 , 1 , 2 , 2 },
98+ new byte [] {3 , 2 , 1 , 2 , 2 , 1 },
99+ new byte [] {3 , 1 , 2 , 2 , 1 , 2 },
100+ new byte [] {3 , 2 , 2 , 1 , 1 , 2 },
101+ new byte [] {3 , 2 , 2 , 2 , 1 , 1 },
102+ new byte [] {2 , 1 , 2 , 1 , 2 , 3 },
103+ new byte [] {2 , 1 , 2 , 3 , 2 , 1 },
104+ new byte [] {2 , 3 , 2 , 1 , 2 , 1 },
105+ new byte [] {1 , 1 , 1 , 3 , 2 , 3 },
106+ new byte [] {1 , 3 , 1 , 1 , 2 , 3 },
107+ new byte [] {1 , 3 , 1 , 3 , 2 , 1 },
108+ new byte [] {1 , 1 , 2 , 3 , 1 , 3 },
109+ new byte [] {1 , 3 , 2 , 1 , 1 , 3 },
110+ new byte [] {1 , 3 , 2 , 3 , 1 , 1 },
111+ new byte [] {2 , 1 , 1 , 3 , 1 , 3 },
112+ new byte [] {2 , 3 , 1 , 1 , 1 , 3 },
113+ new byte [] {2 , 3 , 1 , 3 , 1 , 1 },
114+ new byte [] {1 , 1 , 2 , 1 , 3 , 3 },
115+ new byte [] {1 , 1 , 2 , 3 , 3 , 1 },
116+ new byte [] {1 , 3 , 2 , 1 , 3 , 1 },
117+ new byte [] {1 , 1 , 3 , 1 , 2 , 3 },
118+ new byte [] {1 , 1 , 3 , 3 , 2 , 1 },
119+ new byte [] {1 , 3 , 3 , 1 , 2 , 1 },
120+ new byte [] {3 , 1 , 3 , 1 , 2 , 1 },
121+ new byte [] {2 , 1 , 1 , 3 , 3 , 1 },
122+ new byte [] {2 , 3 , 1 , 1 , 3 , 1 },
123+ new byte [] {2 , 1 , 3 , 1 , 1 , 3 },
124+ new byte [] {2 , 1 , 3 , 3 , 1 , 1 },
125+ new byte [] {2 , 1 , 3 , 1 , 3 , 1 },
126+ new byte [] {3 , 1 , 1 , 1 , 2 , 3 },
127+ new byte [] {3 , 1 , 1 , 3 , 2 , 1 },
128+ new byte [] {3 , 3 , 1 , 1 , 2 , 1 },
129+ new byte [] {3 , 1 , 2 , 1 , 1 , 3 },
130+ new byte [] {3 , 1 , 2 , 3 , 1 , 1 },
131+ new byte [] {3 , 3 , 2 , 1 , 1 , 1 },
132+ new byte [] {3 , 1 , 4 , 1 , 1 , 1 },
133+ new byte [] {2 , 2 , 1 , 4 , 1 , 1 },
134+ new byte [] {4 , 3 , 1 , 1 , 1 , 1 },
135+ new byte [] {1 , 1 , 1 , 2 , 2 , 4 },
136+ new byte [] {1 , 1 , 1 , 4 , 2 , 2 },
137+ new byte [] {1 , 2 , 1 , 1 , 2 , 4 },
138+ new byte [] {1 , 2 , 1 , 4 , 2 , 1 },
139+ new byte [] {1 , 4 , 1 , 1 , 2 , 2 },
140+ new byte [] {1 , 4 , 1 , 2 , 2 , 1 },
141+ new byte [] {1 , 1 , 2 , 2 , 1 , 4 },
142+ new byte [] {1 , 1 , 2 , 4 , 1 , 2 },
143+ new byte [] {1 , 2 , 2 , 1 , 1 , 4 },
144+ new byte [] {1 , 2 , 2 , 4 , 1 , 1 },
145+ new byte [] {1 , 4 , 2 , 1 , 1 , 2 },
146+ new byte [] {1 , 4 , 2 , 2 , 1 , 1 },
147+ new byte [] {2 , 4 , 1 , 2 , 1 , 1 },
148+ new byte [] {2 , 2 , 1 , 1 , 1 , 4 },
149+ new byte [] {4 , 1 , 3 , 1 , 1 , 1 },
150+ new byte [] {2 , 4 , 1 , 1 , 1 , 2 },
151+ new byte [] {1 , 3 , 4 , 1 , 1 , 1 },
152+ new byte [] {1 , 1 , 1 , 2 , 4 , 2 },
153+ new byte [] {1 , 2 , 1 , 1 , 4 , 2 },
154+ new byte [] {1 , 2 , 1 , 2 , 4 , 1 },
155+ new byte [] {1 , 1 , 4 , 2 , 1 , 2 },
156+ new byte [] {1 , 2 , 4 , 1 , 1 , 2 },
157+ new byte [] {1 , 2 , 4 , 2 , 1 , 1 },
158+ new byte [] {4 , 1 , 1 , 2 , 1 , 2 },
159+ new byte [] {4 , 2 , 1 , 1 , 1 , 2 },
160+ new byte [] {4 , 2 , 1 , 2 , 1 , 1 },
161+ new byte [] {2 , 1 , 2 , 1 , 4 , 1 },
162+ new byte [] {2 , 1 , 4 , 1 , 2 , 1 },
163+ new byte [] {4 , 1 , 2 , 1 , 2 , 1 },
164+ new byte [] {1 , 1 , 1 , 1 , 4 , 3 },
165+ new byte [] {1 , 1 , 1 , 3 , 4 , 1 },
166+ new byte [] {1 , 3 , 1 , 1 , 4 , 1 },
167+ new byte [] {1 , 1 , 4 , 1 , 1 , 3 },
168+ new byte [] {1 , 1 , 4 , 3 , 1 , 1 },
169+ new byte [] {4 , 1 , 1 , 1 , 1 , 3 },
170+ new byte [] {4 , 1 , 1 , 3 , 1 , 1 },
171+ new byte [] {1 , 1 , 3 , 1 , 4 , 1 },
172+ new byte [] {1 , 1 , 4 , 1 , 3 , 1 },
173+ new byte [] {3 , 1 , 1 , 1 , 4 , 1 },
174+ new byte [] {4 , 1 , 1 , 1 , 3 , 1 },
175+ new byte [] {2 , 1 , 1 , 4 , 1 , 2 },
176+ new byte [] {2 , 1 , 1 , 2 , 1 , 4 },
177+ new byte [] {2 , 1 , 1 , 2 , 3 , 2 }
178178 };
179179
180180 /**
181181 * The stop bars.
182182 */
183- private static final byte [] BARS_STOP = {2 , 3 , 3 , 1 , 1 , 1 , 2 };
183+ private static final byte [] BARS_STOP = new byte [] {2 , 3 , 3 , 1 , 1 , 1 , 2 };
184184 /**
185185 * The charset code change.
186186 */
187- public static final char CODE_AB_TO_C = 99 ;
187+ public static final char CODE_AB_TO_C = ( char ) 99 ;
188188 /**
189189 * The charset code change.
190190 */
191- public static final char CODE_AC_TO_B = 100 ;
191+ public static final char CODE_AC_TO_B = ( char ) 100 ;
192192 /**
193193 * The charset code change.
194194 */
195- public static final char CODE_BC_TO_A = 101 ;
195+ public static final char CODE_BC_TO_A = ( char ) 101 ;
196196 /**
197197 * The code for UCC/EAN-128.
198198 */
199- public static final char FNC1_INDEX = 102 ;
199+ public static final char FNC1_INDEX = ( char ) 102 ;
200200 /**
201201 * The start code.
202202 */
203- public static final char START_A = 103 ;
203+ public static final char START_A = ( char ) 103 ;
204204 /**
205205 * The start code.
206206 */
207- public static final char START_B = 104 ;
207+ public static final char START_B = ( char ) 104 ;
208208 /**
209209 * The start code.
210210 */
211- public static final char START_C = 105 ;
211+ public static final char START_C = ( char ) 105 ;
212212
213213 public static final char FNC1 = '\u00ca' ;
214214 public static final char DEL = '\u00c3' ;
@@ -238,28 +238,15 @@ public Barcode128(PdfDocument document) {
238238 textAlignment = ALIGN_CENTER ;
239239 codeType = CODE128 ;
240240 } catch (Exception e ) {
241- throw new RuntimeException (e . getLocalizedMessage () );
241+ throw new RuntimeException (e );
242242 }
243243 }
244244
245245 public enum Barcode128CodeSet {
246246 A ,
247247 B ,
248248 C ,
249- AUTO ;
250-
251- public char getStartSymbol () {
252- switch (this ) {
253- case A :
254- return START_A ;
255- case B :
256- return START_B ;
257- case C :
258- return START_C ;
259- default :
260- return START_B ;
261- }
262- }
249+ AUTO
263250 }
264251
265252 public void setCodeSet (Barcode128CodeSet codeSet ) {
@@ -296,7 +283,7 @@ public static String removeFNC1(String code) {
296283 */
297284 public static String getHumanReadableUCCEAN (String code ) {
298285 StringBuilder buf = new StringBuilder ();
299- String fnc1 = String . valueOf ( FNC1 );
286+ String fnc1 = new String ( new char []{ FNC1 } );
300287 while (true ) {
301288 if (code .startsWith (fnc1 )) {
302289 code = code .substring (1 );
@@ -350,7 +337,7 @@ public static String getRawText(String text, boolean ucc, Barcode128CodeSet code
350337 String out = "" ;
351338 int tLen = text .length ();
352339 if (tLen == 0 ) {
353- out += codeSet . getStartSymbol ();
340+ out += getStartSymbol (codeSet );
354341 if (ucc )
355342 out += FNC1_INDEX ;
356343 return out ;
@@ -389,7 +376,7 @@ public static String getRawText(String text, boolean ucc, Barcode128CodeSet code
389376 out += (char ) (c - ' ' );
390377 ++index ;
391378 }
392- if (codeSet != Barcode128CodeSet .AUTO && currentCode != codeSet . getStartSymbol ())
379+ if (codeSet != Barcode128CodeSet .AUTO && currentCode != getStartSymbol (codeSet ))
393380 throw new PdfException (PdfException .ThereAreIllegalCharactersForBarcode128In1 );
394381 while (index < tLen ) {
395382 switch (currentCode ) {
@@ -458,7 +445,7 @@ else if (c < ' ') {
458445 }
459446 break ;
460447 }
461- if (codeSet != Barcode128CodeSet .AUTO && currentCode != codeSet . getStartSymbol ())
448+ if (codeSet != Barcode128CodeSet .AUTO && currentCode != getStartSymbol (codeSet ))
462449 throw new PdfException (PdfException .ThereAreIllegalCharactersForBarcode128In1 );
463450 }
464451 return out ;
@@ -702,7 +689,7 @@ public void setCode(String code) {
702689 if (len == 0 ) {
703690 throw new IllegalArgumentException ("AI not found" );
704691 }
705- sai = String .valueOf (ai );
692+ sai = Integer .valueOf (ai ). toString ( );
706693 if (sai .length () == 1 ) {
707694 sai = "0" + sai ;
708695 }
@@ -772,6 +759,19 @@ public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color b
772759 return canvas .createImage (new java .awt .image .MemoryImageSource (fullWidth , height , pix , 0 , fullWidth ));
773760 }
774761
762+ private static char getStartSymbol (Barcode128CodeSet codeSet ) {
763+ switch (codeSet ) {
764+ case A :
765+ return START_A ;
766+ case B :
767+ return START_B ;
768+ case C :
769+ return START_C ;
770+ default :
771+ return START_B ;
772+ }
773+ }
774+
775775 static {
776776 ais .put (0 , 20 );
777777 ais .put (1 , 16 );
0 commit comments