KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
13 import org.mmbase.util.ReaderInputStream;
14 import org.mmbase.util.logging.*;
15
16 /**
17  * A CharTransformer which wraps a ByteToCharTransformer.
18  *
19  * It uses the <em>UTF-8</em> bytes (on default).
20  *
21  * @author Michiel Meeuwissen
22  * @since MMBase-1.8
23  * @version $Id: ByteCharTransformer.java,v 1.2.2.1 2006/10/02 14:36:12 michiel Exp $
24  */

25
26 public class ByteCharTransformer extends ReaderTransformer implements CharTransformer {
27     private static Logger log = Logging.getLoggerInstance(ByteCharTransformer.class);
28
29     private ByteToCharTransformer byteToChars;
30     private String JavaDoc encoding = "UTF-8";
31     public ByteCharTransformer(ByteToCharTransformer b) {
32         byteToChars = b;
33     }
34     public ByteCharTransformer(ByteToCharTransformer b, String JavaDoc enc) {
35         this(b);
36         encoding = enc;
37     }
38
39     // javadoc inherited
40
public Writer transform(Reader reader, Writer writer) {
41         return byteToChars.transform(new ReaderInputStream(reader, encoding), writer);
42     }
43
44     public String JavaDoc toString() {
45         return "CHAR " + byteToChars ;
46     }
47 }
48
Popular Tags