PdfDictionary.java

1
/*
2
 * $Id: PdfDictionary.java 3762 2009-03-06 16:53:44Z blowagie $
3
 *
4
 * Copyright 1999, 2000, 2001, 2002 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
 * 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
50
package com.lowagie.text.pdf;
51
52
import java.io.IOException;
53
import java.io.OutputStream;
54
import java.util.HashMap;
55
import java.util.Map;
56
import java.util.Set;
57
58
/**
59
 * <CODE>PdfDictionary</CODE> is the Pdf dictionary object.
60
 * <P>
61
 * A dictionary is an associative table containing pairs of objects.
62
 * The first element of each pair is called the <I>key</I> and the second
63
 * element is called the <I>value</I>.
64
 * Unlike dictionaries in the PostScript language, a key must be a
65
 * <CODE>PdfName</CODE>.
66
 * A value can be any kind of <CODE>PdfObject</CODE>, including a dictionary.
67
 * A dictionary is generally used to collect and tie together the attributes
68
 * of a complex object, with each key-value pair specifying the name and value
69
 * of an attribute.<BR>
70
 * A dictionary is represented by two left angle brackets (<<), followed by a
71
 * sequence of key-value pairs, followed by two right angle brackets (>>).<BR>
72
 * This object is described in the 'Portable Document Format Reference Manual
73
 * version 1.7' section 3.2.6 (page 59-60).
74
 * <P>
75
 *
76
 * @see        PdfObject
77
 * @see        PdfName
78
 * @see        BadPdfFormatException
79
 */
