com.feilong.lib.excel.convertor.DoubleConvertor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of feilong Show documentation
Show all versions of feilong Show documentation
feilong is a suite of core and expanded libraries that include utility classes, http, excel,cvs, io classes, and much much more.
The newest version!
package com.feilong.lib.excel.convertor;
import com.feilong.excel.ExcelException;
import com.feilong.excel.definition.ExcelCell;
public class DoubleConvertor extends AbstractDataConvertor{
@Override
protected Double handleConvert(Object value,int sheetNo,String cellIndex,ExcelCell excelCell){
if (value instanceof String){
String str = (String) value;
str = str.trim();
if (str.length() == 0){
if (excelCell.isMandatory()){
throw new ExcelException(WRONG_DATA_NULL, sheetNo, cellIndex, null, excelCell);
}
return null;
}
try{
return new Double((String) value);
}catch (NumberFormatException e){
throw new ExcelException(WRONG_DATA_TYPE_NUMBER, sheetNo, cellIndex, value, excelCell);
}
}else if (value instanceof Double){
return (Double) value;
}
throw new ExcelException(WRONG_DATA_TYPE_NUMBER, sheetNo, cellIndex, value, excelCell);
}
//---------------------------------------------------------------
@Override
public String getDataTypeAbbr(){
return "double";
}
@Override
public Class supportClass(){
return Double.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy