PdfArray.java

1
/*
2
 * $Id: PdfArray.java 3761 2009-03-06 16:33:57Z 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.ArrayList;
55
import java.util.Iterator;
56
import java.util.List;
57
import java.util.ListIterator;
58
59
/**
60
 * <CODE>PdfArray</CODE> is the PDF Array object.
61
 * <P>
62
 * An array is a sequence of PDF objects. An array may contain a mixture of
63
 * object types. An array is written as a left square bracket ([), followed by a
64
 * sequence of objects, followed by a right square bracket (]).<BR>
65
 * This object is described in the 'Portable Document Format Reference Manual
66
 * version 1.7' section 3.2.5 (page 58).
67
 * 
68
 * @see PdfObject
69
 */
70
public class PdfArray extends PdfObject {
71
72
    // CLASS VARIABLES
73
74
    /** this is the actual array of PdfObjects */
75
    protected List<PdfObject> arrayList;
76
77
    // constructors
78
79
    /**
80
     * Constructs an empty <CODE>PdfArray</CODE>-object.
81
     */
82
    public PdfArray() {
83
        super(ARRAY);
84
        arrayList = new ArrayList<>();
85
    }
86
87
    /**
88
     * Constructs an <CODE>PdfArray</CODE>-object, containing 1
89
     * <CODE>PdfObject</CODE>.
90
     * 
91
     * @param object
92
     *            a <CODE>PdfObject</CODE> that has to be added to the array
93
     */
94
    public PdfArray(PdfObject object) {
95
        this();
96
        arrayList.add(object);
97
    }
98
99
    /**
100
     * Constructs a <CODE>PdfArray</CODE>-object, containing all
101
     * <CODE>float</CODE> values in a specified array.
102
     * 
103
     * The <CODE>float</CODE> values are internally converted to
104
     * <CODE>PdfNumber</CODE> objects.
105
     * 
106
     * @param values
107
     *            an array of <CODE>float</CODE> values to be added
108
     */
109
    public PdfArray(float[] values) {
110
        this();
111
        add(values);
112
    }
113
114
    /**
115
     * Constructs a <CODE>PdfArray</CODE>-object, containing all
116
     * <CODE>int</CODE> values in a specified array.
117
     * 
118
     * The <CODE>int</CODE> values are internally converted to
119
     * <CODE>PdfNumber</CODE> objects.
120
     * 
121
     * @param values
122
     *            an array of <CODE>int</CODE> values to be added
123
     */
124
    public PdfArray(int[] values) {
125
        this();
126
        add(values);
127
    }
128
129
    /**
130
     * Constructs a <CODE>PdfArray</CODE>, containing all elements of a
131
     * specified <CODE>List</CODE>.
132
     *
133
     * @param pdfObjectList
134
     *            an <CODE>List</CODE> with <CODE>PdfObject</CODE>s to be
135
     *            added to the array
136
     * @since 2.1.3
137
     */
138
    public PdfArray(List<PdfObject> pdfObjectList) {
139
        this();
140 1 1. : negated conditional → NO_COVERAGE
        if (pdfObjectList != null) {
141
            arrayList.addAll(pdfObjectList);
142
        }
143
    }
144
145
    /**
146
     * Constructs an <CODE>PdfArray</CODE>-object, containing all
147
     * <CODE>PdfObject</CODE>s in a specified <CODE>PdfArray</CODE>.
148
     * 
149
     * @param array
150
     *            a <CODE>PdfArray</CODE> to be added to the array
151
     */
152
    public PdfArray(PdfArray array) {
153
        this(array.getElements());
154
    }
155
156
    // METHODS OVERRIDING SOME PDFOBJECT METHODS
157
158
    /**
159
     * Writes the PDF representation of this <CODE>PdfArray</CODE> as an array
160
     * of <CODE>byte</CODE> to the specified <CODE>OutputStream</CODE>.
161
     * 
162
     * @param writer
163
     *            for backwards compatibility
164
     * @param os
165
     *            the <CODE>OutputStream</CODE> to write the bytes to.
166
     */
167
    @Override
168
    public void toPdf(PdfWriter writer, OutputStream os) throws IOException {
169 1 1. toPdf : removed call to java/io/OutputStream::write → NO_COVERAGE
        os.write('[');
170
171
        Iterator<PdfObject> i = arrayList.iterator();
172
        PdfObject object;
173
        int type;
174 1 1. toPdf : negated conditional → NO_COVERAGE
        if (i.hasNext()) {
175
            object = i.next();
176 1 1. toPdf : negated conditional → NO_COVERAGE
            if (object == null) {
177
                object = PdfNull.PDFNULL;
178
            }
179 1 1. toPdf : removed call to com/lowagie/text/pdf/PdfObject::toPdf → NO_COVERAGE
            object.toPdf(writer, os);
180
        }
181 1 1. toPdf : negated conditional → NO_COVERAGE
        while (i.hasNext()) {
182
            object = i.next();
183 1 1. toPdf : negated conditional → NO_COVERAGE
            if (object == null) {
184
                object = PdfNull.PDFNULL;
185
            }
186
            type = object.type();
187 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
188
                    && type != PdfObject.NAME && type != PdfObject.STRING) {
189 1 1. toPdf : removed call to java/io/OutputStream::write → NO_COVERAGE
                os.write(' ');
190
            }
191 1 1. toPdf : removed call to com/lowagie/text/pdf/PdfObject::toPdf → NO_COVERAGE
            object.toPdf(writer, os);
192
        }
193 1 1. toPdf : removed call to java/io/OutputStream::write → NO_COVERAGE
        os.write(']');
194
    }
