1 | /* | |
2 | * $Id: Meta.java 3373 2008-05-12 16:21:24Z xlv $ | |
3 | * | |
4 | * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * 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; | |
51 | ||
52 | import java.util.ArrayList; | |
53 | ||
54 | /** | |
55 | * This is an <CODE>Element</CODE> that contains | |
56 | * some meta information about the document. | |
57 | * <P> | |
58 | * An object of type <CODE>Meta</CODE> can not be constructed by the user. | |
59 | * User defined meta information should be placed in a <CODE>Header</CODE>-object. | |
60 | * <CODE>Meta</CODE> is reserved for: Subject, Keywords, Author, Title, Producer | |
61 | * and Creationdate information. | |
62 | * | |
63 | * @see Element | |
64 | * @see Header | |
65 | */ | |
66 | ||
67 | public class Meta implements Element { | |
68 | | |
69 | // membervariables | |
70 | | |
71 | /** This is the type of Meta-information this object contains. */ | |
72 | private int type; | |
73 | | |
74 | /** This is the content of the Meta-information. */ | |
75 | private StringBuffer content; | |
76 | | |
77 | // constructors | |
78 | | |
79 | /** | |
80 | * Constructs a <CODE>Meta</CODE>. | |
81 | * | |
82 | * @param type the type of meta-information | |
83 | * @param content the content | |
84 | */ | |
85 | Meta(int type, String content) { | |
86 | this.type = type; | |
87 | this.content = new StringBuffer(content); | |
88 | } | |
89 | | |
90 | /** | |
91 | * Constructs a <CODE>Meta</CODE>. | |
92 | * | |
93 | * @param tag the tagname of the meta-information | |
94 | * @param content the content | |
95 | */ | |
96 | public Meta(String tag, String content) { | |
97 | this.type = Meta.getType(tag); | |
98 | this.content = new StringBuffer(content); | |
99 | } | |
100 | | |
101 | // implementation of the Element-methods | |
102 | | |
103 | /** | |
104 | * Processes the element by adding it (or the different parts) to a | |
105 | * <CODE>ElementListener</CODE>. | |
106 | * | |
107 | * @param listener the <CODE>ElementListener</CODE> | |
108 | * @return <CODE>true</CODE> if the element was processed successfully | |
109 | */ | |
110 | public boolean process(ElementListener listener) { | |
111 | try { | |
112 |
1
1. process : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return listener.add(this); |
113 | } | |
114 | catch(DocumentException de) { | |
115 |
1
1. process : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
116 | } | |
117 | } | |
118 | | |
119 | /** | |
120 | * Gets the type of the text element. | |
121 | * | |
122 | * @return a type | |
123 | */ | |
124 | public int type() { | |
125 | return type; | |
126 | } | |
127 | | |
128 | /** | |
129 | * Gets all the chunks in this element. | |
130 | * | |
131 | * @return an <CODE>ArrayList</CODE> | |
132 | */ | |
133 | public ArrayList getChunks() { | |
134 |
1
1. getChunks : mutated return of Object value for com/lowagie/text/Meta::getChunks to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new ArrayList(); |
135 | } | |
136 | | |
137 | /** | |
138 | * @see com.lowagie.text.Element#isContent() | |
139 | * @since iText 2.0.8 | |
140 | */ | |
141 | public boolean isContent() { | |
142 | return false; | |
143 | } | |
144 | ||
145 | /** | |
146 | * @see com.lowagie.text.Element#isNestable() | |
147 | * @since iText 2.0.8 | |
148 | */ | |
149 | public boolean isNestable() { | |
150 | return false; | |
151 | } | |
152 | | |
153 | // methods | |
154 | | |
155 | /** | |
156 | * appends some text to this <CODE>Meta</CODE>. | |
157 | * | |
158 | * @param string a <CODE>String</CODE> | |
159 | * @return a <CODE>StringBuffer</CODE> | |
160 | */ | |
161 | public StringBuffer append(String string) { | |
162 | return content.append(string); | |
163 | } | |
164 | | |
165 | // methods to retrieve information | |
166 | ||
167 | /** | |
168 | * Returns the content of the meta information. | |
169 | * | |
170 | * @return a <CODE>String</CODE> | |
171 | */ | |
172 | public String getContent() { | |
173 | return content.toString(); | |
174 | } | |
175 | ||
176 | /** | |
177 | * Returns the name of the meta information. | |
178 | * | |
179 | * @return a <CODE>String</CODE> | |
180 | */ | |
181 | | |
182 | public String getName() { | |
183 | switch (type) { | |
184 | case Element.SUBJECT: | |
185 |
1
1. getName : mutated return of Object value for com/lowagie/text/Meta::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ElementTags.SUBJECT; |
186 | case Element.KEYWORDS: | |
187 |
1
1. getName : mutated return of Object value for com/lowagie/text/Meta::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ElementTags.KEYWORDS; |
188 | case Element.AUTHOR: | |
189 |
1
1. getName : mutated return of Object value for com/lowagie/text/Meta::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ElementTags.AUTHOR; |
190 | case Element.TITLE: | |
191 |
1
1. getName : mutated return of Object value for com/lowagie/text/Meta::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ElementTags.TITLE; |
192 | case Element.PRODUCER: | |
193 |
1
1. getName : mutated return of Object value for com/lowagie/text/Meta::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ElementTags.PRODUCER; |
194 | case Element.CREATIONDATE: | |
195 |
1
1. getName : mutated return of Object value for com/lowagie/text/Meta::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ElementTags.CREATIONDATE; |
196 | default: | |
197 |
1
1. getName : mutated return of Object value for com/lowagie/text/Meta::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ElementTags.UNKNOWN; |
198 | } | |
199 | } | |
200 | | |
201 | /** | |
202 | * Returns the name of the meta information. | |
203 | * | |
204 | * @param tag iText tag for meta information | |
205 | * @return the Element value corresponding with the given tag | |
206 | */ | |
207 | public static int getType(String tag) { | |
208 |
1
1. getType : negated conditional → NO_COVERAGE |
if (ElementTags.SUBJECT.equals(tag)) { |
209 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return Element.SUBJECT; |
210 | } | |
211 |
1
1. getType : negated conditional → NO_COVERAGE |
if (ElementTags.KEYWORDS.equals(tag)) { |
212 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return Element.KEYWORDS; |
213 | } | |
214 |
1
1. getType : negated conditional → NO_COVERAGE |
if (ElementTags.AUTHOR.equals(tag)) { |
215 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return Element.AUTHOR; |
216 | } | |
217 |
1
1. getType : negated conditional → NO_COVERAGE |
if (ElementTags.TITLE.equals(tag)) { |
218 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return Element.TITLE; |
219 | } | |
220 |
1
1. getType : negated conditional → NO_COVERAGE |
if (ElementTags.PRODUCER.equals(tag)) { |
221 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return Element.PRODUCER; |
222 | } | |
223 |
1
1. getType : negated conditional → NO_COVERAGE |
if (ElementTags.CREATIONDATE.equals(tag)) { |
224 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return Element.CREATIONDATE; |
225 | } | |
226 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return Element.HEADER; |
227 | } | |
228 | ||
229 | } | |
Mutations | ||
112 |
1.1 |
|
115 |
1.1 |
|
134 |
1.1 |
|
185 |
1.1 |
|
187 |
1.1 |
|
189 |
1.1 |
|
191 |
1.1 |
|
193 |
1.1 |
|
195 |
1.1 |
|
197 |
1.1 |
|
208 |
1.1 |
|
209 |
1.1 |
|
211 |
1.1 |
|
212 |
1.1 |
|
214 |
1.1 |
|
215 |
1.1 |
|
217 |
1.1 |
|
218 |
1.1 |
|
220 |
1.1 |
|
221 |
1.1 |
|
223 |
1.1 |
|
224 |
1.1 |
|
226 |
1.1 |