Package org.agrona
Class AsciiSequenceView
- java.lang.Object
-
- org.agrona.AsciiSequenceView
-
- All Implemented Interfaces:
java.lang.CharSequence
public class AsciiSequenceView extends java.lang.Object implements java.lang.CharSequence
View over aDirectBuffer
which contains an ASCII string for a given range.
-
-
Field Summary
Fields Modifier and Type Field Description private DirectBuffer
buffer
private int
length
private int
offset
-
Constructor Summary
Constructors Constructor Description AsciiSequenceView()
Default constructor.AsciiSequenceView(DirectBuffer buffer, int offset, int length)
Construct a view over aDirectBuffer
from an offset for a given length.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DirectBuffer
buffer()
Gets the underlying buffer which this is a view over.char
charAt(int index)
int
getBytes(MutableDirectBuffer dstBuffer, int dstOffset)
Copy the bytes from a view into a provided buffer.int
length()
int
offset()
Gets the offset into the underlying buffer.void
reset()
Reset the view to null.AsciiSequenceView
subSequence(int start, int end)
java.lang.String
toString()
AsciiSequenceView
wrap(DirectBuffer buffer, int offset, int length)
Wrap a range of an existing buffer containing an ASCII sequence.
-
-
-
Field Detail
-
buffer
private DirectBuffer buffer
-
offset
private int offset
-
length
private int length
-
-
Constructor Detail
-
AsciiSequenceView
public AsciiSequenceView()
Default constructor.
-
AsciiSequenceView
public AsciiSequenceView(DirectBuffer buffer, int offset, int length)
Construct a view over aDirectBuffer
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 Detail
-
length
public int length()
- Specified by:
length
in interfacejava.lang.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 interfacejava.lang.CharSequence
-
subSequence
public AsciiSequenceView subSequence(int start, int end)
- Specified by:
subSequence
in interfacejava.lang.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 java.lang.String toString()
- Specified by:
toString
in interfacejava.lang.CharSequence
- Overrides:
toString
in classjava.lang.Object
-
-