195
196
    /**
197
     * Returns a string representation of this <CODE>PdfArray</CODE>.
198
     * 
199
     * The string representation consists of a list of all
200
     * <CODE>PdfObject</CODE>s contained in this <CODE>PdfArray</CODE>, enclosed
201
     * in square brackets ("[]"). Adjacent elements are separated by the
202
     * characters ", " (comma and space).
203
     * 
204
     * @return the string representation of this <CODE>PdfArray</CODE>
205
     */
206
    @Override
207
    public String toString() {
208
        return arrayList.toString();
209
    }
210
211
    // ARRAY CONTENT METHODS
212
213
    /**
214
     * Overwrites a specified location of the array, returning the previous
215
     * value
216
     * 
217
     * @param idx
218
     *            The index of the element to be overwritten
219
     * @param obj
220
     *            new value for the specified index
221
     * @throws IndexOutOfBoundsException
222
     *             if the specified position doesn't exist
223
     * @return the previous value
224
     * @since 2.1.5
225
     */
226
    public PdfObject set(int idx, PdfObject obj) {
227 1 1. set : mutated return of Object value for com/lowagie/text/pdf/PdfArray::set to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return arrayList.set(idx, obj);
228
    }
229
230
    /**
231
     * Remove the element at the specified position from the array.
232
     * 
233
     * Shifts any subsequent elements to the left (subtracts one from their
234
     * indices).
235
     * 
236
     * @param idx
237
     *            The index of the element to be removed.
238
     * @throws IndexOutOfBoundsException
239
     *             the specified position doesn't exist
240
     * @since 2.1.5
241
     */
242
    public PdfObject remove(int idx) {
243 1 1. remove : mutated return of Object value for com/lowagie/text/pdf/PdfArray::remove to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return arrayList.remove(idx);
244
    }
245
246
    /**
247
     * Get a copy the internal list for this PdfArray.
248
     *
249
     * @deprecated Please use getElements() instead.
250
     * @return a copy of the the internal List.
251
     */
252
    @Deprecated
253
    public List<PdfObject> getArrayList() {
254
        return getElements();
255
    }
256
257
    /**
258
     * Get a copy the internal list for this PdfArray.
259
     *
260
     * @return a copy of the the internal List.
261
     */
262
    public List<PdfObject> getElements() {
263 1 1. getElements : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getElements to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return new ArrayList<>(arrayList);
264
    }
265
266
    /**
267
     * Returns the number of entries in the array.
268
     *
269
     * @return the size of the List
270
     */
271
    public int size() {
272
        return arrayList.size();
273
    }
274
275
    /**
276
     * Returns <CODE>true</CODE> if the array is empty.
277
     * 
278
     * @return <CODE>true</CODE> if the array is empty
279
     * @since 2.1.5
280
     */
281
    public boolean isEmpty() {
282
        return arrayList.isEmpty();
283
    }
284
285
    /**
286
     * Adds a <CODE>PdfObject</CODE> to the end of the <CODE>PdfArray</CODE>.
287
     * 
288
     * The <CODE>PdfObject</CODE> will be the last element.
289
     * 
290
     * @param object
291
     *            <CODE>PdfObject</CODE> to add
292
     * @return always <CODE>true</CODE>
293
     */
294
    public boolean add(PdfObject object) {
295
        return arrayList.add(object);
296
    }
