Package org.agrona.io
Class ExpandableDirectBufferOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.agrona.io.ExpandableDirectBufferOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class ExpandableDirectBufferOutputStream extends java.io.OutputStream
OutputStream
that wraps an underlying expandable version of aMutableDirectBuffer
.
-
-
Field Summary
Fields Modifier and Type Field Description private MutableDirectBuffer
buffer
private int
offset
private int
position
-
Constructor Summary
Constructors Constructor Description ExpandableDirectBufferOutputStream()
Default constructor.ExpandableDirectBufferOutputStream(MutableDirectBuffer buffer)
Wrap givenMutableDirectBuffer
.ExpandableDirectBufferOutputStream(MutableDirectBuffer buffer, int offset)
Wrap givenMutableDirectBuffer
at a given offset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MutableDirectBuffer
buffer()
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.
-
-
-
Field Detail
-
buffer
private MutableDirectBuffer buffer
-
offset
private int offset
-
position
private int position
-
-
Constructor Detail
-
ExpandableDirectBufferOutputStream
public ExpandableDirectBufferOutputStream()
Default constructor.
-
ExpandableDirectBufferOutputStream
public ExpandableDirectBufferOutputStream(MutableDirectBuffer buffer)
Wrap givenMutableDirectBuffer
.- Parameters:
buffer
- to wrap.
-
ExpandableDirectBufferOutputStream
public ExpandableDirectBufferOutputStream(MutableDirectBuffer buffer, int offset)
Wrap givenMutableDirectBuffer
at a given offset.- Parameters:
buffer
- to wrap.offset
- at which the puts will occur.
-
-
Method Detail
-
wrap
public void wrap(MutableDirectBuffer buffer)
Wrap a given buffer beginning with an offset of 0.- Parameters:
buffer
- to wrap
-
wrap
public void wrap(MutableDirectBuffer buffer, int offset)
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
public MutableDirectBuffer 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 classjava.io.OutputStream
- Parameters:
b
- to be written.
-
write
public void write(byte[] srcBytes, int srcOffset, int length)
Write a byte[] to the buffer.- Overrides:
write
in classjava.io.OutputStream
- 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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
-
-