Class DelimeterInserter

java.lang.Object
com.atlassian.jira.util.DelimeterInserter

public class DelimeterInserter extends Object
This can take an input string and look into it for occurences of given terms. It will then intert delimeters into the input string arround the terms. You can use this to hilight text with bold tags in HTML for example.

This is smart enough to merge areas when they overlap or exit side by side, and only one set of delimeters will be inserted.

  • Constructor Details

    • DelimeterInserter

      public DelimeterInserter(String frontDelimeter, String endDelimeter)
      Creates a DelimeterInserter that is in prefix mode and case insenstive.
      Parameters:
      frontDelimeter - the delimeter to use as around the front of a term
      endDelimeter - the delimeter to use as around the end of a term
    • DelimeterInserter

      public DelimeterInserter(String frontDelimeter, String endDelimeter, boolean prefixMode)
      Creates a DelimeterInserter that is case insenstive.
      Parameters:
      frontDelimeter - the delimeter to use as around the front of a term
      endDelimeter - the delimeter to use as around the end of a term
      prefixMode - whether a match must be made on word boundaries
    • DelimeterInserter

      public DelimeterInserter(String frontDelimeter, String endDelimeter, boolean prefixMode, boolean caseInsensitive)
      Parameters:
      frontDelimeter - the delimeter to use as around the front of a term
      endDelimeter - the delimeter to use as around the end of a term
      prefixMode - whether a match must be made on word boundaries
      caseInsensitive - whether matching is case insenstive
  • Method Details

    • getConsideredWhitespace

      public String getConsideredWhitespace()
      Returns:
      the String characters that can be considered whitespace ALONG with Character.iswhiteSpace().
    • setConsideredWhitespace

      public void setConsideredWhitespace(String consideredWhitespace)
      The String characters that can be considered whitespace ALONG with Character.iswhiteSpace().
      Parameters:
      consideredWhitespace - the extra whitespace characters
    • insert

      public String insert(String targetString, String[] terms)
      Called to do the actual delimeter intertion
      Parameters:
      targetString - the target string to insert the delimeters into
      terms - the terms to look for in the targetString
      Returns:
      a string with delimeters around any terms within it
    • builder

      public static DelimeterInserter.Builder builder()