KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > serialization > RTFSerializer


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.serialization;
17
18 import java.io.BufferedWriter JavaDoc;
19 import java.io.OutputStream JavaDoc;
20 import java.io.OutputStreamWriter JavaDoc;
21 import java.io.Writer JavaDoc;
22
23 import org.apache.avalon.framework.CascadingRuntimeException;
24 import org.jfor.jfor.converter.Converter;
25
26 /**
27  * This class uses the <a HREF="http://www.jfor.org">jfor</a> library
28  * to serialize XSL:FO documents to RTF streams.
29  *
30  * @author <a HREF="mailto:gianugo@rabellino.it">Gianugo Rabellino</a>
31  * @version CVS $Id: RTFSerializer.java 36659 2004-08-20 09:42:50Z cziegeler $
32  */

33
34 public class RTFSerializer extends AbstractTextSerializer {
35
36     private Writer JavaDoc rtfWriter;
37     private Converter handler;
38
39
40     /**
41      * Set the OutputStream where the serializer will write to.
42      *
43      * @param out the OutputStream
44      */

45     public void setOutputStream(OutputStream JavaDoc out) {
46         try {
47             rtfWriter =
48             new BufferedWriter JavaDoc(new OutputStreamWriter JavaDoc(out, "ISO-8859-1"));
49
50             // FIXME Find a way to work with the org.apache.avalon.framework.logger.Logger
51
handler = new Converter(rtfWriter,
52                Converter.createConverterOption(System.out));
53             super.setContentHandler(handler);
54
55         } catch (Exception JavaDoc e) {
56             getLogger().error("RTFSerializer.setOutputStream()", e);
57             throw new CascadingRuntimeException("RTFSerializer.setOutputStream()", e);
58         }
59     }
60
61     /**
62      * Recycle the serializer. GC instance variables
63      */

64     public void recycle() {
65         super.recycle();
66         this.rtfWriter = null;
67         this.handler = null;
68     }
69 }
70
Popular Tags