Class StringUtils
java.lang.Object
net.thevpc.common.strings.StringUtils
- Author:
- taha.bensalah@gmail.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Patternstatic final StringConverterstatic final StringConverterstatic final StringConverter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic StringalignRight(String s, int width) static StringBuilderstatic Stringstatic StringConvertercombineConverters(StringConverter... converters) static PatterncompileSubPatterns(String text, String... subPatterns) Builds a pattern where all the string is escaped but £? will be replaced by valid patterns Example :static Pattern2compileSubPatterns2(String text, String... subPatterns) static StringCollectioncreateStringCollection(String separators, boolean preserveOrder, boolean duplicates, StringConverter keyConverter, StringConverter valueConverter) static StringCollectioncreateStringList(String separators, StringConverter keyConverter) static StringCollectioncreateStringMap(String separators, StringConverter keyConverter, StringConverter valueConverter) static StringCollectioncreateStringSet(String separators, StringConverter keyConverter) static Stringstatic Stringstatic StringescapeRegex(String string) static Stringstatic Stringstatic StringfillString(char x, int width) static StringfillString(String pattern, int width) static Stringformat(String message, Map<String, Object> parameters, MessageNameFormatContext messageNameFormatContext) static StringformatLeft(Object number, int size) static StringformatRight(Object number, int size) static intindexOfRegexpEnd(String value, String regexp) static intindexOfRegexpStart(String value, String regexp) static intindexOfWord(String string, String word) static intindexOfWord(String string, String word, int from) static intindexOfWord(String string, String word, int from, String ponctuations) static booleanstatic booleanisJavaIdentifier(String value) static Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringjoin(String sep, Collection<String> items) static <T> Stringjoin(String sep, Collection<T> items, ObjectToString<T> toStr) static <T> Stringjoin(String sep, T[] items, ObjectToString<T> toStr) static <T> StringlistToString(Collection<T> objects, String separator) static <T> StringlistToString(Collection<T> objects, String separator, boolean noEmpty, StringTransform transform) static <T> StringlistToStringDeep(String separator, boolean noEmpty, StringTransform transform, Object... items) static StringliteralToString(Object literal) static StringLocationlocationOfRegexp(String value, String regexp) static StringlongestSubstring(String str1, String str2, boolean caseInsensitive) https://karussell.wordpress.com/2011/04/14/longest-common-substring-algorithm-in-java/static booleanmatchesWildcardExpression(String str, String pattern) static booleanmatchesWildcardExpression(String str, String pattern, char pathSeparator) matchSubstring(String val, String pattern) * **static Stringstatic Stringstatic StringnormalizeString(String expression) static String[]parseCommandline(String line) code from org.apache.tools.ant.types.Commandline copyrights goes to Apache Ant Authors (Licensed to the Apache Software Foundation (ASF)) Crack a command line.static intreadToken(Reader reader, String stopTokens, StringBuilder result) static String[]removeDuplicates(String[] values) static StringreplaceDollarPlaceHolders(String s, StringConverter converter) static StringreplaceHead(String s, String oldHead, String newHead) static StringreplacePlaceHolders(String s, String prefix, String suffix, StringConverter converter) static StringreplaceTail(String s, String oldTail, String newTail) static String[]static String[]static StringstacktraceToString(Throwable throwable) static Stringstatic StringtoCapitalized(String name) static StringtoUncapitalized(String name) static Stringstatic StringtrimObject(Object value) static StringtrimObjectToNull(Object any) return either a null string or a non empty string.static StringtrimToNull(String str) static StringverboseStacktraceToString(Throwable throwable) static StringwildcardToRegex(String pattern) static StringwildcardToRegex(String pattern, char pathSeparator)
-
Field Details
-
DOLLAR_PLACE_HOLDER_PATTERN
-
UPPER
-
LOWER
-
NORMALIZED
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
combineConverters
-
normalizeString
-
nonNull
-
nonNull
-
trimObject
-
trim
-
isBlank
-
escapeRegex
-
indexOfWord
-
indexOfWord
-
indexOfWord
-
wildcardToRegex
-
wildcardToRegex
-
indexOfRegexpStart
-
isJavaIdentifier
-
locationOfRegexp
-
indexOfRegexpEnd
-
replaceDollarPlaceHolders
-
replacePlaceHolders
public static String replacePlaceHolders(String s, String prefix, String suffix, StringConverter converter) -
substring
-
verboseStacktraceToString
-
stacktraceToString
-
matchesWildcardExpression
-
matchesWildcardExpression
-
listToString
-
listToString
public static <T> String listToString(Collection<T> objects, String separator, boolean noEmpty, StringTransform transform) -
longestSubstring
-
createStringList
-
createStringSet
-
createStringMap
public static StringCollection createStringMap(String separators, StringConverter keyConverter, StringConverter valueConverter) -
createStringCollection
public static StringCollection createStringCollection(String separators, boolean preserveOrder, boolean duplicates, StringConverter keyConverter, StringConverter valueConverter) -
removeDuplicates
-
split
-
split
-
cut
-
cut
-
expand
-
listToStringDeep
public static <T> String listToStringDeep(String separator, boolean noEmpty, StringTransform transform, Object... items) -
trimToNull
-
trimObjectToNull
return either a null string or a non empty string. If the object is not a string, it is first converted to a string using String.valueOf(object); if the resulting string is empty, null is returned- Parameters:
any- any- Returns:
- null or trimmed object's toString
-
exceptionToString
-
fillString
-
fillString
-
alignLeft
-
alignRight
-
join
-
join
-
join
-
join
-
join
-
join
-
join
-
join
-
join
-
join
-
join
-
format
-
literalToString
-
toCapitalized
-
toUncapitalized
-
matchSubstring
-
replaceTail
-
replaceHead
-
formatLeft
-
formatRight
-
parseMap
-
parseMap
-
readToken
public static int readToken(Reader reader, String stopTokens, StringBuilder result) throws IOException - Throws:
IOException
-
clear
-
parseCommandline
code from org.apache.tools.ant.types.Commandline copyrights goes to Apache Ant Authors (Licensed to the Apache Software Foundation (ASF)) Crack a command line.- Parameters:
line- the command line to process.- Returns:
- the command line broken into strings. An empty or null toProcess parameter results in a zero sized array.
-
coalesce
-
compileSubPatterns2
-
compileSubPatterns
Builds a pattern where all the string is escaped but £? will be replaced by valid patterns Example :StringUtils.compileSubPatterns("\"java.lang:type=Threading\".operations.dumpAllThreads[£1].threadName", "?<Item>[0-9]+")- Parameters:
text- textsubPatterns- subPatterns- Returns:
- Pattern
-