CompressionStream.st
changeset 4265 cbd62f582ae7
parent 4262 a4efbb47dc1e
child 4311 55d6e8abb73b
equal deleted inserted replaced
4264:962bd694f813 4265:cbd62f582ae7
   452     self close.
   452     self close.
   453     ^ stream contents
   453     ^ stream contents
   454 !
   454 !
   455 
   455 
   456 next
   456 next
   457     "return the next element, a character or byte (textmode)
   457     "return the next element,
   458      raise an error, if there are no more elements"
   458      as character (text mode) or byte (binary mode). 
       
   459      Possibly raises ReadPastEnd error, if there are no more elements"
   459 
   460 
   460     |byte|
   461     |byte|
   461 
   462 
   462     (byte := self nextByte) isNil ifTrue:[
   463     (byte := self nextByte) isNil ifTrue:[
   463         "there is no more element; the stream is at end"
   464         "there is no more element; the stream is at end"
   522      raise an error, if there are no more elements"
   523      raise an error, if there are no more elements"
   523 
   524 
   524     mode ~~ #readonly ifTrue:[
   525     mode ~~ #readonly ifTrue:[
   525         self errorWriteOnly
   526         self errorWriteOnly
   526     ].
   527     ].
   527     self fillBuffer ifFalse:[
   528     position >= readLimit ifTrue:[
   528         "there is no more element; the stream is at end"
   529         self fillBuffer ifFalse:[
   529         ^ self pastEndRead.
   530             "there is no more element; the stream is at end"
   530     ].
   531             ^ self pastEndRead.
       
   532         ].
       
   533     ].    
   531     position := position + 1.
   534     position := position + 1.
   532     ^ outputBytes at:position.
   535     ^ outputBytes at:position.
   533 !
   536 !
   534 
   537 
   535 nextByteOrNil
   538 nextByteOrNil
   537      return nil, if there are no more elements"
   540      return nil, if there are no more elements"
   538 
   541 
   539     mode ~~ #readonly ifTrue:[
   542     mode ~~ #readonly ifTrue:[
   540         self errorWriteOnly
   543         self errorWriteOnly
   541     ].
   544     ].
   542     self fillBuffer ifFalse:[
   545     position >= readLimit ifTrue:[
   543         "there is no more element; the stream is at end"
   546         self fillBuffer ifFalse:[
   544         ^ nil.
   547             "there is no more element; the stream is at end"
       
   548             ^ nil.
       
   549         ].
   545     ].
   550     ].
   546     position := position + 1.
   551     position := position + 1.
   547     ^ outputBytes at:position.
   552     ^ outputBytes at:position.
   548 !
   553 !
   549 
   554 
   552 
   557 
   553     ^ self next:numBytes into:aByteCollection startingAt:initialIndex.
   558     ^ self next:numBytes into:aByteCollection startingAt:initialIndex.
   554 !
   559 !
   555 
   560 
   556 nextOrNil
   561 nextOrNil
   557     "return the next element, a character or byte (textmode)
   562     "return the next element, 
       
   563      as character (text mode) or byte (binary mode). 
   558      return nil, if there are no more elements"
   564      return nil, if there are no more elements"
   559 
   565 
   560     |byte|
   566     |byte|
   561 
   567 
   562     (byte := self nextByteOrNil) isNil ifTrue:[
   568     (byte := self nextByteOrNil) isNil ifTrue:[