Package org.agrona.io
Class DirectBufferInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.agrona.io.DirectBufferInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class DirectBufferInputStream extends java.io.InputStream
AnInputStream
that wraps aDirectBuffer
.
-
-
Field Summary
Fields Modifier and Type Field Description private DirectBuffer
buffer
private int
length
private int
offset
private int
position
-
Constructor Summary
Constructors Constructor Description DirectBufferInputStream()
Default constructor.DirectBufferInputStream(DirectBuffer buffer)
Wrap givenDirectBuffer
.DirectBufferInputStream(DirectBuffer buffer, int offset, int length)
Wrap givenDirectBuffer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
DirectBuffer
buffer()
The underlying buffer being wrapped.void
close()
int
length()
The length of the underlying buffer to useboolean
markSupported()
int
offset()
The offset within the underlying buffer at which to start.int
read()
int
read(byte[] dstBytes, int dstOffset, int length)
long
skip(long n)
void
wrap(DirectBuffer buffer)
Wrap givenDirectBuffer
.void
wrap(DirectBuffer buffer, int offset, int length)
Wrap givenDirectBuffer
.
-
-
-
Field Detail
-
buffer
private DirectBuffer buffer
-
offset
private int offset
-
length
private int length
-
position
private int position
-
-
Constructor Detail
-
DirectBufferInputStream
public DirectBufferInputStream()
Default constructor.
-
DirectBufferInputStream
public DirectBufferInputStream(DirectBuffer buffer)
Wrap givenDirectBuffer
.- Parameters:
buffer
- to wrap.
-
DirectBufferInputStream
public DirectBufferInputStream(DirectBuffer buffer, int offset, int length)
Wrap givenDirectBuffer
.- Parameters:
buffer
- to wrap.offset
- into the buffer.length
- in bytes.
-
-
Method Detail
-
wrap
public void wrap(DirectBuffer buffer)
Wrap givenDirectBuffer
.- Parameters:
buffer
- to wrap.
-
wrap
public void wrap(DirectBuffer buffer, int offset, int length)
Wrap givenDirectBuffer
.- Parameters:
buffer
- to wrap.offset
- into the buffer.length
- in bytes.
-
offset
public int offset()
The offset within the underlying buffer at which to start.- Returns:
- offset within the underlying buffer at which to start.
-
length
public int length()
The length of the underlying buffer to use- Returns:
- length of the underlying buffer to use
-
buffer
public DirectBuffer buffer()
The underlying buffer being wrapped.- Returns:
- the underlying buffer being wrapped.
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
available
public int available()
- Overrides:
available
in classjava.io.InputStream
-
skip
public long skip(long n)
- Overrides:
skip
in classjava.io.InputStream
-
read
public int read()
- Specified by:
read
in classjava.io.InputStream
-
read
public int read(byte[] dstBytes, int dstOffset, int length)
- Overrides:
read
in classjava.io.InputStream
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
-
-