Package mockit.asm.util
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
(@org.checkerframework.checker.index.qual.NonNegative int initialSize) Constructs a new ByteVector with the given initial size. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getData()
Returns the bytedata
.@org.checkerframework.checker.index.qual.NonNegative int
Returns thelength
of 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.void
putByteArray
(byte[] bytes, @org.checkerframework.checker.index.qual.NonNegative int offset, @org.checkerframework.checker.index.qual.NonNegative int numBytes) Puts an array of bytes into this byte vector.void
putByteVector
(ByteVector another) putInt
(int i) Puts an int into this byte vector.void
putLong
(long l) Puts a long into this byte vector.putShort
(int s) Puts a short into this byte vector.void
Puts an UTF8 string into this byte vector.void
void
setLength
(@org.checkerframework.checker.index.qual.NonNegative int length) Sets thelength
of this vector, in bytes.
-
Constructor Details
-
ByteVector
public ByteVector()Constructs a new ByteVector with a default initial size. -
ByteVector
public ByteVector(@org.checkerframework.checker.index.qual.NonNegative int initialSize) Constructs a new ByteVector with the given initial size.
-
-
Method Details
-
getData
@NonNull public byte[] getData()Returns the bytedata
. -
getLength
public @org.checkerframework.checker.index.qual.NonNegative int getLength()Returns thelength
of this vector, in bytes. -
setLength
public void setLength(@org.checkerframework.checker.index.qual.NonNegative int length) Sets thelength
of 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, @org.checkerframework.checker.index.qual.NonNegative int offset, @org.checkerframework.checker.index.qual.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()
-