80
public class PdfDictionary extends PdfObject {
81
82
    // CONSTANTS
83
84
    /** This is a possible type of dictionary */
85
    public static final PdfName FONT = PdfName.FONT;
86
87
    /** This is a possible type of dictionary */
88
    public static final PdfName OUTLINES = PdfName.OUTLINES;
89
90
    /** This is a possible type of dictionary */
91
    public static final PdfName PAGE = PdfName.PAGE;
92
93
    /** This is a possible type of dictionary */
94
    public static final PdfName PAGES = PdfName.PAGES;
95
96
    /** This is a possible type of dictionary */
97
    public static final PdfName CATALOG = PdfName.CATALOG;
98
99
    // CLASS VARIABLES
100
101
    /** This is the type of this dictionary */
102
    private PdfName dictionaryType = null;
103
104
    /** This is the hashmap that contains all the values and keys of the dictionary */
105
    protected Map<PdfName, PdfObject> hashMap;
106
107
    // CONSTRUCTORS
108
109
    /**
110
     * Constructs an empty <CODE>PdfDictionary</CODE>-object.
111
     */
112
    public PdfDictionary() {
113
        super(DICTIONARY);
114
        hashMap = new HashMap<>();
115
    }
116
117
    /**
118
     * Constructs a <CODE>PdfDictionary</CODE>-object of a certain type.
119
     *
120
     * @param type a <CODE>PdfName</CODE>
121
     */
122
    public PdfDictionary(PdfName type) {
123
        this();
124
        dictionaryType = type;
125 1 1. : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        put(PdfName.TYPE, dictionaryType);
126
    }
127
128
    // METHODS OVERRIDING SOME PDFOBJECT METHODS
129
130
    /**
131
     * Writes the PDF representation of this <CODE>PdfDictionary</CODE> as an
132
     * array of <CODE>byte</CODE> to the given <CODE>OutputStream</CODE>.
133
     *
134
     * @param writer for backwards compatibility
135
     * @param os the <CODE>OutputStream</CODE> to write the bytes to.
136
     * @throws IOException
137
     */
138
    public void toPdf(PdfWriter writer, OutputStream os) throws IOException {
139 1 1. toPdf : removed call to java/io/OutputStream::write → NO_COVERAGE
        os.write('<');
140 1 1. toPdf : removed call to java/io/OutputStream::write → NO_COVERAGE
        os.write('<');
141
        // loop over all the object-pairs in the HashMap
142
        for (PdfName pdfName : hashMap.keySet()) {
143
            PdfObject value = hashMap.get(pdfName);
144 1 1. toPdf : removed call to com/lowagie/text/pdf/PdfName::toPdf → NO_COVERAGE
            pdfName.toPdf(writer, os);
145
            int type = value.type();
146 4 1. toPdf : negated conditional → NO_COVERAGE
2. toPdf : negated conditional → NO_COVERAGE
3. toPdf : negated conditional → NO_COVERAGE
4. toPdf : negated conditional → NO_COVERAGE
            if (type != PdfObject.ARRAY && type != PdfObject.DICTIONARY && type != PdfObject.NAME && type != PdfObject.STRING)
147 1 1. toPdf : removed call to java/io/OutputStream::write → NO_COVERAGE
                os.write(' ');
148 1 1. toPdf : removed call to com/lowagie/text/pdf/PdfObject::toPdf → NO_COVERAGE
            value.toPdf(writer, os);
149
        }
150 1 1. toPdf : removed call to java/io/OutputStream::write → NO_COVERAGE
        os.write('>');
151 1 1. toPdf : removed call to java/io/OutputStream::write → NO_COVERAGE
        os.write('>');
152
    }
153
154
    /**
155
     * Returns a string representation of this <CODE>PdfDictionary</CODE>.
156
     *
157
     * The string doesn't contain any of the content of this dictionary.
158
     * Rather the string "dictionary" is returned, possibly followed by the
159
     * type of this <CODE>PdfDictionary</CODE>, if set.
160
     *
161
     * @return the string representation of this <CODE>PdfDictionary</CODE>
162
     * @see com.lowagie.text.pdf.PdfObject#toString()
163
     */
164
    public String toString() {
165
        if (get(PdfName.TYPE) == null)
166
            return "Dictionary";
167
        return "Dictionary of type: " + get(PdfName.TYPE);
168
    }
169
170
    // DICTIONARY CONTENT METHODS
171
172
    /**
173
     * Associates the specified <CODE>PdfObject</CODE> as <VAR>value</VAR> with
174
     * the specified <CODE>PdfName</CODE> as <VAR>key</VAR> in this map.
175
     *
176
     * If the map previously contained a mapping for this <VAR>key</VAR>, the
177
     * old <VAR>value</VAR> is replaced. If the <VAR>value</VAR> is
178
     * <CODE>null</CODE> or <CODE>PdfNull</CODE> the key is deleted.
179
     *
180
     * @param key a <CODE>PdfName</CODE>
181
     * @param object the <CODE>PdfObject</CODE> to be associated with the
182
     *   <VAR>key</VAR>
183
     */
184
    public void put(PdfName key, PdfObject object) {
185 2 1. put : negated conditional → NO_COVERAGE
2. put : negated conditional → NO_COVERAGE
        if (object == null || object.isNull())
186
            hashMap.remove(key);
187
        else
188
            hashMap.put(key, object);
189
    }
190
191
    /**
192
     * Associates the specified <CODE>PdfObject</CODE> as value to the
193
     * specified <CODE>PdfName</CODE> as key in this map.
194
     *
195
     * If the <VAR>value</VAR> is a <CODE>PdfNull</CODE>, it is treated just as
196
     * any other <CODE>PdfObject</CODE>. If the <VAR>value</VAR> is
197
     * <CODE>null</CODE> however nothing is done.
198
     *
199
     * @param key a <CODE>PdfName</CODE>
200
     * @param value the <CODE>PdfObject</CODE> to be associated to the
201
     * <VAR>key</VAR>
202
     */
203
    public void putEx(PdfName key, PdfObject value) {
204 1 1. putEx : negated conditional → NO_COVERAGE
        if (value == null)
205
            return;
206 1 1. putEx : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        put(key, value);
207
    }
208
209
    /**
210
     * Copies all of the mappings from the specified <CODE>PdfDictionary</CODE>
211
     * to this <CODE>PdfDictionary</CODE>.
212
     *
213
     * These mappings will replace any mappings previously contained in this
214
     * <CODE>PdfDictionary</CODE>.
215
     *
216
     * @param dic The <CODE>PdfDictionary</CODE> with the mappings to be
217
     *   copied over
218
     */
219
    public void putAll(PdfDictionary dic) {
220 1 1. putAll : removed call to java/util/Map::putAll → NO_COVERAGE
        hashMap.putAll(dic.hashMap);
221
    }
222
223
    /**
224
     * Removes a <CODE>PdfObject</CODE> and its <VAR>key</VAR> from the
225
     * <CODE>PdfDictionary</CODE>.
226
     *
227
     * @param key a <CODE>PdfName</CODE>
228
     */
229
    public void remove(PdfName key) {
230
        hashMap.remove(key);
231
    }
232
233
    /**
234
     * Returns the <CODE>PdfObject</CODE> associated to the specified
235
     * <VAR>key</VAR>.
236
     *
237
     * @param key a <CODE>PdfName</CODE>
238
     * @return the </CODE>PdfObject</CODE> previously associated to the
239
     *   <VAR>key</VAR>
240
     */
241
    public PdfObject get(PdfName key) {
242 1 1. get : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return hashMap.get(key);
243
    }
244
245
    /**
246
     * Returns the <CODE>PdfObject</CODE> associated to the specified
247
     * <VAR>key</VAR>, resolving a possible indirect reference to a direct
248
     * object.
249
     *
250
     * This method will never return a <CODE>PdfIndirectReference</CODE>
251
     * object.
252
     *
253
     * @param key A key for the <CODE>PdfObject</CODE> to be returned
254
     * @return A direct <CODE>PdfObject</CODE> or <CODE>null</CODE>
255
     */
256
    public PdfObject getDirectObject(PdfName key) {
257 1 1. getDirectObject : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getDirectObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return PdfReader.getPdfObject(get(key));
258
    }
259
260
    /**
261
     * Get all keys that are set.
262
     *
263
     * @return <CODE>true</CODE> if it is, otherwise <CODE>false</CODE>.
264
     */
265
    public Set<PdfName> getKeys() {
266
        return hashMap.keySet();
267
    }
268
269
    /**
270
     * Returns the number of <VAR>key</VAR>-<VAR>value</VAR> mappings in this
271
     * <CODE>PdfDictionary</CODE>.
272
     *
273
     * @return the number of <VAR>key</VAR>-<VAR>value</VAR> mappings in this
274
     *   <CODE>PdfDictionary</CODE>.
275
     */
276
    public int size() {
277
        return hashMap.size();
278
    }
279
280
    /**
281
     * Returns <CODE>true</CODE> if this <CODE>PdfDictionary</CODE> contains a
282
     * mapping for the specified <VAR>key</VAR>.
283
     *
284
     * @return <CODE>true</CODE> if the key is set, otherwise <CODE>false</CODE>.
285
     */
286
    public boolean contains(PdfName key) {
287
        return hashMap.containsKey(key);
288
    }
289
290
    // DICTIONARY TYPE METHODS
291
292
    /**
293
     * Checks if a <CODE>Dictionary</CODE> is of the type FONT.
294
     *
295
     * @return <CODE>true</CODE> if it is, otherwise <CODE>false</CODE>.
296
     */
297
    public boolean isFont() {
298 1 1. isFont : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return FONT.equals(dictionaryType);
299
    }
300
301
    /**
302
     * Checks if a <CODE>Dictionary</CODE> is of the type PAGE.
303
     *
304
     * @return <CODE>true</CODE> if it is, otherwise <CODE>false</CODE>.
305
     */
306
    public boolean isPage() {
307 1 1. isPage : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return PAGE.equals(dictionaryType);
308
    }
309
310
    /**
311
     * Checks if a <CODE>Dictionary</CODE> is of the type PAGES.
312
     *
313
     * @return <CODE>true</CODE> if it is, otherwise <CODE>false</CODE>.
314
     */
315
    public boolean isPages() {
316 1 1. isPages : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return PAGES.equals(dictionaryType);
317
    }
318
319
    /**
320
     * Checks if a <CODE>Dictionary</CODE> is of the type CATALOG.
321
     *
322
     * @return <CODE>true</CODE> if it is, otherwise <CODE>false</CODE>.
323
     */
324
    public boolean isCatalog() {
325 1 1. isCatalog : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return CATALOG.equals(dictionaryType);
326
    }
327
328
    /**
329
     * Checks if a <CODE>Dictionary</CODE> is of the type OUTLINES.
330
     *
331
     * @return <CODE>true</CODE> if it is, otherwise <CODE>false</CODE>.
332
     */
333
    public boolean isOutlineTree() {
334 1 1. isOutlineTree : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return OUTLINES.equals(dictionaryType);
335
    }
336
337
    // OTHER METHODS
338
339
    public void merge(PdfDictionary other) {
340 1 1. merge : removed call to java/util/Map::putAll → NO_COVERAGE
        hashMap.putAll(other.hashMap);
341
    }
342
343
    public void mergeDifferent(PdfDictionary other) {
344
        for (PdfName key : other.hashMap.keySet()) {
345 1 1. mergeDifferent : negated conditional → NO_COVERAGE
            if (!hashMap.containsKey(key))
346
                hashMap.put(key, other.hashMap.get(key));
347
        }
348
    }
349
350
     // DOWNCASTING GETTERS
351
     // @author Mark A Storer (2/17/06)
352
353
    /**
354
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfDictionary</CODE>,
355
     * resolving indirect references.
356
     *
357
     * The object associated with the <CODE>PdfName</CODE> given is retrieved
358
     * and resolved to a direct object.
359
     * If it is a <CODE>PdfDictionary</CODE>, it is cast down and returned as
360
     * such. Otherwise <CODE>null</CODE> is returned.
361
     *
362
     * @param key A <CODE>PdfName</CODE>
363
     * @return the associated <CODE>PdfDictionary</CODE> object,
364
     *   or <CODE>null</CODE>
365
     */
366
    public PdfDictionary getAsDict(PdfName key) {
367
        PdfDictionary dict = null;
368
        PdfObject orig = getDirectObject(key);
369 2 1. getAsDict : negated conditional → NO_COVERAGE
2. getAsDict : negated conditional → NO_COVERAGE
        if (orig != null && orig.isDictionary())
370
            dict = (PdfDictionary) orig;
371 1 1. getAsDict : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsDict to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return dict;
372
    }
373
374
    /**
375
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfArray</CODE>,
376
     * resolving indirect references.
377
     *
378
     * The object associated with the <CODE>PdfName</CODE> given is retrieved
379
     * and resolved to a direct object.
380
     * If it is a <CODE>PdfArray</CODE>, it is cast down and returned as such.
381
     * Otherwise <CODE>null</CODE> is returned.
382
     *
383
     * @param key A <CODE>PdfName</CODE>
384
     * @return the associated <CODE>PdfArray</CODE> object,
385
     *   or <CODE>null</CODE>
386
     */
387
    public PdfArray getAsArray(PdfName key) {
388
        PdfArray array = null;
389
        PdfObject orig = getDirectObject(key);
390 2 1. getAsArray : negated conditional → NO_COVERAGE
2. getAsArray : negated conditional → NO_COVERAGE
        if (orig != null && orig.isArray())
391
            array = (PdfArray) orig;
392 1 1. getAsArray : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return array;
393
    }
394
395
    /**
396
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfStream</CODE>,
397
     * resolving indirect references.
398
     *
399
     * The object associated with the <CODE>PdfName</CODE> given is retrieved
400
     * and resolved to a direct object.
401
     * If it is a <CODE>PdfStream</CODE>, it is cast down and returned as such.
402
     * Otherwise <CODE>null</CODE> is returned.
403
     *
404
     * @param key A <CODE>PdfName</CODE>
405
     * @return the associated <CODE>PdfStream</CODE> object,
406
     *   or <CODE>null</CODE>
407
     */
408
    public PdfStream getAsStream(PdfName key) {
409
        PdfStream stream = null;
410
        PdfObject orig = getDirectObject(key);
411 2 1. getAsStream : negated conditional → NO_COVERAGE
2. getAsStream : negated conditional → NO_COVERAGE
        if (orig != null && orig.isStream())
412
            stream = (PdfStream) orig;
413 1 1. getAsStream : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsStream to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return stream;
414
    }
415
416
    /**
417
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfString</CODE>,
418
     * resolving indirect references.
419
     *
420
     * The object associated with the <CODE>PdfName</CODE> given is retrieved
421
     * and resolved to a direct object.
422
     * If it is a <CODE>PdfString</CODE>, it is cast down and returned as such.
423
     * Otherwise <CODE>null</CODE> is returned.
424
     *
425
     * @param key A <CODE>PdfName</CODE>
426
     * @return the associated <CODE>PdfString</CODE> object,
427
     *   or <CODE>null</CODE>
428
     */
429
    public PdfString getAsString(PdfName key) {
430
        PdfString string = null;
431
        PdfObject orig = getDirectObject(key);
432 2 1. getAsString : negated conditional → NO_COVERAGE
2. getAsString : negated conditional → NO_COVERAGE
        if (orig != null && orig.isString())
433
            string = (PdfString) orig;
434 1 1. getAsString : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsString to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return string;
435
    }
436
437
    /**
438
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfNumber</CODE>,
439
     * resolving indirect references.
440
     *
441
     * The object associated with the <CODE>PdfName</CODE> given is retrieved
442
     * and resolved to a direct object.
443
     * If it is a <CODE>PdfNumber</CODE>, it is cast down and returned as such.
444
     * Otherwise <CODE>null</CODE> is returned.
445
     *
446
     * @param key A <CODE>PdfName</CODE>
447
     * @return the associated <CODE>PdfNumber</CODE> object,
448
     *   or <CODE>null</CODE>
449
     */
450
    public PdfNumber getAsNumber(PdfName key) {
451
        PdfNumber number = null;
452
        PdfObject orig = getDirectObject(key);
453 2 1. getAsNumber : negated conditional → NO_COVERAGE
2. getAsNumber : negated conditional → NO_COVERAGE
        if (orig != null && orig.isNumber())
454
            number = (PdfNumber) orig;
455 1 1. getAsNumber : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsNumber to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return number;
456
    }
457
458
    /**
459
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfName</CODE>,
460
     * resolving indirect references.
461
     *
462
     * The object associated with the <CODE>PdfName</CODE> given is retrieved
463
     * and resolved to a direct object.
464
     * If it is a <CODE>PdfName</CODE>, it is cast down and returned as such.
465
     * Otherwise <CODE>null</CODE> is returned.
466
     *
467
     * @param key A <CODE>PdfName</CODE>
468
     * @return the associated <CODE>PdfName</CODE> object,
469
     *   or <CODE>null</CODE>
470
     */
471
    public PdfName getAsName(PdfName key) {
472
        PdfName name = null;
473
        PdfObject orig = getDirectObject(key);
474 2 1. getAsName : negated conditional → NO_COVERAGE
2. getAsName : negated conditional → NO_COVERAGE
        if (orig != null && orig.isName())
475
            name = (PdfName) orig;
476 1 1. getAsName : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return name;
477
    }
478
479
    /**
480
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfBoolean</CODE>,
481
     * resolving indirect references.
482
     *
483
     * The object associated with the <CODE>PdfName</CODE> given is retrieved
484
     * and resolved to a direct object.
485
     * If it is a <CODE>PdfBoolean</CODE>, it is cast down and returned as such.
486
     * Otherwise <CODE>null</CODE> is returned.
487
     *
488
     * @param key A <CODE>PdfName</CODE>
489
     * @return the associated <CODE>PdfBoolean</CODE> object,
490
     *   or <CODE>null</CODE>
491
     */
492
    public PdfBoolean getAsBoolean(PdfName key) {
493
        PdfBoolean bool = null;
494
        PdfObject orig = getDirectObject(key);
495 2 1. getAsBoolean : negated conditional → NO_COVERAGE
2. getAsBoolean : negated conditional → NO_COVERAGE
        if (orig != null && orig.isBoolean())
496
            bool = (PdfBoolean)orig;
497 1 1. getAsBoolean : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsBoolean to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return bool;
498
    }
499
500
    /**
501
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfIndirectReference</CODE>.
502
     *
503
     * The object associated with the <CODE>PdfName</CODE> given is retrieved
504
     * If it is a <CODE>PdfIndirectReference</CODE>, it is cast down and returned
505
     * as such. Otherwise <CODE>null</CODE> is returned.
506
     *
507
     * @param key A <CODE>PdfName</CODE>
508
     * @return the associated <CODE>PdfIndirectReference</CODE> object,
509
     *   or <CODE>null</CODE>
510
     */
511
    public PdfIndirectReference getAsIndirectObject(PdfName key) {
512
        PdfIndirectReference ref = null;
513
        PdfObject orig = get(key); // not getDirect this time.
514 2 1. getAsIndirectObject : negated conditional → NO_COVERAGE
2. getAsIndirectObject : negated conditional → NO_COVERAGE
        if (orig != null && orig.isIndirect())
515
            ref = (PdfIndirectReference) orig;
516 1 1. getAsIndirectObject : mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsIndirectObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return ref;
517
    }
518
}

