Package org.agrona

Class AsciiSequenceView

java.lang.Object
org.agrona.AsciiSequenceView
All Implemented Interfaces:
CharSequence

public class AsciiSequenceView extends Object implements CharSequence
View over a DirectBuffer which contains an ASCII string for a given range.
  • Field Details

    • buffer

      private DirectBuffer buffer
    • offset

      private int offset
    • length

      private int length
  • Constructor Details

    • AsciiSequenceView

      public AsciiSequenceView()
      Default constructor.
    • AsciiSequenceView

      public AsciiSequenceView(DirectBuffer buffer, int offset, int length)
      Construct a view over a DirectBuffer from an offset for a given length.
      Parameters:
      buffer - containing the ASCII sequence.
      offset - at which the ASCII sequence begins.
      length - of the ASCII sequence in bytes.
  • Method Details

    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • buffer

      public DirectBuffer buffer()
      Gets the underlying buffer which this is a view over.
      Returns:
      the underlying buffer which this is a view over.
    • offset

      public int offset()
      Gets the offset into the underlying buffer.
      Returns:
      the offset into the underlying buffer.
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public AsciiSequenceView subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • wrap

      public AsciiSequenceView wrap(DirectBuffer buffer, int offset, int length)
      Wrap a range of an existing buffer containing an ASCII sequence.
      Parameters:
      buffer - containing the ASCII sequence.
      offset - at which the ASCII sequence begins.
      length - of the ASCII sequence in bytes.
      Returns:
      this for a fluent API.
    • reset

      public void reset()
      Reset the view to null.
    • getBytes

      public int getBytes(MutableDirectBuffer dstBuffer, int dstOffset)
      Copy the bytes from a view into a provided buffer.
      Parameters:
      dstBuffer - into which the bytes will be copied.
      dstOffset - offset in the destination buffer to begin the copy.
      Returns:
      the number of bytes copied.
    • toString

      public String toString()
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object