public class CharSeq
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
CharSeq |
capitalize()
Returns a copy of CharSeq with the string's first character
converted to uppercase and the remainder to lowercase.
|
java.lang.Character |
charAt(int i)
Return the Character at the index i of this CharSeq
|
int |
compareTo(CharSeq another)
Compares two CharSeqs lexicographically.
|
int |
compareToIgnoreCase(CharSeq another)
Compares two CharSeqs lexicographically ignore case differences.
|
CharSeq |
concat(CharSeq another)
Append string of the given CharSeq to this CharSeq
|
CharSeq |
concat(java.lang.String another)
Append the given string to this CharSeq
|
boolean |
containsSubSeq(CharSeq seq)
Check whether this CharSeq contains the sub seq, if the given seq is empty, always return true.
|
boolean |
containsSubSeq(java.lang.String seq)
Check whether this CharSeq contains the sub seq, if the given seq is empty, always return true.
|
Seq<java.lang.Byte> |
eachByte()
Encodes this
CharSeq into a sequence of bytes using the
platform's default charset, storing the result into a new Byte Seq. |
Seq<java.lang.Character> |
eachChar()
Converts this CharSeq to a new Character Seq.
|
Seq<java.lang.Integer> |
eachCodePoint()
Returns the collection of the Unicode of each character in this
CharSeq. |
Seq<CharSeq> |
eachLine()
Split the CharSeq by the newline character and return the
result as a Seq of CharSeq.
|
boolean |
endsWith(CharSeq suffix)
Tests whether this CharSeq ends with the specified suffix
|
boolean |
endsWith(java.lang.String suffix)
Tests whether this CharSeq ends with the specified suffix
|
boolean |
equals(java.lang.Object another) |
CharSeq |
forEachByte(java.util.function.BiConsumer<java.lang.Byte,java.lang.Integer> action)
Performs the given action for each byte of the CharSeq,
with additional parameter "index" as the second parameter.
|
CharSeq |
forEachByte(java.util.function.Consumer<java.lang.Byte> action)
Performs the given action for each byte of the CharSeq.
|
CharSeq |
forEachChar(java.util.function.BiConsumer<java.lang.Character,java.lang.Integer> action)
Performs the given action for each character of the CharSeq,
with additional parameter "index" as the second parameter.
|
CharSeq |
forEachChar(java.util.function.Consumer<java.lang.Character> action)
Performs the given action for each character of the CharSeq.
|
CharSeq |
forEachCodePoint(java.util.function.Consumer<java.lang.Integer> consumer)
Takes action on the Unicode of each character in this
CharSeq. |
CharSeq |
forEachLine(java.util.function.BiConsumer<CharSeq,java.lang.Integer> action)
Performs the given action for each line of the CharSeq,
with additional parameter "index" as the second parameter.
|
CharSeq |
forEachLine(java.util.function.Consumer<CharSeq> action)
Performs the given action for each line of the CharSeq.
|
int |
indexOfSubSeq(CharSeq seq)
Return the first index of the given sub seq, or -1 if the given seq is not a sub seq.
|
int |
indexOfSubSeq(java.lang.String seq)
Return the first index of the given sub seq, or -1 if the given seq is not a sub seq.
|
boolean |
isEmpty()
|
int |
lastIndexOfSubSeq(CharSeq seq)
Return the last index of the given sub seq, or -1 if the given seq is not a sub seq.
|
int |
lastIndexOfSubSeq(java.lang.String seq)
Return the last index of the given sub seq, or -1 if the given seq is not a sub seq.
|
int |
length()
Returns the length of string of this CharSeq.
|
boolean |
matches(java.lang.String regex)
Tells whether or not this CharSeq matches the given regular expression.
|
static CharSeq |
of(char[] charArr)
Construct a new CharSeq with the given char array
|
static CharSeq |
of(java.lang.String str)
Construct a new CharSeq with the given string
|
Seq<CharSeq> |
partition(java.lang.String regex)
Searches pattern (regex) in the CharSeq and returns
a Seq of CharSeq consists of the part before it,
the first match, and the part after it.
|
CharSeq |
prepend(CharSeq another)
Prepend string of the given CharSeq to this CharSeq
|
CharSeq |
prepend(java.lang.String another)
Prepend the given string to this CharSeq
|
CharSeq |
replaceAll(java.lang.String regex,
CharSeq replacement)
Return a new CharSeq by replacing each substring of this
CharSeq that matches the given regular expression with
the given CharSeq replacement.
|
CharSeq |
replaceAll(java.lang.String regex,
java.lang.String replacement)
Return a new CharSeq by replacing each substring of this
CharSeq that matches the given regular expression with
the given String replacement.
|
CharSeq |
replaceFirst(java.lang.String regex,
CharSeq replacement)
Return a new CharSeq by replacing the first substring of this CharSeq
that matches the given regular expression with the given CharSeq replacement.
|
CharSeq |
replaceFirst(java.lang.String regex,
java.lang.String replacement)
Return a new CharSeq by replacing the first substring of this CharSeq
that matches the given regular expression with the given String replacement.
|
CharSeq |
reverse()
Return a new CharSeq with the characters from
this CharSeq in reverse order.
|
Seq<CharSeq> |
rPartition(java.lang.String regex)
Searches pattern (regex) in the CharSeq and returns
a Seq of CharSeq consists of the part before it,
the last match, and the part after it.
|
Seq<CharSeq> |
scan(java.lang.String regex)
Scan through this CharSeq iteratively, generate a Seq of CharSeq
with all the matching subStrings.
|
Seq<CharSeq> |
split(java.lang.String regex)
Splits this CharSeq around matches of the given regular expression.
|
boolean |
startsWith(CharSeq prefix)
Tests whether this CharSeq starts with the specified prefix
|
CharSeq |
subSeq(int fromIndex)
Returns a CharSeq that contains a substring of this CharSeq's string.
|
CharSeq |
subSeq(int fromIndex,
int toIndex)
Returns a CharSeq that contains a substring of this CharSeq's string.
|
CharSeq |
swapcase()
Return a new CharSeq with all characters' cases toggled.
|
CharSeq |
toLowerCase()
Returns a copy of this CharSeq with characters all
converted to lowercase.
|
java.lang.String |
toString() |
CharSeq |
toUpperCase()
Returns a copy of CharSeq with the string's characters all
converted to uppercase.
|
CharSeq |
trim()
Returns a CharSeq whose value is this CharSeq, with any leading and trailing
whitespace removed.
|
public CharSeq subSeq(int fromIndex, int toIndex)
beginIndex and
extends to the character at index endIndex - 1.
Thus the length of the substring is endIndex-beginIndex.
Examples:
CharSeq.of("hamburger").subSeq(4, 8) returns CharSeq.of("urge")
CharSeq.of("smiles").subSeq(1, 5) returns CharSeq.of("mile")
fromIndex - the beginning index, inclusive.toIndex - the ending index, exclusive.public CharSeq subSeq(int fromIndex)
beginIndex and
extends to the end of this string.
Examples:
CharSeq.of("unhappy").subSeq(2) returns CharSeq.of("happy")
CharSeq.of("Harbison").subSeq(3) returns CharSeq.of("bison")
fromIndex - the beginning index, inclusive.public CharSeq concat(CharSeq another)
another - the given CharSeqpublic CharSeq concat(java.lang.String another)
another - the given stringpublic CharSeq prepend(CharSeq another)
another - the given stringpublic CharSeq prepend(java.lang.String another)
another - the given stringpublic int length()
public boolean isEmpty()
true if length() is 0, otherwise
falsepublic CharSeq capitalize()
public CharSeq toUpperCase()
public CharSeq toLowerCase()
public Seq<CharSeq> split(java.lang.String regex)
regex - Regular expressionpublic static CharSeq of(java.lang.String str)
str - the given stringpublic static CharSeq of(char[] charArr)
charArr - the given char arraypublic CharSeq reverse()
Examples:
CharSeq.of("stressed").reverse() returns CharSeq.of("desserts")
public CharSeq swapcase()
Examples:
CharSeq.of("sTrEsSed").swapcase() returns CharSeq.of("StReSsED")
public boolean endsWith(CharSeq suffix)
suffix - suffixpublic boolean endsWith(java.lang.String suffix)
suffix - suffixpublic boolean startsWith(CharSeq prefix)
prefix - prefixpublic java.lang.Character charAt(int i)
i - the indexpublic CharSeq trim()
public Seq<CharSeq> scan(java.lang.String regex)
regex - The regular expressionpublic CharSeq forEachChar(java.util.function.Consumer<java.lang.Character> action)
action - Consumer with single parameter of Characterpublic CharSeq forEachChar(java.util.function.BiConsumer<java.lang.Character,java.lang.Integer> action)
action - BiConsumer with parameters of Character and the indexpublic CharSeq forEachByte(java.util.function.Consumer<java.lang.Byte> action)
action - Consumer with single parameter of Bytepublic CharSeq forEachByte(java.util.function.BiConsumer<java.lang.Byte,java.lang.Integer> action)
action - BiConsumer with parameters of Byte and the indexpublic CharSeq forEachLine(java.util.function.Consumer<CharSeq> action)
action - Consumer with single parameter of CharSeqpublic CharSeq forEachLine(java.util.function.BiConsumer<CharSeq,java.lang.Integer> action)
action - BiConsumer with parameters of CharSeq and the indexpublic Seq<CharSeq> eachLine()
public boolean matches(java.lang.String regex)
public CharSeq replaceFirst(java.lang.String regex, CharSeq replacement)
regex - The regular expressionreplacement - The replacement CharSeqpublic CharSeq replaceFirst(java.lang.String regex, java.lang.String replacement)
regex - The regular expressionreplacement - The replacement Stringpublic CharSeq replaceAll(java.lang.String regex, CharSeq replacement)
regex - The regular expressionreplacement - The replacement CharSeqpublic CharSeq replaceAll(java.lang.String regex, java.lang.String replacement)
regex - The regular expressionreplacement - The replacement Stringpublic boolean equals(java.lang.Object another)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic int compareTo(CharSeq another)
0 if the argument CharSeq is equal to
this CharSeq; a value less than 0 if this CharSeq
is lexicographically less than the CharSeq argument; and a
value greater than 0 if this CharSeq is
lexicographically greater than the CharSeq argument.public int compareToIgnoreCase(CharSeq another)
public Seq<CharSeq> partition(java.lang.String regex)
If no such match is found in this CharSeq, return a Seq of CharSeq consists two empty CharSeqs and the CharSeq itself.
regex - Regular Expressionpublic Seq<CharSeq> rPartition(java.lang.String regex)
If no such match is found in this CharSeq, return a Seq of CharSeq consists of two empty CharSeqs and the CharSeq itself.
regex - Regular Expressionpublic Seq<java.lang.Character> eachChar()
public Seq<java.lang.Byte> eachByte()
CharSeq into a sequence of bytes using the
platform's default charset, storing the result into a new Byte Seq.public Seq<java.lang.Integer> eachCodePoint()
CharSeq.public CharSeq forEachCodePoint(java.util.function.Consumer<java.lang.Integer> consumer)
CharSeq.
Similar to eachCodePoint(), but instead of returning the Unicode collection, it iterates the collection and takes action.
consumer - the action to be taken on the Unicode of each characterjava.lang.NullPointerException - if consumer is nullpublic boolean containsSubSeq(java.lang.String seq)
java.lang.NullPointerException - if seq is nullpublic int indexOfSubSeq(java.lang.String seq)
java.lang.NullPointerException - if seq is nullpublic int lastIndexOfSubSeq(java.lang.String seq)
java.lang.NullPointerException - if seq is nullpublic boolean containsSubSeq(CharSeq seq)
java.lang.NullPointerException - if seq is nullpublic int indexOfSubSeq(CharSeq seq)
java.lang.NullPointerException - if seq is nullpublic int lastIndexOfSubSeq(CharSeq seq)
java.lang.NullPointerException - if seq is null