Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk
Class ByteBufferEncoder

    java.lang.Object
      com.sun.squawk.ByteBufferEncoder

    public final class ByteBufferEncoder

extends Object

A byte buffer encoder can be used to build a byte array of values encoded using a space-saving encoding. The byte array can be decoded with a `byte buffer decoder`.

Field Summary
`protected byte[]` | `buffer` The data written to this buffer.
`protected int` | `count` The amount of data written to the buffer.

Constructor Summary
`ByteBufferEncoder()`

Method Summary
`void` | `add(ByteBufferEncoder buf)` Adds the contents of another ByteBuffer to this buffer.
`void` | `addUnencodedByte(int value)` Adds an unencoded byte to the buffer.
`void` | `addUnsignedByte(int value)` Adds an unsigned byte value to the buffer.
`void` | `addUnsignedShort(int value)` Adds an unsigned short value to the buffer.
`void` | `addUtf8(String s)` Adds a string to the buffer in UTF8 encoded form.
`protected void` | `ensure(int needed)` Ensures that the buffer is large enough.
`void` | `reset()` Clears the buffer.
`byte[]` | `toByteArray()` Gets the contents of this buffer as a byte array.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### count

    protected int count

  The amount of data written to the buffer.

### buffer

    protected byte[] buffer

  The data written to this buffer.

Constructor Detail

### ByteBufferEncoder

    public ByteBufferEncoder()

Method Detail

### reset

    public void reset()

  Clears the buffer.

### ensure

    protected final void ensure(int needed)

  Ensures that the buffer is large enough.

  Parameters:
    `needed` - the extra amount of data about to be written

### addUnencodedByte

    public final void addUnencodedByte(int value)

  Adds an unencoded byte to the buffer.

  Parameters:
    `value` - the byte to be added.

### addUnsignedByte

    public final void addUnsignedByte(int value)

  Adds an unsigned byte value to the buffer.

  Parameters:
    `value` - the byte to be added (must be between 0 and 0xFF).

### addUnsignedShort

    public final void addUnsignedShort(int value)

  Adds an unsigned short value to the buffer. The number of bytes added to the buffer will be 1 if `value` is less than 128 otherwise the value will be encoded in 2 bytes.

  Parameters:
    `value` - the byte to be added (must be between 0 and 0xFFFF).

### addUtf8

    public void addUtf8(String s)

  Adds a string to the buffer in UTF8 encoded form. The length of the string is prepended with `addUnsignedShort(int)`.

  Parameters:
    `s` - the string to add

### add

    public void add(ByteBufferEncoder buf)

  Adds the contents of another ByteBuffer to this buffer. The length of `buf` is added with `addUnsignedInt(int)` before its contents are.

  Parameters:
    `buf` - the buffer to add

### toByteArray

    public byte[] toByteArray()

  Gets the contents of this buffer as a byte array.

  Returns:
    the contents of this buffer as a byte array

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"