/*
 * $Id: VKCUnicode2HtmlEntities.java,v 1.1 2006/05/24 18:00:14 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: VKCUnicode2HtmlEntities.java,v $
 * Revision 1.1  2006/05/24 18:00:14  marbobo
 * + Initiale Version
 *
 */
package vkc.util;

import java.util.HashMap;

/**
 * Die Klasse konvertiert Unicode-Zeichen (&#8364; = \u20AC) in entsprechende
 * äquivalente HTML-Entities (z.B. &amp;euro;)
 * <p>
 * @author marbobo
 */
public final class VKCUnicode2HtmlEntities {
	private static final HashMap unicodeChars = new HashMap();
	
	static {
		unicodeChars.put("\u00C2", "&Acirc;");
		unicodeChars.put("\u00E2", "&acirc;");
		unicodeChars.put("\u00B4", "&acute;");
		unicodeChars.put("\u00C6", "&AElig;");
		unicodeChars.put("\u00E6", "&aelig;");
		unicodeChars.put("\u00C0", "&Agrave;");
		unicodeChars.put("\u00E0", "&agrave;");
		unicodeChars.put("\u2135", "&alefsym;");
		unicodeChars.put("\u0391", "&Alpha;");
		unicodeChars.put("\u03B1", "&alpha;");
		unicodeChars.put("\u0026", "&amp;");
		unicodeChars.put("\u2227", "&and;");
		unicodeChars.put("\u2220", "&ang;");
		unicodeChars.put("\u0027", "&apos;");
		unicodeChars.put("\u00C5", "&Aring;");
		unicodeChars.put("\u00E5", "&aring;");
		unicodeChars.put("\u2248", "&asymp;");
		unicodeChars.put("\u00C3", "&Atilde;");
		unicodeChars.put("\u00E3", "&atilde;");
		unicodeChars.put("\u00C4", "&Auml;");
		unicodeChars.put("\u00E4", "&auml;");
		                                 
		unicodeChars.put("\u201E", "&bdquo;");
		unicodeChars.put("\u0392", "&Beta;");
		unicodeChars.put("\u03B2", "&beta;");
		unicodeChars.put("\u00A6", "&brvbar;");
		unicodeChars.put("\u2022", "&bull;");
		                                 
		unicodeChars.put("\u2229", "&cap;");
		unicodeChars.put("\u00C7", "&Ccedil;");
		unicodeChars.put("\u00E7", "&ccedil;");
		unicodeChars.put("\u00B8", "&cedil;");
		unicodeChars.put("\u00A2", "&cent;");
		unicodeChars.put("\u03A7", "&Chi;");
		unicodeChars.put("\u03C7", "&chi;");
		unicodeChars.put("\u02C6", "&circ;");
		unicodeChars.put("\u2663", "&clubs;");
		unicodeChars.put("\u2245", "&cong;");
		unicodeChars.put("\u00A9", "&copy;");
		unicodeChars.put("\u21B5", "&crarr;");
		unicodeChars.put("\u222A", "&cup;");
		unicodeChars.put("\u00A4", "&curren;");
		                                  
		unicodeChars.put("\u2021", "&Dagger;");
		unicodeChars.put("\u2020", "&dagger;");
		unicodeChars.put("\u21D3", "&dArr;");
		unicodeChars.put("\u2193", "&darr;");
		unicodeChars.put("\u00B0", "&deg;");
		unicodeChars.put("\u0394", "&Delta;");
		unicodeChars.put("\u03B4", "&delta;");
		unicodeChars.put("\u2666", "&diams;");
		unicodeChars.put("\u00F7", "&divide;");
		                                  
		unicodeChars.put("\u00C9", "&Eacute;");
		unicodeChars.put("\u00E9", "&eacute;");
		unicodeChars.put("\u00CA", "&Ecirc;");
		unicodeChars.put("\u00EA", "&ecirc;");
		unicodeChars.put("\u00C8", "&Egrave;");
		unicodeChars.put("\u00E8", "&egrave;");
		unicodeChars.put("\u2205", "&empty;");
		unicodeChars.put("\u2003", "&emsp;");
		unicodeChars.put("\u2002", "&ensp;");
		unicodeChars.put("\u0395", "&Epsilon;");
		unicodeChars.put("\u03B5", "&epsilon;");
		unicodeChars.put("\u2261", "&equiv;");
		unicodeChars.put("\u0397", "&Eta;");
		unicodeChars.put("\u03B7", "&eta;");
		unicodeChars.put("\u00D0", "&ETH;");
		unicodeChars.put("\u00F0", "&eth;");
		unicodeChars.put("\u00CB", "&Euml;");
		unicodeChars.put("\u00EB", "&euml;");
		unicodeChars.put("\u20AC", "&euro;");
		unicodeChars.put("\u2203", "&exist;");
		                                  
		unicodeChars.put("\u0192", "&fnof;");
		unicodeChars.put("\u2200", "&forall;");
		unicodeChars.put("\u00BD", "&frac12;");
		unicodeChars.put("\u00BC", "&frac14;");
		unicodeChars.put("\u00BE", "&frac34;");
		unicodeChars.put("\u2044", "&frasl;");
		                                                               
		unicodeChars.put("\u0393", "&Gamma;");
		unicodeChars.put("\u03B3", "&gamma;");
		unicodeChars.put("\u2265", "&ge;");
		unicodeChars.put("\u003E", "&gt;");
		                                
		unicodeChars.put("\u21D4", "&hArr;");
		unicodeChars.put("\u2194", "&harr;");
		unicodeChars.put("\u2665", "&hearts;");
		unicodeChars.put("\u2026", "&hellip;");
		                         
		unicodeChars.put("\u00CD", "&Iacute;");
		unicodeChars.put("\u00ED", "&iacute;");
		unicodeChars.put("\u00CE", "&Icirc;");
		unicodeChars.put("\u00EE", "&icirc;");
		unicodeChars.put("\u00A1", "&iexcl;");
		unicodeChars.put("\u00CC", "&Igrave;");
		unicodeChars.put("\u00EC", "&igrave;");
		unicodeChars.put("\u2111", "&image;");
		unicodeChars.put("\u221E", "&infin;");
		unicodeChars.put("\u222B", "&int;");
		unicodeChars.put("\u0399", "&Iota;");
		unicodeChars.put("\u03B9", "&iota;");
		unicodeChars.put("\u00BF", "&iquest;");
		unicodeChars.put("\u2208", "&isin;");
		unicodeChars.put("\u00CF", "&Iuml;");
		unicodeChars.put("\u00EF", "&iuml;");
		                                
		unicodeChars.put("\u039A", "&Kappa;");
		unicodeChars.put("\u03BA", "&kappa;");
		                           
		unicodeChars.put("\u039B", "&Lambda;");
		unicodeChars.put("\u03BB", "&lambda;");
		unicodeChars.put("\u2329", "&lang;");
		unicodeChars.put("\u00AB", "&laquo;");
		unicodeChars.put("\u21D0", "&lArr;");
		unicodeChars.put("\u2190", "&larr;");
		unicodeChars.put("\u2308", "&lceil;");
		unicodeChars.put("\u201C", "&ldquo;");
		unicodeChars.put("\u2264", "&le;");
		unicodeChars.put("\u230A", "&lfloor;");
		unicodeChars.put("\u2217", "&lowast;");
		unicodeChars.put("\u25CA", "&loz;");
		unicodeChars.put("\u200E", "&lrm;");
		unicodeChars.put("\u2039", "&lsaquo;");
		unicodeChars.put("\u2018", "&lsquo;");
		unicodeChars.put("\u003C", "&lt;");
		                                 
		unicodeChars.put("\u00AF", "&macr;");
		unicodeChars.put("\u2014", "&mdash;");
		unicodeChars.put("\u00B5", "&micro;");
		unicodeChars.put("\u00B7", "&middot;");
		unicodeChars.put("\u2212", "&minus;");
		unicodeChars.put("\u039C", "&Mu;");
		unicodeChars.put("\u03BC", "&mu;");
		                                 
		unicodeChars.put("\u2207", "&nabla;");
		unicodeChars.put("\u00A0", "&nbsp;");
		unicodeChars.put("\u2013", "&ndash;");
		unicodeChars.put("\u2260", "&ne;");
		unicodeChars.put("\u220B", "&ni;");
		unicodeChars.put("\u00AC", "&not;");
		unicodeChars.put("\u2209", "&notin;");
		unicodeChars.put("\u2284", "&nsub;");
		unicodeChars.put("\u00D1", "&Ntilde;");
		unicodeChars.put("\u00F1", "&ntilde;");
		unicodeChars.put("\u039D", "&Nu;");
		unicodeChars.put("\u03BD", "&nu;");
		                                                               
		unicodeChars.put("\u00D3", "&Oacute;");
		unicodeChars.put("\u00F3", "&oacute;");
		unicodeChars.put("\u00D4", "&Ocirc;");
		unicodeChars.put("\u00F4", "&ocirc;");
		unicodeChars.put("\u0152", "&OElig;");
		unicodeChars.put("\u0153", "&oelig;");
		unicodeChars.put("\u00D2", "&Ograve;");
		unicodeChars.put("\u00F2", "&ograve;");
		unicodeChars.put("\u203E", "&oline;");
		unicodeChars.put("\u03A9", "&Omega;");
		unicodeChars.put("\u03C9", "&omega;");
		unicodeChars.put("\u039F", "&Omicron;");
		unicodeChars.put("\u03BF", "&omicron;");
		unicodeChars.put("\u2295", "&oplus;");
		unicodeChars.put("\u2228", "&or;");
		unicodeChars.put("\u00AA", "&ordf;");
		unicodeChars.put("\u00BA", "&ordm;");
		unicodeChars.put("\u00D8", "&Oslash;");
		unicodeChars.put("\u00F8", "&oslash;");
		unicodeChars.put("\u00D5", "&Otilde;");
		unicodeChars.put("\u00F5", "&otilde;");
		unicodeChars.put("\u2297", "&otimes;");
		unicodeChars.put("\u00D6", "&Ouml;");
		unicodeChars.put("\u00F6", "&ouml;");
		                                 
		unicodeChars.put("\u00B6", "&para;");
		unicodeChars.put("\u2202", "&part;");
		unicodeChars.put("\u2030", "&permil;");
		unicodeChars.put("\u22A5", "&perp;");
		unicodeChars.put("\u03A6", "&Phi;");
		unicodeChars.put("\u03C6", "&phi;");
		unicodeChars.put("\u03A0", "&Pi;");
		unicodeChars.put("\u03C0", "&pi;");
		unicodeChars.put("\u03D6", "&piv;");
		unicodeChars.put("\u00B1", "&plusmn;");
		unicodeChars.put("\u00A3", "&pound;");
		unicodeChars.put("\u2033", "&Prime;");
		unicodeChars.put("\u2032", "&prime;");
		unicodeChars.put("\u220F", "&prod;");
		unicodeChars.put("\u221D", "&prop;");
		unicodeChars.put("\u03A8", "&Psi;");
		unicodeChars.put("\u03C8", "&psi;");
		                                                                  
		unicodeChars.put(new String(new char[]{'\u0022'}), "&quot;");
		                                                                  
		unicodeChars.put("\u221A", "&radic;");
		unicodeChars.put("\u232A", "&rang;");
		unicodeChars.put("\u00BB", "&raquo;");
		unicodeChars.put("\u21D2", "&rArr;");
		unicodeChars.put("\u2192", "&rarr;");
		unicodeChars.put("\u2309", "&rceil;");
		unicodeChars.put("\u201D", "&rdquo;");
		unicodeChars.put("\u211C", "&real;");
		unicodeChars.put("\u00AE", "&reg;");
		unicodeChars.put("\u230B", "&rfloor;");
		unicodeChars.put("\u03A1", "&Rho;");
		unicodeChars.put("\u03C1", "&rho;");
		unicodeChars.put("\u200F", "&rlm;");
		unicodeChars.put("\u203A", "&rsaquo;");
		unicodeChars.put("\u2019", "&rsquo;");
		                                 
		unicodeChars.put("\u201A", "&sbquo;");
		unicodeChars.put("\u0160", "&Scaron;");
		unicodeChars.put("\u0161", "&scaron;");
		unicodeChars.put("\u22C5", "&sdot;");
		unicodeChars.put("\u00A7", "&sect;");
		unicodeChars.put("\u00AD", "&shy;");
		unicodeChars.put("\u03A3", "&Sigma;");
		unicodeChars.put("\u03C3", "&sigma;");
		unicodeChars.put("\u03C2", "&sigmaf;");
		unicodeChars.put("\u223C", "&sim;");
		unicodeChars.put("\u2660", "&spades;");
		unicodeChars.put("\u2282", "&sub;");
		unicodeChars.put("\u2286", "&sube;");
		unicodeChars.put("\u2211", "&sum;");
		unicodeChars.put("\u2283", "&sup;");
		unicodeChars.put("\u00B9", "&sup1;");
		unicodeChars.put("\u00B2", "&sup2;");
		unicodeChars.put("\u00B3", "&sup3;");
		unicodeChars.put("\u2287", "&supe;");
		unicodeChars.put("\u00DF", "&szlig;");
		                                   
		unicodeChars.put("\u03A4", "&Tau;");
		unicodeChars.put("\u03C4", "&tau;");
		unicodeChars.put("\u2234", "&there4;");
		unicodeChars.put("\u0398", "&Theta;");
		unicodeChars.put("\u03B8", "&theta;");
		unicodeChars.put("\u03D1", "&thetasym;");
		unicodeChars.put("\u2009", "&thinsp;");
		unicodeChars.put("\u00DE", "&THORN;");
		unicodeChars.put("\u00FE", "&thorn;");
		unicodeChars.put("\u02DC", "&tilde;");
		unicodeChars.put("\u00D7", "&times;");
		unicodeChars.put("\u2122", "&trade;");
		                                   
		unicodeChars.put("\u00DA", "&Uacute;");
		unicodeChars.put("\u00FA", "&uacute;");
		unicodeChars.put("\u21D1", "&uArr;");
		unicodeChars.put("\u2191", "&uarr;");
		unicodeChars.put("\u00DB", "&Ucirc;");
		unicodeChars.put("\u00FB", "&ucirc;");
		unicodeChars.put("\u00D9", "&Ugrave;");
		unicodeChars.put("\u00F9", "&ugrave;");
		unicodeChars.put("\u00A8", "&uml;");
		unicodeChars.put("\u03D2", "&upsih;");
		unicodeChars.put("\u03A5", "&Upsilon;");
		unicodeChars.put("\u03C5", "&upsilon;");
		unicodeChars.put("\u00DC", "&Uuml;");
		unicodeChars.put("\u00FC", "&uuml;");
		                                   
		unicodeChars.put("\u2118", "&weierp;");
		                                   
		unicodeChars.put("\u039E", "&Xi;");
		unicodeChars.put("\u03BE", "&xi;");
		                                 
		unicodeChars.put("\u00DD", "&Yacute;");
		unicodeChars.put("\u00FD", "&yacute;");
		unicodeChars.put("\u00A5", "&yen;");
		unicodeChars.put("\u0178", "&Yuml;");
		unicodeChars.put("\u00FF", "&yuml;");
		                                 
		unicodeChars.put("\u0396", "&Zeta;");
		unicodeChars.put("\u03B6", "&zeta;");
		unicodeChars.put("\u200D", "&zwj;");
		unicodeChars.put("\u200C", "&zwnj;");
	}
	
	public static final String getHtmlEntity(String character) {
		return (String)unicodeChars.get(character);
	}
	
	public static final String getHtmlEntity(char character) {
		return (String)unicodeChars.get(new String(new char[]{character}));
	}
}