Package com.jogamp.common.util
Interface Bitstream.ByteStream<T>
- All Known Implementing Classes:
Bitstream.ByteArrayStream,Bitstream.ByteBufferStream,Bitstream.ByteInputStream,Bitstream.ByteOutputStream
public static interface Bitstream.ByteStream<T>
General byte stream.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanInput()Return true if stream can handle input, i.e.booleanReturn true if stream can handle output, i.e.voidclose()Closing the underlying stream, impliesflush().voidflush()Synchronizes all underlyingoutput streamoperations, or do nothing.Returns the underlying streamvoidmark(int readLimit) Setmarkposto current position, allowing the stream to bereset().longposition()Returns the byte position in the stream.longposition(long newPosition) Sets this stream's position.intread()Reads one byte from the stream.voidreset()Reset stream position to markpos as set viamark(int).voidSets the underlying stream, withoutclose()ing the previous one.longskip(long n) It is implementation dependent, whether backward skip giving a negative number is supported or not.intwrite(byte val) Writes one byte, to the stream.
-
Method Details
-
setStream
Sets the underlying stream, withoutclose()ing the previous one. -
getStream
T getStream()Returns the underlying stream -
close
Closing the underlying stream, impliesflush().Implementation will
nullthe stream references, hencesetStream(Object)must be called before re-using instance.- Throws:
IOException
-
flush
Synchronizes all underlyingoutput streamoperations, or do nothing.- Throws:
IOException
-
canInput
boolean canInput()Return true if stream can handle input, i.e.read(). -
canOutput
boolean canOutput()Return true if stream can handle output, i.e.write(byte) -
position
long position()Returns the byte position in the stream. -
position
Sets this stream's position.A set mark is cleared if > new position.
Returns
Bitstream.EOSis end-of-stream is reached, otherwise the new position.Known supporting implementation is
Bitstream.ByteBufferStreamandBitstream.ByteArrayStream.- Parameters:
newPosition- The new positive position.- Returns:
- The new set position or
Bitstream.EOSif end-of-stream is reached. - Throws:
UnsupportedOperationException- if not supported, i.e.Bitstream.ByteInputStreamorBitstream.ByteOutputStreamIllegalArgumentException- If thenewPositionis negative
-
skip
It is implementation dependent, whether backward skip giving a negative number is supported or not.- Parameters:
n- number of bytes to skip- Returns:
- actual skipped bytes
- Throws:
IOException
-
mark
Setmarkposto current position, allowing the stream to bereset().- Parameters:
readlimit- maximum number of bytes able to read before invalidating themarkpos.- Throws:
UnsupportedOperationException- if not supported, i.e. if stream is not aninput stream.
-
reset
Reset stream position to markpos as set viamark(int).markpos is kept, hence
reset()can be called multiple times.- Throws:
UnsupportedOperationException- if not supported, i.e. if stream is not aninput stream.IllegalStateException- if markpos has not been set viamark(int)or reset operation failed.IOException- if reset operation failed.
-
read
Reads one byte from the stream.Returns
Bitstream.EOSis end-of-stream is reached, otherwise the resulting value.- Throws:
IOExceptionUnsupportedOperationException- if not supported, i.e. if stream is not aninput stream.
-
write
Writes one byte, to the stream.Returns
Bitstream.EOSis end-of-stream is reached, otherwise the written value.- Throws:
IOExceptionUnsupportedOperationException- if not supported, i.e. if stream is not anoutput stream.
-