T - the implementation class typepublic abstract class StrBase<T extends StrBase<T>> extends ListBase<Character> implements RandomAccess, CharSequence, Serializable, Comparable<T>
The abstract base class for Str and FastStr. This class aggregates methods from both CharSequence and C.List to provide easy manipulation and also functional programming facilities to char sequence
| Modifier and Type | Class and Description |
|---|---|
static class |
StrBase.F |
C.List.Cursor<T>C.Featured.FactorymodCount| Modifier | Constructor and Description |
|---|---|
protected |
StrBase() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
_empty()
Check if the str is empty
|
protected abstract Class<T> |
_impl()
Return the class of the implementation
|
T |
accept(Lang.Visitor<? super Character> visitor)
Iterate this
Traversable with a visitor function. |
T |
acceptLeft(Lang.Visitor<? super Character> visitor)
Iterate through this sequence from head to tail with the visitor function specified
|
T |
acceptRight(Lang.Visitor<? super Character> visitor)
Iterate through this sequence from tail to head with the visitor function specified
|
void |
add(int index,
Character element) |
T |
after(String s) |
T |
after(T s) |
abstract T |
afterFirst(char c) |
abstract T |
afterFirst(String s) |
abstract T |
afterFirst(T s) |
abstract T |
afterLast(char c) |
abstract T |
afterLast(String s) |
abstract T |
afterLast(T characters) |
abstract T |
append(C.List<Character> list)
Return a str instance contains all characters of this str instance append with all characters in the list specified
|
abstract T |
append(char... array)
Return a str instance contains all characters of this str instance append with all characters in the array specified
|
abstract T |
append(Character character)
Returns a str instance contains all characters of this str instance appended with the character specified
|
abstract T |
append(Collection<? extends Character> collection)
Return a str instance contains all characters of this str append with all characters in the collection specified
|
abstract T |
append(String s)
Returns a str instance contains all characters of this str instance appended with all characters in the
String specified |
abstract T |
append(T s)
Returns a str instance contains all characters of this str instance appended with all characters in teh str specified
|
T |
before(String s) |
T |
before(T s) |
abstract T |
beforeFirst(char c) |
abstract T |
beforeFirst(String s) |
abstract T |
beforeFirst(T s) |
abstract T |
beforeLast(char c) |
abstract T |
beforeLast(String s) |
abstract T |
beforeLast(T s) |
abstract T |
capFirst() |
abstract char[] |
charArray() |
abstract int |
compareTo(CharSequence x)
Compare the char sequence specified against this str
|
abstract int |
compareToIgnoreCase(CharSequence x)
Compare the char sequence specified against this str in a case insensitive manner
|
abstract int |
compareToIgnoreCase(T x)
Compare the str specified against this str in a case insensitive manner
|
T |
concat(String str) |
T |
concat(T str) |
boolean |
contains(char c) |
abstract boolean |
contains(CharSequence s) |
abstract boolean |
contentEquals(CharSequence chars)
Check if this str content is equals to the char sequence specified
|
boolean |
contentEquals(StringBuffer stringBuffer)
Wrapper of
String.contentEquals(StringBuffer) |
abstract boolean |
contentEquals(T str)
Check if this str content iks equals to the str specified
|
T |
copy()
Returns a copy of this str.
|
void |
copy(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin) |
int |
count(String s) |
abstract int |
count(String search,
boolean overlap) |
int |
count(T s) |
abstract int |
count(T search,
boolean overlap) |
int |
countWithOverlap(String s) |
int |
countWithOverlap(T s) |
T |
cutOff(int max) |
abstract T |
decodeBASE64() |
T |
drop(int n)
Returns a
Sequence consisting of the elements from this Sequence except the first n if number n is positive and the Sequence contains more than n elements |
abstract T |
dropWhile(Lang.Function<? super Character,Boolean> predicate)
Return a str that without the first N characters in the string.
|
T |
eager()
Returns this traversable and make sure
C.Feature.LAZY is unset |
boolean |
empty() |
abstract T |
encodeBASE64() |
boolean |
endsWith(CharSequence prefix)
Check if this str ends with the given char sequence
|
abstract boolean |
endsWith(CharSequence prefix,
int toffset)
Check if this str ends with a char sequence, with the search starts at the specified offset
|
boolean |
endsWith(T prefix)
Check if this str ends with the given str
|
abstract boolean |
endsWith(T prefix,
int toffset)
Check this str instance ends with str, with the search starts at specified offset
|
boolean |
eq(CharSequence x)
Alias of
contentEquals(CharSequence) |
boolean |
eq(StringBuffer stringBuffer)
Alias of
contentEquals(StringBuffer) |
boolean |
eq(T x)
Alias of
contentEquals(StrBase) |
boolean |
equals(Object o) |
abstract boolean |
equalsIgnoreCase(CharSequence x)
Compare content of the str and the specified char sequence, case insensitive
|
T |
filter(Lang.Function<? super Character,Boolean> predicate)
Returns an new traversable that contains all elements in the current traversable except that does not pass the test of the filter function specified.
|
<R> C.List<R> |
flatMap(Lang.Function<? super Character,? extends Iterable<? extends R>> mapper)
Returns a traversable consisting of the results of replacing each element of this stream with the contents of the iterable produced by applying the provided mapping function to each element.
|
Character |
get(int index) |
abstract byte[] |
getBytes()
Encodes this str into a sequence of bytes using the platform’s default charset, storing the result into a new byte array.
|
abstract byte[] |
getBytes(Charset charset)
Encodes this str into a sequence of bytes using the given charset, storing the result into a new byte array.
|
abstract byte[] |
getBytes(String charsetName)
Encodes this str into a sequence of bytes using the named charset, storing the result into a new byte array.
|
abstract byte[] |
getBytesAscII()
Returns byte array of string composed of only ascii chars
|
abstract byte[] |
getBytesUTF8()
Returns byte array of string composed of UTF-8 chars
|
abstract void |
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Copy part of the char sequence into another array
|
T |
head(int n)
Alias of
C.Sequence.take(int) |
int |
indexOf(CharSequence str)
Returns the index within this str of the first occurrence of the specified substring, starting at 0.
|
abstract int |
indexOf(CharSequence str,
int fromIndex)
Returns the index within this str of the first occurrence of the specified substring, starting at the specified index.
|
int |
indexOf(int ch)
Returns the index within this str of the first occurrence of the specified character.
|
abstract int |
indexOf(int ch,
int fromIndex)
Returns the index within this str of the first occurrence of the specified character.
|
int |
indexOf(List<Character> list)
Returns the index within this str of the first occurrence of the specified character list
|
int |
indexOf(List<Character> list,
int startIndex)
Returns the index within this str of the first occurrence of the specified character list, starting at the specified index
|
int |
indexOf(Object o)
Returns the index within this str of the first occurrence of the specified object.
|
int |
indexOf(T x)
Locate another str inside this str, start at the specified index
|
abstract int |
indexOf(T s,
int fromIndex)
Locate another str inside this str, start at the specified index
|
protected EnumSet<C.Feature> |
initFeatures()
Sub class should override this method to provide initial feature set for the feature based instance
|
abstract T |
insert(int index,
char... ta)
Return a new str with character array inserted into the char sequence of this str
|
abstract T |
insert(int index,
char character)
Return a new str with character inserted into the char sequence of this str
|
abstract T |
insert(int index,
Character... ca)
Return a new str with character array inserted into the char sequence of this str
|
abstract T |
insert(int index,
Character character)
Return a new str with character inserted into the char sequence of this str
|
abstract T |
insert(int index,
StrBase<?> str)
Returns a new str with a string specified inserted into the char sequence of this str
|
abstract T |
insert(int index,
String s)
Returns a new str with a string specified inserted into the char sequence of this str
|
abstract String |
intern() |
abstract boolean |
isBlank()
Check if this str is blank (empty or all space characters)
|
int |
lastIndexOf(CharSequence str)
Returns the index within this str of the last occurrence of the specified substring.
|
abstract int |
lastIndexOf(CharSequence str,
int fromIndex)
Returns the index within this str of the last occurrence of the specified substring, searching backward starting at the specified index.
|
int |
lastIndexOf(int ch)
Returns the index within this str of the last occurrence of the specified character.
|
abstract int |
lastIndexOf(int ch,
int fromIndex)
Returns the index within this str of the last occurrence of the specified character, searching backward starting at the specified index.
|
int |
lastIndexOf(List<Character> list)
Returns the index within this str of the last occurrence of the specified character list
|
int |
lastIndexOf(List<Character> list,
int startIndex)
Returns the index within this str of the last occurrence of the specified character list, starting at the specified index from tail to head
|
int |
lastIndexOf(Object o)
Returns the index within this str of the last occurrence of the specified object.
|
int |
lastIndexOf(T str)
Returns the index within this str of the last occurrence of the specified substr.
|
abstract int |
lastIndexOf(T str,
int fromIndex)
Returns the index within this str of the last occurrence of the specified str, searching backward starting at the specified index.
|
T |
lazy()
Returns this traversable and make sure
C.Feature.LAZY is set |
ListIterator<Character> |
listIterator(int index) |
T |
lower() |
T |
lower(Locale locale) |
abstract T |
lpad(char c,
int times)
Alias of
padLeft(char, int) |
abstract T |
lpad(int times)
Alias of
padLeft(int) |
<R> C.List<R> |
map(Lang.Function<? super Character,? extends R> mapper)
Returns an new traversable with a mapper function specified.
|
abstract boolean |
matches(String regex)
Tells whether or not this str matches the given regular expression.
|
T |
maxLength(int max) |
boolean |
notEmpty() |
abstract T |
padLeft(char c,
int times)
Returns a str instance with
times of char c left pad to the current str |
abstract T |
padLeft(int times)
Returns a str instance with
times of char ' ' (space) left pad to the current str |
abstract T |
padRight(char c,
int times)
Returns a str instance with
times of char c right pad to the current str |
abstract T |
padRight(int times)
Returns a str instance with
times of char ' ' (space) right pad to the current str |
T |
parallel()
Returns this traversable and make sure
C.Feature.PARALLEL is set |
int |
pos(CharSequence x)
Alias of
indexOf(CharSequence) |
int |
pos(CharSequence x,
int fromIndex)
Alias of
indexOf(CharSequence, int) |
int |
pos(int ch)
Alias of
indexOf(int) |
int |
pos(int ch,
int fromIndex)
Alias of
indexOf(int, int) |
int |
pos(T x)
Alias of
indexOf(StrBase) |
int |
pos(T x,
int fromIndex)
Alias of
indexOf(StrBase, int) |
abstract T |
prepend(C.List<Character> list)
Return a str instance contains all characters of this str instance prepended with all characters in the list specified
|
abstract T |
prepend(char... chars)
Return a str instance contains all characters of this str instance prepended with all characters in the array specified
|
abstract T |
prepend(Character character)
Returns a str instance contains all characters of this str instance prepended with the character specified
|
abstract T |
prepend(Collection<? extends Character> collection)
Returns a str instance contains all characters of this str instance prepended with all characters in teh collection
|
abstract T |
prepend(String s)
Returns a str instance contains all characters of this str instance prepended with all characters in the
String specified |
abstract T |
prepend(T s)
Returns a str instance contains all characters of this str instance prepended with all characters in the str specified
|
T |
readOnly()
Returns a view of this list that is readonly.
|
abstract boolean |
regionMatches(boolean ignoreCase,
int toffset,
CharSequence other,
int ooffset,
int len)
Tests if two string regions are equal.
|
abstract boolean |
regionMatches(boolean ignoreCase,
int toffset,
T other,
int ooffset,
int len)
Tests if two string regions are equal.
|
boolean |
regionMatches(int toffset,
String other,
int ooffset,
int len) |
boolean |
regionMatches(int toffset,
T other,
int ooffset,
int len) |
Character |
remove(int index) |
abstract T |
remove(Lang.Function<? super Character,Boolean> predicate)
Returns a str that with all characters in this str instance except those matches the test of predicate function specified
|
abstract T |
replace(char oldChar,
char newChar)
Returns a new str resulting from replacing all occurrences of
oldChar in this string with newChar. |
abstract T |
replace(CharSequence target,
CharSequence replacement)
Replaces each substring of this str that matches the literal target sequence with the specified literal replacement sequence.
|
abstract T |
replaceAll(String regex,
String replacement)
Replaces each substr of this str that matches the given regular expression with the given replacement.
|
abstract T |
replaceFirst(String regex,
String replacement)
Replaces the first substring of this str that matches the given regular expression with the given replacement.
|
abstract T |
reverse()
Returns a str that contains all characters in this str instance but in a reversed order.
|
abstract T |
rpad(char c,
int times)
Alias of
padRight(char, int) |
abstract T |
rpad(int times)
Alias of
padRight(int) |
int |
rpos(CharSequence str)
alias of
lastIndexOf(CharSequence) |
int |
rpos(CharSequence str,
int fromIndex)
alias of
lastIndexOf(CharSequence, int) |
int |
rpos(int ch)
Alias of
lastIndexOf(int) |
int |
rpos(int ch,
int fromIndex)
Alias of
lastIndexOf(int, int) |
int |
rpos(T x)
alias of
lastIndexOf(StrBase) |
int |
rpos(T str,
int fromIndex)
alias of
lastIndexOf(StrBase, int) |
Character |
set(int index,
Character element) |
protected T |
setFeature(C.Feature feature) |
int |
size()
Return the size of this traversal
|
T |
snapshot()
Returns an immutable list contains all elements of the current list.
|
C.List<T> |
split(String regex) |
abstract C.List<T> |
split(String regex,
int limit) |
boolean |
startsWith(CharSequence prefix)
Check if this str starts with the given char sequence
|
abstract boolean |
startsWith(CharSequence prefix,
int toffset)
Check if this str starts with a char sequence, with the search starts at the specified offset
|
boolean |
startsWith(T prefix)
Check if this str starts with the given str
|
abstract boolean |
startsWith(T prefix,
int toffset)
Check this str instance starts with str, with the search starts at specified offset
|
abstract T |
strip(String prefix,
String suffix) |
abstract T |
subList(int fromIndex,
int toIndex)
Returns a sub str that is a part of this str
|
abstract T |
subSequence(int start,
int end)
Return a part of this str specified by start inclusive and end exclusive position.
|
T |
substr(int beginIndex)
Synonym of
substring(int) but return Str instead of String |
T |
substr(int beginIndex,
int endIndex) |
abstract String |
substring(int beginIndex)
Return a sub string of type
String of this str starts from beginIndex specified till the end of the char array of this str |
abstract String |
substring(int beginIndex,
int endIndex)
Returns a new string that is a substring of this str.
|
T |
tail()
Returns the rest part of the
Sequence except the first element |
T |
tail(int n)
Returns a
Sequence consisting the last n elements from this Sequence if number n is positive and the Sequence contains more than n elements |
T |
take(int n)
Returns a
Sequence consisting the first n elements from this Sequence if number n is positive and the Sequence contains more than n elements |
abstract T |
takeWhile(Lang.Function<? super Character,Boolean> predicate)
Return a str that contains the first N characters in this string, the characters in the new str must matches the test specified by the predicate function.
|
abstract T |
times(int n)
Returns a str instance that repeat this str’s char sequence for
n times |
char[] |
toCharArray()
Wrapper of
String.toCharArray() |
abstract FastStr |
toFastStr()
Return a
FastStr that contains all the char sequence in this str instance |
T |
toLowerCase() |
abstract T |
toLowerCase(Locale locale) |
T |
toUpperCase() |
abstract T |
toUpperCase(Locale locale) |
abstract T |
trim() |
protected T |
unsetFeature(C.Feature feature) |
T |
upper() |
T |
upper(Locale locale) |
abstract T |
urlEncode() |
String |
val() |
String |
value() |
accept, acceptLeft, acceptRight, add, addAll, allMatch, anyMatch, append, append, append, append, append, appendList, appendReversibleSeq, asList, collect, count, each, each, features_, features, findFirst, findLast, findOne, first, forEach, forEach, forEachLeft, forEachLeft, forEachRight, forEachRight, hashCode, head, insert, is, isImmutable, isLazy, isMutable, isReadOnly, iterator, last, locate, locateFirst, locateLast, noneMatch, prepend, prepend, prepend, prepend, prepend, prependList, prependReversibleSeq, reduce, reduce, reduceLeft, reduceLeft, reduceRight, reduceRight, reverseIterator, sequential, sorted, sorted, split, toMap, toMapByKey, toMapByVal, unique, unique, without, without, without, zip, zip, zip, zipAll, zipAll, zipAll, zipWithIndexaddAll, clear, listIterator, removeRangeaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcharAt, chars, codePoints, length, toStringcompareToaddAll, addAll, clear, contains, containsAll, isEmpty, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayparallelStream, removeIf, streamisEmptyprotected abstract Class<T> _impl()
Return the class of the implementation
protected abstract T _empty()
Check if the str is empty
true if the str is emptypublic abstract T subList(int fromIndex, int toIndex) throws StringIndexOutOfBoundsException
Returns a sub str that is a part of this str
subList in interface List<Character>subList in interface C.List<Character>subList in class ListBase<Character>fromIndex - the from (inclusive)toIndex - the to (exclusive)fromIndex and end at (@code toIndex)StringIndexOutOfBoundsException - if fromIndex is lesser than 0 or greater than or equals to size() of the strsubSequence(int, int),
substr(int, int)public abstract T insert(int index, char character) throws StringIndexOutOfBoundsException
Return a new str with character inserted into the char sequence of this str
index - the position to insert the charactercharacter - the char to be insertedStringIndexOutOfBoundsException - if index is lesser than 0 or greater than or equals to size() of the strpublic abstract T insert(int index, Character character) throws StringIndexOutOfBoundsException
Return a new str with character inserted into the char sequence of this str
insert in interface C.List<Character>insert in class ListBase<Character>index - the position to insert the charactercharacter - the char to be insertedStringIndexOutOfBoundsException - if index is lesser than 0 or greater than or equals to size() of the strpublic abstract T insert(int index, Character... ca) throws StringIndexOutOfBoundsException
Return a new str with character array inserted into the char sequence of this str
insert in interface C.List<Character>insert in class ListBase<Character>index - the position to insert the characterca - the char array to be insertedStringIndexOutOfBoundsException - if index is lesser than 0 or greater than or equals to size() of the strpublic abstract T insert(int index, char... ta) throws StringIndexOutOfBoundsException
Return a new str with character array inserted into the char sequence of this str
index - the position to insert the characterta - the char array to be insertedStringIndexOutOfBoundsException - if index is lesser than 0 or greater than or equals to size() of the strpublic abstract T insert(int index, StrBase<?> str) throws StringIndexOutOfBoundsException
Returns a new str with a string specified inserted into the char sequence of this str
index - the position to insert the stringstr - the str to be insertedStringIndexOutOfBoundsException - if index is lesser than 0 or greater than or equals to size() of the strpublic abstract T insert(int index, String s) throws StringIndexOutOfBoundsException
Returns a new str with a string specified inserted into the char sequence of this str
index - the position to insert the strings - the string to be insertedStringIndexOutOfBoundsException - if index is lesser than 0 or greater than or equals to size() of the strpublic abstract T remove(Lang.Function<? super Character,Boolean> predicate)
Returns a str that with all characters in this str instance except those matches the test of predicate function specified
public abstract T takeWhile(Lang.Function<? super Character,Boolean> predicate)
Return a str that contains the first N characters in this string, the characters in the new str must matches the test specified by the predicate function. The match operation stop at the first character that does not match the predicate
takeWhile in interface C.List<Character>takeWhile in interface C.ReversibleSequence<Character>takeWhile in interface C.Sequence<Character>takeWhile in class ListBase<Character>predicate - test if the character should be put into the new str or should stop matchingpublic abstract T dropWhile(Lang.Function<? super Character,Boolean> predicate)
Return a str that without the first N characters in the string. The characters been dropped must matches the test specified by teh predicate function. The match operation stop at the first character that matches the predicate
dropWhile in interface C.List<Character>dropWhile in interface C.ReversibleSequence<Character>dropWhile in interface C.Sequence<Character>dropWhile in class ListBase<Character>predicate - the function test if character should be dropped in the new str or stop match operationpublic abstract T reverse()
Returns a str that contains all characters in this str instance but in a reversed order.
reverse in interface C.List<Character>reverse in interface C.ReversibleSequence<Character>reverse in class ListBase<Character>C.Feature.LIMITED,
C.Featured.is(org.osgl.util.C.Feature)public abstract T append(Collection<? extends Character> collection)
Return a str instance contains all characters of this str append with all characters in the collection specified
public abstract T append(C.List<Character> list)
Return a str instance contains all characters of this str instance append with all characters in the list specified
public abstract T append(char... array)
Return a str instance contains all characters of this str instance append with all characters in the array specified
array - the array of characters to be appendedpublic abstract T append(Character character)
Returns a str instance contains all characters of this str instance appended with the character specified
append in interface C.List<Character>append in interface C.ReversibleSequence<Character>append in interface C.Sequence<Character>append in class ListBase<Character>character - the character to be appendedpublic abstract T append(T s)
Returns a str instance contains all characters of this str instance appended with all characters in teh str specified
s - the str in which characters to be appendedpublic abstract T append(String s)
Returns a str instance contains all characters of this str instance appended with all characters in the String specified
s - the String in which characters to be appendedpublic abstract T prepend(Collection<? extends Character> collection)
Returns a str instance contains all characters of this str instance prepended with all characters in teh collection
public abstract T prepend(C.List<Character> list)
Return a str instance contains all characters of this str instance prepended with all characters in the list specified
public abstract T prepend(char... chars)
Return a str instance contains all characters of this str instance prepended with all characters in the array specified
chars - the array of characters to be prependedpublic abstract T prepend(Character character)
Returns a str instance contains all characters of this str instance prepended with the character specified
prepend in interface C.List<Character>prepend in interface C.ReversibleSequence<Character>prepend in interface C.Sequence<Character>prepend in class ListBase<Character>character - the character to be preppendedpublic abstract T prepend(T s)
Returns a str instance contains all characters of this str instance prepended with all characters in the str specified
s - the str in which characters to be prependedpublic abstract T prepend(String s)
Returns a str instance contains all characters of this str instance prepended with all characters in the String specified
s - the String in which characters to be prependedpublic abstract T subSequence(int start, int end)
Return a part of this str specified by start inclusive and end exclusive position.
Note calling this method has the same effect with calling subList(int, int) and calling substr(int, int)
subSequence in interface CharSequencestart - the start positionend - the end positionsubList(int, int),
substr(int, int)public abstract T times(int n)
Returns a str instance that repeat this str’s char sequence for n times
n - repeat timespublic abstract T padLeft(char c, int times)
Returns a str instance with times of char c left pad to the current str
c - the char used to pad to this strtimes - the repeat timespublic abstract T lpad(char c, int times)
Alias of padLeft(char, int)
c - the char used to pad to this strtimes - the repeat timespublic abstract T padLeft(int times)
Returns a str instance with times of char ' ' (space) left pad to the current str
times - the repeat timespublic abstract T lpad(int times)
Alias of padLeft(int)
times - the repeat timespublic abstract T padRight(char c, int times)
Returns a str instance with times of char c right pad to the current str
c - the char used to pad to this strtimes - the repeat timespublic abstract T rpad(char c, int times)
Alias of padRight(char, int)
c - the char used to pad to this strtimes - the repeat timespublic abstract T padRight(int times)
Returns a str instance with times of char ' ' (space) right pad to the current str
times - the repeat timespublic abstract T rpad(int times)
Alias of padRight(int)
times - the repeat timespublic abstract void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Copy part of the char sequence into another array
srcBegin - the start of copy inclusivesrcEnd - the end of copy exclusivedst - the destination arraydstBegin - the start of past in destination arraypublic abstract byte[] getBytesAscII()
Returns byte array of string composed of only ascii chars
public abstract byte[] getBytesUTF8()
Returns byte array of string composed of UTF-8 chars
public abstract byte[] getBytes()
Encodes this str into a sequence of bytes using the platform’s default charset, storing the result into a new byte array.
String.getBytes()public abstract byte[] getBytes(Charset charset)
Encodes this str into a sequence of bytes using the given charset, storing the result into a new byte array.
charset - The Charset to be used to encode the String. If charset is null then this function shall return the result of getBytes()String.getBytes(Charset)public abstract byte[] getBytes(String charsetName)
Encodes this str into a sequence of bytes using the named charset, storing the result into a new byte array.
charsetName - The name of a supported charset. If charsetName is null then this function shall return the result of getBytes()String.getBytes(String)public abstract FastStr toFastStr()
Return a FastStr that contains all the char sequence in this str instance
public abstract boolean contentEquals(CharSequence chars)
Check if this str content is equals to the char sequence specified
chars - the char sequence to be checked agains this strtrue if content of this str equals to that of the charspublic abstract boolean contentEquals(T str)
Check if this str content iks equals to the str specified
str - the str instancetrue if content of this str equals to that of the strpublic abstract boolean isBlank()
Check if this str is blank (empty or all space characters)
true if this str is blankpublic final int indexOf(int ch)
Returns the index within this str of the first occurrence of the specified character.
ch - a character (Unicode code point).-1 if the character does not occur.String.indexOf(int)public int indexOf(Object o)
Returns the index within this str of the first occurrence of the specified object. The function will check if the object is an instance of StrBase, String, Character or Integer, and delegate to the indexOf(...) override methods respectively.
If the object is not of the above types, then -1 returned
public abstract int indexOf(int ch,
int fromIndex)
Returns the index within this str of the first occurrence of the specified character.
ch - a character (Unicode code point).fromIndex - the from index-1 if the character does not occur.String.indexOf(int, int)public abstract int indexOf(CharSequence str, int fromIndex)
Returns the index within this str of the first occurrence of the specified substring, starting at the specified index.
str - the substring to search for.fromIndex - the index from which to start the search.-1 if there is no such occurrence.String.indexOf(String, int)public abstract int indexOf(T s, int fromIndex)
Locate another str inside this str, start at the specified index
s - the search stringfromIndex - from where the search should begin-1 if not foundpublic int indexOf(List<Character> list)
Returns the index within this str of the first occurrence of the specified character list
list - the list of chars to search forpublic int indexOf(List<Character> list, int startIndex)
Returns the index within this str of the first occurrence of the specified character list, starting at the specified index
list - the list of chars to search forstartIndex - the index from which to start the searchpublic final int lastIndexOf(int ch)
Returns the index within this str of the last occurrence of the specified character.
ch - a character (Unicode code point).-1 if the character does not occur.String.lastIndexOf(int)public final int lastIndexOf(CharSequence str)
Returns the index within this str of the last occurrence of the specified substring. The last occurrence of the empty string "" is considered to occur at the index value this.length().
The returned index is the largest value k for which:
If no such value of k exists, thenthis.startsWith(str, k)
-1 is returned.str - the substring to search for.-1 if there is no such occurrence.String.lastIndexOf(String)public final int lastIndexOf(T str)
Returns the index within this str of the last occurrence of the specified substr. The last occurrence of the empty str is considered to occur at the index value this.length().
The returned index is the largest value k for which:
If no such value of k exists, thenthis.startsWith(str, k)
-1 is returned.str - the substring to search for.-1 if there is no such occurrence.lastIndexOf(CharSequence)public int lastIndexOf(List<Character> list)
Returns the index within this str of the last occurrence of the specified character list
list - the list of chars to search forpublic int lastIndexOf(List<Character> list, int startIndex)
Returns the index within this str of the last occurrence of the specified character list, starting at the specified index from tail to head
list - the list of chars to search forstartIndex - the index from which to start the search backwardspublic int lastIndexOf(Object o)
Returns the index within this str of the last occurrence of the specified object. The function will check if the object is an instance of StrBase, String, Character or Integer, and delegate to the lastIndexOf(...) override methods respectively.
If the object is not of the above types, then -1 returned
lastIndexOf in interface List<Character>lastIndexOf in class AbstractList<Character>o - the objectpublic abstract int lastIndexOf(int ch,
int fromIndex)
Returns the index within this str of the last occurrence of the specified character, searching backward starting at the specified index.
ch - a character (Unicode code point).fromIndex - the index to start the search from. There is no restriction on the value of fromIndex. If it is greater than or equal to the length of this str, it has the same effect as if it were equal to one less than the length of this str: this entire str may be searched. If it is negative, it has the same effect as if it were -1: -1 is returned.fromIndex, or -1 if the character does not occur before that point.String.lastIndexOf(int, int)public abstract int lastIndexOf(CharSequence str, int fromIndex)
Returns the index within this str of the last occurrence of the specified substring, searching backward starting at the specified index.
The returned index is the largest value k for which:
If no such value of k exists, thenk <= fromIndex && this.startsWith(str, k)
-1 is returned.str - the string to search for.fromIndex - the index to start the search from.-1 if there is no such occurrence.String.lastIndexOf(String)public abstract int lastIndexOf(T str, int fromIndex)
Returns the index within this str of the last occurrence of the specified str, searching backward starting at the specified index.
The returned index is the largest value k for which:
If no such value of k exists, thenk <= fromIndex && this.startsWith(str, k)
-1 is returned.str - the str to search for.fromIndex - the index to start the search from.-1 if there is no such occurrence.String.lastIndexOf(String),
lastIndexOf(CharSequence, int)public abstract String substring(int beginIndex)
Return a sub string of type String of this str starts from beginIndex specified till the end of the char array of this str
beginIndex - the start index of the sub stringpublic abstract boolean equalsIgnoreCase(CharSequence x)
Compare content of the str and the specified char sequence, case insensitive
x - the char sequence to be checkedtrue if the argument is not null and it represents an equivalent String ignoring case; false otherwisepublic abstract int compareTo(CharSequence x)
Compare the char sequence specified against this str
x - the char sequence to be compared to this strString.compareTo(String)public abstract int compareToIgnoreCase(T x)
Compare the str specified against this str in a case insensitive manner
x - the str to be compared to this strString.compareToIgnoreCase(String)public abstract int compareToIgnoreCase(CharSequence x)
Compare the char sequence specified against this str in a case insensitive manner
x - the char sequence to be compared to this strString.compareToIgnoreCase(String)public abstract boolean regionMatches(boolean ignoreCase,
int toffset,
T other,
int ooffset,
int len)
Tests if two string regions are equal.
ignoreCase - if true, ignore case when comparing characters.toffset - the starting offset of the subregion in this str.other - the str argument.ooffset - the starting offset of the subregion in the str argument.len - the number of characters to compare.true if the specified subregion of this string matches the specified subregion of the string argument; false otherwise. Whether the matching is exact or case insensitive depends on the ignoreCase argument.String.regionMatches(boolean, int, String, int, int)public abstract boolean regionMatches(boolean ignoreCase,
int toffset,
CharSequence other,
int ooffset,
int len)
Tests if two string regions are equal.
ignoreCase - if true, ignore case when comparing characters.toffset - the starting offset of the subregion in this str.other - the char sequence argument.ooffset - the starting offset of the subregion in the str argument.len - the number of characters to compare.true if the specified subregion of this string matches the specified subregion of the string argument; false otherwise. Whether the matching is exact or case insensitive depends on the ignoreCase argument.String.regionMatches(boolean, int, String, int, int)public final boolean startsWith(CharSequence prefix)
Check if this str starts with the given char sequence
prefix - the char sequencetrue if this str starts with the char sequence specified or false otherwisepublic final boolean startsWith(T prefix)
Check if this str starts with the given str
prefix - the str argumenttrue if this str starts with the str specified or false otherwisepublic abstract boolean startsWith(T prefix, int toffset)
Check this str instance starts with str, with the search starts at specified offset
prefix - the str argumentstoffset - the offset where the search beginstrue if the search matches or false otherwisepublic abstract boolean startsWith(CharSequence prefix, int toffset)
Check if this str starts with a char sequence, with the search starts at the specified offset
prefix - the char sequence argumenttoffset - the start offset where search beginstrue if search matches or false otherwisepublic final boolean endsWith(CharSequence prefix)
Check if this str ends with the given char sequence
prefix - the char sequencetrue if this str ends with the char sequence specified or false otherwisepublic final boolean endsWith(T prefix)
Check if this str ends with the given str
prefix - the str argumenttrue if this str ends with the str specified or false otherwisepublic abstract boolean endsWith(T prefix, int toffset)
Check this str instance ends with str, with the search starts at specified offset
prefix - the str argumentstoffset - the offset where the search begins (backwards)true if the search matches or false otherwisepublic abstract boolean endsWith(CharSequence prefix, int toffset)
Check if this str ends with a char sequence, with the search starts at the specified offset
prefix - the char sequence argumenttoffset - the start offset where search begins backwardstrue if search matches or false otherwisepublic abstract String substring(int beginIndex, int endIndex)
Returns a new string that is a substring of this str. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.
beginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.String.substring(int, int)public abstract T replace(char oldChar, char newChar)
Returns a new str resulting from replacing all occurrences of oldChar in this string with newChar.
If the character oldChar does not occur in the character sequence represented by this str object, then a reference to this str object is returned. Otherwise, a new str object is created that represents a character sequence identical to the character sequence represented by this str object, except that every occurrence of oldChar is replaced by an occurrence of newChar.
oldChar - the old character.newChar - the new character.oldChar with newChar.public abstract T replace(CharSequence target, CharSequence replacement)
Replaces each substring of this str that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the str to the end, for example, replacing “aa” with “b” in the str “aaa” will result in “ba” rather than “ab”.
target - The sequence of char values to be replacedreplacement - The replacement sequence of char valuesNullPointerException - if target or replacement is null.public abstract T replaceAll(String regex, String replacement)
Replaces each substr of this str that matches the given regular expression with the given replacement.
regex - the regular expression to which this string is to be matchedreplacement - the string to be substituted for each matchPatternSyntaxException - if the regular expression’s syntax is invalidPattern,
String.replaceAll(String, String)public abstract T replaceFirst(String regex, String replacement)
Replaces the first substring of this str that matches the given regular expression with the given replacement.
regex - the regular expression to which this str is to be matchedreplacement - the string to be substituted for the first matchPatternSyntaxException - if the regular expression’s syntax is invalidPattern,
String.replaceFirst(String, String)public abstract boolean matches(String regex)
Tells whether or not this str matches the given regular expression.
regex - the regular expression to which this string is to be matchedPatternSyntaxException - if the regular expression’s syntax is invalidPattern,
String.matches(String)public abstract boolean contains(CharSequence s)
public abstract T trim()
public abstract char[] charArray()
public abstract String intern()
public abstract T afterFirst(char c)
public abstract T afterLast(char c)
public abstract T beforeFirst(char c)
public abstract T beforeLast(char c)
public abstract T urlEncode()
public abstract T decodeBASE64()
public abstract T encodeBASE64()
public abstract T capFirst()
public abstract int count(String search, boolean overlap)
public abstract int count(T search, boolean overlap)
public boolean equals(Object o)
equals in interface Collection<Character>equals in interface List<Character>equals in class AbstractList<Character>protected EnumSet<C.Feature> initFeatures()
ListBaseSub class should override this method to provide initial feature set for the feature based instance
initFeatures in class ListBase<Character>public T lazy()
C.ListReturns this traversable and make sure C.Feature.LAZY is set
lazy in interface C.List<Character>lazy in interface C.ReversibleSequence<Character>lazy in interface C.Sequence<Character>lazy in interface C.Traversable<Character>lazy in class ListBase<Character>public T eager()
C.ListReturns this traversable and make sure C.Feature.LAZY is unset
eager in interface C.List<Character>eager in interface C.ReversibleSequence<Character>eager in interface C.Sequence<Character>eager in interface C.Traversable<Character>eager in class ListBase<Character>public T snapshot()
C.ListReturns an immutable list contains all elements of the current list. If the current list is immutable, then return the current list itself.
public T readOnly()
C.ListReturns a view of this list that is readonly. If the current list is readonly or immutable then return the current list itself
public T copy()
Returns a copy of this str. The char buf is copied
public final void copy(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
protected T setFeature(C.Feature feature)
setFeature in class ListBase<Character>public T parallel()
C.ListReturns this traversable and make sure C.Feature.PARALLEL is set
parallel in interface C.List<Character>parallel in interface C.ReversibleSequence<Character>parallel in interface C.Sequence<Character>parallel in interface C.Traversable<Character>parallel in class ListBase<Character>protected T unsetFeature(C.Feature feature)
unsetFeature in class ListBase<Character>public final Character get(int index)
public final int size()
C.TraversableReturn the size of this traversal
size in interface Collection<Character>size in interface List<Character>size in interface C.Traversable<Character>size in class AbstractCollection<Character>public final void add(int index,
Character element)
public final Character remove(int index)
public ListIterator<Character> listIterator(int index)
listIterator in interface List<Character>listIterator in class ListBase<Character>public T take(int n)
C.ListReturns a Sequence consisting the first n elements from this Sequence if number n is positive and the Sequence contains more than n elements
If this Sequence contains less than n elements, then a Sequence consisting the whole elements of this Sequence is returned. Note it might return this Sequence itself if the Sequence is immutable.
If the number n is zero, then an empty Sequence is returned in reverse order
If the number n is negative, then the last -n elements from this Sequence is returned in an new Sequence, or throw UnsupportedOperationException if this operation is not supported
Sequence seq = C.list(1, 2, 3, 4); assertEquals(C.list(1, 2), seq.take(2)); assertEquals(C.list(1, 2, 3, 4), seq.take(100)); assertEquals(C.list(), seq.take(0)); assertEquals(C.list(3, 4), seq.take(-2)); assertEquals(C.list(1, 2, 3, 4), seq.take(-200));
This method does not alter the underline list
take in interface C.List<Character>take in interface C.ReversibleSequence<Character>take in interface C.Sequence<Character>take in class ListBase<Character>n - specify the number of elements to be taken from the head of this Sequencen items in this listC.Sequence.head(int)public T head(int n)
C.ListAlias of C.Sequence.take(int)
head in interface C.List<Character>head in interface C.ReversibleSequence<Character>head in interface C.Sequence<Character>head in class ListBase<Character>n - specify the number of elements to be included in the return listn items in this Listpublic T drop(int n) throws IndexOutOfBoundsException
C.ListReturns a Sequence consisting of the elements from this Sequence except the first n if number n is positive and the Sequence contains more than n elements
If this Sequence contains less than n elements, then an empty Sequence is returned
If the number n is zero, then a copy of this Sequence or this Sequence itself is returned depending on the implementation
If the number n is negative, then either IllegalArgumentException should be thrown out if this sequence is not C.Feature.LIMITED or it drop -n element starts from the tail side
C.Sequence seq = C.list(1, 2, 3, 4, 5); assertEquals(C.list(3, 4, 5), seq.drop(2)); assertEquals(C.list(1, 2, 3, 4, 5), seq.drop(0)); assertEquals(C.list(), seq.drop(100));
Note this method does NOT modify the current sequence, instead it returns an new sequence structure containing the elements as required
This method does not alter the underline list
drop in interface C.List<Character>drop in interface C.ReversibleSequence<Character>drop in interface C.Sequence<Character>drop in class ListBase<Character>n - specify the number of elements to be taken from the head of this Sequence or the -n number of elements to be taken from the tail of this sequence if n is an negative numbern numberIndexOutOfBoundsExceptionpublic <R> C.List<R> map(Lang.Function<? super Character,? extends R> mapper)
C.SequenceReturns an new traversable with a mapper function specified. The element in the new traversal is the result of the mapper function applied to this traversal element.
Traversable traversable = C.list(23, .NONE, null); assertEquals(C.list(true, false, false), traversal.map(.F.NOT_NULL)); assertEquals(C.list(“23”, "“, ”"), traversal.map(_.F.AS_STRING));
For Lazy Traversable, it must use lazy evaluation for this method. Otherwise it is up to implementation to decide whether use lazy evaluation or not
map in interface C.List<Character>map in interface C.ReversibleSequence<Character>map in interface C.Sequence<Character>map in interface C.Traversable<Character>map in class ListBase<Character>R - the element type of the new traversalmapper - the function that applied to element in this traversal and returns element in the result traversalR that are mapped from this sequencepublic <R> C.List<R> flatMap(Lang.Function<? super Character,? extends Iterable<? extends R>> mapper)
C.ListReturns a traversable consisting of the results of replacing each element of this stream with the contents of the iterable produced by applying the provided mapping function to each element. If the result of the mapping function is null, this is treated as if the result is an empty traversable.
flatMap in interface C.List<Character>flatMap in interface C.ReversibleSequence<Character>flatMap in interface C.Sequence<Character>flatMap in interface C.Traversable<Character>flatMap in class ListBase<Character>R - the element type of the the new traversablemapper - the function produce an iterable when applied to an elementR type element that are mapped from this sequencespublic T filter(Lang.Function<? super Character,Boolean> predicate)
C.SequenceReturns an new traversable that contains all elements in the current traversable except that does not pass the test of the filter function specified.
Traversable traversable = C.list(-1, 0, 1, -3, 7); Traversable filtered = traversable.filter(_.F.gt(0)); assertTrue(filtered.contains(1)); assertFalse(filtered.contains(-3));
filter in interface C.List<Character>filter in interface C.ReversibleSequence<Character>filter in interface C.Sequence<Character>filter in interface C.Traversable<Character>filter in class ListBase<Character>predicate - the function that test if the element in the traversable should be kept in the resulting traversable. When applying the filter function to the element, if the result is true then the element will be kept in the resulting traversable.Sequence consists of elements that passed the predicatepublic T accept(Lang.Visitor<? super Character> visitor)
C.TraversableIterate this Traversable with a visitor function. This method does not specify the approach to iterate through this structure. The implementation might choose iterate from left to right, or vice versa. It might even choose to split the structure into multiple parts, and iterate through them in parallel
accept in interface C.List<Character>accept in interface C.ReversibleSequence<Character>accept in interface C.Sequence<Character>accept in interface C.Traversable<Character>accept in class ListBase<Character>visitor - a function that apply to element in this Traversable. The return value of the function is ignoredTraversable instance for chained callpublic T acceptLeft(Lang.Visitor<? super Character> visitor)
C.SequenceIterate through this sequence from head to tail with the visitor function specified
acceptLeft in interface C.List<Character>acceptLeft in interface C.ReversibleSequence<Character>acceptLeft in interface C.Sequence<Character>acceptLeft in class ListBase<Character>visitor - the function to visit elements in this sequenceC.Traversable.accept(Lang.Visitor),
C.ReversibleSequence.acceptRight(Lang.Visitor)public T acceptRight(Lang.Visitor<? super Character> visitor)
C.ReversibleSequenceIterate through this sequence from tail to head with the visitor function specified
acceptRight in interface C.List<Character>acceptRight in interface C.ReversibleSequence<Character>acceptRight in class ListBase<Character>visitor - the function to visit elements in this sequenceC.Traversable.accept(Lang.Visitor),
C.Sequence.acceptLeft(Lang.Visitor)public T tail()
C.ListReturns the rest part of the Sequence except the first element
tail in interface C.List<Character>tail in interface C.ReversibleSequence<Character>tail in interface C.Sequence<Character>tail in class ListBase<Character>C.Sequence.head(),
C.ReversibleSequence.tail(int)public T tail(int n)
C.ListReturns a Sequence consisting the last n elements from this Sequence if number n is positive and the Sequence contains more than n elements
If this Sequence contains less than n elements, then a Sequence consisting the whole elements of this Sequence is returned. Note it might return this Sequence itself if the Sequence is immutable.
If the number n is zero, then an empty Sequence is returned in reverse order
If the number n is negative, then the first -n elements from this Sequence is returned in an new Sequence
Sequence seq = C1.list(1, 2, 3, 4); assertEquals(C1.list(3, 4), seq.tail(2)); assertEquals(C1.list(1, 2, 3, 4), seq.tail(100)); assertEquals(C1.list(), seq.tail(0)); assertEquals(C1.list(1, 2, 3), seq.tail(-3)); assertEquals(C1.list(1, 2, 3, 4), seq.tail(-200));
This method does not mutate the underline container
This method does not alter the underline list
tail in interface C.List<Character>tail in interface C.ReversibleSequence<Character>tail in class ListBase<Character>n - specify the number of elements to be taken from the tail of this Sequencen items in this listC.Feature.LIMITED,
C.Featured.is(org.osgl.util.C.Feature)public String value()
public String val()
public final T substr(int beginIndex, int endIndex)
public boolean empty()
public boolean notEmpty()
public T maxLength(int max)
Return a string no longer than specified max length.
If the string supplied is longer than the specified max length then only it’s part that is less than the max length returned, appended with “…”
max - the maximum length of the resultmax number of chars of this instancepublic T cutOff(int max)
Return a string no longer than specified max length.
If the string supplied is longer than the specified max length then only it’s part that is less than the max length returned, appended with “…”
max - the maximum length of the resultpublic final boolean contentEquals(StringBuffer stringBuffer)
Wrapper of String.contentEquals(StringBuffer)
stringBuffer - string bufferpublic final boolean eq(CharSequence x)
Alias of contentEquals(CharSequence)
x - an instance of CharSequence typetrue if chars inside this instance equals to the chars inside xpublic final boolean eq(T x)
Alias of contentEquals(StrBase)
x - another instancetrue if this instance equals to the xpublic final boolean eq(StringBuffer stringBuffer)
Alias of contentEquals(StringBuffer)
stringBuffer - the string buffertrue if content of this instance equals to content of the string bufferpublic final int pos(CharSequence x, int fromIndex)
Alias of indexOf(CharSequence, int)
x - the substr to search forfromIndex - the index from where the search starts, backwardspublic final int pos(CharSequence x)
Alias of indexOf(CharSequence)
x - the substr to search forpublic final int indexOf(T x)
Locate another str inside this str, start at the specified index
x - the search str-1 if not foundpublic final int indexOf(CharSequence str)
Returns the index within this str of the first occurrence of the specified substring, starting at 0.
str - the substring to search for.-1 if there is no such occurrence.String.indexOf(String, int)public final int pos(int ch)
Alias of indexOf(int)
ch - the character to be locatedpublic final int pos(T x)
Alias of indexOf(StrBase)
x - the str to be locatedpublic final int pos(int ch,
int fromIndex)
Alias of indexOf(int, int)
ch - the char to be locatedfromIndex - the index the search beginspublic final int pos(T x, int fromIndex)
Alias of indexOf(StrBase, int)
x - a StrBase to searchfromIndex - the index from where the search should begins-1 if not foundpublic final int rpos(int ch)
Alias of lastIndexOf(int)
ch - the char to be locatedpublic final int rpos(T x)
alias of lastIndexOf(StrBase)
x - the str to be locatedpublic final int rpos(CharSequence str, int fromIndex)
alias of lastIndexOf(CharSequence, int)
str - the string to be locatedfromIndex - the index from where the search begins backwardspublic final int rpos(T str, int fromIndex)
alias of lastIndexOf(StrBase, int)
str - the str to be locatedfromIndex - the index from where the search begins backwardspublic final int rpos(CharSequence str)
alias of lastIndexOf(CharSequence)
str - the string to be locatedpublic final int rpos(int ch,
int fromIndex)
Alias of lastIndexOf(int, int)
ch - the char to be locatedfromIndex - the index from where the search begins backwardspublic final boolean contains(char c)
public final boolean regionMatches(int toffset,
T other,
int ooffset,
int len)
public final boolean regionMatches(int toffset,
String other,
int ooffset,
int len)
public final T substr(int beginIndex)
Synonym of substring(int) but return Str instead of String
beginIndex - the begin indexpublic final T toLowerCase()
public final T lower()
public final T toUpperCase()
public final T upper()
public final int count(String s)
public final int count(T s)
public final int countWithOverlap(String s)
public final int countWithOverlap(T s)
public final char[] toCharArray()
Wrapper of String.toCharArray()
Copyright © 2014–2019 OSGL (Open Source General Library). All rights reserved.