PdfFunction.java

1
/*
2
 * Copyright 2002 Paulo Soares
3
 *
4
 * The contents of this file are subject to the Mozilla Public License Version 1.1
5
 * (the "License"); you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
7
 *
8
 * Software distributed under the License is distributed on an "AS IS" basis,
9
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10
 * for the specific language governing rights and limitations under the License.
11
 *
12
 * The Original Code is 'iText, a free JAVA-PDF library'.
13
 *
14
 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
15
 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
16
 * All Rights Reserved.
17
 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
18
 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
19
 *
20
 * Contributor(s): all the names of the contributors are added in the source code
21
 * where applicable.
22
 *
23
 * Alternatively, the contents of this file may be used under the terms of the
24
 * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
25
 * provisions of LGPL are applicable instead of those above.  If you wish to
26
 * allow use of your version of this file only under the terms of the LGPL
27
 * License and not to allow others to use your version of this file under
28
 * the MPL, indicate your decision by deleting the provisions above and
29
 * replace them with the notice and other provisions required by the LGPL.
30
 * If you do not delete the provisions above, a recipient may use your version
31
 * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
32
 *
33
 * This library is free software; you can redistribute it and/or modify it
34
 * under the terms of the MPL as stated above or under the terms of the GNU
35
 * Library General Public License as published by the Free Software Foundation;
36
 * either version 2 of the License, or any later version.
37
 *
38
 * This library is distributed in the hope that it will be useful, but WITHOUT
39
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
40
 * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
41
 * details.
42
 *
43
 * If you didn't download this code from the following link, you should check if
44
 * you aren't using an obsolete version:
45
 * http://www.lowagie.com/iText/
46
 */
47
package com.lowagie.text.pdf;
48
49
import com.lowagie.text.ExceptionConverter;
50
51
import java.io.IOException;
52
53
54
/** Implements PDF functions.
55
 *
56
 * @author Paulo Soares (psoares@consiste.pt)
57
 */
58
public class PdfFunction {
59
    
60
    protected PdfWriter writer;
61
    
62
    protected PdfIndirectReference reference;
63
    
64
    protected PdfDictionary dictionary;
65
    
66
    /** Creates new PdfFunction */
67
    protected PdfFunction(PdfWriter writer) {
68
        this.writer = writer;
69
    }
70
    
71
    PdfIndirectReference getReference() {
72
        try {
73 1 1. getReference : negated conditional → NO_COVERAGE
            if (reference == null) {
74
                reference = writer.addToBody(dictionary).getIndirectReference();
75
            }
76
        }
77
        catch (IOException ioe) {
78
            throw new ExceptionConverter(ioe);
79
        }
80 1 1. getReference : mutated return of Object value for com/lowagie/text/pdf/PdfFunction::getReference to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return reference;
81
    }
82
        
83
    public static PdfFunction type0(PdfWriter writer, float[] domain, float[] range, int[] size,
84
                                    int bitsPerSample, int order, float[] encode, float[] decode, byte[] stream) {
85
        PdfFunction func = new PdfFunction(writer);
86
        func.dictionary = new PdfStream(stream);
87 1 1. type0 : removed call to com/lowagie/text/pdf/PdfStream::flateCompress → NO_COVERAGE
        ((PdfStream)func.dictionary).flateCompress(writer.getCompressionLevel());
88 1 1. type0 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.FUNCTIONTYPE, new PdfNumber(0));
89 1 1. type0 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.DOMAIN, new PdfArray(domain));
90 1 1. type0 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.RANGE, new PdfArray(range));
91 1 1. type0 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.SIZE, new PdfArray(size));
92 1 1. type0 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.BITSPERSAMPLE, new PdfNumber(bitsPerSample));
93 1 1. type0 : negated conditional → NO_COVERAGE
        if (order != 1)
94 1 1. type0 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            func.dictionary.put(PdfName.ORDER, new PdfNumber(order));
95 1 1. type0 : negated conditional → NO_COVERAGE
        if (encode != null)
96 1 1. type0 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            func.dictionary.put(PdfName.ENCODE, new PdfArray(encode));
97 1 1. type0 : negated conditional → NO_COVERAGE
        if (decode != null)
98 1 1. type0 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            func.dictionary.put(PdfName.DECODE, new PdfArray(decode));
99 1 1. type0 : mutated return of Object value for com/lowagie/text/pdf/PdfFunction::type0 to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return func;
100
    }
