KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > Entities


1 /*
2  * $Id: Entities.java,v 1.43 2004/12/14 11:52:46 blowagie Exp $
3  * $Name: $
4  *
5  * Copyright 1999, 2000, 2001, 2002 Bruno Lowagie.
6  *
7  * The contents of this file are subject to the Mozilla Public License Version 1.1
8  * (the "License"); you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the License.
14  *
15  * The Original Code is 'iText, a free JAVA-PDF library'.
16  *
17  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
18  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
19  * All Rights Reserved.
20  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
21  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
22  *
23  * Contributor(s): all the names of the contributors are added in the source code
24  * where applicable.
25  *
26  * Alternatively, the contents of this file may be used under the terms of the
27  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
28  * provisions of LGPL are applicable instead of those above. If you wish to
29  * allow use of your version of this file only under the terms of the LGPL
30  * License and not to allow others to use your version of this file under
31  * the MPL, indicate your decision by deleting the provisions above and
32  * replace them with the notice and other provisions required by the LGPL.
33  * If you do not delete the provisions above, a recipient may use your version
34  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Library General Public License as published by the Free Software Foundation;
39  * either version 2 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
43  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
44  * details.
45  *
46  * If you didn't download this code from the following link, you should check if
47  * you aren't using an obsolete version:
48  * http://www.lowagie.com/iText/
49  */

50
51 package com.lowagie.text;
52
53 import java.util.HashMap;
54
55 /**
56  * This class contains entities that can be used in an entity tag.
57  */

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

348     
349     public static Chunk get(String e, Font font) {
350         int s = getCorrespondingSymbol(e);
351         if (s == -1) {
352             try {
353                 return new Chunk(String.valueOf((char)Integer.parseInt(e)), font);
354             }
355             catch(Exception exception) {
356                 return new Chunk(e, font);
357             }
358         }
359         Font symbol = new Font(Font.SYMBOL, font.size(), font.style(), font.color());
360         return new Chunk(String.valueOf((char)s), symbol);
361     }
362     
363 /**
364  * Looks for the corresponding symbol in the font Symbol.
365  *
366  * @param c the original ASCII-char
367  * @return the corresponding symbol in font Symbol
368  */

369     
370     public static int getCorrespondingSymbol(String c) {
371         Integer integer = (Integer) map.get(c);
372         if (integer == null) {
373             return -1;
374         }
375         return integer.intValue();
376     }
377     
378 /**
379  * Checks if a given tag corresponds with this object.
380  *
381  * @param tag the given tag
382  * @return true if the tag corresponds
383  */

384     
385     public static boolean isTag(String tag) {
386         return ElementTags.ENTITY.equals(tag);
387     }
388 }
389
Popular Tags