|
PageMixer API - 3.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jp.ne.dti.lares.foozy.pagemixer.mixer.Filter
Abstract implementation of consumer to "filter" token stream.
One Consumer
should not do all things
to create final HTML page image,
because of modulality, re-usability, testability, consistency and so on.
Processing should be divided in small, simple, mono-function units
like as many UNIX commands.
This class provides abstraction to "filter" of token stream.
On input side, this behaves as same as Consumer
,
and on output side, this behaves as "producer" of another
Consumer
to which this is connected by
connectTo(Consumer)
.
This mechanism makes it easy to insert additional funcionality after all.
You must concretize below method(s) to have this function.
And you should
register cleanup procedure
to clear internal status at invocation of
clear()
.
Inner Class Summary | |
static interface |
Filter.Factory
Factory interface to create " Filter ". |
Constructor Summary | |
Filter()
Construct filter. |
Method Summary | |
protected void |
addCleanup(java.lang.Runnable cleanup)
Add custom clean up procedure as Runnable . |
void |
clear()
Clear internal status to reuse itself. |
void |
connectTo(Consumer consumer)
Connect token stream "output" to specified consumer. |
abstract void |
consume(ConsumerContext context,
Token token)
Consume token with specified context. |
abstract void |
flush(ConsumerContext context)
Finalize with specified context. |
protected Consumer |
getConsumer()
Get consumer to which it is connected. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Filter()
This registers cleanup procedure
to invoke clear()
of connected one.
Method Detail |
public final void connectTo(Consumer consumer)
consumer
- this object is connected to.protected final Consumer getConsumer()
protected final void addCleanup(java.lang.Runnable cleanup)
Runnable
.
This method adds specified Runnable
instance to
cleanup procedure list,
and invokes them at invocation of own
clear()
method.
This allows you to extend cleanup procedure unless method overriding with invocation of "super.cleanup()".
For example:
public class CustomFilter extends Filter // or other derived class { // Constructor pubilc CustomFilter(){ : : Runnable cleanup = new Runnable(){ public void run(){ // custom clean up procedure } }; addCleanup(cleanup); cleanup.run(); } }
In above example,
"cleanup.run()
" is invoked
instead of clear()
,
because the later causes invocation of
all registrated cleanup procedures
but only custom class local cleanup is required in this situation
(base class cleanup procedures should be invoked
in their own constructors).
cleanup
- procedure as Runnable
.public abstract void consume(ConsumerContext context, Token token) throws MixingIOException
consume
in interface Consumer
context
- on which consuming processing dependstoken
- to be processedMixingIOException
- IOException is thrownpublic abstract void flush(ConsumerContext context) throws MixingIOException
This method indicate end of token stream, in other word, works like "consume(context, EOF)".
Implementation class should clear internal status on completion of invocation.
flush
in interface Consumer
context
- on which consuming processing depends onMixingIOException
- IOException is thrownpublic void clear()
This invokes registrated procedures(as Runnable
)
one by one.
clear
in interface Consumer
addCleanup(Runnable)
|
PageMixer API - 3.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |