Package one.microstream.chars
Class VarString
java.lang.Object
one.microstream.chars.VarString
- All Implemented Interfaces:
Serializable
,Appendable
,CharSequence
public final class VarString extends Object implements CharSequence, Appendable, Serializable
Faster implementation of a StringBuilder with richer functionality.
Note that this class is NOT synchronized and only meant for single-threaded or thread-safe
(i.e. read only or explicitly synchronized) use.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
VarString.Appendable
Implementors of this interface handle appending their specific string representation directly.
This is useful for preventing the instantiation and copying of potentially large temporary strings which can have unnecessary and devastatingly negative effects on performance. -
Method Summary
Modifier and Type Method Description VarString
add(boolean value)
VarString
add(byte value)
VarString
add(char c)
VarString
add(char[] chars)
void
add(char[] chars, int offset, int length)
VarString
add(char c1, char c2)
VarString
add(char c1, char c2, char c3)
VarString
add(double value)
VarString
add(float value)
VarString
add(int value)
VarString
add(long value)
VarString
add(short value)
<E> VarString
add(E element, BiConsumer<VarString,? super E> joiner)
VarString
add(Character c)
VarString
add(CharSequence cs)
VarString
add(Object o)
VarString
add(String s)
VarString
add(VarString vs)
<E> VarString
addAll(E[] elements, int offset, int length, BiConsumer<VarString,? super E> joiner)
<E> VarString
addAll(E[] elements, BiConsumer<VarString,? super E> joiner)
<E> VarString
addAll(Iterable<? extends E> elements, BiConsumer<VarString,? super E> joiner)
VarString
addChars(char... chars)
VarString
addCharSequences(CharSequence... csqs)
VarString
addFalse()
VarString
addHexDec(byte value)
VarString
addHexDec(byte... bytes)
VarString
addMapped(boolean value, String trueValue, String falseValue)
VarString
addMapped(Boolean value, String trueValue, String falseValue)
static void
addNonNull(VarString vs, Object object)
VarString
addNull()
VarString
addObjects(Object... objects)
VarString
addTrue()
VarString
append(char c)
VarString
append(CharSequence csq)
VarString
append(CharSequence csq, int start, int end)
VarString
append(VarString.Appendable appendable)
VarString
apply(Consumer<? super VarString> procedure)
VarString
blank()
VarString
blank(int amount)
char
charAt(int index)
VarString
clear()
Fills this instance's char storage completely with zeros and sets its size to 0.static void
commaSpace(VarString vs, Object element)
VarString
consolidate()
boolean
contains(char c)
boolean
contains(char[] chars)
boolean
contains(String s)
boolean
contains(VarString vc)
VarString
copyTo(char[] target, int targetOffset)
VarString
copyTo(int offset, char[] target, int targetOffset, int length)
int
count(char c)
int
count(char[] chars)
int
count(String s)
int
count(VarString vc)
VarString
cr()
VarString
cr(int amount)
VarString
crlf()
VarString
deleteAt(int index)
VarString
deleteLast()
VarString
deleteLast(int n)
byte[]
encode()
Alias forthis.encodeBy(XChars.standardCharset());
for general purpose encoding, with the "standard" being UTF-8 (XChars.utf8()
), because any other charset is nonsense for a general case.byte[]
encodeBy(Charset charset)
boolean
endsWith(char c)
boolean
endsWith(char[] chars)
boolean
endsWith(String string)
void
ensureCapacity(int minimumCapacity)
void
ensureFreeCapacity(int minimumFreeCapacity)
boolean
equalsAt(int index, char[] chars, int charsOffset, int charsLength)
char
first()
int
indexOf(char c)
int
indexOf(char[] chars)
int
indexOf(char[] chars, int offset)
int
indexOf(char c, int offset)
int
indexOf(String s)
int
indexOf(String s, int offset)
int
indexOf(VarString vc)
int
indexOf(VarString vc, int offset)
boolean
isEmpty()
void
iterate(_charProcedure iterator)
char
last()
int
lastIndexOf(char c)
int
lastIndexOf(char c, int offset)
int
length()
VarString
lf()
VarString
lf(int amount)
VarString
list(String separator, boolean... listElements)
VarString
list(String separator, byte... listElements)
VarString
list(String separator, char... listElements)
VarString
list(String separator, double... listElements)
VarString
list(String separator, float... listElements)
VarString
list(String separator, int... listElements)
VarString
list(String separator, long... listElements)
VarString
list(String separator, short... listElements)
VarString
list(String separator, Object... listElements)
VarString
list(String separator, String... listElements)
VarString
list(String separator, VarString... listElements)
VarString
list(String separator, VarString.Appendable... listElements)
VarString
list(String separator, XGettingCollection<?> listElements)
static VarString
New()
static VarString
New(int initialMinimumCapacity)
static VarString
New(String s)
VarString
padLeft(String s, int totalLength, char paddingChar)
VarString
padRight(String s, int totalLength, char paddingChar)
VarString
repeat(int amount, char c)
VarString
repeat(int amount, char[] chars)
VarString
repeat(int amount, String string)
String
replace(CharSequence target, CharSequence replacement)
VarString
replaceAll(char sample, char replacement)
VarString
replaceAll(char sample, char replacement, int offset)
VarString
replaceAll(char sample, char replacement, int offset, int length)
String
replaceAll(String regex, String replacement)
VarString
replaceFirst(char sample, char replacement)
VarString
replaceFirst(char sample, char replacement, int offset)
VarString
replaceFirst(char sample, char replacement, int offset, int length)
String
replaceFirst(String regex, String replacement)
VarString
reset()
Simply resets this instance by setting its size to 0 while leaving the actual char storage untouched.VarString
reverse()
VarString
set(int index, char c)
VarString
setChars(int index, char... c)
VarString
setLast(char c)
VarString
shrinkTo(int n)
String[]
split(String regex)
String[]
split(String regex, int limit)
VarString
subsequence(int beginIndex, int endIndex)
VarString
subSequence(int start, int end)
String
substring(int beginIndex, int endIndex)
VarString
surrogateCharReverse()
Deprecated.not implemented yet.VarString
tab()
VarString
tab(int amount)
char[]
toArray()
String
toString()
VarString
trim()
VarString
truncateTo(int newLength)
void
validateIndex(int index)
void
validateRange(int offset, int length)
-
Method Details
-
addNonNull
-
commaSpace
-
New
-
New
-
New
-
add
public final void add(char[] chars, int offset, int length) -
validateIndex
public final void validateIndex(int index) -
validateRange
public final void validateRange(int offset, int length) -
last
public final char last() -
first
public final char first() -
add
-
add
-
add
-
add
-
add
-
add
-
addMapped
-
addMapped
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
addHexDec
-
addHexDec
-
addObjects
-
ensureFreeCapacity
public final void ensureFreeCapacity(int minimumFreeCapacity) -
ensureCapacity
public final void ensureCapacity(int minimumCapacity) -
addChars
-
addCharSequences
-
addNull
-
addTrue
-
addFalse
-
append
-
add
-
addAll
-
addAll
public final <E> VarString addAll(E[] elements, int offset, int length, BiConsumer<VarString,? super E> joiner) -
addAll
public final <E> VarString addAll(Iterable<? extends E> elements, BiConsumer<VarString,? super E> joiner) -
set
-
setChars
-
setLast
-
reverse
-
surrogateCharReverse
Deprecated.not implemented yet. Currently just callsreverse()
.Not implemented yet. -
indexOf
public final int indexOf(char c) -
indexOf
public final int indexOf(char c, int offset) -
indexOf
public final int indexOf(char[] chars) -
indexOf
public final int indexOf(char[] chars, int offset) -
indexOf
-
indexOf
-
indexOf
-
indexOf
-
contains
public final boolean contains(char c) -
contains
public final boolean contains(char[] chars) -
contains
-
contains
-
lastIndexOf
public final int lastIndexOf(char c) -
lastIndexOf
public final int lastIndexOf(char c, int offset) -
count
public final int count(char c) -
count
public final int count(char[] chars) -
count
-
count
-
deleteAt
-
deleteLast
-
deleteLast
-
shrinkTo
-
toArray
public final char[] toArray() -
copyTo
-
copyTo
-
isEmpty
public final boolean isEmpty() -
consolidate
-
trim
-
truncateTo
-
subsequence
-
substring
-
iterate
-
list
-
list
-
list
-
list
-
list
-
list
-
list
-
list
-
list
-
list
-
list
-
list
-
list
-
clear
Fills this instance's char storage completely with zeros and sets its size to 0. Only preferable toreset()
for in-memory security reasons.- Returns:
- this
-
reset
Simply resets this instance by setting its size to 0 while leaving the actual char storage untouched.- Returns:
- this
-
blank
-
blank
-
tab
-
tab
-
cr
-
cr
-
lf
-
lf
-
crlf
-
repeat
-
repeat
-
repeat
-
apply
-
equalsAt
public final boolean equalsAt(int index, char[] chars, int charsOffset, int charsLength) -
endsWith
public final boolean endsWith(char c) -
endsWith
public final boolean endsWith(char[] chars) -
endsWith
-
padLeft
-
padRight
-
replaceFirst
-
replaceFirst
-
replaceFirst
-
replaceAll
-
replaceAll
-
replaceAll
-
replaceFirst
-
replaceAll
-
replace
-
split
-
split
-
encode
public final byte[] encode()Alias forthis.encodeBy(XChars.standardCharset());
for general purpose encoding, with the "standard" being UTF-8 (XChars.utf8()
), because any other charset is nonsense for a general case.- Returns:
- the character data of this instance as an UTF-8 byte array.
- See Also:
encodeBy(Charset)
-
encodeBy
-
charAt
public final char charAt(int index)- Specified by:
charAt
in interfaceCharSequence
-
length
public final int length()- Specified by:
length
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-