java.lang.Object
com.sun.faces.util.HtmlUtils
Utility class for HTML. Kudos to Adam Winer (Oracle) for much of this code.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isEmptyElement
(String name) static boolean
isISO8859_1encoding
(String encoding) static boolean
isUTFencoding
(String encoding) static boolean
validateEncoding
(String encoding) static void
writeAttribute
(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buff, char[] text, int start, int length, boolean isScriptInAttributeValueEnabled, boolean forXml) Write a character array attribute.static void
writeAttribute
(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buff, String text, char[] textBuff, boolean isScriptInAttributeValueEnabled, boolean forXml) Write a string attribute.static void
writeText
(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buffer, char[] text, boolean forXml) static void
writeText
(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buff, char[] text, int start, int length, boolean forXml) Write char array text.static void
writeText
(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buff, String text, char[] textBuff, boolean forXml) Write String text.static void
writeTextForXML
(Writer out, String text, char[] outbuf) static void
writeUnescapedTextForXML
(Writer out, String text) static void
Writes a string into URL-encoded format out to a Writer.static void
Writes a string into URL-encoded format out to a Writer.
-
Method Details
-
writeText
public static void writeText(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buffer, char[] text, boolean forXml) throws IOException - Throws:
IOException
-
writeText
public static void writeText(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buff, char[] text, int start, int length, boolean forXml) throws IOException Write char array text.- Throws:
IOException
-
writeText
public static void writeText(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buff, String text, char[] textBuff, boolean forXml) throws IOException Write String text.- Throws:
IOException
-
writeAttribute
public static void writeAttribute(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buff, String text, char[] textBuff, boolean isScriptInAttributeValueEnabled, boolean forXml) throws IOException Write a string attribute. Note that this code is duplicated below for character arrays - change both places if you make any changes!!!- Throws:
IOException
-
writeAttribute
public static void writeAttribute(Writer out, boolean escapeUnicode, boolean escapeIsocode, char[] buff, char[] text, int start, int length, boolean isScriptInAttributeValueEnabled, boolean forXml) throws IOException Write a character array attribute. Note that this code is duplicated above for string - change both places if you make any changes!!!- Throws:
IOException
-
writeURL
public static void writeURL(Writer out, String text, char[] textBuff, String queryEncoding) throws IOException, UnsupportedEncodingException Writes a string into URL-encoded format out to a Writer. All characters before the start of the query string will be encoded using UTF-8. Characters after the start of the query string will be encoded using a client-defined encoding. You'll need to use the encoding that the server will expect. (HTML forms will generate query strings using the character encoding that the HTML itself was generated in.) All characters will be encoded as needed for URLs, with the exception of the percent symbol ("%"). Because this is the character itself used for escaping, attempting to escape this character would cause this code to double-escape some strings. It also may be necessary to pre-escape some characters. In particular, a question mark ("?") is considered the start of the query string.NOTE: This is method is duplicated below. The difference being the acceptance of a char[] for the text to write. Any changes made here, should be made below.
- Parameters:
out
- a Writer for the outputtext
- the unencoded (or partially encoded) StringqueryEncoding
- the character set encoding for after the first question mark- Throws:
IOException
UnsupportedEncodingException
-
writeURL
public static void writeURL(Writer out, char[] textBuff, int start, int len, String queryEncoding) throws IOException, UnsupportedEncodingException Writes a string into URL-encoded format out to a Writer. All characters before the start of the query string will be encoded using UTF-8. Characters after the start of the query string will be encoded using a client-defined encoding. You'll need to use the encoding that the server will expect. (HTML forms will generate query strings using the character encoding that the HTML itself was generated in.) All characters will be encoded as needed for URLs, with the exception of the percent symbol ("%"). Because this is the character itself used for escaping, attempting to escape this character would cause this code to double-escape some strings. It also may be necessary to pre-escape some characters. In particular, a question mark ("?") is considered the start of the query string.NOTE: This is method is duplicated above. The difference being the acceptance of a String for the text to write. Any changes made here, should be made above.
- Parameters:
out
- a Writer for the outputtextBuff
- char[] containing the content to writequeryEncoding
- the character set encoding for after the first question mark- Throws:
IOException
UnsupportedEncodingException
-
writeTextForXML
- Throws:
IOException
-
writeUnescapedTextForXML
- Throws:
IOException
-
validateEncoding
-
isISO8859_1encoding
-
isUTFencoding
-
isEmptyElement
-