Package rife.tools
Class StringUtils
java.lang.Object
rife.tools.StringUtils
General purpose class containing common
String manipulation
methods.- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Patternstatic final Patternstatic final Patternstatic final Patternstatic final Patternstatic final Patternstatic final Patternstatic Charsetstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic final char[]static final char[] -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendHexDigit(StringBuilder out, int number) Appends the hexadecimal digit of the provided number.static voidappendHexDigitLower(StringBuilder out, int number) Appends the lowercase hexadecimal digit of the provided number.static Stringcapitalize(String source) Ensure that the first character of the provided string is upper case.static StringconvertBbcode(String source) Converts a BBCode marked-up text to regular html.static StringconvertBbcode(String source, rife.tools.StringUtils.BbcodeOption... options) Converts a BBCode marked-up text to regular html.static StringconvertLineSeparator(String text) Replaces\nwith the system line separator.static StringconvertTabsToSpaces(String line, int tabWidth) Converts all tabs on a line to spaces according to the provided tab width.static booleanconvertToBoolean(String value) Converts aStringto abooleanvalue.static intCounts the number of times a substring occures in a provided string in a case-sensitive manner.static intCounts the number of times a substring occures in a provided string.static StringdecodeHtml(String source) static StringTransforms a providedStringURL into a new string, containing decoded URL characters in the UTF-8 encoding.static StringencodeBase32(byte[] bytes) Encodes byte array to Base32 String.static StringencodeBase64(byte[] bytes) Encodes byte array to Base64 String.static StringencodeClassname(String name) Transforms a providedStringobject into a new string, containing only valid characters for a java class name.static StringencodeHex(byte[] bytes) Generates an uppercase hexadecimal string for the provided byte array.static StringencodeHexLower(byte[] bytes) Generates a lowercase hexadecimal string for the provided byte array.static StringencodeHtml(String source) Transforms a providedStringobject into a new string, containing only valid Html characters.static StringencodeHtmlDefensive(String source) Transforms a providedStringobject into a new string, containing as much as possible Html characters.static StringencodeJson(String source) Transforms a providedStringobject into a new string, containing only valid Json characters.static StringencodeLatex(String source) Transforms a providedStringobject into a new string, containing only valid LaTeX characters.static StringencodeRegexp(String source) Transforms a providedStringobject into a literal that can be included into a regular expressionPatternas-is.static StringTransforms a providedStringobject into a new string, containing only valid Sql characters.static StringencodeString(String source) Transforms a providedStringobject into a new string, containing only validStringcharacters.static StringencodeUnicode(String source) Transforms a providedStringobject into a series of unicode escape codes.static StringTransforms a providedStringobject into a new string, containing only valid URL characters in the UTF-8 encoding.static StringTransforms a providedStringobject into a new string, containing only valid URL characters in the UTF-8 encoding.static StringTransforms a providedStringobject into a new string, containing only valid URL characters in the UTF-8 encoding.static StringTransforms a providedStringobject into a new string, containing only valid XML characters.static booleanChecks if the name filters through a series of including and excluding regular expressions.static booleanChecks if the name filters through a series of including and excluding regular expressions.static booleanChecks if the name filters through a series of including and excluding regular expressions.static booleanChecks if the name filters through a series of including and excluding regular expressions.static booleanChecks if the name filters through an including and an excluding regular expression.static booleanChecks if the name filters through an including and an excluding regular expression.static StringfilterAsIdentifier(String value) Filters the given string by removing any characters that are not valid in a Java identifier.static StringfilterAsIdentifier(String value, boolean capitalizeSegments) Filters the given string by removing any characters that are not valid in a Java identifier.static DocumentPositiongetDocumentPosition(String document, int characterIndex) Calculates theDocumentPositionof a character index in a document.static MatchergetMatchingRegexp(String value, Collection<Pattern> regexps) Matches a collection of regular expressions against a string.static MatchergetRegexpMatch(Collection<String> values, Pattern regexp) Matches a collection of strings against a regular expression.static int[]Returns an array that contains all the occurances of a substring in a string in the correct order.static int[]Returns an array that contains all the occurances of a substring in a string in the correct order.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static StringCreates a newStringobject, containing the elements of a supplied array, joined by a given separator.static Stringjoin(Collection<?> collection, String separator) Creates a newStringobject, containing the elements of a suppliedCollectionofStringobjects joined by a given separator.static StringCreates a new string that contains the provided string a number of times.static StringSearches for a string within a specified string in a case-sensitive manner and replaces every match with another string.static StringSearches for a string within a specified string and replaces every match with another string.Splits a string into different parts, using a separator string to detect the seperation boundaries in a case-sensitive manner.Splits a string into different parts, using a separator string to detect the seperation boundaries.static String[]splitToArray(String source, String separator) Splits a string into different parts, using a separator string to detect the seperation boundaries in a case-sensitive manner.static String[]splitToArray(String source, String separator, boolean matchCase) Splits a string into different parts, using a separator string to detect the seperation boundaries.static byte[]splitToByteArray(String source, String separator) Splits a string into bytes, using a separator string to detect the seperation boundaries in a case-sensitive manner.static byte[]splitToByteArray(String source, String separator, boolean matchCase) Splits a string into bytes, using a separator string to detect the seperation boundaries.static int[]splitToIntArray(String source, String separator) Splits a string into integers, using a separator string to detect the seperation boundaries in a case-sensitive manner.static int[]splitToIntArray(String source, String separator, boolean matchCase) Splits a string into integers, using a separator string to detect the seperation boundaries.static StringstripBlankLines(String text) Removes all blank lines from text.static StringstripFromEnd(String source, String stringToStrip) Removes all occurances of a string from the end of another string in a case-sensitive manner.static StringstripFromEnd(String source, String stringToStrip, boolean matchCase) Removes all occurances of a string from the end of another string.static StringstripFromFront(String source, String stringToStrip) Removes all occurances of a string from the front of another string in a case-sensitive manner.static StringstripFromFront(String source, String stringToStrip, boolean matchCase) Removes all occurances of a string from the front of another string.toArrayList(String[] stringArray) Creates a newArrayList, containing the elements of a supplied array ofStringobjects.static StringCreates aStringfor the provided byte array and encodingstatic String[]toStringArray(Iterator<String> iterator) Creates a new array ofStringobjects, containing the elements of a suppliedIterator.static StringEnsures that all whitespace is removed from aString.static Stringuncapitalize(String source) Ensure that the first character of the provided string is lower case.static StringReformats a string where lines that are longer thanwidthare split apart at the earliest wordbreak or at maxLength, whichever is sooner.
-
Field Details
-
ENCODING_US_ASCII
-
ENCODING_ISO_8859_1
-
ENCODING_ISO_8859_2
-
ENCODING_ISO_8859_5
-
ENCODING_UTF_8
-
ENCODING_UTF_16BE
-
ENCODING_UTF_16LE
-
ENCODING_UTF_16
-
CHARSET_US_ASCII
-
HEX_DIGITS
public static final char[] HEX_DIGITS -
HEX_DIGITS_LOWER
public static final char[] HEX_DIGITS_LOWER -
BBCODE_COLOR
-
BBCODE_SIZE
-
BBCODE_URL_SHORT
-
BBCODE_URL_LONG
-
BBCODE_IMG
-
BBCODE_QUOTE_LONG
-
BBCODE_BAREURL
-
-
Method Details
-
encodeClassname
Transforms a providedStringobject into a new string, containing only valid characters for a java class name.- Parameters:
name- The string that has to be transformed into a valid class name.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeUrl
Transforms a providedStringobject into a new string, containing only valid URL characters in the UTF-8 encoding.- Parameters:
source- The string that has to be transformed into a valid URL string.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeUrl
Transforms a providedStringobject into a new string, containing only valid URL characters in the UTF-8 encoding.- Parameters:
source- The string that has to be transformed into a valid URL string.allow- Additional characters to allow.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeUrl
Transforms a providedStringobject into a new string, containing only valid URL characters in the UTF-8 encoding.- Parameters:
source- The string that has to be transformed into a valid URL string.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
appendHexDigit
Appends the hexadecimal digit of the provided number.- Parameters:
out- the string builder to append tonumber- the number who's first digit will be appended in hexadecimal- Since:
- 1.0
-
appendHexDigitLower
Appends the lowercase hexadecimal digit of the provided number.- Parameters:
out- the string builder to append tonumber- the number who's first digit will be appended in hexadecimal- Since:
- 1.5.7
-
decodeUrl
Transforms a providedStringURL into a new string, containing decoded URL characters in the UTF-8 encoding.- Parameters:
source- The string URL that has to be decoded- Returns:
- The decoded
Stringobject. - Since:
- 1.0
- See Also:
-
decodeHtml
- Since:
- 1.0
-
encodeHtml
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
- See Also:
-
encodeHtmlDefensive
Transforms a providedStringobject into a new string, containing as much as possible Html characters. It is safe to already feed existing Html to this method since &, < and > will not be encoded.- Parameters:
source- The string that has to be transformed into a valid Html string.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeXml
Transforms a providedStringobject into a new string, containing only valid XML characters.- Parameters:
source- The string that has to be transformed into a valid XML string.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeString
Transforms a providedStringobject into a new string, containing only validStringcharacters.- Parameters:
source- The string that has to be transformed into a valid sequence ofStringcharacters.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeUnicode
Transforms a providedStringobject into a series of unicode escape codes.- Parameters:
source- The string that has to be transformed into a valid sequence of unicode escape codes- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeSql
Transforms a providedStringobject into a new string, containing only valid Sql characters.- Parameters:
source- The string that has to be transformed into a valid Sql string.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeLatex
Transforms a providedStringobject into a new string, containing only valid LaTeX characters.- Parameters:
source- The string that has to be transformed into a valid LaTeX string.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeJson
Transforms a providedStringobject into a new string, containing only valid Json characters.- Parameters:
source- The string that has to be transformed into a valid LaTeX string.- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeRegexp
Transforms a providedStringobject into a literal that can be included into a regular expressionPatternas-is. None of the regular expression escapes in the string will be functional anymore.- Parameters:
source- The string that has to be escaped as a literal- Returns:
- The encoded
Stringobject. - Since:
- 1.0
- See Also:
-
encodeHex
Generates an uppercase hexadecimal string for the provided byte array.- Parameters:
bytes- the byte array to convert to a hex string- Returns:
- the converted hexadecimal string
- Since:
- 1.0
-
encodeHexLower
Generates a lowercase hexadecimal string for the provided byte array.- Parameters:
bytes- the byte array to convert to a hex string- Returns:
- the converted hexadecimal string
- Since:
- 1.5.7
-
encodeBase64
Encodes byte array to Base64 String.- Parameters:
bytes- Bytes to encode.- Returns:
- Encoded byte array
bytesas a String. - Since:
- 1.1
-
encodeBase32
Encodes byte array to Base32 String.- Parameters:
bytes- Bytes to encode.- Returns:
- Encoded byte array
bytesas a String. - Since:
- 1.0
-
count
Counts the number of times a substring occures in a provided string in a case-sensitive manner.- Parameters:
source- TheStringobject that will be searched in.substring- The string whose occurances will we counted.- Returns:
- An
intvalue containing the number of occurances of the substring. - Since:
- 1.0
-
count
Counts the number of times a substring occures in a provided string.- Parameters:
source- TheStringobject that will be searched in.substring- The string whose occurances will we counted.matchCase- Abooleanindicating if the match is going to be performed in a case-sensitive manner or not.- Returns:
- An
intvalue containing the number of occurances of the substring. - Since:
- 1.0
-
split
Splits a string into different parts, using a separator string to detect the seperation boundaries in a case-sensitive manner. The separator will not be included in the list of parts.- Parameters:
source- The string that will be split into parts.separator- The separator string that will be used to determine the parts.- Returns:
- An
ArrayListcontaining the parts asStringobjects. - Since:
- 1.0
-
split
Splits a string into different parts, using a separator string to detect the seperation boundaries. The separator will not be included in the list of parts.- Parameters:
source- The string that will be split into parts.separator- The separator 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
-
splitToArray
Splits a string into different parts, using a separator string to detect the seperation boundaries in a case-sensitive manner. The separator will not be included in the parts array.- Parameters:
source- The string that will be split into parts.separator- The separator string that will be used to determine the parts.- Returns:
- A
String[]array containing the seperated parts. - Since:
- 1.0
-
splitToArray
Splits a string into different parts, using a separator string to detect the seperation boundaries. The separator will not be included in the parts array.- Parameters:
source- The string that will be split into parts.separator- The separator 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:
- A
String[]array containing the seperated parts. - Since:
- 1.0
-
splitToIntArray
Splits a string into integers, using a separator string to detect the seperation boundaries in a case-sensitive manner. If a part couldn't be converted to an integer, it will be omitted from the resulting array.- Parameters:
source- The string that will be split into integers.separator- The separator string that will be used to determine the parts.- Returns:
- An
int[]array containing the seperated parts. - Since:
- 1.0
-
splitToIntArray
Splits a string into integers, using a separator string to detect the seperation boundaries. If a part couldn't be converted to an integer, it will be omitted from the resulting array.- Parameters:
source- The string that will be split into integers.separator- The separator 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
int[]array containing the seperated parts. - Since:
- 1.0
-
splitToByteArray
Splits a string into bytes, using a separator string to detect the seperation boundaries in a case-sensitive manner. If a part couldn't be converted to abyte, it will be omitted from the resulting array.- Parameters:
source- The string that will be split into bytes.separator- The separator string that will be used to determine the parts.- Returns:
- A
byte[]array containing the bytes. - Since:
- 1.0
-
splitToByteArray
Splits a string into bytes, using a separator string to detect the seperation boundaries. If a part couldn't be converted to abyte, it will be omitted from the resulting array.- Parameters:
source- The string that will be split into bytes.separator- The separator 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:
- A
byte[]array containing the bytes. - Since:
- 1.0
-
stripFromFront
Removes all occurances of a string from the front of another string in a case-sensitive manner.- Parameters:
source- The string in which the matching will be done.stringToStrip- The string that will be stripped from the front.- Returns:
- A new
Stringcontaining the stripped result. - Since:
- 1.0
-
stripFromFront
Removes all occurances of a string from the front of another string.- Parameters:
source- The string in which the matching will be done.stringToStrip- The string that will be stripped from the front.matchCase- Abooleanindicating if the match is going to be performed in a case-sensitive manner or not.- Returns:
- A new
Stringcontaining the stripping result. - Since:
- 1.0
-
stripFromEnd
Removes all occurances of a string from the end of another string in a case-sensitive manner.- Parameters:
source- The string in which the matching will be done.stringToStrip- The string that will be stripped from the end.- Returns:
- A new
Stringcontaining the stripped result. - Since:
- 1.0
-
stripFromEnd
Removes all occurances of a string from the end of another string.- Parameters:
source- The string in which the matching will be done.stringToStrip- The string that will be stripped from the end.matchCase- Abooleanindicating if the match is going to be performed in a case-sensitive manner or not.- Returns:
- A new
Stringcontaining the stripped result. - Since:
- 1.0
-
replace
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 String replace(String source, String stringToReplace, 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
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
-
toString
Creates aStringfor the provided byte array and encoding- Parameters:
bytes- The byte array to convert.encoding- The encoding to use for the string conversion.- Returns:
- The converted
String. - Since:
- 1.0
-
toStringArray
Creates a new array ofStringobjects, containing the elements of a suppliedIterator.- Parameters:
iterator- The iterator containing the elements to create the array with.- Returns:
- The new
Stringarray. - Since:
- 1.0
-
toArrayList
Creates a newArrayList, containing the elements of a supplied array ofStringobjects.- Parameters:
stringArray- The array ofStringobjects that have to be converted.- Returns:
- The new
ArrayListwith the elements of theStringarray. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a suppliedCollectionofStringobjects joined by a given separator.- Parameters:
collection- TheCollectioncontaining the elements to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The object array containing the elements to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The object array containing the elements to join.separator- The separator used to join the string elements.delimiter- The delimiter used to surround the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
public static String join(Object[] array, String separator, String delimiter, boolean encodeStrings) Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The object array containing the elements to join.separator- The separator used to join the string elements.delimiter- The delimiter used to surround the string elements.encodeStrings- Indicates whether the characters of the string representation of the Array values should be encoded.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The boolean array containing the values to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The byte array containing the values to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The double array containing the values to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The float array containing the values to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The integer array containing the values to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The long array containing the values to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The short array containing the values to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The char array containing the values to join.separator- The separator used to join the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
join
Creates a newStringobject, containing the elements of a supplied array, joined by a given separator.- Parameters:
array- The char array containing the values to join.separator- The separator used to join the string elements.delimiter- The delimiter used to surround the string elements.- Returns:
- A new
Stringwith the join result. - Since:
- 1.0
-
indicesOf
Returns an array that contains all the occurances of a substring in a string in the correct order. The search will be performed in a case-sensitive manner.- Parameters:
source- TheStringobject that will be searched in.substring- The string whose occurances will we counted.- Returns:
- An
int[]array containing the indices of the substring. - Since:
- 1.0
-
indicesOf
Returns an array that contains all the occurances of a substring in a string in the correct order.- Parameters:
source- TheStringobject that will be searched in.substring- The string whose occurances will we counted.matchCase- Abooleanindicating if the match is going to be performed in a case-sensitive manner or not.- Returns:
- An
int[]array containing the indices of the substring. - Since:
- 1.0
-
getMatchingRegexp
Matches a collection of regular expressions against a string.- Parameters:
value- TheStringthat will be checked.regexps- The collection of regular expressions against which the match will be performed.- Returns:
- The
Matcherinstance that corresponds to theStringthat returned a successful match; ornullif no match could be found. - Since:
- 1.0
-
getRegexpMatch
Matches a collection of strings against a regular expression.- Parameters:
values- TheCollectionofStringobjects that will be checked.regexp- The regular expressionPatternagainst which the matches will be performed.- Returns:
- The
Matcherinstance that corresponds to theStringthat returned a successful match; ornullif no match could be found. - Since:
- 1.0
-
filter
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
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 failmatches- Indicates whether it should be a full match or a contains- Returns:
trueif the name filtered through correctly; orfalseotherwise.- Since:
- 1.5.18
-
filter
Checks if the name filters through a series of including and excluding regular expressions.- Parameters:
name- TheStringthat will be filtered.included- A list of regular expressions that need to succeedexcluded- A list of regular expressions that need to fail- Returns:
trueif the name filtered through correctly; orfalseotherwise.- Since:
- 1.5
-
filter
public static boolean filter(String name, List<Pattern> included, List<Pattern> excluded, boolean matches) Checks if the name filters through a series of including and excluding regular expressions.- Parameters:
name- TheStringthat will be filtered.included- A list of regular expressions that need to succeedexcluded- A list of regular expressions that need to failmatches- Indicates whether it should be a full match or a contains- Returns:
trueif the name filtered through correctly; orfalseotherwise.- Since:
- 1.5.18
-
filter
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
-
filter
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 failmatches- Indicates whether it should be a full match or a contains- Returns:
trueif the name filtered through correctly; orfalseotherwise.- Since:
- 1.5.18
-
filterAsIdentifier
Filters the given string by removing any characters that are not valid in a Java identifier.If a valid identifier can't be generated,
nullwill be returned.- Parameters:
value- the string to be filtered- Returns:
- the filtered string as a valid Java identifier; or
nullif a valid Java identifier couldn't be generated - Since:
- 1.8.0
-
filterAsIdentifier
Filters the given string by removing any characters that are not valid in a Java identifier.If a valid identifier can't be generated,
nullwill be returned.- Parameters:
value- the string to be filteredcapitalizeSegments-trueto capitalize each valid character segment; orfalseto leave the original characters unaffected- Returns:
- the filtered string as a valid Java identifier; or
nullif a valid Java identifier couldn't be generated - Since:
- 1.9.1
-
capitalize
Ensure that the first character of the provided string is upper case.- Parameters:
source- TheStringto capitalize.- Returns:
- The capitalized
String. - Since:
- 1.0
-
uncapitalize
Ensure that the first character of the provided string is lower case.- Parameters:
source- TheStringto uncapitalize.- Returns:
- The uncapitalized
String. - Since:
- 1.0
-
convertBbcode
Converts a BBCode marked-up text to regular html.- Parameters:
source- The text with BBCode tags.- Returns:
- A
Stringwith the corresponding HTML code - Since:
- 1.0
-
convertBbcode
Converts a BBCode marked-up text to regular html.- Parameters:
source- The text with BBCode tags.- Returns:
- A
Stringwith the corresponding HTML code - Since:
- 1.0
-
convertToBoolean
Converts aStringto abooleanvalue.- Parameters:
value- TheStringto convert.- Returns:
- The corresponding
booleanvalue. - Since:
- 1.0
-
convertTabsToSpaces
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
-
trim
Ensures that all whitespace is removed from aString.It also works with a
nullargument.- Parameters:
source- TheStringto trim.- Returns:
- The trimmed
String. - Since:
- 1.0
-
getDocumentPosition
Calculates theDocumentPositionof a character index in a document.- Parameters:
document- aStringwith the document where the position should be looked up incharacterIndex- the index of the character- Returns:
- the resulting
DocumentPositioninstance; ornullif thecharacterIndexwas invalid or if thedocumentwas null - Since:
- 1.0
-
wordWrap
Reformats a string where lines that are longer thanwidthare split apart at the earliest wordbreak or at maxLength, whichever is sooner. If the width specified is less than 5 or greater than the input Strings length the string will be returned as is.Please note that this method can be lossy - trailing spaces on wrapped lines may be trimmed.
- Parameters:
input- the String to reformat.width- the maximum length of any one line.- Returns:
- a new String with reformatted as needed.
-
stripBlankLines
Removes all blank lines from text.- Parameters:
text- the text to strip blank lines from- Returns:
- the text without any blank lines
- Since:
- 1.5.7
-
convertLineSeparator
Replaces\nwith the system line separator.- Parameters:
text- the string in which the line separator should be replaced- Returns:
- the new string with the replaced line separator
- Since:
- 1.7.2
-