KickJava   Java API By Example, From Geeks To Geeks.

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


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.components.elementprocessor.impl.poi.hssf.elements;
17
18 import org.apache.cocoon.components.elementprocessor.types.Attribute;
19 import org.apache.cocoon.components.elementprocessor.ElementProcessor;
20 import org.apache.cocoon.components.elementprocessor.types.NumericConverter;
21 import org.apache.cocoon.components.elementprocessor.types.NumericResult;
22
23 import java.io.IOException JavaDoc;
24
25 /**
26  * No-op implementation of ElementProcessor to handle the "Rows" tag
27  *
28  * This element has an attribute (DefaultSizePts) and is a container
29  * element
30  *
31  * @author Marc Johnson (marc_johnson27591@hotmail.com)
32  * @version CVS $Id: EPRows.java 30932 2004-07-29 17:35:38Z vgritsenko $
33  */

34 public class EPRows extends BaseElementProcessor {
35     private NumericResult _default_size_pts;
36     private static final String JavaDoc _default_size_pts_attribute = "DefaultSizePts";
37
38     // package scope so test code can see it
39
static final String JavaDoc DEFAULT_SIZE_PTS = "12.8";
40
41     /**
42      * constructor
43      */

44     public EPRows() {
45         super(null);
46         _default_size_pts = null;
47     }
48
49     /**
50      * get the default size of rows, in points
51      * @return size in points
52      * @exception IOException if the attribute is missing or malformed
53      */

54     public double getDefaultSizePts() throws IOException JavaDoc {
55         if (_default_size_pts == null) {
56             String JavaDoc value = getValue(_default_size_pts_attribute);
57
58             if (value == null || value.trim().equals("")) {
59                 value = DEFAULT_SIZE_PTS;
60             }
61             _default_size_pts = NumericConverter.extractDouble(value);
62         }
63         return _default_size_pts.doubleValue();
64     }
65
66     /**
67      * Override of Initialize() implementation
68      * @param attributes the array of Attribute instances; may be empty, will
69      * never be null
70      * @param parent the parent ElementProcessor; may be null
71      * @exception IOException if anything is wrong
72      */

73     public void initialize(final Attribute[] attributes,
74                     final ElementProcessor parent) throws IOException JavaDoc {
75         super.initialize(attributes, parent);
76         getSheet().setDefaultRowHeight(getDefaultSizePts());
77     }
78 } // end public class EPRows
79
Popular Tags