org.owasp.encoder
Class Encoders

java.lang.Object
  extended by org.owasp.encoder.Encoders

public final class Encoders
extends Object

Encoders -- Public factory method for obtaining instances of Encoders. Classes implementing the encoders are not directly exposed as part of the API since encoding strategies are subject to change. In many cases encoders will share the same implementation, but have different internal flags for how to handle varied content. For example the XML_CONTENT and XML_ATTRIBUTE contexts may currently share the same class with each instances having a different set of flags. Future version may optimize them into different classes.

All encoders returned by the factory are thread-safe.

Author:
Jeff Ichnowski

Field Summary
static String CDATA
          Name of CDATA context.
static String CSS_STRING
          Name of CSS string context.
static String CSS_URL
          Name of CSS URL context.
static String HTML
          Name of HTML general context.
static String HTML_ATTRIBUTE
          Name of HTML attribute context.
static String HTML_CONTENT
          Name of HTML content context.
static String HTML_UNQUOTED_ATTRIBUTE
          Name of unquoted HTML attribute context.
static String JAVA
          Name of Java String context.
static String JAVASCRIPT
          Name of JavaScript general context.
static String JAVASCRIPT_ATTRIBUTE
          Name of JavaScript attribute context.
static String JAVASCRIPT_BLOCK
          Name of JavaScript block context.
static String JAVASCRIPT_SOURCE
          Name of JavaScript source context.
static String URI
          Name of URI context.
static String URI_COMPONENT
          Name of URI component context.
static String XML
          Name of XML general context.
static String XML_ATTRIBUTE
          Name of XML attribute context.
static String XML_COMMENT
          Name of XML comment context.
static String XML_CONTENT
          Name of XML content context.
 
Method Summary
static Encoder forName(String contextName)
          Returns a new instance of an Encoder for the specified context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTML

public static final String HTML
Name of HTML general context.

See Also:
Constant Field Values

HTML_CONTENT

public static final String HTML_CONTENT
Name of HTML content context.

See Also:
Constant Field Values

HTML_ATTRIBUTE

public static final String HTML_ATTRIBUTE
Name of HTML attribute context.

See Also:
Constant Field Values

HTML_UNQUOTED_ATTRIBUTE

public static final String HTML_UNQUOTED_ATTRIBUTE
Name of unquoted HTML attribute context.

See Also:
Constant Field Values

XML

public static final String XML
Name of XML general context.

See Also:
Constant Field Values

XML_CONTENT

public static final String XML_CONTENT
Name of XML content context.

See Also:
Constant Field Values

XML_ATTRIBUTE

public static final String XML_ATTRIBUTE
Name of XML attribute context.

See Also:
Constant Field Values

XML_COMMENT

public static final String XML_COMMENT
Name of XML comment context.

See Also:
Constant Field Values

CDATA

public static final String CDATA
Name of CDATA context.

See Also:
Constant Field Values

CSS_STRING

public static final String CSS_STRING
Name of CSS string context.

See Also:
Constant Field Values

CSS_URL

public static final String CSS_URL
Name of CSS URL context.

See Also:
Constant Field Values

JAVA

public static final String JAVA
Name of Java String context.

See Also:
Constant Field Values

JAVASCRIPT

public static final String JAVASCRIPT
Name of JavaScript general context.

See Also:
Constant Field Values

JAVASCRIPT_ATTRIBUTE

public static final String JAVASCRIPT_ATTRIBUTE
Name of JavaScript attribute context.

See Also:
Constant Field Values

JAVASCRIPT_BLOCK

public static final String JAVASCRIPT_BLOCK
Name of JavaScript block context.

See Also:
Constant Field Values

JAVASCRIPT_SOURCE

public static final String JAVASCRIPT_SOURCE
Name of JavaScript source context.

See Also:
Constant Field Values

URI

public static final String URI
Name of URI context.

See Also:
Constant Field Values

URI_COMPONENT

public static final String URI_COMPONENT
Name of URI component context.

See Also:
Constant Field Values
Method Detail

forName

public static Encoder forName(String contextName)
                       throws NullPointerException,
                              UnsupportedContextException
Returns a new instance of an Encoder for the specified context. The returned instance is thread-safe.

Parameters:
contextName - the context name (one of the String constants defined in this class)
Returns:
an encoder for the specified context.
Throws:
NullPointerException - if contextName is null
UnsupportedContextException - if contextName is not recognized.


Copyright © 2011-2013 OWASP (Open Web-Application Security Project). All Rights Reserved.