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 "Label" 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: EPLabel.java 433543 2006-08-22 06:22:54Z crossley $
035: */
036: public class EPLabel 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 EPLabel() {
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: * @exception IOException
070: */
071: public String getLabel() throws IOException {
072: if (_label == null) {
073: _label = getValue(_label_attribute);
074: if (_label == null) {
075: throw new IOException("missing " + _label_attribute
076: + " attribute");
077: }
078: }
079: return _label;
080: }
081:
082: /**
083: * @return object_bound
084: * @exception IOException
085: */
086: public String getObjectBound() throws IOException {
087: if (_object_bound == null) {
088: _object_bound = getValue(_object_bound_attribute);
089: if (_object_bound == null) {
090: throw new IOException("missing "
091: + _object_bound_attribute + " attribute");
092: }
093: }
094: return _object_bound;
095: }
096:
097: /**
098: * @return offsets
099: * @exception IOException
100: */
101: public Offsets getOffsets() throws IOException {
102: if (_object_offset == null) {
103: _object_offset = new Offsets(
104: getValue(_object_offset_attribute));
105: }
106: return _object_offset;
107: }
108:
109: /**
110: * @return anchors
111: * @exception IOException
112: */
113: public Anchors getAnchors() throws IOException {
114: if (_object_anchor_type == null) {
115: _object_anchor_type = new Anchors(
116: getValue(_object_anchor_type_attribute));
117: }
118: return _object_anchor_type;
119: }
120:
121: /**
122: * @return direction as a public member of Direction
123: * @exception IOException
124: */
125: public int getDirection() throws IOException {
126: if (_direction == null) {
127: _direction = NumericConverter.extractInteger(
128: getValue(_direction_attribute),
129: _direction_validator);
130: }
131: return _direction.intValue();
132: }
133: } // end public class EPLabel
|