Class Strings
java.lang.Object
aQute.lib.strings.Strings
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intadjustBegin(String s, int n) static intstatic charstatic booleancompareExcept(String a, String b, Pattern pattern) Compare two strings except for where the first group in pattern.static Stringstatic Stringstatic booleanendsWithIgnoreCase(String target, String suffix) static StringensurePrefix(String s, String prefix) static StringensureSuffix(String s, String suffix) static StringEscape illegal characters in a string with an escape character and the 4-digit hex Unicode encoding.static String[]Split a string into a base and an extension.static String[]static StringThis method is the same as String.format but it makes sure that any arrays are transformed to strings.static Stringstatic StringgetLastSegment(String name) static StringgetLastSegment(String name, char c) static booleanstatic Stringstatic Stringstatic Stringstatic voidstatic Stringstatic Stringstatic Stringstatic Collector<CharSequence, ?, String> joining()static Collector<CharSequence, ?, String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix, CharSequence emptyValue) static String[]Split a string into a prefix and a suffix based on the last time the separator appearsstatic String[]Split a path (/ based) into a prefix and a last segmentstatic booleanstatic booleanstatic booleanstatic StringsplitAsStream(String s, Pattern splitter) splitLines(String s) splitQuoted(String s, String separators) splitQuotedAsStream(String s, boolean retainQuotes) splitQuotedAsStream(String s, String separators) splitQuotedAsStream(String s, String separators, boolean retainQuotes) static booleanstartsWithIgnoreCase(String target, String prefix) static booleanstartsWithIgnoreCase(String target, String prefix, int toffset) static StringstripPrefix(String s, String prefix) static StringstripPrefix(String s, Pattern p) static StringstripSuffix(String s, String suffix) static StringstripSuffix(String s, Pattern p) static Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic StringUnescape a string with the given escape character.
-
Constructor Details
-
Strings
public Strings()
-
-
Method Details
-
join
-
join
-
join
-
join
public static void join(StringBuilder sb, String middle, Iterable<?> objects, Pattern pattern, String replace) -
join
-
joining
-
joining
public static Collector<CharSequence, ?, String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix, CharSequence emptyValue) -
display
-
join
-
join
-
getLastSegment
-
getLastSegment
-
trim
-
notEmpty
-
nonNullOrEmpty
-
nonNullOrTrimmedEmpty
-
splitAsStream
-
splitAsStream
-
split
-
split
-
splitQuotedAsStream
-
splitQuotedAsStream
-
splitQuotedAsStream
-
splitQuotedAsStream
-
splitLinesAsStream
-
splitLines
-
splitQuoted
-
splitQuoted
-
split
-
in
-
charAt
-
from
-
substring
-
substring
-
delete
-
to
-
adjustBegin
-
adjustEnd
-
extension
-
lastPathSegment
-
last
Split a string into a prefix and a suffix based on the last time the separator appears- Parameters:
s- the string that contains a path- Returns:
- null if no suffix or an array of 2 elements, first is the prefix and second is the suffix without the separator at the start
-
first
-
stripPrefix
-
stripPrefix
-
stripSuffix
-
stripSuffix
-
ensureSuffix
-
ensurePrefix
-
times
-
format
-
compareExcept
Compare two strings except for where the first group in pattern. The patterns is matched in the strings using find(). Only group 1 is ignored. Use ignored groups(?:...)to ignore irrelevant groups.a = "abcdefxxxxghixxxxx678" b = "abcdefxxghix678" Pattern "(x+)"First developed to compare two XML files that only differed in their increment number, which was a time long.- Parameters:
a- the first string to compareb- the second string to comparepattern- where first group should be ignored in the comparison- Returns:
- true if the strings are equal ignoring the first group's pattern matches
-
toString
-
escape
Escape illegal characters in a string with an escape character and the 4-digit hex Unicode encoding. A string escaped like this can be unescaped withunescape(String, char)using the same escape character.- Parameters:
string- a string to be escapedillegalCharacters- a pattern matching illegal characters, must include the escape characterescape- an escape character, must be included in the illegalCharacters- Returns:
- a string that does not contain the illegalCharacters except the escape
-
unescape
Unescape a string with the given escape character. There must be 4 hex digits after each escape character.- Parameters:
string- the string to unescape, can be nullescape- the escape character- Returns:
- an Optional, present if the escaping was successful
-
removeQuotes
-
startsWithIgnoreCase
-
startsWithIgnoreCase
-
endsWithIgnoreCase
-