com.ibm.tivoli.maximo.util

Class TextReplacement

  • java.lang.Object
    • com.ibm.tivoli.maximo.util.TextReplacement
  • Direct Known Subclasses:
    RecordLimitResolver


    public class TextReplacement
    extends java.lang.Object
    TextReplace is a simple means to replace all occurances of a string, with another string using a regular expression and a TextResolver. The regular expression must contain one group, and the resolver will be passed the value of the group, and it should return the replacement value or null. This differs from a normal String.replaveAll() in that the replacement value, in this case, is dynamic based on the parsed group value. For example if you have a String like, "where field1=:value1 and field2=:value2" with a regex of ":([a-z])", then the TextResolver will be passed 'value1' and 'value2' and be expected to resolve a potentially different value for each.
    • Constructor Detail

      • TextReplacement

        public TextReplacement(java.util.regex.Pattern pat,
                               TextReplacement.TextResolver resolver)
        Creates a TextReplacement for the given regular expression and resolver. The regular expression MUST contain at least one group, ie, something like ":([a-z]+)", which matches on ":VAR" and the grouping would contain "VAR" but not the ":"
        Parameters:
        pat -
        resolver -
    • Method Detail

      • doReplacements

        public java.lang.String doReplacements(java.lang.String in)
        For the given input string, like, 'fielda=${val1} and fieldb=${val2}', do the variable replacements using the regular expression and resolver that was passed in the contructor
        Parameters:
        in -
        Returns:
      • newPrefixDollarTextReplacement

        public static TextReplacement newPrefixDollarTextReplacement(TextReplacement.TextResolver resolver)
        Creates a TextReplacement for ${opt_prefix:VARNAME:opt_posfix} type of variables VARNAME can contain A-Z,0-9,and _ (underscore)
        Parameters:
        resolver -
        Returns:
        TextResolver instance
      • newMustacheTextReplacement

        public static TextReplacement newMustacheTextReplacement(TextReplacement.TextResolver resolver)
        Creates a mustache TextReplacement for {{opt_prefix:VARNAME:opt_posfix}} type of variables VARNAME can contain A-Z,0-9,and _ (underscore)
        Parameters:
        resolver -
        Returns:
        TextResolver instance