org.xwiki.velocity.tools
Class EscapeTool

java.lang.Object
  extended by org.apache.velocity.tools.generic.EscapeTool
      extended by org.xwiki.velocity.tools.EscapeTool

public class EscapeTool
extends org.apache.velocity.tools.generic.EscapeTool

Tool for working with escaping in Velocity templates. It provides methods to escape outputs for Velocity, Java, JavaScript, HTML, XML and SQL.

Extends the default EscapeTool from velocity-tools since the XML escape performed by it doesn't work inside HTML content, since apos is not a valid HTML entity name, and it always escapes non-ASCII characters, which increases the HTML length considerably, while also making the source unreadable.

Since:
2.7RC1
Version:
$Id: 96bba45f3e30e9e868650c8e9044468f904de4b7 $

Constructor Summary
EscapeTool()
           
 
Method Summary
 String b(Object content)
          Encode a text using the B encoding specified in RFC 2047.
 String q(Object content)
          Encode a text using the Q encoding specified in RFC 2047.
 String quotedPrintable(Object content)
          Encode a text using the Quoted-Printable format, as specified in section 6.7 of RFC 2045.
 String xml(Object content)
          Escapes the XML special characters in a String using numerical XML entities.
 
Methods inherited from class org.apache.velocity.tools.generic.EscapeTool
dumpString, getB, getBackslash, getD, getDollar, getE, getExclamation, getH, getHash, getQ, getQuote, getS, getSingleQuote, html, java, javascript, propertyKey, propertyValue, sql, url
 
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

xml

public String xml(Object content)
Escapes the XML special characters in a String using numerical XML entities.

Overrides:
xml in class org.apache.velocity.tools.generic.EscapeTool
Parameters:
content - the text to escape, may be null
Returns:
a new escaped String, null if null input

quotedPrintable

public String quotedPrintable(Object content)
Encode a text using the Quoted-Printable format, as specified in section 6.7 of RFC 2045. UTF-8 is used as the character encoding, and no line breaking is performed.

Parameters:
content - the text to encode
Returns:
the text converted into the Quoted-Printable format

q

public String q(Object content)
Encode a text using the Q encoding specified in RFC 2047. UTF-8 is used as the character encoding, and no line breaking is performed. The resulting text is already wrapped with the encoded word markers, starting with =?UTF-8?Q? and ending with ?=.

Parameters:
content - the text to encode
Returns:
the text converted into an encoded word using the Q encoding

b

public String b(Object content)
Encode a text using the B encoding specified in RFC 2047. UTF-8 is used as the character encoding, and no line breaking is performed. The resulting text is already wrapped with the encoded word markers, starting with =?UTF-8?B? and ending with ?=.

Parameters:
content - the text to encode
Returns:
the text converted into an encoded word using the B encoding


Copyright © 2004-2011 XWiki. All Rights Reserved.