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
 
- 
- 
Constructor SummaryConstructors Constructor Description VarByte()
 - 
Method SummaryModifier 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 Detail- 
Newpublic static VarByte New() 
 - 
Newpublic static VarByte New(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.
 Note that the given initialCapacitywill still be adjusted to the next higher 2^n bounding value.- Parameters:
- initialCapacity-
 
 - 
getpublic byte get(int index) 
 - 
lastBytepublic byte lastByte() 
 - 
firstBytepublic byte firstByte() 
 - 
lengthpublic int length() 
 - 
subSequencepublic VarByte subSequence(int start, int end) 
 - 
readExternalpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException - Specified by:
- readExternalin interface- Externalizable
- Throws:
- IOException
- ClassNotFoundException
 
 - 
writeExternalpublic void writeExternal(ObjectOutput out) throws IOException - Specified by:
- writeExternalin interface- Externalizable
- Parameters:
- out-
- Throws:
- IOException
 
 - 
toStringpublic String toString(Charset charset) throws UnsupportedEncodingException - Throws:
- UnsupportedEncodingException
 
 - 
addpublic VarByte add(boolean b) 
 - 
addpublic VarByte add(byte c) 
 - 
addpublic VarByte add(short s) 
 - 
addpublic VarByte add(int i) 
 - 
addpublic VarByte add(long l) 
 - 
addpublic VarByte add(float f) 
 - 
addpublic VarByte add(double d) 
 - 
addpublic VarByte add(byte[] bytes) 
 - 
ensureFreeCapacitypublic void ensureFreeCapacity(int requiredFreeCapacity) 
 - 
appendArraypublic VarByte appendArray(byte... bytes) 
 - 
appendpublic VarByte append(byte[] bytes) 
 - 
appendpublic VarByte append(byte[] bytes, int offset, int length) 
 - 
appendpublic VarByte append(byte value) 
 - 
appendpublic VarByte append(boolean value) 
 - 
appendpublic VarByte append(short value) 
 - 
appendpublic VarByte append(char value) 
 - 
appendpublic VarByte append(int value) 
 - 
appendpublic VarByte append(float value) 
 - 
appendpublic VarByte append(long value) 
 - 
appendpublic VarByte append(double value) 
 - 
setBytepublic VarByte setByte(int index, byte c) 
 - 
setBytespublic VarByte setBytes(int index, byte... c) 
 - 
setLastBytepublic VarByte setLastByte(byte c) 
 - 
reversepublic VarByte reverse() 
 - 
surrogateByteReverse@Deprecated public VarByte surrogateByteReverse() Deprecated.not implemented yet. Currently just doesreverse().Not implemented yet.
 - 
indexOfpublic int indexOf(byte c) 
 - 
indexOfpublic int indexOf(byte c, int fromIndex)
 - 
indexOfpublic int indexOf(byte[] bytes) 
 - 
indexOfpublic int indexOf(byte[] bytes, int offset)
 - 
containspublic boolean contains(byte c) 
 - 
lastIndexOfpublic int lastIndexOf(byte c) 
 - 
lastIndexOfpublic int lastIndexOf(byte c, int fromIndex)
 - 
countpublic int count(byte c) 
 - 
deleteByteAtpublic VarByte deleteByteAt(int index) 
 - 
deleteLastBytepublic VarByte deleteLastByte() 
 - 
deleteLastpublic VarByte deleteLast(int n) 
 - 
shrinkTopublic VarByte shrinkTo(int n) 
 - 
toByteArraypublic byte[] toByteArray() 
 - 
getBytespublic void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)
 - 
isEmptypublic boolean isEmpty() 
 - 
trimToSizepublic void trimToSize() 
 - 
hasNoContentpublic static final boolean hasNoContent(VarByte varByte) - Parameters:
- varByte-
- Returns:
- trueif- varByteis either- nullor empty.
- See Also:
- isEmpty()
 
 - 
hasContentpublic static final boolean hasContent(VarByte varByte) 
 - 
replaceFirstpublic VarByte replaceFirst(byte sample, byte replacement) 
 - 
replaceFirstpublic VarByte replaceFirst(int beginIndex, byte sample, byte replacement) 
 - 
subsequencepublic VarByte subsequence(int beginIndex, int endIndex) 
 - 
processpublic void process(_byteProcedure processor) 
 - 
resetpublic final VarByte reset() 
 - 
truncatepublic void truncate() 
 - 
printlnTopublic VarByte printlnTo(PrintStream printStream) 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- the- PrintStreaminstance to be written to.
- Returns:
- this VarByteinstance.
 
 - 
printTopublic VarByte printTo(PrintStream printStream) 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- the- PrintStreaminstance to be written to.
- Returns:
- this VarByteinstance.
 
 - 
repeatpublic VarByte repeat(int amount, byte b) 
 
- 
 
-