Kafenio.editor 0.8.5

de.xeinfach.kafenio.util
Class HTMLTranslate

java.lang.Object
  extended byde.xeinfach.kafenio.util.HTMLTranslate

public final class HTMLTranslate
extends java.lang.Object

HTMLTranslate numeric character references and character entity references to unicode characters. Based on tables found at http://www.w3.org/TR/REC-html40/sgml/entities.html

Note: Do not edit! This class is created by the Generate class.

Typical usage:

      String s = HTMLTranslate.decode (getTextFromHtmlPage ());
 

Author:
DerrickOswald@users.sourceforge.net, Karsten Pawlik // removed not necessary methods.

Method Summary
static char convertToChar(java.lang.String string)
          Convert a reference to a unicode character.
static java.lang.String convertToString(java.lang.Character character)
          Convert a character to a character entity reference.
static java.lang.String convertToString(int character)
          Convert a character to a numeric character reference.
static java.lang.String decode(java.lang.String string)
          Decode a string containing references.
static java.lang.String encode(java.lang.String string)
          Encode a string to use references.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertToChar

public static char convertToChar(java.lang.String string)
Convert a reference to a unicode character. Convert a single numeric character reference or character entity reference to a unicode character.

Parameters:
string - The string to convert. Of the form &xxxx; or &#xxxx; with or without the leading ampersand or trailing semi-colon.
Returns:
The converted character or '\0' (zero) if the string is an invalid reference.

decode

public static java.lang.String decode(java.lang.String string)
Decode a string containing references. Change all numeric character reference and character entity references to unicode characters.

Parameters:
string - The string to translate.
Returns:
returns the input string without html-entities.

convertToString

public static java.lang.String convertToString(java.lang.Character character)
Convert a character to a character entity reference. Convert a unicode character to a character entity reference of the form &xxxx;.

Parameters:
character - The character to convert.
Returns:
The converted character or null if the character is not one of the known entity references.

convertToString

public static java.lang.String convertToString(int character)
Convert a character to a numeric character reference. Convert a unicode character to a numeric character reference of the form &#xxxx;.

Parameters:
character - The character to convert.
Returns:
The converted character.

encode

public static java.lang.String encode(java.lang.String string)
Encode a string to use references. Change all characters that are not ASCII to their numeric character reference or character entity reference. This implementation is inefficient, allocating a new Character for each character in the string, but this class is primarily intended to decode strings so efficiency and speed in the encoding was not a priority.

Parameters:
string - The string to translate.
Returns:
returns the encoded input string.

Kafenio.editor 0.8.5

Copyright © 2003-2004 by Karsten Pawlik. All Rights Reserved. Published under the Lesser General Public License (LGPL)