KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > elementprocessor > impl > poi > hssf > elements > EPCellComment


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
18
19 import org.apache.cocoon.components.elementprocessor.types.NumericConverter;
20 import org.apache.cocoon.components.elementprocessor.types.NumericResult;
21 import org.apache.cocoon.components.elementprocessor.types.Validator;
22
23 import java.io.IOException JavaDoc;
24
25 /**
26  * No-op implementation of ElementProcessor to handle the
27  * "CellComment" tag
28  *
29  * This element has a small number of Attributes and no content.
30  *
31  * This element is not used in HSSFSerializer 1.0
32  *
33  * @author Marc Johnson (marc_johnson27591@hotmail.com)
34  * @version CVS $Id: EPCellComment.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class EPCellComment
37     extends BaseElementProcessor
38 {
39     private String JavaDoc _author;
40     private String JavaDoc _text;
41     private String JavaDoc _object_bound;
42     private Offsets _object_offset;
43     private Anchors _object_anchor_type;
44     private NumericResult _direction;
45     private static final String JavaDoc _author_attribute = "Author";
46     private static final String JavaDoc _text_attribute = "Text";
47     private static final String JavaDoc _object_bound_attribute = "ObjectBound";
48     private static final String JavaDoc _object_offset_attribute = "ObjectOffset";
49     private static final String JavaDoc _object_anchor_type_attribute =
50         "ObjectAnchorType";
51     private static final String JavaDoc _direction_attribute = "Direction";
52     private static final Validator _direction_validator = new Validator() {
53         public IOException JavaDoc validate(final Number JavaDoc number) {
54             return Direction.isValid(number.intValue()) ? null
55                 : new IOException JavaDoc("\"" + number + "\" is not a legal value");
56         }
57     };
58
59     /**
60      * constructor
61      */

62     public EPCellComment() {
63         super(null);
64         _author = null;
65         _text = null;
66         _object_bound = null;
67         _object_offset = null;
68         _object_anchor_type = null;
69         _direction = null;
70     }
71
72     /**
73      * @return author
74      *
75      * @exception IOException
76      */

77
78     public String JavaDoc getAuthor() throws IOException JavaDoc {
79         if (_author == null) {
80             _author = getValue(_author_attribute);
81             if (_author == null) {
82                 throw new IOException JavaDoc("missing " + _author_attribute
83                         + " attribute");
84             }
85         }
86         return _author;
87     }
88
89     /**
90      * @return text
91      *
92      * @exception IOException
93      */

94     public String JavaDoc getText() throws IOException JavaDoc {
95         if (_text == null) {
96             _text = getValue(_text_attribute);
97             if (_text == null) {
98                 throw new IOException JavaDoc("missing " + _text_attribute
99                                       + " attribute");
100             }
101         }
102         return _text;
103     }
104
105     /**
106      * @return object_bound
107      *
108      * @exception IOException
109      */

110     public String JavaDoc getObjectBound() throws IOException JavaDoc {
111         if (_object_bound == null) {
112             _object_bound = getValue(_object_bound_attribute);
113             if (_object_bound == null) {
114                 throw new IOException JavaDoc("missing " + _object_bound_attribute
115                                       + " attribute");
116             }
117         }
118         return _object_bound;
119     }
120
121     /**
122      * @return offsets
123      *
124      * @exception IOException
125      */

126     public Offsets getOffsets() throws IOException JavaDoc {
127         if (_object_offset == null) {
128             _object_offset = new Offsets(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 JavaDoc {
139         if (_object_anchor_type == null) {
140             _object_anchor_type =
141                 new Anchors(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 JavaDoc {
152         if (_direction == null) {
153             _direction = NumericConverter.extractInteger(
154                 getValue(_direction_attribute), _direction_validator);
155         }
156         return _direction.intValue();
157     }
158 } // end public class EPCellComment
159
Popular Tags