297
298
    /**
299
     * Adds an array of <CODE>float</CODE> values to end of the
300
     * <CODE>PdfArray</CODE>.
301
     * 
302
     * The values will be the last elements. The <CODE>float</CODE> values are
303
     * internally converted to <CODE>PdfNumber</CODE> objects.
304
     * 
305
     * @param values
306
     *            An array of <CODE>float</CODE> values to add
307
     * @return always <CODE>true</CODE>
308
     */
309
    public boolean add(float[] values) {
310
        for (float value : values) {
311
            arrayList.add(new PdfNumber(value));
312
        }
313 1 1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return true;
314
    }
315
316
    /**
317
     * Adds an array of <CODE>int</CODE> values to end of the
318
     * <CODE>PdfArray</CODE>.
319
     * 
320
     * The values will be the last elements. The <CODE>int</CODE> values are
321
     * internally converted to <CODE>PdfNumber</CODE> objects.
322
     * 
323
     * @param values
324
     *            An array of <CODE>int</CODE> values to add
325
     * @return always <CODE>true</CODE>
326
     */
327
    public boolean add(int[] values) {
328
        for (int value : values) {
329
            arrayList.add(new PdfNumber(value));
330
        }
331 1 1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
        return true;
332
    }
333
334
    /**
335
     * Inserts the specified element at the specified position.
336
     * 
337
     * Shifts the element currently at that position (if any) and any subsequent
338
     * elements to the right (adds one to their indices).
339
     * 
340
     * @param index
341
     *            The index at which the specified element is to be inserted
342
     * @param element
343
     *            The element to be inserted
344
     * @throws IndexOutOfBoundsException
345
     *             if the specified index is larger than the last position
346
     *             currently set, plus 1.
347
     * @since 2.1.5
348
     */
349
    public void add(int index, PdfObject element) {
350
        arrayList.add(index, element);
351
    }
352
353
    /**
354
     * Inserts a <CODE>PdfObject</CODE> at the beginning of the
355
     * <CODE>PdfArray</CODE>.
356
     * 
357
     * The <CODE>PdfObject</CODE> will be the first element, any other elements
358
     * will be shifted to the right (adds one to their indices).
359
     * 
360
     * @param object
361
     *            The <CODE>PdfObject</CODE> to add
362
     */
363
    public void addFirst(PdfObject object) {
364 1 1. addFirst : removed call to java/util/List::add → NO_COVERAGE
        arrayList.add(0, object);
365
    }
366
367
    /**
368
     * Checks if the <CODE>PdfArray</CODE> already contains a certain
369
     * <CODE>PdfObject</CODE>.
370
     * 
371
     * @param object
372
     *            The <CODE>PdfObject</CODE> to check
373
     * @return <CODE>true</CODE>
374
     */
375
    public boolean contains(PdfObject object) {
376
        return arrayList.contains(object);
377
    }
378
379
    /**
380
     * Returns the list iterator for the array.
381
     * 
382
     * @return a ListIterator
383
     */
384
    public ListIterator<PdfObject> listIterator() {
385
        return arrayList.listIterator();
386
    }
387
388
    /**
389
     * Returns the <CODE>PdfObject</CODE> with the specified index.
390
     * 
391
     * A possible indirect references is not resolved, so the returned
392
     * <CODE>PdfObject</CODE> may be either a direct object or an indirect
393
     * reference, depending on how the object is stored in the
394
     * <CODE>PdfArray</CODE>.
395
     * 
396
     * @param idx
397
     *            The index of the <CODE>PdfObject</CODE> to be returned
398
     * @return A <CODE>PdfObject</CODE>
399
     */
400
    public PdfObject getPdfObject(int idx) {
401 1 1. getPdfObject : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getPdfObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return arrayList.get(idx);
402
    }
403
404
    /**
405
     * Returns the <CODE>PdfObject</CODE> with the specified index, resolving a
406
     * possible indirect reference to a direct object.
407
     * 
408
     * Thus this method will never return a <CODE>PdfIndirectReference</CODE>
409
     * object.
410
     * 
411
     * @param idx
412
     *            The index of the <CODE>PdfObject</CODE> to be returned
413
     * @return A direct <CODE>PdfObject</CODE> or <CODE>null</CODE>
414
     */
415
    public PdfObject getDirectObject(int idx) {
416 1 1. getDirectObject : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getDirectObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return PdfReader.getPdfObject(getPdfObject(idx));
417
    }
418
419
    // DOWNCASTING GETTERS
420
    // @author Mark A Storer (2/17/06)
421
422
    /**
423
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfDictionary</CODE>,
424
     * resolving indirect references.
425
     * 
426
     * The object corresponding to the specified index is retrieved and
427
     * resolvedto a direct object. If it is a <CODE>PdfDictionary</CODE>, it is
428
     * cast down and returned as such. Otherwise <CODE>null</CODE> is returned.
429
     * 
430
     * @param idx
431
     *            The index of the <CODE>PdfObject</CODE> to be returned
432
     * @return the corresponding <CODE>PdfDictionary</CODE> object, or
433
     *         <CODE>null</CODE>
434
     */
435
    public PdfDictionary getAsDict(int idx) {
436
        PdfDictionary dict = null;
437
        PdfObject orig = getDirectObject(idx);
438 2 1. getAsDict : negated conditional → NO_COVERAGE
2. getAsDict : negated conditional → NO_COVERAGE
        if (orig != null && orig.isDictionary()) {
439
            dict = (PdfDictionary) orig;
440
        }
441 1 1. getAsDict : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getAsDict to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return dict;
442
    }
443
444
    /**
445
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfArray</CODE>, resolving
446
     * indirect references.
447
     * 
448
     * The object corresponding to the specified index is retrieved and resolved
449
     * to a direct object. If it is a <CODE>PdfArray</CODE>, it is cast down and
450
     * returned as such. Otherwise <CODE>null</CODE> is returned.
451
     * 
452
     * @param idx
453
     *            The index of the <CODE>PdfObject</CODE> to be returned
454
     * @return the corresponding <CODE>PdfArray</CODE> object, or
455
     *         <CODE>null</CODE>
456
     */
457
    public PdfArray getAsArray(int idx) {
458
        PdfArray array = null;
459
        PdfObject orig = getDirectObject(idx);
460 2 1. getAsArray : negated conditional → NO_COVERAGE
2. getAsArray : negated conditional → NO_COVERAGE
        if (orig != null && orig.isArray()) {
461
            array = (PdfArray) orig;
462
        }
463 1 1. getAsArray : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getAsArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return array;
464
    }
465
466
    /**
467
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfStream</CODE>, resolving
468
     * indirect references.
469
     * 
470
     * The object corresponding to the specified index is retrieved and resolved
471
     * to a direct object. If it is a <CODE>PdfStream</CODE>, it is cast down
472
     * and returned as such. Otherwise <CODE>null</CODE> is returned.
473
     * 
474
     * @param idx
475
     *            The index of the <CODE>PdfObject</CODE> to be returned
476
     * @return the corresponding <CODE>PdfStream</CODE> object, or
477
     *         <CODE>null</CODE>
478
     */
479
    public PdfStream getAsStream(int idx) {
480
        PdfStream stream = null;
481
        PdfObject orig = getDirectObject(idx);
482 2 1. getAsStream : negated conditional → NO_COVERAGE
2. getAsStream : negated conditional → NO_COVERAGE
        if (orig != null && orig.isStream()) {
483
            stream = (PdfStream) orig;
484
        }
485 1 1. getAsStream : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getAsStream to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return stream;
486
    }
487
488
    /**
489
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfString</CODE>, resolving
490
     * indirect references.
491
     * 
492
     * The object corresponding to the specified index is retrieved and resolved
493
     * to a direct object. If it is a <CODE>PdfString</CODE>, it is cast down
494
     * and returned as such. Otherwise <CODE>null</CODE> is returned.
495
     * 
496
     * @param idx
497
     *            The index of the <CODE>PdfObject</CODE> to be returned
498
     * @return the corresponding <CODE>PdfString</CODE> object, or
499
     *         <CODE>null</CODE>
500
     */
501
    public PdfString getAsString(int idx) {
502
        PdfString string = null;
503
        PdfObject orig = getDirectObject(idx);
504 2 1. getAsString : negated conditional → NO_COVERAGE
2. getAsString : negated conditional → NO_COVERAGE
        if (orig != null && orig.isString()) {
505
            string = (PdfString) orig;
506
        }
507 1 1. getAsString : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getAsString to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return string;
508
    }
509
510
    /**
511
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfNumber</CODE>, resolving
512
     * indirect references.
513
     * 
514
     * The object corresponding to the specified index is retrieved and resolved
515
     * to a direct object. If it is a <CODE>PdfNumber</CODE>, it is cast down
516
     * and returned as such. Otherwise <CODE>null</CODE> is returned.
517
     * 
518
     * @param idx
519
     *            The index of the <CODE>PdfObject</CODE> to be returned
520
     * @return the corresponding <CODE>PdfNumber</CODE> object, or
521
     *         <CODE>null</CODE>
522
     */
