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.elements;
018:
019: import org.apache.cocoon.components.elementprocessor.types.NumericConverter;
020: import org.apache.cocoon.components.elementprocessor.types.NumericResult;
021: import org.apache.cocoon.components.elementprocessor.types.Validator;
022:
023: import java.io.IOException;
024:
025: /**
026: * No-op implementation of ElementProcessor to handle the
027: * "SheetObjectFilled" tag
028: *
029: * This element has a small number of Attributes and no content.
030: *
031: * This element is not used in HSSFSerializer 1.0
032: *
033: * @author Marc Johnson (marc_johnson27591@hotmail.com)
034: * @version CVS $Id: EPSheetObjectFilled.java 433543 2006-08-22 06:22:54Z crossley $
035: */
036: public class EPSheetObjectFilled extends BaseElementProcessor {
037: private String _object_bound;
038: private Offsets _object_offset;
039: private Anchors _object_anchor_type;
040: private NumericResult _direction;
041: private ColorCode _outline_color;
042: private ColorCode _fill_color;
043: private NumericResult _type;
044: private NumericResult _width;
045: private NumericResult _arrow_shape_a;
046: private NumericResult _arrow_shape_b;
047: private NumericResult _arrow_shape_c;
048: private boolean _arrow_shape_a_fetched;
049: private boolean _arrow_shape_b_fetched;
050: private boolean _arrow_shape_c_fetched;
051: private static final String _object_bound_attribute = "ObjectBound";
052: private static final String _object_offset_attribute = "ObjectOffset";
053: private static final String _object_anchor_type_attribute = "ObjectAnchorType";
054: private static final String _direction_attribute = "Direction";
055: private static final String _outline_color_attribute = "OutlineColor";
056: private static final String _fill_color_attribute = "FillColor";
057: private static final String _type_attribute = "Type";
058: private static final String _width_attribute = "Width";
059: private static final String _arrow_shape_a_attribute = "ArrowShapeA";
060: private static final String _arrow_shape_b_attribute = "ArrowShapeB";
061: private static final String _arrow_shape_c_attribute = "ArrowShapeC";
062: private static final Validator _direction_validator = new Validator() {
063: public IOException validate(final Number number) {
064: return Direction.isValid(number.intValue()) ? null
065: : new IOException("\"" + number
066: + "\" is not a legal value");
067: }
068: };
069: private static final Validator _object_fill_validator = new Validator() {
070: public IOException validate(final Number number) {
071: return ObjectFill.isValid(number.intValue()) ? null
072: : new IOException("\"" + number
073: + "\" is not a legal value");
074: }
075: };
076:
077: /**
078: * constructor
079: */
080: public EPSheetObjectFilled() {
081: super (null);
082: _object_bound = null;
083: _object_offset = null;
084: _object_anchor_type = null;
085: _direction = null;
086: _outline_color = null;
087: _fill_color = null;
088: _type = null;
089: _width = null;
090: _arrow_shape_a = null;
091: _arrow_shape_b = null;
092: _arrow_shape_c = null;
093: _arrow_shape_a_fetched = false;
094: _arrow_shape_b_fetched = false;
095: _arrow_shape_c_fetched = false;
096: }
097:
098: /**
099: * @return object_bound
100: * @exception IOException
101: */
102: public String getObjectBound() throws IOException {
103: if (_object_bound == null) {
104: _object_bound = getValue(_object_bound_attribute);
105: if (_object_bound == null) {
106: throw new IOException("missing "
107: + _object_bound_attribute + " attribute");
108: }
109: }
110: return _object_bound;
111: }
112:
113: /**
114: * @return offsets
115: * @exception IOException
116: */
117: public Offsets getOffsets() throws IOException {
118: if (_object_offset == null) {
119: _object_offset = new Offsets(
120: getValue(_object_offset_attribute));
121: }
122: return _object_offset;
123: }
124:
125: /**
126: * @return anchors
127: * @exception IOException
128: */
129: public Anchors getAnchors() throws IOException {
130: if (_object_anchor_type == null) {
131: _object_anchor_type = new Anchors(
132: getValue(_object_anchor_type_attribute));
133: }
134: return _object_anchor_type;
135: }
136:
137: /**
138: * @return direction as a public member of Direction
139: * @exception IOException
140: */
141: public int getDirection() throws IOException {
142: if (_direction == null) {
143: _direction = NumericConverter.extractInteger(
144: getValue(_direction_attribute),
145: _direction_validator);
146: }
147: return _direction.intValue();
148: }
149:
150: /**
151: * @return outline color
152: * @exception IOException
153: */
154: public ColorCode getOutlineColor() throws IOException {
155: if (_outline_color == null) {
156: _outline_color = new ColorCode(
157: getValue(_outline_color_attribute));
158: }
159: return _outline_color;
160: }
161:
162: /**
163: * @return fill color
164: * @exception IOException
165: */
166: public ColorCode getFillColor() throws IOException {
167: if (_fill_color == null) {
168: _fill_color = new ColorCode(getValue(_fill_color_attribute));
169: }
170: return _fill_color;
171: }
172:
173: /**
174: * @return type as a public member of ObjectFill
175: * @exception IOException
176: */
177: public int getType() throws IOException {
178: if (_type == null) {
179: _type = NumericConverter.extractInteger(
180: getValue(_type_attribute), _object_fill_validator);
181: }
182: return _type.intValue();
183: }
184:
185: /**
186: * @return width
187: * @exception IOException
188: */
189: public int getWidth() throws IOException {
190: if (_width == null) {
191: _width = NumericConverter
192: .extractPositiveInteger(getValue(_width_attribute));
193: }
194: return _width.intValue();
195: }
196:
197: /**
198: * @return arrow shape a
199: * @exception IOException
200: * @exception NullPointerException
201: */
202: public double getArrowShapeA() throws IOException,
203: NullPointerException {
204: if (!_arrow_shape_a_fetched) {
205: _arrow_shape_a_fetched = true;
206: String arrowShapeString = getValue(_arrow_shape_a_attribute);
207: if (arrowShapeString != null) {
208: _arrow_shape_a = NumericConverter
209: .extractDouble(arrowShapeString);
210: } else {
211: throw new NullPointerException("attribute "
212: + _arrow_shape_a_attribute + " is absent");
213: }
214: }
215: return _arrow_shape_a.doubleValue();
216: }
217:
218: /**
219: * @return arrow shape b
220: * @exception IOException, NullPointerException
221: * @exception NullPointerException
222: */
223: public double getArrowShapeB() throws IOException,
224: NullPointerException {
225: if (!_arrow_shape_b_fetched) {
226: _arrow_shape_b_fetched = true;
227: String arrowShapeString = getValue(_arrow_shape_b_attribute);
228: if (arrowShapeString != null) {
229: _arrow_shape_b = NumericConverter
230: .extractDouble(arrowShapeString);
231: } else {
232: throw new NullPointerException("attribute "
233: + _arrow_shape_b_attribute + " is absent");
234: }
235: }
236: return _arrow_shape_b.doubleValue();
237: }
238:
239: /**
240: * @return arrow shape c
241: * @exception IOException, NullPointerException
242: * @exception NullPointerException
243: */
244: public double getArrowShapeC() throws IOException,
245: NullPointerException {
246: if (!_arrow_shape_c_fetched) {
247: _arrow_shape_c_fetched = true;
248: String arrowShapeString = getValue(_arrow_shape_c_attribute);
249: if (arrowShapeString != null) {
250: _arrow_shape_c = NumericConverter
251: .extractDouble(arrowShapeString);
252: } else {
253: throw new NullPointerException("attribute "
254: + _arrow_shape_c_attribute + " is absent");
255: }
256: }
257: return _arrow_shape_c.doubleValue();
258: }
259: } // end public class EPSheetObjectFilled
|