Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

ConduitSink Class Reference

Inheritance diagram for ConduitSink:

IConduitSink List of all members.

Public Member Functions

int writer (void[] src)

Protected Member Functions

void bind (IConduitSink next)
void unbind ()

Protected Attributes

IConduitSink next

Detailed Description

Defines an output filter base-class. The filter is invoked via its writer(void[]) method whenever a block of content is being written; the void[] array supplies writeable content. The filter should return the number of bytes it has actually consumed: less than or equal to the length of the provided array.

Filters are chained together such that the last filter added is the first one invoked. It is the responsibility of each filter to invoke the next link in the chain; for example:

class MungingOutputFilter : FilterOutput { int writer (void[] src) { char[src.length] tmp; // set everything to '*' tmp = '*'; // write the munged output return next.writer (tmp); } }

Notice how the filter invokes the 'next' instance after munging the content ... the far end of the chain is where the original IConduit writer is attached, so it will get invoked eventually assuming each filter invokes 'next'. If the next writer fails it will return IConduit.Eof, as should your filter (or throw an IOException). At the client level, filters are attached like this:

FileConduit fc = new FileConduit (...); fc.attach (new ZipOutputFilter); fc.attach (new MungingOutputFilter);

Again, the last filter attached is the first one invoked when a block of content is actually written. Each filter has two additional methods that it may use to control behavior:

class FilterOutput : IFilterOutput { protected IFilterOutput next; void bind (IFilterOutput next) { this.next = next; } void unbind () { } }

The first method is invoked when the filter is attached to a conduit, while the second is invoked just before the conduit is closed. Both of these may be overridden by the filter for whatever purpose desired.

Note that an output filter can choose to sidestep writing to the conduit (per the usual case), and direct its output to somewhere else entirely. This mechanism supports the notion of 'piping' between multiple conduits, or between a conduit and something else entirely; as with the input-filter case, this is a bridging mechanism.

Definition at line 476 of file Conduit.d.


Member Function Documentation

int writer void[]  src  ) 
 

conduit-specific writer

Reimplemented from IConduitSink.

Referenced by testConduitFilters().

void bind IConduitSink  next  )  [inline, protected]
 

Reimplemented from IConduitSink.

Definition at line 490 of file Conduit.d.

void unbind  )  [inline, protected]
 

Reimplemented from IConduitSink.

Definition at line 500 of file Conduit.d.

References IConduitSink::unbind().


Member Data Documentation

IConduitSink next [protected]
 

Definition at line 478 of file Conduit.d.


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:01 2004 for Mango by doxygen 1.3.6