Package io.deephaven.base.string.cache
Class AbstractCompressedString<TYPE extends AbstractCompressedString>
java.lang.Object
io.deephaven.base.string.cache.AbstractCompressedString<TYPE>
- All Implemented Interfaces:
StringAlike<TYPE>
,StringCompatible
,Serializable
,CharSequence
,Comparable<CharSequence>
- Direct Known Subclasses:
CompressedString
,MappedCompressedString
public abstract class AbstractCompressedString<TYPE extends AbstractCompressedString>
extends Object
implements StringAlike<TYPE>
Base class for immutable byte[]-backed String replacements.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfinal char
charAt
(int index) final int
codePointAt
(int index) final int
codePointBefore
(int index) final int
codePointCount
(int beginIndex, int endIndex) final int
compareTo
(@NotNull CharSequence that) Implementations MUST compare StringCompatibles and Strings char-by-char.final int
compareToIgnoreCase
(@NotNull CharSequence that) final TYPE
final TYPE
final boolean
contains
(CharSequence cs) final boolean
contentEquals
(@NotNull CharSequence cs) protected abstract TYPE
convertValue
(byte[] data, int offset, int length) Convert a byte array to this type, assuming ISO-8859-1protected abstract TYPE
convertValue
(String string) Convert a String to this type.final boolean
endsWith
(@NotNull CharSequence suffix) final boolean
final boolean
equalsIgnoreCase
(@NotNull CharSequence that) final byte[]
getBytes()
final void
getChars
(int srcBegin, int srcEnd, char[] dst, int dstBegin) final byte[]
getData()
Note: This is an API for trusted code to use.final int
hashCode()
Implementations MUST match the current implementation of String.hashCode().final int
indexOf
(int ch) final int
indexOf
(int ch, int fromIndex) final int
indexOf
(CharSequence cs) final int
indexOf
(CharSequence cs, int fromIndex) final TYPE
intern()
final boolean
isEmpty()
final int
lastIndexOf
(int ch) final int
lastIndexOf
(int ch, int fromIndex) final int
final int
lastIndexOf
(CharSequence cs, int fromIndex) final int
length()
final boolean
matches
(CharSequence regex) final boolean
regionMatches
(boolean ignoreCase, int offset, CharSequence that, int thatOffset, int length) final TYPE
replace
(char oldChar, char newChar) final TYPE
replace
(CharSequence target, CharSequence replacement) final TYPE
replaceAll
(CharSequence regex, CharSequence replacement) final TYPE
replaceFirst
(CharSequence regex, CharSequence replacement) final TYPE[]
split
(CharSequence regex) final TYPE[]
split
(CharSequence regex, int limit) final boolean
startsWith
(@NotNull CharSequence prefix) final boolean
startsWith
(@NotNull CharSequence prefix, int offset) final CharSequence
subSequence
(int start, int end) final TYPE
substring
(int beginIndex) final TYPE
substring
(int beginIndex, int endIndex) final char[]
final TYPE
final TYPE
toLowerCase
(Locale locale) final @NotNull String
toString()
Convert this StringCompatible into a String.final TYPE
final TYPE
toUpperCase
(Locale locale) final TYPE
trim()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints
Methods inherited from interface io.deephaven.base.string.cache.StringCompatible
toCompressedString, toMappedCompressedString
-
Method Details
-
convertValue
Convert a String to this type.- Parameters:
string
- The String to convert- Returns:
- A new TYPE with the same contents as String, assuming ISO-8859-1 encoding
-
convertValue
Convert a byte array to this type, assuming ISO-8859-1- Parameters:
data
- The data to convertoffset
- The starting index from data to convertlength
- The length to convert- Returns:
- A new TYPE with the same contents as the specified region of data, assuming ISO-8859-1 encoding
-
getData
public final byte[] getData()Note: This is an API for trusted code to use. The data array must not be modified.- Returns:
- The internal data array for this instance.
-
length
public final int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public final char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
Description copied from interface:StringCompatible
Convert this StringCompatible into a String. Implementations should not cache result Strings, in order to avoid inadvertently allowing promotion of short-lived objects under generational garbage collection.- Specified by:
toString
in interfaceCharSequence
- Specified by:
toString
in interfaceStringCompatible
- Overrides:
toString
in classObject
- Returns:
- A newly constructed String representing the same sequence of characters as this StringCompatible.
-
compareTo
Description copied from interface:StringCompatible
Implementations MUST compare StringCompatibles and Strings char-by-char.- Specified by:
compareTo
in interfaceComparable<TYPE extends AbstractCompressedString>
- Specified by:
compareTo
in interfaceStringCompatible
- Returns:
- 0, <0, or >0 if that compares equal-to, less-than, or greater-than this.
-
hashCode
public final int hashCode()Description copied from interface:StringCompatible
Implementations MUST match the current implementation of String.hashCode().- Specified by:
hashCode
in interfaceStringCompatible
- Overrides:
hashCode
in classObject
- Returns:
- A hashcode value for this StringCompatible that matches the value a String of the same chars.
-
equals
- Specified by:
equals
in interfaceStringCompatible
- Overrides:
equals
in classObject
- Returns:
- true iff that is a StringCompatible of the same class with identical members.
-
isEmpty
public final boolean isEmpty()- Specified by:
isEmpty
in interfaceCharSequence
- Specified by:
isEmpty
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
codePointAt
public final int codePointAt(int index) - Specified by:
codePointAt
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
codePointBefore
public final int codePointBefore(int index) - Specified by:
codePointBefore
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
codePointCount
public final int codePointCount(int beginIndex, int endIndex) - Specified by:
codePointCount
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
getChars
public final void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) - Specified by:
getChars
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
getBytes
public final byte[] getBytes()- Specified by:
getBytes
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
contentEquals
- Specified by:
contentEquals
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
equalsIgnoreCase
- Specified by:
equalsIgnoreCase
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
compareToIgnoreCase
- Specified by:
compareToIgnoreCase
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
regionMatches
public final boolean regionMatches(boolean ignoreCase, int offset, CharSequence that, int thatOffset, int length) - Specified by:
regionMatches
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
startsWith
- Specified by:
startsWith
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
startsWith
- Specified by:
startsWith
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
endsWith
- Specified by:
endsWith
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
indexOf
public final int indexOf(int ch, int fromIndex) - Specified by:
indexOf
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
indexOf
public final int indexOf(int ch) - Specified by:
indexOf
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
lastIndexOf
public final int lastIndexOf(int ch, int fromIndex) - Specified by:
lastIndexOf
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
lastIndexOf
public final int lastIndexOf(int ch) - Specified by:
lastIndexOf
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
substring
- Specified by:
substring
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
substring
- Specified by:
substring
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
concat
- Specified by:
concat
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
concat
- Specified by:
concat
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
matches
- Specified by:
matches
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
trim
- Specified by:
trim
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
toCharArray
public final char[] toCharArray()- Specified by:
toCharArray
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
indexOf
- Specified by:
indexOf
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
indexOf
- Specified by:
indexOf
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
replace
- Specified by:
replace
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
contains
- Specified by:
contains
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
replaceFirst
- Specified by:
replaceFirst
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
replaceAll
- Specified by:
replaceAll
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
replace
- Specified by:
replace
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
split
- Specified by:
split
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
split
- Specified by:
split
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
toLowerCase
- Specified by:
toLowerCase
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
toLowerCase
- Specified by:
toLowerCase
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
toUpperCase
- Specified by:
toUpperCase
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
toUpperCase
- Specified by:
toUpperCase
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-
intern
- Specified by:
intern
in interfaceStringAlike<TYPE extends AbstractCompressedString>
-