KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > util > transformers > InverseCharTransformer


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.util.transformers;
11
12 import java.io.Reader JavaDoc;
13 import java.io.Writer JavaDoc;
14
15 /**
16  * Turns a Transformer around. This only works if this Tranformer
17  * implements transform(Reader, Writer) and/or transformBack(Reader,
18  * Writer);
19  *
20  * @author Michiel Meeuwissen
21  * @since MMBase-1.7
22  */

23
24 public class InverseCharTransformer implements CharTransformer {
25
26     private CharTransformer ct;
27
28     /**
29      * The constructor
30      * @param c The CharTransformed to be turned around.
31      */

32
33     public InverseCharTransformer(CharTransformer c) {
34         super();
35         ct = c;
36     }
37
38     public String JavaDoc transform(String JavaDoc s) {
39         return ct.transformBack(s);
40     }
41
42     public String JavaDoc transformBack(String JavaDoc s) {
43         return ct.transform(s);
44     }
45
46     public Writer JavaDoc transform(Reader JavaDoc r) {
47         return ct.transformBack(r);
48     }
49     public Writer JavaDoc transformBack(Reader JavaDoc r) {
50         return ct.transform(r);
51     }
52
53     public Writer JavaDoc transform(Reader JavaDoc r, Writer JavaDoc w) {
54         return ct.transformBack(r, w);
55     }
56     public Writer JavaDoc transformBack(Reader JavaDoc r, Writer JavaDoc w) {
57         return ct.transform(r, w);
58     }
59
60
61     public String JavaDoc toString() {
62         return "INVERSE " + ct;
63     }
64 }
65
Popular Tags