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.components.elementprocessor.impl.poi.hssf;
018:
019: import org.apache.cocoon.components.elementprocessor.CannotCreateElementProcessorException;
020: import org.apache.cocoon.components.elementprocessor.ElementProcessor;
021: import org.apache.cocoon.components.elementprocessor.LocaleAware;
022: import org.apache.cocoon.components.elementprocessor.impl.AbstractElementProcessorFactory;
023: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPAttribute;
024: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPAttributes;
025: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPBottom;
026: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPButton;
027: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPCell;
028: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPCellComment;
029: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPCells;
030: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPCheckbox;
031: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPColInfo;
032: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPCols;
033: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPConstr;
034: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPContent;
035: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPDiagonal;
036: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPFont;
037: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPFooter;
038: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPFrame;
039: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPGeometry;
040: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPHeader;
041: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPItem;
042: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPLabel;
043: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPLeft;
044: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPMargins;
045: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPMaxCol;
046: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPMaxRow;
047: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPMerge;
048: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPMergedRegions;
049: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPName;
050: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPNames;
051: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPObjects;
052: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPPrintInformation;
053: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPRev_Diagonal;
054: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPRight;
055: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPRowInfo;
056: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPRows;
057: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSelection;
058: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSelections;
059: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSheet;
060: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSheetName;
061: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSheetNameIndex;
062: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSheetObjectBonobo;
063: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSheetObjectFilled;
064: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSheets;
065: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSolver;
066: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyle;
067: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyleBorder;
068: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyleRegion;
069: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyles;
070: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPSummary;
071: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPTop;
072: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPUIData;
073: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPWorkbook;
074: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPZoom;
075: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Bottom;
076: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Default_;
077: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Draft;
078: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_EvenIfOnlyStyles;
079: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Footer;
080: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Grid;
081: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_HCenter;
082: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Header;
083: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Left;
084: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Monochrome;
085: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Name;
086: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Order;
087: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Orientation;
088: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Paper;
089: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_RepeatLeft;
090: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_RepeatTop;
091: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Right;
092: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Titles;
093: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Top;
094: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Type;
095: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_VCenter;
096: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_ValString;
097: import org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EP_Value;
098:
099: /**
100: * a simple extension of ElementProcessorFactory that maps the HSSF
101: * XML element names to HSSF-specific ElementProcessor progenitor
102: * objects.
103: *
104: * @author Marc Johnson (marc_johnson27591@hotmail.com)
105: * @version CVS $Id: HSSFElementProcessorFactory.java 433543 2006-08-22 06:22:54Z crossley $
106: */
107: public class HSSFElementProcessorFactory extends
108: AbstractElementProcessorFactory {
109: //holds the locale configuration
110: String locale;
111:
112: /**
113: * default constructor
114: */
115:
116: public HSSFElementProcessorFactory(String locale) {
117: super ();
118: this .locale = locale;
119: addElementProcessorProgenitor("Attribute", EPAttribute.class);
120: addElementProcessorProgenitor("Attributes", EPAttributes.class);
121: addElementProcessorProgenitor("Bottom", EPBottom.class);
122: addElementProcessorProgenitor("bottom", EP_Bottom.class);
123: addElementProcessorProgenitor("Button", EPButton.class);
124: addElementProcessorProgenitor("Cell", EPCell.class);
125: addElementProcessorProgenitor("CellComment",
126: EPCellComment.class);
127: addElementProcessorProgenitor("Cells", EPCells.class);
128: addElementProcessorProgenitor("Checkbox", EPCheckbox.class);
129: addElementProcessorProgenitor("ColInfo", EPColInfo.class);
130: addElementProcessorProgenitor("Cols", EPCols.class);
131: addElementProcessorProgenitor("Constr", EPConstr.class);
132: addElementProcessorProgenitor("Content", EPContent.class);
133: addElementProcessorProgenitor("Diagonal", EPDiagonal.class);
134: addElementProcessorProgenitor("draft", EP_Draft.class);
135: addElementProcessorProgenitor("even_if_only_styles",
136: EP_EvenIfOnlyStyles.class);
137: addElementProcessorProgenitor("Font", EPFont.class);
138: addElementProcessorProgenitor("Footer", EPFooter.class);
139: addElementProcessorProgenitor("footer", EP_Footer.class);
140: addElementProcessorProgenitor("Frame", EPFrame.class);
141: addElementProcessorProgenitor("Geometry", EPGeometry.class);
142: addElementProcessorProgenitor("grid", EP_Grid.class);
143: addElementProcessorProgenitor("hcenter", EP_HCenter.class);
144: addElementProcessorProgenitor("Header", EPHeader.class);
145: addElementProcessorProgenitor("header", EP_Header.class);
146: addElementProcessorProgenitor("Item", EPItem.class);
147: addElementProcessorProgenitor("Label", EPLabel.class);
148: addElementProcessorProgenitor("Left", EPLeft.class);
149: addElementProcessorProgenitor("left", EP_Left.class);
150: addElementProcessorProgenitor("Margins", EPMargins.class);
151: addElementProcessorProgenitor("MaxCol", EPMaxCol.class);
152: addElementProcessorProgenitor("MaxRow", EPMaxRow.class);
153: addElementProcessorProgenitor("Merge", EPMerge.class);
154: addElementProcessorProgenitor("MergedRegions",
155: EPMergedRegions.class);
156: addElementProcessorProgenitor("monochrome", EP_Monochrome.class);
157: addElementProcessorProgenitor("Name", EPName.class);
158: addElementProcessorProgenitor("name", EP_Name.class);
159: addElementProcessorProgenitor("Names", EPNames.class);
160: addElementProcessorProgenitor("Objects", EPObjects.class);
161: addElementProcessorProgenitor("order", EP_Order.class);
162: addElementProcessorProgenitor("orientation",
163: EP_Orientation.class);
164: addElementProcessorProgenitor("paper", EP_Paper.class);
165: addElementProcessorProgenitor("PrintInformation",
166: EPPrintInformation.class);
167: addElementProcessorProgenitor("repeat_left",
168: EP_RepeatLeft.class);
169: addElementProcessorProgenitor("repeat_top", EP_RepeatTop.class);
170: addElementProcessorProgenitor("Rev-Diagonal",
171: EPRev_Diagonal.class);
172: addElementProcessorProgenitor("Right", EPRight.class);
173: addElementProcessorProgenitor("right", EP_Right.class);
174: addElementProcessorProgenitor("RowInfo", EPRowInfo.class);
175: addElementProcessorProgenitor("Rows", EPRows.class);
176: addElementProcessorProgenitor("Selection", EPSelection.class);
177: addElementProcessorProgenitor("Sheet", EPSheet.class);
178: addElementProcessorProgenitor("SheetName", EPSheetName.class);
179: addElementProcessorProgenitor("SheetNameIndex",
180: EPSheetNameIndex.class);
181: addElementProcessorProgenitor("SheetObjectBonobo",
182: EPSheetObjectBonobo.class);
183: addElementProcessorProgenitor("SheetObjectFilled",
184: EPSheetObjectFilled.class);
185: addElementProcessorProgenitor("Sheets", EPSheets.class);
186: addElementProcessorProgenitor("Selections", EPSelections.class);
187: addElementProcessorProgenitor("Solver", EPSolver.class);
188: addElementProcessorProgenitor("Style", EPStyle.class);
189: addElementProcessorProgenitor("StyleBorder",
190: EPStyleBorder.class);
191: addElementProcessorProgenitor("StyleRegion",
192: EPStyleRegion.class);
193: addElementProcessorProgenitor("Styles", EPStyles.class);
194: addElementProcessorProgenitor("Summary", EPSummary.class);
195: addElementProcessorProgenitor("titles", EP_Titles.class);
196: addElementProcessorProgenitor("Top", EPTop.class);
197: addElementProcessorProgenitor("top", EP_Top.class);
198: addElementProcessorProgenitor("type", EP_Type.class);
199: addElementProcessorProgenitor("UIData", EPUIData.class);
200: addElementProcessorProgenitor("val-string", EP_ValString.class);
201: addElementProcessorProgenitor("value", EP_Value.class);
202: addElementProcessorProgenitor("vcenter", EP_VCenter.class);
203: addElementProcessorProgenitor("Workbook", EPWorkbook.class);
204: addElementProcessorProgenitor("Zoom", EPZoom.class);
205: addElementProcessorProgenitor("*", EP_Default_.class);
206: }
207:
208: /**
209: * create an ElementProcessor
210: *
211: * @param progenitor the Object from which the ElementProcessor
212: * will be created
213: *
214: * @return the new ElementProcessor
215: *
216: * @exception CannotCreateElementProcessorException
217: */
218:
219: protected ElementProcessor doCreateElementProcessor(
220: final Object progenitor)
221: throws CannotCreateElementProcessorException {
222: ElementProcessor rval = null;
223:
224: try {
225: rval = createNewElementProcessorInstance((Class) progenitor);
226:
227: //every locale aware element processor is passed the locale string
228: if (rval instanceof LocaleAware) {
229: ((LocaleAware) rval).setLocale(locale);
230: }
231: } catch (ClassCastException e) {
232: e.printStackTrace();
233: throw new CannotCreateElementProcessorException(
234: "Progenitor is not an instance of Class");
235: }
236: return rval;
237: }
238: } // end public class HSSFElementProcessorFactory
|