{DefaultBufferedInputStream-of t:Type} (class)
public DefaultBufferedInputStream-of {inherits {InputStreamBuffer-of t}}
Package: CURL.IO.STREAM
Direct Known Subclasses: DefaultTextInputStream, DefaultSeekableBufferedInputStream-of

This is a generic full implementation of a BufferedInputStream-of that takes an unbuffered InputStream-of and buffers calls to it.


Constructors
default:
constructor public {DefaultBufferedInputStream-of.default
    stream:{InputStream-of t},
    close-stream-on-close?:bool = true,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, t },
    unread-size:int = {max {min 4, buffer-size div 4}, 1}
}
Properties
fill-data-allow-short-read-supported?:Indicate if fill-data should be able to do short reads.
accessor protected DefaultBufferedInputStream-of.fill-data-allow-short-read-supported?:bool
fill-data-non-blocking-supported?:Indicate if fill-data should be able to do non-blocking.
accessor protected DefaultBufferedInputStream-of.fill-data-non-blocking-supported?:bool
open?:Indicate if this Stream is currently open, should return false once Stream-of.close has been called.
accessor public DefaultBufferedInputStream-of.open?:bool
origin-url:Returns the Url that this stream was opened from, or null, if no such Url exists.
accessor public DefaultBufferedInputStream-of.origin-url:#Url
underlying-input-stream:The InputStream-of being wrapped in buffering.
field public-get protected-set DefaultBufferedInputStream-of.underlying-input-stream:{InputStream-of t}
when-last-modified:Time of most recent modification of underlying data, if available.
accessor public DefaultBufferedInputStream-of.when-last-modified:#DateTime
Properties inherited from InputStreamBuffer-of: _buffer-valid-end, _seen-eof?, non-blocking-supported?, read-buffer-data-size, read-buffer-empty?, read-buffer-size, unread-size
Properties inherited from StreamBuffer-of: _buffer, _buffer-location, _buffer-valid-start, _seek-location
Properties inherited from PeekableInputStream-of: end-of-stream?
Methods
close:Close Stream, should make stream un-usable and make sure that Stream-of.open? return false once this has been called.
public {DefaultBufferedInputStream-of.close}:void
fill-data:Routine which buffering code will call to get more data from underlying thing.
protected {DefaultBufferedInputStream-of.fill-data
    buf:{Array-of t},
    min-read:int,
    start:int = 0,
    max-read:int = buf.size - start
}:(int, eof?:bool)
Methods inherited from InputStreamBuffer-of: async-read, clear-buffer, do-buffer-fill-data, read, read-one, resize-buffer, set-unread-size, unread-one
Methods inherited from BufferedInputStream-of: peek-one, peek-one-any, unread-one-any
Methods inherited from InputStream-of: copy-out, read-anys, read-one-any, to-Iterator
Methods inherited from Stream-of: verify-open
Methods inherited from Object: object-describe, object-describe-for-debugging, object-serialize

Constructor Details
default (constructor)
public {DefaultBufferedInputStream-of.default
    stream:{InputStream-of t},
    close-stream-on-close?:bool = true,
    buffer-size:int = {calculate-instances-per-memory-size default-buffer-memory-size, t },
    unread-size:int = {max {min 4, buffer-size div 4}, 1}
}
stream: InputStream-of to be wrapped by buffering.
close-stream-on-close?: specifies whether this class's close method should invoke close on the underlying stream.
buffer-size: Approximately how many items the main buffer should hold. Must be greater than 0.
unread-size: Approximately how many items should be able to be held for successive unread-one operations.

Notes

The amount of space available for unreading can grow dynamically, but such growth is expensive. Unread space is never used for other purposes. The main buffer will not grow.


Property Details
fill-data-allow-short-read-supported? (accessor)
accessor protected DefaultBufferedInputStream-of.fill-data-allow-short-read-supported?:bool

Indicate if fill-data should be able to do short reads.

Notes

This may be checked to decide how to call fill-data.


fill-data-non-blocking-supported? (accessor)
accessor protected DefaultBufferedInputStream-of.fill-data-non-blocking-supported?:bool

Indicate if fill-data should be able to do non-blocking.

Notes

This may be checked to decide how to call fill-data.


open? (accessor)
accessor public DefaultBufferedInputStream-of.open?:bool

Indicate if this Stream is currently open, should return false once Stream-of.close has been called.

Notes

Used by default implementations in InputStream-of and OutputStream-of to error out from many operations if stream is not open.

Overriding

Subclasses must provide this.


origin-url (accessor)
accessor public DefaultBufferedInputStream-of.origin-url:#Url

Returns the Url that this stream was opened from, or null, if no such Url exists.

Example

{read-open {url "file://c:/foo.txt"}}.origin-url would return the Url file://c:/foo.txt (assuming such a file exists).

On the other hand, {{TextInputStream-from String} "foo"}.origin-url would return null.


underlying-input-stream (field)
public-get protected-set DefaultBufferedInputStream-of.underlying-input-stream:{InputStream-of t}

The InputStream-of being wrapped in buffering.



when-last-modified (accessor)
accessor public DefaultBufferedInputStream-of.when-last-modified:#DateTime

Time of most recent modification of underlying data, if available.

Description

Returns most recent modification time of underlying data, if this is known, otherwise returns null.

For streams that originate from a http: URL, this is the time parsed from the Last-Modified HTTP header, if present.

For streams that wrap other streams (such as DefaultBufferedInputStream-of), this will typically be the value from the underlying stream.

Other streams will return null.


Method Details
close (method)
public {DefaultBufferedInputStream-of.close}:void

Close Stream, should make stream un-usable and make sure that Stream-of.open? return false once this has been called.



fill-data (method)
protected {DefaultBufferedInputStream-of.fill-data
    buf:{Array-of t},
    min-read:int,
    start:int = 0,
    max-read:int = buf.size - start
}:(int, eof?:bool)

Routine which buffering code will call to get more data from underlying thing.

buf: Array to read data into, may be the buffer or a user supplied Array.
min-read: Minimum amount that this routine must read, unless it hits the end of the data, before returning.
start: Starting place in buf to start storing the read data.
max-read: Maximum amount that this routine can read into buf before it must return. May exceed available space in buf, in which case buf should be resized for amount read.

Returns

Returns number of items read, and if it is at EOF. eof? may be true even when data was read, but this is not required, implementors may choose to only return eof? as true when there is no data.

Notes

buf should not be resized down to amount read, only up, if needed. A min-read of 0 basically implies that the caller is expecting the same semantics as if non-blocking? were true in a call to InputStream-of.read. A min-read of 1 basically implies that the caller is expecting the same semantics as if allow-short-read? were true in a call to InputStream-of.read. And generally, if min-read does not equal max-read, then the routine should not do anything expensive or slow once it has read in min-read, but it should try to read max-read data if readily possible.

Overriding

Override this in a subclass to provide the data from the data source to be buffered.