mirror of https://github.com/apache/poi.git
Fix some IDE warnings, Javadoc, useless asserts, ...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1833293 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7e2b111f85
commit
4b8fc63558
|
@ -95,11 +95,8 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||
}
|
||||
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(excelFileName);
|
||||
try {
|
||||
try (FileInputStream fis = new FileInputStream(excelFileName)) {
|
||||
workbook = WorkbookFactory.create(fis);
|
||||
} finally {
|
||||
fis.close();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
throw new BuildException("Cannot load file " + excelFileName
|
||||
|
@ -111,11 +108,11 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||
|
||||
/**
|
||||
* Used to add a UDF to the evaluator.
|
||||
* @param name
|
||||
* @param clazzName
|
||||
* @throws ClassNotFoundException
|
||||
* @throws InstantiationException
|
||||
* @throws IllegalAccessException
|
||||
* @param name The name of the function to add
|
||||
* @param clazzName The class which implements this function
|
||||
* @throws ClassNotFoundException if the class cannot be found
|
||||
* @throws InstantiationException if the class cannot be constructed
|
||||
* @throws IllegalAccessException if the constructor or the class is not accessible
|
||||
*/
|
||||
public void addFunction(String name, String clazzName) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
Class<?> clazzInst = Class.forName(clazzName);
|
||||
|
@ -130,8 +127,8 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||
* Updates the internal HashMap of functions with instance and alias passed
|
||||
* in.
|
||||
*
|
||||
* @param name
|
||||
* @param func
|
||||
* @param name the name of the function to replace
|
||||
* @param func the function to use
|
||||
*/
|
||||
protected void addFunction(String name, FreeRefFunction func) {
|
||||
xlsMacroList.put(name, func);
|
||||
|
@ -140,7 +137,8 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||
/**
|
||||
* returns a UDFFinder that contains all of the functions added.
|
||||
*
|
||||
* @return
|
||||
* @return An instance of {@link UDFFinder} which can be used to
|
||||
* lookup functions
|
||||
*/
|
||||
protected UDFFinder getFunctions() {
|
||||
|
||||
|
@ -163,8 +161,9 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||
* Returns a formula evaluator that is loaded with the functions that
|
||||
* have been supplied.
|
||||
*
|
||||
* @param fileName
|
||||
* @return
|
||||
* @param fileName Specifies if XSSF or HSSF should be used for
|
||||
* the evaluator
|
||||
* @return A {@link FormulaEvaluator} constructed accordingly
|
||||
*/
|
||||
protected FormulaEvaluator getEvaluator(String fileName) {
|
||||
FormulaEvaluator evaluator;
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.ss.examples.formula.CalculateMortgageFunction;
|
||||
import org.apache.poi.ss.excelant.BuildFileTest;
|
||||
import org.apache.poi.ss.formula.udf.UDFFinder;
|
||||
|
@ -56,15 +55,14 @@ public class TestExcelAntWorkbookUtil extends TestCase {
|
|||
|
||||
public void testLoadNotExistingFile() {
|
||||
try {
|
||||
assertNotNull(new ExcelAntWorkbookUtilTestHelper(
|
||||
"notexistingFile" ));
|
||||
new ExcelAntWorkbookUtilTestHelper("notexistingFile");
|
||||
fail("Should catch exception here");
|
||||
} catch (BuildException e) {
|
||||
assertTrue(e.getMessage().contains("notexistingFile"));
|
||||
}
|
||||
}
|
||||
|
||||
public void testWorkbookConstructor() throws InvalidFormatException, IOException {
|
||||
public void testWorkbookConstructor() throws IOException {
|
||||
File workbookFile = new File(mortgageCalculatorFileName);
|
||||
FileInputStream fis = new FileInputStream(workbookFile);
|
||||
Workbook workbook = WorkbookFactory.create(fis);
|
||||
|
@ -300,7 +298,6 @@ public class TestExcelAntWorkbookUtil extends TestCase {
|
|||
|
||||
double value = fixture.getCellAsDouble(cell);
|
||||
|
||||
assertNotNull(value);
|
||||
assertEquals(0.0, value);
|
||||
}
|
||||
|
||||
|
@ -330,7 +327,6 @@ public class TestExcelAntWorkbookUtil extends TestCase {
|
|||
|
||||
double value = fixture.getCellAsDouble(cell);
|
||||
|
||||
assertNotNull(value);
|
||||
assertEquals(DateUtil.getExcelDate(cellValue, false), value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue