com.atlassian.jira.util
Class DelimeterInserter

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

public class DelimeterInserter
extends java.lang.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 Summary
DelimeterInserter(java.lang.String frontDelimeter, java.lang.String endDelimeter)
          Creates a DelimeterInserter that is in prefix mode and case insenstive.
DelimeterInserter(java.lang.String frontDelimeter, java.lang.String endDelimeter, boolean prefixMode)
          Creates a DelimeterInserter that is case insenstive.
DelimeterInserter(java.lang.String frontDelimeter, java.lang.String endDelimeter, boolean prefixMode, boolean caseInsensitive)
           
 
Method Summary
 java.lang.String getConsideredWhitespace()
           
 java.lang.String insert(java.lang.String targetString, java.lang.String[] terms)
          Called to do the actual delimeter intertion
 void setConsideredWhitespace(java.lang.String consideredWhitespace)
          The String characters that can be considered whitespace ALONG with Character.iswhiteSpace().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelimeterInserter

public DelimeterInserter(java.lang.String frontDelimeter,
                         java.lang.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(java.lang.String frontDelimeter,
                         java.lang.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(java.lang.String frontDelimeter,
                         java.lang.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 Detail

getConsideredWhitespace

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

setConsideredWhitespace

public void setConsideredWhitespace(java.lang.String consideredWhitespace)
The String characters that can be considered whitespace ALONG with Character.iswhiteSpace().

Parameters:
consideredWhitespace - the extra whitespace characters

insert

public java.lang.String insert(java.lang.String targetString,
                               java.lang.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


Copyright © 2002-2010 Atlassian. All Rights Reserved.