jaulib v1.1.2-115-g39e35fd
Jau Support Library (C++, Java, ..)
Public Member Functions | List of all members
org.jau.io.ByteInStream_URL Class Reference

Ringbuffer-Based byte input stream with a URL connection provisioned data feed. More...

Inheritance diagram for org.jau.io.ByteInStream_URL:
Collaboration diagram for org.jau.io.ByteInStream_URL:

Public Member Functions

 ByteInStream_URL (final String url, final long timeoutMS)
 Construct a ringbuffer backed Http 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 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...
 

Detailed Description

Ringbuffer-Based byte input stream with a URL connection provisioned data feed.

Instance uses the native C++ object jau::io::ByteInStream_URL.

Standard implementation uses curl, hence all libcurl network protocols are supported, jau::io::uri::supported_protocols().

Definition at line 37 of file ByteInStream_URL.java.

Constructor & Destructor Documentation

◆ ByteInStream_URL()

org.jau.io.ByteInStream_URL.ByteInStream_URL ( final String  url,
final long  timeoutMS 
)

Construct a ringbuffer backed Http byte input stream.

Parameters
urlthe URL of the data to read
timeoutmaximum duration in milliseconds to wait @ check_available() for next bytes, where zero waits infinitely

Definition at line 46 of file ByteInStream_URL.java.

Member Function Documentation

◆ available()

native boolean org.jau.io.ByteInStream_URL.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.

Parameters
nbyte count to wait for
Returns
true if n bytes are available, otherwise false
See also
has_content_size()
read()
ByteInStream Properties

Implements org.jau.io.ByteInStream.

◆ bad()

native boolean org.jau.io.ByteInStream_URL.bad ( )

Checks if a non-recoverable error has occurred.

Implements org.jau.io.IOStateFunc.

◆ clear()

void org.jau.io.ByteInStream_URL.clear ( final IOState  state)

Clears state flags by assignment to the given value.

Implements org.jau.io.IOStateFunc.

Definition at line 81 of file ByteInStream_URL.java.

◆ close()

void org.jau.io.ByteInStream_URL.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 60 of file ByteInStream_URL.java.

Here is the caller graph for this function:

◆ closeStream()

native void org.jau.io.ByteInStream_URL.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.

◆ content_size()

native long org.jau.io.ByteInStream_URL.content_size ( )

Returns the content_size if known.

See also
has_content_size()

Implements org.jau.io.ByteInStream.

◆ discard_next()

native long org.jau.io.ByteInStream_URL.discard_next ( long  N)

Discard the next N bytes of the data.

Parameters
Nthe number of bytes to discard
Returns
number of bytes actually discarded

Implements org.jau.io.ByteInStream.

◆ eof()

native boolean org.jau.io.ByteInStream_URL.eof ( )

Checks if end-of-file has been reached.

Implements org.jau.io.IOStateFunc.

◆ fail()

native boolean org.jau.io.ByteInStream_URL.fail ( )

Checks if an error has occurred.

Implements org.jau.io.IOStateFunc.

◆ finalize()

void org.jau.io.ByteInStream_URL.finalize ( )

Definition at line 73 of file ByteInStream_URL.java.

Here is the call graph for this function:

◆ good()

native boolean org.jau.io.ByteInStream_URL.good ( )

Checks if no error nor eof() has occurred i.e.

I/O operations are available.

Implements org.jau.io.IOStateFunc.

◆ has_content_size()

native boolean org.jau.io.ByteInStream_URL.has_content_size ( )

Returns true if implementation is aware of content_size(), otherwise false.

See also
content_size()

Implements org.jau.io.ByteInStream.

◆ id()

native String org.jau.io.ByteInStream_URL.id ( )

return the id of this data source

Returns
std::string representing the id of this data source

Implements org.jau.io.ByteInStream.

◆ is_open()

native boolean org.jau.io.ByteInStream_URL.is_open ( )

Checks if the stream has an associated file.

Implements org.jau.io.ByteInStream.

◆ peek()

native int org.jau.io.ByteInStream_URL.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.

Parameters
outthe byte array to write the output to
offsetoffset to byte array to read into
lengthnumber of in bytes to read into starting at offset
peek_offsetthe offset into the stream to read at
Returns
length in bytes that was actually read and put into out

Implements org.jau.io.ByteInStream.

◆ rdState()

IOState org.jau.io.ByteInStream_URL.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 87 of file ByteInStream_URL.java.

◆ read() [1/2]

native int org.jau.io.ByteInStream_URL.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.

Parameters
outthe byte array to write the result to
offsetoffset to byte array to read into
lengththe length of the byte array out
Returns
length in bytes that was actually read and put into out
See also
available()
ByteInStream Properties

Implements org.jau.io.ByteInStream.

◆ read() [2/2]

int org.jau.io.ByteInStream_URL.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.

Parameters
outthe direct ByteBuffer to write the result starting at its position up to its capacity. Limit will be set to position + read-bytes.
Returns
length in bytes that was actually read and put into out, equal to its limit - position, i.e. remaining.
See also
available()
ByteInStream Properties

Implements org.jau.io.ByteInStream.

Definition at line 120 of file ByteInStream_URL.java.

Here is the call graph for this function:

◆ setState()

void org.jau.io.ByteInStream_URL.setState ( final IOState  state)

Sets state flags, by keeping its previous bits.

Implements org.jau.io.IOStateFunc.

Definition at line 93 of file ByteInStream_URL.java.

◆ tellg()

native long org.jau.io.ByteInStream_URL.tellg ( )

Returns the input position indicator, similar to std::basic_istream.

Returns
number of bytes read so far.

Implements org.jau.io.ByteInStream.

◆ timeout()

native boolean org.jau.io.ByteInStream_URL.timeout ( )

Checks if a timeout (non-recoverable) has occurred.

Implements org.jau.io.IOStateFunc.

◆ toString()

native String org.jau.io.ByteInStream_URL.toString ( )

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