com.mindprod.entities
Class InsertEntities

java.lang.Object
  extended by com.mindprod.entities.InsertEntities
Direct Known Subclasses:
InsertFileEntities

public class InsertEntities
extends java.lang.Object

Inserts HTML entities such as " into a String replacing the single character equivalents.

Entities are coded inline in a giant case.

Since:
2005
Version:
3.0 2011-01-05 remove deprecated methods. add toHTMLEntity, toXMLEntity
Author:
Roedy Green, Canadian Mind Products
See Also:
InsertEntities, InsertFileEntities, StripEntities, StripFileEntities

Constructor Summary
InsertEntities()
           
 
Method Summary
static java.lang.String insertHTMLEntities(java.lang.String text)
          Converts text to HTML by quoting dangerous characters.
static java.lang.String insertXMLEntities(java.lang.String text)
          Converts text to XML by quoting dangerous characters.
static java.lang.String toHTMLEntity(char c)
          Converts text to HTML by quoting dangerous characters.; Does not convert space to  
static java.lang.String toXMLEntity(char c)
          Converts text to XML by quoting dangerous characters.; Does not convert space to  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InsertEntities

public InsertEntities()
Method Detail

insertHTMLEntities

public static java.lang.String insertHTMLEntities(java.lang.String text)
Converts text to HTML by quoting dangerous characters. Text must not already contain entities. e.g. " ==> " < ==> < ordinary text passes unchanged. Does not convert space to  

Parameters:
text - raw text to be processed. Must not be null.
Returns:
translated HTML text, or null if input is null.

insertXMLEntities

public static java.lang.String insertXMLEntities(java.lang.String text)
Converts text to XML by quoting dangerous characters. Text must not already contain entities. e.g. " ==> " < ==> < ordinary text passes unchanged. Does not convert space to  

Parameters:
text - raw text to be processed. Must not be null.
Returns:
translated XML text, or null if input is null.

toHTMLEntity

public static java.lang.String toHTMLEntity(char c)
Converts text to HTML by quoting dangerous characters.; Does not convert space to  

Parameters:
c - raw character.
Returns:
translated HTML text, eg. & -> & x -> x

toXMLEntity

public static java.lang.String toXMLEntity(char c)
Converts text to XML by quoting dangerous characters.; Does not convert space to  

Parameters:
c - raw character.
Returns:
translated HTML text, eg. < -> < x -> x