1 | /* | |
2 | * $Id: SpecialSymbol.java 3963 2009-06-11 11:45:49Z psoares33 $ | |
3 | * | |
4 | * Copyright 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 | /** | |
53 | * This class contains the symbols that correspond with special symbols. | |
54 | * <P> | |
55 | * When you construct a <CODE>Phrase</CODE> with Phrase.getInstance using a <CODE>String</CODE>, | |
56 | * this <CODE>String</CODE> can contain special Symbols. These are characters with an int value | |
57 | * between 913 and 937 (except 930) and between 945 and 969. With this class the value of the | |
58 | * corresponding character of the Font Symbol, can be retrieved. | |
59 | * | |
60 | * @see Phrase | |
61 | * | |
62 | * @author Bruno Lowagie | |
63 | * @author Evelyne De Cordier | |
64 | */ | |
65 | ||
66 | public class SpecialSymbol { | |
67 | | |
68 | /** | |
69 | * Returns the first occurrence of a special symbol in a <CODE>String</CODE>. | |
70 | * | |
71 | * @param string a <CODE>String</CODE> | |
72 | * @return an index of -1 if no special symbol was found | |
73 | */ | |
74 | public static int index(String string) { | |
75 | int length = string.length(); | |
76 |
3
1. index : changed conditional boundary → NO_COVERAGE 2. index : Changed increment from 1 to -1 → NO_COVERAGE 3. index : negated conditional → NO_COVERAGE |
for (int i = 0; i < length; i++) { |
77 |
1
1. index : negated conditional → NO_COVERAGE |
if (getCorrespondingSymbol(string.charAt(i)) != ' ') { |
78 |
1
1. index : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return i; |
79 | } | |
80 | } | |
81 |
1
1. index : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return -1; |
82 | } | |
83 | | |
84 | /** | |
85 | * Gets a chunk with a symbol character. | |
86 | * @param c a character that has to be changed into a symbol | |
87 | * @param font Font if there is no SYMBOL character corresponding with c | |
88 | * @return a SYMBOL version of a character | |
89 | */ | |
90 | public static Chunk get(char c, Font font) { | |
91 | char greek = SpecialSymbol.getCorrespondingSymbol(c); | |
92 |
1
1. get : negated conditional → NO_COVERAGE |
if (greek == ' ') { |
93 |
1
1. get : mutated return of Object value for com/lowagie/text/SpecialSymbol::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Chunk(String.valueOf(c), font); |
94 | } | |
95 | Font symbol = new Font(Font.SYMBOL, font.getSize(), font.getStyle(), font.getColor()); | |
96 | String s = String.valueOf(greek); | |
97 |
1
1. get : mutated return of Object value for com/lowagie/text/SpecialSymbol::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Chunk(s, symbol); |
98 | } | |
99 | | |
100 | /** | |
101 | * Looks for the corresponding symbol in the font Symbol. | |
102 | * | |
103 | * @param c the original ASCII-char | |
104 | * @return the corresponding symbol in font Symbol | |
105 | */ | |
106 | public static char getCorrespondingSymbol(char c) { | |
107 | switch(c) { | |
108 | case 913: | |
109 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'A'; // ALFA |
110 | case 914: | |
111 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'B'; // BETA |
112 | case 915: | |
113 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'G'; // GAMMA |
114 | case 916: | |
115 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'D'; // DELTA |
116 | case 917: | |
117 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'E'; // EPSILON |
118 | case 918: | |
119 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'Z'; // ZETA |
120 | case 919: | |
121 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'H'; // ETA |
122 | case 920: | |
123 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'Q'; // THETA |
124 | case 921: | |
125 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'I'; // IOTA |
126 | case 922: | |
127 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'K'; // KAPPA |
128 | case 923: | |
129 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'L'; // LAMBDA |
130 | case 924: | |
131 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'M'; // MU |
132 | case 925: | |
133 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'N'; // NU |
134 | case 926: | |
135 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'X'; // XI |
136 | case 927: | |
137 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'O'; // OMICRON |
138 | case 928: | |
139 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'P'; // PI |
140 | case 929: | |
141 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'R'; // RHO |
142 | case 931: | |
143 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'S'; // SIGMA |
144 | case 932: | |
145 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'T'; // TAU |
146 | case 933: | |
147 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'U'; // UPSILON |
148 | case 934: | |
149 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'F'; // PHI |
150 | case 935: | |
151 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'C'; // CHI |
152 | case 936: | |
153 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'Y'; // PSI |
154 | case 937: | |
155 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'W'; // OMEGA |
156 | case 945: | |
157 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'a'; // alfa |
158 | case 946: | |
159 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'b'; // beta |
160 | case 947: | |
161 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'g'; // gamma |
162 | case 948: | |
163 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'd'; // delta |
164 | case 949: | |
165 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'e'; // epsilon |
166 | case 950: | |
167 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'z'; // zeta |
168 | case 951: | |
169 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'h'; // eta |
170 | case 952: | |
171 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'q'; // theta |
172 | case 953: | |
173 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'i'; // iota |
174 | case 954: | |
175 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'k'; // kappa |
176 | case 955: | |
177 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'l'; // lambda |
178 | case 956: | |
179 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'm'; // mu |
180 | case 957: | |
181 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'n'; // nu |
182 | case 958: | |
183 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'x'; // xi |
184 | case 959: | |
185 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'o'; // omicron |
186 | case 960: | |
187 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'p'; // pi |
188 | case 961: | |
189 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'r'; // rho |
190 | case 962: | |
191 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'V'; // sigma |
192 | case 963: | |
193 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 's'; // sigma |
194 | case 964: | |
195 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 't'; // tau |
196 | case 965: | |
197 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'u'; // upsilon |
198 | case 966: | |
199 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'f'; // phi |
200 | case 967: | |
201 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'c'; // chi |
202 | case 968: | |
203 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'y'; // psi |
204 | case 969: | |
205 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 'w'; // omega |
206 | default: | |
207 |
1
1. getCorrespondingSymbol : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return ' '; |
208 | } | |
209 | } | |
210 | } | |
Mutations | ||
76 |
1.1 2.2 3.3 |
|
77 |
1.1 |
|
78 |
1.1 |
|
81 |
1.1 |
|
92 |
1.1 |
|
93 |
1.1 |
|
97 |
1.1 |
|
109 |
1.1 |
|
111 |
1.1 |
|
113 |
1.1 |
|
115 |
1.1 |
|
117 |
1.1 |
|
119 |
1.1 |
|
121 |
1.1 |
|
123 |
1.1 |
|
125 |
1.1 |
|
127 |
1.1 |
|
129 |
1.1 |
|
131 |
1.1 |
|
133 |
1.1 |
|
135 |
1.1 |
|
137 |
1.1 |
|
139 |
1.1 |
|
141 |
1.1 |
|
143 |
1.1 |
|
145 |
1.1 |
|
147 |
1.1 |
|
149 |
1.1 |
|
151 |
1.1 |
|
153 |
1.1 |
|
155 |
1.1 |
|
157 |
1.1 |
|
159 |
1.1 |
|
161 |
1.1 |
|
163 |
1.1 |
|
165 |
1.1 |
|
167 |
1.1 |
|
169 |
1.1 |
|
171 |
1.1 |
|
173 |
1.1 |
|
175 |
1.1 |
|
177 |
1.1 |
|
179 |
1.1 |
|
181 |
1.1 |
|
183 |
1.1 |
|
185 |
1.1 |
|
187 |
1.1 |
|
189 |
1.1 |
|
191 |
1.1 |
|
193 |
1.1 |
|
195 |
1.1 |
|
197 |
1.1 |
|
199 |
1.1 |
|
201 |
1.1 |
|
203 |
1.1 |
|
205 |
1.1 |
|
207 |
1.1 |