101
102
    public static PdfFunction type2(PdfWriter writer, float[] domain, float[] range, float[] c0, float[] c1, float n) {
103
        PdfFunction func = new PdfFunction(writer);
104
        func.dictionary = new PdfDictionary();
105 1 1. type2 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.FUNCTIONTYPE, new PdfNumber(2));
106 1 1. type2 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.DOMAIN, new PdfArray(domain));
107 1 1. type2 : negated conditional → NO_COVERAGE
        if (range != null)
108 1 1. type2 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            func.dictionary.put(PdfName.RANGE, new PdfArray(range));
109 1 1. type2 : negated conditional → NO_COVERAGE
        if (c0 != null)
110 1 1. type2 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            func.dictionary.put(PdfName.C0, new PdfArray(c0));
111 1 1. type2 : negated conditional → NO_COVERAGE
        if (c1 != null)
112 1 1. type2 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            func.dictionary.put(PdfName.C1, new PdfArray(c1));
113 1 1. type2 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.N, new PdfNumber(n));
114 1 1. type2 : mutated return of Object value for com/lowagie/text/pdf/PdfFunction::type2 to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return func;
115
    }
116
117
    public static PdfFunction type3(PdfWriter writer, float[] domain, float[] range, PdfFunction[] functions, float[] bounds, float[] encode) {
118
        PdfFunction func = new PdfFunction(writer);
119
        func.dictionary = new PdfDictionary();
120 1 1. type3 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.FUNCTIONTYPE, new PdfNumber(3));
121 1 1. type3 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.DOMAIN, new PdfArray(domain));
122 1 1. type3 : negated conditional → NO_COVERAGE
        if (range != null)
123 1 1. type3 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
            func.dictionary.put(PdfName.RANGE, new PdfArray(range));
124
        PdfArray array = new PdfArray();
125
        for (PdfFunction function : functions) array.add(function.getReference());
126 1 1. type3 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.FUNCTIONS, array);
127 1 1. type3 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.BOUNDS, new PdfArray(bounds));
128 1 1. type3 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.ENCODE, new PdfArray(encode));
129 1 1. type3 : mutated return of Object value for com/lowagie/text/pdf/PdfFunction::type3 to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return func;
130
    }
131
    
132
    public static PdfFunction type4(PdfWriter writer, float[] domain, float[] range, String postscript) {
133
        byte[] b = new byte[postscript.length()];
134 2 1. type4 : changed conditional boundary → NO_COVERAGE
2. type4 : negated conditional → NO_COVERAGE
        for (int k = 0; k < b.length; ++k)
135
            b[k] = (byte)postscript.charAt(k);
136
        PdfFunction func = new PdfFunction(writer);
137
        func.dictionary = new PdfStream(b);
138 1 1. type4 : removed call to com/lowagie/text/pdf/PdfStream::flateCompress → NO_COVERAGE
        ((PdfStream)func.dictionary).flateCompress(writer.getCompressionLevel());
139 1 1. type4 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.FUNCTIONTYPE, new PdfNumber(4));
140 1 1. type4 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.DOMAIN, new PdfArray(domain));
141 1 1. type4 : removed call to com/lowagie/text/pdf/PdfDictionary::put → NO_COVERAGE
        func.dictionary.put(PdfName.RANGE, new PdfArray(range));
142 1 1. type4 : mutated return of Object value for com/lowagie/text/pdf/PdfFunction::type4 to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
        return func;
143
    }
144
}

Mutations

73

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

80

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

87

1.1
Location : type0
Killed by : none
removed call to com/lowagie/text/pdf/PdfStream::flateCompress → NO_COVERAGE

88

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

89

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

90

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

91

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

92

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

93

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

94

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

95

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

96

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

97

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

98

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

99

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

105

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

106

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

107

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

108

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

109

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

110

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

111

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

112

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

113

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

114

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

120

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

121

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

122

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

123

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

126

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

127

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

128

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

129

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

134

1.1
Location : type4
Killed by : none
changed conditional boundary → NO_COVERAGE

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

138

1.1
Location : type4
Killed by : none
removed call to com/lowagie/text/pdf/PdfStream::flateCompress → NO_COVERAGE

139

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

140

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

141

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

142

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

Active mutators

Tests examined


Report generated by PIT 1.4.2