public class CharArrayUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
containLineBreaks(java.lang.CharSequence seq) |
static boolean |
containLineBreaks(java.lang.CharSequence seq,
int fromOffset,
int endOffset) |
static boolean |
containsOnlyWhiteSpaces(java.lang.CharSequence chars) |
static ImmutableCharSequence |
createImmutableCharSequence(java.lang.CharSequence sequence) |
static boolean |
equals(char [] buffer1,
int start1,
int end1,
char [] buffer2,
int start2,
int end2) |
static char [] |
fromSequence(java.lang.CharSequence seq) |
static char [] |
fromSequence(java.lang.CharSequence seq,
int start,
int end) |
static char [] |
fromSequenceWithoutCopying(java.lang.CharSequence seq) |
static void |
getChars(java.lang.CharSequence src,
char [] dst,
int dstOffset)
Copies all symbols from the given char sequence to the given array
|
static void |
getChars(java.lang.CharSequence src,
char [] dst,
int dstOffset,
int len)
Copies necessary number of symbols from the given char sequence start to the given array.
|
static void |
getChars(java.lang.CharSequence src,
char [] dst,
int srcOffset,
int dstOffset,
int len)
Copies necessary number of symbols from the given char sequence to the given array.
|
static TextRange [] |
getIndents(java.lang.CharSequence charsSequence,
int shift) |
static int |
indexOf(char [] buffer,
char symbol,
int fromIndex,
int toIndex)
Tries to find index that points to the first location of the given symbol at the given char array at range
[from; to) . |
static int |
indexOf(char [] buffer,
java.lang.String pattern,
int fromIndex) |
static int |
indexOf(java.lang.CharSequence buffer,
java.lang.CharSequence pattern,
int fromIndex) |
static int |
indexOf(java.lang.CharSequence buffer,
java.lang.CharSequence pattern,
int fromIndex,
int toIndex)
Tries to find index of given pattern at the given buffer.
|
static boolean |
isEmptyOrSpaces(java.lang.CharSequence text,
int start,
int end)
Allows to answer if target region of the given text contains only white space symbols (tabulations, white spaces and line feeds).
|
static int |
lastIndexOf(char [] buffer,
char symbol,
int fromIndex,
int toIndex)
Tries to find index that points to the last location of the given symbol at the given char array at range
[from; to) . |
static int |
lastIndexOf(char [] buffer,
java.lang.String pattern,
int maxIndex) |
static int |
lastIndexOf(java.lang.CharSequence buffer,
java.lang.String pattern,
int maxIndex) |
static java.io.Reader |
readerFromCharSequence(java.lang.CharSequence text) |
static boolean |
regionMatches(char [] buffer,
int start,
int end,
java.lang.CharSequence s) |
static boolean |
regionMatches(java.lang.CharSequence buffer,
int offset,
java.lang.CharSequence s) |
static boolean |
regionMatches(java.lang.CharSequence buffer,
int start,
int end,
java.lang.CharSequence s) |
static boolean |
regionMatches(java.lang.CharSequence s1,
int start1,
int end1,
java.lang.CharSequence s2,
int start2,
int end2) |
static int |
shiftBackward(char [] buffer,
int offset,
java.lang.String chars) |
static int |
shiftBackward(java.lang.CharSequence buffer,
int minOffset,
int maxOffset,
java.lang.String chars) |
static int |
shiftBackward(java.lang.CharSequence buffer,
int offset,
java.lang.String chars) |
static int |
shiftBackwardUntil(java.lang.CharSequence buffer,
int offset,
java.lang.String chars)
Calculates offset that points to the given buffer and has the following characteristics:
is less than or equal to the given offset;
it's guaranteed that all symbols of the given buffer that are located at
(returned offset; given offset]
interval differ from the given symbols;
Example: suppose that this method is called with buffer that holds 'test data' symbols, offset that points
to the last symbols and 'sf' as a chars to exclude. |
static int |
shiftForward(char [] buffer,
int offset,
java.lang.String chars) |
static int |
shiftForward(java.lang.CharSequence buffer,
int startOffset,
int endOffset,
java.lang.String chars)
Tries to find an offset from the
[startOffset; endOffset) interval such that a char from the given buffer is
not contained at the given 'chars' string. |
static int |
shiftForward(java.lang.CharSequence buffer,
int offset,
java.lang.String chars) |
static int |
shiftForwardCarefully(java.lang.CharSequence buffer,
int offset,
java.lang.String chars) |
static int |
shiftForwardUntil(java.lang.CharSequence buffer,
int offset,
java.lang.String chars) |
public static void getChars(java.lang.CharSequence src, char [] dst, int dstOffset)
src
- source data holderdst
- output data bufferdstOffset
- start offset to use within the given output data bufferpublic static void getChars(java.lang.CharSequence src, char [] dst, int dstOffset, int len)
src
- source data holderdst
- output data bufferdstOffset
- start offset to use within the given output data bufferlen
- number of source data symbols to copy to the given bufferpublic static void getChars(java.lang.CharSequence src, char [] dst, int srcOffset, int dstOffset, int len)
src
- source data holderdst
- output data buffersrcOffset
- source text offsetdstOffset
- start offset to use within the given output data bufferlen
- number of source data symbols to copy to the given bufferpublic static char [] fromSequenceWithoutCopying(java.lang.CharSequence seq)
public static char [] fromSequence(java.lang.CharSequence seq)
public static char [] fromSequence(java.lang.CharSequence seq, int start, int end)
public static int shiftForward(java.lang.CharSequence buffer, int offset, java.lang.String chars)
public static int shiftForward(java.lang.CharSequence buffer, int startOffset, int endOffset, java.lang.String chars)
[startOffset; endOffset)
interval such that a char from the given buffer is
not contained at the given 'chars' string.
Example:
buffer="abc", startOffset=0, endOffset = 3, chars="ab". Result: 2
buffer
- target buffer which symbols should be checkedstartOffset
- start offset to use within the given buffer (inclusive)endOffset
- end offset to use within the given buffer (exclusive)chars
- pass-through symbols[startOffset; endOffset)
which points to a symbol at the given buffer such
as that that symbol is not contained at the given 'chars';
endOffset
otherwisepublic static int shiftForwardCarefully(java.lang.CharSequence buffer, int offset, java.lang.String chars)
public static int shiftForward(char [] buffer, int offset, java.lang.String chars)
public static int shiftBackward(java.lang.CharSequence buffer, int offset, java.lang.String chars)
public static int shiftBackward(java.lang.CharSequence buffer, int minOffset, int maxOffset, java.lang.String chars)
public static int shiftBackward(char [] buffer, int offset, java.lang.String chars)
public static int shiftForwardUntil(java.lang.CharSequence buffer, int offset, java.lang.String chars)
public static int shiftBackwardUntil(java.lang.CharSequence buffer, int offset, java.lang.String chars)
(returned offset; given offset]
interval differ from the given symbols;
'test data'
symbols, offset that points
to the last symbols and 'sf'
as a chars to exclude. Offset that points to 's'
symbol
is returned then, i.e. all symbols of the given buffer that are located after it and not after given offset
('t data'
) are guaranteed to not contain given chars ('sf'
).buffer
- symbols buffer to checkoffset
- initial symbols buffer offset to usechars
- chars to exclude(returned offset; given offset]
interval of the given buffer differ from symbols of given 'chars'
arguments;
given offset is returned if it is outside of given buffer bounds;
'-1'
is returned if all document symbols that precede given offset differ from symbols
of the given 'chars to exclude'
public static boolean regionMatches(char [] buffer, int start, int end, java.lang.CharSequence s)
public static boolean regionMatches(java.lang.CharSequence buffer, int start, int end, java.lang.CharSequence s)
public static boolean regionMatches(java.lang.CharSequence s1, int start1, int end1, java.lang.CharSequence s2, int start2, int end2)
public static boolean regionMatches(java.lang.CharSequence buffer, int offset, java.lang.CharSequence s)
public static boolean equals(char [] buffer1, int start1, int end1, char [] buffer2, int start2, int end2)
public static int indexOf(char [] buffer, java.lang.String pattern, int fromIndex)
public static int indexOf(java.lang.CharSequence buffer, java.lang.CharSequence pattern, int fromIndex)
public static int indexOf(java.lang.CharSequence buffer, java.lang.CharSequence pattern, int fromIndex, int toIndex)
buffer
- characters buffer which contents should be checked for the given patternpattern
- target characters sequence to find at the given bufferfromIndex
- start index (inclusive). Zero is used if given index is negativetoIndex
- end index (exclusive)-1
otherwisepublic static int indexOf(char [] buffer, char symbol, int fromIndex, int toIndex)
[from; to)
.buffer
- target symbols holder to checksymbol
- target symbol which offset should be foundfromIndex
- start index to search (inclusive)toIndex
- end index to search (exclusive)[from; to)
if target symbol is found;
-1
otherwisepublic static int lastIndexOf(char [] buffer, char symbol, int fromIndex, int toIndex)
[from; to)
.buffer
- target symbols holder to checksymbol
- target symbol which offset should be foundfromIndex
- start index to search (inclusive)toIndex
- end index to search (exclusive)[from; to)
if target symbol is found;
-1
otherwisepublic static int lastIndexOf(java.lang.CharSequence buffer, java.lang.String pattern, int maxIndex)
public static int lastIndexOf(char [] buffer, java.lang.String pattern, int maxIndex)
public static boolean containsOnlyWhiteSpaces(java.lang.CharSequence chars)
public static TextRange [] getIndents(java.lang.CharSequence charsSequence, int shift)
public static boolean containLineBreaks(java.lang.CharSequence seq)
public static boolean containLineBreaks(java.lang.CharSequence seq, int fromOffset, int endOffset)
public static boolean isEmptyOrSpaces(java.lang.CharSequence text, int start, int end)
text
- text to checkstart
- start offset within the given text to check (inclusive)end
- end offset within the given text to check (exclusive)true
if target region of the given text contains white space symbols only; false
otherwisepublic static java.io.Reader readerFromCharSequence(java.lang.CharSequence text)
public static ImmutableCharSequence createImmutableCharSequence(java.lang.CharSequence sequence)