KickJava   Java API By Example, From Geeks To Geeks.

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


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  * "Checkbox" 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: EPCheckbox.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class EPCheckbox extends BaseElementProcessor {
37     private String JavaDoc _input;
38     private NumericResult _value;
39     private String JavaDoc _object_bound;
40     private Offsets _object_offset;
41     private Anchors _object_anchor_type;
42     private NumericResult _direction;
43     private static final String JavaDoc _input_attribute = "Input";
44     private static final String JavaDoc _value_attribute = "Value";
45     private static final String JavaDoc _object_bound_attribute = "ObjectBound";
46     private static final String JavaDoc _object_offset_attribute = "ObjectOffset";
47     private static final String JavaDoc _object_anchor_type_attribute =
48         "ObjectAnchorType";
49     private static final String JavaDoc _direction_attribute = "Direction";
50     private static final Validator _direction_validator = new Validator() {
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 EPCheckbox() {
61         super(null);
62         _input = null;
63         _value = null;
64         _object_bound = null;
65         _object_offset = null;
66         _object_anchor_type = null;
67         _direction = null;
68     }
69
70     /**
71      * @return input
72      * @exception IOException
73      */

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

89     public int getValue() throws IOException JavaDoc {
90         if (_value == null) {
91             _value =
92                 NumericConverter.extractInteger(getValue(_value_attribute));
93         }
94         return _value.intValue();
95     }
96
97     /**
98      * @return object_bound
99      * @exception IOException
100      */

101     public String JavaDoc getObjectBound() throws IOException JavaDoc {
102         if (_object_bound == null) {
103             _object_bound = getValue(_object_bound_attribute);
104             if (_object_bound == null) {
105                 throw new IOException JavaDoc(
106                     "missing " + _object_bound_attribute + " attribute");
107             }
108         }
109         return _object_bound;
110     }
111
112     /**
113      * @return offsets
114      * @exception IOException
115      */

116     public Offsets getOffsets() throws IOException JavaDoc {
117         if (_object_offset == null) {
118             _object_offset = new Offsets(getValue(_object_offset_attribute));
119         }
120         return _object_offset;
121     }
122
123     /**
124      * @return anchors
125      * @exception IOException
126      */

127     public Anchors getAnchors() throws IOException JavaDoc {
128         if (_object_anchor_type == null) {
129             _object_anchor_type =
130                 new Anchors(getValue(_object_anchor_type_attribute));
131         }
132         return _object_anchor_type;
133     }
134
135     /**
136      * @return direction as a public member of Direction
137      * @exception IOException
138      */

139     public int getDirection() throws IOException JavaDoc {
140         if (_direction == null) {
141             _direction =
142                 NumericConverter.extractInteger(
143                     getValue(_direction_attribute),
144                     _direction_validator);
145         }
146         return _direction.intValue();
147     }
148 } // end public class EPCheckbox
149
Popular Tags