1 | /* | |
2 | * $Id: Markup.java 3654 2009-01-21 16:11:00Z blowagie $ | |
3 | * | |
4 | * Copyright 2001, 2002 by Bruno Lowagie. | |
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 | * Contributions by: | |
46 | * Lubos Strapko | |
47 | * | |
48 | * If you didn't download this code from the following link, you should check if | |
49 | * you aren't using an obsolete version: | |
50 | * http://www.lowagie.com/iText/ | |
51 | */ | |
52 | ||
53 | package com.lowagie.text.html; | |
54 | ||
55 | import java.awt.Color; | |
56 | import java.util.Locale; | |
57 | import java.util.Properties; | |
58 | import java.util.StringTokenizer; | |
59 | ||
60 | /** | |
61 | * A class that contains all the possible tagnames and their attributes. | |
62 | */ | |
63 | ||
64 | public class Markup { | |
65 | ||
66 | // iText specific | |
67 | ||
68 | /** the key for any tag */ | |
69 | public static final String ITEXT_TAG = "tag"; | |
70 | ||
71 | // HTML tags | |
72 | ||
73 | /** the markup for the body part of a file */ | |
74 | public static final String HTML_TAG_BODY = "body"; | |
75 | ||
76 | /** The DIV tag. */ | |
77 | public static final String HTML_TAG_DIV = "div"; | |
78 | ||
79 | /** This is a possible HTML-tag. */ | |
80 | public static final String HTML_TAG_LINK = "link"; | |
81 | ||
82 | /** The SPAN tag. */ | |
83 | public static final String HTML_TAG_SPAN = "span"; | |
84 | ||
85 | // HTML attributes | |
86 | ||
87 | /** the height attribute. */ | |
88 | public static final String HTML_ATTR_HEIGHT = "height"; | |
89 | ||
90 | /** the hyperlink reference attribute. */ | |
91 | public static final String HTML_ATTR_HREF = "href"; | |
92 | ||
93 | /** This is a possible HTML attribute for the LINK tag. */ | |
94 | public static final String HTML_ATTR_REL = "rel"; | |
95 | ||
96 | /** This is used for inline css style information */ | |
97 | public static final String HTML_ATTR_STYLE = "style"; | |
98 | ||
99 | /** This is a possible HTML attribute for the LINK tag. */ | |
100 | public static final String HTML_ATTR_TYPE = "type"; | |
101 | ||
102 | /** This is a possible HTML attribute. */ | |
103 | public static final String HTML_ATTR_STYLESHEET = "stylesheet"; | |
104 | ||
105 | /** the width attribute. */ | |
106 | public static final String HTML_ATTR_WIDTH = "width"; | |
107 | ||
108 | /** attribute for specifying externally defined CSS class */ | |
109 | public static final String HTML_ATTR_CSS_CLASS = "class"; | |
110 | ||
111 | /** The ID attribute. */ | |
112 | public static final String HTML_ATTR_CSS_ID = "id"; | |
113 | ||
114 | // HTML values | |
115 | ||
116 | /** This is a possible value for the language attribute (SCRIPT tag). */ | |
117 | public static final String HTML_VALUE_JAVASCRIPT = "text/javascript"; | |
118 | ||
119 | /** This is a possible HTML attribute for the LINK tag. */ | |
120 | public static final String HTML_VALUE_CSS = "text/css"; | |
121 | ||
122 | // CSS keys | |
123 | ||
124 | /** the CSS tag for background color */ | |
125 | public static final String CSS_KEY_BGCOLOR = "background-color"; | |
126 | ||
127 | /** the CSS tag for text color */ | |
128 | public static final String CSS_KEY_COLOR = "color"; | |
129 | ||
130 | /** CSS key that indicate the way something has to be displayed */ | |
131 | public static final String CSS_KEY_DISPLAY = "display"; | |
132 | ||
133 | /** the CSS tag for the font family */ | |
134 | public static final String CSS_KEY_FONTFAMILY = "font-family"; | |
135 | ||
136 | /** the CSS tag for the font size */ | |
137 | public static final String CSS_KEY_FONTSIZE = "font-size"; | |
138 | ||
139 | /** the CSS tag for the font style */ | |
140 | public static final String CSS_KEY_FONTSTYLE = "font-style"; | |
141 | ||
142 | /** the CSS tag for the font weight */ | |
143 | public static final String CSS_KEY_FONTWEIGHT = "font-weight"; | |
144 | ||
145 | /** the CSS tag for text decorations */ | |
146 | public static final String CSS_KEY_LINEHEIGHT = "line-height"; | |
147 | ||
148 | /** the CSS tag for the margin of an object */ | |
149 | public static final String CSS_KEY_MARGIN = "margin"; | |
150 | ||
151 | /** the CSS tag for the margin of an object */ | |
152 | public static final String CSS_KEY_MARGINLEFT = "margin-left"; | |
153 | ||
154 | /** the CSS tag for the margin of an object */ | |
155 | public static final String CSS_KEY_MARGINRIGHT = "margin-right"; | |
156 | ||
157 | /** the CSS tag for the margin of an object */ | |
158 | public static final String CSS_KEY_MARGINTOP = "margin-top"; | |
159 | ||
160 | /** the CSS tag for the margin of an object */ | |
161 | public static final String CSS_KEY_MARGINBOTTOM = "margin-bottom"; | |
162 | ||
163 | /** the CSS tag for the margin of an object */ | |
164 | public static final String CSS_KEY_PADDING = "padding"; | |
165 | ||
166 | /** the CSS tag for the margin of an object */ | |
167 | public static final String CSS_KEY_PADDINGLEFT = "padding-left"; | |
168 | ||
169 | /** the CSS tag for the margin of an object */ | |
170 | public static final String CSS_KEY_PADDINGRIGHT = "padding-right"; | |
171 | ||
172 | /** the CSS tag for the margin of an object */ | |
173 | public static final String CSS_KEY_PADDINGTOP = "padding-top"; | |
174 | ||
175 | /** the CSS tag for the margin of an object */ | |
176 | public static final String CSS_KEY_PADDINGBOTTOM = "padding-bottom"; | |
177 | ||
178 | /** the CSS tag for the margin of an object */ | |
179 | public static final String CSS_KEY_BORDERCOLOR = "border-color"; | |
180 | ||
181 | /** the CSS tag for the margin of an object */ | |
182 | public static final String CSS_KEY_BORDERWIDTH = "border-width"; | |
183 | ||
184 | /** the CSS tag for the margin of an object */ | |
185 | public static final String CSS_KEY_BORDERWIDTHLEFT = "border-left-width"; | |
186 | ||
187 | /** the CSS tag for the margin of an object */ | |
188 | public static final String CSS_KEY_BORDERWIDTHRIGHT = "border-right-width"; | |
189 | ||
190 | /** the CSS tag for the margin of an object */ | |
191 | public static final String CSS_KEY_BORDERWIDTHTOP = "border-top-width"; | |
192 | ||
193 | /** the CSS tag for the margin of an object */ | |
194 | public static final String CSS_KEY_BORDERWIDTHBOTTOM = "border-bottom-width"; | |
195 | ||
196 | /** the CSS tag for adding a page break when the document is printed */ | |
197 | public static final String CSS_KEY_PAGE_BREAK_AFTER = "page-break-after"; | |
198 | ||
199 | /** the CSS tag for adding a page break when the document is printed */ | |
200 | public static final String CSS_KEY_PAGE_BREAK_BEFORE = "page-break-before"; | |
201 | ||
202 | /** the CSS tag for the horizontal alignment of an object */ | |
203 | public static final String CSS_KEY_TEXTALIGN = "text-align"; | |
204 | ||
205 | /** the CSS tag for text decorations */ | |
206 | public static final String CSS_KEY_TEXTDECORATION = "text-decoration"; | |
207 | ||
208 | /** the CSS tag for text decorations */ | |
209 | public static final String CSS_KEY_VERTICALALIGN = "vertical-align"; | |
210 | ||
211 | /** the CSS tag for the visibility of objects */ | |
212 | public static final String CSS_KEY_VISIBILITY = "visibility"; | |
213 | ||
214 | // CSS values | |
215 | ||
216 | /** | |
217 | * value for the CSS tag for adding a page break when the document is | |
218 | * printed | |
219 | */ | |
220 | public static final String CSS_VALUE_ALWAYS = "always"; | |
221 | ||
222 | /** A possible value for the DISPLAY key */ | |
223 | public static final String CSS_VALUE_BLOCK = "block"; | |
224 | ||
225 | /** a CSS value for text font weight */ | |
226 | public static final String CSS_VALUE_BOLD = "bold"; | |
227 | ||
228 | /** the value if you want to hide objects. */ | |
229 | public static final String CSS_VALUE_HIDDEN = "hidden"; | |
230 | ||
231 | /** A possible value for the DISPLAY key */ | |
232 | public static final String CSS_VALUE_INLINE = "inline"; | |
233 | ||
234 | /** a CSS value for text font style */ | |
235 | public static final String CSS_VALUE_ITALIC = "italic"; | |
236 | ||
237 | /** a CSS value for text decoration */ | |
238 | public static final String CSS_VALUE_LINETHROUGH = "line-through"; | |
239 | ||
240 | /** A possible value for the DISPLAY key */ | |
241 | public static final String CSS_VALUE_LISTITEM = "list-item"; | |
242 | ||
243 | /** a CSS value */ | |
244 | public static final String CSS_VALUE_NONE = "none"; | |
245 | ||
246 | /** a CSS value */ | |
247 | public static final String CSS_VALUE_NORMAL = "normal"; | |
248 | ||
249 | /** a CSS value for text font style */ | |
250 | public static final String CSS_VALUE_OBLIQUE = "oblique"; | |
251 | ||
252 | /** A possible value for the DISPLAY key */ | |
253 | public static final String CSS_VALUE_TABLE = "table"; | |
254 | ||
255 | /** A possible value for the DISPLAY key */ | |
256 | public static final String CSS_VALUE_TABLEROW = "table-row"; | |
257 | ||
258 | /** A possible value for the DISPLAY key */ | |
259 | public static final String CSS_VALUE_TABLECELL = "table-cell"; | |
260 | ||
261 | /** the CSS value for a horizontal alignment of an object */ | |
262 | public static final String CSS_VALUE_TEXTALIGNLEFT = "left"; | |
263 | ||
264 | /** the CSS value for a horizontal alignment of an object */ | |
265 | public static final String CSS_VALUE_TEXTALIGNRIGHT = "right"; | |
266 | ||
267 | /** the CSS value for a horizontal alignment of an object */ | |
268 | public static final String CSS_VALUE_TEXTALIGNCENTER = "center"; | |
269 | ||
270 | /** the CSS value for a horizontal alignment of an object */ | |
271 | public static final String CSS_VALUE_TEXTALIGNJUSTIFY = "justify"; | |
272 | ||
273 | /** a CSS value for text decoration */ | |
274 | public static final String CSS_VALUE_UNDERLINE = "underline"; | |
275 | ||
276 | /** a default value for font-size | |
277 | * @since 2.1.3 | |
278 | */ | |
279 | public static final float DEFAULT_FONT_SIZE = 12f; | |
280 | ||
281 | /** | |
282 | * Parses a length. | |
283 | * | |
284 | * @param string | |
285 | * a length in the form of an optional + or -, followed by a | |
286 | * number and a unit. | |
287 | * @return a float | |
288 | */ | |
289 | ||
290 | public static float parseLength(String string) { | |
291 | // TODO: Evaluate the effect of this. | |
292 | // It may change the default behavour of the methd if this is changed. | |
293 | // return parseLength(string, Markup.DEFAULT_FONT_SIZE); | |
294 | int pos = 0; | |
295 | int length = string.length(); | |
296 | boolean ok = true; | |
297 |
3
1. parseLength : changed conditional boundary → NO_COVERAGE 2. parseLength : negated conditional → NO_COVERAGE 3. parseLength : negated conditional → NO_COVERAGE |
while (ok && pos < length) { |
298 | switch (string.charAt(pos)) { | |
299 | case '+': | |
300 | case '-': | |
301 | case '0': | |
302 | case '1': | |
303 | case '2': | |
304 | case '3': | |
305 | case '4': | |
306 | case '5': | |
307 | case '6': | |
308 | case '7': | |
309 | case '8': | |
310 | case '9': | |
311 | case '.': | |
312 |
1
1. parseLength : Changed increment from 1 to -1 → NO_COVERAGE |
pos++; |
313 | break; | |
314 | default: | |
315 | ok = false; | |
316 | } | |
317 | } | |
318 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (pos == 0) |
319 |
1
1. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return 0f; |
320 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (pos == length) |
321 |
1
1. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return Float.parseFloat(string + "f"); |
322 | float f = Float.parseFloat(string.substring(0, pos) + "f"); | |
323 | string = string.substring(pos); | |
324 | // inches | |
325 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("in")) { |
326 |
2
1. parseLength : Replaced float multiplication with division → NO_COVERAGE 2. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return f * 72f; |
327 | } | |
328 | // centimeters | |
329 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("cm")) { |
330 |
3
1. parseLength : Replaced float division with multiplication → NO_COVERAGE 2. parseLength : Replaced float multiplication with division → NO_COVERAGE 3. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return (f / 2.54f) * 72f; |
331 | } | |
332 | // millimeters | |
333 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("mm")) { |
334 |
3
1. parseLength : Replaced float division with multiplication → NO_COVERAGE 2. parseLength : Replaced float multiplication with division → NO_COVERAGE 3. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return (f / 25.4f) * 72f; |
335 | } | |
336 | // picas | |
337 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("pc")) { |
338 |
2
1. parseLength : Replaced float multiplication with division → NO_COVERAGE 2. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return f * 12f; |
339 | } | |
340 | // default: we assume the length was measured in points | |
341 |
1
1. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return f; |
342 | } | |
343 | ||
344 | /** | |
345 | * New method contributed by: Lubos Strapko | |
346 | * | |
347 | * @since 2.1.3 | |
348 | */ | |
349 | public static float parseLength(String string, float actualFontSize) { | |
350 |
1
1. parseLength : negated conditional → KILLED |
if (string == null) |
351 |
1
1. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → SURVIVED |
return 0f; |
352 | int pos = 0; | |
353 | int length = string.length(); | |
354 | boolean ok = true; | |
355 |
3
1. parseLength : changed conditional boundary → KILLED 2. parseLength : negated conditional → KILLED 3. parseLength : negated conditional → KILLED |
while (ok && pos < length) { |
356 | switch (string.charAt(pos)) { | |
357 | case '+': | |
358 | case '-': | |
359 | case '0': | |
360 | case '1': | |
361 | case '2': | |
362 | case '3': | |
363 | case '4': | |
364 | case '5': | |
365 | case '6': | |
366 | case '7': | |
367 | case '8': | |
368 | case '9': | |
369 | case '.': | |
370 |
1
1. parseLength : Changed increment from 1 to -1 → KILLED |
pos++; |
371 | break; | |
372 | default: | |
373 | ok = false; | |
374 | } | |
375 | } | |
376 |
1
1. parseLength : negated conditional → KILLED |
if (pos == 0) |
377 |
1
1. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return 0f; |
378 |
1
1. parseLength : negated conditional → SURVIVED |
if (pos == length) |
379 |
1
1. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → KILLED |
return Float.parseFloat(string + "f"); |
380 | float f = Float.parseFloat(string.substring(0, pos) + "f"); | |
381 | string = string.substring(pos); | |
382 | // inches | |
383 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("in")) { |
384 |
2
1. parseLength : Replaced float multiplication with division → NO_COVERAGE 2. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return f * 72f; |
385 | } | |
386 | // centimeters | |
387 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("cm")) { |
388 |
3
1. parseLength : Replaced float division with multiplication → NO_COVERAGE 2. parseLength : Replaced float multiplication with division → NO_COVERAGE 3. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return (f / 2.54f) * 72f; |
389 | } | |
390 | // millimeters | |
391 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("mm")) { |
392 |
3
1. parseLength : Replaced float division with multiplication → NO_COVERAGE 2. parseLength : Replaced float multiplication with division → NO_COVERAGE 3. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return (f / 25.4f) * 72f; |
393 | } | |
394 | // picas | |
395 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("pc")) { |
396 |
2
1. parseLength : Replaced float multiplication with division → NO_COVERAGE 2. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return f * 12f; |
397 | } | |
398 | // 1em is equal to the current font size | |
399 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("em")) { |
400 |
2
1. parseLength : Replaced float multiplication with division → NO_COVERAGE 2. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return f * actualFontSize; |
401 | } | |
402 | // one ex is the x-height of a font (x-height is usually about half the | |
403 | // font-size) | |
404 |
1
1. parseLength : negated conditional → NO_COVERAGE |
if (string.startsWith("ex")) { |
405 |
3
1. parseLength : Replaced float multiplication with division → NO_COVERAGE 2. parseLength : Replaced float division with multiplication → NO_COVERAGE 3. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return f * actualFontSize / 2; |
406 | } | |
407 | // default: we assume the length was measured in points | |
408 |
1
1. parseLength : replaced return of float value with -(x + 1) for com/lowagie/text/html/Markup::parseLength → NO_COVERAGE |
return f; |
409 | } | |
410 | ||
411 | /** | |
412 | * Converts a <CODE>Color</CODE> into a HTML representation of this <CODE> | |
413 | * Color</CODE>. | |
414 | * | |
415 | * @param s | |
416 | * the <CODE>Color</CODE> that has to be converted. | |
417 | * @return the HTML representation of this <COLOR>Color </COLOR> | |
418 | */ | |
419 | ||
420 | public static Color decodeColor(String s) { | |
421 |
1
1. decodeColor : negated conditional → KILLED |
if (s == null) |
422 |
1
1. decodeColor : mutated return of Object value for com/lowagie/text/html/Markup::decodeColor to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return null; |
423 | s = s.toLowerCase(Locale.ROOT).trim(); | |
424 | try { | |
425 |
1
1. decodeColor : mutated return of Object value for com/lowagie/text/html/Markup::decodeColor to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return WebColors.getRGBColor(s); |
426 | } | |
427 | catch(IllegalArgumentException iae) { | |
428 |
1
1. decodeColor : mutated return of Object value for com/lowagie/text/html/Markup::decodeColor to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
429 | } | |
430 | } | |
431 | ||
432 | /** | |
433 | * This method parses a String with attributes and returns a Properties | |
434 | * object. | |
435 | * | |
436 | * @param string | |
437 | * a String of this form: 'key1="value1"; key2="value2";... | |
438 | * keyN="valueN" ' | |
439 | * @return a Properties object | |
440 | */ | |
441 | public static Properties parseAttributes(String string) { | |
442 | Properties result = new Properties(); | |
443 |
1
1. parseAttributes : negated conditional → KILLED |
if (string == null) |
444 |
1
1. parseAttributes : mutated return of Object value for com/lowagie/text/html/Markup::parseAttributes to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return result; |
445 | StringTokenizer keyValuePairs = new StringTokenizer(string, ";"); | |
446 | StringTokenizer keyValuePair; | |
447 | String key; | |
448 | String value; | |
449 |
1
1. parseAttributes : negated conditional → KILLED |
while (keyValuePairs.hasMoreTokens()) { |
450 | keyValuePair = new StringTokenizer(keyValuePairs.nextToken(), ":"); | |
451 |
1
1. parseAttributes : negated conditional → KILLED |
if (keyValuePair.hasMoreTokens()) |
452 | key = keyValuePair.nextToken().trim(); | |
453 | else | |
454 | continue; | |
455 |
1
1. parseAttributes : negated conditional → KILLED |
if (keyValuePair.hasMoreTokens()) |
456 | value = keyValuePair.nextToken().trim(); | |
457 | else | |
458 | continue; | |
459 |
1
1. parseAttributes : negated conditional → KILLED |
if (value.startsWith("\"")) |
460 | value = value.substring(1); | |
461 |
1
1. parseAttributes : negated conditional → KILLED |
if (value.endsWith("\"")) |
462 |
1
1. parseAttributes : Replaced integer subtraction with addition → NO_COVERAGE |
value = value.substring(0, value.length() - 1); |
463 | result.setProperty(key.toLowerCase(Locale.ROOT), value); | |
464 | } | |
465 |
1
1. parseAttributes : mutated return of Object value for com/lowagie/text/html/Markup::parseAttributes to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return result; |
466 | } | |
467 | ||
468 | /** | |
469 | * Removes the comments sections of a String. | |
470 | * | |
471 | * @param string | |
472 | * the original String | |
473 | * @param startComment | |
474 | * the String that marks the start of a Comment section | |
475 | * @param endComment | |
476 | * the String that marks the end of a Comment section. | |
477 | * @return the String stripped of its comment section | |
478 | */ | |
479 | public static String removeComment(String string, String startComment, | |
480 | String endComment) { | |
481 | StringBuilder result = new StringBuilder(); | |
482 | int pos = 0; | |
483 | int end = endComment.length(); | |
484 | int start = string.indexOf(startComment, pos); | |
485 |
2
1. removeComment : changed conditional boundary → NO_COVERAGE 2. removeComment : negated conditional → NO_COVERAGE |
while (start > -1) { |
486 | result.append(string, pos, start); | |
487 |
1
1. removeComment : Replaced integer addition with subtraction → NO_COVERAGE |
pos = string.indexOf(endComment, start) + end; |
488 | start = string.indexOf(startComment, pos); | |
489 | } | |
490 | result.append(string.substring(pos)); | |
491 |
1
1. removeComment : mutated return of Object value for com/lowagie/text/html/Markup::removeComment to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return result.toString(); |
492 | } | |
493 | ||
494 | } | |
Mutations | ||
297 |
1.1 2.2 3.3 |
|
312 |
1.1 |
|
318 |
1.1 |
|
319 |
1.1 |
|
320 |
1.1 |
|
321 |
1.1 |
|
325 |
1.1 |
|
326 |
1.1 2.2 |
|
329 |
1.1 |
|
330 |
1.1 2.2 3.3 |
|
333 |
1.1 |
|
334 |
1.1 2.2 3.3 |
|
337 |
1.1 |
|
338 |
1.1 2.2 |
|
341 |
1.1 |
|
350 |
1.1 |
|
351 |
1.1 |
|
355 |
1.1 2.2 3.3 |
|
370 |
1.1 |
|
376 |
1.1 |
|
377 |
1.1 |
|
378 |
1.1 |
|
379 |
1.1 |
|
383 |
1.1 |
|
384 |
1.1 2.2 |
|
387 |
1.1 |
|
388 |
1.1 2.2 3.3 |
|
391 |
1.1 |
|
392 |
1.1 2.2 3.3 |
|
395 |
1.1 |
|
396 |
1.1 2.2 |
|
399 |
1.1 |
|
400 |
1.1 2.2 |
|
404 |
1.1 |
|
405 |
1.1 2.2 3.3 |
|
408 |
1.1 |
|
421 |
1.1 |
|
422 |
1.1 |
|
425 |
1.1 |
|
428 |
1.1 |
|
443 |
1.1 |
|
444 |
1.1 |
|
449 |
1.1 |
|
451 |
1.1 |
|
455 |
1.1 |
|
459 |
1.1 |
|
461 |
1.1 |
|
462 |
1.1 |
|
465 |
1.1 |
|
485 |
1.1 2.2 |
|
487 |
1.1 |
|
491 |
1.1 |