Squeak Class Documentation category index | class index  
 
PositionableStream
  category: Collections-Streams
  superclass: Stream
  subclasses: ReadStream WriteStream

I represent an accessor for a sequence of objects (a collection) that are externally named by indices so that the point of access can be repositioned. I am abstract in that I do not implement the messages next and nextPut: which are inherited from my superclass Stream.

instance methods
  accessing
  contents
contentsOfEntireFile
last
next:
next:into:
next:into:startingAt:
next:putAll:
next:putAll:startingAt:
nextDelimited:
nextInto:
nextInto:startingAt:
nextLine
nextWordsInto:
originalContents
peek
peekFor:
upTo:
upToAll:
upToEnd

  converting
  asBinaryOrTextStream
asZLibReadStream

  data get/put
  boolean
boolean:
int16
int16:
int32
int32:
string
string:
uint16
uint16:
uint24
uint24:
uint32
uint32:

  fileIn/Out
  checkForPreamble:
command:
copyMethodChunkFrom:
copyMethodWithPreamble:from:
copyPreamble:from:
decodeStyle:version:
fileIn
fileInAnnouncing:
header
nextChunk
nextChunkText
skipSeparators
skipSeparatorsAndPeekNext
skipStyleChunk
trailer
unCommand
verbatim:

  nonhomogeneous accessing
  nextInt32
nextInt32Put:
nextLittleEndianNumber:
nextLittleEndianNumber:put:
nextNumber:
nextNumber:put:
nextString
nextStringOld
nextStringPut:
nextWord
nextWordPut:

  positioning
  match:
padTo:put:
padToNextLongPut:
position
position:
reset
resetContents
setToEnd
skip:
skipTo:

  private
  on:
positionError
setFrom:to:

  testing
  atEnd
isBinary
isEmpty

class methods
  instance creation
  on:
on:from:to:

instance methods
  accessing top  
 

contents

Answer with a copy of my collection from 1 to readLimit.


 

contentsOfEntireFile

For non-file streams


 

last

Return the final element in the receiver


 

next:

Answer the next anInteger elements of my collection. Must override
because default uses self contents species, which might involve a large
collection.


 

next:into:

Read n objects into the given collection.
Return aCollection or a partial copy if less than
n elements have been read.


 

next:into:startingAt:

Read n objects into the given collection.
Return aCollection or a partial copy if less than
n elements have been read.


 

next:putAll:

Store the next anInteger elements from the given collection.


 

next:putAll:startingAt:

Store the next anInteger elements from the given collection.


 

nextDelimited:

Answer the contents of the receiver, up to the next terminator character. Doubled terminators indicate an embedded terminator character. For example: 'this '' was a quote'. Start postioned before the initial terminator.


 

nextInto:

Read the next elements of the receiver into aCollection.
Return aCollection or a partial copy if less than aCollection
size elements have been read.


 

nextInto:startingAt:

Read the next elements of the receiver into aCollection.
Return aCollection or a partial copy if less than aCollection
size elements have been read.


 

nextLine

Answer next line (may be empty), or nil if at end


 

nextWordsInto:

Fill the word based buffer from my collection.
Stored on stream as Big Endian. Optimized for speed.
Read in BigEndian, then restoreEndianness.


 

originalContents

Answer the receiver's actual contents collection, NOT a copy. 1/29/96 sw


 

peek

Answer what would be returned if the message next were sent to the
receiver. If the receiver is at the end, answer nil.


 

peekFor:

Answer false and do not move over the next element if it is not equal to
the argument, anObject, or if the receiver is at the end. Answer true
and increment the position for accessing elements, if the next element is
equal to anObject.


 

upTo:

Answer a subcollection from the current access position to the
occurrence (if any, but not inclusive) of anObject in the receiver. If
anObject is not in the collection, answer the entire rest of the receiver.


 

upToAll:

Answer a subcollection from the current access position to the occurrence (if any, but not inclusive) of aCollection. If aCollection is not in the stream, answer the entire rest of the stream.


 

upToEnd

Answer a subcollection from the current access position through the last element of the receiver.


  converting top  
 

asBinaryOrTextStream

Convert to a stream that can switch between bytes and characters


 

asZLibReadStream


  data get/put top  
 

boolean

Answer the next boolean value from this (binary) stream.


 

boolean:

Store the given boolean value on this (binary) stream.


 

int16

Answer the next signed, 16-bit integer from this (binary) stream.


 

int16:

Store the given signed, 16-bit integer on this (binary) stream.


 

int32

Answer the next signed, 32-bit integer from this (binary) stream.


 

int32:

Store the given signed, 32-bit integer on this (binary) stream.


 

string

Answer the next string from this (binary) stream.


 

string:

Store the given string on this (binary) stream. The string must contain 65535 or fewer characters.


 

uint16

Answer the next unsigned, 16-bit integer from this (binary) stream.


 

uint16:

Store the given unsigned, 16-bit integer on this (binary) stream.


 

uint24

Answer the next unsigned, 24-bit integer from this (binary) stream.


 

uint24:

