java.lang.Object
org.bzdev.net.WebDecoder
Decoder for HTML and Javascript strings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRead an input stream containing application/x-www-form-encoded data, given a default charset (UTF-8) and an ampersand as the separator between keyword-value pairs, and create a keyword-value map, supporting a single value per key.formDecode
(InputStream is, boolean semicolonDelimiter) Read an input stream containing application/x-www-form-encoded data, given a default charset (UTF-8), and create a keyword-value map, supporting a single value per key.formDecode
(InputStream is, boolean semicolonDelimiter, Charset charset) Read an input stream containing application/x-www-form-encoded data, given a charset, and create a keyword-value map, supporting a single value per key.formDecode
(String string) Convert a string containing application/x-www-form-encoded data, given a default charset (UTF-8) and an ampersand as the separator between keyword-value pairs, and create a keyword-value map, supporting a single value per key.formDecode
(String string, boolean semicolonDelimiter) Convert a string containing application/x-www-form-encoded data, given a default charset (UTF-8), and create a keyword-value map, supporting a single value per key.formDecode
(String string, boolean semicolonDelimiter, Charset charset) Convert a string containing application/x-www-form-encoded data, given a charset, and create a keyword-value map, supporting a single value per key.Read an input stream containing application/x-www-form-encoded data, given a default charset (UTF-8) and an ampersand as the separator between keyword-value pairs, and create a keyword-value map, supporting multiple values per key.formDecodeMV
(InputStream is, boolean semicolonDelimiter) Read an input stream containing application/x-www-form-encoded data, given a default charset (UTF-8), and create a keyword-value map, supporting multiple values per key.formDecodeMV
(InputStream is, boolean semicolonDelimiter, Charset charset) Read an input stream containing application/x-www-form-encoded data, given a charset, and create a keyword-value map, supporting multiple values per key.formDecodeMV
(String string) Convert a string containing application/x-www-form-encoded data, given a default charset (UTF-8) and an ampersand as the separator between keyword-value pairs, and create a keyword-value map, supporting a multiple values per key.formDecodeMV
(String string, boolean semicolonDelimiter) Convert a string containing application/x-www-form-encoded data, given a default charset (UTF-8), and create a keyword-value map, supporting a multiple values per key.formDecodeMV
(String string, boolean semicolonDelimiter, Charset charset) Convert a string containing application/x-www-form-encoded data, given a charset, and create a keyword-value map, supporting multiple values per key.static String
htmlDecode
(String string) Decode an HTML-encoded string.static String
quoteDecode
(String string) Decode a string that is encoded so that it can appear within double quotes in a Java or ECMAScript program.
-
Constructor Details
-
WebDecoder
public WebDecoder()
-
-
Method Details
-
htmlDecode
Decode an HTML-encoded string. The entities '&', '"e;', '>' and '<' are replaced with '&', '"', '>' and '<' respectively.- Parameters:
string
- the input string- Returns:
- the decoded string; null if the input string is null
- Throws:
IllegalArgumentException
- there is a syntax error in the argument
-
quoteDecode
Decode a string that is encoded so that it can appear within double quotes in a Java or ECMAScript program. This method replaces escape sequences with their corresponding characters. The argument does not include the delimiting quotes that would appear in Java or ECMA code.- Parameters:
string
- the string to decode- Returns:
- the decoded string.
- Throws:
IllegalArgumentException
- there is a syntax error in the argument
-
formDecode
Convert a string containing application/x-www-form-encoded data, given a default charset (UTF-8) and an ampersand as the separator between keyword-value pairs, and create a keyword-value map, supporting a single value per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
string
- a String containing the URL-encoded data- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IllegalArgumentException
-
formDecodeMV
Convert a string containing application/x-www-form-encoded data, given a default charset (UTF-8) and an ampersand as the separator between keyword-value pairs, and create a keyword-value map, supporting a multiple values per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
string
- a String containing the URL-encoded data- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IllegalArgumentException
-
formDecode
public static Map<String,String> formDecode(String string, boolean semicolonDelimiter) throws IllegalArgumentException Convert a string containing application/x-www-form-encoded data, given a default charset (UTF-8), and create a keyword-value map, supporting a single value per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
string
- a String containing the URL-encoded datasemicolonDelimiter
- true if the delimiter should be a semicolon (";") rather than an ampersand ("&").- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IllegalArgumentException
-
formDecodeMV
public static Map<String,String[]> formDecodeMV(String string, boolean semicolonDelimiter) throws IllegalArgumentException Convert a string containing application/x-www-form-encoded data, given a default charset (UTF-8), and create a keyword-value map, supporting a multiple values per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
string
- a String containing the URL-encoded datasemicolonDelimiter
- true if the delimiter should be a semicolon (";") rather than an ampersand ("&").- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IllegalArgumentException
-
formDecode
public static Map<String,String> formDecode(String string, boolean semicolonDelimiter, Charset charset) throws IllegalArgumentException Convert a string containing application/x-www-form-encoded data, given a charset, and create a keyword-value map, supporting a single value per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
string
- a String containing the URL-encoded datasemicolonDelimiter
- true if the delimiter should be a semicolon (";") rather than an ampersand ("&").charset
- the Charset used when the keyword-value pairs was encoded- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IllegalArgumentException
-
formDecodeMV
public static Map<String,String[]> formDecodeMV(String string, boolean semicolonDelimiter, Charset charset) throws IllegalArgumentException Convert a string containing application/x-www-form-encoded data, given a charset, and create a keyword-value map, supporting multiple values per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument, based on the first occurrence of a key.- Parameters:
string
- a String containing the URL-encoded datasemicolonDelimiter
- true if the delimiter should be a semicolon (";") rather than an ampersand ("&").charset
- the Charset used when the keyword-value pairs was encoded- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IllegalArgumentException
-
formDecode
public static Map<String,String> formDecode(InputStream is) throws IllegalArgumentException, IOException Read an input stream containing application/x-www-form-encoded data, given a default charset (UTF-8) and an ampersand as the separator between keyword-value pairs, and create a keyword-value map, supporting a single value per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
is
- the input stream- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IOException
- an IO error occurred, including syntax errors in the input streamIllegalArgumentException
-
formDecodeMV
public static Map<String,String[]> formDecodeMV(InputStream is) throws IllegalArgumentException, IOException Read an input stream containing application/x-www-form-encoded data, given a default charset (UTF-8) and an ampersand as the separator between keyword-value pairs, and create a keyword-value map, supporting multiple values per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
is
- the input stream- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IOException
- an IO error occurred, including syntax errors in the input streamIllegalArgumentException
-
formDecode
public static Map<String,String> formDecode(InputStream is, boolean semicolonDelimiter) throws IllegalArgumentException, IOException Read an input stream containing application/x-www-form-encoded data, given a default charset (UTF-8), and create a keyword-value map, supporting a single value per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
is
- the input streamsemicolonDelimiter
- true if the delimiter should be a semicolon (";") rather than an ampersand ("&").- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IOException
- an IO error occurred, including syntax errors in the input streamIllegalArgumentException
-
formDecodeMV
public static Map<String,String[]> formDecodeMV(InputStream is, boolean semicolonDelimiter) throws IllegalArgumentException, IOException Read an input stream containing application/x-www-form-encoded data, given a default charset (UTF-8), and create a keyword-value map, supporting multiple values per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
is
- the input streamsemicolonDelimiter
- true if the delimiter should be a semicolon (";") rather than an ampersand ("&").- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IOException
- an IO error occurred, including syntax errors in the input streamIllegalArgumentException
-
formDecode
public static Map<String,String> formDecode(InputStream is, boolean semicolonDelimiter, Charset charset) throws IllegalArgumentException, IOException Read an input stream containing application/x-www-form-encoded data, given a charset, and create a keyword-value map, supporting a single value per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
is
- the input streamsemicolonDelimiter
- true if the delimiter should be a semicolon (";") rather than an ampersand ("&").charset
- the Charset used when the keyword-value pairs was encoded- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IOException
- an IO error occurred, including syntax errors in the input streamIllegalArgumentException
-
formDecodeMV
public static Map<String,String[]> formDecodeMV(InputStream is, boolean semicolonDelimiter, Charset charset) throws IllegalArgumentException, IOException Read an input stream containing application/x-www-form-encoded data, given a charset, and create a keyword-value map, supporting multiple values per key. The map's iterator will provide entries in the same order as the keyword-value pairs in the argument.- Parameters:
is
- the input streamsemicolonDelimiter
- true if the delimiter should be a semicolon (";") rather than an ampersand ("&").charset
- the Charset used when the keyword-value pairs was encoded- Returns:
- a the map of keyword-value pairs (both elements are strings)
- Throws:
IOException
- an IO error occurred, including syntax errors in the input streamIllegalArgumentException
-