net.atlanticbb.tantlinger.ui.text
Class Entities

java.lang.Object
  extended by net.atlanticbb.tantlinger.ui.text.Entities

public class Entities
extends java.lang.Object

Provides HTML and XML entity utilities.

This class comes from the jakarta project's commons-lang package. It was made public and method unescapeUnknownEntities was added.

Since:
2.0
Author:
Alexander Day Chaffee, Gary Gregory
See Also:
ISO Entities,
HTML 3.2 Character Entities for ISO Latin-1,
HTML 4.0 Character entity references,
HTML 4.01 Character References,
HTML 4.01 Code positions

Field Summary
static Entities HTML_BASIC
           A set of common entities that should be escaped in HTML.
static Entities HTML32
           The set of entities supported by HTML 3.2.
static Entities HTML40
           The set of entities supported by HTML 4.0.
static Entities HTML40_FULL
           The set of entities supported by HTML 4.0.
static Entities XML
           The set of entities supported by standard XML.
 
Constructor Summary
Entities()
           
 
Method Summary
 void addEntities(java.lang.String[][] entityArray)
           
 void addEntity(java.lang.String name, int value)
           
 java.lang.String entityName(int value)
           
 int entityValue(java.lang.String name)
           
 java.lang.String escape(java.lang.String str)
           Escapes the characters in a String.
 java.lang.String escape(java.lang.String str, boolean escapeNon7bit)
           Escapes the characters in a String.
 java.lang.String unescape(java.lang.String str)
           Unescapes the entities in a String.
 java.lang.String unescapeUnknownEntities(java.lang.String str)
           Unescapes the unknown entities in a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML

public static final Entities XML

The set of entities supported by standard XML.


HTML_BASIC

public static final Entities HTML_BASIC

A set of common entities that should be escaped in HTML. This includes double-quote, ampersand, less-than, greater-than and chars 160 - 190


HTML32

public static final Entities HTML32

The set of entities supported by HTML 3.2.


HTML40

public static final Entities HTML40

The set of entities supported by HTML 4.0. excluding greek entities


HTML40_FULL

public static final Entities HTML40_FULL

The set of entities supported by HTML 4.0. including greek entities

Constructor Detail

Entities

public Entities()
Method Detail

addEntities

public void addEntities(java.lang.String[][] entityArray)

addEntity

public void addEntity(java.lang.String name,
                      int value)

entityName

public java.lang.String entityName(int value)

entityValue

public int entityValue(java.lang.String name)

escape

public java.lang.String escape(java.lang.String str)

Escapes the characters in a String.

For example, if you have called addEntity("foo", 0xA1), escape("¡") will return "&foo;"

Parameters:
str - The String to escape.
Returns:
A new escaped String.

escape

public java.lang.String escape(java.lang.String str,
                               boolean escapeNon7bit)

Escapes the characters in a String.

For example, if you have called addEntity("foo", 0xA1), escape("¡") will return "&foo;"

Parameters:
str - The String to escape.
escapeNon7bit - Indicate whether non-7-bit chars should be escaped as well
Returns:
A new escaped String.

unescape

public java.lang.String unescape(java.lang.String str)

Unescapes the entities in a String.

For example, if you have called addEntity("foo", 0xA1), unescape("&foo;") will return "¡"

Parameters:
str - The String to escape.
Returns:
A new escaped String.

unescapeUnknownEntities

public java.lang.String unescapeUnknownEntities(java.lang.String str)

Unescapes the unknown entities in a String.

For example, if you have called addEntity("foo", 0xA1), unescape("&foo;") will return & quot;&foo& quot;

This is useful if you only want to unescape Cryllic entities, for example.

Parameters:
str - The String to escape.
Returns:
A new escaped String.