Package com.ibm.fhir.persistence.util
Class InputOutputByteStream
- java.lang.Object
- 
- com.ibm.fhir.persistence.util.InputOutputByteStream
 
- 
 @NotThreadSafe public class InputOutputByteStream extends java.lang.ObjectA byte buffer which supports both InputStream and OutputStream interfaces without needless copying of (potentially large) byte arrays. Not intended for multi-threaded access (no synchronization).
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classInputOutputByteStream.ReshapeStrategyStrategy for how we resize the buffer.
 - 
Constructor SummaryConstructors Constructor Description InputOutputByteStream(byte[] adoptBuffer, int offset)Adopt a buffer which may already contain dataInputOutputByteStream(int initialCapacity)Create a buffer with the given capacity and defaultInputOutputByteStream.ReshapeStrategyInputOutputByteStream(int initialCapacity, InputOutputByteStream.ReshapeStrategy strat)Create a buffer with a given capacity and override theInputOutputByteStream.ReshapeStrategyInputOutputByteStream(java.nio.ByteBuffer bb)Initialize the internal buffer by copying the contents of the given ByteBuffer (which can be read-only).
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getRawBuffer()Get the underlying byte[] buffer at the current point in time.java.io.InputStreaminputStream()Provide a new InputStream with its own dedicated position starting at 0 offsetjava.io.OutputStreamoutputStream()Return a new output stream backed by the byte buffer managed by this.voidreset()Reset the offset to make the buffer appear empty.intsize()How many bytes have been written to the byte bufferjava.nio.ByteBufferwrap()Provides a wrapped version of the internal buffer.
 
- 
- 
- 
Constructor Detail- 
InputOutputByteStreampublic InputOutputByteStream(int initialCapacity) Create a buffer with the given capacity and defaultInputOutputByteStream.ReshapeStrategy
 - 
InputOutputByteStreampublic InputOutputByteStream(byte[] adoptBuffer, int offset)Adopt a buffer which may already contain data- Parameters:
- adoptBuffer-
- offset-
 
 - 
InputOutputByteStreampublic InputOutputByteStream(java.nio.ByteBuffer bb) Initialize the internal buffer by copying the contents of the given ByteBuffer (which can be read-only).- Parameters:
- bb-
 
 - 
InputOutputByteStreampublic InputOutputByteStream(int initialCapacity, InputOutputByteStream.ReshapeStrategy strat)Create a buffer with a given capacity and override theInputOutputByteStream.ReshapeStrategy- Parameters:
- initialCapacity-
- strat-
 
 
- 
 - 
Method Detail- 
sizepublic int size() How many bytes have been written to the byte buffer- Returns:
 
 - 
outputStreampublic java.io.OutputStream outputStream() Return a new output stream backed by the byte buffer managed by this.- Returns:
- Throws:
- java.lang.IllegalStateException- if called after the mode has been flipped to read.
 
 - 
inputStreampublic java.io.InputStream inputStream() Provide a new InputStream with its own dedicated position starting at 0 offset- Returns:
 
 - 
wrappublic java.nio.ByteBuffer wrap() Provides a wrapped version of the internal buffer.- Returns:
- a read-only ByteBuffer.
 
 - 
resetpublic void reset() Reset the offset to make the buffer appear empty. Does not change the current length (capacity). Note that any streams currently being used to read the data will end.
 - 
getRawBufferpublic byte[] getRawBuffer() Get the underlying byte[] buffer at the current point in time.- Returns:
 
 
- 
 
-