org.mmbase.util.transformers
Class ChainedCharTransformer
java.lang.Object
org.mmbase.util.transformers.ReaderTransformer
org.mmbase.util.transformers.ChainedCharTransformer
- All Implemented Interfaces:
- CharTransformer, Serializable, Transformer
- public class ChainedCharTransformer
- extends ReaderTransformer
- implements CharTransformer
A CharTransformer which wraps N other CharTransformers, and links them with N - 1 new Threads,
effectively working as a 'chained' transformer.
The first transformation is done by the ChainedCharTransformer instance itself, after starting
the N - 1 Threads for the other N - 1 transformations.
If no CharTransformers are added, and 'transform' is called, logically, nothing will happen. Add
the CopyCharTransformer if necessary.
Schematicly:
new ChainedCharTransformer().add(T1).add(T2)....add(TN).transform(R, W);
___________ __________ _________
/ \/ \ / \
| R --> PW - PR --> PW -...- PR --> W |
| T1 | T2 | | TN |
\___________/ \_________/ \_________/
R: reader, PR: piped reader, W: writer, PW, piped writer, T1 - TN: transformers
- Since:
- MMBase-1.7
- Version:
- $Id: ChainedCharTransformer.java,v 1.24 2005/05/24 21:42:54 michiel Exp $
- Author:
- Michiel Meeuwissen
- See Also:
- Serialized Form
ChainedCharTransformer
public ChainedCharTransformer()
add
public ChainedCharTransformer add(CharTransformer ct)
- Adds a CharTranformer to the chain of CharTransformers. If the
CharTransformer is a ChainedCharTransformer, then it will not
be added itself, but its elements will be added.
addAll
public ChainedCharTransformer addAll(Collection col)
- Adds a Collection of CharTranformers to the chain of CharTransformers.
- Throws:
ClassCastException - if collecion does not contain only CharTransformers
transform
public String transform(String string)
- Implementation without Threads. Not needed when transforming by String.
- Specified by:
transform in interface CharTransformer- Overrides:
transform in class ReaderTransformer
transform
public Writer transform(Reader startReader,
Writer endWriter)
- Specified by:
transform in interface CharTransformer- Specified by:
transform in class ReaderTransformer
toString
public String toString()
- Specified by:
toString in interface Transformer
main
public static void main(String[] args)
throws IOException
- Throws:
IOException
MMBase build 1.8.1.20060716