From a7a43a469b667cd31d098bc41db513db9dd8dcc5 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Fri, 3 Feb 2017 10:58:13 +0200 Subject: [PATCH] Reducing use of deprecated code: using CellType enum instead of int for cell types. refs #7012 Change-Id: Ib8b8f2042e258a8ce811097112247a0c7c566ec9 --- .../poi/parser/CellDataResolverBase.java | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/org.simantics.excel.poi/src/org/simantics/excel/poi/parser/CellDataResolverBase.java b/org.simantics.excel.poi/src/org/simantics/excel/poi/parser/CellDataResolverBase.java index 5a78735..6788b82 100644 --- a/org.simantics.excel.poi/src/org/simantics/excel/poi/parser/CellDataResolverBase.java +++ b/org.simantics.excel.poi/src/org/simantics/excel/poi/parser/CellDataResolverBase.java @@ -9,20 +9,21 @@ public abstract class CellDataResolverBase implements DataResolver { protected Double getCellNumericValue(Cell cell) { if (cell == null) return null; - switch (cell.getCellType()) { - case Cell.CELL_TYPE_BLANK: + switch (cell.getCellTypeEnum()) { + case BLANK: return null; - case Cell.CELL_TYPE_BOOLEAN: + case BOOLEAN: return null; - case Cell.CELL_TYPE_ERROR: + case ERROR: return null; - case Cell.CELL_TYPE_FORMULA: + case FORMULA: return null; - case Cell.CELL_TYPE_NUMERIC: + case NUMERIC: return cell.getNumericCellValue(); - case Cell.CELL_TYPE_STRING: + case STRING: + return null; + case _NONE: return null; - } throw new RuntimeException(); } @@ -30,20 +31,21 @@ public abstract class CellDataResolverBase implements DataResolver { protected String getCellStringValue(Cell cell) { if (cell == null) return null; - switch (cell.getCellType()) { - case Cell.CELL_TYPE_BLANK: + switch (cell.getCellTypeEnum()) { + case BLANK: return null; - case Cell.CELL_TYPE_BOOLEAN: + case BOOLEAN: return Boolean.toString(cell.getBooleanCellValue()); - case Cell.CELL_TYPE_ERROR: + case ERROR: return null; - case Cell.CELL_TYPE_FORMULA: + case FORMULA: return null; - case Cell.CELL_TYPE_NUMERIC: + case NUMERIC: return Double.toString(cell.getNumericCellValue()); - case Cell.CELL_TYPE_STRING: + case STRING: return cell.getStringCellValue(); - + case _NONE: + return null; } throw new RuntimeException(); } @@ -51,24 +53,27 @@ public abstract class CellDataResolverBase implements DataResolver { protected Boolean getCellBooleanValue(Cell cell) { if (cell == null) return null; - switch (cell.getCellType()) { - case Cell.CELL_TYPE_BLANK: + switch (cell.getCellTypeEnum()) { + case BLANK: return null; - case Cell.CELL_TYPE_BOOLEAN: + case BOOLEAN: return cell.getBooleanCellValue(); - case Cell.CELL_TYPE_ERROR: + case ERROR: return null; - case Cell.CELL_TYPE_FORMULA: + case FORMULA: return null; - case Cell.CELL_TYPE_NUMERIC: + case NUMERIC: return null; - case Cell.CELL_TYPE_STRING: + case STRING: String value = cell.getStringCellValue(); if ("true".equalsIgnoreCase(value)) return true; if ("1".equalsIgnoreCase(value)) return true; - return false; + return false; + case _NONE: + return null; + } throw new RuntimeException(); } -- 2.47.1