1 | /* | |
2 | * $Id: ElementFactory.java 4065 2009-09-16 23:09:11Z psoares33 $ | |
3 | * | |
4 | * Copyright 2007 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 | package com.lowagie.text.factories; | |
53 | ||
54 | import java.awt.Color; | |
55 | import java.io.IOException; | |
56 | import java.net.MalformedURLException; | |
57 | import java.util.ArrayList; | |
58 | import java.util.Properties; | |
59 | import java.util.StringTokenizer; | |
60 | import com.lowagie.text.error_messages.MessageLocalization; | |
61 | ||
62 | import com.lowagie.text.Anchor; | |
63 | import com.lowagie.text.Annotation; | |
64 | import com.lowagie.text.BadElementException; | |
65 | import com.lowagie.text.Cell; | |
66 | import com.lowagie.text.ChapterAutoNumber; | |
67 | import com.lowagie.text.Chunk; | |
68 | import com.lowagie.text.ElementTags; | |
69 | ||
70 | import com.lowagie.text.FontFactory; | |
71 | import com.lowagie.text.Image; | |
72 | import com.lowagie.text.List; | |
73 | import com.lowagie.text.ListItem; | |
74 | import com.lowagie.text.Paragraph; | |
75 | import com.lowagie.text.Phrase; | |
76 | import com.lowagie.text.Rectangle; | |
77 | import com.lowagie.text.Section; | |
78 | import com.lowagie.text.Table; | |
79 | import com.lowagie.text.Utilities; | |
80 | import com.lowagie.text.ExceptionConverter; | |
81 | import com.lowagie.text.html.Markup; | |
82 | ||
83 | /** | |
84 | * This class is able to create Element objects based on a list of properties. | |
85 | */ | |
86 | public class ElementFactory { | |
87 | ||
88 | /** | |
89 | * Creates a Chunk object based on a list of properties. | |
90 | * @param attributes | |
91 | * @return a Chunk | |
92 | */ | |
93 | public static Chunk getChunk(Properties attributes) { | |
94 | Chunk chunk = new Chunk(); | |
95 | ||
96 |
1
1. getChunk : removed call to com/lowagie/text/Chunk::setFont → NO_COVERAGE |
chunk.setFont(FontFactory.getFont(attributes)); |
97 | String value; | |
98 | ||
99 | value = attributes.getProperty(ElementTags.ITEXT); | |
100 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (value != null) { |
101 | chunk.append(value); | |
102 | } | |
103 | value = attributes.getProperty(ElementTags.LOCALGOTO); | |
104 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (value != null) { |
105 | chunk.setLocalGoto(value); | |
106 | } | |
107 | value = attributes.getProperty(ElementTags.REMOTEGOTO); | |
108 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (value != null) { |
109 | String page = attributes.getProperty(ElementTags.PAGE); | |
110 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (page != null) { |
111 | chunk.setRemoteGoto(value, Integer.parseInt(page)); | |
112 | } else { | |
113 | String destination = attributes | |
114 | .getProperty(ElementTags.DESTINATION); | |
115 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (destination != null) { |
116 | chunk.setRemoteGoto(value, destination); | |
117 | } | |
118 | } | |
119 | } | |
120 | value = attributes.getProperty(ElementTags.LOCALDESTINATION); | |
121 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (value != null) { |
122 | chunk.setLocalDestination(value); | |
123 | } | |
124 | value = attributes.getProperty(ElementTags.SUBSUPSCRIPT); | |
125 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (value != null) { |
126 | chunk.setTextRise(Float.parseFloat(value + "f")); | |
127 | } | |
128 | value = attributes.getProperty(Markup.CSS_KEY_VERTICALALIGN); | |
129 |
2
1. getChunk : negated conditional → NO_COVERAGE 2. getChunk : negated conditional → NO_COVERAGE |
if (value != null && value.endsWith("%")) { |
130 |
2
1. getChunk : Replaced integer subtraction with addition → NO_COVERAGE 2. getChunk : Replaced float division with multiplication → NO_COVERAGE |
float p = Float.parseFloat(value.substring(0, value.length() - 1) |
131 | + "f") / 100f; | |
132 |
1
1. getChunk : Replaced float multiplication with division → NO_COVERAGE |
chunk.setTextRise(p * chunk.getFont().getSize()); |
133 | } | |
134 | value = attributes.getProperty(ElementTags.GENERICTAG); | |
135 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (value != null) { |
136 | chunk.setGenericTag(value); | |
137 | } | |
138 | value = attributes.getProperty(ElementTags.BACKGROUNDCOLOR); | |
139 |
1
1. getChunk : negated conditional → NO_COVERAGE |
if (value != null) { |
140 | chunk.setBackground(Markup.decodeColor(value)); | |
141 | } | |
142 |
1
1. getChunk : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getChunk to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return chunk; |
143 | } | |
144 | ||
145 | /** | |
146 | * Creates a Phrase object based on a list of properties. | |
147 | * @param attributes | |
148 | * @return a Phrase | |
149 | */ | |
150 | public static Phrase getPhrase(Properties attributes) { | |
151 | Phrase phrase = new Phrase(); | |
152 |
1
1. getPhrase : removed call to com/lowagie/text/Phrase::setFont → NO_COVERAGE |
phrase.setFont(FontFactory.getFont(attributes)); |
153 | String value; | |
154 | value = attributes.getProperty(ElementTags.LEADING); | |
155 |
1
1. getPhrase : negated conditional → NO_COVERAGE |
if (value != null) { |
156 |
1
1. getPhrase : removed call to com/lowagie/text/Phrase::setLeading → NO_COVERAGE |
phrase.setLeading(Float.parseFloat(value + "f")); |
157 | } | |
158 | value = attributes.getProperty(Markup.CSS_KEY_LINEHEIGHT); | |
159 |
1
1. getPhrase : negated conditional → NO_COVERAGE |
if (value != null) { |
160 |
1
1. getPhrase : removed call to com/lowagie/text/Phrase::setLeading → NO_COVERAGE |
phrase.setLeading(Markup.parseLength(value, |
161 | Markup.DEFAULT_FONT_SIZE)); | |
162 | } | |
163 | value = attributes.getProperty(ElementTags.ITEXT); | |
164 |
1
1. getPhrase : negated conditional → NO_COVERAGE |
if (value != null) { |
165 | Chunk chunk = new Chunk(value); | |
166 |
1
1. getPhrase : negated conditional → NO_COVERAGE |
if ((value = attributes.getProperty(ElementTags.GENERICTAG)) != null) { |
167 | chunk.setGenericTag(value); | |
168 | } | |
169 | phrase.add(chunk); | |
170 | } | |
171 |
1
1. getPhrase : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getPhrase to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return phrase; |
172 | } | |
173 | ||
174 | /** | |
175 | * Creates an Anchor object based on a list of properties. | |
176 | * @param attributes | |
177 | * @return an Anchor | |
178 | */ | |
179 | public static Anchor getAnchor(Properties attributes) { | |
180 | Anchor anchor = new Anchor(getPhrase(attributes)); | |
181 | String value; | |
182 | value = attributes.getProperty(ElementTags.NAME); | |
183 |
1
1. getAnchor : negated conditional → NO_COVERAGE |
if (value != null) { |
184 |
1
1. getAnchor : removed call to com/lowagie/text/Anchor::setName → NO_COVERAGE |
anchor.setName(value); |
185 | } | |
186 | value = (String) attributes.remove(ElementTags.REFERENCE); | |
187 |
1
1. getAnchor : negated conditional → NO_COVERAGE |
if (value != null) { |
188 |
1
1. getAnchor : removed call to com/lowagie/text/Anchor::setReference → NO_COVERAGE |
anchor.setReference(value); |
189 | } | |
190 |
1
1. getAnchor : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getAnchor to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return anchor; |
191 | } | |
192 | ||
193 | /** | |
194 | * Creates a Paragraph object based on a list of properties. | |
195 | * @param attributes | |
196 | * @return a Paragraph | |
197 | */ | |
198 | public static Paragraph getParagraph(Properties attributes) { | |
199 | Paragraph paragraph = new Paragraph(getPhrase(attributes)); | |
200 | String value; | |
201 | value = attributes.getProperty(ElementTags.ALIGN); | |
202 |
1
1. getParagraph : negated conditional → NO_COVERAGE |
if (value != null) { |
203 |
1
1. getParagraph : removed call to com/lowagie/text/Paragraph::setAlignment → NO_COVERAGE |
paragraph.setAlignment(value); |
204 | } | |
205 | value = attributes.getProperty(ElementTags.INDENTATIONLEFT); | |
206 |
1
1. getParagraph : negated conditional → NO_COVERAGE |
if (value != null) { |
207 |
1
1. getParagraph : removed call to com/lowagie/text/Paragraph::setIndentationLeft → NO_COVERAGE |
paragraph.setIndentationLeft(Float.parseFloat(value + "f")); |
208 | } | |
209 | value = attributes.getProperty(ElementTags.INDENTATIONRIGHT); | |
210 |
1
1. getParagraph : negated conditional → NO_COVERAGE |
if (value != null) { |
211 |
1
1. getParagraph : removed call to com/lowagie/text/Paragraph::setIndentationRight → NO_COVERAGE |
paragraph.setIndentationRight(Float.parseFloat(value + "f")); |
212 | } | |
213 |
1
1. getParagraph : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getParagraph to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return paragraph; |
214 | } | |
215 | ||
216 | /** | |
217 | * Creates a ListItem object based on a list of properties. | |
218 | * @param attributes | |
219 | * @return a ListItem | |
220 | */ | |
221 | public static ListItem getListItem(Properties attributes) { | |
222 | ListItem item = new ListItem(getParagraph(attributes)); | |
223 |
1
1. getListItem : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getListItem to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return item; |
224 | } | |
225 | ||
226 | /** | |
227 | * Creates a List object based on a list of properties. | |
228 | * @param attributes | |
229 | * @return the List | |
230 | */ | |
231 | public static List getList(Properties attributes) { | |
232 | List list = new List(); | |
233 | ||
234 |
1
1. getList : removed call to com/lowagie/text/List::setNumbered → NO_COVERAGE |
list.setNumbered(Utilities.checkTrueOrFalse(attributes, |
235 | ElementTags.NUMBERED)); | |
236 |
1
1. getList : removed call to com/lowagie/text/List::setLettered → NO_COVERAGE |
list.setLettered(Utilities.checkTrueOrFalse(attributes, |
237 | ElementTags.LETTERED)); | |
238 |
1
1. getList : removed call to com/lowagie/text/List::setLowercase → NO_COVERAGE |
list.setLowercase(Utilities.checkTrueOrFalse(attributes, |
239 | ElementTags.LOWERCASE)); | |
240 |
1
1. getList : removed call to com/lowagie/text/List::setAutoindent → NO_COVERAGE |
list.setAutoindent(Utilities.checkTrueOrFalse(attributes, |
241 | ElementTags.AUTO_INDENT_ITEMS)); | |
242 |
1
1. getList : removed call to com/lowagie/text/List::setAlignindent → NO_COVERAGE |
list.setAlignindent(Utilities.checkTrueOrFalse(attributes, |
243 | ElementTags.ALIGN_INDENTATION_ITEMS)); | |
244 | ||
245 | String value; | |
246 | ||
247 | value = attributes.getProperty(ElementTags.FIRST); | |
248 |
1
1. getList : negated conditional → NO_COVERAGE |
if (value != null) { |
249 | char character = value.charAt(0); | |
250 |
1
1. getList : negated conditional → NO_COVERAGE |
if (Character.isLetter(character)) { |
251 |
1
1. getList : removed call to com/lowagie/text/List::setFirst → NO_COVERAGE |
list.setFirst(character); |
252 | } else { | |
253 |
1
1. getList : removed call to com/lowagie/text/List::setFirst → NO_COVERAGE |
list.setFirst(Integer.parseInt(value)); |
254 | } | |
255 | } | |
256 | ||
257 | value = attributes.getProperty(ElementTags.LISTSYMBOL); | |
258 |
1
1. getList : negated conditional → NO_COVERAGE |
if (value != null) { |
259 | list | |
260 |
1
1. getList : removed call to com/lowagie/text/List::setListSymbol → NO_COVERAGE |
.setListSymbol(new Chunk(value, FontFactory |
261 | .getFont(attributes))); | |
262 | } | |
263 | ||
264 | value = attributes.getProperty(ElementTags.INDENTATIONLEFT); | |
265 |
1
1. getList : negated conditional → NO_COVERAGE |
if (value != null) { |
266 |
1
1. getList : removed call to com/lowagie/text/List::setIndentationLeft → NO_COVERAGE |
list.setIndentationLeft(Float.parseFloat(value + "f")); |
267 | } | |
268 | ||
269 | value = attributes.getProperty(ElementTags.INDENTATIONRIGHT); | |
270 |
1
1. getList : negated conditional → NO_COVERAGE |
if (value != null) { |
271 |
1
1. getList : removed call to com/lowagie/text/List::setIndentationRight → NO_COVERAGE |
list.setIndentationRight(Float.parseFloat(value + "f")); |
272 | } | |
273 | ||
274 | value = attributes.getProperty(ElementTags.SYMBOLINDENT); | |
275 |
1
1. getList : negated conditional → NO_COVERAGE |
if (value != null) { |
276 |
1
1. getList : removed call to com/lowagie/text/List::setSymbolIndent → NO_COVERAGE |
list.setSymbolIndent(Float.parseFloat(value)); |
277 | } | |
278 | ||
279 |
1
1. getList : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getList to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return list; |
280 | } | |
281 | ||
282 | /** | |
283 | * Creates a Cell object based on a list of properties. | |
284 | * @param attributes | |
285 | * @return a Cell | |
286 | */ | |
287 | public static Cell getCell(Properties attributes) { | |
288 | Cell cell = new Cell(); | |
289 | String value; | |
290 | ||
291 |
1
1. getCell : removed call to com/lowagie/text/Cell::setHorizontalAlignment → SURVIVED |
cell.setHorizontalAlignment(attributes |
292 | .getProperty(ElementTags.HORIZONTALALIGN)); | |
293 |
1
1. getCell : removed call to com/lowagie/text/Cell::setVerticalAlignment → SURVIVED |
cell.setVerticalAlignment(attributes |
294 | .getProperty(ElementTags.VERTICALALIGN)); | |
295 | ||
296 | value = attributes.getProperty(ElementTags.WIDTH); | |
297 |
1
1. getCell : negated conditional → KILLED |
if (value != null) { |
298 |
1
1. getCell : removed call to com/lowagie/text/Cell::setWidth → NO_COVERAGE |
cell.setWidth(value); |
299 | } | |
300 | value = attributes.getProperty(ElementTags.COLSPAN); | |
301 |
1
1. getCell : negated conditional → KILLED |
if (value != null) { |
302 |
1
1. getCell : removed call to com/lowagie/text/Cell::setColspan → NO_COVERAGE |
cell.setColspan(Integer.parseInt(value)); |
303 | } | |
304 | value = attributes.getProperty(ElementTags.ROWSPAN); | |
305 |
1
1. getCell : negated conditional → KILLED |
if (value != null) { |
306 |
1
1. getCell : removed call to com/lowagie/text/Cell::setRowspan → NO_COVERAGE |
cell.setRowspan(Integer.parseInt(value)); |
307 | } | |
308 | value = attributes.getProperty(ElementTags.LEADING); | |
309 |
1
1. getCell : negated conditional → KILLED |
if (value != null) { |
310 |
1
1. getCell : removed call to com/lowagie/text/Cell::setLeading → NO_COVERAGE |
cell.setLeading(Float.parseFloat(value + "f")); |
311 | } | |
312 |
1
1. getCell : removed call to com/lowagie/text/Cell::setHeader → SURVIVED |
cell.setHeader(Utilities.checkTrueOrFalse(attributes, |
313 | ElementTags.HEADER)); | |
314 |
1
1. getCell : negated conditional → SURVIVED |
if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) { |
315 |
1
1. getCell : removed call to com/lowagie/text/Cell::setMaxLines → NO_COVERAGE |
cell.setMaxLines(1); |
316 | } | |
317 |
1
1. getCell : removed call to com/lowagie/text/factories/ElementFactory::setRectangleProperties → SURVIVED |
setRectangleProperties(cell, attributes); |
318 |
1
1. getCell : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getCell to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return cell; |
319 | } | |
320 | ||
321 | /** | |
322 | * Creates an Table object based on a list of properties. | |
323 | * @param attributes | |
324 | * @return a Table | |
325 | */ | |
326 | public static Table getTable(Properties attributes) { | |
327 | String value; | |
328 | Table table; | |
329 | try { | |
330 | ||
331 | value = attributes.getProperty(ElementTags.WIDTHS); | |
332 |
1
1. getTable : negated conditional → KILLED |
if (value != null) { |
333 | StringTokenizer widthTokens = new StringTokenizer(value, ";"); | |
334 | ArrayList values = new ArrayList(); | |
335 |
1
1. getTable : negated conditional → NO_COVERAGE |
while (widthTokens.hasMoreTokens()) { |
336 | values.add(widthTokens.nextToken()); | |
337 | } | |
338 | table = new Table(values.size()); | |
339 | float[] widths = new float[table.getColumns()]; | |
340 |
2
1. getTable : changed conditional boundary → NO_COVERAGE 2. getTable : negated conditional → NO_COVERAGE |
for (int i = 0; i < values.size(); i++) { |
341 | value = (String) values.get(i); | |
342 | widths[i] = Float.parseFloat(value + "f"); | |
343 | } | |
344 |
1
1. getTable : removed call to com/lowagie/text/Table::setWidths → NO_COVERAGE |
table.setWidths(widths); |
345 | } else { | |
346 | value = attributes.getProperty(ElementTags.COLUMNS); | |
347 | try { | |
348 | table = new Table(Integer.parseInt(value)); | |
349 | } catch (Exception e) { | |
350 | table = new Table(1); | |
351 | } | |
352 | } | |
353 | ||
354 |
1
1. getTable : removed call to com/lowagie/text/Table::setBorder → SURVIVED |
table.setBorder(Table.BOX); |
355 |
1
1. getTable : removed call to com/lowagie/text/Table::setBorderWidth → SURVIVED |
table.setBorderWidth(1); |
356 |
1
1. getTable : removed call to com/lowagie/text/Cell::setBorder → SURVIVED |
table.getDefaultCell().setBorder(Table.BOX); |
357 | ||
358 | value = attributes.getProperty(ElementTags.LASTHEADERROW); | |
359 |
1
1. getTable : negated conditional → KILLED |
if (value != null) { |
360 |
1
1. getTable : removed call to com/lowagie/text/Table::setLastHeaderRow → NO_COVERAGE |
table.setLastHeaderRow(Integer.parseInt(value)); |
361 | } | |
362 | value = attributes.getProperty(ElementTags.ALIGN); | |
363 |
1
1. getTable : negated conditional → SURVIVED |
if (value != null) { |
364 |
1
1. getTable : removed call to com/lowagie/text/Table::setAlignment → NO_COVERAGE |
table.setAlignment(value); |
365 | } | |
366 | value = attributes.getProperty(ElementTags.CELLSPACING); | |
367 |
1
1. getTable : negated conditional → KILLED |
if (value != null) { |
368 |
1
1. getTable : removed call to com/lowagie/text/Table::setSpacing → NO_COVERAGE |
table.setSpacing(Float.parseFloat(value + "f")); |
369 | } | |
370 | value = attributes.getProperty(ElementTags.CELLPADDING); | |
371 |
1
1. getTable : negated conditional → KILLED |
if (value != null) { |
372 |
1
1. getTable : removed call to com/lowagie/text/Table::setPadding → NO_COVERAGE |
table.setPadding(Float.parseFloat(value + "f")); |
373 | } | |
374 | value = attributes.getProperty(ElementTags.OFFSET); | |
375 |
1
1. getTable : negated conditional → KILLED |
if (value != null) { |
376 |
1
1. getTable : removed call to com/lowagie/text/Table::setOffset → NO_COVERAGE |
table.setOffset(Float.parseFloat(value + "f")); |
377 | } | |
378 | value = attributes.getProperty(ElementTags.WIDTH); | |
379 |
1
1. getTable : negated conditional → KILLED |
if (value != null) { |
380 |
1
1. getTable : negated conditional → NO_COVERAGE |
if (value.endsWith("%")) |
381 |
1
1. getTable : removed call to com/lowagie/text/Table::setWidth → NO_COVERAGE |
table.setWidth(Float.parseFloat(value.substring(0, value |
382 |
1
1. getTable : Replaced integer subtraction with addition → NO_COVERAGE |
.length() - 1) |
383 | + "f")); | |
384 | else { | |
385 |
1
1. getTable : removed call to com/lowagie/text/Table::setWidth → NO_COVERAGE |
table.setWidth(Float.parseFloat(value + "f")); |
386 |
1
1. getTable : removed call to com/lowagie/text/Table::setLocked → NO_COVERAGE |
table.setLocked(true); |
387 | } | |
388 | } | |
389 |
1
1. getTable : removed call to com/lowagie/text/Table::setTableFitsPage → SURVIVED |
table.setTableFitsPage(Utilities.checkTrueOrFalse(attributes, |
390 | ElementTags.TABLEFITSPAGE)); | |
391 |
1
1. getTable : removed call to com/lowagie/text/Table::setCellsFitPage → SURVIVED |
table.setCellsFitPage(Utilities.checkTrueOrFalse(attributes, |
392 | ElementTags.CELLSFITPAGE)); | |
393 |
1
1. getTable : removed call to com/lowagie/text/Table::setConvert2pdfptable → SURVIVED |
table.setConvert2pdfptable(Utilities.checkTrueOrFalse(attributes, |
394 | ElementTags.CONVERT2PDFP)); | |
395 | ||
396 |
1
1. getTable : removed call to com/lowagie/text/factories/ElementFactory::setRectangleProperties → SURVIVED |
setRectangleProperties(table, attributes); |
397 |
1
1. getTable : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getTable to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return table; |
398 | } catch (BadElementException e) { | |
399 | throw new ExceptionConverter(e); | |
400 | } | |
401 | } | |
402 | ||
403 | /** | |
404 | * Sets some Rectangle properties (for a Cell, Table,...). | |
405 | */ | |
406 | private static void setRectangleProperties(Rectangle rect, | |
407 | Properties attributes) { | |
408 | String value; | |
409 | value = attributes.getProperty(ElementTags.BORDERWIDTH); | |
410 |
1
1. setRectangleProperties : negated conditional → KILLED |
if (value != null) { |
411 |
1
1. setRectangleProperties : removed call to com/lowagie/text/Rectangle::setBorderWidth → NO_COVERAGE |
rect.setBorderWidth(Float.parseFloat(value + "f")); |
412 | } | |
413 | int border = 0; | |
414 |
1
1. setRectangleProperties : negated conditional → SURVIVED |
if (Utilities.checkTrueOrFalse(attributes, ElementTags.LEFT)) { |
415 |
1
1. setRectangleProperties : Replaced bitwise OR with AND → NO_COVERAGE |
border |= Rectangle.LEFT; |
416 | } | |
417 |
1
1. setRectangleProperties : negated conditional → SURVIVED |
if (Utilities.checkTrueOrFalse(attributes, ElementTags.RIGHT)) { |
418 |
1
1. setRectangleProperties : Replaced bitwise OR with AND → NO_COVERAGE |
border |= Rectangle.RIGHT; |
419 | } | |
420 |
1
1. setRectangleProperties : negated conditional → SURVIVED |
if (Utilities.checkTrueOrFalse(attributes, ElementTags.TOP)) { |
421 |
1
1. setRectangleProperties : Replaced bitwise OR with AND → NO_COVERAGE |
border |= Rectangle.TOP; |
422 | } | |
423 |
1
1. setRectangleProperties : negated conditional → SURVIVED |
if (Utilities.checkTrueOrFalse(attributes, ElementTags.BOTTOM)) { |
424 |
1
1. setRectangleProperties : Replaced bitwise OR with AND → NO_COVERAGE |
border |= Rectangle.BOTTOM; |
425 | } | |
426 |
1
1. setRectangleProperties : removed call to com/lowagie/text/Rectangle::setBorder → SURVIVED |
rect.setBorder(border); |
427 | ||
428 | String r = attributes.getProperty(ElementTags.RED); | |
429 | String g = attributes.getProperty(ElementTags.GREEN); | |
430 | String b = attributes.getProperty(ElementTags.BLUE); | |
431 |
3
1. setRectangleProperties : negated conditional → SURVIVED 2. setRectangleProperties : negated conditional → SURVIVED 3. setRectangleProperties : negated conditional → SURVIVED |
if (r != null || g != null || b != null) { |
432 | int red = 0; | |
433 | int green = 0; | |
434 | int blue = 0; | |
435 |
1
1. setRectangleProperties : negated conditional → NO_COVERAGE |
if (r != null) |
436 | red = Integer.parseInt(r); | |
437 |
1
1. setRectangleProperties : negated conditional → NO_COVERAGE |
if (g != null) |
438 | green = Integer.parseInt(g); | |
439 |
1
1. setRectangleProperties : negated conditional → NO_COVERAGE |
if (b != null) |
440 | blue = Integer.parseInt(b); | |
441 |
1
1. setRectangleProperties : removed call to com/lowagie/text/Rectangle::setBorderColor → NO_COVERAGE |
rect.setBorderColor(new Color(red, green, blue)); |
442 | } else { | |
443 |
1
1. setRectangleProperties : removed call to com/lowagie/text/Rectangle::setBorderColor → SURVIVED |
rect.setBorderColor(Markup.decodeColor(attributes |
444 | .getProperty(ElementTags.BORDERCOLOR))); | |
445 | } | |
446 | r = (String) attributes.remove(ElementTags.BGRED); | |
447 | g = (String) attributes.remove(ElementTags.BGGREEN); | |
448 | b = (String) attributes.remove(ElementTags.BGBLUE); | |
449 | value = attributes.getProperty(ElementTags.BACKGROUNDCOLOR); | |
450 |
3
1. setRectangleProperties : negated conditional → SURVIVED 2. setRectangleProperties : negated conditional → SURVIVED 3. setRectangleProperties : negated conditional → SURVIVED |
if (r != null || g != null || b != null) { |
451 | int red = 0; | |
452 | int green = 0; | |
453 | int blue = 0; | |
454 |
1
1. setRectangleProperties : negated conditional → NO_COVERAGE |
if (r != null) |
455 | red = Integer.parseInt(r); | |
456 |
1
1. setRectangleProperties : negated conditional → NO_COVERAGE |
if (g != null) |
457 | green = Integer.parseInt(g); | |
458 |
1
1. setRectangleProperties : negated conditional → NO_COVERAGE |
if (b != null) |
459 | blue = Integer.parseInt(b); | |
460 |
1
1. setRectangleProperties : removed call to com/lowagie/text/Rectangle::setBackgroundColor → NO_COVERAGE |
rect.setBackgroundColor(new Color(red, green, blue)); |
461 |
1
1. setRectangleProperties : negated conditional → SURVIVED |
} else if (value != null) { |
462 |
1
1. setRectangleProperties : removed call to com/lowagie/text/Rectangle::setBackgroundColor → NO_COVERAGE |
rect.setBackgroundColor(Markup.decodeColor(value)); |
463 | } else { | |
464 | value = attributes.getProperty(ElementTags.GRAYFILL); | |
465 |
1
1. setRectangleProperties : negated conditional → KILLED |
if (value != null) { |
466 |
1
1. setRectangleProperties : removed call to com/lowagie/text/Rectangle::setGrayFill → NO_COVERAGE |
rect.setGrayFill(Float.parseFloat(value + "f")); |
467 | } | |
468 | } | |
469 | } | |
470 | ||
471 | /** | |
472 | * Creates a ChapterAutoNumber object based on a list of properties. | |
473 | * @param attributes | |
474 | * @return a Chapter | |
475 | */ | |
476 | public static ChapterAutoNumber getChapter(Properties attributes) { | |
477 | ChapterAutoNumber chapter = new ChapterAutoNumber(""); | |
478 |
1
1. getChapter : removed call to com/lowagie/text/factories/ElementFactory::setSectionParameters → NO_COVERAGE |
setSectionParameters(chapter, attributes); |
479 |
1
1. getChapter : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getChapter to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return chapter; |
480 | } | |
481 | ||
482 | /** | |
483 | * Creates a Section object based on a list of properties. | |
484 | * @param attributes | |
485 | * @return a Section | |
486 | */ | |
487 | public static Section getSection(Section parent, Properties attributes) { | |
488 | Section section = parent.addSection(""); | |
489 |
1
1. getSection : removed call to com/lowagie/text/factories/ElementFactory::setSectionParameters → NO_COVERAGE |
setSectionParameters(section, attributes); |
490 |
1
1. getSection : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getSection to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return section; |
491 | } | |
492 | ||
493 | /** | |
494 | * Helper method to create a Chapter/Section object. | |
495 | * @param attributes | |
496 | */ | |
497 | private static void setSectionParameters(Section section, | |
498 | Properties attributes) { | |
499 | String value; | |
500 | value = attributes.getProperty(ElementTags.NUMBERDEPTH); | |
501 |
1
1. setSectionParameters : negated conditional → NO_COVERAGE |
if (value != null) { |
502 |
1
1. setSectionParameters : removed call to com/lowagie/text/Section::setNumberDepth → NO_COVERAGE |
section.setNumberDepth(Integer.parseInt(value)); |
503 | } | |
504 | value = attributes.getProperty(ElementTags.INDENT); | |
505 |
1
1. setSectionParameters : negated conditional → NO_COVERAGE |
if (value != null) { |
506 |
1
1. setSectionParameters : removed call to com/lowagie/text/Section::setIndentation → NO_COVERAGE |
section.setIndentation(Float.parseFloat(value + "f")); |
507 | } | |
508 | value = attributes.getProperty(ElementTags.INDENTATIONLEFT); | |
509 |
1
1. setSectionParameters : negated conditional → NO_COVERAGE |
if (value != null) { |
510 |
1
1. setSectionParameters : removed call to com/lowagie/text/Section::setIndentationLeft → NO_COVERAGE |
section.setIndentationLeft(Float.parseFloat(value + "f")); |
511 | } | |
512 | value = attributes.getProperty(ElementTags.INDENTATIONRIGHT); | |
513 |
1
1. setSectionParameters : negated conditional → NO_COVERAGE |
if (value != null) { |
514 |
1
1. setSectionParameters : removed call to com/lowagie/text/Section::setIndentationRight → NO_COVERAGE |
section.setIndentationRight(Float.parseFloat(value + "f")); |
515 | } | |
516 | } | |
517 | ||
518 | /** | |
519 | * Creates an Image object based on a list of properties. | |
520 | * @param attributes | |
521 | * @return an Image | |
522 | */ | |
523 | public static Image getImage(Properties attributes) | |
524 | throws BadElementException, IOException { | |
525 | String value; | |
526 | ||
527 | value = attributes.getProperty(ElementTags.URL); | |
528 |
1
1. getImage : negated conditional → NO_COVERAGE |
if (value == null) |
529 | throw new MalformedURLException(MessageLocalization.getComposedMessage("the.url.of.the.image.is.missing")); | |
530 | Image image = Image.getInstance(value); | |
531 | ||
532 | value = attributes.getProperty(ElementTags.ALIGN); | |
533 | int align = 0; | |
534 |
1
1. getImage : negated conditional → NO_COVERAGE |
if (value != null) { |
535 |
1
1. getImage : negated conditional → NO_COVERAGE |
if (ElementTags.ALIGN_LEFT.equalsIgnoreCase(value)) |
536 |
1
1. getImage : Replaced bitwise OR with AND → NO_COVERAGE |
align |= Image.LEFT; |
537 |
1
1. getImage : negated conditional → NO_COVERAGE |
else if (ElementTags.ALIGN_RIGHT.equalsIgnoreCase(value)) |
538 |
1
1. getImage : Replaced bitwise OR with AND → NO_COVERAGE |
align |= Image.RIGHT; |
539 |
1
1. getImage : negated conditional → NO_COVERAGE |
else if (ElementTags.ALIGN_MIDDLE.equalsIgnoreCase(value)) |
540 |
1
1. getImage : Replaced bitwise OR with AND → NO_COVERAGE |
align |= Image.MIDDLE; |
541 | } | |
542 |
1
1. getImage : negated conditional → NO_COVERAGE |
if ("true".equalsIgnoreCase(attributes |
543 | .getProperty(ElementTags.UNDERLYING))) | |
544 |
1
1. getImage : Replaced bitwise OR with AND → NO_COVERAGE |
align |= Image.UNDERLYING; |
545 |
1
1. getImage : negated conditional → NO_COVERAGE |
if ("true".equalsIgnoreCase(attributes |
546 | .getProperty(ElementTags.TEXTWRAP))) | |
547 |
1
1. getImage : Replaced bitwise OR with AND → NO_COVERAGE |
align |= Image.TEXTWRAP; |
548 |
1
1. getImage : removed call to com/lowagie/text/Image::setAlignment → NO_COVERAGE |
image.setAlignment(align); |
549 | ||
550 | value = attributes.getProperty(ElementTags.ALT); | |
551 |
1
1. getImage : negated conditional → NO_COVERAGE |
if (value != null) { |
552 |
1
1. getImage : removed call to com/lowagie/text/Image::setAlt → NO_COVERAGE |
image.setAlt(value); |
553 | } | |
554 | ||
555 | String x = attributes.getProperty(ElementTags.ABSOLUTEX); | |
556 | String y = attributes.getProperty(ElementTags.ABSOLUTEY); | |
557 |
2
1. getImage : negated conditional → NO_COVERAGE 2. getImage : negated conditional → NO_COVERAGE |
if ((x != null) && (y != null)) { |
558 |
1
1. getImage : removed call to com/lowagie/text/Image::setAbsolutePosition → NO_COVERAGE |
image.setAbsolutePosition(Float.parseFloat(x + "f"), Float |
559 | .parseFloat(y + "f")); | |
560 | } | |
561 | value = attributes.getProperty(ElementTags.PLAINWIDTH); | |
562 |
1
1. getImage : negated conditional → NO_COVERAGE |
if (value != null) { |
563 |
1
1. getImage : removed call to com/lowagie/text/Image::scaleAbsoluteWidth → NO_COVERAGE |
image.scaleAbsoluteWidth(Float.parseFloat(value + "f")); |
564 | } | |
565 | value = attributes.getProperty(ElementTags.PLAINHEIGHT); | |
566 |
1
1. getImage : negated conditional → NO_COVERAGE |
if (value != null) { |
567 |
1
1. getImage : removed call to com/lowagie/text/Image::scaleAbsoluteHeight → NO_COVERAGE |
image.scaleAbsoluteHeight(Float.parseFloat(value + "f")); |
568 | } | |
569 | value = attributes.getProperty(ElementTags.ROTATION); | |
570 |
1
1. getImage : negated conditional → NO_COVERAGE |
if (value != null) { |
571 |
1
1. getImage : removed call to com/lowagie/text/Image::setRotation → NO_COVERAGE |
image.setRotation(Float.parseFloat(value + "f")); |
572 | } | |
573 |
1
1. getImage : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getImage to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return image; |
574 | } | |
575 | ||
576 | /** | |
577 | * Creates an Annotation object based on a list of properties. | |
578 | * @param attributes | |
579 | * @return an Annotation | |
580 | */ | |
581 | public static Annotation getAnnotation(Properties attributes) { | |
582 | float llx = 0, lly = 0, urx = 0, ury = 0; | |
583 | String value; | |
584 | ||
585 | value = attributes.getProperty(ElementTags.LLX); | |
586 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (value != null) { |
587 | llx = Float.parseFloat(value + "f"); | |
588 | } | |
589 | value = attributes.getProperty(ElementTags.LLY); | |
590 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (value != null) { |
591 | lly = Float.parseFloat(value + "f"); | |
592 | } | |
593 | value = attributes.getProperty(ElementTags.URX); | |
594 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (value != null) { |
595 | urx = Float.parseFloat(value + "f"); | |
596 | } | |
597 | value = attributes.getProperty(ElementTags.URY); | |
598 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (value != null) { |
599 | ury = Float.parseFloat(value + "f"); | |
600 | } | |
601 | ||
602 | String title = attributes.getProperty(ElementTags.TITLE); | |
603 | String text = attributes.getProperty(ElementTags.CONTENT); | |
604 |
2
1. getAnnotation : negated conditional → NO_COVERAGE 2. getAnnotation : negated conditional → NO_COVERAGE |
if (title != null || text != null) { |
605 |
1
1. getAnnotation : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getAnnotation to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Annotation(title, text, llx, lly, urx, ury); |
606 | } | |
607 | value = attributes.getProperty(ElementTags.URL); | |
608 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (value != null) { |
609 |
1
1. getAnnotation : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getAnnotation to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Annotation(llx, lly, urx, ury, value); |
610 | } | |
611 | value = attributes.getProperty(ElementTags.NAMED); | |
612 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (value != null) { |
613 |
1
1. getAnnotation : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getAnnotation to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Annotation(llx, lly, urx, ury, Integer.parseInt(value)); |
614 | } | |
615 | String file = attributes.getProperty(ElementTags.FILE); | |
616 | String destination = attributes.getProperty(ElementTags.DESTINATION); | |
617 | String page = (String) attributes.remove(ElementTags.PAGE); | |
618 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (file != null) { |
619 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (destination != null) { |
620 |
1
1. getAnnotation : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getAnnotation to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Annotation(llx, lly, urx, ury, file, destination); |
621 | } | |
622 |
1
1. getAnnotation : negated conditional → NO_COVERAGE |
if (page != null) { |
623 |
1
1. getAnnotation : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getAnnotation to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Annotation(llx, lly, urx, ury, file, Integer |
624 | .parseInt(page)); | |
625 | } | |
626 | } | |
627 |
1
1. getAnnotation : mutated return of Object value for com/lowagie/text/factories/ElementFactory::getAnnotation to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Annotation("", "", llx, lly, urx, ury); |
628 | } | |
629 | } | |
Mutations | ||
96 |
1.1 |
|
100 |
1.1 |
|
104 |
1.1 |
|
108 |
1.1 |
|
110 |
1.1 |
|
115 |
1.1 |
|
121 |
1.1 |
|
125 |
1.1 |
|
129 |
1.1 2.2 |
|
130 |
1.1 2.2 |
|
132 |
1.1 |
|
135 |
1.1 |
|
139 |
1.1 |
|
142 |
1.1 |
|
152 |
1.1 |
|
155 |
1.1 |
|
156 |
1.1 |
|
159 |
1.1 |
|
160 |
1.1 |
|
164 |
1.1 |
|
166 |
1.1 |
|
171 |
1.1 |
|
183 |
1.1 |
|
184 |
1.1 |
|
187 |
1.1 |
|
188 |
1.1 |
|
190 |
1.1 |
|
202 |
1.1 |
|
203 |
1.1 |
|
206 |
1.1 |
|
207 |
1.1 |
|
210 |
1.1 |
|
211 |
1.1 |
|
213 |
1.1 |
|
223 |
1.1 |
|
234 |
1.1 |
|
236 |
1.1 |
|
238 |
1.1 |
|
240 |
1.1 |
|
242 |
1.1 |
|
248 |
1.1 |
|
250 |
1.1 |
|
251 |
1.1 |
|
253 |
1.1 |
|
258 |
1.1 |
|
260 |
1.1 |
|
265 |
1.1 |
|
266 |
1.1 |
|
270 |
1.1 |
|
271 |
1.1 |
|
275 |
1.1 |
|
276 |
1.1 |
|
279 |
1.1 |
|
291 |
1.1 |
|
293 |
1.1 |
|
297 |
1.1 |
|
298 |
1.1 |
|
301 |
1.1 |
|
302 |
1.1 |
|
305 |
1.1 |
|
306 |
1.1 |
|
309 |
1.1 |
|
310 |
1.1 |
|
312 |
1.1 |
|
314 |
1.1 |
|
315 |
1.1 |
|
317 |
1.1 |
|
318 |
1.1 |
|
332 |
1.1 |
|
335 |
1.1 |
|
340 |
1.1 2.2 |
|
344 |
1.1 |
|
354 |
1.1 |
|
355 |
1.1 |
|
356 |
1.1 |
|
359 |
1.1 |
|
360 |
1.1 |
|
363 |
1.1 |
|
364 |
1.1 |
|
367 |
1.1 |
|
368 |
1.1 |
|
371 |
1.1 |
|
372 |
1.1 |
|
375 |
1.1 |
|
376 |
1.1 |
|
379 |
1.1 |
|
380 |
1.1 |
|
381 |
1.1 |
|
382 |
1.1 |
|
385 |
1.1 |
|
386 |
1.1 |
|
389 |
1.1 |
|
391 |
1.1 |
|
393 |
1.1 |
|
396 |
1.1 |
|
397 |
1.1 |
|
410 |
1.1 |
|
411 |
1.1 |
|
414 |
1.1 |
|
415 |
1.1 |
|
417 |
1.1 |
|
418 |
1.1 |
|
420 |
1.1 |
|
421 |
1.1 |
|
423 |
1.1 |
|
424 |
1.1 |
|
426 |
1.1 |
|
431 |
1.1 2.2 3.3 |
|
435 |
1.1 |
|
437 |
1.1 |
|
439 |
1.1 |
|
441 |
1.1 |
|
443 |
1.1 |
|
450 |
1.1 2.2 3.3 |
|
454 |
1.1 |
|
456 |
1.1 |
|
458 |
1.1 |
|
460 |
1.1 |
|
461 |
1.1 |
|
462 |
1.1 |
|
465 |
1.1 |
|
466 |
1.1 |
|
478 |
1.1 |
|
479 |
1.1 |
|
489 |
1.1 |
|
490 |
1.1 |
|
501 |
1.1 |
|
502 |
1.1 |
|
505 |
1.1 |
|
506 |
1.1 |
|
509 |
1.1 |
|
510 |
1.1 |
|
513 |
1.1 |
|
514 |
1.1 |
|
528 |
1.1 |
|
534 |
1.1 |
|
535 |
1.1 |
|
536 |
1.1 |
|
537 |
1.1 |
|
538 |
1.1 |
|
539 |
1.1 |
|
540 |
1.1 |
|
542 |
1.1 |
|
544 |
1.1 |
|
545 |
1.1 |
|
547 |
1.1 |
|
548 |
1.1 |
|
551 |
1.1 |
|
552 |
1.1 |
|
557 |
1.1 2.2 |
|
558 |
1.1 |
|
562 |
1.1 |
|
563 |
1.1 |
|
566 |
1.1 |
|
567 |
1.1 |
|
570 |
1.1 |
|
571 |
1.1 |
|
573 |
1.1 |
|
586 |
1.1 |
|
590 |
1.1 |
|
594 |
1.1 |
|
598 |
1.1 |
|
604 |
1.1 2.2 |
|
605 |
1.1 |
|
608 |
1.1 |
|
609 |
1.1 |
|
612 |
1.1 |
|
613 |
1.1 |
|
618 |
1.1 |
|
619 |
1.1 |
|
620 |
1.1 |
|
622 |
1.1 |
|
623 |
1.1 |
|
627 |
1.1 |