Class ByteVector
java.lang.Object
mockit.asm.util.ByteVector
A dynamically extensible vector of bytes. This class is roughly equivalent to a DataOutputStream on top of a
ByteArrayOutputStream, but is more efficient.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new ByteVector with a default initial size.ByteVector(@NonNegative int initialSize) Constructs a new ByteVector with the given initial size. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getData()Returns the bytedata.@NonNegative intReturns thelengthof this vector, in bytes.put11(int b1, int b2) Puts two bytes into this byte vector.put12(int b, int s) Puts a byte and a short into this byte vector.putByte(int b) Puts a byte into this byte vector.voidputByteArray(byte[] bytes, @NonNegative int offset, @NonNegative int numBytes) Puts an array of bytes into this byte vector.voidputByteVector(ByteVector another) putInt(int i) Puts an int into this byte vector.voidputLong(long l) Puts a long into this byte vector.putShort(int s) Puts a short into this byte vector.voidPuts an UTF8 string into this byte vector.voidvoidsetLength(@NonNegative int length) Sets thelengthof this vector, in bytes.
-
Constructor Details
-
ByteVector
public ByteVector()Constructs a new ByteVector with a default initial size. -
ByteVector
public ByteVector(@NonNegative int initialSize) Constructs a new ByteVector with the given initial size.
-
-
Method Details
-
getData
@NonNull public byte[] getData()Returns the bytedata. -
getLength
public @NonNegative int getLength()Returns thelengthof this vector, in bytes. -
setLength
public void setLength(@NonNegative int length) Sets thelengthof this vector, in bytes. -
putByte
Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary.- Returns:
- this byte vector
-
put11
Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary.- Returns:
- this byte vector
-
putShort
Puts a short into this byte vector. The byte vector is automatically enlarged if necessary.- Returns:
- this byte vector
-
put12
Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if necessary.- Returns:
- this byte vector
-
putInt
Puts an int into this byte vector. The byte vector is automatically enlarged if necessary.- Returns:
- this byte vector
-
putLong
public void putLong(long l) Puts a long into this byte vector. The byte vector is automatically enlarged if necessary. -
putUTF8
Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary.- Parameters:
utf8String- a String whose UTF8 encoded length must be less than 65536
-
putByteArray
public void putByteArray(@NonNull byte[] bytes, @NonNegative int offset, @NonNegative int numBytes) Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if necessary.- Parameters:
bytes- an array of bytesoffset- index of the first byte of code that must be copiednumBytes- number of bytes of code that must be copied
-
putByteVector
-
roundUpLength
public void roundUpLength()
-