{OutputStream-of t:Type} (class)
public abstract shared OutputStream-of {inherits {Stream-of t}}
Package: CURL.IO.STREAM
Direct Known Subclasses: SeekableOutputStream-of, BufferedOutputStream-of, SerializeOutputStream, XMLOutputStream

Parameterized output stream.


Properties
Properties inherited from Stream-of: non-blocking-supported?, open?, origin-url
Methods
async-write:Asynchronously writes data to the stream, delivering AsyncStreamWriteEvents to the EventHandlers on errors, or on completion of the writing. If partial? is true, events are delivered whenever progress is made in writing data.
public {OutputStream-of.async-write
    data:{Array-of t},
    start:int = 0,
    n:int = data.size - start,
    max-chunk-size:int = 8192,
    partial?:bool = false,
    event-handler:EventHandler,
    ...:EventHandler
}:AsyncWorker
close:Close Stream, should make stream un-usable and make sure that Stream-of.open? return false once this has been called.
public {OutputStream-of.close}:void
flush:Flushes any buffered output that self may have collected.
public abstract {OutputStream-of.flush
    non-blocking?:bool = false,
    allow-short-write?:bool = false
}:void
write:Write an Array of items to an OutputStream-of.
public {OutputStream-of.write
    data:{Array-of t},
    start:int = 0,
    n:int = data.size - start,
    allow-short-write?:bool = false,
    non-blocking?:bool = false
}:int
write-one:Write an item to an OutputStream-of.
public abstract {OutputStream-of.write-one obj:t}:void
Methods inherited from Stream-of: verify-open
Methods inherited from Object: object-describe, object-describe-for-debugging, object-serialize

Property DetailsMethod Details
async-write (method)
public {OutputStream-of.async-write
    data:{Array-of t},
    start:int = 0,
    n:int = data.size - start,
    max-chunk-size:int = 8192,
    partial?:bool = false,
    event-handler:EventHandler,
    ...:EventHandler
}:AsyncWorker

Asynchronously writes data to the stream, delivering AsyncStreamWriteEvents to the EventHandlers on errors, or on completion of the writing. If partial? is true, events are delivered whenever progress is made in writing data.

data: The Array of objects that is to be sent.
start: Objects are written from a, starting with the slot designated by this keyword parameter. Default is 0.
n: The maximum number of objects to write, default is a.size - start.
max-chunk-size: Is the maximum amount of data to write to the stream in a single operation. But the asynchronous write will continue after that amount is written if there is more data to be written.
partial?: keyword bool that indicates if any AsyncStreamWriteEvents should be sent before n items have been written or a failure occurs.
event-handler: EventHandler that must take a AsyncStreamWriteEvent, at least one must be provided.
...: More optional EventHandlers that must take a AsyncStreamWriteEvent.
Introduced in: version 6.0


close (method)
public {OutputStream-of.close}:void

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

Notes

This calls OutputStream-of.flush before closing the stream.

Overriding

Implementors of this should call OutputStream-of.flush in a try block, with the code to close the stream in the finally part of the try block.


flush (method)
public abstract {OutputStream-of.flush
    non-blocking?:bool = false,
    allow-short-write?:bool = false
}:void

Flushes any buffered output that self may have collected.

Overriding

Must be provided by non-abstract subclasses. Implementers should probably include code like:
{if not self.open? then
    {throw {new IOException, {format "%s not open", self}}}
}
at the top of their implementations of this method.

Throws

IOException — If the data can not be written due to such problems as a full disk.


write (method)
public {OutputStream-of.write
    data:{Array-of t},
    start:int = 0,
    n:int = data.size - start,
    allow-short-write?:bool = false,
    non-blocking?:bool = false
}:int

Write an Array of items to an OutputStream-of.

data: The Array of objects that is to be sent.
start: Objects are written from a, starting with the slot designated by this keyword parameter. Default is 0.
n: The maximum number of objects to write, default is a.size - start.
allow-short-write?: can the call write less than n or the whole array worth of data? Default is false. Not supported by most streams, and will not error or exception if not supported. Use this for situations like networking.
non-blocking?: should the call be done non-blocking, i.e. should it return immediately having written no data if there is no data immediately available. Default is false. If this is true, allow-short-write? is implied to be true.

Returns

Amount of data written, always n unless allow-short-write? or non-blocking? are true, in which case it will be as much data as could be written immediately, but at least 1 if only allow-short-write? is true.


write-one (method)
public abstract {OutputStream-of.write-one obj:t}:void

Write an item to an OutputStream-of.

Notes

It is an error to call this when the stream is not open. Subclasses must implement this.

Overriding

Must be provided by non-abstract subclasses. Implementers should probably include code like:
{if not self.open? then
    {throw {new IOException, {format "%s not open", self}}}
}
at the top of their implementations of this method.