Category: Streams-Collections
Superclass: Stream
My instances represent streams where explicit positioning is permitted. Thus, my streams act in a manner to normal disk files: you can read or write sequentially, but also position the file to a particular place whenever you choose. Generally, you'll want to use ReadStream, WriteStream or ReadWriteStream instead of me to create and use streams.

Method category index

instance creation (class)
accessing-reading (instance)
class type methods (instance)
compiling (instance)
positioning (instance)
still unclassified (instance)
testing (instance)
truncating (instance)

instance creation (class)

on: aCollection
Answer an instance of the receiver streaming on the whole contents of aCollection

on: aCollection from: firstIndex to: lastIndex

Answer an instance of the receiver streaming from the firstIndex-th item of aCollection to the lastIndex-th

top


accessing-reading (instance)

close
Disassociate a stream from its backing store.

contents

Returns a collection of the same type that the stream accesses, up to and including the final element.

copyFrom: start to: end

Answer the data on which the receiver is streaming, from the start-th item to the end-th. Note that this method is 0-based, unlike the one in Collection, because a Stream's #position method returns 0-based values.

next

Answer the next item of the receiver. Returns nil when at end of stream.

nextAvailable: anInteger into: aCollection startingAt: pos

Place up to anInteger objects from the receiver into aCollection, starting from position pos in the collection and stopping if no more data is available.

nextAvailable: anInteger putAllOn: aStream

Copy up to anInteger objects from the receiver into aStream, stopping if no more data is available.

peek

Returns the next element of the stream without moving the pointer. Returns nil when at end of stream.

peekFor: anObject

Returns true and gobbles the next element from the stream of it is equal to anObject, returns false and doesn't gobble the next element if the next element is not equal to anObject.

readStream

Answer a ReadStream on the same contents as the receiver

reverseContents

Returns a collection of the same type that the stream accesses, up to and including the final element, but in reverse order.

upTo: anObject

Returns a collection of the same type that the stream accesses, up to but not including the object anObject. Returns the entire rest of the stream's contents if anObject is not present.

upToEnd

Returns a collection of the same type that the stream accesses, containing the entire rest of the stream's contents.

top


class type methods (instance)

isExternalStream
We stream on a collection residing in the image, so answer false

species

Return the type of the collections returned by #upTo: etc., which are the same kind as those returned by the collection with methods such as #select:.

top


compiling (instance)

name
Answer a string that represents what the receiver is streaming on

segmentFrom: startPos to: endPos

Answer an object that, when sent #asString, will yield the result of sending `copyFrom: startPos to: endPos' to the receiver

top


positioning (instance)

basicPosition: anInteger
Move the stream pointer to the anInteger-th object

isPositionable

Answer true if the stream supports moving backwards with #skip:.

position

Answer the current value of the stream pointer

position: anInteger

Move the stream pointer to the anInteger-th object

reset

Move the stream back to its first element. For write-only streams, the stream is truncated there.

setToEnd

Move the current position to the end of the stream.

size

Answer the size of data on which we are streaming.

skip: anInteger

Move the current position by anInteger places, either forwards or backwards.

top


still unclassified (instance)

nextPutAllOn: aStream
Write all the objects in the receiver to aStream.

top


testing (instance)

atEnd
Answer whether the objects in the stream have reached an end

basicAtEnd

Answer whether the objects in the stream have reached an end. This method must NOT be overridden.

isEmpty

Answer whether the stream has no objects

top


truncating (instance)

truncate
Truncate the receiver to the current position - only valid for writing streams

top