textbender.g.xml.sax
Class FilterChainer

java.lang.Object
  extended by FilterChainer
Direct Known Subclasses:
FilterChainerL

public class FilterChainer
extends Object

Links together a chain of SAX filters. Serves as a temporary scaffold to construct an intermediate filter chain, prior to use. When the intermediate chain is finished, you terminate its first filter with a parent reader, and terminate its last with a content handler. Then you typically call parse() on the last filter. The chainer itself may be discarded.

Not intended for use after a chain is terminated.

Not intended to join muliple chains. Accepts only single, unlinked filters for linking.

Not thread safe.


Constructor Summary
FilterChainer()
           
 
Method Summary
 void append(XMLFilterCH newLast)
          Appends a new filter as the chain's last.
 XMLFilterCH first()
          The first filter of the chain.
 XMLFilterCH last()
          The last filter of the chain.
 void prepend(XMLFilterCH newFirst)
          Prepends a new filter as the chain's first.
 void terminateFirst(XMLReader reader)
          Convenience method to terminate the chain's first filter, with a reader.
 void terminateLast(ContentHandler contentHandler)
          Convenience method to terminate the chain's last filter, with a content handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterChainer

public FilterChainer()
Method Detail

append

public final void append(XMLFilterCH newLast)
Appends a new filter as the chain's last.

Throws:
AssertionError - if previous last filter already has a content handler
AssertionError - if newLast already has a content handler or parent reader

first

public final XMLFilterCH first()
The first filter of the chain.

Returns:
first filter; or null if no filter is yet appended/prepended

last

public final XMLFilterCH last()
The last filter of the chain.

Returns:
last filter; or null if no filter is yet appended/prepended

prepend

public final void prepend(XMLFilterCH newFirst)
Prepends a new filter as the chain's first.

Throws:
AssertionError - if previous first filter already has a parent reader
AssertionError - if newFirst already has a content handler or parent reader

terminateFirst

public void terminateFirst(XMLReader reader)
Convenience method to terminate the chain's first filter, with a reader. Afterwards, first() still points to the first filter, as before.


terminateLast

public final void terminateLast(ContentHandler contentHandler)
Convenience method to terminate the chain's last filter, with a content handler. Afterwards, last() still points to the last filter, as before.