Mutations

125

1.1
Location :
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

139

1.1
Location : toPdf
Killed by : none
removed call to java/io/OutputStream::write → NO_COVERAGE

140

1.1
Location : toPdf
Killed by : none
removed call to java/io/OutputStream::write → NO_COVERAGE

144

1.1
Location : toPdf
Killed by : none
removed call to com/lowagie/text/pdf/PdfName::toPdf → NO_COVERAGE

146

1.1
Location : toPdf
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : toPdf
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : toPdf
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : toPdf
Killed by : none
negated conditional → NO_COVERAGE

147

1.1
Location : toPdf
Killed by : none
removed call to java/io/OutputStream::write → NO_COVERAGE

148

1.1
Location : toPdf
Killed by : none
removed call to com/lowagie/text/pdf/PdfObject::toPdf → NO_COVERAGE

150

1.1
Location : toPdf
Killed by : none
removed call to java/io/OutputStream::write → NO_COVERAGE

151

1.1
Location : toPdf
Killed by : none
removed call to java/io/OutputStream::write → NO_COVERAGE

185

1.1
Location : put
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : put
Killed by : none
negated conditional → NO_COVERAGE

204

1.1
Location : putEx
Killed by : none
negated conditional → NO_COVERAGE

206

1.1
Location : putEx
Killed by : none
removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE

