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 Summary

    Constructors
    Constructor
    Description
    Constructs 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 Type
    Method
    Description
    byte[]
    Returns the byte data.
    @org.checkerframework.checker.index.qual.NonNegative int
    Returns the length 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
     
    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
    putUTF8(String utf8String)
    Puts an UTF8 string into this byte vector.
    void
     
    void
    setLength(@org.checkerframework.checker.index.qual.NonNegative int length)
    Sets the length of this vector, in bytes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 byte data.
    • getLength

      public @org.checkerframework.checker.index.qual.NonNegative int getLength()
      Returns the length of this vector, in bytes.
    • setLength

      public void setLength(@org.checkerframework.checker.index.qual.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, @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 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()