The stream classes are ReadStream, ReadWriteStream, and WriteStream. Described in Chapter 12 of the Blue Book, streams provide an abstraction that enables store and retrieve operations to be performed on the elements of an underlying composite data structure, usually an indexed collection. In particular, a stream remembers the position of the last element in the data structure to be read or written. Streams are positionable, that is, the current read/write position can be changed using the stream's public interface. This allows elements to be accessed in either a sequential or nonsequential fashion.
It is implicit in stream semantics that the elements of the underlying data structure are sequentially ordered. With respect to the CLDT classes, a ReadWriteStream or WriteStream can stream over a String, DBString, ByteArray, or Array. A ReadStream can stream over the same set of classes plus Interval, OrderedCollection, SortedCollection, or Symbol.
The following table lists protocols supported by Stream
classes.
Table 4. Protocols supported by Stream classes
| Accessing | Copying | Enumer- ating | Position- ing | Reading | Testing | Truncating | Writing |
---|---|---|---|---|---|---|---|---|
ReadStream | X | X | X | X | X | X |
|
|
ReadWrite- Stream | X | X | X | X | X | X | X | X |
WriteStream | X |
|
| X |
| X |
| X |