Class ValueMacroExpression.OffsetLengthSubstringExpansionProcessor

    • Constructor Detail

      • OffsetLengthSubstringExpansionProcessor

        protected OffsetLengthSubstringExpansionProcessor()
    • Method Detail

      • process

        public String process​(String sMacro,
                              ParameterResolver resolver,
                              int cDepth)
        Perform substring expansion on sMacro.
         ${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 class ValueMacroExpression.MacroExpansionProcessor
        Parameters:
        sMacro - a string starting with prefix and ending with suffix
        resolver - macro parameter resolver
        cDepth - count of current macro parameter expansions
        Returns:
        the substring expanded value or the original parameter macro if it does not contain substring expansion