Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

oracle.i18n.net
Class CharEntityReference

java.lang.Object
  |
  +--oracle.i18n.net.CharEntityReference

public class CharEntityReference
extends Object

CharEntityReference is a utility class to escape or unescape a string into character reference or entity reference form.

Character reference refers to a specific character in the ISO/IEC 10646 character set in the following representation:

  CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'

Entity reference refers to the content of named entity of the form '&XXX;', where XXX represents the name of the entity. These names are defined in XML and HTML standards.

In escape operations, the entities 'amp', 'lt', 'gt', 'apos', and 'quot' are used as NAMED entity references. DECIMAL or HEXADECIMAL character references are used for other characters.

In unescape operations, 'amp', 'lt', 'gt', 'apos', 'quot' and all entity references defined in HTML 4.01 recognized in order to convert back to original characters.

Since:
10.1.0.2
See Also:
HTML 4.01 Specification, Extensible Markup Language (XML) 1.0 (Second Edition)

Nested Class Summary
static class CharEntityReference.Form
          Form parameter class that specifies the escaped form.

 

Method Summary
static String escape(String srcstr)
          Escapes a String into the character entity reference form in NAMED_DECIMAL_NUMBER assuming WE8ISO8859P1 character set.
static String escape(String srcstr, String dstCharset)
          Escapes a String into the character entity refernce form in NAMED_DECIMAL_NUMBER.
static String escape(String srcstr, String dstCharset, CharEntityReference.Form form)
          Escapes a String into the character entity refernce form.
static String unescape(String srcstr)
          Converts an escaped String into a Unicode string.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Method Detail

escape

public static String escape(String srcstr)
Escapes a String into the character entity reference form in NAMED_DECIMAL_NUMBER assuming WE8ISO8859P1 character set.

Default character set is WE8ISO8859P1, and default form is NAMED_DECIMAL_NUMBER. Some characters are escaped in the named entity, e.g., &lt; for '<'; other characters are escaped in the hexadecimal form if they are not supported by the given character set.

Parameters:
srcstr - a String to be escaped
Returns:
an escaped String object
Throws:
IllegalStateException - if WE8ISO8859P1 is not supported.
See Also:
escape(String, String, CharEntityReference.Form)

escape

public static String escape(String srcstr,
String dstCharset)
                     throws UnsupportedEncodingException
Escapes a String into the character entity refernce form in NAMED_DECIMAL_NUMBER.

Default form is NAMED_DECIMAL_NUMBER. Some characters are escaped in the named entity, e.g., &lt; for '<'; other characters are escaped in the hexadecimal form if they are not supported by the given character set.

Parameters:
srcstr - a String to be escaped
dstCharset - an Oracle character set name
Returns:
an escaped String object
Throws:
UnsupportedEncodingException - if the dstCharset is a invalid character set name.
See Also:
escape(String, String, CharEntityReference.Form)

escape

public static String escape(String srcstr,
String dstCharset,
CharEntityReference.Form form)
                     throws UnsupportedEncodingException
Escapes a String into the character entity refernce form. Aside from characters not supported by the given character set in either form of DECIMAL_NUMBER or HEXADECIMAL_NUMBER form, the following characters will be escaped in either NAMED, DECIMAL_NUMBER, or HEXADECIMAL_NUMBER forms:

Parameters:
srcstr - a String to be escaped
dstCharset - an Oracle character set name
form - a form of character entity reference
Returns:
an escaped String object
Throws:
UnsupportedEncodingException - if the dstCharset is invalid character set name.

unescape

public static String unescape(String srcstr)
Converts an escaped String into a Unicode string.
Parameters:
srcstr - a string containing escaped characters
Returns:
a String representing the original data
Throws:
IllegalArgumentException - if unregistered character entity reference is used.

Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

Copyright © 2003 Oracle Corporation. All Rights Reserved.