Class StringUtils
-
- All Implemented Interfaces:
public final class StringUtils
-
-
Method Summary
Modifier and Type Method Description final static StringBuilderappend(StringBuilder $self, Character c, Integer repeats)append the given Char to this StringBuilder, repeated repeats times. final static StringremoveSurrounding(String $self, Character char)final static StringsubstringOr(String $self, Integer fromIndex, Integer toIndex, String other)final static StringsubstringSafe(String $self, Integer fromIndex, Integer toIndex)final static Stringremove(String $self, Character char)final static StringdropAt(String $self, Integer index, Integer amount)final static Stringtruncate(String $self, Renderer renderer, Font font, Float fontSize, Float width, String limitText)Limit the given string to a width. final static Pair<String, String>substringToWidth(String $self, Renderer renderer, Font font, Float fontSize, Float width)take the given string and cut it to the length, returning a pair of the string cut to the length, and the remainder. final static IntegerlevenshteinDistance(String $self, String other)calculate the levenshtein distance between this string and the other string. final static <Error class: unknown class><Line>)>wrap(String $self, Float maxWidth, Renderer renderer, Font font, Float fontSize, <Error class: unknown class><Line> lines)Wrap the given text to the given width, inserting them into lines, or a new list is created if it is null. final static IntegerclosestToPoint(CharSequence $self, Renderer renderer, Font font, Float fontSize, Float x)Returns the closest character index from the given string to the given point x. -
-
Method Detail
-
append
final static StringBuilder append(StringBuilder $self, Character c, Integer repeats)
append the given Char to this StringBuilder, repeated repeats times.
This function is equivalent to doing sb
.append(c.repeat(repeats)), but it uses an already existing StringBuilder.
-
removeSurrounding
final static String removeSurrounding(String $self, Character char)
-
substringOr
final static String substringOr(String $self, Integer fromIndex, Integer toIndex, String other)
-
substringSafe
final static String substringSafe(String $self, Integer fromIndex, Integer toIndex)
-
truncate
final static String truncate(String $self, Renderer renderer, Font font, Float fontSize, Float width, String limitText)
Limit the given string to a width. If the string is too long, it will be cut to the width, and limitText will be appended to the end.
- Since:
0.22.0
-
substringToWidth
final static Pair<String, String> substringToWidth(String $self, Renderer renderer, Font font, Float fontSize, Float width)
take the given string and cut it to the length, returning a pair of the string cut to the length, and the remainder.
if the string fits within the width, the first string will be the entire string, and the second will be empty.
-
levenshteinDistance
final static Integer levenshteinDistance(String $self, String other)
calculate the levenshtein distance between this string and the other string.
- Since:
0.19.1
-
wrap
final static <Error class: unknown class><Line> )>wrap(String $self, Float maxWidth, Renderer renderer, Font font, Float fontSize, <Error class: unknown class><Line> lines)
Wrap the given text to the given width, inserting them into lines, or a new list is created if it is null. It also returned.
-
closestToPoint
final static Integer closestToPoint(CharSequence $self, Renderer renderer, Font font, Float fontSize, Float x)
Returns the closest character index from the given string to the given point x.
- Returns:
the index of the character closest to the given point x, or
-1if it could not be found.- Since:
0.18.5
-
-
-
-