public final class AsciiString extends ByteString implements CharSequence, Comparable<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 TextHeaders.ByteString.ByteStringFactory| Modifier and Type | Field and Description |
|---|---|
static HashingStrategy<CharSequence> |
CASE_INSENSITIVE_HASHER |
static HashingStrategy<CharSequence> |
CASE_SENSITIVE_HASHER |
static AsciiString |
EMPTY_STRING |
HASH_CODE_PRIME, value| Constructor and Description |
|---|
AsciiString(byte[] value) |
AsciiString(byte[] value,
boolean copy) |
AsciiString(byte[] value,
int start,
int length,
boolean copy) |
AsciiString(ByteBuffer value) |
AsciiString(ByteBuffer value,
int start,
int length,
boolean copy) |
AsciiString(ByteString value,
boolean copy) |
AsciiString(char[] value) |
AsciiString(char[] value,
int start,
int length) |
AsciiString(CharSequence value) |
AsciiString(CharSequence value,
int start,
int length) |
| Modifier and Type | Method and Description |
|---|---|
void |
arrayChanged()
During normal use cases the
ByteString should be immutable, but if the underlying array is shared,
and changes then this needs to be called. |
static int |
caseInsensitiveHashCode(CharSequence value)
Returns the case-insensitive hash code of the specified string.
|
char |
charAt(int index) |
int |
compareTo(CharSequence string)
Compares the specified string to this string using the ASCII values of the characters.
|
AsciiString |
concat(CharSequence string)
Concatenates this string and the specified string.
|
boolean |
contains(CharSequence cs)
Determines if this
String contains the sequence of characters in the CharSequence passed. |
boolean |
contentEquals(CharSequence a)
Compares a
CharSequence to this String to determine if their contents are equal. |
static boolean |
contentEquals(CharSequence a,
CharSequence b)
Returns
true if the content of both CharSequence's are equals. |
boolean |
contentEqualsIgnoreCase(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(CharSequence a,
CharSequence b)
Returns
true if both CharSequence's are equals when ignore the case. |
void |
copy(int srcIdx,
char[] dst,
int dstIdx,
int length)
Copied the content of this string to a character array.
|
boolean |
endsWith(CharSequence suffix)
Compares the specified string to this string to determine if the specified string is a suffix.
|
static int |
hashCode(CharSequence value)
A case-sensitive version of
caseInsensitiveHashCode(CharSequence). |
int |
hashCodeCaseInsensitive()
Generate a hash code that will be consistent regardless of ASCII character casing.
|
int |
indexOf(CharSequence string)
Searches in this string for the first index of the specified string.
|
int |
indexOf(CharSequence subString,
int start)
Searches in this string for the index of the specified string.
|
int |
lastIndexOf(CharSequence string)
Searches in this string for the last index of the specified string.
|
int |
lastIndexOf(CharSequence subString,
int start)
Searches in this string for the index of the specified string.
|
boolean |
matches(String expr)
Determines whether this string matches a given regular expression.
|
static AsciiString |
of(CharSequence string)
Returns an
AsciiString containing the given character sequence. |
boolean |
regionMatches(boolean ignoreCase,
int thisStart,
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.
|
boolean |
regionMatches(int thisStart,
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.
|
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(String expr,
int max)
Splits this string using the supplied regular expression
expr. |
boolean |
startsWith(CharSequence prefix)
Compares the specified string to this string to determine if the specified string is a prefix.
|
boolean |
startsWith(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.
|
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.
|
String |
toString(Charset charset,
int start,
int end)
|
AsciiString |
toUpperCase()
Converts the characters in this string to uppercase, using the default Locale.
|
AsciiString |
trim()
Copies this string removing white space characters from the beginning and end of the string.
|
array, arrayOffset, byteAt, copy, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, fromAscii, hashCode, isEmpty, isEntireArrayUsed, length, parseAsciiDouble, parseAsciiDouble, parseAsciiFloat, parseAsciiFloat, parseAsciiInt, parseAsciiInt, parseAsciiInt, parseAsciiInt, parseAsciiLong, parseAsciiLong, parseAsciiLong, parseAsciiLong, parseAsciiShort, parseAsciiShort, parseAsciiShort, parseAsciiShort, parseChar, parseChar, subSequence, toByteArray, toByteArray, toString, toString, toStringclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitlength, toStringpublic static final AsciiString EMPTY_STRING
public static final HashingStrategy<CharSequence> CASE_INSENSITIVE_HASHER
public static final HashingStrategy<CharSequence> CASE_SENSITIVE_HASHER
public AsciiString(byte[] value)
public AsciiString(byte[] value,
boolean copy)
public AsciiString(byte[] value,
int start,
int length,
boolean copy)
public AsciiString(ByteString value, boolean copy)
public AsciiString(ByteBuffer value)
public AsciiString(ByteBuffer value, int start, int length, boolean copy)
public AsciiString(char[] value)
public AsciiString(char[] value,
int start,
int length)
public AsciiString(CharSequence value)
public AsciiString(CharSequence value, int start, int length)
public static AsciiString of(CharSequence string)
AsciiString containing the given character sequence. If the given string is already a
AsciiString, just returns the same instance.public char charAt(int index)
charAt in interface CharSequencepublic void arrayChanged()
ByteStringByteString should be immutable, but if the underlying array is shared,
and changes then this needs to be called.arrayChanged in class ByteStringpublic String toString(Charset charset, int start, int end)
ByteStringtoString in class ByteStringpublic int compareTo(CharSequence string)
compareTo in interface Comparable<CharSequence>string - the string to compare.NullPointerException - if string is null.public AsciiString concat(CharSequence string)
string - the string to concatenatepublic boolean endsWith(CharSequence suffix)
suffix - the suffix to look for.true if the specified string is a suffix of this string, false otherwise.NullPointerException - if suffix is null.public boolean contentEqualsIgnoreCase(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)
ByteStringsubSequence in class ByteStringstart - the offset of the first character (inclusive).public AsciiString subSequence(int start, int end)
ByteStringsubSequence in interface CharSequencesubSequence in class ByteStringstart - the offset of the first character (inclusive).end - The index to stop at (exclusive).public AsciiString subSequence(int start, int end, boolean copy)
ByteStringsubSequence in class ByteStringstart - 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.public int indexOf(CharSequence string)
string - the string to find.NullPointerException - if string is null.public int indexOf(CharSequence subString, int start)
subString - the string to find.start - the starting offset.NullPointerException - if subString is null.public int lastIndexOf(CharSequence string)
string - the string to find.NullPointerException - if string is null.public int lastIndexOf(CharSequence subString, int start)
subString - the string to find.start - the starting offset.NullPointerException - if subString is null.public boolean regionMatches(int thisStart,
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 otherwiseNullPointerException - if string is null.public boolean regionMatches(boolean ignoreCase,
int thisStart,
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.NullPointerException - if string is null.public AsciiString replace(char oldChar, char newChar)
oldChar - the character to replace.newChar - the replacement character.public boolean startsWith(CharSequence prefix)
prefix - the string to look for.true if the specified string is a prefix of this string, false otherwiseNullPointerException - if prefix is null.public boolean startsWith(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.NullPointerException - if prefix is null.public AsciiString toLowerCase()
public AsciiString toUpperCase()
public AsciiString trim()
<= \\u0020 removed from the beginning and the end.public boolean contentEquals(CharSequence a)
CharSequence to this String to determine if their contents are equal.a - the character sequence to compare to.true if equal, otherwise falsepublic boolean matches(String expr)
expr - the regular expression to be matched.true if the expression matches, otherwise false.PatternSyntaxException - if the syntax of the supplied regular expression is not valid.NullPointerException - if expr is null.public AsciiString[] split(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.NullPointerException - if expr is null.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 hashCodeCaseInsensitive()
NOTE: This must be compatible with caseInsensitiveHashCode(CharSequence).
public static int caseInsensitiveHashCode(CharSequence value)
ByteString.hashCode() so that you can put both AsciiStrings and arbitrary
CharSequences into the same TextHeaders.public static int hashCode(CharSequence value)
caseInsensitiveHashCode(CharSequence).value - public static boolean contentEqualsIgnoreCase(CharSequence a, CharSequence b)
true if both CharSequence's are equals when ignore the case. This only supports 8-bit
ASCII.public static boolean contentEquals(CharSequence a, CharSequence b)
true if the content of both CharSequence's are equals. This only supports 8-bit ASCII.public boolean contains(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.Copyright © 2008–2015 The Netty Project. All rights reserved.