com.lowagie.text.html
Class HtmlEncoder
java.lang.Object
com.lowagie.text.html.HtmlEncoder
public class HtmlEncoder
extends java.lang.Object
This class converts a
String
to the HTML-format of a String.
To convert the
String
, each character is examined:
- ASCII-characters from 000 till 031 are represented as &#xxx;
(with xxx = the value of the character)
- ASCII-characters from 032 t/m 127 are represented by the character itself, except for:
- '\n' becomes <BR>\n
- " becomes "
- & becomes &
- < becomes <
- > becomes >
ASCII-characters from 128 till 255 are represented as &#xxx;
(with xxx = the value of the character)
Example:
String htmlPresentation = HtmlEncoder.encode("Marie-Thérèse Sørensen");
for more info: see O'Reilly; "HTML: The Definitive Guide" (page 164)
- mario.maccarini@rug.ac.be
private static String[] | htmlCode - List with the HTML translation of all the characters.
|
static String | encode(Color color) - Converts a
Color into a HTML representation of this Color .
|
static String | encode(String string) - Converts a
String to the HTML-format of this String .
|
static String | getAlignment(int alignment) - Translates the alignment value.
|
htmlCode
private static final String[] htmlCode
List with the HTML translation of all the characters.
HtmlEncoder
private HtmlEncoder()
This class will never be constructed.
HtmlEncoder only contains static methods.
encode
public static String encode(Color color)
Converts a Color
into a HTML representation of this Color
.
color
- the Color
that has to be converted.
- the HTML representation of this Color
encode
public static String encode(String string)
Converts a String
to the HTML-format of this String
.
string
- The String
to convert
getAlignment
public static String getAlignment(int alignment)
Translates the alignment value.
alignment
- the alignment value