01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.serialization;
18:
19: import java.io.BufferedWriter;
20: import java.io.OutputStream;
21: import java.io.OutputStreamWriter;
22: import java.io.Writer;
23:
24: import org.apache.avalon.framework.CascadingRuntimeException;
25: import org.jfor.jfor.converter.Converter;
26:
27: /**
28: * This class uses the <a href="http://www.jfor.org">jfor</a> library
29: * to serialize XSL:FO documents to RTF streams.
30: *
31: * @author <a href="mailto:gianugo@rabellino.it">Gianugo Rabellino</a>
32: * @version CVS $Id: RTFSerializer.java 433543 2006-08-22 06:22:54Z crossley $
33: */
34:
35: public class RTFSerializer extends AbstractTextSerializer {
36:
37: private Writer rtfWriter;
38: private Converter handler;
39:
40: /**
41: * Set the OutputStream where the serializer will write to.
42: *
43: * @param out the OutputStream
44: */
45: public void setOutputStream(OutputStream out) {
46: try {
47: rtfWriter = new BufferedWriter(new OutputStreamWriter(out,
48: "ISO-8859-1"));
49:
50: // FIXME Find a way to work with the org.apache.avalon.framework.logger.Logger
51: handler = new Converter(rtfWriter, Converter
52: .createConverterOption(System.out));
53: super .setContentHandler(handler);
54:
55: } catch (Exception e) {
56: getLogger().error("RTFSerializer.setOutputStream()", e);
57: throw new CascadingRuntimeException(
58: "RTFSerializer.setOutputStream()", e);
59: }
60: }
61:
62: /**
63: * Recycle the serializer. GC instance variables
64: */
65: public void recycle() {
66: super.recycle();
67: this.rtfWriter = null;
68: this.handler = null;
69: }
70: }
|