Class EscapeXML


  • public class EscapeXML
    extends java.lang.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
      EscapeXML()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      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​(java.io.Reader src, boolean escapeXml, JspWriter out)
      Copy the content of a Reader into the specified JSPWriter escaping characters if needed.
      static void emit​(java.lang.Object src, boolean escapeXml, JspWriter out)
      Emit the supplied object to the specified writer, escaping characters if needed.
      static void emit​(java.lang.String src, boolean escapeXml, JspWriter out)
      Emit the supplied String to the specified writer, escaping characters if needed.
      static void emit​(java.lang.String src, JspWriter out)
      Emit escaped content into the specified JSPWriter.
      static java.lang.String escape​(java.lang.String src)
      Escape a string.
      • Methods inherited from class java.lang.Object

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

      • EscapeXML

        public EscapeXML()
    • Method Detail

      • escape

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

        public static void emit​(java.lang.Object src,
                                boolean escapeXml,
                                JspWriter out)
                         throws java.io.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:
        java.io.IOException - if there was a problem emitting the content
      • emit

        public static void emit​(java.lang.String src,
                                boolean escapeXml,
                                JspWriter out)
                         throws java.io.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:
        java.io.IOException - if there was a problem emitting the content
      • emit

        public static void emit​(java.lang.String src,
                                JspWriter out)
                         throws java.io.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:
        java.io.IOException - if there was a problem emitting the content
      • emit

        public static void emit​(java.io.Reader src,
                                boolean escapeXml,
                                JspWriter out)
                         throws java.io.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:
        java.io.IOException - if there was a problem emitting the content
      • emit

        public static void emit​(char[] buffer,
                                int from,
                                int count,
                                JspWriter out)
                         throws java.io.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:
        java.io.IOException - if there was a problem emitting the content