Package com.tangosol.config.expression
Class ValueMacroExpression.OffsetLengthSubstringExpansionProcessor
- java.lang.Object
-
- com.tangosol.config.expression.ValueMacroExpression.MacroExpansionProcessor
-
- com.tangosol.config.expression.ValueMacroExpression.OffsetLengthSubstringExpansionProcessor
-
- Enclosing class:
- ValueMacroExpression
protected static class ValueMacroExpression.OffsetLengthSubstringExpansionProcessor extends ValueMacroExpression.MacroExpansionProcessor
Process:offset
and:length
substring expansion.
- See Also:
process(String, ParameterResolver, int)
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OffsetLengthSubstringExpansionProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canProcess(String sMacro)
Return true iffsMacro
contains the delimiter that this processor handles.String
getDelimiter()
Return delimiter being used by the processor.String
process(String sMacro, ParameterResolver resolver, int cDepth)
Perform substring expansion onsMacro
.-
Methods inherited from class com.tangosol.config.expression.ValueMacroExpression.MacroExpansionProcessor
validateMacroExpansion
-
-
-
-
Method Detail
-
getDelimiter
public String getDelimiter()
Description copied from class:ValueMacroExpression.MacroExpansionProcessor
Return delimiter being used by the processor.- Overrides:
getDelimiter
in classValueMacroExpression.MacroExpansionProcessor
- Returns:
- delimiter used by the processor or empty string if processor does not have a delimiter
-
canProcess
public boolean canProcess(String sMacro)
Description copied from class:ValueMacroExpression.MacroExpansionProcessor
Return true iffsMacro
contains the delimiter that this processor handles.- Overrides:
canProcess
in classValueMacroExpression.MacroExpansionProcessor
- Parameters:
sMacro
- the macro parameter- Returns:
- true iff this processor can process
sMacro
-
process
public String process(String sMacro, ParameterResolver resolver, int cDepth)
Perform substring expansion onsMacro
.${macro-parameter:offset} ${macro-parameter:offset:length} Note that length and offset are integer values.
Substring expansion expands to up to length characters of the value of macro-parameter starting at the character specified by offset.
If length is omitted, it expands to the substring of the value of macro-parameter starting at the character specified by offset and extending to the end of the value.
If offset evaluates to a number less than zero, the value is used as an offset in characters from the end of the value of macro-parameter.
If length evaluates to a number less than zero, it is interpreted as an offset in characters from the end of the value of macro-parameter. rather than a number of characters, and the expansion is the characters between offset and that result.Note that a negative offset or length must be separated from the colon by at least one space to avoid being confused with the macro parameter default delimiter :-.
Examples illustrating substring expansion of a parameter:
Given property parameter of string value 01234567890abcdefgh. ${parameter:7} evaluates to 7890abcdefgh ${parameter:7:0} evaluates to empty string ${parameter:7:2} evaluates to 78 ${parameter:7: -2} evaluates to 7890abcdef ${parameter: -7} evaluates to bcdefgh ${parameter: -7:0} evaluates to empty string ${parameter: -7:2} evaluates to bc ${parameter: -7: -2} evaluates to bcdef
- Overrides:
process
in classValueMacroExpression.MacroExpansionProcessor
- Parameters:
sMacro
- a string starting withprefix
and ending withsuffix
resolver
- macro parameter resolvercDepth
- count of current macro parameter expansions- Returns:
- the substring expanded value or the original parameter macro if it does not contain substring expansion
-
-