KickJava   Java API By Example, From Geeks To Geeks.

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


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 "type" tag
27  *
28  * This element is not used in HSSFSerializer 1.0
29  *
30  * This element has no attributes, but has string content, which is
31  * numeric.
32  *
33  * @author Marc Johnson (marc_johnson27591@hotmail.com)
34  * @version CVS $Id: EP_Type.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class EP_Type extends BaseElementProcessor {
37     private NumericResult _type;
38     private static final Validator _validator = new Validator()
39     {
40         public IOException JavaDoc validate(final Number JavaDoc number) {
41             return GTKTypes.isValid(number.intValue()) ? null :
42                 new IOException JavaDoc("\"" + number + "\" is not a legal value");
43         }
44     };
45
46     /**
47      * constructor
48      */

49     public EP_Type() {
50         super(null);
51         _type = null;
52     }
53
54     /**
55      * @return the type
56      *
57      * @exception IOException if the type is not numeric
58      */

59     int getType() throws IOException JavaDoc {
60         if (_type == null) {
61             _type = NumericConverter.extractInteger(getData(), _validator);
62         }
63         return _type.intValue();
64     }
65 } // end public class EP_Type
66
Popular Tags