Design Patterns: Elements of Reusable Object-Oriented Software by Gamma Erich & Helm Richard & Johnson Ralph & Vlissides John

Design Patterns: Elements of Reusable Object-Oriented Software by Gamma Erich & Helm Richard & Johnson Ralph & Vlissides John

Author:Gamma, Erich & Helm, Richard & Johnson, Ralph & Vlissides, John [Gamma, Erich]
Language: eng
Format: epub
Publisher: Pearson Education (USA)
Published: 1994-10-30T23:00:00+00:00


The Stream abstract class maintains an internal buffer and provides operations for storing data onto the stream (PutInt, PutString). Whenever the buffer is full, Stream calls the abstract operation HandleBufferFull, which does the actual data transfer. The FileStream version of this operation overrides this operation to transfer the buffer to a file.

The key class here is StreamDecorator, which maintains a reference to a component stream and forwards requests to it. StreamDecorator subclasses override HandleBufferFull and perform additional actions before calling StreamDecorator’s HandleBufferFull operation.

For example, the CompressingStream subclass compresses the data, and the ASCII7Stream converts the data into 7-bit ASCII. Now, to create a FileStream that compresses its data and converts the compressed binary data to 7-bit ASCII, we decorate a FileStream with a CompressingStream and an ASCII7Stream:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.