com.iplanet.jato.util
Class HtmlUtil

java.lang.Object
  |
  +--com.iplanet.jato.util.HtmlUtil

public class HtmlUtil
extends java.lang.Object

Static utility class for escaping/descaping strings to/from suitable HTML forms, generating unique values and formating data for HTML display. This class provides static methods only and the default constructor is hidden. The implementation focuses on avoiding synchronization points for higher performance.

Version:
JATO/1.2.2 $Id: HtmlUtil.java,v 1.13 2002/03/16 03:26:38 todd Exp $

Field Summary
static int ALPHANUMERIC_FORMAT_TYPE
           
static char ALPHANUMERIC_MASK_TOKEN
           
static int CURRENCY_FORMAT_TYPE
           
static int DATETIME_FORMAT_TYPE
           
static boolean DEBUG_FORMAT
           
static int DECIMAL_FORMAT_TYPE
           
static int NO_FORMAT_TYPE
           
 
Method Summary
static java.lang.String descape(java.lang.String encodedString)
          Reverse the effects of the escape(String) method.
static java.lang.String escape(java.lang.String rawString)
          Convert a string to an equivalent form suitable for HTML output.
static java.lang.String escapeQuotes(java.lang.String rawString)
          Convert a string containing quotes to an equivalent form suitable for HTML output.
static java.lang.String format(java.util.Date value, java.lang.String pattern)
          Shortcut to generalized format method for explicit date formatting.
static java.lang.String format(java.lang.Object value, int formatType, java.lang.String pattern)
          Shortcut to generalized format method with default Locale
static java.lang.String format(java.lang.Object value, int formatType, java.lang.String pattern, java.util.Locale locale)
          Shortcut to generalized format method with default symbols
static java.lang.String format(java.lang.Object value, int formatType, java.lang.String pattern, java.util.Locale locale, java.text.DecimalFormatSymbols decimalSymbols, java.text.DateFormatSymbols dateSymbols)
          Generalized format method which currently only supports string and decimal formatting.
static java.lang.String format(java.lang.String value, java.lang.String pattern)
          Shortcut to generalized format method for explicit string formatting
static java.lang.String formatString(java.lang.String value, java.lang.String pattern)
          Formatting of arbitrary text via the application of a simple mask containing any arbitrary combination of static text and the reserved metacharacter "?".
static int getUniqueValue()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_FORMAT

public static final boolean DEBUG_FORMAT

ALPHANUMERIC_MASK_TOKEN

public static final char ALPHANUMERIC_MASK_TOKEN

NO_FORMAT_TYPE

public static final int NO_FORMAT_TYPE

ALPHANUMERIC_FORMAT_TYPE

public static final int ALPHANUMERIC_FORMAT_TYPE

DATETIME_FORMAT_TYPE

public static final int DATETIME_FORMAT_TYPE

CURRENCY_FORMAT_TYPE

public static final int CURRENCY_FORMAT_TYPE

DECIMAL_FORMAT_TYPE

public static final int DECIMAL_FORMAT_TYPE
Method Detail

escapeQuotes

public static java.lang.String escapeQuotes(java.lang.String rawString)
Convert a string containing quotes to an equivalent form suitable for HTML output. Shortcut for escape(String) when original string is known to only have quotes and no other unsuitable characters.
Parameters:
rawString - The HTML string to escape

escape

public static java.lang.String escape(java.lang.String rawString)
Convert a string to an equivalent form suitable for HTML output. Specifically, the greater-than, less-than, ampersand, and double quote characters are escaped.
Parameters:
rawString - The HTML string to escape

descape

public static java.lang.String descape(java.lang.String encodedString)
Reverse the effects of the escape(String) method.
Parameters:
encodedString - The HTML string to unescape

getUniqueValue

public static int getUniqueValue()
Returns:
a unique 32-bit integer without synchronization costs.

format

public static java.lang.String format(java.util.Date value,
                                      java.lang.String pattern)
Shortcut to generalized format method for explicit date formatting. Generates formatted string from java.util.Date value according to default Locale and provided pattern. Please note that this features in not implemented yet.

format

public static java.lang.String format(java.lang.String value,
                                      java.lang.String pattern)
Shortcut to generalized format method for explicit string formatting
See Also:
generalized format method

format

public static java.lang.String format(java.lang.Object value,
                                      int formatType,
                                      java.lang.String pattern)
Shortcut to generalized format method with default Locale
See Also:
generalized format method

format

public static java.lang.String format(java.lang.Object value,
                                      int formatType,
                                      java.lang.String pattern,
                                      java.util.Locale locale)
Shortcut to generalized format method with default symbols
See Also:
generalized format method

format

public static java.lang.String format(java.lang.Object value,
                                      int formatType,
                                      java.lang.String pattern,
                                      java.util.Locale locale,
                                      java.text.DecimalFormatSymbols decimalSymbols,
                                      java.text.DateFormatSymbols dateSymbols)
Generalized format method which currently only supports string and decimal formatting. Alphanumeric formatting uses a simple mask containing any arbitrary combination of static text and the reserved metacharacter "?". Each "?" metacharacter serves as a placeholder for a single character in the value being formatted, proceeding from left to right. A literal "?" can be specified by escaping the "?" character with "\\". Decimal and currency formatting uses a format mask consisting of two patterns separated by a semicolon: a primary pattern (specifies precision and thousandths separator) and a negative number pattern (see java.text.DecimalFormat for pattern details).
Parameters:
value - object to be formatted
formatType - must be one of NO_FORMAT_TYPE, ALPHANUMERIC_FORMAT_TYPE, DATETIME_FORMAT_TYPE unsupported, CURRENCY_FORMAT_TYPE unsupported, DECIMAL_FORMAT_TYPE
pattern - format string
locale - used for date and currency formatting
decimalSymbols - see java.text.DecimalFormatSymbols
dateSymbols - not used
Returns:
formatted string, string form of the input value if NO_FORMAT_TYPE or null if the input value is null

formatString

public static java.lang.String formatString(java.lang.String value,
                                            java.lang.String pattern)
Formatting of arbitrary text via the application of a simple mask containing any arbitrary combination of static text and the reserved metacharacter "?". Each "?" metacharacter serves as a placeholder for a single character in the value being formatted, proceeding from left to right. A literal "?" can be specified by escaping the "?" character with "\\".