001package com.hfg.xml.parser; 002 003import java.util.HashMap; 004 005 006//------------------------------------------------------------------------------ 007/** 008 Lookup class for the character entities defined in XHTML1-special.ent 009 010 @author J. Alex Taylor, hairyfatguy.com 011 */ 012//------------------------------------------------------------------------------ 013// com.hfg XML/HTML Coding Library 014// 015// This library is free software; you can redistribute it and/or 016// modify it under the terms of the GNU Lesser General Public 017// License as published by the Free Software Foundation; either 018// version 2.1 of the License, or (at your option) any later version. 019// 020// This library is distributed in the hope that it will be useful, 021// but WITHOUT ANY WARRANTY; without even the implied warranty of 022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 023// Lesser General Public License for more details. 024// 025// You should have received a copy of the GNU Lesser General Public 026// License along with this library; if not, write to the Free Software 027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 028// 029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 030// jataylor@hairyfatguy.com 031//------------------------------------------------------------------------------ 032 033 034public class SpecialCharacterEntities 035{ 036 private static HashMap<String, String> sEntityMap = new HashMap<>(35); 037 038 static 039 { 040 // CO Controls and Basic Latin 041 sEntityMap.put("quot", "#34"); 042 sEntityMap.put("amp", "#38"); 043 sEntityMap.put("apos", "#39"); 044 sEntityMap.put("lt", "#60"); 045 sEntityMap.put("gt", "#62"); 046 047 // Latin Extended-A 048 sEntityMap.put("OElig", "#338"); 049 sEntityMap.put("oelig", "#339"); 050 sEntityMap.put("Scaron", "#352"); 051 sEntityMap.put("scaron", "#353"); 052 sEntityMap.put("Yuml", "#376"); 053 054 // Spacing Modifier Letters 055 sEntityMap.put("circ", "#710"); 056 sEntityMap.put("tilde", "#732"); 057 058 // General Punctuation 059 sEntityMap.put("ensp", "#8194"); 060 sEntityMap.put("emsp", "#8195"); 061 sEntityMap.put("thinsp", "#8201"); 062 sEntityMap.put("zwnj", "#8204"); 063 sEntityMap.put("zwj", "#8205"); 064 sEntityMap.put("lrm", "#8206"); 065 sEntityMap.put("rlm", "#8207"); 066 sEntityMap.put("ndash", "#8211"); 067 sEntityMap.put("mdash", "#8212"); 068 sEntityMap.put("lsquo", "#8216"); 069 sEntityMap.put("rsquo", "#8217"); 070 sEntityMap.put("sbquo", "#8218"); 071 sEntityMap.put("ldquo", "#8220"); 072 sEntityMap.put("rdquo", "#8221"); 073 sEntityMap.put("bdquo", "#8222"); 074 sEntityMap.put("dagger", "#8224"); 075 sEntityMap.put("Dagger", "#8225"); 076 sEntityMap.put("permil", "#8240"); 077 sEntityMap.put("lsaquo", "#8249"); 078 sEntityMap.put("rsaquo", "#8250"); 079 sEntityMap.put("euro", "#8364"); 080 081 } 082 083 //--------------------------------------------------------------------------- 084 /** 085 @param inEntity String such as 'quot' from the character entity '&quot;' 086 @return String with the Unicode character representation (ex: '#34' given 'quot' as input). 087 */ 088 public static String resolveEntity(String inEntity) 089 { 090 return (String) sEntityMap.get(inEntity); 091 } 092 093}