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 "Button" 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: EPButton.java 433543 2006-08-22 06:22:54Z crossley $
035: */
036: public class EPButton extends BaseElementProcessor {
037: private String _label;
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 _label_attribute = "Label";
043: private static final String _object_bound_attribute = "ObjectBound";
044: private static final String _object_offset_attribute = "ObjectOffset";
045: private static final String _object_anchor_type_attribute = "ObjectAnchorType";
046: private static final String _direction_attribute = "Direction";
047: private static final Validator _direction_validator = new Validator() {
048: public IOException validate(final Number number) {
049: return Direction.isValid(number.intValue()) ? null
050: : new IOException("\"" + number
051: + "\" is not a legal value");
052: }
053: };
054:
055: /**
056: * constructor
057: */
058: public EPButton() {
059: super (null);
060: _label = null;
061: _object_bound = null;
062: _object_offset = null;
063: _object_anchor_type = null;
064: _direction = null;
065: }
066:
067: /**
068: * @return label
069: *
070: * @exception IOException
071: */
072: public String getLabel() throws IOException {
073: if (_label == null) {
074: _label = getValue(_label_attribute);
075: if (_label == null) {
076: throw new IOException("missing " + _label_attribute
077: + " attribute");
078: }
079: }
080: return _label;
081: }
082:
083: /**
084: * @return object_bound
085: *
086: * @exception IOException
087: */
088: public String getObjectBound() throws IOException {
089: if (_object_bound == null) {
090: _object_bound = getValue(_object_bound_attribute);
091: if (_object_bound == null) {
092: throw new IOException("missing "
093: + _object_bound_attribute + " attribute");
094: }
095: }
096: return _object_bound;
097: }
098:
099: /**
100: * @return offsets
101: *
102: * @exception IOException
103: */
104:
105: public Offsets getOffsets() throws IOException {
106: if (_object_offset == null) {
107: _object_offset = new Offsets(
108: getValue(_object_offset_attribute));
109: }
110: return _object_offset;
111: }
112:
113: /**
114: * @return anchors
115: *
116: * @exception IOException
117: */
118: public Anchors getAnchors() throws IOException {
119: if (_object_anchor_type == null) {
120: _object_anchor_type = new Anchors(
121: getValue(_object_anchor_type_attribute));
122: }
123: return _object_anchor_type;
124: }
125:
126: /**
127: * @return direction as a public member of Direction
128: *
129: * @exception IOException
130: */
131: public int getDirection() throws IOException {
132: if (_direction == null) {
133: _direction = NumericConverter.extractInteger(
134: getValue(_direction_attribute),
135: _direction_validator);
136: }
137: return _direction.intValue();
138: }
139: } // end public class EPButton
|