public class CharSequences extends java.lang.Object
Utility functions for handling java.lang.CharSequence instances
Constructor and description |
---|
private CharSequences
() |
Type Params | Return Type | Name and description |
---|---|---|
|
public static boolean |
canUseOriginalForSubSequence(java.lang.CharSequence str, int start, int count) Checks if start == 0 and count == length of CharSequence It does this check only for String, StringBuilder and StringBuffer classes which have a fast way to check length |
|
public static java.lang.CharSequence |
createCharSequence(char[] chars) |
|
public static java.lang.CharSequence |
createCharSequence(char[] chars, int start, int count) |
|
public static java.lang.CharSequence |
createCharSequence(java.lang.CharSequence str, int start, int count) |
|
public static java.lang.CharSequence |
createSingleCharSequence(int c) |
|
public static java.lang.CharSequence |
createSingleCharSequence(char ch) |
|
public static void |
getChars(java.lang.CharSequence csq, int srcBegin, int srcEnd, char[] dst, int dstBegin) Provides an optimized way to copy CharSequence content to target array. |
|
public static void |
writeCharSequence(java.io.Writer target, java.lang.CharSequence csq, int start, int end) Writes a CharSequence instance in the most optimal way to the target writer |
|
public static void |
writeCharSequence(java.io.Writer target, java.lang.CharSequence csq) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Checks if start == 0 and count == length of CharSequence It does this check only for String, StringBuilder and StringBuffer classes which have a fast way to check length Calculating length on GStringImpl requires building the result which is costly. This helper method is to avoid calling length on other that String, StringBuilder and StringBuffer classes when checking if the input CharSequence instance is already the same as the requested sub sequence
str
- CharSequence inputstart
- start indexcount
- length on sub sequence Provides an optimized way to copy CharSequence content to target array.
Uses getChars method available on String, StringBuilder and StringBuffer classes.
Characters are copied from the source sequence csq
into the
destination character array dst
. The first character to
be copied is at index srcBegin
; the last character to
be copied is at index srcEnd-1
. The total number of
characters to be copied is srcEnd-srcBegin
. The
characters are copied into the subarray of dst
starting
at index dstBegin
and ending at index:
dstbegin + (srcEnd-srcBegin) - 1
dst
is
null
.srcBegin
is negative
dstBegin
is negative
srcBegin
argument is greater than
the srcEnd
argument.
srcEnd
is greater than
this.length()
.
dstBegin+srcEnd-srcBegin
is greater than
dst.length
csq
- the source CharSequence instance.srcBegin
- start copying at this offset.srcEnd
- stop copying at this offset.dst
- the array to copy the data into.dstBegin
- offset into dst
.Writes a CharSequence instance in the most optimal way to the target writer
target
- writercsq
- source CharSequence instancestart
- start/offset indexend
- end index + 1