public final class CharSequences
extends java.lang.Object
CharSequence
implementations.Modifier and Type | Method and Description |
---|---|
static boolean |
contentEquals(java.lang.CharSequence a,
java.lang.CharSequence b)
Returns
true if the content of both CharSequence 's are equals. |
static boolean |
contentEqualsIgnoreCase(java.lang.CharSequence a,
java.lang.CharSequence b)
Perform a case-insensitive comparison of two
CharSequence s. |
static java.lang.CharSequence |
emptyAsciiString()
Get a reference to an unmodifiable empty
CharSequence with the same properties as
newAsciiString(Buffer) . |
static int |
indexOf(java.lang.CharSequence sequence,
char c,
int fromIndex)
Find the index of
c within sequence starting at index fromIndex . |
static java.lang.CharSequence |
newAsciiString(Buffer input)
Create a new
CharSequence from the specified input , supporting only 8-bit ASCII characters, and
with a case-insensitive hashCode . |
static java.lang.CharSequence |
newAsciiString(java.lang.String input)
Create a new
CharSequence from the specified input , supporting only 8-bit ASCII characters, and
with a case-insensitive hashCode . |
static boolean |
regionMatches(java.lang.CharSequence cs,
boolean ignoreCase,
int csStart,
java.lang.CharSequence string,
int start,
int length)
This methods make regionMatches operation correctly for any chars in strings.
|
static Buffer |
unwrapBuffer(java.lang.CharSequence cs)
Attempt to unwrap a
CharSequence and obtain the underlying Buffer if possible. |
public static java.lang.CharSequence newAsciiString(java.lang.String input)
CharSequence
from the specified input
, supporting only 8-bit ASCII characters, and
with a case-insensitive hashCode
.
Supporting only 8-bit ASCII and providing a case-insensitive hashCode
allows for optimizations when the
CharSequence
returned is used as HttpHeaders
names or values.
input
- a string containing only 8-bit ASCII characters.CharSequence
public static java.lang.CharSequence newAsciiString(Buffer input)
CharSequence
from the specified input
, supporting only 8-bit ASCII characters, and
with a case-insensitive hashCode
.
Supporting only 8-bit ASCII and providing a case-insensitive hashCode
allows for optimizations when the
CharSequence
returned is used as HttpHeaders
names or values.
input
- a Buffer
containingCharSequence
.public static java.lang.CharSequence emptyAsciiString()
CharSequence
with the same properties as
newAsciiString(Buffer)
.CharSequence
with the same properties as
newAsciiString(Buffer)
.@Nullable public static Buffer unwrapBuffer(java.lang.CharSequence cs)
CharSequence
and obtain the underlying Buffer
if possible.cs
- the CharSequence
to unwrap.Buffer
or null
.public static boolean contentEqualsIgnoreCase(@Nullable java.lang.CharSequence a, @Nullable java.lang.CharSequence b)
CharSequence
s.
NOTE: This only supports 8-bit ASCII.
a
- first CharSequence
to compare.b
- second CharSequence
to compare.true
if both CharSequence
's are equals when ignoring the case.public static boolean contentEquals(java.lang.CharSequence a, java.lang.CharSequence b)
true
if the content of both CharSequence
's are equals. This only supports 8-bit ASCII.a
- left hand side of comparison.b
- right hand side of comparison.true
if a
's content equals b
.public static int indexOf(java.lang.CharSequence sequence, char c, int fromIndex)
c
within sequence
starting at index fromIndex
.sequence
- The CharSequence
to search in.c
- The character to find.fromIndex
- The index to start searching (inclusive).c
or -1
otherwise.public static boolean regionMatches(java.lang.CharSequence cs, boolean ignoreCase, int csStart, java.lang.CharSequence string, int start, int length)
cs
- the CharSequence
to be processedignoreCase
- specifies if case should be ignored.csStart
- the starting offset in the cs
CharSequencestring
- the CharSequence
to compare.start
- the starting offset in the specified string
.length
- the number of characters to compare.true
if the ranges of characters are equal, false
otherwise.