Package one.microstream.bytes
Class VarByte
java.lang.Object
one.microstream.bytes.VarByte
- All Implemented Interfaces:
Externalizable,Serializable
public final class VarByte extends Object implements Externalizable
- See Also:
- Serialized Form
-
Method Summary
Modifier and Type Method Description VarByteadd(boolean b)VarByteadd(byte c)VarByteadd(byte[] bytes)VarByteadd(double d)VarByteadd(float f)VarByteadd(int i)VarByteadd(long l)VarByteadd(short s)VarByteadd(String s)VarByteadd(VarByte varByte)VarByteappend(boolean value)VarByteappend(byte value)VarByteappend(byte[] bytes)VarByteappend(byte[] bytes, int offset, int length)VarByteappend(char value)VarByteappend(double value)VarByteappend(float value)VarByteappend(int value)VarByteappend(long value)VarByteappend(short value)VarByteappendArray(byte... bytes)VarByteapply(Consumer<? super VarByte> procedure)VarByteclear()Only preferable toreset()for security reasons.booleancontains(byte c)intcount(byte c)VarBytedeleteByteAt(int index)VarBytedeleteLast(int n)VarBytedeleteLastByte()voidensureFreeCapacity(int requiredFreeCapacity)bytefirstByte()byteget(int index)voidgetBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)static booleanhasContent(VarByte varByte)static booleanhasNoContent(VarByte varByte)intindexOf(byte c)intindexOf(byte[] bytes)intindexOf(byte[] bytes, int offset)intindexOf(byte c, int fromIndex)booleanisEmpty()bytelastByte()intlastIndexOf(byte c)intlastIndexOf(byte c, int fromIndex)intlength()static VarByteNew()static VarByteNew(int initialCapacity)Use this constructor only if really a specific size is needed or of the text to be handled is really big.
Otherwise, use the factory methods as they are faster due to skipping capacity checks and bounds adjustment.VarByteprintlnTo(PrintStream printStream)Passes a copy of the internal byte array to thePrintStream.println(String)method of the passedPrintStreaminstance.VarByteprintTo(PrintStream printStream)Passes a copy of the internal byte array to thePrintStream.print(String)method of the passedPrintStreaminstance.voidprocess(_byteProcedure processor)voidreadExternal(ObjectInput in)VarByterepeat(int amount, byte b)VarBytereplaceFirst(byte sample, byte replacement)VarBytereplaceFirst(int beginIndex, byte sample, byte replacement)VarBytereset()VarBytereverse()VarBytesetByte(int index, byte c)VarBytesetBytes(int index, byte... c)VarBytesetLastByte(byte c)VarByteshrinkTo(int n)VarBytesubsequence(int beginIndex, int endIndex)VarBytesubSequence(int start, int end)VarBytesurrogateByteReverse()Deprecated.not implemented yet.byte[]toByteArray()StringtoString()StringtoString(Charset charset)voidtrimToSize()voidtruncate()voidwriteExternal(ObjectOutput out)
-
Method Details
-
New
-
New
Use this constructor only if really a specific size is needed or of the text to be handled is really big.
Otherwise, use the factory methods as they are faster due to skipping capacity checks and bounds adjustment.
Note that the given
initialCapacitywill still be adjusted to the next higher 2^n bounding value.- Parameters:
initialCapacity-
-
get
public byte get(int index) -
lastByte
public byte lastByte() -
firstByte
public byte firstByte() -
length
public int length() -
subSequence
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Parameters:
out-- Throws:
IOException
-
toString
-
toString
- Throws:
UnsupportedEncodingException
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
ensureFreeCapacity
public void ensureFreeCapacity(int requiredFreeCapacity) -
appendArray
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
setByte
-
setBytes
-
setLastByte
-
reverse
-
surrogateByteReverse
Deprecated.not implemented yet. Currently just doesreverse().Not implemented yet. -
indexOf
public int indexOf(byte c) -
indexOf
public int indexOf(byte c, int fromIndex) -
indexOf
public int indexOf(byte[] bytes) -
indexOf
public int indexOf(byte[] bytes, int offset) -
contains
public boolean contains(byte c) -
lastIndexOf
public int lastIndexOf(byte c) -
lastIndexOf
public int lastIndexOf(byte c, int fromIndex) -
count
public int count(byte c) -
deleteByteAt
-
deleteLastByte
-
deleteLast
-
shrinkTo
-
toByteArray
public byte[] toByteArray() -
getBytes
public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) -
isEmpty
public boolean isEmpty() -
trimToSize
public void trimToSize() -
hasNoContent
- Parameters:
varByte-- Returns:
trueifvarByteis eithernullor empty.- See Also:
isEmpty()
-
hasContent
-
replaceFirst
-
replaceFirst
-
subsequence
-
process
-
clear
Only preferable toreset()for security reasons. -
reset
-
truncate
public void truncate() -
printlnTo
Passes a copy of the internal byte array to thePrintStream.println(String)method of the passedPrintStreaminstance.The purpose of this method is to spare the unnecessary String instantiation of the generic method
PrintStream.println(Object).- Parameters:
printStream- thePrintStreaminstance to be written to.- Returns:
- this
VarByteinstance.
-
printTo
Passes a copy of the internal byte array to thePrintStream.print(String)method of the passedPrintStreaminstance.The purpose of this method is to spare the unnecessary String instantiation of the generic method
PrintStream.println(Object).- Parameters:
printStream- thePrintStreaminstance to be written to.- Returns:
- this
VarByteinstance.
-
repeat
-
apply
-