public final class Args extends Object
RawFunction
instances.Modifier and Type | Method and Description |
---|---|
static String |
clean(String originalArgs)
Removes newlines and repeating whitespace from arguments.
|
static String |
extract(String raw)
Extracts the args inside of a function literal.
|
static List<String> |
get(String raw)
Gets the list of comma-separated arguments in the given string.
|
static Iterable<String> |
iterate(String raw)
Gets the list of comma-separated arguments in the given string.
|
static String |
trimDoubleQuotes(String raw)
Strips matching double quotes from the given string.
|
static String |
trimParens(String raw)
Removes the opening and closing parens, only if the first character is a '(' and last character is a ')' (whitespace is
trimmed before doing this check).
|
static String |
trimQuotesSimple(String raw)
Strips matching, encasing quotes (" or ') from the given string.
|
public static List<String> get(String raw)
This will handle if the given string is encased in parenthesis, e.g., (arg1, arg2)
. This does not distinguish
between commas inside of quotes or handle escaped commas.
For example given the following:
(arg1, arg2)
This will return:
List[arg1, arg2]
If only iterating over the args, use iterate(String)
instead.
raw
- Get the args from this string.public static Iterable<String> iterate(String raw)
This will handle if the given string is encased in parenthesis, e.g., (arg1, arg2)
. This does not distinguish
between commas inside of quotes or handle escaped commas.
raw
- Get the args from this string.public static String trimParens(String raw)
For example given the following:
(arg1, arg2 )
This will return:
"arg1, arg2"
raw
- Trim opening and closing parens from this string.public static String extract(String raw)
For example given the following:
customFunction(arg1, arg2)
This will return:
"arg1, arg2"
raw
- Extract the args from this function literal.IndexOutOfBoundsException
- If encasing parenthesis are not present in the given string.public static String trimQuotesSimple(String raw)
Note that this does not support quote escaping, and it will only strip the quotes if the opening quote is not closed before the end of the string. For example, these will be trimmed:
"abc def" 'abc def'
however this will not:
"abc" + 123 + "abc"
raw
- Trim the quotes around this string.public static String trimDoubleQuotes(String raw)
Note that this does not support quote escaping, and it will only strip the quotes if the opening quote is not closed before the end of the string. For example, this will be trimmed:
"abc def"
however this will not:
"abc" + 123 + "abc"
raw
- Trim the quotes around this string.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.