1 | /* | |
2 | * $Id: EntitiesToSymbol.java 3373 2008-05-12 16:21:24Z xlv $ | |
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.xml.simpleparser; | |
51 | ||
52 | import com.lowagie.text.Chunk; | |
53 | import com.lowagie.text.Font; | |
54 | ||
55 | import java.util.HashMap; | |
56 | ||
57 | /** | |
58 | * This class contains entities that can be used in an entity tag. | |
59 | */ | |
60 | ||
61 | public class EntitiesToSymbol { | |
62 | | |
63 | /** | |
64 | * This is a map that contains all possible id values of the entity tag | |
65 | * that can be translated to a character in font Symbol. | |
66 | */ | |
67 | public static final HashMap map; | |
68 | | |
69 | static { | |
70 | map = new HashMap(); | |
71 | map.put("169", (char) 227); | |
72 | map.put("172", (char) 216); | |
73 | map.put("174", (char) 210); | |
74 | map.put("177", (char) 177); | |
75 | map.put("215", (char) 180); | |
76 | map.put("247", (char) 184); | |
77 | map.put("8230", (char) 188); | |
78 | map.put("8242", (char) 162); | |
79 | map.put("8243", (char) 178); | |
80 | map.put("8260", (char) 164); | |
81 | map.put("8364", (char) 240); | |
82 | map.put("8465", (char) 193); | |
83 | map.put("8472", (char) 195); | |
84 | map.put("8476", (char) 194); | |
85 | map.put("8482", (char) 212); | |
86 | map.put("8501", (char) 192); | |
87 | map.put("8592", (char) 172); | |
88 | map.put("8593", (char) 173); | |
89 | map.put("8594", (char) 174); | |
90 | map.put("8595", (char) 175); | |
91 | map.put("8596", (char) 171); | |
92 | map.put("8629", (char) 191); | |
93 | map.put("8656", (char) 220); | |
94 | map.put("8657", (char) 221); | |
95 | map.put("8658", (char) 222); | |
96 | map.put("8659", (char) 223); | |
97 | map.put("8660", (char) 219); | |
98 | map.put("8704", (char) 34); | |
99 | map.put("8706", (char) 182); | |
100 | map.put("8707", (char) 36); | |
101 | map.put("8709", (char) 198); | |
102 | map.put("8711", (char) 209); | |
103 | map.put("8712", (char) 206); | |
104 | map.put("8713", (char) 207); | |
105 | map.put("8717", (char) 39); | |
106 | map.put("8719", (char) 213); | |
107 | map.put("8721", (char) 229); | |
108 | map.put("8722", (char) 45); | |
109 | map.put("8727", (char) 42); | |
110 | map.put("8729", (char) 183); | |
111 | map.put("8730", (char) 214); | |
112 | map.put("8733", (char) 181); | |
113 | map.put("8734", (char) 165); | |
114 | map.put("8736", (char) 208); | |
115 | map.put("8743", (char) 217); | |
116 | map.put("8744", (char) 218); | |
117 | map.put("8745", (char) 199); | |
118 | map.put("8746", (char) 200); | |
119 | map.put("8747", (char) 242); | |
120 | map.put("8756", (char) 92); | |
121 | map.put("8764", (char) 126); | |
122 | map.put("8773", (char) 64); | |
123 | map.put("8776", (char) 187); | |
124 | map.put("8800", (char) 185); | |
125 | map.put("8801", (char) 186); | |
126 | map.put("8804", (char) 163); | |
127 | map.put("8805", (char) 179); | |
128 | map.put("8834", (char) 204); | |
129 | map.put("8835", (char) 201); | |
130 | map.put("8836", (char) 203); | |
131 | map.put("8838", (char) 205); | |
132 | map.put("8839", (char) 202); | |
133 | map.put("8853", (char) 197); | |
134 | map.put("8855", (char) 196); | |
135 | map.put("8869", (char) 94); | |
136 | map.put("8901", (char) 215); | |
137 | map.put("8992", (char) 243); | |
138 | map.put("8993", (char) 245); | |
139 | map.put("9001", (char) 225); | |
140 | map.put("9002", (char) 241); | |
141 | map.put("913", (char) 65); | |
142 | map.put("914", (char) 66); | |
143 | map.put("915", (char) 71); | |
144 | map.put("916", (char) 68); | |
145 | map.put("917", (char) 69); | |
146 | map.put("918", (char) 90); | |
147 | map.put("919", (char) 72); | |
148 | map.put("920", (char) 81); | |
149 | map.put("921", (char) 73); | |
150 | map.put("922", (char) 75); | |
151 | map.put("923", (char) 76); | |
152 | map.put("924", (char) 77); | |
153 | map.put("925", (char) 78); | |
154 | map.put("926", (char) 88); | |
155 | map.put("927", (char) 79); | |
156 | map.put("928", (char) 80); | |
157 | map.put("929", (char) 82); | |
158 | map.put("931", (char) 83); | |
159 | map.put("932", (char) 84); | |
160 | map.put("933", (char) 85); | |
161 | map.put("934", (char) 70); | |
162 | map.put("935", (char) 67); | |
163 | map.put("936", (char) 89); | |
164 | map.put("937", (char) 87); | |
165 | map.put("945", (char) 97); | |
166 | map.put("946", (char) 98); | |
167 | map.put("947", (char) 103); | |
168 | map.put("948", (char) 100); | |
169 | map.put("949", (char) 101); | |
170 | map.put("950", (char) 122); | |
171 | map.put("951", (char) 104); | |
172 | map.put("952", (char) 113); | |
173 | map.put("953", (char) 105); | |
174 | map.put("954", (char) 107); | |
175 | map.put("955", (char) 108); | |
176 | map.put("956", (char) 109); | |
177 | map.put("957", (char) 110); | |
178 | map.put("958", (char) 120); | |
179 | map.put("959", (char) 111); | |
180 | map.put("960", (char) 112); | |
181 | map.put("961", (char) 114); | |
182 | map.put("962", (char) 86); | |
183 | map.put("963", (char) 115); | |
184 | map.put("964", (char) 116); | |
185 | map.put("965", (char) 117); | |
186 | map.put("966", (char) 102); | |
187 | map.put("967", (char) 99); | |
188 | map.put("9674", (char) 224); | |
189 | map.put("968", (char) 121); | |
190 | map.put("969", (char) 119); | |
191 | map.put("977", (char) 74); | |
192 | map.put("978", (char) 161); | |
193 | map.put("981", (char) 106); | |
194 | map.put("982", (char) 118); | |
195 | map.put("9824", (char) 170); | |
196 | map.put("9827", (char) 167); | |
197 | map.put("9829", (char) 169); | |
198 | map.put("9830", (char) 168); | |
199 | map.put("Alpha", (char) 65); | |
200 | map.put("Beta", (char) 66); | |
201 | map.put("Chi", (char) 67); | |
202 | map.put("Delta", (char) 68); | |
203 | map.put("Epsilon", (char) 69); | |
204 | map.put("Eta", (char) 72); | |
205 | map.put("Gamma", (char) 71); | |
206 | map.put("Iota", (char) 73); | |
207 | map.put("Kappa", (char) 75); | |
208 | map.put("Lambda", (char) 76); | |
209 | map.put("Mu", (char) 77); | |
210 | map.put("Nu", (char) 78); | |
211 | map.put("Omega", (char) 87); | |
212 | map.put("Omicron", (char) 79); | |
213 | map.put("Phi", (char) 70); | |
214 | map.put("Pi", (char) 80); | |
215 | map.put("Prime", (char) 178); | |
216 | map.put("Psi", (char) 89); | |
217 | map.put("Rho", (char) 82); | |
218 | map.put("Sigma", (char) 83); | |
219 | map.put("Tau", (char) 84); | |
220 | map.put("Theta", (char) 81); | |
221 | map.put("Upsilon", (char) 85); | |
222 | map.put("Xi", (char) 88); | |
223 | map.put("Zeta", (char) 90); | |
224 | map.put("alefsym", (char) 192); | |
225 | map.put("alpha", (char) 97); | |
226 | map.put("and", (char) 217); | |
227 | map.put("ang", (char) 208); | |
228 | map.put("asymp", (char) 187); | |
229 | map.put("beta", (char) 98); | |
230 | map.put("cap", (char) 199); | |
231 | map.put("chi", (char) 99); | |
232 | map.put("clubs", (char) 167); | |
233 | map.put("cong", (char) 64); | |
234 | map.put("copy", (char) 211); | |
235 | map.put("crarr", (char) 191); | |
236 | map.put("cup", (char) 200); | |
237 | map.put("dArr", (char) 223); | |
238 | map.put("darr", (char) 175); | |
239 | map.put("delta", (char) 100); | |
240 | map.put("diams", (char) 168); | |
241 | map.put("divide", (char) 184); | |
242 | map.put("empty", (char) 198); | |
243 | map.put("epsilon", (char) 101); | |
244 | map.put("equiv", (char) 186); | |
245 | map.put("eta", (char) 104); | |
246 | map.put("euro", (char) 240); | |
247 | map.put("exist", (char) 36); | |
248 | map.put("forall", (char) 34); | |
249 | map.put("frasl", (char) 164); | |
250 | map.put("gamma", (char) 103); | |
251 | map.put("ge", (char) 179); | |
252 | map.put("hArr", (char) 219); | |
253 | map.put("harr", (char) 171); | |
254 | map.put("hearts", (char) 169); | |
255 | map.put("hellip", (char) 188); | |
256 | map.put("horizontal arrow extender", (char) 190); | |
257 | map.put("image", (char) 193); | |
258 | map.put("infin", (char) 165); | |
259 | map.put("int", (char) 242); | |
260 | map.put("iota", (char) 105); | |
261 | map.put("isin", (char) 206); | |
262 | map.put("kappa", (char) 107); | |
263 | map.put("lArr", (char) 220); | |
264 | map.put("lambda", (char) 108); | |
265 | map.put("lang", (char) 225); | |
266 | map.put("large brace extender", (char) 239); | |
267 | map.put("large integral extender", (char) 244); | |
268 | map.put("large left brace (bottom)", (char) 238); | |
269 | map.put("large left brace (middle)", (char) 237); | |
270 | map.put("large left brace (top)", (char) 236); | |
271 | map.put("large left bracket (bottom)", (char) 235); | |
272 | map.put("large left bracket (extender)", (char) 234); | |
273 | map.put("large left bracket (top)", (char) 233); | |
274 | map.put("large left parenthesis (bottom)", (char) 232); | |
275 | map.put("large left parenthesis (extender)", (char) 231); | |
276 | map.put("large left parenthesis (top)", (char) 230); | |
277 | map.put("large right brace (bottom)", (char) 254); | |
278 | map.put("large right brace (middle)", (char) 253); | |
279 | map.put("large right brace (top)", (char) 252); | |
280 | map.put("large right bracket (bottom)", (char) 251); | |
281 | map.put("large right bracket (extender)", (char) 250); | |
282 | map.put("large right bracket (top)", (char) 249); | |
283 | map.put("large right parenthesis (bottom)", (char) 248); | |
284 | map.put("large right parenthesis (extender)", (char) 247); | |
285 | map.put("large right parenthesis (top)", (char) 246); | |
286 | map.put("larr", (char) 172); | |
287 | map.put("le", (char) 163); | |
288 | map.put("lowast", (char) 42); | |
289 | map.put("loz", (char) 224); | |
290 | map.put("minus", (char) 45); | |
291 | map.put("mu", (char) 109); | |
292 | map.put("nabla", (char) 209); | |
293 | map.put("ne", (char) 185); | |
294 | map.put("not", (char) 216); | |
295 | map.put("notin", (char) 207); | |
296 | map.put("nsub", (char) 203); | |
297 | map.put("nu", (char) 110); | |
298 | map.put("omega", (char) 119); | |
299 | map.put("omicron", (char) 111); | |
300 | map.put("oplus", (char) 197); | |
301 | map.put("or", (char) 218); | |
302 | map.put("otimes", (char) 196); | |
303 | map.put("part", (char) 182); | |
304 | map.put("perp", (char) 94); | |
305 | map.put("phi", (char) 102); | |
306 | map.put("pi", (char) 112); | |
307 | map.put("piv", (char) 118); | |
308 | map.put("plusmn", (char) 177); | |
309 | map.put("prime", (char) 162); | |
310 | map.put("prod", (char) 213); | |
311 | map.put("prop", (char) 181); | |
312 | map.put("psi", (char) 121); | |
313 | map.put("rArr", (char) 222); | |
314 | map.put("radic", (char) 214); | |
315 | map.put("radical extender", (char) 96); | |
316 | map.put("rang", (char) 241); | |
317 | map.put("rarr", (char) 174); | |
318 | map.put("real", (char) 194); | |
319 | map.put("reg", (char) 210); | |
320 | map.put("rho", (char) 114); | |
321 | map.put("sdot", (char) 215); | |
322 | map.put("sigma", (char) 115); | |
323 | map.put("sigmaf", (char) 86); | |
324 | map.put("sim", (char) 126); | |
325 | map.put("spades", (char) 170); | |
326 | map.put("sub", (char) 204); | |
327 | map.put("sube", (char) 205); | |
328 | map.put("sum", (char) 229); | |
329 | map.put("sup", (char) 201); | |
330 | map.put("supe", (char) 202); | |
331 | map.put("tau", (char) 116); | |
332 | map.put("there4", (char) 92); | |
333 | map.put("theta", (char) 113); | |
334 | map.put("thetasym", (char) 74); | |
335 | map.put("times", (char) 180); | |
336 | map.put("trade", (char) 212); | |
337 | map.put("uArr", (char) 221); | |
338 | map.put("uarr", (char) 173); | |
339 | map.put("upsih", (char) 161); | |
340 | map.put("upsilon", (char) 117); | |
341 | map.put("vertical arrow extender", (char) 189); | |
342 | map.put("weierp", (char) 195); | |
343 | map.put("xi", (char) 120); | |
344 | map.put("zeta", (char) 122); | |
345 | } | |
346 | | |
347 | /** | |
348 | * Gets a chunk with a symbol character. | |
349 | * @param e a symbol value (see Entities class: alfa is greek alfa,...) | |
350 | * @param font the font if the symbol isn't found (otherwise Font.SYMBOL) | |
351 | * @return a Chunk | |
352 | */ | |
353 | public static Chunk get(String e, Font font) { | |
354 | char s = getCorrespondingSymbol(e); | |
355 |
1
1. get : negated conditional → NO_COVERAGE |
if (s == (char)0) { |
356 | try { | |
357 |
1
1. get : mutated return of Object value for com/lowagie/text/xml/simpleparser/EntitiesToSymbol::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Chunk(String.valueOf((char)Integer.parseInt(e)), font); |
358 | } | |
359 | catch(Exception exception) { | |
360 |
1
1. get : mutated return of Object value for com/lowagie/text/xml/simpleparser/EntitiesToSymbol::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Chunk(e, font); |
361 | } | |
362 | } | |
363 | Font symbol = new Font(Font.SYMBOL, font.getSize(), font.getStyle(), font.getColor()); | |
364 |
1
1. get : mutated return of Object value for com/lowagie/text/xml/simpleparser/EntitiesToSymbol::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Chunk(String.valueOf(s), symbol); |
365 | } | |
366 | | |
367 | /** | |
368 | * Looks for the corresponding symbol in the font Symbol. | |
369 | * | |
370 | * @param name the name of the entity | |
371 | * @return the corresponding character in font Symbol | |
372 | */ | |
373 | public static char getCorrespondingSymbol(String name) { | |
374 | Character symbol = (Character) map.get(name); | |
375 |
1
1. getCorrespondingSymbol : negated conditional → NO_COVERAGE |
if (symbol == null) { |
376 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return (char)0; |
377 | } | |
378 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return symbol; |
379 | } | |
380 | } | |
Mutations | ||
355 |
1.1 |
|
357 |
1.1 |
|
360 |
1.1 |
|
364 |
1.1 |
|
375 |
1.1 |
|
376 |
1.1 |
|
378 |
1.1 |