Class JsUtils
java.lang.Object
com.onenetwork.platform.tools.util.JsUtils
public abstract class JsUtils
extends java.lang.Object
TODO complete the class documentation
-
Constructor Summary
Constructors Modifier Constructor Description protected
JsUtils()
-
Method Summary
Modifier and Type Method Description static java.lang.String
createJSArrayInitializer(java.util.List<?> list, char quote)
Creates string of comma-separated quoted elements of the list for use as initializer for JS array.static void
escapeNonAlphaNumericCharacter(char c, java.util.function.Consumer<java.lang.Character> consumer)
static void
escapeSepcialCharacterDecoder(java.lang.String strToDecode, java.util.function.Consumer<java.lang.Character> consumer)
Decode except for alpha-numeric characters,char
were encode with prefixand suffix
;
i.e.static void
escapeSepcialCharacterEncoder(java.lang.String strToEscape, java.util.function.Consumer<java.lang.Character> consumer)
Encode all character, except for alpha-numeric characters,char
were encode with prefixand suffix
;
i.e.static java.lang.String
escapeString(java.lang.String string)
Escapes the supplied string so that it may be used within a javascript String literal.static void
escapeString(java.lang.String string, java.util.function.Consumer<java.lang.Character> consumer)
Escapes the supplied string so that it may be used within a javascript String literal.static void
quote(java.lang.String string, char quote, java.util.function.Consumer<java.lang.Character> consumer)
static java.lang.String
unescapeString(java.lang.String string)
Unescape stringstatic void
unescapeString(java.lang.String string, java.util.function.Consumer<java.lang.Character> consumer)
Unescape string
-
Constructor Details
-
JsUtils
protected JsUtils()
-
-
Method Details
-
escapeString
public static java.lang.String escapeString(java.lang.String string)Escapes the supplied string so that it may be used within a javascript String literal. Because this method uses hex escape chars, the resulting string can be nested safely in a single or double quoted literal.- Parameters:
string
- string to be escaped- Returns:
- escaped string
-
escapeString
public static void escapeString(java.lang.String string, java.util.function.Consumer<java.lang.Character> consumer)Escapes the supplied string so that it may be used within a javascript String literal. Because this method uses hex escape chars, the resulting string can be nested safely in a single or double quoted literal.- Parameters:
string
- string to be escapedconsumer
-
-
unescapeString
public static java.lang.String unescapeString(java.lang.String string)Unescape string- Parameters:
string
-- Returns:
-
unescapeString
public static void unescapeString(java.lang.String string, java.util.function.Consumer<java.lang.Character> consumer)Unescape string- Parameters:
string
-consumer
-
-
createJSArrayInitializer
public static java.lang.String createJSArrayInitializer(java.util.List<?> list, char quote)Creates string of comma-separated quoted elements of the list for use as initializer for JS array. toString is used to convert objects to strings Elements are escaped using escapeString.- Parameters:
list
- list to bequote
- either ' or "- Returns:
- escaped string
-
escapeNonAlphaNumericCharacter
public static void escapeNonAlphaNumericCharacter(char c, java.util.function.Consumer<java.lang.Character> consumer) -
quote
public static void quote(java.lang.String string, char quote, java.util.function.Consumer<java.lang.Character> consumer) -
escapeSepcialCharacterEncoder
public static void escapeSepcialCharacterEncoder(java.lang.String strToEscape, java.util.function.Consumer<java.lang.Character> consumer)Encode all character, except for alpha-numeric characters,char
were encode with prefixand suffix
;
i.e.
input:test&string
output:test&string
-
escapeSepcialCharacterDecoder
public static void escapeSepcialCharacterDecoder(java.lang.String strToDecode, java.util.function.Consumer<java.lang.Character> consumer)Decode except for alpha-numeric characters,char
were encode with prefixand suffix
;
i.e.
input:test&string
output:test&string
-