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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
canInput()
Return true if stream can handle input, i.e.boolean
canOutput()
Return true if stream can handle output, i.e.void
close()
Closing the underlying stream, impliesflush()
.void
flush()
Synchronizes all underlyingoutput stream
operations, or do nothing.T
getStream()
Returns the underlying streamvoid
mark(int readLimit)
Setmarkpos
to current position, allowing the stream to bereset()
.long
position()
Returns the byte position in the stream.long
position(long newPosition)
Sets this stream's position.int
read()
Reads one byte from the stream.void
reset()
Reset stream position to markpos as set viamark(int)
.void
setStream(T stream)
Sets the underlying stream, withoutclose()
ing the previous one.long
skip(long n)
It is implementation dependent, whether backward skip giving a negative number is supported or not.int
write(byte val)
Writes one byte, to the stream.
-
-
-
Method Detail
-
setStream
void setStream(T stream)
Sets the underlying stream, withoutclose()
ing the previous one.
-
getStream
T getStream()
Returns the underlying stream
-
close
void close() throws IOException
Closing the underlying stream, impliesflush()
.Implementation will
null
the stream references, hencesetStream(Object)
must be called before re-using instance.- Throws:
IOException
-
flush
void flush() throws IOException
Synchronizes all underlyingoutput stream
operations, 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
long position(long newPosition) throws UnsupportedOperationException, IllegalArgumentException
Sets this stream's position.A set mark is cleared if > new position.
Returns
Bitstream.EOS
is end-of-stream is reached, otherwise the new position.Known supporting implementation is
Bitstream.ByteBufferStream
andBitstream.ByteArrayStream
.- Parameters:
newPosition
- The new positive position.- Returns:
- The new set position or
Bitstream.EOS
if end-of-stream is reached. - Throws:
UnsupportedOperationException
- if not supported, i.e.Bitstream.ByteInputStream
orBitstream.ByteOutputStream
IllegalArgumentException
- If thenewPosition
is negative
-
skip
long skip(long n) throws IOException
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
void mark(int readLimit) throws UnsupportedOperationException
Setmarkpos
to 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
void reset() throws UnsupportedOperationException, IllegalStateException, IOException
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
int read() throws UnsupportedOperationException, IOException
Reads one byte from the stream.Returns
Bitstream.EOS
is end-of-stream is reached, otherwise the resulting value.- Throws:
IOException
UnsupportedOperationException
- if not supported, i.e. if stream is not aninput stream
.
-
write
int write(byte val) throws UnsupportedOperationException, IOException
Writes one byte, to the stream.Returns
Bitstream.EOS
is end-of-stream is reached, otherwise the written value.- Throws:
IOException
UnsupportedOperationException
- if not supported, i.e. if stream is not anoutput stream
.
-
-