Package org.jolokia.server.core.util
Class EscapeUtil
java.lang.Object
org.jolokia.server.core.util.EscapeUtil
Utility class for handling escaping of strings and paths.
- Since:
- 15.03.11
- Author:
- roland
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcombineToPath(List<String> pParts) Combine a list of strings to a single path with proper escaping.static StringconvertSpecialStringTags(String pValue) For GET requests, where operation arguments and values to write are given in string representation as part of the URL, certain special tags are used to indicate special values:[null]for indicating a null value""for indicating an empty string This method converts these tags to the proper value.static StringEscape the delimiter in an argument with the given escape char.extractElementsFromPath(String pPath) Get the path as a reverse stack with the first element of the path on topParse a string path and return a list of split up parts.reversePath(List<String> pathParts) Reverse path and return as a stack.Split a string on a delimiter, respecting escaping with an escape char.static String[]splitAsArray(String pArg, String pEscape, String pDelimiter) Split but return an array which is never null (but might be empty)
-
Field Details
-
PATH_ESCAPE
Escape character used for path escaping as it can be used in a regexp- See Also:
-
CSV_ESCAPE
Escape character for escaping CSV type string as it can be used in a regexp. E.g. a backslash (\ or "\\") must be doubled (\\ or "\\\\")- See Also:
-
-
Method Details
-
combineToPath
Combine a list of strings to a single path with proper escaping.- Parameters:
pParts- parts to combine- Returns:
- the combined path
-
parsePath
Parse a string path and return a list of split up parts.- Parameters:
pPath- the path to parse. Can be null- Returns:
- list of path elements or null if the initial path is null.
-
extractElementsFromPath
Get the path as a reverse stack with the first element of the path on top- Parameters:
pPath- path to parse- Returns:
- stack of arguments in reverse order or an empty stack if path was null or empty
-
reversePath
Reverse path and return as a stack. First path element is on top of the stack.- Parameters:
pathParts- path to reverse- Returns:
- reversed path or an empty stack if no path parts are given. Never return null.
-
split
Split a string on a delimiter, respecting escaping with an escape char. Assuming that a backslash (\) is used as escape char, then the following replacement rules apply:-
\delimiter for the delimiter as literal -
\\for backslashes -
\(everything else) is the same as (everything else).
- Parameters:
pArg- argument to splitpEscape- escape pattern as it can be used in a regular expression.pDelimiter- delimiter to use- Returns:
- the split string as list or an empty array if the argument was null
-
-
splitAsArray
Split but return an array which is never null (but might be empty)- Parameters:
pArg- argument to splitpEscape- single character used for escapingpDelimiter- delimiter to use- Returns:
- the split string as list or an empty array if the argument was null
-
escape
Escape the delimiter in an argument with the given escape char.- Parameters:
pArg- string to add escapes topEscape- the escape character (e.g. '\')pDelimiter- the delimiter to escape (e.g. ',')- Returns:
- the escaped char
-
convertSpecialStringTags
For GET requests, where operation arguments and values to write are given in string representation as part of the URL, certain special tags are used to indicate special values:[null]for indicating a null value""for indicating an empty string
- Parameters:
pValue- the string value to check for a tag- Returns:
- the converted value or the original one if no tag has been found.
-