KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.avalon.framework.activity.Initializable;
19 import org.apache.avalon.framework.configuration.Configurable;
20 import org.apache.avalon.framework.configuration.Configuration;
21 import org.apache.avalon.framework.configuration.ConfigurationException;
22
23 import org.apache.cocoon.components.elementprocessor.ElementProcessorFactory;
24 import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.HSSFElementProcessorFactory;
25
26 /**
27  * Serializer to produce an HSSF stream.
28  *
29  * @author Marc Johnson (marc_johnson27591@hotmail.com)
30  * @author Nicola Ken Barozzi (nicolaken@apache.org)
31  * @version $Id: HSSFSerializer.java 209638 2005-07-07 19:20:48Z vgritsenko $
32  */

33 public class HSSFSerializer extends POIFSSerializer
34                             implements Initializable, Configurable {
35
36     private ElementProcessorFactory _element_processor_factory;
37     private final static String JavaDoc _mime_type = "application/vnd.ms-excel";
38     String JavaDoc locale;
39
40     /**
41      * Constructor
42      */

43     public HSSFSerializer() {
44         super();
45     }
46
47     /**
48      * Initialialize the component. Initialization includes allocating any
49      * resources required throughout the components lifecycle.
50      *
51      * @exception Exception if an error occurs
52      */

53     public void initialize() throws Exception JavaDoc {
54         _element_processor_factory = new HSSFElementProcessorFactory(locale);
55         setupLogger(_element_processor_factory);
56     }
57
58     public void configure(Configuration conf) throws ConfigurationException {
59         Configuration[] parameters = conf.getChildren("parameter");
60         for (int i = 0; i < parameters.length; i++) {
61             String JavaDoc name = parameters[i].getAttribute("name");
62             if (name.trim().equals("locale")) {
63                 locale = parameters[i].getAttribute("value");
64             }
65         }
66     }
67
68     /**
69      * get the mime type
70      *
71      * @return application/vnd.ms-excel
72      */

73     public String JavaDoc getMimeType() {
74         return _mime_type;
75     }
76
77     /**
78      * get the ElementProcessorFactory
79      *
80      * @return the ElementProcessorFactory
81      */

82     protected ElementProcessorFactory getElementProcessorFactory() {
83         return _element_processor_factory;
84     }
85
86     /**
87      * post-processing for endDocument
88      */

89     protected void doLocalPostEndDocument() {
90     }
91
92     /**
93      * pre-processing for endDocument
94      */

95     protected void doLocalPreEndDocument() {
96     }
97 }
98
Popular Tags