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:
  • Constructor Details

    • OffsetLengthSubstringExpansionProcessor

      protected OffsetLengthSubstringExpansionProcessor()
  • Method Details

    • getDelimiter

      public String getDelimiter()
      Description copied from class: ValueMacroExpression.MacroExpansionProcessor
      Return delimiter being used by the processor.
      Overrides:
      getDelimiter in class ValueMacroExpression.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 iff sMacro contains the delimiter that this processor handles.
      Overrides:
      canProcess in class ValueMacroExpression.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 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