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