KickJava   Java API By Example, From Geeks To Geeks.

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


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 "Cols" 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: EPCols.java 30932 2004-07-29 17:35:38Z vgritsenko $
33  */

34 public class EPCols extends BaseElementProcessor {
35     private NumericResult _default_size_pts;
36     private boolean _default_size_pts_fetched;
37     private static final String JavaDoc _default_size_pts_attribute = "DefaultSizePts";
38
39     // package scope so test code can access
40
static final String JavaDoc DEFAULT_SIZE_PTS = "40.0";
41
42     /**
43      * constructor
44      */

45     public EPCols() {
46         super(null);
47         _default_size_pts = null;
48         _default_size_pts_fetched = false;
49     }
50
51     /**
52      * get the default size of columns, in points
53      * @return size in points
54      * @exception IOException if the attribute is malformed
55      * @exception NullPointerException if the attribute is missing
56      */

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

78     public void initialize(
79         final Attribute[] attributes,
80         final ElementProcessor parent)
81         throws IOException JavaDoc {
82         super.initialize(attributes, parent);
83         getSheet().setDefaultColumnWidth(getDefaultSizePts());
84     }
85 } // end public class EPCols
86
Popular Tags