com.evanmclean.evlib.velocity.tools
Class EscapeTool

java.lang.Object
  extended by org.apache.velocity.tools.generic.SafeConfig
      extended by org.apache.velocity.tools.generic.EscapeTool
          extended by com.evanmclean.evlib.velocity.tools.EscapeTool

public class EscapeTool
extends EscapeTool

Extends the velocity tools EscapeTool with extra things that can be escaped.

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

Field Summary
 
Fields inherited from class org.apache.velocity.tools.generic.EscapeTool
DEFAULT_KEY
 
Fields inherited from class org.apache.velocity.tools.generic.SafeConfig
LOCK_CONFIG_KEY, OLD_LOCK_CONFIG_KEY, SAFE_MODE_KEY
 
Constructor Summary
EscapeTool()
           
 
Method Summary
 String cdata(Object obj)
           Return the string with any characters that require escaping done to make it safe for use in XML CDATA text.
 String csv(Object obj)
           Makes a string safe to use as a field within a comma separated (CSV) file.
 String html(Object obj)
           Return the string with any characters that require escaping done to make it safe for use in HTML text.
 String htmlAttr(Object obj)
          Return the string with any characters that require escaping done to make it safe for an HTML attribute.
 String htmlBr(Object obj)
          Return the string with any characters that require escaping done to make it safe for use in HTML text.
 String htmlComment(Object obj)
           Return the string with any characters that require escaping done to make it safe for use in an HTML comment.
 String java(Object obj)
           Makes a string safe to use as a string literal inside a piece of Java code (does not add enclosing double quotes).
 String javascript(Object obj)
           Makes a string safe to use as a string literal inside a piece of Javascript code (does not add enclosing double quotes).
 String url(Object obj)
          Return the string with any characters that require escaping done to make it safe for a URL argument.
 String xml(Object obj)
           Return the string with any characters that require escaping done to make it safe for use in XML text.
 String xmlAttr(Object obj)
          Return the string with any characters that require escaping done to make it safe for an XML attribute.
 String xmlComment(Object obj)
           Return the string with any characters that require escaping done to make it safe for use in an XML comment.
 
Methods inherited from class org.apache.velocity.tools.generic.EscapeTool
configure, dumpString, getB, getBackslash, getD, getDollar, getE, getExclamation, getH, getHash, getKey, getN, getNewline, getQ, getQuote, getS, getSingleQuote, propertyKey, propertyValue, setKey, sql, unicode, velocity
 
Methods inherited from class org.apache.velocity.tools.generic.SafeConfig
configure, isConfigLocked, isSafeMode, setLockConfig, setSafeMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EscapeTool

public EscapeTool()
Method Detail

cdata

public String cdata(Object obj)

Return the string with any characters that require escaping done to make it safe for use in XML CDATA text. Null returns null.

Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

csv

public String csv(Object obj)

Makes a string safe to use as a field within a comma separated (CSV) file. Null returns null.

Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

html

public String html(Object obj)

Return the string with any characters that require escaping done to make it safe for use in HTML text. Null returns null.

Overrides:
html in class EscapeTool
Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

htmlAttr

public String htmlAttr(Object obj)
Return the string with any characters that require escaping done to make it safe for an HTML attribute. Null returns null.

Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

htmlBr

public String htmlBr(Object obj)
Return the string with any characters that require escaping done to make it safe for use in HTML text. New line characters have "<br />" inserted in front of them. Null returns null.

Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

htmlComment

public String htmlComment(Object obj)

Return the string with any characters that require escaping done to make it safe for use in an HTML comment. Null returns null.

Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

java

public String java(Object obj)

Makes a string safe to use as a string literal inside a piece of Java code (does not add enclosing double quotes). Null returns null.

Overrides:
java in class EscapeTool
Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

javascript

public String javascript(Object obj)

Makes a string safe to use as a string literal inside a piece of Javascript code (does not add enclosing double quotes). Null returns null.

Overrides:
javascript in class EscapeTool
Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

url

public String url(Object obj)
Return the string with any characters that require escaping done to make it safe for a URL argument. Null returns null.

Overrides:
url in class EscapeTool
Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.
Throws:
RuntimeException - In the extremely unlikely event that your JVM doesn't know how to do UTF-8 encoding, we rethrow the UnsupportedEncodingException as a RuntimeException instead. Should never happen.

xml

public String xml(Object obj)

Return the string with any characters that require escaping done to make it safe for use in XML text. Null returns null.

Overrides:
xml in class EscapeTool
Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

xmlAttr

public String xmlAttr(Object obj)
Return the string with any characters that require escaping done to make it safe for an XML attribute. Null returns null.

Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.

xmlComment

public String xmlComment(Object obj)

Return the string with any characters that require escaping done to make it safe for use in an XML comment. Null returns null.

Parameters:
obj - The string to make safe.
Returns:
The string with any substitutions necessary.