Class ByteBufAsciiString
- java.lang.Object
-
- com.linkedin.alpini.base.misc.ByteBufAsciiString
-
- All Implemented Interfaces:
io.netty.util.ReferenceCounted,java.lang.CharSequence,java.lang.Comparable<java.lang.CharSequence>
public final class ByteBufAsciiString extends java.lang.Object implements java.lang.CharSequence, io.netty.util.ReferenceCounted, java.lang.Comparable<java.lang.CharSequence>A string implementation, similar to AsciiString, which is backed by a ByteBuf instead of a byte[] array.
-
-
Field Summary
Fields Modifier and Type Field Description static ByteBufAsciiStringEMPTY_STRINGstatic intINDEX_NOT_FOUND
-
Constructor Summary
Constructors Constructor Description ByteBufAsciiString(byte[] bytes, int offset, int length, boolean copy)ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, byte[] bytes)ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, char[] value)Create a copy ofvalueinto this instance assuming ASCII encoding.ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, char[] value, int start, int length)Create a copy ofvalueinto this instance assuming ASCII encoding.ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, char[] value, java.nio.charset.Charset charset)Create a copy ofvalueinto this instance using the encoding type ofcharset.ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, char[] value, java.nio.charset.Charset charset, int start, int length)Create a copy ofvalueinto a this instance using the encoding type ofcharset.ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, java.lang.CharSequence charSequence)ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, java.lang.CharSequence value, int start, int length)Create a copy ofvalueinto this instance assuming ASCII encoding.ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, java.lang.CharSequence value, java.nio.charset.Charset charset)Create a copy ofvalueinto this instance using the encoding type ofcharset.ByteBufAsciiString(io.netty.buffer.ByteBufAllocator alloc, java.lang.CharSequence value, java.nio.charset.Charset charset, int start, int length)Create a copy ofvalueinto this instance using the encoding type ofcharset.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static charb2c(byte b)bytebyteAt(int index)static bytec2b(char c)static bytec2b0(char c)charcharAt(int index)intcompareTo(java.lang.CharSequence string)Compares the specified string to this string using the ASCII values of the characters.ByteBufAsciiStringconcat(java.lang.CharSequence... strings)Concatenates this string and the specified string.booleancontains(java.lang.CharSequence cs)Determines if thisStringcontains the sequence of characters in theCharSequencepassed.static booleancontains(java.lang.CharSequence a, java.lang.CharSequence b)Determine ifacontainsbin a case sensitive manner.static booleancontainsAllContentEqualsIgnoreCase(java.util.Collection<java.lang.CharSequence> a, java.util.Collection<java.lang.CharSequence> b)Determine ifacontains all of the values inbusingcontentEqualsIgnoreCase(CharSequence, CharSequence)to compare values.static booleancontainsContentEqualsIgnoreCase(java.util.Collection<java.lang.CharSequence> collection, java.lang.CharSequence value)Determine ifcollectioncontainsvalueand usingcontentEqualsIgnoreCase(CharSequence, CharSequence)to compare values.static booleancontainsIgnoreCase(java.lang.CharSequence a, java.lang.CharSequence b)Determine ifacontainsbin a case insensitive manner.booleancontentEquals(java.lang.CharSequence a)Compares aCharSequenceto thisStringto determine if their contents are equal.static booleancontentEquals(java.lang.CharSequence a, java.lang.CharSequence b)Returnstrueif the content of bothCharSequence's are equals.booleancontentEqualsIgnoreCase(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 booleancontentEqualsIgnoreCase(java.lang.CharSequence a, java.lang.CharSequence b)Returnstrueif bothCharSequence's are equals when ignore the case.static ByteBufAsciiStringcopy(io.netty.buffer.ByteBuf byteBuf, int index, int length)booleanendsWith(java.lang.CharSequence suffix)Compares the specified string to this string to determine if the specified string is a suffix.booleanequals(java.lang.Object obj)intforEachByte(int index, int length, io.netty.util.ByteProcessor visitor)Iterates over the specified area of this buffer with the specifiedprocessorin ascending order.intforEachByte(io.netty.util.ByteProcessor visitor)Iterates over the readable bytes of this buffer with the specifiedprocessorin ascending order.intforEachByteDesc(int index, int length, io.netty.util.ByteProcessor visitor)Iterates over the specified area of this buffer with the specifiedprocessorin descending order.intforEachByteDesc(io.netty.util.ByteProcessor visitor)Iterates over the readable bytes of this buffer with the specifiedprocessorin descending order.inthashCode()static inthashCode(java.lang.CharSequence value)Returns the case-insensitive hash code of the specified string.intindexOf(char ch, int start)Searches in this string for the index of the specified charch.intindexOf(java.lang.CharSequence string)Searches in this string for the first index of the specified string.static intindexOf(java.lang.CharSequence cs, char searchChar, int start)Finds the first index in theCharSequencethat matches the specified character.intindexOf(java.lang.CharSequence subString, int start)Searches in this string for the index of the specified string.static intindexOfIgnoreCase(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 intindexOfIgnoreCaseAscii(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.booleanisEmpty()Determine if this instance has 0 length.static booleanisUpperCase(byte value)static booleanisUpperCase(char value)intlastIndexOf(java.lang.CharSequence string)Searches in this string for the last index of the specified string.intlastIndexOf(java.lang.CharSequence subString, int start)Searches in this string for the index of the specified string.intlength()booleanmatches(java.lang.String expr)Determines whether this string matches a given regular expression.static ByteBufAsciiStringread(io.netty.buffer.ByteBuf byteBuf, int length)static ByteBufAsciiStringreadBytes(io.netty.buffer.ByteBuf byteBuf, int length)static ByteBufAsciiStringreadRetainedSlice(io.netty.buffer.ByteBuf byteBuf, int length)intrefCnt()booleanregionMatches(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.booleanregionMatches(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 booleanregionMatches(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 stringsstatic booleanregionMatchesAscii(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 onlybooleanrelease()booleanrelease(int decrement)ByteBufAsciiStringreplace(char oldChar, char newChar)Copies this string replacing occurrences of the specified character with another character.ByteBufAsciiStringretain()ByteBufAsciiStringretain(int increment)static ByteBufAsciiStringslice(io.netty.buffer.ByteBuf byteBuf, int index, int length)ByteBufAsciiString[]split(char delim)Splits the specifiedStringwith the specified delimiter..ByteBufAsciiString[]split(java.lang.String expr, int max)Splits this string using the supplied regular expressionexpr.ByteBufAsciiString[]split(java.util.regex.Pattern pattern)ByteBufAsciiString[]split(java.util.regex.Pattern pattern, int limit)booleanstartsWith(java.lang.CharSequence prefix)Compares the specified string to this string to determine if the specified string is a prefix.booleanstartsWith(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.static booleanstartsWith(java.lang.CharSequence string, java.lang.CharSequence prefix)Compares the specified string to this string to determine if the specified string is a prefix.static booleanstartsWith(java.lang.CharSequence string, 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.static booleanstartsWithIgnoreCase(java.lang.CharSequence string, java.lang.CharSequence prefix)Compares the specified string to this string to determine if the specified string is a prefix.static booleanstartsWithIgnoreCase(java.lang.CharSequence string, java.lang.CharSequence prefix, int start)ByteBufAsciiStringsubSequence(int start)Copies a range of characters into a new string.ByteBufAsciiStringsubSequence(int start, int end)Copies a range of characters into a new string.ByteBufAsciiStringsubSequence(int start, int end, boolean copy)Either copy or share a subset of underlying sub-sequence of bytes.io.netty.util.AsciiStringtoAsciiString()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.ByteBufAsciiStringtoLowerCase()Converts the characters in this string to lowercase, using the default Locale.java.lang.StringtoString()Translates the entire byte string to aString.java.lang.StringtoString(int start)Translates the entire byte string to aStringusing thecharsetencoding.java.lang.StringtoString(int start, int end)Translates the [start,end) range of this byte string to aString.io.netty.util.ReferenceCountedtouch()io.netty.util.ReferenceCountedtouch(java.lang.Object hint)ByteBufAsciiStringtoUpperCase()Converts the characters in this string to uppercase, using the default Locale.ByteBufAsciiStringtrim()Duplicates this string removing white space characters from the beginning and end of the string, without copying.static java.lang.CharSequencetrim(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.
-
-
-
Field Detail
-
EMPTY_STRING
public static final ByteBufAsciiString EMPTY_STRING
-
INDEX_NOT_FOUND
public static final int INDEX_NOT_FOUND
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull byte[] bytes)
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull java.lang.CharSequence charSequence)
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull java.lang.CharSequence value, int start, int length)Create a copy ofvalueinto this instance assuming ASCII encoding. The copy will start at indexstartand copylengthbytes.
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull char[] value)Create a copy ofvalueinto this instance assuming ASCII encoding.
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull char[] value, int start, int length)Create a copy ofvalueinto this instance assuming ASCII encoding. The copy will start at indexstartand copylengthbytes.
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull char[] value, java.nio.charset.Charset charset)Create a copy ofvalueinto this instance using the encoding type ofcharset.
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull char[] value, java.nio.charset.Charset charset, int start, int length)Create a copy ofvalueinto a this instance using the encoding type ofcharset. The copy will start at indexstartand copylengthbytes.
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull java.lang.CharSequence value, java.nio.charset.Charset charset)Create a copy ofvalueinto this instance using the encoding type ofcharset.
-
ByteBufAsciiString
public ByteBufAsciiString(@Nonnull io.netty.buffer.ByteBufAllocator alloc, @Nonnull java.lang.CharSequence value, java.nio.charset.Charset charset, int start, int length)Create a copy ofvalueinto this instance using the encoding type ofcharset. The copy will start at indexstartand copylengthbytes.
-
ByteBufAsciiString
public ByteBufAsciiString(byte[] bytes, int offset, int length, boolean copy)
-
-
Method Detail
-
readBytes
public static ByteBufAsciiString readBytes(io.netty.buffer.ByteBuf byteBuf, int length)
-
readRetainedSlice
public static ByteBufAsciiString readRetainedSlice(io.netty.buffer.ByteBuf byteBuf, int length)
-
read
public static ByteBufAsciiString read(io.netty.buffer.ByteBuf byteBuf, int length)
-
copy
public static ByteBufAsciiString copy(io.netty.buffer.ByteBuf byteBuf, int index, int length)
-
slice
public static ByteBufAsciiString slice(io.netty.buffer.ByteBuf byteBuf, int index, int length)
-
forEachByte
public int forEachByte(io.netty.util.ByteProcessor visitor)
Iterates over the readable bytes of this buffer with the specifiedprocessorin ascending order.- Returns:
-1if the processor iterated to or beyond the end of the readable bytes. The last-visited index If theByteProcessor.process(byte)returnedfalse.
-
forEachByte
public int forEachByte(int index, int length, io.netty.util.ByteProcessor visitor)Iterates over the specified area of this buffer with the specifiedprocessorin ascending order. (i.e.index,(index + 1), ..(index + length - 1)).- Returns:
-1if the processor iterated to or beyond the end of the specified area. The last-visited index If theByteProcessor.process(byte)returnedfalse.
-
forEachByteDesc
public int forEachByteDesc(io.netty.util.ByteProcessor visitor)
Iterates over the readable bytes of this buffer with the specifiedprocessorin descending order.- Returns:
-1if the processor iterated to or beyond the beginning of the readable bytes. The last-visited index If theByteProcessor.process(byte)returnedfalse.
-
forEachByteDesc
public int forEachByteDesc(int index, int length, io.netty.util.ByteProcessor visitor)Iterates over the specified area of this buffer with the specifiedprocessorin descending order. (i.e.(index + length - 1),(index + length - 2), ...index).- Returns:
-1if the processor iterated to or beyond the beginning of the specified area. The last-visited index If theByteProcessor.process(byte)returnedfalse.
-
isEmpty
public boolean isEmpty()
Determine if this instance has 0 length.
-
length
public int length()
- Specified by:
lengthin interfacejava.lang.CharSequence
-
byteAt
public byte byteAt(int index)
-
toByteArray
public byte[] toByteArray()
Converts this string to a byte array.
-
toByteArray
public byte[] toByteArray(int start, int end)Converts a subset of this string to a byte array. The subset is defined by the range [start,end).
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfacejava.lang.CharSequence
-
contains
public boolean contains(java.lang.CharSequence cs)
Determines if thisStringcontains the sequence of characters in theCharSequencepassed.- Parameters:
cs- the character sequence to search for.- Returns:
trueif the sequence of characters are contained in this string, otherwisefalse.
-
compareTo
public int compareTo(@Nonnull java.lang.CharSequence string)Compares the specified string to this string using the ASCII values of the characters. Returns 0 if the strings contain the same characters in the same order. Returns a negative integer if the first non-equal character in this string has an ASCII value which is less than the ASCII value of the character at the same position in the specified string, or if this string is a prefix of the specified string. Returns a positive integer if the first non-equal character in this string has a ASCII value which is greater than the ASCII value of the character at the same position in the specified string, or if the specified string is a prefix of this string.- Specified by:
compareToin interfacejava.lang.Comparable<java.lang.CharSequence>- Parameters:
string- the string to compare.- 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.
- Throws:
java.lang.NullPointerException- ifstringisnull.
-
concat
public ByteBufAsciiString concat(java.lang.CharSequence... strings)
Concatenates this string and the specified string.- Parameters:
strings- the strings to concatenate- Returns:
- a new string which is the concatenation of this string and the specified string.
-
endsWith
public boolean endsWith(java.lang.CharSequence suffix)
Compares the specified string to this string to determine if the specified string is a suffix.- Parameters:
suffix- the suffix to look for.- Returns:
trueif the specified string is a suffix of this string,falseotherwise.- Throws:
java.lang.NullPointerException- ifsuffixisnull.
-
contentEqualsIgnoreCase
public 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.- Parameters:
string- the string to compare.- Returns:
trueif the specified string is equal to this string,falseotherwise.
-
subSequence
public ByteBufAsciiString subSequence(int start)
Copies a range of characters into a new string.- Parameters:
start- the offset of the first character (inclusive).- Returns:
- a new string containing the characters from start to the end of the string.
- Throws:
java.lang.IndexOutOfBoundsException- ifstart < 0orstart > length().
-
subSequence
public ByteBufAsciiString subSequence(int start, int end)
Copies a range of characters into a new string.- Specified by:
subSequencein interfacejava.lang.CharSequence- Parameters:
start- the offset of the first character (inclusive).end- The index to stop at (exclusive).- Returns:
- a new string containing the characters from start to the end of the string.
- Throws:
java.lang.IndexOutOfBoundsException- ifstart < 0orstart > length().
-
subSequence
public ByteBufAsciiString subSequence(int start, int end, boolean copy)
Either copy or share a subset of underlying sub-sequence of bytes.- Parameters:
start- the offset of the first character (inclusive).end- The index to stop at (exclusive).copy- Iftruethen a copy of the underlying storage will be made. Iffalsethen the underlying storage will be shared.- Returns:
- a new string containing the characters from start to the end of the string.
- Throws:
java.lang.IndexOutOfBoundsException- ifstart < 0orstart > length().
-
indexOf
public int indexOf(java.lang.CharSequence string)
Searches in this string for the first index of the specified string. The search for the string starts at the beginning and moves towards the end of this string.- Parameters:
string- the string to find.- Returns:
- the index of the first character of the specified string in this string, -1 if the specified string is not a substring.
- Throws:
java.lang.NullPointerException- ifstringisnull.
-
indexOf
public int indexOf(java.lang.CharSequence subString, int start)Searches in this string for the index of the specified string. The search for the string starts at the specified offset and moves towards the end of this string.- Parameters:
subString- the string to find.start- the starting offset.- Returns:
- the index of the first character of the specified string in this string, -1 if the specified string is not a substring.
- Throws:
java.lang.NullPointerException- ifsubStringisnull.
-
indexOf
public int indexOf(char ch, int start)Searches in this string for the index of the specified charch. The search for the char starts at the specified offsetstartand moves towards the end of this string.- Parameters:
ch- the char to find.start- the starting offset.- Returns:
- the index of the first occurrence of the specified char
chin this string, -1 if found no occurrence.
-
lastIndexOf
public int lastIndexOf(java.lang.CharSequence string)
Searches in this string for the last index of the specified string. The search for the string starts at the end and moves towards the beginning of this string.- Parameters:
string- the string to find.- Returns:
- the index of the first character of the specified string in this string, -1 if the specified string is not a substring.
- Throws:
java.lang.NullPointerException- ifstringisnull.
-
lastIndexOf
public int lastIndexOf(java.lang.CharSequence subString, int start)Searches in this string for the index of the specified string. The search for the string starts at the specified offset and moves towards the beginning of this string.- Parameters:
subString- the string to find.start- the starting offset.- Returns:
- the index of the first character of the specified string in this string , -1 if the specified string is not a substring.
- Throws:
java.lang.NullPointerException- ifsubStringisnull.
-
regionMatches
public 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.- Parameters:
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.- Returns:
trueif the ranges of characters are equal,falseotherwise- Throws:
java.lang.NullPointerException- ifstringisnull.
-
regionMatches
public 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. When ignoreCase is true, the case of the characters is ignored during the comparison.- Parameters:
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.- Returns:
trueif the ranges of characters are equal,falseotherwise.- Throws:
java.lang.NullPointerException- ifstringisnull.
-
replace
public ByteBufAsciiString replace(char oldChar, char newChar)
Copies this string replacing occurrences of the specified character with another character.- Parameters:
oldChar- the character to replace.newChar- the replacement character.- Returns:
- a new string with occurrences of oldChar replaced by newChar.
-
startsWith
public boolean startsWith(java.lang.CharSequence prefix)
Compares the specified string to this string to determine if the specified string is a prefix.- Parameters:
prefix- the string to look for.- Returns:
trueif the specified string is a prefix of this string,falseotherwise- Throws:
java.lang.NullPointerException- ifprefixisnull.
-
startsWith
public static boolean startsWith(java.lang.CharSequence string, java.lang.CharSequence prefix)Compares the specified string to this string to determine if the specified string is a prefix.- Parameters:
prefix- the string to look for.- Returns:
trueif the specified string is a prefix of this string,falseotherwise- Throws:
java.lang.NullPointerException- ifprefixisnull.
-
startsWithIgnoreCase
public static boolean startsWithIgnoreCase(java.lang.CharSequence string, java.lang.CharSequence prefix)Compares the specified string to this string to determine if the specified string is a prefix.- Parameters:
prefix- the string to look for.- Returns:
trueif the specified string is a prefix of this string,falseotherwise- Throws:
java.lang.NullPointerException- ifprefixisnull.
-
startsWith
public 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.- Parameters:
prefix- the string to look for.start- the starting offset.- Returns:
trueif the specified string occurs in this string at the specified offset,falseotherwise.- Throws:
java.lang.NullPointerException- ifprefixisnull.
-
startsWith
public static boolean startsWith(java.lang.CharSequence string, 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.- Parameters:
prefix- the string to look for.start- the starting offset.- Returns:
trueif the specified string occurs in this string at the specified offset,falseotherwise.- Throws:
java.lang.NullPointerException- ifprefixisnull.
-
startsWithIgnoreCase
public static boolean startsWithIgnoreCase(java.lang.CharSequence string, java.lang.CharSequence prefix, int start)
-
toLowerCase
public ByteBufAsciiString toLowerCase()
Converts the characters in this string to lowercase, using the default Locale.- Returns:
- a new string containing the lowercase characters equivalent to the characters in this string.
-
toUpperCase
public ByteBufAsciiString toUpperCase()
Converts the characters in this string to uppercase, using the default Locale.- Returns:
- a new string containing the uppercase characters equivalent to the characters in this string.
-
trim
public 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.- Parameters:
c- TheCharSequenceto trim.- Returns:
- a new string with characters
<= \\u0020removed from the beginning and the end.
-
trim
public ByteBufAsciiString trim()
Duplicates this string removing white space characters from the beginning and end of the string, without copying.- Returns:
- a new string with characters
<= \\u0020removed from the beginning and the end.
-
contentEquals
public boolean contentEquals(java.lang.CharSequence a)
Compares aCharSequenceto thisStringto determine if their contents are equal.- Parameters:
a- the character sequence to compare to.- Returns:
trueif equal, otherwisefalse
-
matches
public boolean matches(java.lang.String expr)
Determines whether this string matches a given regular expression.- Parameters:
expr- the regular expression to be matched.- Returns:
trueif the expression matches, otherwisefalse.- Throws:
java.util.regex.PatternSyntaxException- if the syntax of the supplied regular expression is not valid.java.lang.NullPointerException- ifexprisnull.
-
split
public ByteBufAsciiString[] split(java.lang.String expr, int max)
Splits this string using the supplied regular expressionexpr. The parametermaxcontrols the behavior how many times the pattern is applied to the string.- Parameters:
expr- the regular expression used to divide the string.max- the number of entries in the resulting array.- Returns:
- an array of Strings created by separating the string along matches of the regular expression.
- Throws:
java.lang.NullPointerException- ifexprisnull.java.util.regex.PatternSyntaxException- if the syntax of the supplied regular expression is not valid.- See Also:
Pattern.split(CharSequence, int)
-
split
public ByteBufAsciiString[] split(@Nonnull java.util.regex.Pattern pattern)
-
split
public ByteBufAsciiString[] split(@Nonnull java.util.regex.Pattern pattern, int limit)
-
split
public ByteBufAsciiString[] split(char delim)
Splits the specifiedStringwith the specified delimiter..
-
hashCode
public int hashCode()
Provides a case-insensitive hash code for Ascii like byte strings.
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toAsciiString
@Nonnull public io.netty.util.AsciiString toAsciiString()
-
toString
@Nonnull public java.lang.String toString()
Translates the entire byte string to aString.- Specified by:
toStringin interfacejava.lang.CharSequence- Overrides:
toStringin classjava.lang.Object- See Also:
toString(int)
-
toString
public java.lang.String toString(int start)
Translates the entire byte string to aStringusing thecharsetencoding.- See Also:
toString(int, int)
-
toString
public java.lang.String toString(int start, int end)Translates the [start,end) range of this byte string to aString.
-
containsContentEqualsIgnoreCase
public static boolean containsContentEqualsIgnoreCase(java.util.Collection<java.lang.CharSequence> collection, java.lang.CharSequence value)Determine ifcollectioncontainsvalueand usingcontentEqualsIgnoreCase(CharSequence, CharSequence)to compare values.- Parameters:
collection- The collection to look for and equivalent element asvalue.value- The value to look for incollection.- Returns:
trueifcollectioncontainsvalueaccording tocontentEqualsIgnoreCase(CharSequence, CharSequence).falseotherwise.- See Also:
contentEqualsIgnoreCase(CharSequence, CharSequence)
-
containsAllContentEqualsIgnoreCase
public static boolean containsAllContentEqualsIgnoreCase(java.util.Collection<java.lang.CharSequence> a, java.util.Collection<java.lang.CharSequence> b)Determine ifacontains all of the values inbusingcontentEqualsIgnoreCase(CharSequence, CharSequence)to compare values.- Parameters:
a- The collection under test.b- The values to test for.- Returns:
trueifacontains all of the values inbusingcontentEqualsIgnoreCase(CharSequence, CharSequence)to compare values.falseotherwise.- See Also:
contentEqualsIgnoreCase(CharSequence, CharSequence)
-
contentEquals
public static boolean contentEquals(java.lang.CharSequence a, java.lang.CharSequence b)Returnstrueif the content of bothCharSequence's are equals. This only supports 8-bit ASCII.
-
hashCode
public static int hashCode(java.lang.CharSequence value)
Returns the case-insensitive hash code of the specified string. Note that this method uses the same hashing algorithm withhashCode()so that you can put bothAsciiStrings and arbitraryCharSequences into the same headers.
-
contains
public static boolean contains(java.lang.CharSequence a, java.lang.CharSequence b)Determine ifacontainsbin a case sensitive manner.
-
containsIgnoreCase
public static boolean containsIgnoreCase(java.lang.CharSequence a, java.lang.CharSequence b)Determine ifacontainsbin a case insensitive manner.
-
contentEqualsIgnoreCase
public static boolean contentEqualsIgnoreCase(java.lang.CharSequence a, java.lang.CharSequence b)Returnstrueif bothCharSequence's are equals when ignore the case. This only supports 8-bit ASCII.
-
regionMatches
public 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- Parameters:
cs- theCharSequenceto be processedignoreCase- specifies if case should be ignored.csStart- the starting offset in thecsCharSequencestring- theCharSequenceto compare.start- the starting offset in the specifiedstring.length- the number of characters to compare.- Returns:
trueif the ranges of characters are equal,falseotherwise.
-
regionMatchesAscii
public 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- Parameters:
cs- theCharSequenceto be processedignoreCase- specifies if case should be ignored.csStart- the starting offset in thecsCharSequencestring- theCharSequenceto compare.start- the starting offset in the specifiedstring.length- the number of characters to compare.- Returns:
trueif the ranges of characters are equal,falseotherwise.
-
indexOfIgnoreCase
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
nullCharSequence 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- Parameters:
str- the CharSequence to check, may be nullsearchStr- the CharSequence to find, may be nullstartPos- the start position, negative treated as zero- Returns:
- the first index of the search CharSequence (always ≥ startPos),
-1 if no match or
nullstring input
-
indexOfIgnoreCaseAscii
public 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
nullCharSequence 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- Parameters:
str- the CharSequence to check, may be nullsearchStr- the CharSequence to find, may be nullstartPos- the start position, negative treated as zero- Returns:
- the first index of the search CharSequence (always ≥ startPos),
-1 if no match or
nullstring input
-
indexOf
public static int indexOf(java.lang.CharSequence cs, char searchChar, int start)Finds the first index in the
CharSequencethat matches the specified character.- Parameters:
cs- theCharSequenceto be processed, not nullsearchChar- the char to be searched forstart- the start index, negative starts at the string start- Returns:
- the index where the search char was found,
-1 if char
searchCharis not found orcs == null
-
isUpperCase
public static boolean isUpperCase(byte value)
-
isUpperCase
public static boolean isUpperCase(char value)
-
c2b
public static byte c2b(char c)
-
c2b0
public static byte c2b0(char c)
-
b2c
public static char b2c(byte b)
-
refCnt
public int refCnt()
- Specified by:
refCntin interfaceio.netty.util.ReferenceCounted
-
retain
public ByteBufAsciiString retain()
- Specified by:
retainin interfaceio.netty.util.ReferenceCounted
-
retain
public ByteBufAsciiString retain(int increment)
- Specified by:
retainin interfaceio.netty.util.ReferenceCounted
-
touch
public io.netty.util.ReferenceCounted touch()
- Specified by:
touchin interfaceio.netty.util.ReferenceCounted
-
touch
public io.netty.util.ReferenceCounted touch(java.lang.Object hint)
- Specified by:
touchin interfaceio.netty.util.ReferenceCounted
-
release
public boolean release()
- Specified by:
releasein interfaceio.netty.util.ReferenceCounted
-
release
public boolean release(int decrement)
- Specified by:
releasein interfaceio.netty.util.ReferenceCounted
-
-