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.
Modifier and Type | Class and Description |
---|---|
private static class | |
private static interface | |
private static class | |
private static class |
Modifier and Type | Field and Description |
---|---|
public static final HashingStrategy | |
public static final HashingStrategy | |
public static final AsciiString | |
private int | hash
The hash code is cached after it is first computed. |
public static final int | |
private final int | |
private static final char | |
private final int | |
private String | string
Used to cache the |
private final byte[] | value
If this value is modified outside the constructor then call |
Access | Constructor and Description |
---|---|
public | |
public | |
public | AsciiString(byte[] value, int start, int length, boolean
true then a copy of the memory will be made. false the underlying memory
will be shared.Construct a new instance from a |
public | |
public | AsciiString(ByteBuffer value, boolean copy)
Initialize an instance based upon the underlying storage from |
public | AsciiString(ByteBuffer value, int start, int length, boolean copy)
Initialize an |
public | |
public | AsciiString(char[] value, int start, int length)
Create a copy of |
public | AsciiString(char[] value, Charset charset)
Create a copy of |
public | AsciiString(char[] value, Charset charset, int start, int length)
Create a copy of |
public | |
public | AsciiString(CharSequence value, int start, int length)
Create a copy of |
public | AsciiString(CharSequence value, Charset charset)
Create a copy of |
public | AsciiString(CharSequence value, Charset charset, int start, int length)
Create a copy of |
Modifier and Type | Method and Description |
---|---|
public byte[] | |
public void | arrayChanged()
During normal use cases the |
public int | |
public static char | |
public byte | |
public static byte | |
private static byte | |
public static AsciiString | cached(String string)
Returns an |
public char | charAt(int
the index of the index)char value to be returnedImplements java. char value at the specified index.
|
public int | Returns: 0 if the strings are equal, a negative integer if this string is before the specified string, or a positive integer if this string is after the specified string.the string to compare. string)Implements java. |
public AsciiString | Returns: a new string which is the concatenation of this string and the specified string.the string to concatenate string)Concatenates this string and the specified string. |
public boolean | Returns: true if the sequence of characters are contained in this string, otherwise false .the character sequence to search for. cs)Determines if this |
public static boolean | |
private static boolean | |
public static boolean | Returns: true if a contains all of the values in b using
contentEqualsIgnoreCase(CharSequence, CharSequence) to compare values. false otherwise.The collection under test. a, Collection<CharSequence> The values to test for. b)Determine if |
public static boolean | Returns: true if collection contains value according to
contentEqualsIgnoreCase(CharSequence, CharSequence) . false otherwise.The collection to look for and equivalent element as collection, CharSequence value .The value to look for in value)collection .Determine if |
public static boolean | containsIgnoreCase(CharSequence a, CharSequence b)
Determine if |
public boolean | Returns: true if equal, otherwise false the character sequence to compare to. a)Compares a |
public static boolean | contentEquals(CharSequence a, CharSequence b)
Returns |
public boolean | Returns: true if the specified string is equal to this string, false otherwise.the string to compare. string)Compares the specified string to this string ignoring the case of the characters and returns true if they are equal. |
public static boolean | contentEqualsIgnoreCase(CharSequence a, CharSequence b)
Returns |
public void | copy(int
the starting offset of characters to copy. srcIdx, byte[] the destination byte array. dst, int the starting offset in the destination byte array. dstIdx, int the number of characters to copy. length)Copies the content of this string to a byte array. |
public void | copy(int
the starting offset of characters to copy. srcIdx, char[] the destination character array. dst, int the starting offset in the destination byte array. dstIdx, int the number of characters to copy. length)Copied the content of this string to a character array. |
public boolean | Returns: true if the specified string is a suffix of this string, false otherwise.the suffix to look for. suffix)Compares the specified string to this string to determine if the specified string is a suffix. |
public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. |
private static boolean | |
private static boolean | |
public int | Returns: -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 .Iterates over the readable bytes of this buffer with the specified |
public int | Returns: -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 .Iterates over the specified area of this buffer with the specified |
private int | |
public int | Returns: -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 .Iterates over the readable bytes of this buffer with the specified |
public int | Returns: -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 .Iterates over the specified area of this buffer with the specified |
private int | |
public int | |
public static int | |
public int | Returns: the index of the first character of the specified string in this string, -1 if the specified string is not a substring.the string to find. string)Searches in this string for the first index of the specified string. |
public int | Returns: the index of the first character of the specified string in this string, -1 if the specified string is not a substring.the string to find. subString, int the starting offset. start)Searches in this string for the index of the specified string. |
public int | Returns: the index of the first occurrence of the specified charch in this string,
-1 if found no occurrence.the char to find. ch, int the starting offset. start)Searches in this string for the index of the specified char |
public static int | Returns: the index where the search char was found, -1 if charsearchChar is not found or cs == null the cs, final char CharSequence to be processed, not nullthe char to be searched for searchChar, int the start index, negative starts at the string start start)Finds the first index in the |
public static int | Returns: the first index of the search CharSequence (always ≥ startPos), -1 if no match ornull string inputthe CharSequence to check, may be null str, final CharSequence the CharSequence to find, may be null searchStr, int the start position, negative treated as zero startPos)Case in-sensitive find of the first index within a CharSequence from the specified position. |
public static int | Returns: the first index of the search CharSequence (always ≥ startPos), -1 if no match ornull string inputthe CharSequence to check, may be null str, final CharSequence the CharSequence to find, may be null searchStr, int the start position, negative treated as zero startPos)Case in-sensitive find of the first index within a CharSequence from the specified position. |
public boolean | |
public boolean | |
private static boolean | |
public static boolean | |
public static boolean | |
public int | Returns: the index of the first character of the specified string in this string, -1 if the specified string is not a substring.the string to find. string)Searches in this string for the last index of the specified string. |
public int | Returns: the index of the first character of the specified string in this string , -1 if the specified string is not a substring.the string to find. subString, int the starting offset. start)Searches in this string for the index of the specified string. |
public int | |
public boolean | |
public static AsciiString | |
public boolean | |
public char | |
public char | |
public double | |
public double | |
public float | |
public float | |
public int | |
public int | |
public int | |
public int | |
private int | |
public long | |
public long | |
public long | |
public long | |
private long | |
public short | |
public short | |
public short | |
public short | |
public boolean | Returns: true if the ranges of characters are equal, false otherwisethe starting offset in this string. thisStart, CharSequence the string to compare. string, int the starting offset in the specified string. start, int the number of characters to compare. length)Compares the specified string to this string and compares the specified range of characters to determine if they are the same. |
public boolean | Returns: true if the ranges of characters are equal, false otherwise.specifies if case should be ignored. ignoreCase, int the starting offset in this string. thisStart, CharSequence the string to compare. string, int the starting offset in the specified string. start, int the number of characters to compare. length)Compares the specified string to this string and compares the specified range of characters to determine if they are the same. |
public static boolean | Returns: true if the ranges of characters are equal, false otherwise.the cs, final boolean CharSequence to be processedspecifies if case should be ignored. ignoreCase, final int the starting offset in the csStart, final CharSequence cs CharSequencethe string, final int CharSequence to compare.the starting offset in the specified start, final int string .the number of characters to compare. length)This methods make regionMatches operation correctly for any chars in strings |
public static boolean | Returns: true if the ranges of characters are equal, false otherwise.the cs, final boolean CharSequence to be processedspecifies if case should be ignored. ignoreCase, final int the starting offset in the csStart, final CharSequence cs CharSequencethe string, final int CharSequence to compare.the starting offset in the specified start, final int string .the number of characters to compare. length)This is optimized version of regionMatches for string with ASCII chars only |
private static boolean | regionMatchesCharSequences(final CharSequence cs, final int csStart, final CharSequence string, final int start, final int length, AsciiString.
|
public AsciiString | Returns: a new string with occurrences of oldChar replaced by newChar.the character to replace. oldChar, char the replacement character. newChar)Copies this string replacing occurrences of the specified character with another character. |
public AsciiString[] | |
public AsciiString[] | |
public boolean | Returns: true if the specified string is a prefix of this string, false otherwisethe string to look for. prefix)Compares the specified string to this string to determine if the specified string is a prefix. |
public boolean | Returns: true if the specified string occurs in this string at the specified offset, false
otherwise.the string to look for. prefix, int the starting offset. start)Compares the specified string to this string, starting at the specified offset, to determine if the specified string is a prefix. |
public AsciiString | Returns: a new string containing the characters from start to the end of the string.the offset of the first character (inclusive). start)Copies a range of characters into a new string. |
public AsciiString | Returns: a new string containing the characters from start to the end of the string.the offset of the first character (inclusive). start, int The index to stop at (exclusive). end)Implements java. |
public AsciiString | Returns: a new string containing the characters from start to the end of the string.the offset of the first character (inclusive). start, int The index to stop at (exclusive). end, boolean If copy)true then a copy of the underlying storage will be made.
If false then the underlying storage will be shared.Either copy or share a subset of underlying sub-sequence of bytes. |
private static AsciiString[] | |
public byte[] | |
public byte[] | |
public char[] | Returns: a character array containing the characters of this string.Copies the characters in this string to a character array. |
public char[] | Returns: a character array containing the characters of this string.Copies the characters in this string to a character array. |
public AsciiString | Returns: a new string containing the lowercase characters equivalent to the characters in this string.Converts the characters in this string to lowercase, using the default Locale. |
private static byte | |
public static char | Returns: lowercase ASCII character equivalentIf the character is uppercase - converts the character to lowercase, otherwise returns the character as it is. |
public String | toString()
Overrides java. Implements java. String .
|
public String | |
public String | |
public AsciiString | Returns: a new string containing the uppercase characters equivalent to the characters in this string.Converts the characters in this string to uppercase, using the default Locale. |
private static byte | |
public static CharSequence | Returns: a new string with characters<= \\u0020 removed from the beginning and the end.The c)CharSequence to trim.Copies this string removing white space characters from the beginning and end of the string, and tries not to copy if possible. |
public AsciiString | Returns: a new string with characters<= \\u0020 removed from the beginning and the end.Duplicates this string removing white space characters from the beginning and end of the string, without copying. |