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 int
characterAt
(CharSequence cseq, int index) Get character (code point) at a offset.static int
characterAt
(CharSequence cseq, int start, int end, int index) Get character (code point) at a offset.static int
compareTo
(CharSequence str1, CharSequence str2) static void
copyInto
(CharSequence src, int start, int end, CharSeq dst, int at) static String
fromUtf8
(byte[] bytes, int start, int length) static int
indexByCodePoints
(CharSequence str, int index) Get index'th character (code point).static IString
indirectIndexed
(CharSequence base, IntSequence indexes) Make a read-only substring, generalized to arbitrary index sequences.static void
makeCapitalize
(CharSeq str) Capitalize this string.static void
makeLowerCase
(CharSeq str) Change every character to be lowercase.static void
makeUpperCase
(CharSeq str) Change every character to be uppercase.static int
offsetByCodePoints
(CharSequence str, int offset, int cuStart, int cpStart) Like offsetByCodePoints, but optimize if an IString.static void
printJson
(CharSequence str, Appendable ps) static void
printQuoted
(CharSequence str, Appendable ps, int escapes) Print a string with quotes and escapes.static String
replicate
(int from, int to, boolean suppliedTo, CharSequence string, int start, int end, boolean suppliedEnd) static int
static CharSequence
substring
(CharSequence base, int start, int end) Make a read-only substring.static String
toJson
(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)
-