KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > elementprocessor > impl > poi > hssf > elements > EPSheet


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
17 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
18
19 import org.apache.cocoon.components.elementprocessor.types.Attribute;
20 import org.apache.cocoon.CascadingIOException;
21 import org.apache.cocoon.components.elementprocessor.ElementProcessor;
22 import org.apache.cocoon.components.elementprocessor.types.BooleanConverter;
23 import org.apache.cocoon.components.elementprocessor.types.BooleanResult;
24
25 import java.io.IOException JavaDoc;
26
27 /**
28  * No-op implementation of ElementProcessor to handle the "Sheet" tag
29  *
30  * This element contains other elements and has the following boolean
31  * attributes:
32  * <ul>
33  * <li>DisplayFormulas
34  * <li>HideZero
35  * <li>HideGrid
36  * <li>HideColHeader
37  * <li>HideRowHeader
38  * <li>DisplayOutlines
39  * <li>OutlineSymbolsBelow
40  * <li>OutlineSymbolsRight
41  * </ul>
42  *
43  * @author Marc Johnson (marc_johnson27591@hotmail.com)
44  * @author Andrew C. Oliver (acoliver2@users.sourceforge.net)
45  * @version CVS $Id: EPSheet.java 30932 2004-07-29 17:35:38Z vgritsenko $
46  */

47 public class EPSheet extends BaseElementProcessor {
48     private Sheet _sheet;
49     private BooleanResult _display_formulas;
50     private BooleanResult _hide_zero;
51     private BooleanResult _hide_grid;
52     private BooleanResult _hide_col_header;
53     private BooleanResult _hide_row_header;
54     private BooleanResult _display_outlines;
55     private BooleanResult _outline_symbols_below;
56     private BooleanResult _outline_symbols_right;
57     private static final String JavaDoc _display_formulas_attribute = "DisplayFormulas";
58     private static final String JavaDoc _hide_zero_attribute = "HideZero";
59     private static final String JavaDoc _hide_grid_attribute = "HideGrid";
60     private static final String JavaDoc _hide_col_header_attribute = "HideColHeader";
61     private static final String JavaDoc _hide_row_header_attribute = "HideRowHeader";
62     private static final String JavaDoc _display_outlines_attribute = "DisplayOutlines";
63     private static final String JavaDoc _outline_symbols_below_attribute =
64         "OutlineSymbolsBelow";
65     private static final String JavaDoc _outline_symbols_right_attribute =
66         "OutlineSymbolsRight";
67
68     /**
69      * constructor
70      */

71
72     public EPSheet() {
73         super(null);
74         _display_formulas = null;
75         _hide_zero = null;
76         _hide_grid = null;
77         _hide_col_header = null;
78         _hide_row_header = null;
79         _display_outlines = null;
80         _outline_symbols_below = null;
81         _outline_symbols_right = null;
82     }
83
84     /**
85      * Override of Initialize() implementation
86      * @param attributes the array of Attribute instances; may be empty, will
87      * never be null
88      * @param parent the parent ElementProcessor; may be null
89      * @exception IOException if anything is wrong
90      */

91     public void initialize(final Attribute[] attributes,
92                     final ElementProcessor parent) throws IOException {
93         super.initialize(attributes, parent);
94         try {
95             _sheet = new Sheet(getWorkbook());
96         } catch (IOException e) {
97             throw e;
98         } catch (Exception JavaDoc e) {
99             throw new CascadingIOException(e.getMessage(), e);
100         }
101     }
102
103     /**
104      * override of endProcessing(). Reponsible for fixing style regions with
105      * blank cells.
106      * @exception IOException
107      */

108     public void endProcessing() throws IOException {
109         _sheet.assignBlanksToRegions();
110     }
111
112     /**
113      * override of getSheet()
114      * @return the sheet
115      */

116     protected Sheet getSheet() {
117         return _sheet;
118     }
119
120     /**
121      * @return true if formulas should be displayed
122      * @exception IOException if attribute is missing or malformed
123      */

124     public boolean getDisplayFormulas() throws IOException {
125         if (_display_formulas == null) {
126             _display_formulas = BooleanConverter.extractBoolean(
127                     getValue(_display_formulas_attribute));
128         }
129         return _display_formulas.booleanValue();
130     }
131
132     /**
133      * @return true if zeroes should be suppressed
134      * @exception IOException if attribute is missing or malformed
135      */

136     public boolean getHideZero() throws IOException {
137         if (_hide_zero == null) {
138             _hide_zero =
139                 BooleanConverter.extractBoolean(getValue(_hide_zero_attribute));
140         }
141         return _hide_zero.booleanValue();
142     }
143
144     /**
145      * @return true if grid should be hidden
146      * @exception IOException if attribute is missing or malformed
147      */

148     public boolean getHideGrid() throws IOException {
149         if (_hide_grid == null) {
150             _hide_grid =
151                 BooleanConverter.extractBoolean(getValue(_hide_grid_attribute));
152         }
153         return _hide_grid.booleanValue();
154     }
155
156     /**
157      * @return true if column headers should be hidden
158      * @exception IOException if attribute is missing or malformed
159      */

160     public boolean getHideColHeader() throws IOException {
161         if (_hide_col_header == null) {
162             _hide_col_header = BooleanConverter.extractBoolean(
163                     getValue(_hide_col_header_attribute));
164         }
165         return _hide_col_header.booleanValue();
166     }
167
168     /**
169      * @return true if row headers should be hidden
170      * @exception IOException if attribute is missing or malformed
171      */

172     public boolean getHideRowHeader() throws IOException {
173         if (_hide_row_header == null) {
174             _hide_row_header = BooleanConverter.extractBoolean(
175                     getValue(_hide_row_header_attribute));
176         }
177         return _hide_row_header.booleanValue();
178     }
179
180     /**
181      * @return true if outlines should be displayed
182      * @exception IOException if attribute is missing or malformed
183      */

184     public boolean getDisplayOutlines() throws IOException {
185         if (_display_outlines == null) {
186             _display_outlines = BooleanConverter.extractBoolean(
187                     getValue(_display_outlines_attribute));
188         }
189         return _display_outlines.booleanValue();
190     }
191
192     /**
193      * @return true if outline symbols are below
194      * @exception IOException if attribute is missing or malformed
195      */

196     public boolean getOutlineSymbolsBelow() throws IOException {
197         if (_outline_symbols_below == null) {
198             _outline_symbols_below = BooleanConverter.extractBoolean(
199                     getValue(_outline_symbols_below_attribute));
200         }
201         return _outline_symbols_below.booleanValue();
202     }
203
204     /**
205      * @return true if outline symbols are on the right
206      * @exception IOException if attribute is missing or malformed
207      */

208     public boolean getOutlineSymbolsRight() throws IOException {
209         if (_outline_symbols_right == null) {
210             _outline_symbols_right = BooleanConverter.extractBoolean(
211                     getValue(_outline_symbols_right_attribute));
212         }
213         return _outline_symbols_right.booleanValue();
214     }
215 } // end public class EPSheet
216
Popular Tags