Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../../img/srcFileCovDistChart0.png 86% of files have more coverage
283   327   14   70.75
16   304   0.05   4
4     3.5  
1    
 
  Entities       Line # 21 283 14 0% 0.0
 
No Tests
 
1    package org.apache.lucene.demo.html;
2   
3    /**
4    * Copyright 2004 The Apache Software Foundation
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
12    * Unless required by applicable law or agreed to in writing, software
13    * distributed under the License is distributed on an "AS IS" BASIS,
14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    * See the License for the specific language governing permissions and
16    * limitations under the License.
17    */
18   
19    import java.util.*;
20   
 
21    public class Entities {
22    static final Hashtable decoder = new Hashtable(300);
23    static final String[] encoder = new String[0x100];
24   
 
25  0 toggle static final String decode(String entity) {
26  0 if (entity.charAt(entity.length()-1) == ';') // remove trailing semicolon
27  0 entity = entity.substring(0, entity.length()-1);
28  0 if (entity.charAt(1) == '#') {
29  0 int start = 2;
30  0 int radix = 10;
31  0 if (entity.charAt(2) == 'X' || entity.charAt(2) == 'x') {
32  0 start++;
33  0 radix = 16;
34    }
35  0 Character c =
36    new Character((char)Integer.parseInt(entity.substring(start), radix));
37  0 return c.toString();
38    } else {
39  0 String s = (String)decoder.get(entity);
40  0 if (s != null)
41  0 return s;
42  0 else return "";
43    }
44    }
45   
 
46  0 toggle public static final String encode(String s) {
47  0 int length = s.length();
48  0 StringBuffer buffer = new StringBuffer(length * 2);
49  0 for (int i = 0; i < length; i++) {
50  0 char c = s.charAt(i);
51  0 int j = (int)c;
52  0 if (j < 0x100 && encoder[j] != null) {
53  0 buffer.append(encoder[j]); // have a named encoding
54  0 buffer.append(';');
55  0 } else if (j < 0x80) {
56  0 buffer.append(c); // use ASCII value
57    } else {
58  0 buffer.append("&#"); // use numeric encoding
59  0 buffer.append((int)c);
60  0 buffer.append(';');
61    }
62    }
63  0 return buffer.toString();
64    }
65   
 
66  0 toggle static final void add(String entity, int value) {
67  0 decoder.put(entity, (new Character((char)value)).toString());
68  0 if (value < 0x100)
69  0 encoder[value] = entity;
70    }
71   
 
72  0 toggle static {
73  0 add("&nbsp", 160);
74  0 add("&iexcl", 161);
75  0 add("&cent", 162);
76  0 add("&pound", 163);
77  0 add("&curren", 164);
78  0 add("&yen", 165);
79  0 add("&brvbar", 166);
80  0 add("&sect", 167);
81  0 add("&uml", 168);
82  0 add("&copy", 169);
83  0 add("&ordf", 170);
84  0 add("&laquo", 171);
85  0 add("&not", 172);
86  0 add("&shy", 173);
87  0 add("&reg", 174);
88  0 add("&macr", 175);
89  0 add("&deg", 176);
90  0 add("&plusmn", 177);
91  0 add("&sup2", 178);
92  0 add("&sup3", 179);
93  0 add("&acute", 180);
94  0 add("&micro", 181);
95  0 add("&para", 182);
96  0 add("&middot", 183);
97  0 add("&cedil", 184);
98  0 add("&sup1", 185);
99  0 add("&ordm", 186);
100  0 add("&raquo", 187);
101  0 add("&frac14", 188);
102  0 add("&frac12", 189);
103  0 add("&frac34", 190);
104  0 add("&iquest", 191);
105  0 add("&Agrave", 192);
106  0 add("&Aacute", 193);
107  0 add("&Acirc", 194);
108  0 add("&Atilde", 195);
109  0 add("&Auml", 196);
110  0 add("&Aring", 197);
111  0 add("&AElig", 198);
112  0 add("&Ccedil", 199);
113  0 add("&Egrave", 200);
114  0 add("&Eacute", 201);
115  0 add("&Ecirc", 202);
116  0 add("&Euml", 203);
117  0 add("&Igrave", 204);
118  0 add("&Iacute", 205);
119  0 add("&Icirc", 206);
120  0 add("&Iuml", 207);
121  0 add("&ETH", 208);
122  0 add("&Ntilde", 209);
123  0 add("&Ograve", 210);
124  0 add("&Oacute", 211);
125  0 add("&Ocirc", 212);
126  0 add("&Otilde", 213);
127  0 add("&Ouml", 214);
128  0 add("&times", 215);
129  0 add("&Oslash", 216);
130  0 add("&Ugrave", 217);
131  0 add("&Uacute", 218);
132  0 add("&Ucirc", 219);
133  0 add("&Uuml", 220);
134  0 add("&Yacute", 221);
135  0 add("&THORN", 222);
136  0 add("&szlig", 223);
137  0 add("&agrave", 224);
138  0 add("&aacute", 225);
139  0 add("&acirc", 226);
140  0 add("&atilde", 227);
141  0 add("&auml", 228);
142  0 add("&aring", 229);
143  0 add("&aelig", 230);
144  0 add("&ccedil", 231);
145  0 add("&egrave", 232);
146  0 add("&eacute", 233);
147  0 add("&ecirc", 234);
148  0 add("&euml", 235);
149  0 add("&igrave", 236);
150  0 add("&iacute", 237);
151  0 add("&icirc", 238);
152  0 add("&iuml", 239);
153  0 add("&eth", 240);
154  0 add("&ntilde", 241);
155  0 add("&ograve", 242);
156  0 add("&oacute", 243);
157  0 add("&ocirc", 244);
158  0 add("&otilde", 245);
159  0 add("&ouml", 246);
160  0 add("&divide", 247);
161  0 add("&oslash", 248);
162  0 add("&ugrave", 249);
163  0 add("&uacute", 250);
164  0 add("&ucirc", 251);
165  0 add("&uuml", 252);
166  0 add("&yacute", 253);
167  0 add("&thorn", 254);
168  0 add("&yuml", 255);
169  0 add("&fnof", 402);
170  0 add("&Alpha", 913);
171  0 add("&Beta", 914);
172  0 add("&Gamma", 915);
173  0 add("&Delta", 916);
174  0 add("&Epsilon",917);
175  0 add("&Zeta", 918);
176  0 add("&Eta", 919);
177  0 add("&Theta", 920);
178  0 add("&Iota", 921);
179  0 add("&Kappa", 922);
180  0 add("&Lambda", 923);
181  0 add("&Mu", 924);
182  0 add("&Nu", 925);
183  0 add("&Xi", 926);
184  0 add("&Omicron",927);
185  0 add("&Pi", 928);
186  0 add("&Rho", 929);
187  0 add("&Sigma", 931);
188  0 add("&Tau", 932);
189  0 add("&Upsilon",933);
190  0 add("&Phi", 934);
191  0 add("&Chi", 935);
192  0 add("&Psi", 936);
193  0 add("&Omega", 937);
194  0 add("&alpha", 945);
195  0 add("&beta", 946);
196  0 add("&gamma", 947);
197  0 add("&delta", 948);
198  0 add("&epsilon",949);
199  0 add("&zeta", 950);
200  0 </