Package org.aksw.commons.util.string
Class StringUtils
java.lang.Object
org.aksw.commons.util.string.StringUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringallocateName(String base, boolean forceNumberSuffix, Predicate<String> skip) static StringbytesToHexString(byte[] bytes) static <T> Tcoalesce(T... args) Returns first non-null argumentstatic StringcommonPrefix(String sa, String sb, boolean skipLast) Returns the common prefix of the given stringsstatic StringcropString(String str, int nMax, int nTolerance) Cuts a string after nMax bytes - unless the remaining bytes are less than tolerance.static intfindCharPos(String str, int line, int col) Convert line and column index to the char position line and column indexes are 1-based.getAllPrefixedEntries(String prefix, boolean inclusive, NavigableMap<String, T> prefixMap) getAllPrefixedEntries(String prefix, boolean inclusive, SortedMap<String, T> prefixMap) getAllPrefixes(String lookup, boolean inclusive, NavigableMap<String, T> prefixMap) static <T> NavigableSet<String>getAllPrefixes(String lookup, boolean inclusive, NavigableSet<String> prefixMap) getAllPrefixes(String lookup, boolean inclusive, SortedMap<String, T> prefixMap) static intgetEolCharCount(String str, int charPos) Return the number of end-of-line characters at the current position - if any.getMatchBySuffix(String str, Map<String, T> map) static <T> StringitemPerLine(Iterable<T> iterable) static <T> StringitemPerLine(T[] array) static StringlongestPrefixLookup(String lookup, boolean inclusive, NavigableMap<String, T> prefixMap) Looks up an element in the given map that is the longest prefix of the given lookup key.static <T> StringlongestPrefixLookup(String lookup, boolean inclusive, NavigableSet<String> prefixes) longestPrefixLookup(String lookup, boolean inclusive, SortedMap<String, T> prefixMap) longestPrefixLookup(String lookup, NavigableMap<String, T> prefixMap) static <T> StringlongestPrefixLookup(String lookup, NavigableSet<String> prefixes) static Stringmd5Hash(byte[] bytes) calculate md5 hash of the stringstatic Stringstatic StringnumberSuffix(String base) Return the substring of a string that only consists of digits.shortestMatchLookup(String prefix, boolean inclusive, NavigableMap<String, V> items) static StringshortestMatchLookup(String prefix, boolean inclusive, NavigableSet<String> items) static StringRemoves prefixes that are also suffixes from a given string e.g.static StringtoCamelCase(String s, boolean upper) static Stringstatic Stringstatic Stringstatic Stringstatic StringHelper functions to get rid of that exception.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
getEolCharCount
Return the number of end-of-line characters at the current position - if any. For non-eol positions the result is 0- Parameters:
str-charPos-- Returns:
-
findCharPos
Convert line and column index to the char position line and column indexes are 1-based. Using 0 for either argument yields -1- Parameters:
str-line-col- the column- Returns:
- the char pos or -1 if there was none w.r.t. line and col
-
itemPerLine
-
itemPerLine
-
strip
Removes prefixes that are also suffixes from a given string e.g. strip('Hi', ') -> Hi- Parameters:
str-chars-- Returns:
-
coalesce
public static <T> T coalesce(T... args) Returns first non-null argument- Type Parameters:
T-- Parameters:
args-- Returns:
-
ucFirst
-
lcFirst
-
toLowerCamelCase
-
toUpperCamelCase
-
toCamelCase
-
cropString
Cuts a string after nMax bytes - unless the remaining bytes are less than tolerance. In case of a cut appends "... (# more bytes)". (# cannot be less than tolerance)- Parameters:
str-nMax-nTolerance-- Returns:
-
commonPrefix
Returns the common prefix of the given strings- Returns:
-
getAllPrefixes
-
getAllPrefixedEntries
-
longestPrefixLookup
-
getMatchBySuffix
-
urlEncode
Helper functions to get rid of that exception. Afaik UTF8 en/de-coding cannot fail (read it somewhere, not confirmed)- Parameters:
str-- Returns:
-
urlDecode
-
md5Hash
calculate md5 hash of the string- Parameters:
bytes-- Returns:
-
bytesToHexString
-
md5Hash
-
numberSuffix
Return the substring of a string that only consists of digits.Examples:
"abc123" -> "123" "abc" -> "" "abc123.456" -> "456"
-
allocateName
-