Class HTMLEncoder


  • public abstract class HTMLEncoder
    extends Object
    Converts Strings so that they can be used within HTML-Code.
    • Constructor Detail

      • HTMLEncoder

        public HTMLEncoder()
    • Method Detail

      • encode

        public static String encode​(FacesContext context,
                                    String string,
                                    boolean encodeNewline,
                                    boolean encodeSubsequentBlanksToNbsp)
        Variant of encode(jakarta.faces.context.FacesContext, java.lang.String) where encodeNbsp and encodeNonLatin are true
        Parameters:
        context -
        string - the string to convert
        encodeNewline - if true newline characters are converted to <br>'s
        encodeSubsequentBlanksToNbsp - if true subsequent blanks are converted to &nbsp;'s
        Returns:
        the encoded string
      • encode

        public static String encode​(FacesContext context,
                                    String string,
                                    boolean encodeNewline,
                                    boolean encodeSubsequentBlanksToNbsp,
                                    boolean encodeNonLatin)
        Encodes the given string, so that it can be used within a html page.
        Parameters:
        context -
        string - the string to convert
        encodeNewline - if true newline characters are converted to <br>'s
        encodeSubsequentBlanksToNbsp - if true subsequent blanks are converted to &nbsp;'s
        encodeNonLatin - if true encode non-latin characters as numeric character references
        Returns:
        the encoded string
      • encode

        public static void encode​(Writer writer,
                                  String string,
                                  boolean encodeNewline,
                                  boolean encodeSubsequentBlanksToNbsp,
                                  boolean encodeNonLatin)
                           throws IOException
        Encodes and writes the given string, so that it can be used within a html page.
        Parameters:
        writer -
        string -
        encodeNewline -
        encodeSubsequentBlanksToNbsp -
        encodeNonLatin -
        Throws:
        IOException
      • encode

        public static void encode​(char[] string,
                                  int offset,
                                  int length,
                                  boolean encodeNewline,
                                  boolean encodeSubsequentBlanksToNbsp,
                                  Writer writer)
                           throws IOException
        Variant of encode(jakarta.faces.context.FacesContext, java.lang.String) where encodeNbsp and encodeNonLatin are true
        Parameters:
        string - the string to convert
        offset -
        length -
        encodeNewline - if true newline characters are converted to <br>'s
        encodeSubsequentBlanksToNbsp - if true subsequent blanks are converted to &nbsp;'s
        writer -
        Throws:
        IOException
      • encode

        public static void encode​(char[] string,
                                  int offset,
                                  int length,
                                  boolean encodeNewline,
                                  boolean encodeSubsequentBlanksToNbsp,
                                  boolean encodeNonLatin,
                                  Writer writer)
                           throws IOException
        Encodes the given string, so that it can be used within a html page.
        Parameters:
        string - the string to convert
        offset -
        length -
        encodeNewline - if true newline characters are converted to <br>'s
        encodeSubsequentBlanksToNbsp - if true subsequent blanks are converted to &nbsp;'s
        encodeNonLatin - if true encode non-latin characters as numeric character references
        writer -
        Throws:
        IOException
      • encodeURIAttribute

        public static String encodeURIAttribute​(FacesContext context,
                                                String string,
                                                String characterEncoding)
                                         throws IOException
        Encode an URI, escaping or percent-encoding all required characters and following the rules mentioned on RFC 3986.
        Parameters:
        context -
        string -
        characterEncoding -
        Returns:
        Throws:
        IOException
      • encodeURIAttribute

        public static void encodeURIAttribute​(Writer writer,
                                              String string,
                                              String characterEncoding)
                                       throws IOException
        Encode an URI, escaping or percent-encoding all required characters and following the rules mentioned on RFC 3986.
        Parameters:
        writer -
        string -
        characterEncoding -
        Throws:
        IOException