Package: org.grails.asm

## [Java] Class ByteVector

- org.grails.asm.ByteVector

-     class ByteVector
      extends java.lang.Object

  A dynamically extensible vector of bytes. This class is roughly equivalent to a DataOutputStream on top of a ByteArrayOutputStream, but is more efficient.

  Authors:
    Eric Bruneton

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `byte[]` | `data` | The content of this vector.
    `int` | `length` | Actual number of bytes in this vector.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ByteVector ()` Constructs a new ByteVector with a default initial size.
    `ByteVector (int initialSize)` Constructs a new ByteVector with the given initial size.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `ByteVector` | `encodeUTF8(java.lang.String s, int i, int maxByteLength)` Puts an UTF8 string into this byte vector.
    `` | `private void` | `enlarge(int size)` Enlarge this byte vector so that it can receive n more bytes.
    `` | `ByteVector` | `put11(int b1, int b2)` Puts two bytes into this byte vector.
    `` | `ByteVector` | `put12(int b, int s)` Puts a byte and a short into this byte vector.
    `` | `public ByteVector` | `putByte(int b)` Puts a byte into this byte vector.
    `` | `public ByteVector` | `putByteArray(byte[] b, int off, int len)` Puts an array of bytes into this byte vector.
    `` | `public ByteVector` | `putInt(int i)` Puts an int into this byte vector.
    `` | `public ByteVector` | `putLong(long l)` Puts a long into this byte vector.
    `` | `public ByteVector` | `putShort(int s)` Puts a short into this byte vector.
    `` | `public ByteVector` | `putUTF8(java.lang.String s)` Puts an UTF8 string into this byte vector.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### byte[] data

      The content of this vector.

    - #### int length

      Actual number of bytes in this vector.

  - ### Constructor Detail

    - #### public ByteVector()

      Constructs a new ByteVector with a default initial size.

    - #### public ByteVector(int initialSize)

      Constructs a new ByteVector with the given initial size.

      Parameters:
        `initialSize` - the initial size of the byte vector to be constructed.

  - ### Method Detail

    - #### ByteVector encodeUTF8(java.lang.String s, int i, int maxByteLength)

      Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary. The string length is encoded in two bytes before the encoded characters, if there is space for that (i.e. if this.length - i - 2 >= 0).

      Parameters:
        `s` - the String to encode.
        `i` - the index of the first character to encode. The previous characters are supposed to have already been encoded, using only one byte per character.
        `maxByteLength` - the maximum byte length of the encoded string, including the already encoded characters.
      Returns:
        this byte vector.

    - #### private void enlarge(int size)

      Enlarge this byte vector so that it can receive n more bytes.

      Parameters:
        `size` - number of additional bytes that this byte vector should be able to receive.

    - #### ByteVector put11(int b1, int b2)

      Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary.

      Parameters:
        `b1` - a byte.
        `b2` - another byte.
      Returns:
        this byte vector.

    - #### ByteVector put12(int b, int s)

      Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if necessary.

      Parameters:
        `b` - a byte.
        `s` - a short.
      Returns:
        this byte vector.

    - #### public ByteVector putByte(int b)

      Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary.

      Parameters:
        `b` - a byte.
      Returns:
        this byte vector.

    - #### public ByteVector putByteArray(byte[] b, int off, int len)

      Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if necessary.

      Parameters:
        `b` - an array of bytes. May be `null` to put `len` null bytes into this byte vector.
        `off` - index of the fist byte of b that must be copied.
        `len` - number of bytes of b that must be copied.
      Returns:
        this byte vector.

    - #### public ByteVector putInt(int i)

      Puts an int into this byte vector. The byte vector is automatically enlarged if necessary.

      Parameters:
        `i` - an int.
      Returns:
        this byte vector.

    - #### public ByteVector putLong(long l)

      Puts a long into this byte vector. The byte vector is automatically enlarged if necessary.

      Parameters:
        `l` - a long.
      Returns:
        this byte vector.

    - #### public ByteVector putShort(int s)

      Puts a short into this byte vector. The byte vector is automatically enlarged if necessary.

      Parameters:
        `s` - a short.
      Returns:
        this byte vector.

    - #### public ByteVector putUTF8(java.lang.String s)

      Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary.

      Parameters:
        `s` - a String whose UTF8 encoded length must be less than 65536.
      Returns:
        this byte vector.