Package org.owasp.encoder
Enum XMLEncoder.Mode
- java.lang.Object
-
- java.lang.Enum<XMLEncoder.Mode>
-
- org.owasp.encoder.XMLEncoder.Mode
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<XMLEncoder.Mode>
- Enclosing class:
- XMLEncoder
static enum XMLEncoder.Mode extends java.lang.Enum<XMLEncoder.Mode>
An enum of supported "modes" of operation for the XMLEncoder.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ALL
All significant characters are encoded (& < > ' ").ATTRIBUTE
Characters are encoded for attribute values--either single or double quoted.CONTENT
Characters are encoded for content (a.k.a.DOUBLE_QUOTED_ATTRIBUTE
Characters are encoded for double-quoted attribute values.SINGLE_QUOTED_ATTRIBUTE
Characters are encoded for single-quoted attribute values.
-
Field Summary
Fields Modifier and Type Field Description private long
_validMask
The bit-mask of characters that do not need encoding in this mode.
-
Constructor Summary
Constructors Modifier Constructor Description private
Mode(java.lang.String encodedChars)
Sole constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) long
validMask()
Accessor for_validMask
.static XMLEncoder.Mode
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static XMLEncoder.Mode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
ALL
public static final XMLEncoder.Mode ALL
All significant characters are encoded (& < > ' "). This mode is safe for use in either content or attributes. See note onCONTENT
for explanation of why '>' is encoded.
-
CONTENT
public static final XMLEncoder.Mode CONTENT
Characters are encoded for content (a.k.a. "CharData"). This means & < and >. Note: > only requires encoding if it follows "]]". However for maximum compatibility and to avoid the overhead of looking for "]]", we just always encode '>' to '>'.
-
ATTRIBUTE
public static final XMLEncoder.Mode ATTRIBUTE
Characters are encoded for attribute values--either single or double quoted. This means the characters & < ' and " are encoded. Note: > is NOT encoded, and thus this mode is not suitable for content.
-
SINGLE_QUOTED_ATTRIBUTE
public static final XMLEncoder.Mode SINGLE_QUOTED_ATTRIBUTE
Characters are encoded for single-quoted attribute values. Thus, the same asATTRIBUTE
except ' is not encoded.
-
DOUBLE_QUOTED_ATTRIBUTE
public static final XMLEncoder.Mode DOUBLE_QUOTED_ATTRIBUTE
Characters are encoded for double-quoted attribute values. Thus, the same asATTRIBUTE
except " is not encoded.
-
-
Method Detail
-
values
public static XMLEncoder.Mode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (XMLEncoder.Mode c : XMLEncoder.Mode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static XMLEncoder.Mode valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
validMask
long validMask()
Accessor for_validMask
.- Returns:
_validMask
-
-