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:
018: package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
019:
020: import org.apache.cocoon.components.elementprocessor.types.NumericConverter;
021: import org.apache.cocoon.components.elementprocessor.types.NumericResult;
022: import org.apache.cocoon.components.elementprocessor.types.Validator;
023:
024: import java.io.IOException;
025:
026: /**
027: * No-op implementation of ElementProcessor to handle the
028: * "SheetObjectBonobo" tag
029: *
030: * This element has a small number of Attributes and no content.
031: *
032: * This element is not used in HSSFSerializer 1.0
033: *
034: * @author Marc Johnson (marc_johnson27591@hotmail.com)
035: * @version CVS $Id: EPSheetObjectBonobo.java 433543 2006-08-22 06:22:54Z crossley $
036: */
037: public class EPSheetObjectBonobo extends BaseElementProcessor {
038: private String _object_bound;
039: private Offsets _object_offset;
040: private Anchors _object_anchor_type;
041: private NumericResult _direction;
042: private static final String _object_bound_attribute = "ObjectBound";
043: private static final String _object_offset_attribute = "ObjectOffset";
044: private static final String _object_anchor_type_attribute = "ObjectAnchorType";
045: private static final String _direction_attribute = "Direction";
046: private static final Validator _direction_validator = new Validator() {
047: public IOException validate(final Number number) {
048: return Direction.isValid(number.intValue()) ? null
049: : new IOException("\"" + number
050: + "\" is not a legal value");
051: }
052: };
053:
054: /**
055: * constructor
056: */
057: public EPSheetObjectBonobo() {
058: super (null);
059: _object_bound = null;
060: _object_offset = null;
061: _object_anchor_type = null;
062: _direction = null;
063: }
064:
065: /**
066: * @return object_bound
067: * @exception IOException
068: */
069: public String getObjectBound() throws IOException {
070: if (_object_bound == null) {
071: _object_bound = getValue(_object_bound_attribute);
072: if (_object_bound == null) {
073: throw new IOException("missing "
074: + _object_bound_attribute + " attribute");
075: }
076: }
077: return _object_bound;
078: }
079:
080: /**
081: * @return offsets
082: * @exception IOException
083: */
084: public Offsets getOffsets() throws IOException {
085: if (_object_offset == null) {
086: _object_offset = new Offsets(
087: getValue(_object_offset_attribute));
088: }
089: return _object_offset;
090: }
091:
092: /**
093: * @return anchors
094: * @exception IOException
095: */
096: public Anchors getAnchors() throws IOException {
097: if (_object_anchor_type == null) {
098: _object_anchor_type = new Anchors(
099: getValue(_object_anchor_type_attribute));
100: }
101: return _object_anchor_type;
102: }
103:
104: /**
105: * @return direction as a public member of Direction
106: * @exception IOException
107: */
108: public int getDirection() throws IOException {
109: if (_direction == null) {
110: _direction = NumericConverter.extractInteger(
111: getValue(_direction_attribute),
112: _direction_validator);
113: }
114: return _direction.intValue();
115: }
116: } // end public class EPSheetObjectBonobo
|