public final class AsciiString
extends java.lang.Object
implements java.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>
String
, which uses a character array, for
reduced memory footprint and faster data transfer from/to byte-based data structures such as a byte array and
ByteBuffer
. It is often used in conjunction with Headers
that require a CharSequence
.
This class was designed to provide an immutable array of bytes, and caches some internal state based upon the value
of this array. However underlying access to this byte array is provided via not copying the array on construction or
array()
. If any changes are made to the underlying byte array it is the user's responsibility to call
arrayChanged()
so the state of this class can be reset.
限定符和类型 | 字段和说明 |
---|---|
static HashingStrategy<java.lang.CharSequence> |
CASE_INSENSITIVE_HASHER |
static HashingStrategy<java.lang.CharSequence> |
CASE_SENSITIVE_HASHER |
static AsciiString |
EMPTY_STRING |
static int |
INDEX_NOT_FOUND |
构造器和说明 |
---|
AsciiString(byte[] value)
Initialize this byte string based upon a byte array.
|
AsciiString(byte[] value,
boolean copy)
Initialize this byte string based upon a byte array.
|
AsciiString(byte[] value,
int start,
int length,
boolean copy)
Construct a new instance from a
byte[] array. |
AsciiString(java.nio.ByteBuffer value)
Create a copy of the underlying storage from
value . |
AsciiString(java.nio.ByteBuffer value,
boolean copy)
Initialize an instance based upon the underlying storage from
value . |
AsciiString(java.nio.ByteBuffer value,
int start,
int length,
boolean copy)
Initialize an
AsciiString based upon the underlying storage from value . |
AsciiString(char[] value)
Create a copy of
value into this instance assuming ASCII encoding. |
AsciiString(char[] value,
java.nio.charset.Charset charset)
Create a copy of
value into this instance using the encoding type of charset . |
AsciiString(char[] value,
java.nio.charset.Charset charset,
int start,
int length)
Create a copy of
value into a this instance using the encoding type of charset . |
AsciiString(char[] value,
int start,
int length)
Create a copy of
value into this instance assuming ASCII encoding. |
AsciiString(java.lang.CharSequence value)
Create a copy of
value into this instance assuming ASCII encoding. |
AsciiString(java.lang.CharSequence value,
java.nio.charset.Charset charset)
Create a copy of
value into this instance using the encoding type of charset . |
AsciiString(java.lang.CharSequence value,
java.nio.charset.Charset charset,
int start,
int length)
Create a copy of
value into this instance using the encoding type of charset . |
AsciiString(java.lang.CharSequence value,
int start,
int length)
Create a copy of
value into this instance assuming ASCII encoding. |
限定符和类型 | 方法和说明 |
---|---|
byte[] |
array()
This gives direct access to the underlying storage array.
|
void |
arrayChanged()
During normal use cases the
AsciiString should be immutable, but if the underlying array is shared,
and changes then this needs to be called. |
int |
arrayOffset()
The offset into
array() for which data for this ByteString begins. |
static char |
b2c(byte b) |
byte |
byteAt(int index) |
static byte |
c2b(char c) |
static AsciiString |
cached(java.lang.String string)
Returns an
AsciiString containing the given string and retains/caches the input
string for later use in toString() . |
char |
charAt(int index) |
int |
compareTo(java.lang.CharSequence string)
Compares the specified string to this string using the ASCII values of the characters.
|
AsciiString |
concat(java.lang.CharSequence string)
Concatenates this string and the specified string.
|
boolean |
contains(java.lang.CharSequence cs)
Determines if this
String contains the sequence of characters in the CharSequence passed. |
static boolean |
contains(java.lang.CharSequence a,
java.lang.CharSequence b)
Determine if
a contains b in a case sensitive manner. |
static boolean |
containsAllContentEqualsIgnoreCase(java.util.Collection<java.lang.CharSequence> a,
java.util.Collection<java.lang.CharSequence> b)
Determine if
a contains all of the values in b using
contentEqualsIgnoreCase(CharSequence, CharSequence) to compare values. |
static boolean |
containsContentEqualsIgnoreCase(java.util.Collection<java.lang.CharSequence> collection,
java.lang.CharSequence value)
Determine if
collection contains value and using
contentEqualsIgnoreCase(CharSequence, CharSequence) to compare values. |
static boolean |
containsIgnoreCase(java.lang.CharSequence a,
java.lang.CharSequence b)
Determine if
a contains b in a case insensitive manner. |
boolean |
contentEquals(java.lang.CharSequence a)
Compares a
CharSequence to this String to determine if their contents are equal. |
static boolean |
contentEquals(java.lang.CharSequence a,
java.lang.CharSequence b)
Returns
true if the content of both CharSequence 's are equals. |
boolean |
contentEqualsIgnoreCase(java.lang.CharSequence string)
Compares the specified string to this string ignoring the case of the characters and returns true if they are
equal.
|
static boolean |
contentEqualsIgnoreCase(java.lang.CharSequence a,
java.lang.CharSequence b)
Returns
true if both CharSequence 's are equals when ignore the case. |
void |
copy(int srcIdx,
byte[] dst,
int dstIdx,
int length)
Copies the content of this string to a byte array.
|
void |
copy(int srcIdx,
char[] dst,
int dstIdx,
int length)
Copied the content of this string to a character array.
|
boolean |
endsWith(java.lang.CharSequence suffix)
Compares the specified string to this string to determine if the specified string is a suffix.
|
boolean |
equals(java.lang.Object obj) |
int |
forEachByte(ByteProcessor visitor)
Iterates over the readable bytes of this buffer with the specified
processor in ascending order. |
int |
forEachByte(int index,
int length,
ByteProcessor visitor)
Iterates over the specified area of this buffer with the specified
processor in ascending order. |
int |
forEachByteDesc(ByteProcessor visitor)
Iterates over the readable bytes of this buffer with the specified
processor in descending order. |
int |
forEachByteDesc(int index,
int length,
ByteProcessor visitor)
Iterates over the specified area of this buffer with the specified
processor in descending order. |
int |
hashCode()
Provides a case-insensitive hash code for Ascii like byte strings.
|
static int |
hashCode(java.lang.CharSequence value)
Returns the case-insensitive hash code of the specified string.
|
int |
indexOf(char ch,
int start)
Searches in this string for the index of the specified char
ch . |
int |
indexOf(java.lang.CharSequence string)
Searches in this string for the first index of the specified string.
|
static int |
indexOf(java.lang.CharSequence cs,
char searchChar,
int start)
Finds the first index in the
CharSequence that matches the
specified character. |
int |
indexOf(java.lang.CharSequence subString,
int start)
Searches in this string for the index of the specified string.
|
static int |
indexOfIgnoreCase(java.lang.CharSequence str,
java.lang.CharSequence searchStr,
int startPos)
Case in-sensitive find of the first index within a CharSequence
from the specified position.
|
static int |
indexOfIgnoreCaseAscii(java.lang.CharSequence str,
java.lang.CharSequence searchStr,
int startPos)
Case in-sensitive find of the first index within a CharSequence
from the specified position.
|
boolean |
isEmpty()
Determine if this instance has 0 length.
|
boolean |
isEntireArrayUsed()
Determine if the storage represented by
array() is entirely used. |
static boolean |
isUpperCase(byte value) |
static boolean |
isUpperCase(char value) |
int |
lastIndexOf(java.lang.CharSequence string)
Searches in this string for the last index of the specified string.
|
int |
lastIndexOf(java.lang.CharSequence subString,
int start)
Searches in this string for the index of the specified string.
|
int |
length()
The length in bytes of this instance.
|
boolean |
matches(java.lang.String expr)
Determines whether this string matches a given regular expression.
|
static AsciiString |
of(java.lang.CharSequence string)
Returns an
AsciiString containing the given character sequence. |
boolean |
parseBoolean() |
char |
parseChar() |
char |
parseChar(int start) |
double |
parseDouble() |
double |
parseDouble(int start,
int end) |
float |
parseFloat() |
float |
parseFloat(int start,
int end) |
int |
parseInt() |
int |
parseInt(int radix) |
int |
parseInt(int start,
int end) |
int |
parseInt(int start,
int end,
int radix) |
long |
parseLong() |
long |
parseLong(int radix) |
long |
parseLong(int start,
int end) |
long |
parseLong(int start,
int end,
int radix) |
short |
parseShort() |
short |
parseShort(int radix) |
short |
parseShort(int start,
int end) |
short |
parseShort(int start,
int end,
int radix) |
boolean |
regionMatches(boolean ignoreCase,
int thisStart,
java.lang.CharSequence string,
int start,
int length)
Compares the specified string to this string and compares the specified range of characters to determine if they
are the same.
|
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
|
boolean |
regionMatches(int thisStart,
java.lang.CharSequence string,
int start,
int length)
Compares the specified string to this string and compares the specified range of characters to determine if they
are the same.
|
static boolean |
regionMatchesAscii(java.lang.CharSequence cs,
boolean ignoreCase,
int csStart,
java.lang.CharSequence string,
int start,
int length)
This is optimized version of regionMatches for string with ASCII chars only
|
AsciiString |
replace(char oldChar,
char newChar)
Copies this string replacing occurrences of the specified character with another character.
|
AsciiString[] |
split(char delim)
Splits the specified
String with the specified delimiter.. |
AsciiString[] |
split(java.lang.String expr,
int max)
Splits this string using the supplied regular expression
expr . |
boolean |
startsWith(java.lang.CharSequence prefix)
Compares the specified string to this string to determine if the specified string is a prefix.
|
boolean |
startsWith(java.lang.CharSequence prefix,
int start)
Compares the specified string to this string, starting at the specified offset, to determine if the specified
string is a prefix.
|
AsciiString |
subSequence(int start)
Copies a range of characters into a new string.
|
AsciiString |
subSequence(int start,
int end)
Copies a range of characters into a new string.
|
AsciiString |
subSequence(int start,
int end,
boolean copy)
Either copy or share a subset of underlying sub-sequence of bytes.
|
byte[] |
toByteArray()
Converts this string to a byte array.
|
byte[] |
toByteArray(int start,
int end)
Converts a subset of this string to a byte array.
|
char[] |
toCharArray()
Copies the characters in this string to a character array.
|
char[] |
toCharArray(int start,
int end)
Copies the characters in this string to a character array.
|
AsciiString |
toLowerCase()
Converts the characters in this string to lowercase, using the default Locale.
|
static char |
toLowerCase(char c)
If the character is uppercase - converts the character to lowercase,
otherwise returns the character as it is.
|
java.lang.String |
toString()
Translates the entire byte string to a
String . |
java.lang.String |
toString(int start)
Translates the entire byte string to a
String using the charset encoding. |
java.lang.String |
toString(int start,
int end)
Translates the [
start , end ) range of this byte string to a String . |
AsciiString |
toUpperCase()
Converts the characters in this string to uppercase, using the default Locale.
|
AsciiString |
trim()
Duplicates this string removing white space characters from the beginning and end of the
string, without copying.
|
static java.lang.CharSequence |
trim(java.lang.CharSequence c)
Copies this string removing white space characters from the beginning and end of the string, and tries not to
copy if possible.
|
public static final AsciiString EMPTY_STRING
public static final int INDEX_NOT_FOUND
public static final HashingStrategy<java.lang.CharSequence> CASE_INSENSITIVE_HASHER
public static final HashingStrategy<java.lang.CharSequence> CASE_SENSITIVE_HASHER
public AsciiString(byte[] value)
public AsciiString(byte[] value, boolean copy)
copy
determines if a copy is made or the array is shared.public AsciiString(byte[] value, int start, int length, boolean copy)
byte[]
array.copy
- true
then a copy of the memory will be made. false
the underlying memory
will be shared.public AsciiString(java.nio.ByteBuffer value)
value
.
The copy will start at Buffer.position()
and copy Buffer.remaining()
bytes.public AsciiString(java.nio.ByteBuffer value, boolean copy)
value
.
There is a potential to share the underlying array storage if ByteBuffer.hasArray()
is true
.
if copy
is true
a copy will be made of the memory.
if copy
is false
the underlying storage will be shared, if possible.public AsciiString(java.nio.ByteBuffer value, int start, int length, boolean copy)
AsciiString
based upon the underlying storage from value
.
There is a potential to share the underlying array storage if ByteBuffer.hasArray()
is true
.
if copy
is true
a copy will be made of the memory.
if copy
is false
the underlying storage will be shared, if possible.public AsciiString(char[] value)
value
into this instance assuming ASCII encoding.public AsciiString(char[] value, int start, int length)
value
into this instance assuming ASCII encoding.
The copy will start at index start
and copy length
bytes.public AsciiString(char[] value, java.nio.charset.Charset charset)
value
into this instance using the encoding type of charset
.public AsciiString(char[] value, java.nio.charset.Charset charset, int start, int length)
value
into a this instance using the encoding type of charset
.
The copy will start at index start
and copy length
bytes.public AsciiString(java.lang.CharSequence value)
value
into this instance assuming ASCII encoding.public AsciiString(java.lang.CharSequence value, int start, int length)
value
into this instance assuming ASCII encoding.
The copy will start at index start
and copy length
bytes.public AsciiString(java.lang.CharSequence value, java.nio.charset.Charset charset)
value
into this instance using the encoding type of charset
.public AsciiString(java.lang.CharSequence value, java.nio.charset.Charset charset, int start, int length)
value
into this instance using the encoding type of charset
.
The copy will start at index start
and copy length
bytes.public int forEachByte(ByteProcessor visitor) throws java.lang.Exception
processor
in ascending order.-1
if the processor iterated to or beyond the end of the readable bytes.
The last-visited index If the ByteProcessor.process(byte)
returned false
.java.lang.Exception
public int forEachByte(int index, int length, ByteProcessor visitor) throws java.lang.Exception
processor
in ascending order.
(i.e. index
, (index + 1)
, .. (index + length - 1)
).-1
if the processor iterated to or beyond the end of the specified area.
The last-visited index If the ByteProcessor.process(byte)
returned false
.java.lang.Exception
public int forEachByteDesc(ByteProcessor visitor) throws java.lang.Exception
processor
in descending order.-1
if the processor iterated to or beyond the beginning of the readable bytes.
The last-visited index If the ByteProcessor.process(byte)
returned false
.java.lang.Exception
public int forEachByteDesc(int index, int length, ByteProcessor visitor) throws java.lang.Exception
processor
in descending order.
(i.e. (index + length - 1)
, (index + length - 2)
, ... index
).-1
if the processor iterated to or beyond the beginning of the specified area.
The last-visited index If the ByteProcessor.process(byte)
returned false
.java.lang.Exception
public byte byteAt(int index)
public boolean isEmpty()
public int length()
length
在接口中 java.lang.CharSequence
public void arrayChanged()
AsciiString
should be immutable, but if the underlying array is shared,
and changes then this needs to be called.public byte[] array()
toByteArray()
should be preferred over this method.
If the return value is changed then arrayChanged()
must be called.arrayOffset()
,
isEntireArrayUsed()
public int arrayOffset()
array()
for which data for this ByteString begins.array()
,
isEntireArrayUsed()
public boolean isEntireArrayUsed()
array()
is entirely used.array()
public byte[] toByteArray()
public byte[] toByteArray(int start, int end)
start
, end
).public void copy(int srcIdx, byte[] dst, int dstIdx, int length)
srcIdx
- the starting offset of characters to copy.dst
- the destination byte array.dstIdx
- the starting offset in the destination byte array.length
- the number of characters to copy.public char charAt(int index)
charAt
在接口中 java.lang.CharSequence
public boolean contains(java.lang.CharSequence cs)
String
contains the sequence of characters in the CharSequence
passed.cs
- the character sequence to search for.true
if the sequence of characters are contained in this string, otherwise false
.public int compareTo(java.lang.CharSequence string)
compareTo
在接口中 java.lang.Comparable<java.lang.CharSequence>
string
- the string to compare.java.lang.NullPointerException
- if string
is null
.public AsciiString concat(java.lang.CharSequence string)
string
- the string to concatenatepublic boolean endsWith(java.lang.CharSequence suffix)
suffix
- the suffix to look for.true
if the specified string is a suffix of this string, false
otherwise.java.lang.NullPointerException
- if suffix
is null
.public boolean contentEqualsIgnoreCase(java.lang.CharSequence string)
string
- the string to compare.true
if the specified string is equal to this string, false
otherwise.public char[] toCharArray()
public char[] toCharArray(int start, int end)
public void copy(int srcIdx, char[] dst, int dstIdx, int length)
srcIdx
- the starting offset of characters to copy.dst
- the destination character array.dstIdx
- the starting offset in the destination byte array.length
- the number of characters to copy.public AsciiString subSequence(int start)
start
- the offset of the first character (inclusive).java.lang.IndexOutOfBoundsException
- if start < 0
or start > length()
.public AsciiString subSequence(int start, int end)
subSequence
在接口中 java.lang.CharSequence
start
- the offset of the first character (inclusive).end
- The index to stop at (exclusive).java.lang.IndexOutOfBoundsException
- if start < 0
or start > length()
.public AsciiString subSequence(int start, int end, boolean copy)
start
- the offset of the first character (inclusive).end
- The index to stop at (exclusive).copy
- If true
then a copy of the underlying storage will be made.
If false
then the underlying storage will be shared.java.lang.IndexOutOfBoundsException
- if start < 0
or start > length()
.public int indexOf(java.lang.CharSequence string)
string
- the string to find.java.lang.NullPointerException
- if string
is null
.public int indexOf(java.lang.CharSequence subString, int start)
subString
- the string to find.start
- the starting offset.java.lang.NullPointerException
- if subString
is null
.public int indexOf(char ch, int start)
ch
.
The search for the char starts at the specified offset start
and moves towards the end of this string.ch
- the char to find.start
- the starting offset.ch
in this string,
-1 if found no occurrence.public int lastIndexOf(java.lang.CharSequence string)
string
- the string to find.java.lang.NullPointerException
- if string
is null
.public int lastIndexOf(java.lang.CharSequence subString, int start)
subString
- the string to find.start
- the starting offset.java.lang.NullPointerException
- if subString
is null
.public boolean regionMatches(int thisStart, java.lang.CharSequence string, int start, int length)
thisStart
- the starting offset in this string.string
- the string 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
otherwisejava.lang.NullPointerException
- if string
is null
.public boolean regionMatches(boolean ignoreCase, int thisStart, java.lang.CharSequence string, int start, int length)
ignoreCase
- specifies if case should be ignored.thisStart
- the starting offset in this string.string
- the string 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.java.lang.NullPointerException
- if string
is null
.public AsciiString replace(char oldChar, char newChar)
oldChar
- the character to replace.newChar
- the replacement character.public boolean startsWith(java.lang.CharSequence prefix)
prefix
- the string to look for.true
if the specified string is a prefix of this string, false
otherwisejava.lang.NullPointerException
- if prefix
is null
.public boolean startsWith(java.lang.CharSequence prefix, int start)
prefix
- the string to look for.start
- the starting offset.true
if the specified string occurs in this string at the specified offset, false
otherwise.java.lang.NullPointerException
- if prefix
is null
.public AsciiString toLowerCase()
public AsciiString toUpperCase()
public static java.lang.CharSequence trim(java.lang.CharSequence c)
c
- The CharSequence
to trim.<= \\u0020
removed from the beginning and the end.public AsciiString trim()
<= \\u0020
removed from the beginning and the end.public boolean contentEquals(java.lang.CharSequence a)
CharSequence
to this String
to determine if their contents are equal.a
- the character sequence to compare to.true
if equal, otherwise false
public boolean matches(java.lang.String expr)
expr
- the regular expression to be matched.true
if the expression matches, otherwise false
.java.util.regex.PatternSyntaxException
- if the syntax of the supplied regular expression is not valid.java.lang.NullPointerException
- if expr
is null
.public AsciiString[] split(java.lang.String expr, int max)
expr
. The parameter max
controls the
behavior how many times the pattern is applied to the string.expr
- the regular expression used to divide the string.max
- the number of entries in the resulting array.java.lang.NullPointerException
- if expr
is null
.java.util.regex.PatternSyntaxException
- if the syntax of the supplied regular expression is not valid.Pattern.split(CharSequence, int)
public AsciiString[] split(char delim)
String
with the specified delimiter..public int hashCode()
Provides a case-insensitive hash code for Ascii like byte strings.
hashCode
在类中 java.lang.Object
public boolean equals(java.lang.Object obj)
equals
在类中 java.lang.Object
public java.lang.String toString()
String
.toString
在接口中 java.lang.CharSequence
toString
在类中 java.lang.Object
toString(int)
public java.lang.String toString(int start)
String
using the charset
encoding.toString(int, int)
public java.lang.String toString(int start, int end)
start
, end
) range of this byte string to a String
.public boolean parseBoolean()
public char parseChar()
public char parseChar(int start)
public short parseShort()
public short parseShort(int radix)
public short parseShort(int start, int end)
public short parseShort(int start, int end, int radix)
public int parseInt()
public int parseInt(int radix)
public int parseInt(int start, int end)
public int parseInt(int start, int end, int radix)
public long parseLong()
public long parseLong(int radix)
public long parseLong(int start, int end)
public long parseLong(int start, int end, int radix)
public float parseFloat()
public float parseFloat(int start, int end)
public double parseDouble()
public double parseDouble(int start, int end)
public static AsciiString of(java.lang.CharSequence string)
AsciiString
containing the given character sequence. If the given string is already a
AsciiString
, just returns the same instance.public static AsciiString cached(java.lang.String string)
AsciiString
containing the given string and retains/caches the input
string for later use in toString()
.
Used for the constants (which already stored in the JVM's string table) and in cases
where the guaranteed use of the toString()
method.public static int hashCode(java.lang.CharSequence value)
hashCode()
so that you can put both AsciiString
s and arbitrary
CharSequence
s into the same headers.public static boolean contains(java.lang.CharSequence a, java.lang.CharSequence b)
a
contains b
in a case sensitive manner.public static boolean containsIgnoreCase(java.lang.CharSequence a, java.lang.CharSequence b)
a
contains b
in a case insensitive manner.public static boolean contentEqualsIgnoreCase(java.lang.CharSequence a, java.lang.CharSequence b)
true
if both CharSequence
's are equals when ignore the case. This only supports 8-bit
ASCII.public static boolean containsContentEqualsIgnoreCase(java.util.Collection<java.lang.CharSequence> collection, java.lang.CharSequence value)
collection
contains value
and using
contentEqualsIgnoreCase(CharSequence, CharSequence)
to compare values.collection
- The collection to look for and equivalent element as value
.value
- The value to look for in collection
.true
if collection
contains value
according to
contentEqualsIgnoreCase(CharSequence, CharSequence)
. false
otherwise.contentEqualsIgnoreCase(CharSequence, CharSequence)
public static boolean containsAllContentEqualsIgnoreCase(java.util.Collection<java.lang.CharSequence> a, java.util.Collection<java.lang.CharSequence> b)
a
contains all of the values in b
using
contentEqualsIgnoreCase(CharSequence, CharSequence)
to compare values.a
- The collection under test.b
- The values to test for.true
if a
contains all of the values in b
using
contentEqualsIgnoreCase(CharSequence, CharSequence)
to compare values. false
otherwise.contentEqualsIgnoreCase(CharSequence, CharSequence)
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.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.public static boolean regionMatchesAscii(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.public static int indexOfIgnoreCase(java.lang.CharSequence str, java.lang.CharSequence searchStr, int startPos)
Case in-sensitive find of the first index within a CharSequence from the specified position.
A null
CharSequence will return -1
.
A negative start position is treated as zero.
An empty ("") search CharSequence always matches.
A start position greater than the string length only matches
an empty search CharSequence.
AsciiString.indexOfIgnoreCase(null, *, *) = -1 AsciiString.indexOfIgnoreCase(*, null, *) = -1 AsciiString.indexOfIgnoreCase("", "", 0) = 0 AsciiString.indexOfIgnoreCase("aabaabaa", "A", 0) = 0 AsciiString.indexOfIgnoreCase("aabaabaa", "B", 0) = 2 AsciiString.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1 AsciiString.indexOfIgnoreCase("aabaabaa", "B", 3) = 5 AsciiString.indexOfIgnoreCase("aabaabaa", "B", 9) = -1 AsciiString.indexOfIgnoreCase("aabaabaa", "B", -1) = 2 AsciiString.indexOfIgnoreCase("aabaabaa", "", 2) = 2 AsciiString.indexOfIgnoreCase("abc", "", 9) = -1
str
- the CharSequence to check, may be nullsearchStr
- the CharSequence to find, may be nullstartPos
- the start position, negative treated as zeronull
string inputpublic static int indexOfIgnoreCaseAscii(java.lang.CharSequence str, java.lang.CharSequence searchStr, int startPos)
Case in-sensitive find of the first index within a CharSequence from the specified position. This method optimized and works correctly for ASCII CharSequences only
A null
CharSequence will return -1
.
A negative start position is treated as zero.
An empty ("") search CharSequence always matches.
A start position greater than the string length only matches
an empty search CharSequence.
AsciiString.indexOfIgnoreCase(null, *, *) = -1 AsciiString.indexOfIgnoreCase(*, null, *) = -1 AsciiString.indexOfIgnoreCase("", "", 0) = 0 AsciiString.indexOfIgnoreCase("aabaabaa", "A", 0) = 0 AsciiString.indexOfIgnoreCase("aabaabaa", "B", 0) = 2 AsciiString.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1 AsciiString.indexOfIgnoreCase("aabaabaa", "B", 3) = 5 AsciiString.indexOfIgnoreCase("aabaabaa", "B", 9) = -1 AsciiString.indexOfIgnoreCase("aabaabaa", "B", -1) = 2 AsciiString.indexOfIgnoreCase("aabaabaa", "", 2) = 2 AsciiString.indexOfIgnoreCase("abc", "", 9) = -1
str
- the CharSequence to check, may be nullsearchStr
- the CharSequence to find, may be nullstartPos
- the start position, negative treated as zeronull
string inputpublic static int indexOf(java.lang.CharSequence cs, char searchChar, int start)
Finds the first index in the CharSequence
that matches the
specified character.
cs
- the CharSequence
to be processed, not nullsearchChar
- the char to be searched forstart
- the start index, negative starts at the string startsearchChar
is not found or cs == null
public static char toLowerCase(char c)
public static boolean isUpperCase(byte value)
public static boolean isUpperCase(char value)
public static byte c2b(char c)
public static char b2c(byte b)