Fix some Eclipse warnings and adjust use of Generics, Comments, close()
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691308 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c54cc66158
commit
0c410544a9
@ -50,5 +50,7 @@ public class CreateCells {
|
|||||||
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
|
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
|
||||||
wb.write(fileOut);
|
wb.write(fileOut);
|
||||||
fileOut.close();
|
fileOut.close();
|
||||||
|
|
||||||
|
wb.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,25 +168,29 @@ public class BigGridDemo {
|
|||||||
private static void substitute(File zipfile, File tmpfile, String entry, OutputStream out) throws IOException {
|
private static void substitute(File zipfile, File tmpfile, String entry, OutputStream out) throws IOException {
|
||||||
ZipFile zip = ZipHelper.openZipFile(zipfile);
|
ZipFile zip = ZipHelper.openZipFile(zipfile);
|
||||||
|
|
||||||
ZipOutputStream zos = new ZipOutputStream(out);
|
try {
|
||||||
|
ZipOutputStream zos = new ZipOutputStream(out);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
|
Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
|
||||||
while (en.hasMoreElements()) {
|
while (en.hasMoreElements()) {
|
||||||
ZipEntry ze = en.nextElement();
|
ZipEntry ze = en.nextElement();
|
||||||
if(!ze.getName().equals(entry)){
|
if(!ze.getName().equals(entry)){
|
||||||
zos.putNextEntry(new ZipEntry(ze.getName()));
|
zos.putNextEntry(new ZipEntry(ze.getName()));
|
||||||
InputStream is = zip.getInputStream(ze);
|
InputStream is = zip.getInputStream(ze);
|
||||||
copyStream(is, zos);
|
copyStream(is, zos);
|
||||||
is.close();
|
is.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
zos.putNextEntry(new ZipEntry(entry));
|
||||||
zos.putNextEntry(new ZipEntry(entry));
|
InputStream is = new FileInputStream(tmpfile);
|
||||||
InputStream is = new FileInputStream(tmpfile);
|
copyStream(is, zos);
|
||||||
copyStream(is, zos);
|
is.close();
|
||||||
is.close();
|
|
||||||
|
|
||||||
zos.close();
|
zos.close();
|
||||||
|
} finally {
|
||||||
|
zip.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyStream(InputStream in, OutputStream out) throws IOException {
|
private static void copyStream(InputStream in, OutputStream out) throws IOException {
|
||||||
|
@ -285,7 +285,7 @@ public class Section
|
|||||||
/*
|
/*
|
||||||
* Extract the dictionary (if available).
|
* Extract the dictionary (if available).
|
||||||
*/
|
*/
|
||||||
dictionary = (Map) getProperty(0);
|
dictionary = (Map<Long,String>) getProperty(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public final class OperandResolver {
|
|||||||
*/
|
*/
|
||||||
public static ValueEval getSingleValue(ValueEval arg, int srcCellRow, int srcCellCol)
|
public static ValueEval getSingleValue(ValueEval arg, int srcCellRow, int srcCellCol)
|
||||||
throws EvaluationException {
|
throws EvaluationException {
|
||||||
ValueEval result;
|
final ValueEval result;
|
||||||
if (arg instanceof RefEval) {
|
if (arg instanceof RefEval) {
|
||||||
result = chooseSingleElementFromRef((RefEval) arg);
|
result = chooseSingleElementFromRef((RefEval) arg);
|
||||||
} else if (arg instanceof AreaEval) {
|
} else if (arg instanceof AreaEval) {
|
||||||
|
@ -491,7 +491,7 @@ public final class Countif extends Fixed2ArgFunction {
|
|||||||
*/
|
*/
|
||||||
private static ValueEval evaluateCriteriaArg(ValueEval arg, int srcRowIndex, int srcColumnIndex) {
|
private static ValueEval evaluateCriteriaArg(ValueEval arg, int srcRowIndex, int srcColumnIndex) {
|
||||||
try {
|
try {
|
||||||
return OperandResolver.getSingleValue(arg, srcRowIndex, (short)srcColumnIndex);
|
return OperandResolver.getSingleValue(arg, srcRowIndex, srcColumnIndex);
|
||||||
} catch (EvaluationException e) {
|
} catch (EvaluationException e) {
|
||||||
return e.getErrorEval();
|
return e.getErrorEval();
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public final class Sumifs implements FreeRefFunction {
|
|||||||
public static final FreeRefFunction instance = new Sumifs();
|
public static final FreeRefFunction instance = new Sumifs();
|
||||||
|
|
||||||
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
|
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
|
||||||
|
// need at least 3 arguments and need to have an odd number of arguments (sum-range plus x*(criteria_range, criteria))
|
||||||
if(args.length < 3 || args.length % 2 == 0) {
|
if(args.length < 3 || args.length % 2 == 0) {
|
||||||
return ErrorEval.VALUE_INVALID;
|
return ErrorEval.VALUE_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -110,9 +111,12 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
File file;
|
File file;
|
||||||
try {
|
try {
|
||||||
file = TempFile.createTempFile(simpleFileName + "#", ".xls");
|
file = TempFile.createTempFile(simpleFileName + "#", ".xls");
|
||||||
FileOutputStream out = new FileOutputStream(file);
|
OutputStream out = new FileOutputStream(file);
|
||||||
wb.write(out);
|
try {
|
||||||
out.close();
|
wb.write(out);
|
||||||
|
} finally {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -178,7 +182,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
cell = row.createCell(3);
|
cell = row.createCell(3);
|
||||||
|
|
||||||
// Write test
|
// Write test
|
||||||
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||||
setCellText(cell, "a test");
|
setCellText(cell, "a test");
|
||||||
|
|
||||||
// change existing numeric cell value
|
// change existing numeric cell value
|
||||||
@ -460,7 +464,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
HSSFRow row = sheet.getRow(i);
|
HSSFRow row = sheet.getRow(i);
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
HSSFCell cell = row .getCell(0);
|
HSSFCell cell = row .getCell(0);
|
||||||
assertEquals(HSSFCell.CELL_TYPE_STRING, cell.getCellType());
|
assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1151,13 +1155,13 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void confirmCachedValue(double expectedValue, HSSFCell cell) {
|
private static void confirmCachedValue(double expectedValue, HSSFCell cell) {
|
||||||
assertEquals(HSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
|
assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
|
||||||
assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
|
assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
|
||||||
assertEquals(expectedValue, cell.getNumericCellValue(), 0.0);
|
assertEquals(expectedValue, cell.getNumericCellValue(), 0.0);
|
||||||
}
|
}
|
||||||
private static void confirmCachedValue(String expectedValue, HSSFCell cell) {
|
private static void confirmCachedValue(String expectedValue, HSSFCell cell) {
|
||||||
assertEquals(HSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
|
assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
|
||||||
assertEquals(HSSFCell.CELL_TYPE_STRING, cell.getCachedFormulaResultType());
|
assertEquals(Cell.CELL_TYPE_STRING, cell.getCachedFormulaResultType());
|
||||||
assertEquals(expectedValue, cell.getRichStringCellValue().getString());
|
assertEquals(expectedValue, cell.getRichStringCellValue().getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1270,7 +1274,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
s = wb.getSheet("OneVariable Table Completed");
|
s = wb.getSheet("OneVariable Table Completed");
|
||||||
r = s.getRow(3);
|
r = s.getRow(3);
|
||||||
c = r.getCell(4);
|
c = r.getCell(4);
|
||||||
assertEquals(HSSFCell.CELL_TYPE_FORMULA, c.getCellType());
|
assertEquals(Cell.CELL_TYPE_FORMULA, c.getCellType());
|
||||||
|
|
||||||
// TODO - check the formula once tables and
|
// TODO - check the formula once tables and
|
||||||
// arrays are properly supported
|
// arrays are properly supported
|
||||||
@ -1280,7 +1284,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
s = wb.getSheet("TwoVariable Table Example");
|
s = wb.getSheet("TwoVariable Table Example");
|
||||||
r = s.getRow(3);
|
r = s.getRow(3);
|
||||||
c = r.getCell(4);
|
c = r.getCell(4);
|
||||||
assertEquals(HSSFCell.CELL_TYPE_FORMULA, c.getCellType());
|
assertEquals(Cell.CELL_TYPE_FORMULA, c.getCellType());
|
||||||
|
|
||||||
// TODO - check the formula once tables and
|
// TODO - check the formula once tables and
|
||||||
// arrays are properly supported
|
// arrays are properly supported
|
||||||
@ -1333,7 +1337,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
assertTrue(wb.isSheetVeryHidden(2));
|
assertTrue(wb.isSheetVeryHidden(2));
|
||||||
|
|
||||||
// Change 0 to be very hidden, and re-load
|
// Change 0 to be very hidden, and re-load
|
||||||
wb.setSheetHidden(0, HSSFWorkbook.SHEET_STATE_VERY_HIDDEN);
|
wb.setSheetHidden(0, Workbook.SHEET_STATE_VERY_HIDDEN);
|
||||||
|
|
||||||
HSSFWorkbook nwb = writeOutAndReadBack(wb);
|
HSSFWorkbook nwb = writeOutAndReadBack(wb);
|
||||||
|
|
||||||
@ -1579,7 +1583,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
OPOIFSFileSystem fs = new OPOIFSFileSystem(
|
OPOIFSFileSystem fs = new OPOIFSFileSystem(
|
||||||
HSSFITestDataProvider.instance.openWorkbookStream("46904.xls"));
|
HSSFITestDataProvider.instance.openWorkbookStream("46904.xls"));
|
||||||
new HSSFWorkbook(fs.getRoot(), false).close();
|
new HSSFWorkbook(fs.getRoot(), false).close();
|
||||||
fail();
|
fail("Should catch exception here");
|
||||||
} catch(OldExcelFormatException e) {
|
} catch(OldExcelFormatException e) {
|
||||||
assertTrue(e.getMessage().startsWith(
|
assertTrue(e.getMessage().startsWith(
|
||||||
"The supplied spreadsheet seems to be Excel"
|
"The supplied spreadsheet seems to be Excel"
|
||||||
@ -1590,7 +1594,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
HSSFITestDataProvider.instance.openWorkbookStream("46904.xls"));
|
HSSFITestDataProvider.instance.openWorkbookStream("46904.xls"));
|
||||||
try {
|
try {
|
||||||
new HSSFWorkbook(fs.getRoot(), false).close();
|
new HSSFWorkbook(fs.getRoot(), false).close();
|
||||||
fail();
|
fail("Should catch exception here");
|
||||||
} finally {
|
} finally {
|
||||||
fs.close();
|
fs.close();
|
||||||
}
|
}
|
||||||
@ -1846,17 +1850,15 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||||
|
|
||||||
// TODO - Fix these so they work...
|
// TODO - Fix these so they work...
|
||||||
if(1==2) {
|
/*row = s.getRow(4);
|
||||||
row = s.getRow(4);
|
assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
|
||||||
assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
|
assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula());
|
||||||
assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula());
|
assertEquals(123.0, row.getCell(1).getNumericCellValue(), 0);
|
||||||
assertEquals(123.0, row.getCell(1).getNumericCellValue(), 0);
|
|
||||||
|
|
||||||
row = s.getRow(5);
|
row = s.getRow(5);
|
||||||
assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
|
assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
|
||||||
assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
|
assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
|
||||||
assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0);
|
assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0);*/
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2419,9 +2421,11 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
Workbook wb = new HSSFWorkbook(); //or new HSSFWorkbook();
|
Workbook wb = new HSSFWorkbook(); //or new HSSFWorkbook();
|
||||||
wb.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG);
|
wb.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG);
|
||||||
assertEquals(wb.getAllPictures().size(), 1);
|
assertEquals(wb.getAllPictures().size(), 1);
|
||||||
|
wb.close();
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
wb = new HSSFWorkbook();
|
wb = new HSSFWorkbook();
|
||||||
|
|
||||||
wb = writeOutAndReadBack((HSSFWorkbook) wb);
|
wb = writeOutAndReadBack((HSSFWorkbook) wb);
|
||||||
assertEquals(wb.getAllPictures().size(), 0);
|
assertEquals(wb.getAllPictures().size(), 0);
|
||||||
wb.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG);
|
wb.addPicture(new byte[]{123,22}, Workbook.PICTURE_TYPE_JPEG);
|
||||||
@ -2482,7 +2486,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
HSSFSheet sheet = wb.getSheetAt(0);
|
HSSFSheet sheet = wb.getSheetAt(0);
|
||||||
HSSFRow row = sheet.getRow(0);
|
HSSFRow row = sheet.getRow(0);
|
||||||
HSSFCellStyle rstyle = row.getRowStyle();
|
HSSFCellStyle rstyle = row.getRowStyle();
|
||||||
assertEquals(rstyle.getBorderBottom(), HSSFCellStyle.BORDER_DOUBLE);
|
assertEquals(rstyle.getBorderBottom(), CellStyle.BORDER_DOUBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user