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.*;
13: import org.mmbase.util.ReaderInputStream;
14:
15: /**
16: * A CharTransformer which wraps a ByteToCharTransformer.
17: *
18: * It uses the <em>UTF-8</em> bytes (on default).
19: *
20: * @author Michiel Meeuwissen
21: * @since MMBase-1.8
22: * @version $Id: ByteCharTransformer.java,v 1.4 2007/02/24 21:57:50 nklasens Exp $
23: */
24:
25: public class ByteCharTransformer extends ReaderTransformer implements
26: CharTransformer {
27:
28: private ByteToCharTransformer byteToChars;
29: private String encoding = "UTF-8";
30:
31: public ByteCharTransformer(ByteToCharTransformer b) {
32: byteToChars = b;
33: }
34:
35: public ByteCharTransformer(ByteToCharTransformer b, String enc) {
36: this (b);
37: encoding = enc;
38: }
39:
40: // javadoc inherited
41: public Writer transform(Reader reader, Writer writer) {
42: return byteToChars.transform(new ReaderInputStream(reader,
43: encoding), writer);
44: }
45:
46: public String toString() {
47: return "CHAR " + byteToChars;
48: }
49: }
|