Interface RandomAccessOutputStream
-
- All Superinterfaces:
DirectDataOutput
- All Known Implementing Classes:
ByteBufferOutputStream
public interface RandomAccessOutputStream extends DirectDataOutput
Defines an extension to OutputStream that allows writing to an arbitrary position.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteArraySegmentgetData()Returns aByteArraySegmentwrapping the current contents of theRandomAccessOutputStream.intsize()Gets a value indicating the size of this OutputStream.voidwrite(byte[] buffer, int bufferOffset, int length, int position)Writes a sequence of bytes at the given position.voidwrite(int byteValue, int position)Writes the given byte value at the given position.voidwriteInt(int intValue, int position)Writes the given Int value at the given position.-
Methods inherited from interface io.pravega.common.io.DirectDataOutput
writeBuffer, writeInt, writeLong, writeShort
-
-
-
-
Method Detail
-
writeInt
void writeInt(int intValue, int position) throws java.io.IOExceptionWrites the given Int value at the given position.- Parameters:
intValue- The value to write.position- The position to write at.- Throws:
java.io.IOException- If an IO Exception occurred.java.lang.IndexOutOfBoundsException- If position is outside of the current bounds of this object.
-
write
void write(int byteValue, int position) throws java.io.IOExceptionWrites the given byte value at the given position.- Parameters:
byteValue- The value to write.position- The position to write at.- Throws:
java.io.IOException- If an IO Exception occurred.java.lang.IndexOutOfBoundsException- If position is outside of the current bounds of this object.
-
write
void write(byte[] buffer, int bufferOffset, int length, int position) throws java.io.IOExceptionWrites a sequence of bytes at the given position. NOTE: depending on the implementation of this interface, this may result in increasing the size of the stream. For example, if position is smaller than size() AND position + length is larger than size() then the extra bytes may be appended at the end, if the underlying OutputStream's structure permits it.- Parameters:
buffer- The buffer to write from.bufferOffset- The offset within the buffer to start at.length- The number of bytes to write.position- The position within the OutputStream to write at.- Throws:
java.io.IOException- If an IO Exception occurred.java.lang.IndexOutOfBoundsException- If bufferOffset and length are invalid for the given buffer or if position is invalid for the current OutputStream's state.
-
size
int size()
Gets a value indicating the size of this OutputStream.- Returns:
- size of stream
-
getData
ByteArraySegment getData()
Returns aByteArraySegmentwrapping the current contents of theRandomAccessOutputStream. Further changes to theRandomAccessOutputStreammay or may not be reflected in the returned object (depending on methods invoked and whether the underlying buffers need to be resized).- Returns:
- A
ByteArraySegmentfrom the current contents of theRandomAccessOutputStream.
-
-