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 Summary
Constructors Constructor Description HTMLEncoder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
encode(char[] string, int offset, int length, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp, boolean encodeNonLatin, Writer writer)
Encodes the given string, so that it can be used within a html page.static void
encode(char[] string, int offset, int length, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp, Writer writer)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp and encodeNonLatin are truestatic void
encode(char[] string, int offset, int length, boolean encodeNewline, Writer writer)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp is true.static void
encode(char[] string, int offset, int length, Writer writer)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNewline is false and encodeNbsp is true.static String
encode(FacesContext context, String string)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNewline is false and encodeNbsp is true.static String
encode(FacesContext context, String string, boolean encodeNewline)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp is true.static String
encode(FacesContext context, String string, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp and encodeNonLatin are truestatic 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.static void
encode(Writer writer, String string)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNewline is false and encodeNbsp is true.static void
encode(Writer writer, String string, boolean encodeNewline)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp is true.static void
encode(Writer writer, String string, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp and encodeNonLatin are truestatic void
encode(Writer writer, String string, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp, boolean encodeNonLatin)
Encodes and writes the given string, so that it can be used within a html page.static String
encodeURIAttribute(FacesContext context, String string, String characterEncoding)
Encode an URI, escaping or percent-encoding all required characters and following the rules mentioned on RFC 3986.static void
encodeURIAttribute(Writer writer, String string, String characterEncoding)
Encode an URI, escaping or percent-encoding all required characters and following the rules mentioned on RFC 3986.
-
-
-
Method Detail
-
encode
public static String encode(FacesContext context, String string)
Variant ofencode(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)
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp is true.- Parameters:
context
-string
- the string to convertencodeNewline
- 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 ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp and encodeNonLatin are true- Parameters:
context
-string
- the string to convertencodeNewline
- if true newline characters are converted to <br>'sencodeSubsequentBlanksToNbsp
- if true subsequent blanks are converted to '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 convertencodeNewline
- if true newline characters are converted to <br>'sencodeSubsequentBlanksToNbsp
- if true subsequent blanks are converted to 'sencodeNonLatin
- 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 ofencode(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
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp is true.- Parameters:
writer
-string
-encodeNewline
-- Throws:
IOException
-
encode
public static void encode(Writer writer, String string, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp) throws IOException
Variant ofencode(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 ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNewline is false and encodeNbsp is true.- Parameters:
string
- the string to convertoffset
-length
-writer
-- Throws:
IOException
-
encode
public static void encode(char[] string, int offset, int length, boolean encodeNewline, Writer writer) throws IOException
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp is true.- Parameters:
string
- the string to convertoffset
-length
-encodeNewline
- if true newline characters are converted to <br>'swriter
-- Throws:
IOException
-
encode
public static void encode(char[] string, int offset, int length, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp, Writer writer) throws IOException
Variant ofencode(jakarta.faces.context.FacesContext, java.lang.String)
where encodeNbsp and encodeNonLatin are true- Parameters:
string
- the string to convertoffset
-length
-encodeNewline
- if true newline characters are converted to <br>'sencodeSubsequentBlanksToNbsp
- if true subsequent blanks are converted to 'swriter
-- 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 convertoffset
-length
-encodeNewline
- if true newline characters are converted to <br>'sencodeSubsequentBlanksToNbsp
- if true subsequent blanks are converted to 'sencodeNonLatin
- if true encode non-latin characters as numeric character referenceswriter
-- 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
-
-