Class Strings
java.lang.Object
arc.util.Strings
com.xpdustry.claj.common.util.Strings
public class Strings
extends arc.util.Strings
-
Field Summary
Fields inherited from class arc.util.Strings
ascii, utf8 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longbase64ToLong(String str) static arc.struct.Seq<String> static arc.struct.Seq<String> static Stringstatic StringJustify string to the center.static arc.struct.Seq<String> static arc.struct.Seq<String> static arc.struct.Seq<String> static arc.struct.Seq<String> static arc.struct.Seq<String> static arc.struct.Seq<String> static intcompareVersion(String currentVersion, String newVersion) static intcompareVersion(String currentVersion, String newVersion, int maxDepth) Compare ifnewVersionis greater or less thancurrentVersion, e.g.static booleanString.contains(CharSequence)but with a predicate.static voidformat(StringBuilder out, String text, Object... args) LikeStrings.format(String, Object[])but you can specify theStringBuilder.static StringformatBytes(long v) static StringformatDuration(long millis, boolean narrow) Convertmillisduration to localized human readable format (e.g.static StringformatSize(long value, int base, String unit) static StringformattedClassName(Class<?> clazz) static booleanstatic booleanstatic booleanstatic booleanstatic booleanisVersionAtLeast(String currentVersion, String newVersion) static booleanisVersionAtLeast(String currentVersion, String newVersion, int maxDepth) static Stringjoin(CharSequence delimiter, CharSequence[] elements, int start, int end) LikeString.join(CharSequence, CharSequence[])but you can specify the start and end of the list.static StringjsonPrettyPrint(arc.util.serialization.JsonValue object, arc.util.serialization.JsonWriter.OutputType outputType) static voidjsonPrettyPrint(arc.util.serialization.JsonValue object, Writer writer, arc.util.serialization.JsonWriter.OutputType outputType) static voidjsonPrettyPrint(arc.util.serialization.JsonValue object, Writer writer, arc.util.serialization.JsonWriter.OutputType outputType, int indent) Re-implementation ofJsonValue.prettyPrint(OutputType, Writer), because the ident isn't correct and the max object size before new line is too big.static Stringstatic arc.struct.Seq<String> static arc.struct.Seq<String> static Stringstatic StringJustify string to the left.static StringlongToBase64(long l) Encodes a long to an url-safe base64 string.static booleanString.matches(String)but with a predicate.static intstatic intstatic Stringstatic StringreadUTF(arc.util.io.ByteBufferInput in) Method that suppressIOExceptionfromByteBufferInput.readUTF().static Stringrepeat(char c, int count) static StringTaken from theString.repeat(int)method of JDK 11static arc.struct.Seq<String> static arc.struct.Seq<String> static Stringstatic StringJustify string to the right.static arc.struct.Seq<String> static arc.struct.Seq<String> static Stringstatic StringJustify string to the sides.static arc.struct.Seq<String> static arc.struct.Seq<String> static arc.struct.Seq<String> tableify(arc.struct.Seq<String> lines, int width, int gap, arc.func.Func2<String, Integer, String> justifier) Create a table with givenlines.
Columns number is automatic calculated with the table'swidth.static arc.struct.Seq<String> static voidtoJson(arc.util.serialization.JsonValue object, Writer writer, arc.util.serialization.JsonWriter.OutputType outputType) Re-implementation ofJsonValue.json(JsonValue, StringBuilder, OutputType), with the ability write directly to aWriterinstead of aStringBuilder.static <T> StringtoSentence(Iterable<T> list, arc.func.Func<T, String> stringifier) Converts a list to a human readable sentence.static <T> StringtoSentence(Iterable<T> list, arc.func.Func<T, String> stringifier, String or, String and) Converts a list to a human readable sentence with configurableorandanddelimiters.static <T> voidtoSentence(StringBuilder builder, Iterable<T> list, arc.func.Cons2<StringBuilder, T> stringifier) Converts a list to a human readable sentence.static <T> voidtoSentence(StringBuilder builder, Iterable<T> list, arc.func.Cons2<StringBuilder, T> stringifier, String or, String and) Converts a list to a human readable sentence with configurableorandanddelimiters.static StringwordTruncate(String str, int length) static StringwordTruncate(String str, int length, String ellipsis) https://stackoverflow.com/a/17188686static voidMethod that suppressIOExceptionfromByteBufferOutput.writeUTF(String).Methods inherited from class arc.util.Strings
animated, autoFixed, biasedLevenshtein, bytesToHex, camelize, camelToKebab, canParseFloat, canParseInt, canParsePositiveFloat, canParsePositiveInt, capitalize, checkNewerSemver, count, count, encode, fixed, fixedBuilder, format, formatByteCount, formatMillis, getCauses, getFileExtension, getFileName, getFileNameWithoutExtension, getFinalCause, getFinalMessage, getSimpleMessage, getSimpleMessages, getStackTrace, insertSpaces, isSafeFilename, join, join, kebabToCamel, levenshtein, matches, neatError, neatError, parseColor, parseColor, parseDouble, parseFloat, parseFloat, parseInt, parseInt, parseInt, parseInt, parseLong, parseLong, parseLong, replace, replace, sanitizeFilename, sanitizeVersion, sha256, stripColors, stripGlyphs, truncate, truncate
-
Constructor Details
-
Strings
public Strings()
-
-
Method Details
-
rJust
-
rJust
-
rJust
-
rJust
-
lJust
-
lJust
-
lJust
-
lJust
-
cJust
-
cJust
-
cJust
-
cJust
-
sJust
-
sJust
-
sJust
-
sJust
-
columnify
-
columnify
@SafeVarargs public static arc.struct.Seq<String> columnify(int gap, arc.struct.Seq<String>... columns) -
columnify
@SafeVarargs public static arc.struct.Seq<String> columnify(String filler, arc.struct.Seq<String>... columns) -
columnify
@SafeVarargs public static arc.struct.Seq<String> columnify(int gap, String filler, arc.struct.Seq<String>... columns) -
columnify
-
columnify
-
tableify
-
tableify
-
tableify
-
tableify
-
isVersionAtLeast
-
isVersionAtLeast
-
compareVersion
-
compareVersion
-
kebabize
-
repeat
Taken from theString.repeat(int)method of JDK 11 -
repeat
-
maxLength
-
maxLength
-
normalize
-
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
-
jsonPrettyPrint
public static String jsonPrettyPrint(arc.util.serialization.JsonValue object, arc.util.serialization.JsonWriter.OutputType outputType) -
jsonPrettyPrint
public static void jsonPrettyPrint(arc.util.serialization.JsonValue object, Writer writer, arc.util.serialization.JsonWriter.OutputType outputType) throws IOException - Throws:
IOException
-
jsonPrettyPrint
public static void jsonPrettyPrint(arc.util.serialization.JsonValue object, Writer writer, arc.util.serialization.JsonWriter.OutputType outputType, int indent) throws IOException Re-implementation ofJsonValue.prettyPrint(OutputType, Writer), because the ident isn't correct and the max object size before new line is too big.- Throws:
IOException
-
toJson
public static void toJson(arc.util.serialization.JsonValue object, Writer writer, arc.util.serialization.JsonWriter.OutputType outputType) throws IOException Re-implementation ofJsonValue.json(JsonValue, StringBuilder, OutputType), with the ability write directly to aWriterinstead of aStringBuilder.- Throws:
IOException
-
format
LikeStrings.format(String, Object[])but you can specify theStringBuilder. -
join
LikeString.join(CharSequence, CharSequence[])but you can specify the start and end of the list. -
toSentence
-
toSentence
-
toSentence
public static <T> void toSentence(StringBuilder builder, Iterable<T> list, arc.func.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, arc.func.Cons2<StringBuilder, T> stringifier, String or, String and) Converts a list to a human readable sentence with configurableorandanddelimiters. -
contains
String.contains(CharSequence)but with a predicate. -
matches
String.matches(String)but with a predicate. -
longToBase64
Encodes a long to an url-safe base64 string. -
base64ToLong
-
readUTF
Method that suppressIOExceptionfromByteBufferInput.readUTF(). -
writeUTF
Method that suppressIOExceptionfromByteBufferOutput.writeUTF(String). -
formattedClassName
-
formatBytes
-
formatSize
-
formatDuration
Convertmillisduration to localized human readable format (e.g. 123456 -> 2 minutes and 3 seconds), using the logger system.- Parameters:
millis- milliseconds to convert to durationnarrow- use short units or not. E.g. "5 months" iffalse, "5mo" iftrue
-
wordTruncate
-
wordTruncate
-