Store the given unsigned, 24-bit integer on this (binary) stream.


 

uint32

Answer the next unsigned, 32-bit integer from this (binary) stream.


 

uint32:

Store the given unsigned, 32-bit integer on this (binary) stream.


  fileIn/Out top  
 

checkForPreamble:


 

command:

Overridden by HtmlFileStream to append commands directly without translation. 4/5/96 tk


 

copyMethodChunkFrom:

Copy the next chunk from aStream (must be different from the receiver).


 

copyMethodWithPreamble:from:

First copy the preamble if any.


 

copyPreamble:from:

Look for a changeStamp for this method by peeking backward.
Write a method preamble, with that stamp if found.


 

decodeStyle:version:

Decode the runs array from the ReferenceStream it is stored in.


 

fileIn

This is special for reading expressions from text that has been formatted
with exclamation delimitors. The expressions are read and passed to the
Compiler. Answer the result of compilation.


 

fileInAnnouncing:

This is special for reading expressions from text that has been formatted
with exclamation delimitors. The expressions are read and passed to the
Compiler. Answer the result of compilation. Put up a progress report with
the given announcement as the title.


 

header

If the stream requires a standard header, override this message. See HtmlFileStream


 

nextChunk

Answer the contents of the receiver, up to the next terminator character. Doubled terminators indicate an embedded terminator character.


 

nextChunkText

Deliver the next chunk as a Text. Decode the following ]style[ chunk if present. Position at start of next real chunk.


 

skipSeparators


 

skipSeparatorsAndPeekNext

A special function to make nextChunk fast


 

skipStyleChunk

Get to the start of the next chunk that is not a style for the previous chunk


 

trailer

If the stream requires a standard trailer, override this message. See HtmlFileStream


 

unCommand

If this read stream is at a <, then skip up to just after the next >. For removing html commands.


 

verbatim:

Do not attempt to translate the characters. Use to override nextPutAll:


  nonhomogeneous accessing top  
 

nextInt32

Read a 32-bit signed integer from the next 4 bytes


 

nextInt32Put:

Write a signed integer to the next 4 bytes


 

nextLittleEndianNumber:

Answer the next n bytes as a positive Integer or LargePositiveInteger, where the bytes are ordered from least significant to most significant.


 

nextLittleEndianNumber:put:

Answer the next n bytes as a positive Integer or LargePositiveInteger, where the bytes are ordered from least significant to most significant.


 

nextNumber:

Answer the next n bytes as a positive Integer or LargePositiveInteger.


 

nextNumber:put:

Append to the receiver the argument, v, which is a positive
SmallInteger or a LargePositiveInteger, as the next n bytes.
Possibly pad with leading zeros.


 

nextString

Read a string from the receiver. The first byte is the length of the string, unless it is greater than 192, in which case the first four bytes encode the length. I expect to be in ascii mode when called (caller puts back to binary).


 

nextStringOld

Read a string from the receiver. The first byte is the length of the
string, unless it is greater than 192, in which case the first *two* bytes
encode the length. Max size 16K.


 

nextStringPut:

Append the string, s, to the receiver. Only used by DataStream. Max size of 64*256*256*256.


 

nextWord

Answer the next two bytes from the receiver as an Integer.


 

nextWordPut:

Append to the receiver an Integer as the next two bytes.


  positioning top  
 

match:

Set the access position of the receiver to be past the next occurrence of the subCollection. Answer whether subCollection is found. No wildcards, and case does matter.


 

padTo:put:

Pad using the argument, aCharacter, to the next boundary of nBytes characters.


 

padToNextLongPut:

Make position be on long word boundary, writing the padding
character, char, if necessary.


 

position

Answer the current position of accessing the sequence of objects.


 

position:

Set the current position for accessing the objects to be anInteger, as long
as anInteger is within the bounds of the receiver's contents. If it is not,
create an error notification.


 

reset

Set the receiver's position to the beginning of the sequence of objects.


 

resetContents

Set the position and limits to 0.


 

setToEnd

Set the position of the receiver to the end of the sequence of objects.


 

skip:

Set the receiver's position to be the current position+anInteger. A
subclass might choose to be more helpful and select the minimum of the
receiver's size and position+anInteger, or the maximum of 1 and
position+anInteger for the repositioning.


 

skipTo:

Set the access position of the receiver to be past the next occurrence of
anObject. Answer whether anObject is found.


  private top  
 

on:


 

positionError

Since I am not necessarily writable, it is up to my subclasses to override
position: if expanding the collection is preferrable to giving this error.


 

setFrom:to:


  testing top  
 

atEnd

Primitive. Answer whether the receiver can access any more objects.
Optional. See Object documentation whatIsAPrimitive.


 

isBinary

Return true if the receiver is a binary byte stream


 

isEmpty

Answer whether the receiver's contents has no elements.


class methods
  instance creation top  
 

on:

Answer an instance of me, streaming over the elements of aCollection.


 

on:from:to:

Answer an instance of me, streaming over the elements of aCollection
starting with the element at firstIndex and ending with the one at
lastIndex.