Package arc.util
Class Strings
java.lang.Object
arc.util.Strings
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic StringautoFixed(float value, int max) static StringConverts a Space Separated string to camelCase.static Stringstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic Stringcapitalize(String s) Converts a snake_case or kebab-case string to Upper Case.static booleanString.contains(CharSequence)but with a predicate.static intcount(CharSequence s, char c) static intstatic Stringstatic Stringfixed(float d, int decimalPlaces) static StringBuilderfixedBuilder(float d, int decimalPlaces) static voidformat(StringBuilder out, String text, Object... args) static Stringstatic StringformatMillis(long val) static Throwablestatic Stringstatic Stringstatic Stringstatic StringhueToColorTag(int hue) static voidhueToColorTag(StringBuilder builder, int hue) Re-implementation ofColor.fromHsv(float, float, float)that handles only the hue.static StringAdds spaces to a camel/pascal case string.static booleanstatic booleanstatic booleanstatic booleanstatic booleanisVersionAtLeast(String currentVersion, String newVersion) static Stringjoin(CharSequence delimiter, CharSequence[] elements, int start, int end) static Stringstatic Stringstatic Stringstatic Stringstatic intlevenshtein(String x, String y) Returns the levenshtein distance between two strings.static booleanstatic Stringstatic Stringstatic StringRemoves colors, glyphs and leading spaces.static doubleparseDouble(String value) static doubleparseDouble(String value, double defaultValue) static doubleparseDouble(String value, int start, int end, double defaultValue) Faster double parser that doesn't throw exceptions.static floatparseFloat(String s) Returns Float.NEGATIVE_INFINITY if parsing failed.static floatparseFloat(String s, float defaultValue) static intReturns Integer.MIN_VALUE if parsing failed.static intstatic intstatic intstatic longstatic longstatic longstatic longstatic Stringrainbowify(String src, int startHue, int addedHue) static StringTaken from theString.repeat(int)method of JDK 11static StringBuilderreplace(StringBuilder builder, char find, String replace) Replaces all instances offindwithreplace.static StringBuilderreplace(StringBuilder builder, String find, String replace) Replaces all instances offindwithreplace.static StringsanitizeFilename(String str) Replaces non-safe filename characters with '_'.static StringstripColors(CharSequence str) static StringstripGlyphs(CharSequence str) static <T> StringtoSentence(Iterable<T> list, Func<T, String> stringifier) Converts a list to a human readable sentence.static <T> StringConverts a list to a human readable sentence.static <T> voidtoSentence(StringBuilder builder, Iterable<T> list, Cons2<StringBuilder, T> stringifier) Converts a list to a human readable sentence.static <T> voidtoSentence(StringBuilder builder, Iterable<T> list, Cons2<StringBuilder, T> stringifier, String or, String and) Converts a list to a human readable sentence.static Stringstatic String
-
Field Details
-
utf8
-
-
Constructor Details
-
Strings
public Strings()
-
-
Method Details
-
matches
- Returns:
- whether the name matches the query; case-insensitive. Always returns true if query is empty.
-
count
-
count
-
truncate
-
truncate
-
getCauses
-
getSimpleMessage
-
getFinalMessage
-
getFinalCause
-
getStackTrace
-
neatError
- Returns:
- a neat error message of a throwable, with stack trace.
-
neatError
- Returns:
- a neat error message of a throwable, with stack trace.
-
stripColors
-
stripGlyphs
-
normalize
Removes colors, glyphs and leading spaces. -
sanitizeFilename
Replaces non-safe filename characters with '_'. Handles reserved window file names. -
encode
-
format
-
format
-
join
-
join
-
join
-
levenshtein
Returns the levenshtein distance between two strings. -
repeat
Taken from theString.repeat(int)method of JDK 11 -
animated
-
kebabToCamel
-
camelToKebab
-
kebabize
-
capitalize
Converts a snake_case or kebab-case string to Upper Case. For example: "test_string" -> "Test String" -
insertSpaces
Adds spaces to a camel/pascal case string. -
camelize
Converts a Space Separated string to camelCase. For example: "Camel Case" -> "camelCase" -
canParseInt
-
canParsePositiveInt
-
parseInt
Returns Integer.MIN_VALUE if parsing failed. -
parseInt
-
parseInt
-
parseInt
-
canParseLong
-
canParsePositiveLong
-
parseLong
-
parseLong
-
parseLong
-
parseLong
-
parseDouble
-
parseDouble
-
parseDouble
Faster double parser that doesn't throw exceptions. -
canParseFloat
-
canParsePositiveFloat
-
parseFloat
Returns Float.NEGATIVE_INFINITY if parsing failed. -
parseFloat
-
autoFixed
-
fixed
-
fixedBuilder
-
formatMillis
-
replace
Replaces all instances offindwithreplace. -
replace
Replaces all instances offindwithreplace. -
toSentence
Converts a list to a human readable sentence. E.g. [1, 2, 3, 4, 5] -> "1, 2, 3, 4 and 5" -
toSentence
public static <T> String toSentence(Iterable<T> list, Func<T, String> stringifier, String or, String and) Converts a list to a human readable sentence. E.g. [1, 2, 3, 4, 5] -> "1, 2, 3, 4 and 5" -
toSentence
public static <T> void toSentence(StringBuilder builder, Iterable<T> list, Cons2<StringBuilder, T> stringifier) Converts a list to a human readable sentence. E.g. [1, 2, 3, 4, 5] -> "1, 2, 3, 4 and 5" -
toSentence
public static <T> void toSentence(StringBuilder builder, Iterable<T> list, Cons2<StringBuilder, T> stringifier, String or, String and) Converts a list to a human readable sentence. E.g. [1, 2, 3, 4, 5] -> "1, 2, 3, 4 and 5" -
contains
String.contains(CharSequence)but with a predicate. -
hueToColorTag
-
hueToColorTag
Re-implementation ofColor.fromHsv(float, float, float)that handles only the hue. -
rainbowify
-
isTrue
- Returns:
- whether the specified string mean true
-
isTrue
- Returns:
- whether the specified string mean true
-
isFalse
- Returns:
- whether the specified string mean false
-
isFalse
- Returns:
- whether the specified string mean false
-
isVersionAtLeast
- Returns:
- whether
newVersionis greater thancurrentVersion. (e.g."v146" > "124.1")
-