Class ByteVector

java.lang.Object
mockit.asm.util.ByteVector

public final class ByteVector extends Object
A dynamically extensible vector of bytes. This class is roughly equivalent to a DataOutputStream on top of a ByteArrayOutputStream, but is more efficient.
  • 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 byte data.
    • getLength

      public @NonNegative int getLength()
      Returns the length of this vector, in bytes.
    • setLength

      public void setLength(@NonNegative int length)
      Sets the length of this vector, in bytes.
    • putByte

      @NonNull public ByteVector putByte(int b)
      Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary.
      Returns:
      this byte vector
    • put11

      @NonNull public ByteVector put11(int b1, int b2)
      Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary.
      Returns:
      this byte vector
    • putShort

      @NonNull public ByteVector putShort(int s)
      Puts a short into this byte vector. The byte vector is automatically enlarged if necessary.
      Returns:
      this byte vector
    • put12

      @NonNull public ByteVector put12(int b, int s)
      Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if necessary.
      Returns:
      this byte vector
    • putInt

      @NonNull public ByteVector putInt(int i)
      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

      public void putUTF8(@NonNull String utf8String)
      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 bytes
      offset - index of the first byte of code that must be copied
      numBytes - number of bytes of code that must be copied
    • putByteVector

      public void putByteVector(@NonNull ByteVector another)
    • roundUpLength

      public void roundUpLength()