01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.util.transformers;
11:
12: import java.io.Reader;
13: import java.io.Writer;
14:
15: /**
16: * This is the character transformer which does not actually transform
17: * anything, it just copies the reader to the writer.
18: *
19: * @author Michiel Meeuwissen
20: * @since MMBase-1.7
21: * @version $Id: CopyCharTransformer.java,v 1.6 2005/05/08 13:22:05 michiel Exp $
22: */
23:
24: public class CopyCharTransformer extends ReaderTransformer implements
25: CharTransformer {
26:
27: public static final CopyCharTransformer INSTANCE = new CopyCharTransformer();
28:
29: private CopyCharTransformer() {
30: super ();
31: }
32:
33: // implementation, javadoc inherited
34: public Writer transform(Reader r, Writer w) {
35: try {
36: while (true) {
37: int c = r.read();
38: if (c == -1)
39: break;
40: w.write(c);
41: }
42: } catch (java.io.IOException e) {
43: System.out.println("c " + e.toString());
44: }
45: return w;
46: }
47:
48: // implementation, javadoc inherited
49: public Writer transformBack(Reader r, Writer w) {
50: return transform(r, w);
51: }
52:
53: // overridden for performance.
54: public String transform(String s) {
55: return s;
56: }
57:
58: // overridden for performance.
59: public String transformBack(String s) {
60: return s;
61: }
62:
63: public String toString() {
64: return "COPY";
65: }
66:
67: }
|