Package gnu.lists
Class Strings
java.lang.Object
gnu.lists.Strings
Various static utility methods for general strings (CharSeqs).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcharacterAt(CharSequence cseq, int index) Get character (code point) at a offset.static intcharacterAt(CharSequence cseq, int start, int end, int index) Get character (code point) at a offset.static intcompareTo(CharSequence str1, CharSequence str2) static voidcopyInto(CharSequence src, int start, int end, CharSeq dst, int at) static StringfromUtf8(byte[] bytes, int start, int length) static intindexByCodePoints(CharSequence str, int index) Get index'th character (code point).static IStringindirectIndexed(CharSequence base, IntSequence indexes) Make a read-only substring, generalized to arbitrary index sequences.static voidmakeCapitalize(CharSeq str) Capitalize this string.static voidmakeLowerCase(CharSeq str) Change every character to be lowercase.static voidmakeUpperCase(CharSeq str) Change every character to be uppercase.static intoffsetByCodePoints(CharSequence str, int offset, int cuStart, int cpStart) Like offsetByCodePoints, but optimize if an IString.static voidprintJson(CharSequence str, Appendable ps) static voidprintQuoted(CharSequence str, Appendable ps, int escapes) Print a string with quotes and escapes.static Stringreplicate(int from, int to, boolean suppliedTo, CharSequence string, int start, int end, boolean suppliedEnd) static intstatic CharSequencesubstring(CharSequence base, int start, int end) Make a read-only substring.static StringtoJson(CharSequence str) static byte[]toUtf16(CharSequence str, int start, int end, boolean bigEndian, boolean writeBOM)
-
Constructor Details
-
Strings
public Strings()
-
-
Method Details
-
characterAt
Get character (code point) at a offset.- Parameters:
index- offset measured in 16-bit code units
-
characterAt
Get character (code point) at a offset.- Parameters:
index- offset measured in 16-bit code units, from begining of cseq, not frm start
-
indexByCodePoints
Get index'th character (code point).- Parameters:
index- offset by code points
-
offsetByCodePoints
Like offsetByCodePoints, but optimize if an IString.- Parameters:
offset- number of code points beyond start index.cuStart- start index in code units (Java chars)cpStart- start index in Unicode code points
-
sizeInCodePoints
-
makeUpperCase
Change every character to be uppercase. -
makeLowerCase
Change every character to be lowercase. -
makeCapitalize
Capitalize this string. Change first character of each word to titlecase, and change the other characters to lowercase. -
toJson
-
printJson
-
printQuoted
Print a string with quotes and escapes.- Parameters:
escapes- The value 0 means only escape '"' and '\\'; the value 1 means escape standard escape characters like '\\b'; the value 2 means escape all non-ascii or control characters; the value 3 means follow the JSON standard.
-
copyInto
-
indirectIndexed
Make a read-only substring, generalized to arbitrary index sequences. The indexes are in terms of code points (character) offsets. -
substring
Make a read-only substring. The start and end are in terms of code unit (16-bit char). -
fromUtf8
-
toUtf16
public static byte[] toUtf16(CharSequence str, int start, int end, boolean bigEndian, boolean writeBOM) -
compareTo
-
replicate
public static String replicate(int from, int to, boolean suppliedTo, CharSequence string, int start, int end, boolean suppliedEnd)
-