com.atlassian.renderer.v2.components
Class HtmlEscaper

java.lang.Object
  extended by com.atlassian.renderer.v2.components.HtmlEscaper

public final class HtmlEscaper
extends Object


Method Summary
static String escapeAll(String s, boolean preserveExistingEntities)
          Replaces the HTML "special characters" <, >, ", ', and & with their equivalent entities in HTML 4 and returns the result.
static String escapeAllExceptQuotes(String s, boolean preserveExistingEntities)
          Does the same as escapeAll(String,boolean), except doesn't replace the quotation mark characters " and '.
static String escapeAmpersands(String s, boolean preserveExistingEntities)
          Replaces the HTML "special character" & with its equivalent entity in HTML 4 and returns the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

escapeAll

public static String escapeAll(String s,
                               boolean preserveExistingEntities)
Replaces the HTML "special characters" <, >, ", ', and & with their equivalent entities in HTML 4 and returns the result. Also replaces the Microsoft "smart quotes" characters (extended ASCII 145-148) with their equivalent HTML entities.

Passing true for preserveExistingEntities will try to not break existing entities already found in the input string, by avoiding escaping ampersands which form part of an existing entity like &lt;. Passing false will do the normal behaviour of escaping everything.

Parameters:
s - the String to escape
preserveExistingEntities - if true, will avoid escaping the ampersand in an existing entity like &lt;. If false, the method will do a normal escaping by replace all matched characters.
Returns:
the string with special characters replaced by entities.

escapeAllExceptQuotes

public static String escapeAllExceptQuotes(String s,
                                           boolean preserveExistingEntities)
Does the same as escapeAll(String,boolean), except doesn't replace the quotation mark characters " and '.

Parameters:
s - the String to escape
preserveExistingEntities - if true, will avoid escaping the ampersand in an existing entity like &lt;. If false, the method will do a normal escaping by replace all matched characters.
Returns:
the string with special characters replaced by entities.

escapeAmpersands

public static String escapeAmpersands(String s,
                                      boolean preserveExistingEntities)
Replaces the HTML "special character" & with its equivalent entity in HTML 4 and returns the result.

Passing true for preserveExistingEntities will try to not break existing entities already found in the input string, by avoiding escaping ampersands which form part of an existing entity like &lt;. Passing false will do the normal behaviour of escaping everything.

Parameters:
s - the String to escape
preserveExistingEntities - if true, will avoid escaping the ampersand in an existing entity like &lt;. If false, the method will do a normal escaping by replace all matched characters.
Returns:
the string with special characters replaced by entities.


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.