KickJava   Java API By Example, From Geeks To Geeks.

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


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.poi.hssf.usermodel.HSSFCell;
20
21 /**
22  * Cell type codes
23  *
24  * @author Marc Johnson (marc_johnson27591@hotmail.com)
25  * @version CVS $Id: CellType.java 30932 2004-07-29 17:35:38Z vgritsenko $
26  */

27 public class CellType {
28
29
30     public static final int CELL_TYPE_FORMULA = -1;
31     public static final int CELL_TYPE_EMPTY = 10;
32     public static final int CELL_TYPE_BOOLEAN = 20;
33     public static final int CELL_TYPE_INTEGER = 30;
34     public static final int CELL_TYPE_FLOAT = 40;
35     public static final int CELL_TYPE_ERROR = 50;
36     public static final int CELL_TYPE_STRING = 60;
37     public static final int CELL_TYPE_CELLRANGE = 70;
38     public static final int CELL_TYPE_ARRAY = 80;
39
40     private CellType() {
41     }
42
43     /**
44      * Is this a valid cell type?
45      *
46      * @param val value to be checked
47      * @return true if valid, false otherwise
48      */

49     public static boolean isValid(final int val) {
50         switch (val) {
51             case CELL_TYPE_EMPTY :
52             case CELL_TYPE_BOOLEAN :
53             case CELL_TYPE_INTEGER :
54             case CELL_TYPE_FLOAT :
55             case CELL_TYPE_ERROR :
56             case CELL_TYPE_STRING :
57             case CELL_TYPE_FORMULA :
58             case CELL_TYPE_CELLRANGE :
59             case CELL_TYPE_ARRAY :
60                 return true;
61             default :
62                 return false;
63         }
64     }
65
66     /**
67      * Convert a CellType enum into an HSSFCell enum
68      *
69      * @param val the value to be converted
70      * @return the converted value
71      */

72     static int convertCellType(final int val) {
73         switch (val) {
74             case CELL_TYPE_INTEGER :
75             case CELL_TYPE_FLOAT :
76                 return HSSFCell.CELL_TYPE_NUMERIC;
77             case CELL_TYPE_STRING :
78                 return HSSFCell.CELL_TYPE_STRING;
79             case CELL_TYPE_FORMULA :
80                 return HSSFCell.CELL_TYPE_FORMULA;
81             default :
82                 return HSSFCell.CELL_TYPE_BLANK;
83         }
84     }
85 } // end public class CellType
86
Popular Tags