@@ -67,148 +67,148 @@ public class Barcode128 extends Barcode1D {
67
67
/**
68
68
* The bars to generate the code.
69
69
*/
70
- private static final byte [][] BARS =
70
+ private static final byte [][] BARS = new byte [][]
71
71
{
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 }
178
178
};
179
179
180
180
/**
181
181
* The stop bars.
182
182
*/
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 };
184
184
/**
185
185
* The charset code change.
186
186
*/
187
- public static final char CODE_AB_TO_C = 99 ;
187
+ public static final char CODE_AB_TO_C = ( char ) 99 ;
188
188
/**
189
189
* The charset code change.
190
190
*/
191
- public static final char CODE_AC_TO_B = 100 ;
191
+ public static final char CODE_AC_TO_B = ( char ) 100 ;
192
192
/**
193
193
* The charset code change.
194
194
*/
195
- public static final char CODE_BC_TO_A = 101 ;
195
+ public static final char CODE_BC_TO_A = ( char ) 101 ;
196
196
/**
197
197
* The code for UCC/EAN-128.
198
198
*/
199
- public static final char FNC1_INDEX = 102 ;
199
+ public static final char FNC1_INDEX = ( char ) 102 ;
200
200
/**
201
201
* The start code.
202
202
*/
203
- public static final char START_A = 103 ;
203
+ public static final char START_A = ( char ) 103 ;
204
204
/**
205
205
* The start code.
206
206
*/
207
- public static final char START_B = 104 ;
207
+ public static final char START_B = ( char ) 104 ;
208
208
/**
209
209
* The start code.
210
210
*/
211
- public static final char START_C = 105 ;
211
+ public static final char START_C = ( char ) 105 ;
212
212
213
213
public static final char FNC1 = '\u00ca' ;
214
214
public static final char DEL = '\u00c3' ;
@@ -238,28 +238,15 @@ public Barcode128(PdfDocument document) {
238
238
textAlignment = ALIGN_CENTER ;
239
239
codeType = CODE128 ;
240
240
} catch (Exception e ) {
241
- throw new RuntimeException (e . getLocalizedMessage () );
241
+ throw new RuntimeException (e );
242
242
}
243
243
}
244
244
245
245
public enum Barcode128CodeSet {
246
246
A ,
247
247
B ,
248
248
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
263
250
}
264
251
265
252
public void setCodeSet (Barcode128CodeSet codeSet ) {
@@ -296,7 +283,7 @@ public static String removeFNC1(String code) {
296
283
*/
297
284
public static String getHumanReadableUCCEAN (String code ) {
298
285
StringBuilder buf = new StringBuilder ();
299
- String fnc1 = String . valueOf ( FNC1 );
286
+ String fnc1 = new String ( new char []{ FNC1 } );
300
287
while (true ) {
301
288
if (code .startsWith (fnc1 )) {
302
289
code = code .substring (1 );
@@ -350,7 +337,7 @@ public static String getRawText(String text, boolean ucc, Barcode128CodeSet code
350
337
String out = "" ;
351
338
int tLen = text .length ();
352
339
if (tLen == 0 ) {
353
- out += codeSet . getStartSymbol ();
340
+ out += getStartSymbol (codeSet );
354
341
if (ucc )
355
342
out += FNC1_INDEX ;
356
343
return out ;
@@ -389,7 +376,7 @@ public static String getRawText(String text, boolean ucc, Barcode128CodeSet code
389
376
out += (char ) (c - ' ' );
390
377
++index ;
391
378
}
392
- if (codeSet != Barcode128CodeSet .AUTO && currentCode != codeSet . getStartSymbol ())
379
+ if (codeSet != Barcode128CodeSet .AUTO && currentCode != getStartSymbol (codeSet ))
393
380
throw new PdfException (PdfException .ThereAreIllegalCharactersForBarcode128In1 );
394
381
while (index < tLen ) {
395
382
switch (currentCode ) {
@@ -458,7 +445,7 @@ else if (c < ' ') {
458
445
}
459
446
break ;
460
447
}
461
- if (codeSet != Barcode128CodeSet .AUTO && currentCode != codeSet . getStartSymbol ())
448
+ if (codeSet != Barcode128CodeSet .AUTO && currentCode != getStartSymbol (codeSet ))
462
449
throw new PdfException (PdfException .ThereAreIllegalCharactersForBarcode128In1 );
463
450
}
464
451
return out ;
@@ -702,7 +689,7 @@ public void setCode(String code) {
702
689
if (len == 0 ) {
703
690
throw new IllegalArgumentException ("AI not found" );
704
691
}
705
- sai = String .valueOf (ai );
692
+ sai = Integer .valueOf (ai ). toString ( );
706
693
if (sai .length () == 1 ) {
707
694
sai = "0" + sai ;
708
695
}
@@ -772,6 +759,19 @@ public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color b
772
759
return canvas .createImage (new java .awt .image .MemoryImageSource (fullWidth , height , pix , 0 , fullWidth ));
773
760
}
774
761
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
+
775
775
static {
776
776
ais .put (0 , 20 );
777
777
ais .put (1 , 16 );
0 commit comments