Package org.dlese.dpc.util
Class HTMLTools
java.lang.Object
org.dlese.dpc.util.HTMLTools
This class holds a number of handy static methods for use in HTML and XML processing.
- Version:
- $Id: HTMLTools.java,v 1.9 2009/03/20 23:34:00 jweather Exp $
- Author:
- John Weatherley
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringencodeCharacterEntityReferences(String input, boolean isSGML) Encodes a regular String with caracter entity references, for example the ampersand character & becomes &.static final StringBufferjavaScriptEncode(char[] chars) Encodes an Array of chars so that they will be valid inside JavaScript quotes.static final StringBufferjavaScriptEncode(String string) Encodes a String so that it will be valid inside JavaScript quotes.static final StringjavaScriptEncodeToStr(String string) Same behavior asjavaScriptEncode(char[]).static StringremoveHTMLComments(String input) Removes all HTML comments from a String.
-
Constructor Details
-
HTMLTools
public HTMLTools()
-
-
Method Details
-
removeHTMLComments
Removes all HTML comments from a String.- Parameters:
input- HTML String- Returns:
- HTML with all comments removed
-
encodeCharacterEntityReferences
Encodes a regular String with caracter entity references, for example the ampersand character & becomes &. See Entities Reference for a nice table of character entity references. Ampersands that are already encoded will not be touched. If the input string is an SGML variant like HTML or XML then all occurances of the characters <, > and " are left alone.- Parameters:
input- A String.isSGML- True if the input string is a an SGML variant such as HTML or XML, false if not.- Returns:
- A String that is encoded with character entity references.
-
javaScriptEncode
Encodes an Array of chars so that they will be valid inside JavaScript quotes.- Parameters:
chars- An array of chars- Returns:
- The resulting, encoded StringBuffer
-
javaScriptEncode
Encodes a String so that it will be valid inside JavaScript quotes.- Parameters:
string- A String- Returns:
- The resulting, encoded StringBuffer
-
javaScriptEncodeToStr
Same behavior asjavaScriptEncode(char[]).- Parameters:
string- A String- Returns:
- The resulting, encoded String
-