01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
19:
20: import org.apache.poi.hssf.usermodel.HSSFCell;
21:
22: /**
23: * Cell type codes
24: *
25: * @author Marc Johnson (marc_johnson27591@hotmail.com)
26: * @version CVS $Id: CellType.java 433543 2006-08-22 06:22:54Z crossley $
27: */
28: public class CellType {
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
|