001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.serialization;
018:
019: import org.apache.avalon.framework.activity.Initializable;
020: import org.apache.avalon.framework.configuration.Configurable;
021: import org.apache.avalon.framework.configuration.Configuration;
022: import org.apache.avalon.framework.configuration.ConfigurationException;
023:
024: import org.apache.cocoon.components.elementprocessor.ElementProcessorFactory;
025: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.HSSFElementProcessorFactory;
026:
027: /**
028: * Serializer to produce an HSSF stream.
029: *
030: * @author Marc Johnson (marc_johnson27591@hotmail.com)
031: * @author Nicola Ken Barozzi (nicolaken@apache.org)
032: * @version $Id: HSSFSerializer.java 433543 2006-08-22 06:22:54Z crossley $
033: */
034: public class HSSFSerializer extends POIFSSerializer implements
035: Initializable, Configurable {
036:
037: private ElementProcessorFactory _element_processor_factory;
038: private final static String _mime_type = "application/vnd.ms-excel";
039: String locale;
040:
041: /**
042: * Constructor
043: */
044: public HSSFSerializer() {
045: super ();
046: }
047:
048: /**
049: * Initialialize the component. Initialization includes allocating any
050: * resources required throughout the components lifecycle.
051: *
052: * @exception Exception if an error occurs
053: */
054: public void initialize() throws Exception {
055: _element_processor_factory = new HSSFElementProcessorFactory(
056: locale);
057: setupLogger(_element_processor_factory);
058: }
059:
060: public void configure(Configuration conf)
061: throws ConfigurationException {
062: Configuration[] parameters = conf.getChildren("parameter");
063: for (int i = 0; i < parameters.length; i++) {
064: String name = parameters[i].getAttribute("name");
065: if (name.trim().equals("locale")) {
066: locale = parameters[i].getAttribute("value");
067: }
068: }
069: }
070:
071: /**
072: * get the mime type
073: *
074: * @return application/vnd.ms-excel
075: */
076: public String getMimeType() {
077: return _mime_type;
078: }
079:
080: /**
081: * get the ElementProcessorFactory
082: *
083: * @return the ElementProcessorFactory
084: */
085: protected ElementProcessorFactory getElementProcessorFactory() {
086: return _element_processor_factory;
087: }
088:
089: /**
090: * post-processing for endDocument
091: */
092: protected void doLocalPostEndDocument() {
093: }
094:
095: /**
096: * pre-processing for endDocument
097: */
098: protected void doLocalPreEndDocument() {
099: }
100: }
|