Package com.smeup.kokos.sdk.util
Class RegexManager
java.lang.Object
com.smeup.kokos.sdk.util.RegexManager
- Author:
- mattia.bonardi
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractCDataValue(String expression) Parse CDATA[value] expressionstatic StringfindAppMatch(Map<String, App> appsMap, String appKey) static StringgenerateRandomString(int stringLength) Generate random string given the lengthstatic String[]getObjectizedColumn(String columnObj) Checks whether a string is an objectified description: the object of this column has the pipe format "xxxxx|[yyyyy]", where: - xxxxx is a generic label or description, - yyyyy is the mother column.static StringgetValueOfSpecificKeyValueBetweenBrackets(String expression, String key) Parse single key(value) expression NB.static StringgetValueOfSpecificKeyValueBetweenBracketsRecursive(String expression, List<String> keys) Parses a string to recursively extract a value associated with a sequence of keys, where each key(value) pair is enclosed in brackets.Extract values between [ and ]parseKeyValueBetweenBrackets(String expression) Parse key(value) expression NB.parseKeyValueBetweenBrackets(String expression, Language language) Parse key(value) expression NB.parseKeyValueBetweenQuotes(String input) Parse key="value" expressionparseProperties(String properties) Parse properties expression key=value;key2=value2parseQueryParamsExpression(String expression) Parse query params expression (a=binvalid input: '&c'=d)static Map<String, SmeupVariable> parseSmeupVariableExpression(String expression) Parse Smeup Variable expression: invalid input: '&xx'.yyparseTPKList(String expression) Parse type parameter code list T() P() K();T() P() K();T() P() K()...parseVariableExpression(String expression) Parse variable expression: ${[VARIABLE_NAME]}parseVariableExpressionWithDefault(String expression) Parse variable expression with default: ${[VARIABLE_NAME]:=[DEFAULT_VALUE]}
-
Field Details
-
HexStringExpression
- See Also:
-
clientVariableExpression
- See Also:
-
invalidXmlCharacters
- See Also:
-
-
Constructor Details
-
RegexManager
public RegexManager()
-
-
Method Details
-
parseKeyValueBetweenBrackets
Parse key(value) expression NB. Nested brackets must be even This version does NOT throw exceptions - returns empty map on error (for backward compatibility)- Parameters:
expression- expression- Returns:
- key value map (empty if parsing fails)
-
parseKeyValueBetweenBrackets
Parse key(value) expression NB. Nested brackets must be even- Parameters:
expression- expressionlanguage- language for error message localization (can be null)- Returns:
- key value map
- Throws:
LocalizableException- if brackets are unbalanced (with localized message)
-
getValueOfSpecificKeyValueBetweenBrackets
Parse single key(value) expression NB. Nested brackets must be even- Parameters:
expression- string to parse to extract value from specific keykey- the 'key' from the key(value) pair involved.- Returns:
- the 'value' of the key(value) pair involved, null if the key is missing or the brackets are left-unbalanced
-
getValueOfSpecificKeyValueBetweenBracketsRecursive
public static String getValueOfSpecificKeyValueBetweenBracketsRecursive(String expression, List<String> keys) Parses a string to recursively extract a value associated with a sequence of keys, where each key(value) pair is enclosed in brackets. This method appliesgetValueOfSpecificKeyValueBetweenBrackets(String, String)iteratively for each key in the provided list. The value extracted for one key becomes the input string for extracting the value of the next key in the list.For example, if the expression is "outer(inner(value))" and the keys are ["outer", "inner"], the method will first extract "inner(value)" for the key "outer", and then extract "value" from "inner(value)" for the key "inner".
- Parameters:
expression- The string to parse, containing key(value) expressions.keys- A list of keys to sequentially search for and extract values. The order of the keys in the list determines the order of extraction.- Returns:
- The 'value' associated with the last key in the list, nested within the preceding keys' values. Returns null if any of the keys are not found in their respective expressions, or if the brackets are left-unbalanced at any stage.
-
extractCDataValue
Parse CDATA[value] expression- Parameters:
expression- expression- Returns:
- null expression not match with CDATA
-
parseKeyValueBetweenQuotes
Parse key="value" expression- Parameters:
input- string- Returns:
- key value
-
parseTPKList
Parse type parameter code list T() P() K();T() P() K();T() P() K()...- Parameters:
expression- expression- Returns:
- key value map
-
parseVariableExpression
Parse variable expression: ${[VARIABLE_NAME]}- Parameters:
expression- expression- Returns:
- key value map
-
parseVariableExpressionWithDefault
Parse variable expression with default: ${[VARIABLE_NAME]:=[DEFAULT_VALUE]}- Parameters:
expression- expression- Returns:
- key value map
-
parseSmeupVariableExpression
Parse Smeup Variable expression: invalid input: '&xx'.yy- Parameters:
expression- expression- Returns:
- key value map
-
parseExpressionBetweenSquareBrackets
Extract values between [ and ]- Parameters:
input- expression- Returns:
- map
-
generateRandomString
Generate random string given the length- Parameters:
stringLength- length- Returns:
- string
-
findAppMatch
-
parseProperties
Parse properties expression key=value;key2=value2- Parameters:
properties- properties string- Returns:
- key value map
-
parseQueryParamsExpression
Parse query params expression (a=binvalid input: '&c'=d)- Parameters:
expression- string- Returns:
- map
-
getObjectizedColumn
Checks whether a string is an objectified description: the object of this column has the pipe format "xxxxx|[yyyyy]", where: - xxxxx is a generic label or description, - yyyyy is the mother column. If the format is valid, returns an array with the two split elements {xxxxx, yyyyy}; otherwise, returns original string and null.- Parameters:
columnObj- The string to analyze.- Returns:
- An array of two strings: {xxxxx, yyyyy} if is a valid pipe; otherwise {columnObj, null}.
-