Class JPPFBuffer

java.lang.Object
org.jppf.utils.JPPFBuffer

public class JPPFBuffer extends Object
buffer for the data read from or written to a socket connection.
Author:
Laurent Cohen, Domingos Creado
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    byte[]
    The actual buffer, intended to contain a serialized object graph.
    int
    The length of the buffer.
    int
    Current position in this buffer.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initialize this buffer.
    JPPFBuffer(byte[] buffer)
    Initialize this buffer with a specified buffer.
    JPPFBuffer(byte[] buffer, int length)
    Initialize this buffer with a specified buffer and buffer length.
    Initialize this buffer with the specified String, using UTF-8 encoding.
  • Method Summary

    Modifier and Type
    Method
    Description
    Transform this buffer into a string using UTF-8 encoding.
    byte[]
    Get the buffered data.
    int
    Get the length of the buffered data.
    int
    Return the number of bytes available for writing in this buffer.
    int
    Return the number of bytes available for reading in this buffer.
    Reset this buffer's position to 0.
    void
    setBuffer(byte[] buffer)
    Set the buffered data.
    void
    setLength(int length)
    Set the length of the buffered data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • buffer

      public byte[] buffer
      The actual buffer, intended to contain a serialized object graph.
    • length

      public int length
      The length of the buffer.
    • pos

      public int pos
      Current position in this buffer.
  • Constructor Details

    • JPPFBuffer

      public JPPFBuffer()
      Initialize this buffer.
    • JPPFBuffer

      public JPPFBuffer(String str)
      Initialize this buffer with the specified String, using UTF-8 encoding.
      Parameters:
      str - the string whose contents will be put into this buffer.
    • JPPFBuffer

      public JPPFBuffer(byte[] buffer)
      Initialize this buffer with a specified buffer.
      Parameters:
      buffer - the buffer to use.
    • JPPFBuffer

      public JPPFBuffer(byte[] buffer, int length)
      Initialize this buffer with a specified buffer and buffer length.
      Parameters:
      buffer - the buffer to use.
      length - the number of bytes to use in the buffer.
  • Method Details

    • setBuffer

      public void setBuffer(byte[] buffer)
      Set the buffered data.
      Parameters:
      buffer - an array of bytes containing the data.
    • getBuffer

      public byte[] getBuffer()
      Get the buffered data.
      Returns:
      an array of bytes containing the data.
    • setLength

      public void setLength(int length)
      Set the length of the buffered data.
      Parameters:
      length - the length as an int.
    • getLength

      public int getLength()
      Get the length of the buffered data.
      Returns:
      the length as an int.
    • remaining

      public int remaining()
      Return the number of bytes available for writing in this buffer.
      Returns:
      the available bytes as an int value.
    • remainingFromPos

      public int remainingFromPos()
      Return the number of bytes available for reading in this buffer.
      Returns:
      the available bytes as an int value.
    • reset

      public JPPFBuffer reset()
      Reset this buffer's position to 0.
      Returns:
      this buffer, for method call chaining.
    • asString

      public String asString()
      Transform this buffer into a string using UTF-8 encoding.
      Returns:
      the content of this buffer as a string.