fix some Eclipse warnings, adjust some unit tests slightly

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1516818 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2013-08-23 10:44:39 +00:00
parent 37b7f408a3
commit bff0813e48
6 changed files with 74 additions and 56 deletions

View File

@ -138,6 +138,7 @@ public final class StyleRecord extends StandardRecord {
return field_4_name; return field_4_name;
} }
@Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
@ -156,6 +157,7 @@ public final class StyleRecord extends StandardRecord {
} }
@Override
protected int getDataSize() { protected int getDataSize() {
if (isBuiltin()) { if (isBuiltin()) {
return 4; // short, byte, byte return 4; // short, byte, byte
@ -165,6 +167,7 @@ public final class StyleRecord extends StandardRecord {
+ field_4_name.length() * (field_3_stringHasMultibyte ? 2 : 1); + field_4_name.length() * (field_3_stringHasMultibyte ? 2 : 1);
} }
@Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeShort(field_1_xf_index); out.writeShort(field_1_xf_index);
if (isBuiltin()) { if (isBuiltin()) {
@ -181,6 +184,7 @@ public final class StyleRecord extends StandardRecord {
} }
} }
@Override
public short getSid() { public short getSid() {
return sid; return sid;
} }

View File

@ -229,9 +229,9 @@ public final class AnalysisToolPak implements UDFFinder {
if(metaData != null) { if(metaData != null) {
throw new IllegalArgumentException(name + " is a built-in Excel function. " + throw new IllegalArgumentException(name + " is a built-in Excel function. " +
"Use FunctoinEval.registerFunction(String name, Function func) instead."); "Use FunctoinEval.registerFunction(String name, Function func) instead.");
} else {
throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack.");
} }
throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack.");
} }
FreeRefFunction f = inst.findFunction(name); FreeRefFunction f = inst.findFunction(name);
if(f != null && !(f instanceof NotImplemented)) { if(f != null && !(f instanceof NotImplemented)) {

View File

@ -343,7 +343,8 @@ public class POIXMLDocumentPart {
* @param noRelation if true, then no relationship is added. * @param noRelation if true, then no relationship is added.
* @return the created child POIXMLDocumentPart * @return the created child POIXMLDocumentPart
*/ */
protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation){ @SuppressWarnings("null")
protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation){
try { try {
PackagePartName ppName = PackagingURIHelper.createPartName(descriptor.getFileName(idx)); PackagePartName ppName = PackagingURIHelper.createPartName(descriptor.getFileName(idx));
PackageRelationship rel = null; PackageRelationship rel = null;

View File

@ -16,7 +16,12 @@
==================================================================== */ ==================================================================== */
package org.apache.poi; package org.apache.poi;
import java.io.*; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
/** /**
* Centralises logic for finding/opening sample files * Centralises logic for finding/opening sample files
@ -219,16 +224,20 @@ public final class POIDataSamples {
_is = is; _is = is;
} }
public int read() throws IOException { @Override
public int read() throws IOException {
return _is.read(); return _is.read();
} }
public int read(byte[] b, int off, int len) throws IOException { @Override
public int read(byte[] b, int off, int len) throws IOException {
return _is.read(b, off, len); return _is.read(b, off, len);
} }
public boolean markSupported() { @Override
public boolean markSupported() {
return false; return false;
} }
public void close() throws IOException { @Override
public void close() throws IOException {
_is.close(); _is.close();
} }
} }

View File

@ -71,9 +71,8 @@ public class AllUserModelTests {
result.addTestSuite(TestRowStyle.class); result.addTestSuite(TestRowStyle.class);
result.addTestSuite(TestSanityChecker.class); result.addTestSuite(TestSanityChecker.class);
result.addTestSuite(TestSheetHiding.class); result.addTestSuite(TestSheetHiding.class);
if (false) { // deliberately avoiding this one /* deliberately avoiding this one
result.addTestSuite(TestUnfixedBugs.class); result.addTestSuite(TestUnfixedBugs.class);*/
}
result.addTestSuite(TestUnicodeWorkbook.class); result.addTestSuite(TestUnicodeWorkbook.class);
result.addTestSuite(TestNonStandardWorkbookStreamNames.class); result.addTestSuite(TestNonStandardWorkbookStreamNames.class);
result.addTestSuite(TestWorkbook.class); result.addTestSuite(TestWorkbook.class);

View File

@ -89,36 +89,41 @@ public abstract class BaseTestRow extends TestCase {
public void testRemoveCell() { public void testRemoveCell() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet(); {
Row row = sheet.createRow(0); Sheet sheet = workbook.createSheet();
Row row = sheet.createRow(0);
assertEquals(0, row.getPhysicalNumberOfCells()); assertEquals(0, row.getPhysicalNumberOfCells());
assertEquals(-1, row.getLastCellNum()); assertEquals(-1, row.getLastCellNum());
assertEquals(-1, row.getFirstCellNum()); assertEquals(-1, row.getFirstCellNum());
row.createCell(1); row.createCell(1);
assertEquals(2, row.getLastCellNum()); assertEquals(2, row.getLastCellNum());
assertEquals(1, row.getFirstCellNum()); assertEquals(1, row.getFirstCellNum());
assertEquals(1, row.getPhysicalNumberOfCells()); assertEquals(1, row.getPhysicalNumberOfCells());
row.createCell(3); row.createCell(3);
assertEquals(4, row.getLastCellNum()); assertEquals(4, row.getLastCellNum());
assertEquals(1, row.getFirstCellNum()); assertEquals(1, row.getFirstCellNum());
assertEquals(2, row.getPhysicalNumberOfCells()); assertEquals(2, row.getPhysicalNumberOfCells());
row.removeCell(row.getCell(3)); row.removeCell(row.getCell(3));
assertEquals(2, row.getLastCellNum()); assertEquals(2, row.getLastCellNum());
assertEquals(1, row.getFirstCellNum()); assertEquals(1, row.getFirstCellNum());
assertEquals(1, row.getPhysicalNumberOfCells()); assertEquals(1, row.getPhysicalNumberOfCells());
row.removeCell(row.getCell(1)); row.removeCell(row.getCell(1));
assertEquals(-1, row.getLastCellNum()); assertEquals(-1, row.getLastCellNum());
assertEquals(-1, row.getFirstCellNum()); assertEquals(-1, row.getFirstCellNum());
assertEquals(0, row.getPhysicalNumberOfCells()); assertEquals(0, row.getPhysicalNumberOfCells());
}
workbook = _testDataProvider.writeOutAndReadBack(workbook); workbook = _testDataProvider.writeOutAndReadBack(workbook);
sheet = workbook.getSheetAt(0);
row = sheet.getRow(0); {
assertEquals(-1, row.getLastCellNum()); Sheet sheet = workbook.getSheetAt(0);
assertEquals(-1, row.getFirstCellNum()); Row row = sheet.getRow(0);
assertEquals(0, row.getPhysicalNumberOfCells()); assertEquals(-1, row.getLastCellNum());
assertEquals(-1, row.getFirstCellNum());
assertEquals(0, row.getPhysicalNumberOfCells());
}
} }
public void baseTestRowBounds(int maxRowNum) { public void baseTestRowBounds(int maxRowNum) {