1 | /* | |
2 | * $Id: Barcode128.java 4065 2009-09-16 23:09:11Z psoares33 $ | |
3 | * | |
4 | * Copyright 2002-2006 by Paulo Soares. | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | package com.lowagie.text.pdf; | |
50 | import java.awt.Canvas; | |
51 | import java.awt.Color; | |
52 | import java.awt.Image; | |
53 | import java.awt.image.MemoryImageSource; | |
54 | import com.lowagie.text.error_messages.MessageLocalization; | |
55 | ||
56 | import com.lowagie.text.Element; | |
57 | import com.lowagie.text.Rectangle; | |
58 | import com.lowagie.text.ExceptionConverter; | |
59 | ||
60 | ||
61 | /** | |
62 | * Implements the code 128 and UCC/EAN-128. Other symbologies are allowed in raw mode.<p> | |
63 | * The code types allowed are:<br> | |
64 | * <ul> | |
65 | * <li><b>CODE128</b> - plain barcode 128. | |
66 | * <li><b>CODE128_UCC</b> - support for UCC/EAN-128 with a full list of AI. | |
67 | * <li><b>CODE128_RAW</b> - raw mode. The code attribute has the actual codes from 0 | |
68 | * to 105 followed by '\uffff' and the human readable text. | |
69 | * </ul> | |
70 | * The default parameters are: | |
71 | * <pre> | |
72 | * x = 0.8f; | |
73 | * font = BaseFont.createFont("Helvetica", "winansi", false); | |
74 | * size = 8; | |
75 | * baseline = size; | |
76 | * barHeight = size * 3; | |
77 | * textAlignment = Element.ALIGN_CENTER; | |
78 | * codeType = CODE128; | |
79 | * </pre> | |
80 | * @author Paulo Soares (psoares@consiste.pt) | |
81 | */ | |
82 | public class Barcode128 extends Barcode{ | |
83 | ||
84 | /** | |
85 | * The bars to generate the code. | |
86 | */ | |
87 | private static final byte[][] BARS = | |
88 | { | |
89 | {2, 1, 2, 2, 2, 2}, | |
90 | {2, 2, 2, 1, 2, 2}, | |
91 | {2, 2, 2, 2, 2, 1}, | |
92 | {1, 2, 1, 2, 2, 3}, | |
93 | {1, 2, 1, 3, 2, 2}, | |
94 | {1, 3, 1, 2, 2, 2}, | |
95 | {1, 2, 2, 2, 1, 3}, | |
96 | {1, 2, 2, 3, 1, 2}, | |
97 | {1, 3, 2, 2, 1, 2}, | |
98 | {2, 2, 1, 2, 1, 3}, | |
99 | {2, 2, 1, 3, 1, 2}, | |
100 | {2, 3, 1, 2, 1, 2}, | |
101 | {1, 1, 2, 2, 3, 2}, | |
102 | {1, 2, 2, 1, 3, 2}, | |
103 | {1, 2, 2, 2, 3, 1}, | |
104 | {1, 1, 3, 2, 2, 2}, | |
105 | {1, 2, 3, 1, 2, 2}, | |
106 | {1, 2, 3, 2, 2, 1}, | |
107 | {2, 2, 3, 2, 1, 1}, | |
108 | {2, 2, 1, 1, 3, 2}, | |
109 | {2, 2, 1, 2, 3, 1}, | |
110 | {2, 1, 3, 2, 1, 2}, | |
111 | {2, 2, 3, 1, 1, 2}, | |
112 | {3, 1, 2, 1, 3, 1}, | |
113 | {3, 1, 1, 2, 2, 2}, | |
114 | {3, 2, 1, 1, 2, 2}, | |
115 | {3, 2, 1, 2, 2, 1}, | |
116 | {3, 1, 2, 2, 1, 2}, | |
117 | {3, 2, 2, 1, 1, 2}, | |
118 | {3, 2, 2, 2, 1, 1}, | |
119 | {2, 1, 2, 1, 2, 3}, | |
120 | {2, 1, 2, 3, 2, 1}, | |
121 | {2, 3, 2, 1, 2, 1}, | |
122 | {1, 1, 1, 3, 2, 3}, | |
123 | {1, 3, 1, 1, 2, 3}, | |
124 | {1, 3, 1, 3, 2, 1}, | |
125 | {1, 1, 2, 3, 1, 3}, | |
126 | {1, 3, 2, 1, 1, 3}, | |
127 | {1, 3, 2, 3, 1, 1}, | |
128 | {2, 1, 1, 3, 1, 3}, | |
129 | {2, 3, 1, 1, 1, 3}, | |
130 | {2, 3, 1, 3, 1, 1}, | |
131 | {1, 1, 2, 1, 3, 3}, | |
132 | {1, 1, 2, 3, 3, 1}, | |
133 | {1, 3, 2, 1, 3, 1}, | |
134 | {1, 1, 3, 1, 2, 3}, | |
135 | {1, 1, 3, 3, 2, 1}, | |
136 | {1, 3, 3, 1, 2, 1}, | |
137 | {3, 1, 3, 1, 2, 1}, | |
138 | {2, 1, 1, 3, 3, 1}, | |
139 | {2, 3, 1, 1, 3, 1}, | |
140 | {2, 1, 3, 1, 1, 3}, | |
141 | {2, 1, 3, 3, 1, 1}, | |
142 | {2, 1, 3, 1, 3, 1}, | |
143 | {3, 1, 1, 1, 2, 3}, | |
144 | {3, 1, 1, 3, 2, 1}, | |
145 | {3, 3, 1, 1, 2, 1}, | |
146 | {3, 1, 2, 1, 1, 3}, | |
147 | {3, 1, 2, 3, 1, 1}, | |
148 | {3, 3, 2, 1, 1, 1}, | |
149 | {3, 1, 4, 1, 1, 1}, | |
150 | {2, 2, 1, 4, 1, 1}, | |
151 | {4, 3, 1, 1, 1, 1}, | |
152 | {1, 1, 1, 2, 2, 4}, | |
153 | {1, 1, 1, 4, 2, 2}, | |
154 | {1, 2, 1, 1, 2, 4}, | |
155 | {1, 2, 1, 4, 2, 1}, | |
156 | {1, 4, 1, 1, 2, 2}, | |
157 | {1, 4, 1, 2, 2, 1}, | |
158 | {1, 1, 2, 2, 1, 4}, | |
159 | {1, 1, 2, 4, 1, 2}, | |
160 | {1, 2, 2, 1, 1, 4}, | |
161 | {1, 2, 2, 4, 1, 1}, | |
162 | {1, 4, 2, 1, 1, 2}, | |
163 | {1, 4, 2, 2, 1, 1}, | |
164 | {2, 4, 1, 2, 1, 1}, | |
165 | {2, 2, 1, 1, 1, 4}, | |
166 | {4, 1, 3, 1, 1, 1}, | |
167 | {2, 4, 1, 1, 1, 2}, | |
168 | {1, 3, 4, 1, 1, 1}, | |
169 | {1, 1, 1, 2, 4, 2}, | |
170 | {1, 2, 1, 1, 4, 2}, | |
171 | {1, 2, 1, 2, 4, 1}, | |
172 | {1, 1, 4, 2, 1, 2}, | |
173 | {1, 2, 4, 1, 1, 2}, | |
174 | {1, 2, 4, 2, 1, 1}, | |
175 | {4, 1, 1, 2, 1, 2}, | |
176 | {4, 2, 1, 1, 1, 2}, | |
177 | {4, 2, 1, 2, 1, 1}, | |
178 | {2, 1, 2, 1, 4, 1}, | |
179 | {2, 1, 4, 1, 2, 1}, | |
180 | {4, 1, 2, 1, 2, 1}, | |
181 | {1, 1, 1, 1, 4, 3}, | |
182 | {1, 1, 1, 3, 4, 1}, | |
183 | {1, 3, 1, 1, 4, 1}, | |
184 | {1, 1, 4, 1, 1, 3}, | |
185 | {1, 1, 4, 3, 1, 1}, | |
186 | {4, 1, 1, 1, 1, 3}, | |
187 | {4, 1, 1, 3, 1, 1}, | |
188 | {1, 1, 3, 1, 4, 1}, | |
189 | {1, 1, 4, 1, 3, 1}, | |
190 | {3, 1, 1, 1, 4, 1}, | |
191 | {4, 1, 1, 1, 3, 1}, | |
192 | {2, 1, 1, 4, 1, 2}, | |
193 | {2, 1, 1, 2, 1, 4}, | |
194 | {2, 1, 1, 2, 3, 2} | |
195 | }; | |
196 | ||
197 | /** | |
198 | * The stop bars. | |
199 | */ | |
200 | private static final byte[] BARS_STOP = {2, 3, 3, 1, 1, 1, 2}; | |
201 | /** The charset code change. | |
202 | */ | |
203 | public static final char CODE_AB_TO_C = 99; | |
204 | /** The charset code change. | |
205 | */ | |
206 | public static final char CODE_AC_TO_B = 100; | |
207 | /** The charset code change. | |
208 | */ | |
209 | public static final char CODE_BC_TO_A = 101; | |
210 | /** The code for UCC/EAN-128. | |
211 | */ | |
212 | public static final char FNC1_INDEX = 102; | |
213 | /** The start code. | |
214 | */ | |
215 | public static final char START_A = 103; | |
216 | /** The start code. | |
217 | */ | |
218 | public static final char START_B = 104; | |
219 | /** The start code. | |
220 | */ | |
221 | public static final char START_C = 105; | |
222 | ||
223 | public static final char FNC1 = '\u00ca'; | |
224 | public static final char DEL = '\u00c3'; | |
225 | public static final char FNC3 = '\u00c4'; | |
226 | public static final char FNC2 = '\u00c5'; | |
227 | public static final char SHIFT = '\u00c6'; | |
228 | public static final char CODE_C = '\u00c7'; | |
229 | public static final char CODE_A = '\u00c8'; | |
230 | public static final char FNC4 = '\u00c8'; | |
231 | public static final char STARTA = '\u00cb'; | |
232 | public static final char STARTB = '\u00cc'; | |
233 | public static final char STARTC = '\u00cd'; | |
234 | | |
235 | private static final IntHashtable ais = new IntHashtable(); | |
236 | /** Creates new Barcode128 */ | |
237 | public Barcode128() { | |
238 | try { | |
239 | x = 0.8f; | |
240 | font = BaseFont.createFont("Helvetica", "winansi", false); | |
241 | size = 8; | |
242 | baseline = size; | |
243 |
1
1. |
barHeight = size * 3; |
244 | textAlignment = Element.ALIGN_CENTER; | |
245 | codeType = CODE128; | |
246 | } | |
247 | catch (Exception e) { | |
248 | throw new ExceptionConverter(e); | |
249 | } | |
250 | } | |
251 | ||
252 | /** | |
253 | * Removes the FNC1 codes in the text. | |
254 | * @param code the text to clean | |
255 | * @return the cleaned text | |
256 | */ | |
257 | public static String removeFNC1(String code) { | |
258 | int len = code.length(); | |
259 | StringBuilder buf = new StringBuilder(len); | |
260 |
3
1. removeFNC1 : changed conditional boundary → NO_COVERAGE 2. removeFNC1 : Changed increment from 1 to -1 → NO_COVERAGE 3. removeFNC1 : negated conditional → NO_COVERAGE |
for (int k = 0; k < len; ++k) { |
261 | char c = code.charAt(k); | |
262 |
4
1. removeFNC1 : changed conditional boundary → NO_COVERAGE 2. removeFNC1 : changed conditional boundary → NO_COVERAGE 3. removeFNC1 : negated conditional → NO_COVERAGE 4. removeFNC1 : negated conditional → NO_COVERAGE |
if (c >= 32 && c <= 126) |
263 | buf.append(c); | |
264 | } | |
265 |
1
1. removeFNC1 : mutated return of Object value for com/lowagie/text/pdf/Barcode128::removeFNC1 to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return buf.toString(); |
266 | } | |
267 | | |
268 | /** | |
269 | * Gets the human readable text of a sequence of AI. | |
270 | * @param code the text | |
271 | * @return the human readable text | |
272 | */ | |
273 | public static String getHumanReadableUCCEAN(String code) { | |
274 | StringBuilder buf = new StringBuilder(); | |
275 | String fnc1 = String.valueOf(FNC1); | |
276 | try { | |
277 | while (true) { | |
278 |
1
1. getHumanReadableUCCEAN : negated conditional → NO_COVERAGE |
if (code.startsWith(fnc1)) { |
279 | code = code.substring(1); | |
280 | continue; | |
281 | } | |
282 | int n = 0; | |
283 | int idlen = 0; | |
284 |
3
1. getHumanReadableUCCEAN : changed conditional boundary → NO_COVERAGE 2. getHumanReadableUCCEAN : Changed increment from 1 to -1 → NO_COVERAGE 3. getHumanReadableUCCEAN : negated conditional → NO_COVERAGE |
for (int k = 2; k < 5; ++k) { |
285 |
2
1. getHumanReadableUCCEAN : changed conditional boundary → NO_COVERAGE 2. getHumanReadableUCCEAN : negated conditional → NO_COVERAGE |
if (code.length() < k) |
286 | break; | |
287 |
1
1. getHumanReadableUCCEAN : negated conditional → NO_COVERAGE |
if ((n = ais.get(Integer.parseInt(code.substring(0, k)))) != 0) { |
288 | idlen = k; | |
289 | break; | |
290 | } | |
291 | } | |
292 |
1
1. getHumanReadableUCCEAN : negated conditional → NO_COVERAGE |
if (idlen == 0) |
293 | break; | |
294 | buf.append('(').append(code, 0, idlen).append(')'); | |
295 | code = code.substring(idlen); | |
296 |
2
1. getHumanReadableUCCEAN : changed conditional boundary → NO_COVERAGE 2. getHumanReadableUCCEAN : negated conditional → NO_COVERAGE |
if (n > 0) { |
297 |
1
1. getHumanReadableUCCEAN : Replaced integer subtraction with addition → NO_COVERAGE |
n -= idlen; |
298 |
2
1. getHumanReadableUCCEAN : changed conditional boundary → NO_COVERAGE 2. getHumanReadableUCCEAN : negated conditional → NO_COVERAGE |
if (code.length() <= n) |
299 | break; | |
300 | buf.append(removeFNC1(code.substring(0, n))); | |
301 | code = code.substring(n); | |
302 | } | |
303 | else { | |
304 | int idx = code.indexOf(FNC1); | |
305 |
2
1. getHumanReadableUCCEAN : changed conditional boundary → NO_COVERAGE 2. getHumanReadableUCCEAN : negated conditional → NO_COVERAGE |
if (idx < 0) |
306 | break; | |
307 | buf.append(code, 0, idx); | |
308 |
1
1. getHumanReadableUCCEAN : Replaced integer addition with subtraction → NO_COVERAGE |
code = code.substring(idx + 1); |
309 | } | |
310 | } | |
311 | } | |
312 | catch (Exception e) { | |
313 | //empty | |
314 | } | |
315 | buf.append(removeFNC1(code)); | |
316 |
1
1. getHumanReadableUCCEAN : mutated return of Object value for com/lowagie/text/pdf/Barcode128::getHumanReadableUCCEAN to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return buf.toString(); |
317 | } | |
318 | | |
319 | /** Returns <CODE>true</CODE> if the next <CODE>numDigits</CODE> | |
320 | * starting from index <CODE>textIndex</CODE> are numeric skipping any FNC1. | |
321 | * @param text the text to check | |
322 | * @param textIndex where to check from | |
323 | * @param numDigits the number of digits to check | |
324 | * @return the check result | |
325 | */ | |
326 | static boolean isNextDigits(String text, int textIndex, int numDigits) { | |
327 | int len = text.length(); | |
328 |
4
1. isNextDigits : changed conditional boundary → NO_COVERAGE 2. isNextDigits : changed conditional boundary → NO_COVERAGE 3. isNextDigits : negated conditional → NO_COVERAGE 4. isNextDigits : negated conditional → NO_COVERAGE |
while (textIndex < len && numDigits > 0) { |
329 |
1
1. isNextDigits : negated conditional → NO_COVERAGE |
if (text.charAt(textIndex) == FNC1) { |
330 |
1
1. isNextDigits : Changed increment from 1 to -1 → NO_COVERAGE |
++textIndex; |
331 | continue; | |
332 | } | |
333 | int n = Math.min(2, numDigits); | |
334 |
3
1. isNextDigits : changed conditional boundary → NO_COVERAGE 2. isNextDigits : Replaced integer addition with subtraction → NO_COVERAGE 3. isNextDigits : negated conditional → NO_COVERAGE |
if (textIndex + n > len) |
335 |
1
1. isNextDigits : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
336 |
3
1. isNextDigits : changed conditional boundary → NO_COVERAGE 2. isNextDigits : Changed increment from -1 to 1 → NO_COVERAGE 3. isNextDigits : negated conditional → NO_COVERAGE |
while (n-- > 0) { |
337 |
1
1. isNextDigits : Changed increment from 1 to -1 → NO_COVERAGE |
char c = text.charAt(textIndex++); |
338 |
4
1. isNextDigits : changed conditional boundary → NO_COVERAGE 2. isNextDigits : changed conditional boundary → NO_COVERAGE 3. isNextDigits : negated conditional → NO_COVERAGE 4. isNextDigits : negated conditional → NO_COVERAGE |
if (c < '0' || c > '9') |
339 |
1
1. isNextDigits : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
340 |
1
1. isNextDigits : Changed increment from -1 to 1 → NO_COVERAGE |
--numDigits; |
341 | } | |
342 | } | |
343 |
2
1. isNextDigits : negated conditional → NO_COVERAGE 2. isNextDigits : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return numDigits == 0; |
344 | } | |
345 | | |
346 | /** Packs the digits for charset C also considering FNC1. It assumes that all the parameters | |
347 | * are valid. | |
348 | * @param text the text to pack | |
349 | * @param textIndex where to pack from | |
350 | * @param numDigits the number of digits to pack. It is always an even number | |
351 | * @return the packed digits, two digits per character | |
352 | */ | |
353 | static String getPackedRawDigits(String text, int textIndex, int numDigits) { | |
354 | String out = ""; | |
355 | int start = textIndex; | |
356 |
2
1. getPackedRawDigits : changed conditional boundary → NO_COVERAGE 2. getPackedRawDigits : negated conditional → NO_COVERAGE |
while (numDigits > 0) { |
357 |
1
1. getPackedRawDigits : negated conditional → NO_COVERAGE |
if (text.charAt(textIndex) == FNC1) { |
358 | out += FNC1_INDEX; | |
359 |
1
1. getPackedRawDigits : Changed increment from 1 to -1 → NO_COVERAGE |
++textIndex; |
360 | continue; | |
361 | } | |
362 |
1
1. getPackedRawDigits : Changed increment from -2 to 2 → NO_COVERAGE |
numDigits -= 2; |
363 |
2
1. getPackedRawDigits : Changed increment from 1 to -1 → NO_COVERAGE 2. getPackedRawDigits : Replaced integer subtraction with addition → NO_COVERAGE |
int c1 = text.charAt(textIndex++) - '0'; |
364 |
2
1. getPackedRawDigits : Changed increment from 1 to -1 → NO_COVERAGE 2. getPackedRawDigits : Replaced integer subtraction with addition → NO_COVERAGE |
int c2 = text.charAt(textIndex++) - '0'; |
365 |
2
1. getPackedRawDigits : Replaced integer multiplication with division → NO_COVERAGE 2. getPackedRawDigits : Replaced integer addition with subtraction → NO_COVERAGE |
out += (char)(c1 * 10 + c2); |
366 | } | |
367 |
2
1. getPackedRawDigits : Replaced integer subtraction with addition → NO_COVERAGE 2. getPackedRawDigits : mutated return of Object value for com/lowagie/text/pdf/Barcode128::getPackedRawDigits to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return (char)(textIndex - start) + out; |
368 | } | |
369 | | |
370 | /** Converts the human readable text to the characters needed to | |
371 | * create a barcode. Some optimization is done to get the shortest code. | |
372 | * @param text the text to convert | |
373 | * @param ucc <CODE>true</CODE> if it is an UCC/EAN-128. In this case | |
374 | * the character FNC1 is added | |
375 | * @return the code ready to be fed to getBarsCode128Raw() | |
376 | */ | |
377 | public static String getRawText(String text, boolean ucc) { | |
378 | String out = ""; | |
379 | int tLen = text.length(); | |
380 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (tLen == 0) { |
381 | out += START_B; | |
382 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (ucc) |
383 | out += FNC1_INDEX; | |
384 |
1
1. getRawText : mutated return of Object value for com/lowagie/text/pdf/Barcode128::getRawText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return out; |
385 | } | |
386 | int c = 0; | |
387 |
3
1. getRawText : changed conditional boundary → NO_COVERAGE 2. getRawText : Changed increment from 1 to -1 → NO_COVERAGE 3. getRawText : negated conditional → NO_COVERAGE |
for (int k = 0; k < tLen; ++k) { |
388 | c = text.charAt(k); | |
389 |
3
1. getRawText : changed conditional boundary → NO_COVERAGE 2. getRawText : negated conditional → NO_COVERAGE 3. getRawText : negated conditional → NO_COVERAGE |
if (c > 127 && c != FNC1) |
390 | throw new RuntimeException(MessageLocalization.getComposedMessage("there.are.illegal.characters.for.barcode.128.in.1", text)); | |
391 | } | |
392 | c = text.charAt(0); | |
393 | char currentCode = START_B; | |
394 | int index = 0; | |
395 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (isNextDigits(text, index, 2)) { |
396 | currentCode = START_C; | |
397 | out += currentCode; | |
398 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (ucc) |
399 | out += FNC1_INDEX; | |
400 | String out2 = getPackedRawDigits(text, index, 2); | |
401 |
1
1. getRawText : Replaced integer addition with subtraction → NO_COVERAGE |
index += out2.charAt(0); |
402 | out += out2.substring(1); | |
403 | } | |
404 |
2
1. getRawText : changed conditional boundary → NO_COVERAGE 2. getRawText : negated conditional → NO_COVERAGE |
else if (c < ' ') { |
405 | currentCode = START_A; | |
406 | out += currentCode; | |
407 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (ucc) |
408 | out += FNC1_INDEX; | |
409 |
1
1. getRawText : Replaced integer addition with subtraction → NO_COVERAGE |
out += (char)(c + 64); |
410 |
1
1. getRawText : Changed increment from 1 to -1 → NO_COVERAGE |
++index; |
411 | } | |
412 | else { | |
413 | out += currentCode; | |
414 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (ucc) |
415 | out += FNC1_INDEX; | |
416 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (c == FNC1) |
417 | out += FNC1_INDEX; | |
418 | else | |
419 |
1
1. getRawText : Replaced integer subtraction with addition → NO_COVERAGE |
out += (char)(c - ' '); |
420 |
1
1. getRawText : Changed increment from 1 to -1 → NO_COVERAGE |
++index; |
421 | } | |
422 |
2
1. getRawText : changed conditional boundary → NO_COVERAGE 2. getRawText : negated conditional → NO_COVERAGE |
while (index < tLen) { |
423 | switch (currentCode) { | |
424 | case START_A: | |
425 | { | |
426 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (isNextDigits(text, index, 4)) { |
427 | currentCode = START_C; | |
428 | out += CODE_AB_TO_C; | |
429 | String out2 = getPackedRawDigits(text, index, 4); | |
430 |
1
1. getRawText : Replaced integer addition with subtraction → NO_COVERAGE |
index += out2.charAt(0); |
431 | out += out2.substring(1); | |
432 | } | |
433 | else { | |
434 |
1
1. getRawText : Changed increment from 1 to -1 → NO_COVERAGE |
c = text.charAt(index++); |
435 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (c == FNC1) |
436 | out += FNC1_INDEX; | |
437 |
2
1. getRawText : changed conditional boundary → NO_COVERAGE 2. getRawText : negated conditional → NO_COVERAGE |
else if (c > '_') { |
438 | currentCode = START_B; | |
439 | out += CODE_AC_TO_B; | |
440 |
1
1. getRawText : Replaced integer subtraction with addition → NO_COVERAGE |
out += (char)(c - ' '); |
441 | } | |
442 |
2
1. getRawText : changed conditional boundary → NO_COVERAGE 2. getRawText : negated conditional → NO_COVERAGE |
else if (c < ' ') |
443 |
1
1. getRawText : Replaced integer addition with subtraction → NO_COVERAGE |
out += (char)(c + 64); |
444 | else | |
445 |
1
1. getRawText : Replaced integer subtraction with addition → NO_COVERAGE |
out += (char)(c - ' '); |
446 | } | |
447 | } | |
448 | break; | |
449 | case START_B: | |
450 | { | |
451 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (isNextDigits(text, index, 4)) { |
452 | currentCode = START_C; | |
453 | out += CODE_AB_TO_C; | |
454 | String out2 = getPackedRawDigits(text, index, 4); | |
455 |
1
1. getRawText : Replaced integer addition with subtraction → NO_COVERAGE |
index += out2.charAt(0); |
456 | out += out2.substring(1); | |
457 | } | |
458 | else { | |
459 |
1
1. getRawText : Changed increment from 1 to -1 → NO_COVERAGE |
c = text.charAt(index++); |
460 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (c == FNC1) |
461 | out += FNC1_INDEX; | |
462 |
2
1. getRawText : changed conditional boundary → NO_COVERAGE 2. getRawText : negated conditional → NO_COVERAGE |
else if (c < ' ') { |
463 | currentCode = START_A; | |
464 | out += CODE_BC_TO_A; | |
465 |
1
1. getRawText : Replaced integer addition with subtraction → NO_COVERAGE |
out += (char)(c + 64); |
466 | } | |
467 | else { | |
468 |
1
1. getRawText : Replaced integer subtraction with addition → NO_COVERAGE |
out += (char)(c - ' '); |
469 | } | |
470 | } | |
471 | } | |
472 | break; | |
473 | case START_C: | |
474 | { | |
475 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (isNextDigits(text, index, 2)) { |
476 | String out2 = getPackedRawDigits(text, index, 2); | |
477 |
1
1. getRawText : Replaced integer addition with subtraction → NO_COVERAGE |
index += out2.charAt(0); |
478 | out += out2.substring(1); | |
479 | } | |
480 | else { | |
481 |
1
1. getRawText : Changed increment from 1 to -1 → NO_COVERAGE |
c = text.charAt(index++); |
482 |
1
1. getRawText : negated conditional → NO_COVERAGE |
if (c == FNC1) |
483 | out += FNC1_INDEX; | |
484 |
2
1. getRawText : changed conditional boundary → NO_COVERAGE 2. getRawText : negated conditional → NO_COVERAGE |
else if (c < ' ') { |
485 | currentCode = START_A; | |
486 | out += CODE_BC_TO_A; | |
487 |
1
1. getRawText : Replaced integer addition with subtraction → NO_COVERAGE |
out += (char)(c + 64); |
488 | } | |
489 | else { | |
490 | currentCode = START_B; | |
491 | out += CODE_AC_TO_B; | |
492 |
1
1. getRawText : Replaced integer subtraction with addition → NO_COVERAGE |
out += (char)(c - ' '); |
493 | } | |
494 | } | |
495 | } | |
496 | break; | |
497 | } | |
498 | } | |
499 |
1
1. getRawText : mutated return of Object value for com/lowagie/text/pdf/Barcode128::getRawText to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return out; |
500 | } | |
501 | | |
502 | /** Generates the bars. The input has the actual barcodes, not | |
503 | * the human readable text. | |
504 | * @param text the barcode | |
505 | * @return the bars | |
506 | */ | |
507 | public static byte[] getBarsCode128Raw(String text) { | |
508 | int idx = text.indexOf('\uffff'); | |
509 |
2
1. getBarsCode128Raw : changed conditional boundary → NO_COVERAGE 2. getBarsCode128Raw : negated conditional → NO_COVERAGE |
if (idx >= 0) |
510 | text = text.substring(0, idx); | |
511 | int chk = text.charAt(0); | |
512 |
3
1. getBarsCode128Raw : changed conditional boundary → NO_COVERAGE 2. getBarsCode128Raw : Changed increment from 1 to -1 → NO_COVERAGE 3. getBarsCode128Raw : negated conditional → NO_COVERAGE |
for (int k = 1; k < text.length(); ++k) |
513 |
2
1. getBarsCode128Raw : Replaced integer multiplication with division → NO_COVERAGE 2. getBarsCode128Raw : Replaced integer addition with subtraction → NO_COVERAGE |
chk += k * text.charAt(k); |
514 |
1
1. getBarsCode128Raw : Replaced integer modulus with multiplication → NO_COVERAGE |
chk = chk % 103; |
515 | text += (char)chk; | |
516 |
3
1. getBarsCode128Raw : Replaced integer addition with subtraction → NO_COVERAGE 2. getBarsCode128Raw : Replaced integer multiplication with division → NO_COVERAGE 3. getBarsCode128Raw : Replaced integer addition with subtraction → NO_COVERAGE |
byte[] bars = new byte[(text.length() + 1) * 6 + 7]; |
517 | int k; | |
518 |
2
1. getBarsCode128Raw : changed conditional boundary → NO_COVERAGE 2. getBarsCode128Raw : negated conditional → NO_COVERAGE |
for (k = 0; k < text.length(); ++k) |
519 |
2
1. getBarsCode128Raw : Replaced integer multiplication with division → NO_COVERAGE 2. getBarsCode128Raw : removed call to java/lang/System::arraycopy → NO_COVERAGE |
System.arraycopy(BARS[text.charAt(k)], 0, bars, k * 6, 6); |
520 |
2
1. getBarsCode128Raw : Replaced integer multiplication with division → NO_COVERAGE 2. getBarsCode128Raw : removed call to java/lang/System::arraycopy → NO_COVERAGE |
System.arraycopy(BARS_STOP, 0, bars, k * 6, 7); |
521 |
1
1. getBarsCode128Raw : mutated return of Object value for com/lowagie/text/pdf/Barcode128::getBarsCode128Raw to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return bars; |
522 | } | |
523 | | |
524 | /** Gets the maximum area that the barcode and the text, if | |
525 | * any, will occupy. The lower left corner is always (0, 0). | |
526 | * @return the size the barcode occupies. | |
527 | */ | |
528 | public Rectangle getBarcodeSize() { | |
529 | float fontX = 0; | |
530 | float fontY = 0; | |
531 | String fullCode; | |
532 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
if (font != null) { |
533 |
2
1. getBarcodeSize : changed conditional boundary → NO_COVERAGE 2. getBarcodeSize : negated conditional → NO_COVERAGE |
if (baseline > 0) |
534 |
1
1. getBarcodeSize : Replaced float subtraction with addition → NO_COVERAGE |
fontY = baseline - font.getFontDescriptor(BaseFont.DESCENT, size); |
535 | else | |
536 |
2
1. getBarcodeSize : removed negation → NO_COVERAGE 2. getBarcodeSize : Replaced float addition with subtraction → NO_COVERAGE |
fontY = -baseline + size; |
537 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
if (codeType == CODE128_RAW) { |
538 | int idx = code.indexOf('\uffff'); | |
539 |
2
1. getBarcodeSize : changed conditional boundary → NO_COVERAGE 2. getBarcodeSize : negated conditional → NO_COVERAGE |
if (idx < 0) |
540 | fullCode = ""; | |
541 | else | |
542 |
1
1. getBarcodeSize : Replaced integer addition with subtraction → NO_COVERAGE |
fullCode = code.substring(idx + 1); |
543 | } | |
544 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
else if (codeType == CODE128_UCC) |
545 | fullCode = getHumanReadableUCCEAN(code); | |
546 | else | |
547 | fullCode = removeFNC1(code); | |
548 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
fontX = font.getWidthPoint(altText != null ? altText : fullCode, size); |
549 | } | |
550 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
if (codeType == CODE128_RAW) { |
551 | int idx = code.indexOf('\uffff'); | |
552 |
2
1. getBarcodeSize : changed conditional boundary → NO_COVERAGE 2. getBarcodeSize : negated conditional → NO_COVERAGE |
if (idx >= 0) |
553 | fullCode = code.substring(0, idx); | |
554 | else | |
555 | fullCode = code; | |
556 | } | |
557 | else { | |
558 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
fullCode = getRawText(code, codeType == CODE128_UCC); |
559 | } | |
560 | int len = fullCode.length(); | |
561 |
5
1. getBarcodeSize : Replaced integer addition with subtraction → NO_COVERAGE 2. getBarcodeSize : Replaced integer multiplication with division → NO_COVERAGE 3. getBarcodeSize : Replaced float multiplication with division → NO_COVERAGE 4. getBarcodeSize : Replaced float multiplication with division → NO_COVERAGE 5. getBarcodeSize : Replaced float addition with subtraction → NO_COVERAGE |
float fullWidth = (len + 2) * 11 * x + 2 * x; |
562 | fullWidth = Math.max(fullWidth, fontX); | |
563 |
1
1. getBarcodeSize : Replaced float addition with subtraction → NO_COVERAGE |
float fullHeight = barHeight + fontY; |
564 |
1
1. getBarcodeSize : mutated return of Object value for com/lowagie/text/pdf/Barcode128::getBarcodeSize to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Rectangle(fullWidth, fullHeight); |
565 | } | |
566 | | |
567 | /** Places the barcode in a <CODE>PdfContentByte</CODE>. The | |
568 | * barcode is always placed at coordinates (0, 0). Use the | |
569 | * translation matrix to move it elsewhere.<p> | |
570 | * The bars and text are written in the following colors:<p> | |
571 | * <P><TABLE BORDER=1> | |
572 | * <TR> | |
573 | * <TH><P><CODE>barColor</CODE></TH> | |
574 | * <TH><P><CODE>textColor</CODE></TH> | |
575 | * <TH><P>Result</TH> | |
576 | * </TR> | |
577 | * <TR> | |
578 | * <TD><P><CODE>null</CODE></TD> | |
579 | * <TD><P><CODE>null</CODE></TD> | |
580 | * <TD><P>bars and text painted with current fill color</TD> | |
581 | * </TR> | |
582 | * <TR> | |
583 | * <TD><P><CODE>barColor</CODE></TD> | |
584 | * <TD><P><CODE>null</CODE></TD> | |
585 | * <TD><P>bars and text painted with <CODE>barColor</CODE></TD> | |
586 | * </TR> | |
587 | * <TR> | |
588 | * <TD><P><CODE>null</CODE></TD> | |
589 | * <TD><P><CODE>textColor</CODE></TD> | |
590 | * <TD><P>bars painted with current color<br>text painted with <CODE>textColor</CODE></TD> | |
591 | * </TR> | |
592 | * <TR> | |
593 | * <TD><P><CODE>barColor</CODE></TD> | |
594 | * <TD><P><CODE>textColor</CODE></TD> | |
595 | * <TD><P>bars painted with <CODE>barColor</CODE><br>text painted with <CODE>textColor</CODE></TD> | |
596 | * </TR> | |
597 | * </TABLE> | |
598 | * @param cb the <CODE>PdfContentByte</CODE> where the barcode will be placed | |
599 | * @param barColor the color of the bars. It can be <CODE>null</CODE> | |
600 | * @param textColor the color of the text. It can be <CODE>null</CODE> | |
601 | * @return the dimensions the barcode occupies | |
602 | */ | |
603 | public Rectangle placeBarcode(PdfContentByte cb, Color barColor, Color textColor) { | |
604 | String fullCode; | |
605 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (codeType == CODE128_RAW) { |
606 | int idx = code.indexOf('\uffff'); | |
607 |
2
1. placeBarcode : changed conditional boundary → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (idx < 0) |
608 | fullCode = ""; | |
609 | else | |
610 |
1
1. placeBarcode : Replaced integer addition with subtraction → NO_COVERAGE |
fullCode = code.substring(idx + 1); |
611 | } | |
612 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
else if (codeType == CODE128_UCC) |
613 | fullCode = getHumanReadableUCCEAN(code); | |
614 | else | |
615 | fullCode = removeFNC1(code); | |
616 | float fontX = 0; | |
617 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (font != null) { |
618 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
fontX = font.getWidthPoint(fullCode = altText != null ? altText : fullCode, size); |
619 | } | |
620 | String bCode; | |
621 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (codeType == CODE128_RAW) { |
622 | int idx = code.indexOf('\uffff'); | |
623 |
2
1. placeBarcode : changed conditional boundary → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (idx >= 0) |
624 | bCode = code.substring(0, idx); | |
625 | else | |
626 | bCode = code; | |
627 | } | |
628 | else { | |
629 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
bCode = getRawText(code, codeType == CODE128_UCC); |
630 | } | |
631 | int len = bCode.length(); | |
632 |
5
1. placeBarcode : Replaced integer addition with subtraction → NO_COVERAGE 2. placeBarcode : Replaced integer multiplication with division → NO_COVERAGE 3. placeBarcode : Replaced float multiplication with division → NO_COVERAGE 4. placeBarcode : Replaced float multiplication with division → NO_COVERAGE 5. placeBarcode : Replaced float addition with subtraction → NO_COVERAGE |
float fullWidth = (len + 2) * 11 * x + 2 * x; |
633 | float barStartX = 0; | |
634 | float textStartX = 0; | |
635 | switch (textAlignment) { | |
636 | case Element.ALIGN_LEFT: | |
637 | break; | |
638 | case Element.ALIGN_RIGHT: | |
639 |
2
1. placeBarcode : changed conditional boundary → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (fontX > fullWidth) |
640 |
1
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE |
barStartX = fontX - fullWidth; |
641 | else | |
642 |
1
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE |
textStartX = fullWidth - fontX; |
643 | break; | |
644 | default: | |
645 |
2
1. placeBarcode : changed conditional boundary → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (fontX > fullWidth) |
646 |
2
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE 2. placeBarcode : Replaced float division with multiplication → NO_COVERAGE |
barStartX = (fontX - fullWidth) / 2; |
647 | else | |
648 |
2
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE 2. placeBarcode : Replaced float division with multiplication → NO_COVERAGE |
textStartX = (fullWidth - fontX) / 2; |
649 | break; | |
650 | } | |
651 | float barStartY = 0; | |
652 | float textStartY = 0; | |
653 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (font != null) { |
654 |
2
1. placeBarcode : changed conditional boundary → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (baseline <= 0) |
655 |
1
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE |
textStartY = barHeight - baseline; |
656 | else { | |
657 |
1
1. placeBarcode : removed negation → NO_COVERAGE |
textStartY = -font.getFontDescriptor(BaseFont.DESCENT, size); |
658 |
1
1. placeBarcode : Replaced float addition with subtraction → NO_COVERAGE |
barStartY = textStartY + baseline; |
659 | } | |
660 | } | |
661 | byte[] bars = getBarsCode128Raw(bCode); | |
662 | boolean print = true; | |
663 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (barColor != null) |
664 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::setColorFill → NO_COVERAGE |
cb.setColorFill(barColor); |
665 | for (byte bar : bars) { | |
666 |
1
1. placeBarcode : Replaced float multiplication with division → NO_COVERAGE |
float w = bar * x; |
667 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (print) |
668 |
2
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE 2. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::rectangle → NO_COVERAGE |
cb.rectangle(barStartX, barStartY, w - inkSpreading, barHeight); |
669 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
print = !print; |
670 |
1
1. placeBarcode : Replaced float addition with subtraction → NO_COVERAGE |
barStartX += w; |
671 | } | |
672 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::fill → NO_COVERAGE |
cb.fill(); |
673 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (font != null) { |
674 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (textColor != null) |
675 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::setColorFill → NO_COVERAGE |
cb.setColorFill(textColor); |
676 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::beginText → NO_COVERAGE |
cb.beginText(); |
677 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::setFontAndSize → NO_COVERAGE |
cb.setFontAndSize(font, size); |
678 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::setTextMatrix → NO_COVERAGE |
cb.setTextMatrix(textStartX, textStartY); |
679 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::showText → NO_COVERAGE |
cb.showText(fullCode); |
680 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::endText → NO_COVERAGE |
cb.endText(); |
681 | } | |
682 |
1
1. placeBarcode : mutated return of Object value for com/lowagie/text/pdf/Barcode128::placeBarcode to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return getBarcodeSize(); |
683 | } | |
684 | | |
685 | /** Creates a <CODE>java.awt.Image</CODE>. This image only | |
686 | * contains the bars without any text. | |
687 | * @param foreground the color of the bars | |
688 | * @param background the color of the background | |
689 | * @return the image | |
690 | */ | |
691 | public java.awt.Image createAwtImage(Color foreground, Color background) { | |
692 | int f = foreground.getRGB(); | |
693 | int g = background.getRGB(); | |
694 | Canvas canvas = new Canvas(); | |
695 | String bCode; | |
696 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
if (codeType == CODE128_RAW) { |
697 | int idx = code.indexOf('\uffff'); | |
698 |
2
1. createAwtImage : changed conditional boundary → NO_COVERAGE 2. createAwtImage : negated conditional → NO_COVERAGE |
if (idx >= 0) |
699 | bCode = code.substring(0, idx); | |
700 | else | |
701 | bCode = code; | |
702 | } | |
703 | else { | |
704 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
bCode = getRawText(code, codeType == CODE128_UCC); |
705 | } | |
706 | int len = bCode.length(); | |
707 |
3
1. createAwtImage : Replaced integer addition with subtraction → NO_COVERAGE 2. createAwtImage : Replaced integer multiplication with division → NO_COVERAGE 3. createAwtImage : Replaced integer addition with subtraction → NO_COVERAGE |
int fullWidth = (len + 2) * 11 + 2; |
708 | byte[] bars = getBarsCode128Raw(bCode); | |
709 | | |
710 | boolean print = true; | |
711 | int ptr = 0; | |
712 | int height = (int)barHeight; | |
713 |
1
1. createAwtImage : Replaced integer multiplication with division → NO_COVERAGE |
int[] pix = new int[fullWidth * height]; |
714 | for (int w : bars) { | |
715 | int c = g; | |
716 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
if (print) |
717 | c = f; | |
718 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
print = !print; |
719 |
3
1. createAwtImage : changed conditional boundary → NO_COVERAGE 2. createAwtImage : Changed increment from 1 to -1 → NO_COVERAGE 3. createAwtImage : negated conditional → NO_COVERAGE |
for (int j = 0; j < w; ++j) |
720 |
1
1. createAwtImage : Changed increment from 1 to -1 → NO_COVERAGE |
pix[ptr++] = c; |
721 | } | |
722 |
3
1. createAwtImage : changed conditional boundary → NO_COVERAGE 2. createAwtImage : Replaced integer addition with subtraction → NO_COVERAGE 3. createAwtImage : negated conditional → NO_COVERAGE |
for (int k = fullWidth; k < pix.length; k += fullWidth) { |
723 |
1
1. createAwtImage : removed call to java/lang/System::arraycopy → NO_COVERAGE |
System.arraycopy(pix, 0, pix, k, fullWidth); |
724 | } | |
725 | Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth)); | |
726 | | |
727 |
1
1. createAwtImage : mutated return of Object value for com/lowagie/text/pdf/Barcode128::createAwtImage to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return img; |
728 | } | |
729 | | |
730 | /** | |
731 | * Sets the code to generate. If it's an UCC code and starts with '(' it will | |
732 | * be split by the AI. This code in UCC mode is valid: | |
733 | * <p> | |
734 | * <code>(01)00000090311314(10)ABC123(15)060916</code> | |
735 | * @param code the code to generate | |
736 | */ | |
737 | public void setCode(String code) { | |
738 |
2
1. setCode : negated conditional → NO_COVERAGE 2. setCode : negated conditional → NO_COVERAGE |
if (getCodeType() == Barcode128.CODE128_UCC && code.startsWith("(")) { |
739 | int idx = 0; | |
740 | String ret = ""; | |
741 |
2
1. setCode : changed conditional boundary → NO_COVERAGE 2. setCode : negated conditional → NO_COVERAGE |
while (idx >= 0) { |
742 | int end = code.indexOf(')', idx); | |
743 |
2
1. setCode : changed conditional boundary → NO_COVERAGE 2. setCode : negated conditional → NO_COVERAGE |
if (end < 0) |
744 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("badly.formed.ucc.string.1", code)); | |
745 |
1
1. setCode : Replaced integer addition with subtraction → NO_COVERAGE |
String sai = code.substring(idx + 1, end); |
746 |
2
1. setCode : changed conditional boundary → NO_COVERAGE 2. setCode : negated conditional → NO_COVERAGE |
if (sai.length() < 2) |
747 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("ai.too.short.1", sai)); | |
748 | int ai = Integer.parseInt(sai); | |
749 | int len = ais.get(ai); | |
750 |
1
1. setCode : negated conditional → NO_COVERAGE |
if (len == 0) |
751 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("ai.not.found.1", sai)); | |
752 | sai = String.valueOf(ai); | |
753 |
1
1. setCode : negated conditional → NO_COVERAGE |
if (sai.length() == 1) |
754 | sai = "0" + sai; | |
755 | idx = code.indexOf('(', end); | |
756 |
2
1. setCode : changed conditional boundary → NO_COVERAGE 2. setCode : negated conditional → NO_COVERAGE |
int next = (idx < 0 ? code.length() : idx); |
757 |
1
1. setCode : Replaced integer addition with subtraction → NO_COVERAGE |
ret += sai + code.substring(end + 1, next); |
758 |
2
1. setCode : changed conditional boundary → NO_COVERAGE 2. setCode : negated conditional → NO_COVERAGE |
if (len < 0) { |
759 |
2
1. setCode : changed conditional boundary → NO_COVERAGE 2. setCode : negated conditional → NO_COVERAGE |
if (idx >= 0) |
760 | ret += FNC1; | |
761 | } | |
762 |
4
1. setCode : Replaced integer subtraction with addition → NO_COVERAGE 2. setCode : Replaced integer subtraction with addition → NO_COVERAGE 3. setCode : Replaced integer addition with subtraction → NO_COVERAGE 4. setCode : negated conditional → NO_COVERAGE |
else if (next - end - 1 + sai.length() != len) |
763 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("invalid.ai.length.1", sai)); | |
764 | } | |
765 |
1
1. setCode : removed call to com/lowagie/text/pdf/Barcode::setCode → NO_COVERAGE |
super.setCode(ret); |
766 | } | |
767 | else | |
768 |
1
1. setCode : removed call to com/lowagie/text/pdf/Barcode::setCode → NO_COVERAGE |
super.setCode(code); |
769 | } | |
770 | | |
771 | static { | |
772 | ais.put(0, 20); | |
773 | ais.put(1, 16); | |
774 | ais.put(2, 16); | |
775 | ais.put(10, -1); | |
776 | ais.put(11, 9); | |
777 | ais.put(12, 8); | |
778 | ais.put(13, 8); | |
779 | ais.put(15, 8); | |
780 | ais.put(17, 8); | |
781 | ais.put(20, 4); | |
782 | ais.put(21, -1); | |
783 | ais.put(22, -1); | |
784 | ais.put(23, -1); | |
785 | ais.put(240, -1); | |
786 | ais.put(241, -1); | |
787 | ais.put(250, -1); | |
788 | ais.put(251, -1); | |
789 | ais.put(252, -1); | |
790 | ais.put(30, -1); | |
791 | for (int k = 3100; k < 3700; ++k) | |
792 | ais.put(k, 10); | |
793 | ais.put(37, -1); | |
794 | for (int k = 3900; k < 3940; ++k) | |
795 | ais.put(k, -1); | |
796 | ais.put(400, -1); | |
797 | ais.put(401, -1); | |
798 | ais.put(402, 20); | |
799 | ais.put(403, -1); | |
800 | for (int k = 410; k < 416; ++k) | |
801 | ais.put(k, 16); | |
802 | ais.put(420, -1); | |
803 | ais.put(421, -1); | |
804 | ais.put(422, 6); | |
805 | ais.put(423, -1); | |
806 | ais.put(424, 6); | |
807 | ais.put(425, 6); | |
808 | ais.put(426, 6); | |
809 | ais.put(7001, 17); | |
810 | ais.put(7002, -1); | |
811 | for (int k = 7030; k < 7040; ++k) | |
812 | ais.put(k, -1); | |
813 | ais.put(8001, 18); | |
814 | ais.put(8002, -1); | |
815 | ais.put(8003, -1); | |
816 | ais.put(8004, -1); | |
817 | ais.put(8005, 10); | |
818 | ais.put(8006, 22); | |
819 | ais.put(8007, -1); | |
820 | ais.put(8008, -1); | |
821 | ais.put(8018, 22); | |
822 | ais.put(8020, -1); | |
823 | ais.put(8100, 10); | |
824 | ais.put(8101, 14); | |
825 | ais.put(8102, 6); | |
826 | for (int k = 90; k < 100; ++k) | |
827 | ais.put(k, -1); | |
828 | } | |
829 | } | |
Mutations | ||
243 |
1.1 |
|
260 |
1.1 2.2 3.3 |
|
262 |
1.1 2.2 3.3 4.4 |
|
265 |
1.1 |
|
278 |
1.1 |
|
284 |
1.1 2.2 3.3 |
|
285 |
1.1 2.2 |
|
287 |
1.1 |
|
292 |
1.1 |
|
296 |
1.1 2.2 |
|
297 |
1.1 |
|
298 |
1.1 2.2 |
|
305 |
1.1 2.2 |
|
308 |
1.1 |
|
316 |
1.1 |
|
328 |
1.1 2.2 3.3 4.4 |
|
329 |
1.1 |
|
330 |
1.1 |
|
334 |
1.1 2.2 3.3 |
|
335 |
1.1 |
|
336 |
1.1 2.2 3.3 |
|
337 |
1.1 |
|
338 |
1.1 2.2 3.3 4.4 |
|
339 |
1.1 |
|
340 |
1.1 |
|
343 |
1.1 2.2 |
|
356 |
1.1 2.2 |
|
357 |
1.1 |
|
359 |
1.1 |
|
362 |
1.1 |
|
363 |
1.1 2.2 |
|
364 |
1.1 2.2 |
|
365 |
1.1 2.2 |
|
367 |
1.1 2.2 |
|
380 |
1.1 |
|
382 |
1.1 |
|
384 |
1.1 |
|
387 |
1.1 2.2 3.3 |
|
389 |
1.1 2.2 3.3 |
|
395 |
1.1 |
|
398 |
1.1 |
|
401 |
1.1 |
|
404 |
1.1 2.2 |
|
407 |
1.1 |
|
409 |
1.1 |
|
410 |
1.1 |
|
414 |
1.1 |
|
416 |
1.1 |
|
419 |
1.1 |
|
420 |
1.1 |
|
422 |
1.1 2.2 |
|
426 |
1.1 |
|
430 |
1.1 |
|
434 |
1.1 |
|
435 |
1.1 |
|
437 |
1.1 2.2 |
|
440 |
1.1 |
|
442 |
1.1 2.2 |
|
443 |
1.1 |
|
445 |
1.1 |
|
451 |
1.1 |
|
455 |
1.1 |
|
459 |
1.1 |
|
460 |
1.1 |
|
462 |
1.1 2.2 |
|
465 |
1.1 |
|
468 |
1.1 |
|
475 |
1.1 |
|
477 |
1.1 |
|
481 |
1.1 |
|
482 |
1.1 |
|
484 |
1.1 2.2 |
|
487 |
1.1 |
|
492 |
1.1 |
|
499 |
1.1 |
|
509 |
1.1 2.2 |
|
512 |
1.1 2.2 3.3 |
|
513 |
1.1 2.2 |
|
514 |
1.1 |
|
516 |
1.1 2.2 3.3 |
|
518 |
1.1 2.2 |
|
519 |
1.1 2.2 |
|
520 |
1.1 2.2 |
|
521 |
1.1 |
|
532 |
1.1 |
|
533 |
1.1 2.2 |
|
534 |
1.1 |
|
536 |
1.1 2.2 |
|
537 |
1.1 |
|
539 |
1.1 2.2 |
|
542 |
1.1 |
|
544 |
1.1 |
|
548 |
1.1 |
|
550 |
1.1 |
|
552 |
1.1 2.2 |
|
558 |
1.1 |
|
561 |
1.1 2.2 3.3 4.4 5.5 |
|
563 |
1.1 |
|
564 |
1.1 |
|
605 |
1.1 |
|
607 |
1.1 2.2 |
|
610 |
1.1 |
|
612 |
1.1 |
|
617 |
1.1 |
|
618 |
1.1 |
|
621 |
1.1 |
|
623 |
1.1 2.2 |
|
629 |
1.1 |
|
632 |
1.1 2.2 3.3 4.4 5.5 |
|
639 |
1.1 2.2 |
|
640 |
1.1 |
|
642 |
1.1 |
|
645 |
1.1 2.2 |
|
646 |
1.1 2.2 |
|
648 |
1.1 2.2 |
|
653 |
1.1 |
|
654 |
1.1 2.2 |
|
655 |
1.1 |
|
657 |
1.1 |
|
658 |
1.1 |
|
663 |
1.1 |
|
664 |
1.1 |
|
666 |
1.1 |
|
667 |
1.1 |
|
668 |
1.1 2.2 |
|
669 |
1.1 |
|
670 |
1.1 |
|
672 |
1.1 |
|
673 |
1.1 |
|
674 |
1.1 |
|
675 |
1.1 |
|
676 |
1.1 |
|
677 |
1.1 |
|
678 |
1.1 |
|
679 |
1.1 |
|
680 |
1.1 |
|
682 |
1.1 |
|
696 |
1.1 |
|
698 |
1.1 2.2 |
|
704 |
1.1 |
|
707 |
1.1 2.2 3.3 |
|
713 |
1.1 |
|
716 |
1.1 |
|
718 |
1.1 |
|
719 |
1.1 2.2 3.3 |
|
720 |
1.1 |
|
722 |
1.1 2.2 3.3 |
|
723 |
1.1 |
|
727 |
1.1 |
|
738 |
1.1 2.2 |
|
741 |
1.1 2.2 |
|
743 |
1.1 2.2 |
|
745 |
1.1 |
|
746 |
1.1 2.2 |
|
750 |
1.1 |
|
753 |
1.1 |
|
756 |
1.1 2.2 |
|
757 |
1.1 |
|
758 |
1.1 2.2 |
|
759 |
1.1 2.2 |
|
762 |
1.1 2.2 3.3 4.4 |
|
765 |
1.1 |
|
768 |
1.1 |