KickJava   Java API By Example, From Geeks To Geeks.

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


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.NumericConverter;
19 import org.apache.cocoon.components.elementprocessor.types.NumericResult;
20 import org.apache.cocoon.components.elementprocessor.types.Validator;
21
22 import java.io.IOException JavaDoc;
23
24 /**
25  * No-op implementation of ElementProcessor to handle the
26  * "SheetObjectFilled" tag
27  *
28  * This element has a small number of Attributes and no content.
29  *
30  * This element is not used in HSSFSerializer 1.0
31  *
32  * @author Marc Johnson (marc_johnson27591@hotmail.com)
33  * @version CVS $Id: EPSheetObjectFilled.java 30932 2004-07-29 17:35:38Z vgritsenko $
34  */

35 public class EPSheetObjectFilled extends BaseElementProcessor {
36     private String JavaDoc _object_bound;
37     private Offsets _object_offset;
38     private Anchors _object_anchor_type;
39     private NumericResult _direction;
40     private ColorCode _outline_color;
41     private ColorCode _fill_color;
42     private NumericResult _type;
43     private NumericResult _width;
44     private NumericResult _arrow_shape_a;
45     private NumericResult _arrow_shape_b;
46     private NumericResult _arrow_shape_c;
47     private boolean _arrow_shape_a_fetched;
48     private boolean _arrow_shape_b_fetched;
49     private boolean _arrow_shape_c_fetched;
50     private static final String JavaDoc _object_bound_attribute = "ObjectBound";
51     private static final String JavaDoc _object_offset_attribute = "ObjectOffset";
52     private static final String JavaDoc _object_anchor_type_attribute =
53         "ObjectAnchorType";
54     private static final String JavaDoc _direction_attribute = "Direction";
55     private static final String JavaDoc _outline_color_attribute = "OutlineColor";
56     private static final String JavaDoc _fill_color_attribute = "FillColor";
57     private static final String JavaDoc _type_attribute = "Type";
58     private static final String JavaDoc _width_attribute = "Width";
59     private static final String JavaDoc _arrow_shape_a_attribute = "ArrowShapeA";
60     private static final String JavaDoc _arrow_shape_b_attribute = "ArrowShapeB";
61     private static final String JavaDoc _arrow_shape_c_attribute = "ArrowShapeC";
62     private static final Validator _direction_validator = new Validator() {
63         public IOException JavaDoc validate(final Number JavaDoc number) {
64             return Direction.isValid(number.intValue()) ? null
65                 : new IOException JavaDoc("\"" + number + "\" is not a legal value");
66         }
67     };
68     private static final Validator _object_fill_validator = new Validator() {
69         public IOException JavaDoc validate(final Number JavaDoc number) {
70             return ObjectFill.isValid(number.intValue()) ? null
71                 : new IOException JavaDoc("\"" + number + "\" is not a legal value");
72         }
73     };
74
75     /**
76      * constructor
77      */

78     public EPSheetObjectFilled() {
79         super(null);
80         _object_bound = null;
81         _object_offset = null;
82         _object_anchor_type = null;
83         _direction = null;
84         _outline_color = null;
85         _fill_color = null;
86         _type = null;
87         _width = null;
88         _arrow_shape_a = null;
89         _arrow_shape_b = null;
90         _arrow_shape_c = null;
91         _arrow_shape_a_fetched = false;
92         _arrow_shape_b_fetched = false;
93         _arrow_shape_c_fetched = false;
94     }
95
96     /**
97      * @return object_bound
98      * @exception IOException
99      */

100     public String JavaDoc getObjectBound() throws IOException JavaDoc {
101         if (_object_bound == null) {
102             _object_bound = getValue(_object_bound_attribute);
103             if (_object_bound == null) {
104                 throw new IOException JavaDoc(
105                     "missing " + _object_bound_attribute + " attribute");
106             }
107         }
108         return _object_bound;
109     }
110
111     /**
112      * @return offsets
113      * @exception IOException
114      */

115     public Offsets getOffsets() throws IOException JavaDoc {
116         if (_object_offset == null) {
117             _object_offset = new Offsets(getValue(_object_offset_attribute));
118         }
119         return _object_offset;
120     }
121
122     /**
123      * @return anchors
124      * @exception IOException
125      */

126     public Anchors getAnchors() throws IOException JavaDoc {
127         if (_object_anchor_type == null) {
128             _object_anchor_type =
129                 new Anchors(getValue(_object_anchor_type_attribute));
130         }
131         return _object_anchor_type;
132     }
133
134     /**
135      * @return direction as a public member of Direction
136      * @exception IOException
137      */

138     public int getDirection() throws IOException JavaDoc {
139         if (_direction == null) {
140             _direction = NumericConverter.extractInteger(
141                     getValue(_direction_attribute), _direction_validator);
142         }
143         return _direction.intValue();
144     }
145
146     /**
147      * @return outline color
148      * @exception IOException
149      */

150     public ColorCode getOutlineColor() throws IOException JavaDoc {
151         if (_outline_color == null) {
152             _outline_color = new ColorCode(getValue(_outline_color_attribute));
153         }
154         return _outline_color;
155     }
156
157     /**
158      * @return fill color
159      * @exception IOException
160      */

161     public ColorCode getFillColor() throws IOException JavaDoc {
162         if (_fill_color == null) {
163             _fill_color = new ColorCode(getValue(_fill_color_attribute));
164         }
165         return _fill_color;
166     }
167
168     /**
169      * @return type as a public member of ObjectFill
170      * @exception IOException
171      */

172     public int getType() throws IOException JavaDoc {
173         if (_type == null) {
174             _type = NumericConverter.extractInteger(
175                     getValue(_type_attribute), _object_fill_validator);
176         }
177         return _type.intValue();
178     }
179
180     /**
181      * @return width
182      * @exception IOException
183      */

184     public int getWidth() throws IOException JavaDoc {
185         if (_width == null) {
186             _width = NumericConverter.extractPositiveInteger(
187                     getValue(_width_attribute));
188         }
189         return _width.intValue();
190     }
191
192     /**
193      * @return arrow shape a
194      * @exception IOException
195      * @exception NullPointerException
196      */

197     public double getArrowShapeA() throws IOException JavaDoc, NullPointerException JavaDoc {
198         if (!_arrow_shape_a_fetched) {
199             _arrow_shape_a_fetched = true;
200             String JavaDoc arrowShapeString = getValue(_arrow_shape_a_attribute);
201             if (arrowShapeString != null) {
202                 _arrow_shape_a =
203                     NumericConverter.extractDouble(arrowShapeString);
204             } else {
205                 throw new NullPointerException JavaDoc(
206                     "attribute " + _arrow_shape_a_attribute + " is absent");
207             }
208         }
209         return _arrow_shape_a.doubleValue();
210     }
211
212     /**
213      * @return arrow shape b
214      * @exception IOException, NullPointerException
215      * @exception NullPointerException
216      */

217     public double getArrowShapeB() throws IOException JavaDoc, NullPointerException JavaDoc {
218         if (!_arrow_shape_b_fetched) {
219             _arrow_shape_b_fetched = true;
220             String JavaDoc arrowShapeString = getValue(_arrow_shape_b_attribute);
221             if (arrowShapeString != null) {
222                 _arrow_shape_b =
223                     NumericConverter.extractDouble(arrowShapeString);
224             } else {
225                 throw new NullPointerException JavaDoc(
226                     "attribute " + _arrow_shape_b_attribute + " is absent");
227             }
228         }
229         return _arrow_shape_b.doubleValue();
230     }
231
232     /**
233      * @return arrow shape c
234      * @exception IOException, NullPointerException
235      * @exception NullPointerException
236      */

237     public double getArrowShapeC() throws IOException JavaDoc, NullPointerException JavaDoc {
238         if (!_arrow_shape_c_fetched) {
239             _arrow_shape_c_fetched = true;
240             String JavaDoc arrowShapeString = getValue(_arrow_shape_c_attribute);
241             if (arrowShapeString != null) {
242                 _arrow_shape_c =
243                     NumericConverter.extractDouble(arrowShapeString);
244             } else {
245                 throw new NullPointerException JavaDoc(
246                     "attribute " + _arrow_shape_c_attribute + " is absent");
247             }
248         }
249         return _arrow_shape_c.doubleValue();
250     }
251 } // end public class EPSheetObjectFilled
252
Popular Tags