Class EscapeXML

java.lang.Object
org.apache.taglibs.standard.util.EscapeXML

public class EscapeXML extends Object
Handles escaping of characters that could be interpreted as XML markup.

The specification for <c:out> defines the following character conversions to be applied:

CharacterCharacter Entity Code
<&lt;
>&gt;
&&amp;
'&#039;
"&#034;
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    emit(char[] buffer, int from, int count, JspWriter out)
    Emit escaped content into the specified JSPWriter.
    static void
    emit(Reader src, boolean escapeXml, JspWriter out)
    Copy the content of a Reader into the specified JSPWriter escaping characters if needed.
    static void
    emit(Object src, boolean escapeXml, JspWriter out)
    Emit the supplied object to the specified writer, escaping characters if needed.
    static void
    emit(String src, boolean escapeXml, JspWriter out)
    Emit the supplied String to the specified writer, escaping characters if needed.
    static void
    emit(String src, JspWriter out)
    Emit escaped content into the specified JSPWriter.
    static String
    Escape a string.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EscapeXML

      public EscapeXML()
  • Method Details

    • escape

      public static String escape(String src)
      Escape a string.
      Parameters:
      src - the string to escape; must not be null
      Returns:
      the escaped string
    • emit

      public static void emit(Object src, boolean escapeXml, JspWriter out) throws IOException
      Emit the supplied object to the specified writer, escaping characters if needed.
      Parameters:
      src - the object to write
      escapeXml - if true, escape unsafe characters before writing
      out - the JspWriter to emit to
      Throws:
      IOException - if there was a problem emitting the content
    • emit

      public static void emit(String src, boolean escapeXml, JspWriter out) throws IOException
      Emit the supplied String to the specified writer, escaping characters if needed.
      Parameters:
      src - the String to write
      escapeXml - if true, escape unsafe characters before writing
      out - the JspWriter to emit to
      Throws:
      IOException - if there was a problem emitting the content
    • emit

      public static void emit(String src, JspWriter out) throws IOException
      Emit escaped content into the specified JSPWriter.
      Parameters:
      src - the string to escape; must not be null
      out - the JspWriter to emit to
      Throws:
      IOException - if there was a problem emitting the content
    • emit

      public static void emit(Reader src, boolean escapeXml, JspWriter out) throws IOException
      Copy the content of a Reader into the specified JSPWriter escaping characters if needed.
      Parameters:
      src - the Reader to read from
      escapeXml - if true, escape characters
      out - the JspWriter to emit to
      Throws:
      IOException - if there was a problem emitting the content
    • emit

      public static void emit(char[] buffer, int from, int count, JspWriter out) throws IOException
      Emit escaped content into the specified JSPWriter.
      Parameters:
      buffer - characters to escape
      from - start position in the buffer
      count - number of characters to emit
      out - the JspWriter to emit to
      Throws:
      IOException - if there was a problem emitting the content