Package com.uwyn.jhighlight.tools
Class StringUtils
- java.lang.Object
-
- com.uwyn.jhighlight.tools.StringUtils
-
public abstract class StringUtils extends java.lang.ObjectGeneral purpose class containing commonStringmanipulation methods.- Since:
- 1.0
- Version:
- $Revision: 3108 $
-
-
Field Summary
Fields Modifier and Type Field Description private static CharKeyOpenHashMapmHtmlEncodeMap
-
Constructor Summary
Constructors Modifier Constructor Description privateStringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringconvertTabsToSpaces(java.lang.String line, int tabWidth)Converts all tabs on a line to spaces according to the provided tab width.private static java.lang.Stringencode(java.lang.String source, CharKeyOpenHashMap encodingTable)Transforms a providedStringobject into a new string, using the mapping that are provided through the supplied encoding table.static java.lang.StringencodeHtml(java.lang.String source)Transforms a providedStringobject into a new string, containing only valid Html characters.static booleanfilter(java.lang.String name, java.util.regex.Pattern[] included, java.util.regex.Pattern[] excluded)Checks if the name filters through a series of including and excluding regular expressions.static booleanfilter(java.lang.String name, java.util.regex.Pattern included, java.util.regex.Pattern excluded)Checks if the name filters through an including and an excluding regular expression.static java.lang.Stringrepeat(java.lang.String source, int count)Creates a new string that contains the provided string a number of times.static java.lang.Stringreplace(java.lang.String source, java.lang.String stringToReplace, java.lang.String replacementString)Searches for a string within a specified string in a case-sensitive manner and replaces every match with another string.static java.lang.Stringreplace(java.lang.String source, java.lang.String stringToReplace, java.lang.String replacementString, boolean matchCase)Searches for a string within a specified string and replaces every match with another string.static java.util.ArrayListsplit(java.lang.String source, java.lang.String seperator)Splits a string into different parts, using a seperator string to detect the seperation boundaries in a case-sensitive manner.static java.util.ArrayListsplit(java.lang.String source, java.lang.String seperator, boolean matchCase)Splits a string into different parts, using a seperator string to detect the seperation boundaries.
-
-
-
Field Detail
-
mHtmlEncodeMap
private static final CharKeyOpenHashMap mHtmlEncodeMap
-
-
Method Detail
-
encodeHtml
public static java.lang.String encodeHtml(java.lang.String source)
Transforms a providedStringobject into a new string, containing only valid Html characters.- Parameters:
source- The string that has to be transformed into a valid Html string.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
-
encode
private static java.lang.String encode(java.lang.String source, CharKeyOpenHashMap encodingTable)Transforms a providedStringobject into a new string, using the mapping that are provided through the supplied encoding table.- Parameters:
source- The string that has to be transformed into a valid string, using the mappings that are provided through the supplied encoding table.encodingTables- AMapobject containing the mappings to transform characters into valid entities. The keys of this map should beCharacterobjects and the valuesStringobjects.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
-
filter
public static boolean filter(java.lang.String name, java.util.regex.Pattern included, java.util.regex.Pattern excluded)Checks if the name filters through an including and an excluding regular expression.- Parameters:
name- TheStringthat will be filtered.included- The regular expressions that needs to succeedexcluded- The regular expressions that needs to fail- Returns:
trueif the name filtered through correctly; orfalseotherwise.- Since:
- 1.0
-
filter
public static boolean filter(java.lang.String name, java.util.regex.Pattern[] included, java.util.regex.Pattern[] excluded)Checks if the name filters through a series of including and excluding regular expressions.- Parameters:
name- TheStringthat will be filtered.included- An array of regular expressions that need to succeedexcluded- An array of regular expressions that need to fail- Returns:
trueif the name filtered through correctly; orfalseotherwise.- Since:
- 1.0
-
split
public static java.util.ArrayList split(java.lang.String source, java.lang.String seperator)Splits a string into different parts, using a seperator string to detect the seperation boundaries in a case-sensitive manner. The seperator will not be included in the list of parts.- Parameters:
source- The string that will be split into parts.seperator- The seperator string that will be used to determine the parts.- Returns:
- An
ArrayListcontaining the parts asStringobjects. - Since:
- 1.0
-
split
public static java.util.ArrayList split(java.lang.String source, java.lang.String seperator, boolean matchCase)Splits a string into different parts, using a seperator string to detect the seperation boundaries. The seperator will not be included in the list of parts.- Parameters:
source- The string that will be split into parts.seperator- The seperator string that will be used to determine the parts.matchCase- Abooleanindicating if the match is going to be performed in a case-sensitive manner or not.- Returns:
- An
ArrayListcontaining the parts asStringobjects. - Since:
- 1.0
-
replace
public static java.lang.String replace(java.lang.String source, java.lang.String stringToReplace, java.lang.String replacementString)Searches for a string within a specified string in a case-sensitive manner and replaces every match with another string.- Parameters:
source- The string in which the matching parts will be replaced.stringToReplace- The string that will be searched for.replacementString- The string that will replace each matching part.- Returns:
- A new
Stringobject containing the replacement result. - Since:
- 1.0
-
replace
public static java.lang.String replace(java.lang.String source, java.lang.String stringToReplace, java.lang.String replacementString, boolean matchCase)Searches for a string within a specified string and replaces every match with another string.- Parameters:
source- The string in which the matching parts will be replaced.stringToReplace- The string that will be searched for.replacementString- The string that will replace each matching part.matchCase- Abooleanindicating if the match is going to be performed in a case-sensitive manner or not.- Returns:
- A new
Stringobject containing the replacement result. - Since:
- 1.0
-
repeat
public static java.lang.String repeat(java.lang.String source, int count)Creates a new string that contains the provided string a number of times.- Parameters:
source- The string that will be repeated.count- The number of times that the string will be repeated.- Returns:
- A new
Stringobject containing the repeated concatenation result. - Since:
- 1.0
-
convertTabsToSpaces
public static java.lang.String convertTabsToSpaces(java.lang.String line, int tabWidth)Converts all tabs on a line to spaces according to the provided tab width.- Parameters:
line- The line whose tabs have to be converted.tabWidth- The tab width.- Returns:
- A new
Stringobject containing the line with the replaced tabs. - Since:
- 1.0
-
-