523
    public PdfNumber getAsNumber(int idx) {
524
        PdfNumber number = null;
525
        PdfObject orig = getDirectObject(idx);
526 2 1. getAsNumber : negated conditional → NO_COVERAGE
2. getAsNumber : negated conditional → NO_COVERAGE
        if (orig != null && orig.isNumber()) {
527
            number = (PdfNumber) orig;
528
        }
529 1 1. getAsNumber : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getAsNumber to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return number;
530
    }
531
532
    /**
533
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfName</CODE>, resolving
534
     * indirect references.
535
     * 
536
     * The object corresponding to the specified index is retrieved and resolved
537
     * to a direct object. If it is a <CODE>PdfName</CODE>, it is cast down and
538
     * returned as such. Otherwise <CODE>null</CODE> is returned.
539
     * 
540
     * @param idx
541
     *            The index of the <CODE>PdfObject</CODE> to be returned
542
     * @return the corresponding <CODE>PdfName</CODE> object, or
543
     *         <CODE>null</CODE>
544
     */
545
    public PdfName getAsName(int idx) {
546
        PdfName name = null;
547
        PdfObject orig = getDirectObject(idx);
548 2 1. getAsName : negated conditional → NO_COVERAGE
2. getAsName : negated conditional → NO_COVERAGE
        if (orig != null && orig.isName()) {
549
            name = (PdfName) orig;
550
        }
551 1 1. getAsName : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getAsName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return name;
552
    }
553
554
    /**
555
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfBoolean</CODE>, resolving
556
     * indirect references.
557
     * 
558
     * The object corresponding to the specified index is retrieved and resolved
559
     * to a direct object. If it is a <CODE>PdfBoolean</CODE>, it is cast down
560
     * and returned as such. Otherwise <CODE>null</CODE> is returned.
561
     * 
562
     * @param idx
563
     *            The index of the <CODE>PdfObject</CODE> to be returned
564
     * @return the corresponding <CODE>PdfBoolean</CODE> object, or
565
     *         <CODE>null</CODE>
566
     */
567
    public PdfBoolean getAsBoolean(int idx) {
568
        PdfBoolean bool = null;
569
        PdfObject orig = getDirectObject(idx);
570 2 1. getAsBoolean : negated conditional → NO_COVERAGE
2. getAsBoolean : negated conditional → NO_COVERAGE
        if (orig != null && orig.isBoolean()) {
571
            bool = (PdfBoolean) orig;
572
        }
573 1 1. getAsBoolean : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getAsBoolean to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return bool;
574
    }
575
576
    /**
577
     * Returns a <CODE>PdfObject</CODE> as a <CODE>PdfIndirectReference</CODE>.
578
     * 
579
     * The object corresponding to the specified index is retrieved. If it is a
580
     * <CODE>PdfIndirectReference</CODE>, it is cast down and returned as such.
581
     * Otherwise <CODE>null</CODE> is returned.
582
     * 
583
     * @param idx
584
     *            The index of the <CODE>PdfObject</CODE> to be returned
585
     * @return the corresponding <CODE>PdfIndirectReference</CODE> object, or
586
     *         <CODE>null</CODE>
587
     */
588
    public PdfIndirectReference getAsIndirectObject(int idx) {
589
        PdfIndirectReference ref = null;
590
        PdfObject orig = getPdfObject(idx); // not getDirect this time.
591 2 1. getAsIndirectObject : negated conditional → NO_COVERAGE
2. getAsIndirectObject : negated conditional → NO_COVERAGE
        if (orig != null && orig.isIndirect()) {
592
            ref = (PdfIndirectReference) orig;
593
        }
594 1 1. getAsIndirectObject : mutated return of Object value for com/lowagie/text/pdf/PdfArray::getAsIndirectObject to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return ref;
595
    }
596
}

Mutations

140

1.1
Location :
Killed by : none
negated conditional → NO_COVERAGE

169

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

174

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

176

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

179

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

181

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

183

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

187

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

189

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

191

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

193

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

227

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

243

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

263

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

313

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

331

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

364

1.1
Location : addFirst
Killed by : none
removed call to java/util/List::add → NO_COVERAGE

401

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

416

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

438

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

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

441

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

460

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

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

463

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

482

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

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

485

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

504

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

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

507

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

526

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

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

529

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

548

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

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

551

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

570

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

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

573

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

591

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

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

594

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

Active mutators

Tests examined


Report generated by PIT 1.4.2