com.sun.faces.util
Class HtmlUtils

java.lang.Object
  extended by com.sun.faces.util.HtmlUtils

public class HtmlUtils
extends java.lang.Object

Utility class for HTML. Kudos to Adam Winer (Oracle) for much of this code.


Method Summary
static boolean isEmptyElement(java.lang.String name)
           
static boolean validateEncoding(java.lang.String encoding)
           
static void writeAttribute(java.io.Writer out, char[] buffer, char[] text)
           
static void writeAttribute(java.io.Writer out, char[] buff, char[] text, int start, int length)
          Write a character array attribute.
static void writeAttribute(java.io.Writer out, char[] buff, java.lang.String text)
          Write a string attribute.
static void writeText(java.io.Writer out, char[] buffer, char[] text)
           
static void writeText(java.io.Writer out, char[] buff, char[] text, int start, int length)
          Write char array text.
static void writeText(java.io.Writer out, char[] buff, java.lang.String text)
          Write String text.
static void writeURL(java.io.Writer out, java.lang.String text, java.lang.String queryEncoding, java.lang.String contentType)
          Writes a string into URL-encoded format out to a Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writeText

public static void writeText(java.io.Writer out,
                             char[] buffer,
                             char[] text)
                      throws java.io.IOException
Throws:
java.io.IOException

writeText

public static void writeText(java.io.Writer out,
                             char[] buff,
                             char[] text,
                             int start,
                             int length)
                      throws java.io.IOException
Write char array text. Note that this code is duplicated below for Strings - change both places if you make any changes!!!

Throws:
java.io.IOException

writeText

public static void writeText(java.io.Writer out,
                             char[] buff,
                             java.lang.String text)
                      throws java.io.IOException
Write String text. Note that this code is duplicated above for character arrays - change both places if you make any changes!!!

Throws:
java.io.IOException

writeAttribute

public static void writeAttribute(java.io.Writer out,
                                  char[] buff,
                                  java.lang.String text)
                           throws java.io.IOException
Write a string attribute. Note that this code is duplicated below for character arrays - change both places if you make any changes!!!

Throws:
java.io.IOException

writeAttribute

public static void writeAttribute(java.io.Writer out,
                                  char[] buffer,
                                  char[] text)
                           throws java.io.IOException
Throws:
java.io.IOException

writeAttribute

public static void writeAttribute(java.io.Writer out,
                                  char[] buff,
                                  char[] text,
                                  int start,
                                  int length)
                           throws java.io.IOException
Write a character array attribute. Note that this code is duplicated above for string - change both places if you make any changes!!!

Throws:
java.io.IOException

writeURL

public static void writeURL(java.io.Writer out,
                            java.lang.String text,
                            java.lang.String queryEncoding,
                            java.lang.String contentType)
                     throws java.io.IOException,
                            java.io.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 ISO-8859-1. PENDING: Ideally, we'd encode characters before the query string using UTF-8, which is what the HTML spec recommends. Unfortunately, the Apache server doesn't support this until 2.0.

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.

Parameters:
out - a Writer for the output
text - the unencoded (or partially encoded) String
queryEncoding - the character set encoding for after the first question mark
Throws:
java.io.IOException
java.io.UnsupportedEncodingException

validateEncoding

public static boolean validateEncoding(java.lang.String encoding)

isEmptyElement

public static boolean isEmptyElement(java.lang.String name)


Copyright ? 2002-2006 Sun Microsystems, Inc. All Rights Reserved.