Package io.protostuff

Class LinkedBuffer

java.lang.Object
io.protostuff.LinkedBuffer

public final class LinkedBuffer extends Object
A buffer that wraps a byte array and has a reference to the next buffer for dynamic increase.
  • Field Details

  • Constructor Details

    • LinkedBuffer

      LinkedBuffer(int size)
      Creates a buffer with the specified size.
    • LinkedBuffer

      LinkedBuffer(int size, LinkedBuffer appendTarget)
      Creates a buffer with the specified size and appends to the provided buffer appendTarget.
    • LinkedBuffer

      LinkedBuffer(byte[] buffer, int offset)
      Uses the buffer starting at the specified offset
    • LinkedBuffer

      LinkedBuffer(byte[] buffer, int start, int offset)
    • LinkedBuffer

      LinkedBuffer(byte[] buffer, int offset, LinkedBuffer appendTarget)
      Uses the buffer starting at the specified offset and appends to the provided buffer appendTarget.
    • LinkedBuffer

      LinkedBuffer(byte[] buffer, int start, int offset, LinkedBuffer appendTarget)
    • LinkedBuffer

      LinkedBuffer(LinkedBuffer viewSource, LinkedBuffer appendTarget)
      Creates a view from the buffer viewSource and appends the view to the provided buffer appendTarget.
  • Method Details

    • allocate

      public static LinkedBuffer allocate()
      Allocates a new buffer with default size.
    • allocate

      public static LinkedBuffer allocate(int size)
      Allocates a new buffer with the specified size.
    • allocate

      public static LinkedBuffer allocate(int size, LinkedBuffer previous)
      Allocates a new buffer with the specified size and appends it to the previous buffer.
    • wrap

      public static LinkedBuffer wrap(byte[] array, int offset, int length)
      Wraps the byte array buffer as a read-only buffer.
    • use

      public static LinkedBuffer use(byte[] buffer)
      Uses the existing byte array as the internal buffer.
    • use

      public static LinkedBuffer use(byte[] buffer, int start)
      Uses the existing byte array as the internal buffer.
    • writeTo

      public static int writeTo(OutputStream out, LinkedBuffer node) throws IOException
      Writes the contents of the LinkedBuffer into the OutputStream.
      Returns:
      the total content size of the buffer.
      Throws:
      IOException
    • writeTo

      public static int writeTo(DataOutput out, LinkedBuffer node) throws IOException
      Writes the contents of the LinkedBuffer into the DataOutput.
      Returns:
      the total content size of the buffer.
      Throws:
      IOException
    • clear

      public LinkedBuffer clear()
      The offset will be reset to its starting position. The buffer next to this will be dereferenced.