All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.xml.parser.SpecialCharacterEntities Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.xml.parser;

import java.util.HashMap;


//------------------------------------------------------------------------------
/**
 Lookup class for the character entities defined in XHTML1-special.ent

 @author J. Alex Taylor, hairyfatguy.com
 */
//------------------------------------------------------------------------------


public class SpecialCharacterEntities
{
   private static HashMap sEntityMap = new HashMap();

   static
   {
      // CO Controls and Basic Latin
      sEntityMap.put("quot", "#34");
      sEntityMap.put("amp", "#38");
      sEntityMap.put("lt", "#60");
      sEntityMap.put("gt", "#62");

      // Latin Extended-A
      sEntityMap.put("OElig", "#338");
      sEntityMap.put("oelig", "#339");
      sEntityMap.put("Scaron", "#352");
      sEntityMap.put("scaron", "#353");
      sEntityMap.put("Yuml", "#376");

      // Spacing Modifier Letters
      sEntityMap.put("circ", "#710");
      sEntityMap.put("tilde", "#732");

      // General Punctuation
      sEntityMap.put("ensp", "#8194");
      sEntityMap.put("emsp", "#8195");
      sEntityMap.put("thinsp", "#8201");
      sEntityMap.put("zwnj", "#8204");
      sEntityMap.put("zwj", "#8205");
      sEntityMap.put("lrm", "#8206");
      sEntityMap.put("rlm", "#8207");
      sEntityMap.put("ndash", "#8211");
      sEntityMap.put("mdash", "#8212");
      sEntityMap.put("lsquo", "#8216");
      sEntityMap.put("rsquo", "#8217");
      sEntityMap.put("sbquo", "#8218");
      sEntityMap.put("ldquo", "#8220");
      sEntityMap.put("rdquo", "#8221");
      sEntityMap.put("bdquo", "#8222");
      sEntityMap.put("dagger", "#8224");
      sEntityMap.put("Dagger", "#8225");
      sEntityMap.put("permil", "#8240");
      sEntityMap.put("lsaquo", "#8249");
      sEntityMap.put("rsaquo", "#8250");
      sEntityMap.put("euro", "#8364");

   }

   //---------------------------------------------------------------------------
   /**
    @param inEntity String such as 'quot' from the character entity '"'
    @return String with the Unicode character representation (ex: '#34' given 'quot' as input).
    */
   public static String resolveEntity(String inEntity)
   {
      return (String) sEntityMap.get(inEntity);
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy