org.mmbase.util.transformers
Class ChainedCharTransformer

java.lang.Object
  extended byorg.mmbase.util.transformers.ReaderTransformer
      extended byorg.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

Constructor Summary
ChainedCharTransformer()
           
 
Method Summary
 ChainedCharTransformer add(CharTransformer ct)
          Adds a CharTranformer to the chain of CharTransformers.
 ChainedCharTransformer addAll(Collection col)
          Adds a Collection of CharTranformers to the chain of CharTransformers.
static void main(String[] args)
           
 String toString()
           
 Writer transform(Reader startReader, Writer endWriter)
           
 String transform(String string)
          Implementation without Threads.
 
Methods inherited from class org.mmbase.util.transformers.ReaderTransformer
transform, transformBack, transformBack, transformBack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.util.transformers.CharTransformer
transform, transformBack, transformBack, transformBack
 

Constructor Detail

ChainedCharTransformer

public ChainedCharTransformer()
Method Detail

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