Class ByteStringBuffer

java.lang.Object
com.unboundid.util.ByteStringBuffer
All Implemented Interfaces:
Serializable, Appendable

This class provides a growable byte array to which data can be appended. Methods in this class are not synchronized.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new empty byte string buffer with a default initial capacity.
    ByteStringBuffer(int initialCapacity)
    Creates a new byte string buffer with the specified capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    append(boolean b)
    Appends the provided boolean value to this buffer.
    append(byte b)
    Appends the provided byte to this buffer.
    append(byte[] b)
    Appends the contents of the provided byte array to this buffer.
    append(byte[] b, int off, int len)
    Appends the specified portion of the provided byte array to this buffer.
    append(char c)
    Appends the provided character to this buffer.
    append(char[] c)
    Appends the contents of the provided character array to this buffer.
    append(char[] c, int off, int len)
    Appends the specified portion of the provided character array to this buffer.
    append(int i)
    Appends the provided integer value to this buffer.
    append(long l)
    Appends the provided long value to this buffer.
    Appends the provided byte string to this buffer.
    Appends the provided byte string buffer to this buffer.
    Appends the provided character sequence to this buffer.
    append(CharSequence s, int start, int end)
    Appends the provided character sequence to this buffer.
    appendCodePoint(int codePoint)
    Appends the provided code point to this buffer.
    Creates an input stream that may be used to read content from this buffer.
    byte
    byteAt(int offset)
    Retrieves the byte at the specified offset in the buffer.
    byte[]
    bytesAt(int offset, int length)
    Retrieves the specified subset of bytes from the buffer.
    int
    Returns the current capacity for this buffer.
    Clears the contents of this buffer.
    clear(boolean zero)
    Clears the contents of this buffer.
    delete(int len)
    Deletes the specified number of bytes from the beginning of the buffer.
    delete(int off, int len)
    Deletes the indicated number of bytes from the specified location in the buffer.
    Creates a duplicate of this byte string buffer.
    boolean
    endsWith(byte[] bytes)
    Indicates whether this buffer ends with the specified set of bytes.
    void
    ensureCapacity(int minimumCapacity)
    Ensures that the total capacity of this buffer is at least equal to the specified size.
    boolean
    Indicates whether the provided object is a byte string buffer with contents that are identical to that of this buffer.
    byte[]
    Retrieves the current backing array for this buffer.
    int
    Retrieves a hash code for this byte array.
    insert(int pos, boolean b)
    Inserts the provided boolean value to this buffer.
    insert(int pos, byte b)
    Inserts the provided byte at the specified position in this buffer.
    insert(int pos, byte[] b)
    Inserts the contents of the provided byte array at the specified position in this buffer.
    insert(int pos, byte[] b, int off, int len)
    Inserts a portion of the data in the provided array at the specified position in this buffer.
    insert(int pos, char c)
    Inserts the provided character into this buffer at the provided position.
    insert(int pos, char[] c)
    Inserts the contents of the provided character array into this buffer at the specified position.
    insert(int pos, char[] c, int off, int len)
    Inserts the specified portion of the provided character array to this buffer at the specified position.
    insert(int pos, int i)
    Inserts the provided integer value to this buffer.
    insert(int pos, long l)
    Inserts the provided long value to this buffer.
    insert(int pos, ByteString b)
    Inserts the provided byte string into this buffer at the specified position.
    insert(int pos, ByteStringBuffer buffer)
    Inserts the provided byte string buffer into this buffer at the specified position.
    insert(int pos, CharSequence s)
    Inserts the provided character sequence to this buffer at the specified position.
    insertCodePoint(int pos, int codePoint)
    Inserts the provided code point into this buffer.
    boolean
    Indicates whether this buffer is currently empty.
    int
    Retrieves the number of bytes contained in this buffer.
    void
    readFrom(File file)
    Reads the contents of the specified file into this buffer, appending it to the end of the buffer.
    void
    readFrom(InputStream inputStream)
    Reads data from the provided input stream into this buffer, appending it to the end of the buffer.
    set(boolean b)
    Sets the contents of this buffer to include only the provided boolean value.
    set(byte b)
    Sets the contents of this buffer to include only the provided byte.
    set(byte[] b)
    Sets the contents of this buffer to the contents of the provided byte array.
    set(byte[] b, int off, int len)
    Sets the contents of this buffer to the specified portion of the provided byte array.
    set(char c)
    Sets the contents of this buffer to include only the provided character.
    set(char[] c)
    Sets the contents of this buffer to the contents of the provided character array.
    set(char[] c, int off, int len)
    Sets the contents of this buffer to the specified portion of the provided character array.
    set(int i)
    Sets the contents of this buffer to include only the provided integer value.
    set(long l)
    Sets the contents of this buffer to include only the provided long value.
    Sets the contents of this buffer to the contents of the provided byte string.
    Sets the contents of this buffer to the contents of the provided byte string buffer.
    Sets the contents of this buffer to the specified portion of the provided character sequence.
    void
    setCapacity(int capacity)
    Sets the capacity equal to the specified value.
    void
    setLength(int length)
    Sets the length of this buffer to the specified value.
    boolean
    startsWith(byte[] bytes)
    Indicates whether this buffer starts with the specified set of bytes.
    byte[]
    Returns a new byte array with the content from this buffer.
    Returns a new byte string with the content from this buffer.
    Retrieves a string representation of the contents for this buffer.
    Trims the backing array to the minimal size required for this buffer.
    void
    write(OutputStream outputStream)
    Writes the contents of this byte string buffer to the provided output stream.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ByteStringBuffer

      Creates a new empty byte string buffer with a default initial capacity.
    • ByteStringBuffer

      public ByteStringBuffer(int initialCapacity)
      Creates a new byte string buffer with the specified capacity.
      Parameters:
      initialCapacity - The initial capacity to use for the buffer. It must be greater than or equal to zero.
  • Method Details

    • append

      @NotNull public ByteStringBuffer append(boolean b)
      Appends the provided boolean value to this buffer.
      Parameters:
      b - The boolean value to be appended to this buffer.
      Returns:
      A reference to this buffer.
    • append

      @NotNull public ByteStringBuffer append(byte b)
      Appends the provided byte to this buffer.
      Parameters:
      b - The byte to be appended to this buffer.
      Returns:
      A reference to this buffer.
    • append

      Appends the contents of the provided byte array to this buffer.
      Parameters:
      b - The array whose contents should be appended to this buffer. It must not be null.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
    • append

      Appends the specified portion of the provided byte array to this buffer.
      Parameters:
      b - The array whose contents should be appended to this buffer.
      off - The offset within the array at which to begin copying data.
      len - The number of bytes to copy.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
      IndexOutOfBoundsException - If the offset or length are negative, if the offset plus the length is beyond the end of the provided array.
    • append

      Appends the provided byte string to this buffer.
      Parameters:
      b - The byte string to be appended to this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided byte string is null.
    • append

      Appends the provided byte string buffer to this buffer.
      Parameters:
      buffer - The buffer whose contents should be appended to this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided buffer is null.
    • append

      @NotNull public ByteStringBuffer append(char c)
      Appends the provided character to this buffer.
      Specified by:
      append in interface Appendable
      Parameters:
      c - The character to be appended to this buffer.
      Returns:
      A reference to this buffer.
    • append

      Appends the contents of the provided character array to this buffer.
      Parameters:
      c - The array whose contents should be appended to this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
    • append

      Appends the specified portion of the provided character array to this buffer.
      Parameters:
      c - The array whose contents should be appended to this buffer.
      off - The offset within the array at which to begin copying data.
      len - The number of characters to copy.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
      IndexOutOfBoundsException - If the offset or length are negative, if the offset plus the length is beyond the end of the provided array.
    • append

      Appends the provided character sequence to this buffer.
      Specified by:
      append in interface Appendable
      Parameters:
      s - The character sequence to append to this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided character sequence is null.
    • append

      Appends the provided character sequence to this buffer.
      Specified by:
      append in interface Appendable
      Parameters:
      s - The character sequence to append to this buffer.
      start - The position in the sequence of the first character in the sequence to be appended to this buffer.
      end - The position in the sequence immediately after the position of the last character to be appended.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided character sequence is null.
      IndexOutOfBoundsException - If the provided start or end positions are outside the bounds of the given character sequence.
    • append

      Appends the provided integer value to this buffer.
      Parameters:
      i - The integer value to be appended to this buffer.
      Returns:
      A reference to this buffer.
    • append

      @NotNull public ByteStringBuffer append(long l)
      Appends the provided long value to this buffer.
      Parameters:
      l - The long value to be appended to this buffer.
      Returns:
      A reference to this buffer.
    • appendCodePoint

      @NotNull public ByteStringBuffer appendCodePoint(int codePoint)
      Appends the provided code point to this buffer.
      Parameters:
      codePoint - The code point to append to this buffer.
      Returns:
      A reference to this buffer.
    • insert

      @NotNull public ByteStringBuffer insert(int pos, boolean b) throws IndexOutOfBoundsException
      Inserts the provided boolean value to this buffer.
      Parameters:
      pos - The position at which the value is to be inserted.
      b - The boolean value to be inserted into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      @NotNull public ByteStringBuffer insert(int pos, byte b) throws IndexOutOfBoundsException
      Inserts the provided byte at the specified position in this buffer.
      Parameters:
      pos - The position at which the byte is to be inserted.
      b - The byte to be inserted into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      Inserts the contents of the provided byte array at the specified position in this buffer.
      Parameters:
      pos - The position at which the data is to be inserted.
      b - The array whose contents should be inserted into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      @NotNull public ByteStringBuffer insert(int pos, @NotNull byte[] b, int off, int len) throws NullPointerException, IndexOutOfBoundsException
      Inserts a portion of the data in the provided array at the specified position in this buffer. Appends the specified portion of the provided byte array to this buffer.
      Parameters:
      pos - The position at which the data is to be inserted.
      b - The array whose contents should be inserted into this buffer.
      off - The offset within the array at which to begin copying data.
      len - The number of bytes to copy.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length, if the offset or length are negative, if the offset plus the length is beyond the end of the provided array.
    • insert

      Inserts the provided byte string into this buffer at the specified position.
      Parameters:
      pos - The position at which the data is to be inserted.
      b - The byte string to insert into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided byte string is null.
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      Inserts the provided byte string buffer into this buffer at the specified position.
      Parameters:
      pos - The position at which the data is to be inserted.
      buffer - The buffer whose contents should be inserted into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided buffer is null.
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      @NotNull public ByteStringBuffer insert(int pos, char c) throws IndexOutOfBoundsException
      Inserts the provided character into this buffer at the provided position.
      Parameters:
      pos - The position at which the character is to be inserted.
      c - The character to be inserted into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      Inserts the contents of the provided character array into this buffer at the specified position.
      Parameters:
      pos - The position at which the data is to be inserted.
      c - The array whose contents should be inserted into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      @NotNull public ByteStringBuffer insert(int pos, @NotNull char[] c, int off, int len) throws NullPointerException, IndexOutOfBoundsException
      Inserts the specified portion of the provided character array to this buffer at the specified position.
      Parameters:
      pos - The position at which the data is to be inserted.
      c - The array whose contents should be inserted into this buffer.
      off - The offset within the array at which to begin copying data.
      len - The number of characters to copy.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length, if the offset or length are negative, if the offset plus the length is beyond the end of the provided array.
    • insert

      Inserts the provided character sequence to this buffer at the specified position.
      Parameters:
      pos - The position at which the data is to be inserted.
      s - The character sequence to insert into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided character sequence is null.
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      @NotNull public ByteStringBuffer insert(int pos, int i) throws IndexOutOfBoundsException
      Inserts the provided integer value to this buffer.
      Parameters:
      pos - The position at which the value is to be inserted.
      i - The integer value to be inserted into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insert

      @NotNull public ByteStringBuffer insert(int pos, long l) throws IndexOutOfBoundsException
      Inserts the provided long value to this buffer.
      Parameters:
      pos - The position at which the value is to be inserted.
      l - The long value to be inserted into this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • insertCodePoint

      @NotNull public ByteStringBuffer insertCodePoint(int pos, int codePoint) throws IndexOutOfBoundsException
      Inserts the provided code point into this buffer.
      Parameters:
      pos - The position at which the code point is to be inserted.
      codePoint - The code point to be inserted.
      Returns:
      A reference to this buffer.
      Throws:
      IndexOutOfBoundsException - If the specified position is negative or greater than the current length.
    • delete

      Deletes the specified number of bytes from the beginning of the buffer.
      Parameters:
      len - The number of bytes to delete.
      Returns:
      A reference to this buffer.
      Throws:
      IndexOutOfBoundsException - If the specified length is negative, or if it is greater than the number of bytes currently contained in this buffer.
    • delete

      @NotNull public ByteStringBuffer delete(int off, int len) throws IndexOutOfBoundsException
      Deletes the indicated number of bytes from the specified location in the buffer.
      Parameters:
      off - The position in the buffer at which the content to delete begins.
      len - The number of bytes to remove from the buffer.
      Returns:
      A reference to this buffer.
      Throws:
      IndexOutOfBoundsException - If the offset or length is negative, or if the combination of the offset and length is greater than the end of the content in the buffer.
    • set

      @NotNull public ByteStringBuffer set(boolean b)
      Sets the contents of this buffer to include only the provided boolean value.
      Parameters:
      b - The boolean value to use as the content for this buffer.
      Returns:
      A reference to this buffer.
    • set

      @NotNull public ByteStringBuffer set(byte b)
      Sets the contents of this buffer to include only the provided byte.
      Parameters:
      b - The byte to use as the content for this buffer.
      Returns:
      A reference to this buffer.
    • set

      Sets the contents of this buffer to the contents of the provided byte array.
      Parameters:
      b - The byte array containing the content to use for this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
    • set

      Sets the contents of this buffer to the specified portion of the provided byte array.
      Parameters:
      b - The byte array containing the content to use for this buffer.
      off - The offset within the array at which to begin copying data.
      len - The number of bytes to copy.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
      IndexOutOfBoundsException - If the offset or length are negative, if the offset plus the length is beyond the end of the provided array.
    • set

      Sets the contents of this buffer to the contents of the provided byte string.
      Parameters:
      b - The byte string that should be used as the content for this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided byte string is null.
    • set

      Sets the contents of this buffer to the contents of the provided byte string buffer.
      Parameters:
      buffer - The buffer whose contents should be used as the content for this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided buffer is null.
    • set

      @NotNull public ByteStringBuffer set(char c)
      Sets the contents of this buffer to include only the provided character.
      Parameters:
      c - The character use as the content for this buffer.
      Returns:
      A reference to this buffer.
    • set

      Sets the contents of this buffer to the contents of the provided character array.
      Parameters:
      c - The character array containing the content to use for this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
    • set

      Sets the contents of this buffer to the specified portion of the provided character array.
      Parameters:
      c - The character array containing the content to use for this buffer.
      off - The offset within the array at which to begin copying data.
      len - The number of characters to copy.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided array is null.
      IndexOutOfBoundsException - If the offset or length are negative, if the offset plus the length is beyond the end of the provided array.
    • set

      Sets the contents of this buffer to the specified portion of the provided character sequence.
      Parameters:
      s - The character sequence to use as the content for this buffer.
      Returns:
      A reference to this buffer.
      Throws:
      NullPointerException - If the provided character sequence is null.
    • set

      @NotNull public ByteStringBuffer set(int i)
      Sets the contents of this buffer to include only the provided integer value.
      Parameters:
      i - The integer value to use as the content for this buffer.
      Returns:
      A reference to this buffer.
    • set

      @NotNull public ByteStringBuffer set(long l)
      Sets the contents of this buffer to include only the provided long value.
      Parameters:
      l - The long value to use as the content for this buffer.
      Returns:
      A reference to this buffer.
    • clear

      Clears the contents of this buffer.
      Returns:
      A reference to this buffer.
    • clear

      @NotNull public ByteStringBuffer clear(boolean zero)
      Clears the contents of this buffer.
      Parameters:
      zero - Indicates whether to overwrite the content of the backing array with all zeros in order to wipe out any sensitive data it may contain.
      Returns:
      A reference to this buffer.
    • getBackingArray

      @NotNull public byte[] getBackingArray()
      Retrieves the current backing array for this buffer. The data will begin at position 0 and will contain length() bytes.
      Returns:
      The current backing array for this buffer.
    • isEmpty

      public boolean isEmpty()
      Indicates whether this buffer is currently empty.
      Returns:
      true if this buffer is currently empty, or false if not.
    • length

      public int length()
      Retrieves the number of bytes contained in this buffer.
      Returns:
      The number of bytes contained in this buffer.
    • setLength

      public void setLength(int length) throws IndexOutOfBoundsException
      Sets the length of this buffer to the specified value. If the new length is greater than the current length, the value will be padded with zeroes.
      Parameters:
      length - The new length to use for the buffer. It must be greater than or equal to zero.
      Throws:
      IndexOutOfBoundsException - If the provided length is negative.
    • capacity

      public int capacity()
      Returns the current capacity for this buffer.
      Returns:
      The current capacity for this buffer.
    • ensureCapacity

      public void ensureCapacity(int minimumCapacity)
      Ensures that the total capacity of this buffer is at least equal to the specified size.
      Parameters:
      minimumCapacity - The minimum capacity for this buffer.
    • setCapacity

      public void setCapacity(int capacity) throws IndexOutOfBoundsException
      Sets the capacity equal to the specified value. If the provided capacity is less than the current length, then the length will be reduced to the new capacity.
      Parameters:
      capacity - The new capacity for this buffer. It must be greater than or equal to zero.
      Throws:
      IndexOutOfBoundsException - If the provided capacity is negative.
    • trimToSize

      Trims the backing array to the minimal size required for this buffer.
      Returns:
      A reference to this buffer.
    • byteAt

      public byte byteAt(int offset) throws IndexOutOfBoundsException
      Retrieves the byte at the specified offset in the buffer.
      Parameters:
      offset - The offset of the byte to read. It must be between greater than or equal to zero and less than length().
      Returns:
      The byte at the specified offset in the buffer.
      Throws:
      IndexOutOfBoundsException - If the provided offset is negative or greater than or equal to the length of the buffer.
    • bytesAt

      @NotNull public byte[] bytesAt(int offset, int length) throws IndexOutOfBoundsException
      Retrieves the specified subset of bytes from the buffer.
      Parameters:
      offset - The offset of the first byte to retrieve. It must be greater than or equal to zero and less than length().
      length - The number of bytes to retrieve. It must be greater than or equal to zero, and the sum of offset and length must be less than or equal to length().
      Returns:
      A byte array containing the specified subset of bytes from the buffer.
      Throws:
      IndexOutOfBoundsException - If either the offset or the length is negative, or if the offsset plus the length is greater than or equal to the length of the buffer.
    • startsWith

      public boolean startsWith(@NotNull byte[] bytes)
      Indicates whether this buffer starts with the specified set of bytes.
      Parameters:
      bytes - The bytes for which to make the determination.
      Returns:
      true if this buffer starts with the specified set of bytes, or false if not.
    • endsWith

      public boolean endsWith(@NotNull byte[] bytes)
      Indicates whether this buffer ends with the specified set of bytes.
      Parameters:
      bytes - The bytes for which to make the determination.
      Returns:
      true if this buffer ends with the specified set of bytes, or false if not.
    • toByteArray

      @NotNull public byte[] toByteArray()
      Returns a new byte array with the content from this buffer.
      Returns:
      A byte array containing the content from this buffer.
    • toByteString

      Returns a new byte string with the content from this buffer.
      Returns:
      A byte string with the content from this buffer.
    • asInputStream

      Creates an input stream that may be used to read content from this buffer. This buffer should not be altered while the input stream is being used.
      Returns:
      An input stream that may be used to read content from this buffer.
    • readFrom

      public void readFrom(@NotNull File file) throws IOException
      Reads the contents of the specified file into this buffer, appending it to the end of the buffer.
      Parameters:
      file - The file to be read.
      Throws:
      IOException - If an unexpected problem occurs.
    • readFrom

      public void readFrom(@NotNull InputStream inputStream) throws IOException
      Reads data from the provided input stream into this buffer, appending it to the end of the buffer. The entire content of the input stream will be read, but the input stream will not be closed.
      Parameters:
      inputStream - The input stream from which data is to be read.
      Throws:
      IOException - If an unexpected problem occurs.
    • write

      public void write(@NotNull OutputStream outputStream) throws IOException
      Writes the contents of this byte string buffer to the provided output stream.
      Parameters:
      outputStream - The output stream to which the data should be written.
      Throws:
      IOException - If a problem occurs while writing to the provided output stream.
    • hashCode

      public int hashCode()
      Retrieves a hash code for this byte array.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code for this byte array.
    • equals

      public boolean equals(@Nullable Object o)
      Indicates whether the provided object is a byte string buffer with contents that are identical to that of this buffer.
      Overrides:
      equals in class Object
      Parameters:
      o - The object for which to make the determination.
      Returns:
      true if the provided object is considered equal to this buffer, or false if not.
    • duplicate

      Creates a duplicate of this byte string buffer. It will have identical content but with a different backing array. Changes to this byte string buffer will not impact the duplicate, and vice-versa.
      Returns:
      A duplicate of this byte string buffer.
    • toString

      Retrieves a string representation of the contents for this buffer.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the contents for this buffer.