jaulib v1.1.2-115-g39e35fd
Jau Support Library (C++, Java, ..)
|
Ringbuffer-Based byte input stream with an externally provisioned data feed. More...
Public Member Functions | |
ByteInStream_Feed (final String id_name, final long timeoutMS) | |
Construct a ringbuffer backed externally provisioned byte input stream. More... | |
native void | closeStream () |
Close the stream if supported by the underlying mechanism. More... | |
void | close () |
Close the stream if supported by the underlying mechanism and dispose the native instance. More... | |
void | finalize () |
native boolean | is_open () |
Checks if the stream has an associated file. More... | |
void | clear (final IOState state) |
Clears state flags by assignment to the given value. More... | |
IOState | rdState () |
Returns the current state flags. More... | |
void | setState (final IOState state) |
Sets state flags, by keeping its previous bits. More... | |
native boolean | good () |
Checks if no error nor eof() has occurred i.e. More... | |
native boolean | eof () |
Checks if end-of-file has been reached. More... | |
native boolean | fail () |
Checks if an error has occurred. More... | |
native boolean | bad () |
Checks if a non-recoverable error has occurred. More... | |
native boolean | timeout () |
Checks if a timeout (non-recoverable) has occurred. More... | |
native boolean | available (final long n) |
Return whether n bytes are available in the input stream, if has_content_size() or using an asynchronous source. More... | |
native int | read (final byte[] out, final int offset, final int length) |
Read from the source. More... | |
int | read (final ByteBuffer out) |
Read from the source. More... | |
native int | peek (byte[] out, final int offset, final int length, final long peek_offset) |
Read from the source but do not modify the internal offset. More... | |
native String | id () |
return the id of this data source More... | |
native long | discard_next (long N) |
Discard the next N bytes of the data. More... | |
native long | tellg () |
Returns the input position indicator, similar to std::basic_istream. More... | |
native boolean | has_content_size () |
Returns true if implementation is aware of content_size(), otherwise false. More... | |
native long | content_size () |
Returns the content_size if known. More... | |
native void | interruptReader () |
Interrupt a potentially blocked reader. More... | |
boolean | write (final byte[] in, final int offset, final int length, final long timeoutMS) |
Write given bytes to the async ringbuffer using explicit given timeout. More... | |
boolean | write (final byte[] in, final int offset, final int length) |
Write given bytes to the async ringbuffer. More... | |
boolean | write (final ByteBuffer in) |
Write given bytes to the async ringbuffer. More... | |
native void | set_content_size (final long size) |
Set known content size, informal only. More... | |
native void | set_eof (final int result) |
Set end-of-data (EOS), i.e. More... | |
native String | toString () |
boolean | is_open () |
Checks if the stream has an associated file. More... | |
void | closeStream () |
Close the stream if supported by the underlying mechanism. More... | |
void | close () |
Close the stream if supported by the underlying mechanism and dispose the native instance. More... | |
boolean | available (long n) |
Return whether n bytes are available in the input stream, if has_content_size() or using an asynchronous source. More... | |
int | read (byte out[], final int offset, final int length) |
Read from the source. More... | |
int | read (ByteBuffer out) |
Read from the source. More... | |
int | peek (byte out[], final int offset, final int length, final long peek_offset) |
Read from the source but do not modify the internal offset. More... | |
String | id () |
return the id of this data source More... | |
long | discard_next (long N) |
Discard the next N bytes of the data. More... | |
long | tellg () |
Returns the input position indicator, similar to std::basic_istream. More... | |
boolean | has_content_size () |
Returns true if implementation is aware of content_size(), otherwise false. More... | |
long | content_size () |
Returns the content_size if known. More... | |
String | toString () |
void | clear (final IOState state) |
Clears state flags by assignment to the given value. More... | |
IOState | rdState () |
Returns the current state flags. More... | |
void | setState (final IOState state) |
Sets state flags, by keeping its previous bits. More... | |
boolean | good () |
Checks if no error nor eof() has occurred i.e. More... | |
boolean | eof () |
Checks if end-of-file has been reached. More... | |
boolean | fail () |
Checks if an error has occurred. More... | |
boolean | bad () |
Checks if a non-recoverable error has occurred. More... | |
boolean | timeout () |
Checks if a timeout (non-recoverable) has occurred. More... | |
Ringbuffer-Based byte input stream with an externally provisioned data feed.
Instance uses the native C++ object jau::io::ByteInStream_Feed
.
Definition at line 33 of file ByteInStream_Feed.java.
org.jau.io.ByteInStream_Feed.ByteInStream_Feed | ( | final String | id_name, |
final long | timeoutMS | ||
) |
Construct a ringbuffer backed externally provisioned byte input stream.
id_name | arbitrary identifier for this instance |
timeoutMS | maximum duration in milliseconds to wait @ check_available() and write(), zero waits infinitely |
Definition at line 42 of file ByteInStream_Feed.java.
native boolean org.jau.io.ByteInStream_Feed.available | ( | final long | n | ) |
Return whether n bytes are available in the input stream, if has_content_size() or using an asynchronous source.
If !has_content_size() and not being an asynchronous source, !end_of_data() is returned.
Method may be blocking when using an asynchronous source up until the requested bytes are available.
A subsequent call to read() shall return immediately with at least the requested numbers of bytes available, if has_content_size() or using an asynchronous source.
See details of the implementing class.
n | byte count to wait for |
Implements org.jau.io.ByteInStream.
native boolean org.jau.io.ByteInStream_Feed.bad | ( | ) |
Checks if a non-recoverable error has occurred.
Implements org.jau.io.IOStateFunc.
void org.jau.io.ByteInStream_Feed.clear | ( | final IOState | state | ) |
Clears state flags by assignment to the given value.
Implements org.jau.io.IOStateFunc.
Definition at line 77 of file ByteInStream_Feed.java.
void org.jau.io.ByteInStream_Feed.close | ( | ) |
Close the stream if supported by the underlying mechanism and dispose the native instance.
Instance is unusable after having this method called.
Close the stream if supported by the underlying mechanism and dispose the native instance.Instance is unusable after having this method called.
Implements org.jau.io.ByteInStream.
Definition at line 56 of file ByteInStream_Feed.java.
native void org.jau.io.ByteInStream_Feed.closeStream | ( | ) |
Close the stream if supported by the underlying mechanism.
Native instance will not be disposed.
Close the stream if supported by the underlying mechanism.Native instance will not be disposed.
Implements org.jau.io.ByteInStream.
native long org.jau.io.ByteInStream_Feed.content_size | ( | ) |
native long org.jau.io.ByteInStream_Feed.discard_next | ( | long | N | ) |
Discard the next N bytes of the data.
N | the number of bytes to discard |
Implements org.jau.io.ByteInStream.
native boolean org.jau.io.ByteInStream_Feed.eof | ( | ) |
Checks if end-of-file has been reached.
Implements org.jau.io.IOStateFunc.
native boolean org.jau.io.ByteInStream_Feed.fail | ( | ) |
Checks if an error has occurred.
Implements org.jau.io.IOStateFunc.
void org.jau.io.ByteInStream_Feed.finalize | ( | ) |
native boolean org.jau.io.ByteInStream_Feed.good | ( | ) |
Checks if no error nor eof() has occurred i.e.
I/O operations are available.
Implements org.jau.io.IOStateFunc.
native boolean org.jau.io.ByteInStream_Feed.has_content_size | ( | ) |
Returns true if implementation is aware of content_size(), otherwise false.
Implements org.jau.io.ByteInStream.
native String org.jau.io.ByteInStream_Feed.id | ( | ) |
return the id of this data source
Implements org.jau.io.ByteInStream.
native void org.jau.io.ByteInStream_Feed.interruptReader | ( | ) |
native boolean org.jau.io.ByteInStream_Feed.is_open | ( | ) |
Checks if the stream has an associated file.
Implements org.jau.io.ByteInStream.
native int org.jau.io.ByteInStream_Feed.peek | ( | byte[] | out, |
final int | offset, | ||
final int | length, | ||
final long | peek_offset | ||
) |
Read from the source but do not modify the internal offset.
Consecutive calls to peek() will return portions of the source starting at the same position.
out | the byte array to write the output to |
offset | offset to byte array to read into |
length | number of in bytes to read into starting at offset |
peek_offset | the offset into the stream to read at |
Implements org.jau.io.ByteInStream.
IOState org.jau.io.ByteInStream_Feed.rdState | ( | ) |
Returns the current state flags.
Method is marked virtual
to allow implementations with asynchronous resources to determine or update the current iostate.
Method is used throughout all query members and setstate(), hence they all will use the updated state from a potential override implementation.
Implements org.jau.io.IOStateFunc.
Definition at line 83 of file ByteInStream_Feed.java.
native int org.jau.io.ByteInStream_Feed.read | ( | final byte[] | out, |
final int | offset, | ||
final int | length | ||
) |
Read from the source.
Moves the internal offset so that every call to read will return a new portion of the source.
Use available() to try to wait for a certain amount of bytes available.
This method shall only block until min(available, length)
bytes are transfered.
See details of the implementing class.
out | the byte array to write the result to |
offset | offset to byte array to read into |
length | the length of the byte array out |
Implements org.jau.io.ByteInStream.
int org.jau.io.ByteInStream_Feed.read | ( | final ByteBuffer | out | ) |
Read from the source.
Moves the internal offset so that every call to read will return a new portion of the source.
Use available() to try to wait for a certain amount of bytes available.
This method shall only block until min(available, length)
bytes are transfered.
See details of the implementing class.
out | the direct ByteBuffer to write the result starting at its position up to its capacity . Limit will be set to position + read-bytes. |
limit
- position
, i.e. remaining
.Implements org.jau.io.ByteInStream.
Definition at line 116 of file ByteInStream_Feed.java.
native void org.jau.io.ByteInStream_Feed.set_content_size | ( | final long | size | ) |
Set known content size, informal only.
content_length | the content size in bytes |
native void org.jau.io.ByteInStream_Feed.set_eof | ( | final int | result | ) |
Set end-of-data (EOS), i.e.
when feeder completed provisioning bytes.
Implementation issues interruptReader() to unblock a potentially blocked reader thread.
result | should be either -1 for FAILED or 1 for SUCCESS. |
void org.jau.io.ByteInStream_Feed.setState | ( | final IOState | state | ) |
Sets state flags, by keeping its previous bits.
Implements org.jau.io.IOStateFunc.
Definition at line 89 of file ByteInStream_Feed.java.
native long org.jau.io.ByteInStream_Feed.tellg | ( | ) |
Returns the input position indicator, similar to std::basic_istream.
Implements org.jau.io.ByteInStream.
native boolean org.jau.io.ByteInStream_Feed.timeout | ( | ) |
Checks if a timeout (non-recoverable) has occurred.
Implements org.jau.io.IOStateFunc.
native String org.jau.io.ByteInStream_Feed.toString | ( | ) |
Implements org.jau.io.ByteInStream.
boolean org.jau.io.ByteInStream_Feed.write | ( | final byte[] | in, |
final int | offset, | ||
final int | length | ||
) |
Write given bytes to the async ringbuffer.
Wait up to timeout duration set in constructor until ringbuffer space is available, where fractions_i64::zero waits infinitely.
This method is blocking.
in | the byte array to transfer to the async ringbuffer |
offset | offset to in byte array to write |
length | number of in bytes to write starting at offset |
Definition at line 184 of file ByteInStream_Feed.java.
boolean org.jau.io.ByteInStream_Feed.write | ( | final byte[] | in, |
final int | offset, | ||
final int | length, | ||
final long | timeoutMS | ||
) |
Write given bytes to the async ringbuffer using explicit given timeout.
Wait up to explicit given timeout duration until ringbuffer space is available, where fractions_i64::zero waits infinitely.
This method is blocking.
n | byte count to wait for |
in | the byte array to transfer to the async ringbuffer |
length | the length of the byte array in |
timeout | explicit given timeout for async ringbuffer put operation |
Definition at line 167 of file ByteInStream_Feed.java.
boolean org.jau.io.ByteInStream_Feed.write | ( | final ByteBuffer | in | ) |
Write given bytes to the async ringbuffer.
Wait up to timeout duration set in constructor until ringbuffer space is available, where fractions_i64::zero waits infinitely.
This method is blocking.
in | the direct ByteBuffer to transfer to the async ringbuffer starting at its position up to its limit . Limit will be reset to position . |
Definition at line 200 of file ByteInStream_Feed.java.