jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Classes | Static Public Member Functions | List of all members
org.jau.io.ByteInStreamUtil Interface Reference

This class represents an abstract byte input stream object. More...

Collaboration diagram for org.jau.io.ByteInStreamUtil:

Classes

interface  StreamConsumer1
 Stream consumer using a byte array. More...
 
interface  StreamConsumer2
 Stream consumer using a direct ByteBuffer. More...
 

Static Public Member Functions

static long read_stream (final ByteInStream in, final byte buffer[], final StreamConsumer1 consumer)
 Synchronous byte array input stream reader using the given StreamConsumer1. More...
 
static long read_stream (final ByteInStream in, final ByteBuffer buffer, final StreamConsumer2 consumer)
 Synchronous direct ByteBuffer input stream reader using the given StreamConsumer2. More...
 
static ByteInStream to_ByteInStream (final String path_or_uri, final long timeoutMS)
 Parses the given path_or_uri, if it matches a supported protocol, see org.jau.io.UriTk#protocol_supported(String), but is not a local file, see org.jau.io.UriTk#is_local_file_protocol(String), ByteInStream_URL is being attempted. More...
 
static ByteInStream to_ByteInStream (final String path_or_uri)
 Parses the given path_or_uri, if it matches a supported protocol, see org.jau.io.UriTk#protocol_supported(String), but is not a local file, see org.jau.io.UriTk#is_local_file_protocol(String), ByteInStream_URL is being attempted. More...
 
static void print_stats (final String prefix, final long out_bytes_total, final long td_ms)
 

Detailed Description

This class represents an abstract byte input stream object.

ByteInStream Properties

The byte input stream can originate from a local source w/o delay, remote URL like http connection or even from another thread feeding the input buffer.
Both latter asynchronous resources may expose blocking properties in check_available().

Asynchronous resources benefit from knowing their content size, as their check_available() implementation may avoid blocking and waiting for requested bytes available if the stream is already beyond its scope.

One may use error() to detect whether an error has occurred, while end_of_data() not only covered the EOS case but includes error().

See also
ByteInStream Properties

Definition at line 48 of file ByteInStreamUtil.java.

Member Function Documentation

◆ print_stats()

static void org.jau.io.ByteInStreamUtil.print_stats ( final String  prefix,
final long  out_bytes_total,
final long  td_ms 
)
static

Definition at line 195 of file ByteInStreamUtil.java.

Here is the call graph for this function:

◆ read_stream() [1/2]

static long org.jau.io.ByteInStreamUtil.read_stream ( final ByteInStream  in,
final byte  buffer[],
final StreamConsumer1  consumer 
)
static

Synchronous byte array input stream reader using the given StreamConsumer1.

To abort streaming, user may return false from the given StreamConsumer1#consume(byte[], long, boolean).

Parameters
inthe input byte stream to read from
bufferbyte buffer passed down to StreamConsumer1#consume(byte[], long, boolean)
consumerStreamConsumer consumer for each received heap of bytes, returning true to continue stream of false to abort.
Returns
total bytes read or 0 if error

Definition at line 73 of file ByteInStreamUtil.java.

Here is the call graph for this function:

◆ read_stream() [2/2]

static long org.jau.io.ByteInStreamUtil.read_stream ( final ByteInStream  in,
final ByteBuffer  buffer,
final StreamConsumer2  consumer 
)
static

Synchronous direct ByteBuffer input stream reader using the given StreamConsumer2.

To abort streaming, user may return false from the given StreamConsumer2#consume(ByteBuffer, boolean).

Parameters
inthe input byte stream to read from
bufferbyte buffer passed down to StreamConsumer2#consume(ByteBuffer, boolean)
consumerStreamConsumer2 consumer for each received heap of bytes, returning true to continue stream of false to abort.
Returns
total bytes read or 0 if error

Definition at line 124 of file ByteInStreamUtil.java.

Here is the call graph for this function:

◆ to_ByteInStream() [1/2]

static ByteInStream org.jau.io.ByteInStreamUtil.to_ByteInStream ( final String  path_or_uri)
static

Parses the given path_or_uri, if it matches a supported protocol, see org.jau.io.UriTk#protocol_supported(String), but is not a local file, see org.jau.io.UriTk#is_local_file_protocol(String), ByteInStream_URL is being attempted.

If the above fails, ByteInStream_File is attempted.

If non of the above leads to a ByteInStream without ByteInStreamUtil#error(), null is returned.

Method uses a timeout of 20_s for maximum duration to wait for next bytes at ByteInStream_URL#available(long)

Parameters
path_or_urigiven path or uri for with a ByteInStream instance shall be established.
Returns
a working ByteInStream w/o ByteInStreamUtil#error() or nullptr

Definition at line 191 of file ByteInStreamUtil.java.

Here is the call graph for this function:

◆ to_ByteInStream() [2/2]

static ByteInStream org.jau.io.ByteInStreamUtil.to_ByteInStream ( final String  path_or_uri,
final long  timeoutMS 
)
static

Parses the given path_or_uri, if it matches a supported protocol, see org.jau.io.UriTk#protocol_supported(String), but is not a local file, see org.jau.io.UriTk#is_local_file_protocol(String), ByteInStream_URL is being attempted.

If the above fails, ByteInStream_File is attempted.

If non of the above leads to a ByteInStream without ByteInStreamUtil#error(), null is returned.

Parameters
path_or_urigiven path or uri for with a ByteInStream instance shall be established.
timeoutMSa timeout in case ByteInStream_URL is being used as maximum duration in milliseconds to wait for next bytes at ByteInStream_URL#available(long), defaults to 20_s
Returns
a working ByteInStream w/o ByteInStreamUtil#error() or nullptr

Definition at line 163 of file ByteInStreamUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this interface was generated from the following file: