|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.lang.XString
public class XString
Wraps an encoded set of bytes representing a string. An XString
provides the
ability to manipulate String values without generating the garbage associated with
Java's String
implementation. An XString is often referred to as a 'RawString'
which is a historical moniker that reflects XString raw access to the String underlying
serialized byte form.
This class serves the following purposes:
String
needs to be maintained in memory for a long period of
time as part of an application's state, late allocation of the String
would normally
produce an object that generational garbage collection would have to promote into
tenured memory. For latency sensitive application's promotion of the String to the
tenured generation will leads to garbage collection pauses. A XString
allows
preallocation of memory for such a field up front whereas a String can't be preallocated
because it is immutable.
An XString
may be preallocated via one of its factory methods or via the factory
methods for XString in XFactory
. The XString
and its backing buffer will be
promoted to the tenured generation at the beginning of the application's life cycle allowing the
tenuring cost to be paid up front thereby eliminating pauses that would result from minor
gc during normal application operation.
When the XString
is later assigned from another XString
, the backing
buffer can be copied from it without any garbage being created. A typical example of
this would be where a transport layer reads a field off the wire and passes it off
to the application. The networking layer wraps the encoded buffer in a pooled
XString
and can pass it off to application code that has a preallocated
XString
that serves as the target. The network buffer is copied into the
preallocated target without instantiating the underlying non primitive type meaning
that no garbage is created in the course of setting the field.
However even if the underlying value is materialized by application code via a call
to getValue()
, the cost in garbage can remain low providing the application
doesn't keep a reference to the materialized value because because the materialized
value needn't be promoted to an eden survivor space or the tenured generation which
is the more expensive operation in garbage collection. The application keeps a reference
to the XString
only and can continue to transiently decode the value and release
it as needed.
String
introduces intermediate garbage in the form of the materialized
value returned by getValue()
, and secondly the decode/encode operation costs clock cycles,
particulary for types like a String
where encoding and decoding is an expensive operation.
As alluded to above, for a networking application that reuses its network buffers, a
XString
can be layered on top of a network buffer and presented to the application
which can pass the XString
to an outbound network buffer where it can be written
without (de)serialization and (re)encoding. When the backing buffer is a direct or native
buffer this provides a mechanism for field transfer with zero intermediate copy.
XString
XString
created via one of the factory methods of XFactory
is
immutable from the point that it is initialized. Once initialized via a setter method,
a factory created XString
is threadsafe.
However, not all XString
s are threadsafe or immutable: platform created XString
may not always be immutable. Applications can test for immutability and initialization
of a XString
via isImmutable()
and isInitialized()
. When dealing with
XString
s returned by platform classes the documentation of the class should be consulted to
determine what thread safety and immutability guarantees are provided. In cases where the platform
doesn't guaranteed immutability, applications can make use of copyInto(XString)
to
create an immutable version of the XString
if needs be.
Appendable
and CharSequence
. Currently
XString
only supports ascii encdodable characters when working with these interfaces, or any
of the other char based methods it supports. An XString
can opaquely wrap and and pass
non ascii encodabled XStrings, but for performance reasons direct character manipulation of
non ascii text is not supported.
CharSequence
. The hashCode()
and equals(Object)
implementations
of this view and those returned by subSequence(int, int)
are not guaranteed to be remain
stable when an XString is mutable or not yet initialized.
XString
s that are immutable obey the contract for object equality and hashCode. Additionally,
an XString will equal another subSequence(int, int)
if they have the same
value. An XString
will not equal another String
of the same value.
XString
s are mutable; they along with their backing buffers
are not safe for mutative access by multiple threads.Nested Class Summary | |
---|---|
static interface |
XString.Factory<T extends XString>
A factory interface for creating new concrete instances of an XString |
static class |
XString.XStringFactory
A. factory for XString s which does not support pooling or preallocation. |
Method Summary | ||
---|---|---|
XString |
append(boolean value)
Appends the given boolean value in String format to the end of this XString . |
|
XString |
append(byte[] value)
Append the given bytes bytes to the end of this XString . |
|
XString |
append(byte[] value,
int valueOffset,
int valueLength)
Append the given bytes bytes to the end of this XString . |
|
XString |
append(ByteBuffer value)
Append the given ByteBuffer 's remaining bytes to the end of this
XString . |
|
XString |
append(char value)
Append the given char to the end of this XString . |
|
XString |
append(char[] value)
Append the given char [] to the end of this XString . |
|
XString |
append(char[] value,
int valueOffset,
int valueLength)
Append the given char [] to the end of this XString . |
|
XString |
append(CharSequence value)
Append the given CharSequence to the end of this XString . |
|
Appendable |
append(CharSequence value,
int start,
int end)
|
|
XString |
append(long value)
Appends the given long value in String format to the end of this XString . |
|
XString |
append(XString source)
Appends the contents of the given XString into this XString . |
|
char |
charAt(int index)
Returns the character at the given position. |
|
void |
clear()
Clears the value of the XString |
|
int |
compareTo(CharSequence other)
Compares two strings lexicographically. |
|
void |
copyFrom(char[] val)
Deprecated. Use setValue(char[]) instead. |
|
void |
copyFrom(XString val)
Deprecated. Use setValue(XString) instead. |
|
void |
copyFromMemory(long address,
int length)
Deprecated. Use setValueFromMemory(long, int) instead |
|
void |
copyFromNative(long address,
int length)
Deprecated. Use setValueFromMemory(long, int) instead |
|
int |
copyInto(ByteBuffer target,
int position)
Serialize the string into the given buffer at the given position. |
|
int |
copyInto(com.neeve.io.IOBuffer target,
int offset)
Serialize this XString into an IOBuffer . |
|
|
copyInto(T target,
int offset)
Serialize this XString into an IOElasticBuffer . |
|
XString |
copyInto(XString target)
Copy this XString into another XString . |
|
static XString |
create()
Create an uninitialized, mutable XString . |
|
static XString |
create(int bufferSize)
Preallocate a non native, uninitialized, immutable XString . |
|
static XString |
create(int bufferSize,
boolean mutable)
Preallocate a non native uninitialized XString . |
|
static XString |
create(int bufferSize,
boolean mutable,
boolean isNative)
Preallocate an uninitialized XString . |
|
static XString |
create(String value)
Create an immutable XString initialized with a given String value. |
|
static XString |
create(String value,
boolean bufferbacked)
Create an immutable XString initialized with the given String value. |
|
static XString |
create(String value,
boolean bufferbacked,
boolean isNative)
Create an immutable XString initialized with the given String value. |
|
boolean |
equals(Object object)
Test if this XString is equal to another XString . |
|
com.neeve.io.IOElasticBuffer |
getBackingBuffer()
Gets the underlying io buffer backing this XString. |
|
int |
getBackingBufferOffset()
Get the underlying io buffer offset for this XString. |
|
int |
getSerializedLength()
Return the XString 's serialized length. |
|
String |
getValue()
Get the String value. |
|
long |
getValueAsLong()
Zero garbage method to parses the string as a long value. |
|
long |
getValueAsLong(int radix)
Zero garbage method to parses the string as a long value. |
|
long |
getValueAsLongDecimal()
Zero garbage method to parses the string as a long value. |
|
int |
hashCode()
Return the current hash code of this XString . |
|
int |
indexOf(char c)
Returns the first index of the given character in this XString. |
|
int |
indexOf(char c,
int offset)
Returns the first index of the given character in this XString starting from the provided offset. |
|
int |
indexOf(CharSequence str)
Returns the first index of the given character sequence in this XString |
|
int |
indexOf(CharSequence str,
int offset)
Returns the first index of the given character sequence in this XString starting from the provided offset. |
|
boolean |
initialize(String value)
Initializes an uninitialized XString with the given String value. |
|
boolean |
initializeFrom(XString value)
Initialize an uninitialized XString with the given value. |
|
boolean |
isImmutable()
Test if this XString is immutable. |
|
boolean |
isInitialized()
Test if this XString has been initialized. |
|
boolean |
isMutable()
Get if a string is mutable |
|
static boolean |
isNativeXStringEnabled()
Checks if native XString buffers are enabled. |
|
boolean |
isNull()
Return if the XString 's represents a null string |
|
int |
length()
Returns the length in characters of the XString. |
|
void |
reset()
Clear the value for this XString . |
|
void |
setCharAt(int position,
char value)
Replaces the character at the given index with the provided value. |
|
void |
setValue(byte[] value)
Set the value of the String to the given bytes. |
|
void |
setValue(byte[] value,
int valueOffset,
int valueLength)
Set the value of the String to the given bytes. |
|
void |
setValue(ByteBuffer source)
Set the value of the XString to that of the given ByteBuffer . |
|
void |
setValue(ByteBuffer source,
int position,
int length)
Set the value of the XString to that of the given ByteBuffer . |
|
void |
setValue(char[] value)
Set the value of the String to the given characters. |
|
void |
setValue(char[] value,
int valueOffset,
int valueLength)
Set the value of the String to the given characters. |
|
void |
setValue(CharSequence value)
Set the value of the XString to that of the given CharSequence |
|
void |
setValue(com.neeve.io.IOBuffer source,
int offset,
int length,
boolean wrap)
Set the raw value of the String using the value in the given buffer. |
|
void |
setValue(com.neeve.io.IOElasticBuffer source,
int offset,
int length)
Set the raw value of the String using the value in the given buffer. |
|
void |
setValue(long value)
Set the raw value of the String to the String value of the given long in decimal radix. |
|
void |
setValue(String val)
Set the String value. |
|
void |
setValue(XString value)
Set the value of the XString from that of another XString |
|
void |
setValueFromMemory(long address,
int length)
Copy the content from the provided memory address into this XString . |
|
boolean |
startsWith(CharSequence prefix)
Tests if this XString starts with the characters in the provided sequence. |
|
boolean |
startsWith(CharSequence prefix,
int offset)
Tests if this XString starts with the characters in the provided sequence starting from the provided offset. |
|
CharSequence |
subSequence(int start,
int end)
Implementation of CharSequence#subSequence(int, int). |
|
String |
toDiagnosticString()
A diagnostic string. |
|
String |
toString()
Return the String value of this XString as returned by getValue() |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static XString create()
XString
.
XString
public static XString create(String value)
value
- the String value
XString
This method does create or serialize to a backing buffer. This make it
possible to use the XString
as a pure wrapper for the String
in cases where the String never needs to be encoded. If the backing
buffer is later requested it will be instantiated.
To create a buffer-backed XString use create(String, boolean)
public static XString create(String value, boolean bufferbacked)
value
- The String valuebufferbacked
- True if the backing buffer should be allocated.
XString
public static XString create(String value, boolean bufferbacked, boolean isNative)
value
- The String valuebufferbacked
- True if the backing buffer should be allocated.isNative
- Whether or not the backing bufffer should be native.
XString
public static XString create(int bufferSize)
XString
.
The XString may be later initialized via one of the returned XString
's
initialize methods after which it will be deemed immutable.
bufferSize
- The expected size of the serialized string
XString
;public static XString create(int bufferSize, boolean mutable)
XString
.
bufferSize
- The expected size of the serialized stringmutable
- True if initialized as mutable. If not set to
mutable, then once the XString
is initialized it will
no longer be mutable
XString
;public static XString create(int bufferSize, boolean mutable, boolean isNative)
XString
.
bufferSize
- The expected size of the serialized stringmutable
- True if initialized as mutable. If not set to
mutable, then once the XString
is initialized it will
no longer be mutableisNative
- Whether or not the XString
is backed by a
native (off-heap) buffer.
XString
;public final boolean startsWith(CharSequence prefix)
prefix
- The prefix
NullPointerException
- if the provided prefix is null;public final boolean startsWith(CharSequence prefix, int offset)
NOTE: Currently this is only reliable for XString composed entirely of ASCII characters.
prefix
- The prefixoffset
- the offset in this XString.
NullPointerException
- if the provided prefix is nullpublic final int indexOf(CharSequence str)
str
- The string to search for.
public final int indexOf(CharSequence str, int offset)
str
- The string to search for.
public final int indexOf(char c)
NOTE: Currently this is only reliable for XString composed entirely of ASCII characters.
c
- The string to search for.
public final int indexOf(char c, int offset)
NOTE: Currently this is only reliable for XString composed entirely of ASCII characters.
c
- The string to search for.
public final int compareTo(CharSequence other)
Ifthis XString is null or uninitialized it will lexigraphically precede another
XString that is initialized, otherwise the comparison produces the same results
as that for String.compareTo(String)
.
other
- The character sequence to compare against.
String.compareTo(String)
for this and the CharSequence
as String
sString.compareTo(String)
public static final boolean isNativeXStringEnabled()
public final boolean isMutable()
public final String getValue()
String
if the XString was initialized from a backing
buffer.
public final CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
XString
CharSequence.subSequence(int, int)
public final boolean initialize(String value)
XString
with the given String value.
value
- The value with which to initialize the XString
XString
's backing buffer, false
if the buffer had to be grown.
IllegalStateException
- if the XString
is already initialized.public final boolean initializeFrom(XString value)
XString
with the given value.
value
- The value with which to initialize the XString
XString
's backing buffer, false
if the buffer had to be grown.
IllegalStateException
- if the XString
is already initialized.public final boolean isInitialized()
XString
has been initialized. A preallocated
XString
will return false until it has been initialized
via copyInto(XString)
XString
is initialized.public final boolean isImmutable()
XString
is immutable. A XString
that is
not initialized will not be immutable, but may become immutable after
initialization.
XString
is immutable.public final void setValue(String val)
setValue(CharSequence)
, this method caches
the provided String allowing it to be used as a return value for getValue()
val
- The String value.
IllegalStateException
- if the value is not mutable.public final void setValue(XString value)
XString
from that of another XString
value
- The XString
value
IllegalStateException
- if the XString
is already initialized.@Deprecated public final void copyFrom(XString val)
setValue(XString)
instead.
XString
, a zero garbage operation.
val
- The XString value.@Deprecated public final void copyFromNative(long address, int length)
setValueFromMemory(long, int)
instead
XString
.
The source bytes are expected to be UTF-8 encoded characters.
address
- The source address from which to copy.length
- The number of bytes to copy.@Deprecated public final void copyFromMemory(long address, int length)
setValueFromMemory(long, int)
instead
XString
.
The source bytes are expected to be UTF-8 encoded characters.
address
- The source address from which to copy.length
- The number of bytes to copy.public final void setValueFromMemory(long address, int length)
XString
.
The source bytes are expected to be UTF-8 encoded characters.
address
- The source address from which to copy.length
- The number of bytes to copy.@Deprecated public final void copyFrom(char[] val)
setValue(char[])
instead.
val
- The XString value.
IllegalArgumentException
- If any of the source character's can't be encoded in ascii.public void setValue(long value)
value
- the value to convert to a String
IllegalStateException
- if the value is not mutable.public void setValue(char[] value)
This method is equivalent to calling setValue(char[], int, int)
with values of 0
and value.length respectively ... see javadoc for additional details.
value
- The String value.
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If any of the source character's can't be encoded in ascii.public void setValue(char[] value, int valueOffset, int valueLength)
XString
implementation
may choose not to copy the characters and instead reference the passed in array.
Callers should therefore ensure that the provided array is not mutated.
If the value is null, the value of the string is cleared.
value
- The String value.valueOffset
- The offset into the provided value from which to copy (0 based, inclusive).valueLength
- The number of of bytes from the valueOffset to copy.
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If any of the source character's can't be encoded in ascii.
IllegalArgumentException
- if the valueOffset or valueLength is outside the bounds of the provided array.public final void setValue(byte[] value)
This method is equivalent to calling setValue(byte[], int, int)
with values of 0
and value.length respectively ... see javadoc for additional details.
value
- The String value.
IllegalStateException
- if the value is not mutable.public final void setValue(byte[] value, int valueOffset, int valueLength)
If the value is null, the value of the string is cleared.
Note, while the XString will store the bytes in its backing buffer for any character encoding, character based operations on this XString only supports ascii encoded bytes being passed in here (e.g. every byte is assumed to be an ascii character)
value
- The String value.valueOffset
- The offset into the provided value from which to copy (0 based, inclusive).valueLength
- The number of of bytes from the valueOffset to copy.
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If any of the source character's can't be encoded in ascii.
IllegalArgumentException
- if the valueOffset or valueLength is outside the bounds of the provided array.public void setValue(CharSequence value)
XString
to that of the given CharSequence
value
- The CharSequence
value.
IllegalStateException
- if the value is not mutable.public final long getValueAsLong() throws NumberFormatException
NumberFormatException
- If the String can't be parsed as a long.public final long getValueAsLongDecimal()
Unlike getValueAsLong(int)
this method does not perform
number format checking and is more efficient.
public final long getValueAsLong(int radix) throws NumberFormatException
radix
- The radix to use when parsing the long value.
NumberFormatException
- If the String can't be parsed as a long.public void setCharAt(int position, char value)
NOTE: Currently this is only reliable for XString composed entirely of ASCII characters.
position
- The position of the character to overwrite (0 based).value
- The value to overwrite the character with.
IndexOutOfBoundsException
- if the position is negative or greater than the length of this string.
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If the value is not a us-ascii character.public final void setValue(com.neeve.io.IOElasticBuffer source, int offset, int length)
source
- The bufferoffset
- The offset into the bufferlength
- The length of the serialized string
IllegalStateException
- if the value is not mutable.public final void setValue(com.neeve.io.IOBuffer source, int offset, int length, boolean wrap)
source
- The bufferoffset
- The offset into the bufferlength
- The length of the serialized stringwrap
- Whether to wrap the XString's buffer around the supplied buffer.
IllegalStateException
- if the value is not mutable.public final void setValue(ByteBuffer source, int position, int length)
XString
to that of the given ByteBuffer
.
The value is copied from the specified buffer position. The ByteBuffer
's
position and limit are left unchanged.
source
- The CharSequence
value.position
- The position in the buffer at which the serialized String's bytes start.length
- The number of bytes to copy. The caller needs to ensure that the
supplied buffer's limit is >= supplied position + length
IllegalStateException
- if the value is not mutable or if limit is < supplied position + lengthpublic final void setValue(ByteBuffer source)
XString
to that of the given ByteBuffer
.
The value is copied from the buffers current position to the buffer's limit.
The ByteBuffer
's position and limit are left unchanged.
source
- The CharSequence
value.
IllegalStateException
- if the value is not mutable.public final XString copyInto(XString target)
XString
into another XString
.
If the target XString
is uninitialized or mutable, and its backing buffer is large
enough to hold the contents of this XString
then it will be used as the
target of the copy operation (a zero garbage operation).
Otherwise a new XString
will be allocated and returned.
target
- The target into which the XString
was copied which may be
different depending on the initialization state and backing buffer size of the
target.
XString
into which this XString
has been copied.public final <T extends com.neeve.io.IOElasticBuffer> T copyInto(T target, int offset)
XString
into an IOElasticBuffer
.
offset
- The offset into the IOElasticBuffer
to copy.
IOElasticBuffer
or null if this wrapped value is
unset i.e. no string or bufferpublic final int copyInto(com.neeve.io.IOBuffer target, int offset)
XString
into an IOBuffer
.
This method is not intended for use by end users without guidance from Neeve support. In particular it is not generally safe to operate on an IOBuffer wrapped by an IOElasticBuffer; this method should only be be used on an independent IOBuffer. If the IOBuffer is owned by an IOElasticBuffer then the copyInto(IOElasticBufffer, offset) method should be used.
offset
- The offset into the IOBuffer
to copy.
IllegalArgumentException
- If the target buffer doesn't have sufficient capacity
to hold this String's content.public final int copyInto(ByteBuffer target, int position)
target
- The buffer into which to serialize the the XStringposition
- The position in the buffer to which to serialize.
public final void reset()
XString
.
public final void clear() throws IllegalStateException
XString
IllegalStateException
- If the XString
is not mutablepublic final boolean isNull()
XString
's represents a null string
public final int getSerializedLength()
XString
's serialized length. Given it's character
encoding, this may be different than it's length()
.
XString
public final com.neeve.io.IOElasticBuffer getBackingBuffer()
public final int getBackingBufferOffset()
public final XString append(XString source)
XString
into this XString
.
If the source XString is not initialized, empty or null then this XString is left unchanged.
source
- The XString
to append to this XString
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.public final XString append(ByteBuffer value)
ByteBuffer
's remaining bytes to the end of this
XString
. The value is copied from the buffers current position
to the buffer's limit. The ByteBuffer
's position and limit are
left unchanged.
value
- The ByteBuffer
value.
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.public final XString append(byte[] value)
XString
.
This method is equivalent to calling append(char[], int, int)
with values of 0
and value.length respectively ... see javadoc for additional details.
value
- The ByteBuffer
value.
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.public final XString append(byte[] value, int valueOffset, int valueLength)
XString
.
Calling this method with a null value has no effect other than throwing an IllegalStateException if this XString is not mutable.
value
- The ByteBuffer
value.valueOffset
- The offset into the provided value from which to append (0 based, inclusive).valueLength
- The number of of bytes from the valueOffset to append.
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- if the valueOffset or valueLength is outside the bounds of the provided array.public final XString append(boolean value)
XString
.
value
- The boolean to append.
XString
for invocation chaining
IllegalStateException
- if this string is not mutable.public final XString append(long value)
XString
.
value
- The value to append.
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If the character is not a us-ascii character.public final XString append(char value) throws IllegalArgumentException
XString
.
append
in interface Appendable
value
- The character to append.
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If the character is not a us-ascii character.public final XString append(CharSequence value) throws IllegalArgumentException
CharSequence
to the end of this XString
.
append
in interface Appendable
value
- The characters to append.
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If any of the characters is not a us-ascii character.public final Appendable append(CharSequence value, int start, int end) throws IllegalArgumentException
append
in interface Appendable
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If any of the characters is not a us-ascii character.public final XString append(char[] value) throws IllegalArgumentException
XString
.
This method is equivalent to calling append(char[], int, int)
with values of 0
and value.length respectively ... see javadoc for additional details.
value
- The characters to append.
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If any of the characters is not a us-ascii character.public final XString append(char[] value, int valueOffset, int valueLength) throws IllegalArgumentException
XString
.
Calling this method with a null value has no effect other than throwing an IllegalStateException if this XString is not mutable.
value
- The characters to append.valueOffset
- The offset into the provided value from which to append (0 based, inclusive).valueLength
- The number of of bytes from the valueOffset to append.
XString
for invocation chaining
IllegalStateException
- if the value is not mutable.
IllegalArgumentException
- If any of the characters is not a us-ascii character.
IllegalArgumentException
- if the valueOffset or valueLength is outside the bounds of the provided array.public final int length()
NOTE:
Currently this is only reliable for XString
s composed entirely
of ASCII characters, and this call is currently synonymous with
getSerializedLength()
. It is anticipated that support for non
ascii characters will be added in a future release, so it is advisable
for applications to code for this eventuality.
length
in interface CharSequence
public final char charAt(int index) throws IndexOutOfBoundsException
NOTE: Currently this is only reliable for XString composed entirely of ASCII characters.
charAt
in interface CharSequence
index
- The character position.
IndexOutOfBoundsException
- If the position is greater than or
equal to this XString
's length()
public String toString()
XString
as returned by getValue()
toString
in interface CharSequence
toString
in class Object
public final String toDiagnosticString()
public boolean equals(Object object)
XString
is equal to another XString
. Two XString
s
that are initialized are equal if their backing byte representations are the
equivalent.
An XString will also equal a CharSequence
that is a subsequence of another
XString if they have the same characters, but equality will not hold true for CharSequence
s
that are not XString
char sequences. This limitations is necessary because it isn't
possible to guarantee that symmetric equality with other CharSequence
implementations.
For example a String will only equal another String
CharSequence
.
equals
in class Object
object
- The object against which to compare
XString
equals the provided objectpublic int hashCode()
XString
.
The hash code of a XString
is based on the backing byte representation
The hashcode of a mutable XString
will change if the underlying String
or bytes are modified.
Because mutable XString
hash codes are content-dependent, it is inadvisable
to use mutable unitialized immutable XString
s as keys in hash maps or similar
data structures unless it is known that their contents will not change.
hashCode
in class Object
XString
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |