Class HTMLEncoder

java.lang.Object
org.apache.myfaces.renderkit.html.util.HTMLEncoder

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

    • HTMLEncoder

      public HTMLEncoder()
  • Method Details

    • encode

      public static String encode(FacesContext context, String string)
      Variant of encode(jakarta.faces.context.FacesContext, java.lang.String) where encodeNewline is false and encodeNbsp is true.
      Parameters:
      context -
      string - the string to convert
      Returns:
      the encoded string
    • encode

      public static String encode(FacesContext context, String string, boolean encodeNewline)
      Parameters:
      context -
      string - the string to convert
      encodeNewline - if true newline characters are converted to <br>'s
      Returns:
      the encoded string
    • 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) throws IOException
      Variant of encode(jakarta.faces.context.FacesContext, java.lang.String) where encodeNewline is false and encodeNbsp is true.
      Parameters:
      writer -
      string -
      Throws:
      IOException
    • encode

      public static void encode(Writer writer, String string, boolean encodeNewline) throws IOException
      Parameters:
      writer -
      string -
      encodeNewline -
      Throws:
      IOException
    • encode

      public static void encode(Writer writer, String string, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp) throws IOException
      Variant of encode(jakarta.faces.context.FacesContext, java.lang.String) where encodeNbsp and encodeNonLatin are true
      Parameters:
      writer -
      string -
      encodeNewline -
      encodeSubsequentBlanksToNbsp -
      Throws:
      IOException
    • 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, Writer writer) throws IOException
      Variant of encode(jakarta.faces.context.FacesContext, java.lang.String) where encodeNewline is false and encodeNbsp is true.
      Parameters:
      string - the string to convert
      offset -
      length -
      writer -
      Throws:
      IOException
    • encode

      public static void encode(char[] string, int offset, int length, boolean encodeNewline, Writer writer) throws IOException
      Parameters:
      string - the string to convert
      offset -
      length -
      encodeNewline - if true newline characters are converted to <br>'s
      writer -
      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