Package org.agrona.io
Class ExpandableDirectBufferOutputStream
java.lang.Object
java.io.OutputStream
org.agrona.io.ExpandableDirectBufferOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
OutputStream
that wraps an underlying expandable version of a MutableDirectBuffer
.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Wrap givenMutableDirectBuffer
.ExpandableDirectBufferOutputStream
(MutableDirectBuffer buffer, int offset) Wrap givenMutableDirectBuffer
at a given offset. -
Method Summary
Modifier and TypeMethodDescriptionbuffer()
The underlying buffer being wrapped.void
close()
int
offset()
The offset within the underlying buffer at which to start.int
position()
The position in the buffer from the offset up to which has been written.void
wrap
(MutableDirectBuffer buffer) Wrap a given buffer beginning with an offset of 0.void
wrap
(MutableDirectBuffer buffer, int offset) Wrap a given buffer beginning at an offset.void
write
(byte[] srcBytes, int srcOffset, int length) Write a byte[] to the buffer.void
write
(int b) Write a byte to buffer.Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Field Details
-
buffer
-
offset
private int offset -
position
private int position
-
-
Constructor Details
-
ExpandableDirectBufferOutputStream
public ExpandableDirectBufferOutputStream()Default constructor. -
ExpandableDirectBufferOutputStream
Wrap givenMutableDirectBuffer
.- Parameters:
buffer
- to wrap.
-
ExpandableDirectBufferOutputStream
Wrap givenMutableDirectBuffer
at a given offset.- Parameters:
buffer
- to wrap.offset
- at which the puts will occur.
-
-
Method Details
-
wrap
Wrap a given buffer beginning with an offset of 0.- Parameters:
buffer
- to wrap
-
wrap
Wrap a given buffer beginning at an offset.- Parameters:
buffer
- to wrapoffset
- at which the puts will occur.
-
position
public int position()The position in the buffer from the offset up to which has been written.- Returns:
- the position in the buffer from the offset up to which has been written.
-
offset
public int offset()The offset within the underlying buffer at which to start.- Returns:
- offset within the underlying buffer at which to start.
-
buffer
The underlying buffer being wrapped.- Returns:
- the underlying buffer being wrapped.
-
write
public void write(int b) Write a byte to buffer.- Specified by:
write
in classOutputStream
- Parameters:
b
- to be written.
-
write
public void write(byte[] srcBytes, int srcOffset, int length) Write a byte[] to the buffer.- Overrides:
write
in classOutputStream
- Parameters:
srcBytes
- to writesrcOffset
- at which to begin reading bytes from the srcBytes.length
- of the srcBytes to read.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
-