220

1.1
Location : putAll
Killed by : none
removed call to java/util/Map::putAll → NO_COVERAGE

242

1.1
Location : get
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

257

1.1
Location : getDirectObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getDirectObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

298

1.1
Location : isFont
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

307

1.1
Location : isPage
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

316

1.1
Location : isPages
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

325

1.1
Location : isCatalog
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

334

1.1
Location : isOutlineTree
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

340

1.1
Location : merge
Killed by : none
removed call to java/util/Map::putAll → NO_COVERAGE

345

1.1
Location : mergeDifferent
Killed by : none
negated conditional → NO_COVERAGE

369

1.1
Location : getAsDict
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getAsDict
Killed by : none
negated conditional → NO_COVERAGE

371

1.1
Location : getAsDict
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsDict to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

390

1.1
Location : getAsArray
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getAsArray
Killed by : none
negated conditional → NO_COVERAGE

392

1.1
Location : getAsArray
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

411

1.1
Location : getAsStream
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getAsStream
Killed by : none
negated conditional → NO_COVERAGE

413

1.1
Location : getAsStream
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsStream to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

432

1.1
Location : getAsString
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getAsString
Killed by : none
negated conditional → NO_COVERAGE

434

1.1
Location : getAsString
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsString to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

453

1.1
Location : getAsNumber
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getAsNumber
Killed by : none
negated conditional → NO_COVERAGE

455

1.1
Location : getAsNumber
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsNumber to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

474

1.1
Location : getAsName
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getAsName
Killed by : none
negated conditional → NO_COVERAGE

476

1.1
Location : getAsName
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

495

1.1
Location : getAsBoolean
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getAsBoolean
Killed by : none
negated conditional → NO_COVERAGE

497

1.1
Location : getAsBoolean
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsBoolean to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

514

1.1
Location : getAsIndirectObject
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getAsIndirectObject
Killed by : none
negated conditional → NO_COVERAGE

516

1.1
Location : getAsIndirectObject
Killed by : none
mutated return of Object value for com/lowagie/text/pdf/PdfDictionary::getAsIndirectObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.4.2