com.evanmclean.evlib.escape
Class EscHtml

java.lang.Object
  extended by com.evanmclean.evlib.escape.EscHtml

public final class EscHtml
extends Object

Performs character escaping suitable for HTML output.

In general, if you pass a null in, you'll get a null out. Otherwise, you'll get the Object.toString() value of the object you pass in, escaped appropriately.

Author:
Evan McLean McLean Computer Services (see the overview for copyright and licensing.)

Method Summary
 String attr(Object obj)
          Performs escaping for an HTML attribute.
 String comment(Object obj)
          Performs escaping for an HTML comment.
 String text(Object obj)
          Performs escaping for general HTML text.
 String textbr(Object obj)
           Performs escaping for general HTML text, and also inserts a <br> or <br/> as appropriate before each new line.
 String textbr(Object obj, boolean replace)
           Performs escaping for general HTML text, and also inserts or replaces a <br> or <br/> as appropriate before each new line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

attr

public String attr(Object obj)
Performs escaping for an HTML attribute.

Parameters:
obj -
Returns:
The substituted string, or null if obj was null.

comment

public String comment(Object obj)
Performs escaping for an HTML comment.

Parameters:
obj -
Returns:
The substituted string, or null if obj was null.

text

public String text(Object obj)
Performs escaping for general HTML text.

Parameters:
obj -
Returns:
The substituted string, or null if obj was null.

textbr

public String textbr(Object obj)

Performs escaping for general HTML text, and also inserts a <br> or <br/> as appropriate before each new line.

A newline is one of:

\r
A single Carriage Return (ASCII 13)
\n
A single Line Feed or Newline (ASCII 10)
\r\n
A Carriage Return followed by a Line Feed

Parameters:
obj -
Returns:
The substituted string, or null if obj was null.

textbr

public String textbr(Object obj,
                     boolean replace)

Performs escaping for general HTML text, and also inserts or replaces a <br> or <br/> as appropriate before each new line.

A newline is one of:

\r
A single Carriage Return (ASCII 13)
\n
A single Line Feed or Newline (ASCII 10)
\r\n
A Carriage Return followed by a Line Feed

Parameters:
obj -
replace - If true then replace the newline character(s), else just insert the element before it.
Returns:
The substituted string, or null if obj was null.