Package com.atlassian.jira.util
Class DelimeterInserter
java.lang.Object
com.atlassian.jira.util.DelimeterInserter
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDelimeterInserter(String frontDelimeter, String endDelimeter) Creates a DelimeterInserter that is in prefix mode and case insenstive.DelimeterInserter(String frontDelimeter, String endDelimeter, boolean prefixMode) Creates a DelimeterInserter that is case insenstive.DelimeterInserter(String frontDelimeter, String endDelimeter, boolean prefixMode, boolean caseInsensitive) -
Method Summary
Modifier and TypeMethodDescriptionstatic DelimeterInserter.Builderbuilder()Called to do the actual delimeter intertionvoidsetConsideredWhitespace(String consideredWhitespace) The String characters that can be considered whitespace ALONG with Character.iswhiteSpace().
-
Constructor Details
-
DelimeterInserter
Creates a DelimeterInserter that is in prefix mode and case insenstive.- Parameters:
frontDelimeter- the delimeter to use as around the front of a termendDelimeter- the delimeter to use as around the end of a term
-
DelimeterInserter
Creates a DelimeterInserter that is case insenstive.- Parameters:
frontDelimeter- the delimeter to use as around the front of a termendDelimeter- the delimeter to use as around the end of a termprefixMode- 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 termendDelimeter- the delimeter to use as around the end of a termprefixMode- whether a match must be made on word boundariescaseInsensitive- whether matching is case insenstive
-
-
Method Details
-
getConsideredWhitespace
- Returns:
- the String characters that can be considered whitespace ALONG with Character.iswhiteSpace().
-
setConsideredWhitespace
The String characters that can be considered whitespace ALONG with Character.iswhiteSpace().- Parameters:
consideredWhitespace- the extra whitespace characters
-
insert
Called to do the actual delimeter intertion- Parameters:
targetString- the target string to insert the delimeters intoterms- the terms to look for in the targetString- Returns:
- a string with delimeters around any terms within it
-
builder
-