KickJava   Java API By Example, From Geeks To Geeks.

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


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 "Button" tag
27  *
28  * This element has a small number of Attributes and no content.
29  *
30  * This element is not used in HSSFSerializer 1.0
31  *
32  * @author Marc Johnson (marc_johnson27591@hotmail.com)
33  * @version CVS $Id: EPButton.java 30932 2004-07-29 17:35:38Z vgritsenko $
34  */

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

60     public EPButton() {
61         super(null);
62         _label = null;
63         _object_bound = null;
64         _object_offset = null;
65         _object_anchor_type = null;
66         _direction = null;
67     }
68
69     /**
70      * @return label
71      *
72      * @exception IOException
73      */

74     public String JavaDoc getLabel() throws IOException JavaDoc {
75         if (_label == null) {
76             _label = getValue(_label_attribute);
77             if (_label == null) {
78                 throw new IOException JavaDoc("missing " + _label_attribute
79                         + " attribute");
80             }
81         }
82         return _label;
83     }
84
85     /**
86      * @return object_bound
87      *
88      * @exception IOException
89      */

90     public String JavaDoc getObjectBound() throws IOException JavaDoc {
91         if (_object_bound == null) {
92             _object_bound = getValue(_object_bound_attribute);
93             if (_object_bound == null) {
94                 throw new IOException JavaDoc("missing " + _object_bound_attribute
95                                       + " attribute");
96             }
97         }
98         return _object_bound;
99     }
100
101     /**
102      * @return offsets
103      *
104      * @exception IOException
105      */

106
107     public Offsets getOffsets() throws IOException JavaDoc {
108         if (_object_offset == null) {
109             _object_offset = new Offsets(getValue(_object_offset_attribute));
110         }
111         return _object_offset;
112     }
113
114     /**
115      * @return anchors
116      *
117      * @exception IOException
118      */

119     public Anchors getAnchors() throws IOException JavaDoc {
120         if (_object_anchor_type == null) {
121             _object_anchor_type =
122                 new Anchors(getValue(_object_anchor_type_attribute));
123         }
124         return _object_anchor_type;
125     }
126
127     /**
128      * @return direction as a public member of Direction
129      *
130      * @exception IOException
131      */

132     public int getDirection() throws IOException JavaDoc {
133         if (_direction == null) {
134             _direction = NumericConverter.extractInteger(
135                 getValue(_direction_attribute), _direction_validator);
136         }
137         return _direction.intValue();
138     }
139 } // end public class EPButton
140
Popular Tags