Class SimpleString
java.lang.Object
org.apache.activemq.artemis.api.core.SimpleString
- All Implemented Interfaces:
Serializable, CharSequence, Comparable<SimpleString>
public final class SimpleString
extends Object
implements CharSequence, Serializable, Comparable<SimpleString>
A simple String class that can store all characters, and stores as simple
byte[], this minimises expensive
copying between String objects.
This object is used heavily throughout ActiveMQ Artemis for performance reasons.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final class -
Constructor Summary
ConstructorsConstructorDescriptionSimpleString(byte[] data) Deprecated, for removal: This API element is subject to removal in a future version.SimpleString(char c) Deprecated, for removal: This API element is subject to removal in a future version.Useof(char)instead.SimpleString(String string) Deprecated, for removal: This API element is subject to removal in a future version.Useof(String)instead. -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int pos) intconcat(char c) Concatenates a SimpleString and a charConcatenates a SimpleString and a Stringconcat(SimpleString toAdd) Concatenates 2 SimpleString'sbooleancontains(char c) checks to see if this SimpleString contains the char parameter passed inbooleanequals(io.netty.buffer.ByteBuf byteBuf, int offset, int length) booleanvoidgetChars(int srcBegin, int srcEnd, char[] dst, int dstPos) This method performs a similar function toString.getChars(int, int, char[], int).byte[]getData()Returns the underlying byte array of thisSimpleString.String[]getPaths(char separator) note the result of the first use is cached, the separator is configured on the postoffice so will be static for the duration of a server instance. calling with different separator values could give invalid resultsinthashCode()booleanisBlank()booleanisEmpty()intlength()static SimpleStringof(byte[] data) creates a SimpleString from a byte arraystatic SimpleStringof(char c) creates a SimpleString from a characterstatic SimpleStringReturns a SimpleString constructed from thestringparameter.static SimpleStringof(String string, SimpleString.StringSimpleStringPool pool) Returns a SimpleString constructed from thestringparameter.static SimpleStringreadNullableSimpleString(io.netty.buffer.ByteBuf buffer) static SimpleStringreadNullableSimpleString(io.netty.buffer.ByteBuf buffer, SimpleString.ByteBufSimpleStringPool pool) static SimpleStringreadSimpleString(io.netty.buffer.ByteBuf buffer) static SimpleStringreadSimpleString(io.netty.buffer.ByteBuf buffer, int length) static SimpleStringreadSimpleString(io.netty.buffer.ByteBuf buffer, SimpleString.ByteBufSimpleStringPool pool) intsizeof()Returns the size of this SimpleString.static intReturns the size of a SimpleString which could benull.static intsizeofString(SimpleString str) Returns the size of a SimpleString.split(char delim) Splits this SimpleString into an array of SimpleString using the char param as the delimiter. i.e.booleanstartsWith(char other) returns true if the SimpleString parameter starts with the same char. false if not.booleanstartsWith(SimpleString other) Returnstrueif theSimpleStringparameter starts with the same data as this one, otherwisefalse.subSeq(int start, int end) subSequence(int start, int end) static SimpleStringtoSimpleString(String string) Deprecated, for removal: This API element is subject to removal in a future version.Useof(String)instead.static SimpleStringtoSimpleString(String string, SimpleString.StringSimpleStringPool pool) Deprecated, for removal: This API element is subject to removal in a future version.Useof(String, StringSimpleStringPool)instead.toString()static voidwriteNullableSimpleString(io.netty.buffer.ByteBuf buffer, SimpleString val) static voidwriteSimpleString(io.netty.buffer.ByteBuf buffer, SimpleString val) Methods inherited from interface CharSequence
chars, codePoints
-
Constructor Details
-
SimpleString
Deprecated, for removal: This API element is subject to removal in a future version.Useof(String)instead.creates a SimpleString from a conventional String- Parameters:
string- the string to transform
-
SimpleString
Deprecated, for removal: This API element is subject to removal in a future version.Useof(byte[])instead.creates a SimpleString from a byte array- Parameters:
data- the byte array to use
-
SimpleString
Deprecated, for removal: This API element is subject to removal in a future version.Useof(char)instead.creates a SimpleString from a character- Parameters:
c- the char to use
-
-
Method Details
-
of
Returns a SimpleString constructed from thestringparameter.If
stringisnull, the return value will benulltoo.- Parameters:
string- String used to instantiate a SimpleString.- Returns:
- A new SimpleString
-
of
Returns a SimpleString constructed from thestringparameter.If
stringisnull, the return value will benulltoo.- Parameters:
string- String used to instantiate a SimpleString.pool- The pool from which to create the SimpleString- Returns:
- A new SimpleString
-
of
creates a SimpleString from a byte array- Parameters:
data- the byte array to use
-
of
creates a SimpleString from a character- Parameters:
c- the char to use
-
toSimpleString
Deprecated, for removal: This API element is subject to removal in a future version.Useof(String)instead.Returns a SimpleString constructed from thestringparameter.If
stringisnull, the return value will benulltoo.- Parameters:
string- String used to instantiate a SimpleString.- Returns:
- A new SimpleString
-
toSimpleString
@Deprecated(forRemoval=true) public static SimpleString toSimpleString(String string, SimpleString.StringSimpleStringPool pool) Deprecated, for removal: This API element is subject to removal in a future version.Useof(String, StringSimpleStringPool)instead.Returns a SimpleString constructed from thestringparameter.If
stringisnull, the return value will benulltoo.- Parameters:
string- String used to instantiate a SimpleString.pool- The pool from which to create the SimpleString- Returns:
- A new SimpleString
-
isBlank
public boolean isBlank() -
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCharSequence
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int pos) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
readNullableSimpleString
-
readNullableSimpleString
public static SimpleString readNullableSimpleString(io.netty.buffer.ByteBuf buffer, SimpleString.ByteBufSimpleStringPool pool) -
readSimpleString
-
readSimpleString
public static SimpleString readSimpleString(io.netty.buffer.ByteBuf buffer, SimpleString.ByteBufSimpleStringPool pool) -
readSimpleString
-
writeNullableSimpleString
-
writeSimpleString
-
subSeq
-
compareTo
- Specified by:
compareToin interfaceComparable<SimpleString>
-
getData
public byte[] getData()Returns the underlying byte array of thisSimpleString.- Returns:
- the underlying byte array of this
SimpleString
-
startsWith
Returnstrueif theSimpleStringparameter starts with the same data as this one, otherwisefalse.- Parameters:
other- the SimpleString to look for- Returns:
trueif theSimpleStringparameter starts with the same data as this one, otherwisefalse
-
startsWith
public boolean startsWith(char other) returns true if the SimpleString parameter starts with the same char. false if not.- Parameters:
other- the char to look for- Returns:
- true if this SimpleString starts with the same data
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
getPaths
note the result of the first use is cached, the separator is configured on the postoffice so will be static for the duration of a server instance. calling with different separator values could give invalid results- Parameters:
separator- value from wildcardConfiguration- Returns:
- String[] reference to the split paths or the cached value if previously called
-
equals
-
equals
public boolean equals(io.netty.buffer.ByteBuf byteBuf, int offset, int length) Returnstrueif theSimpleStringencoded content intobytesis equals tos,falseotherwise.It assumes that the
bytescontent is read usingreadSimpleString(ByteBuf, int)ie starting right after the length field. -
hashCode
-
split
Splits this SimpleString into an array of SimpleString using the char param as the delimiter. i.e. "a.b" would return "a" and "b" if . was the delimiter- Parameters:
delim- The delimiter to split this SimpleString on.- Returns:
- An array of SimpleStrings
-
contains
public boolean contains(char c) checks to see if this SimpleString contains the char parameter passed in- Parameters:
c- the char to check for- Returns:
- true if the char is found, false otherwise
-
concat
Concatenates a SimpleString and a String- Parameters:
toAdd- the String to concatenate with.- Returns:
- the concatenated SimpleString
-
concat
Concatenates 2 SimpleString's- Parameters:
toAdd- the SimpleString to concatenate with.- Returns:
- the concatenated SimpleString
-
concat
Concatenates a SimpleString and a char- Parameters:
c- the char to concate with.- Returns:
- the concatenated SimpleString
-
sizeof
public int sizeof()Returns the size of this SimpleString.- Returns:
- the size of this SimpleString
-
sizeofString
Returns the size of a SimpleString.- Parameters:
str- the SimpleString to check- Returns:
- the size of a SimpleString
-
sizeofNullableString
Returns the size of a SimpleString which could benull.- Parameters:
str- the SimpleString to check- Returns:
- the size of a SimpleString which could be
null
-
getChars
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstPos) This method performs a similar function toString.getChars(int, int, char[], int). This is mainly used by the Parsers on Filters- Parameters:
srcBegin- The srcBeginsrcEnd- The srcEnddst- The destination arraydstPos- The destination position
-
of(byte[])instead.