Fix some compiler warnings, javadoc, ...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1736924 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8afb394974
commit
0115c12e2d
@ -332,11 +332,11 @@ public final class CellUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method that returns the named short value form the given map.
|
* Utility method that returns the named short value form the given map.
|
||||||
* @return zero if the property does not exist, or is not a {@link Short}.
|
|
||||||
*
|
*
|
||||||
* @param properties map of named properties (String -> Object)
|
* @param properties map of named properties (String -> Object)
|
||||||
* @param name property name
|
* @param name property name
|
||||||
* @return property value, or zero
|
* @return zero if the property does not exist, or is not a {@link Short}
|
||||||
|
* otherwise the property value
|
||||||
*/
|
*/
|
||||||
private static short getShort(Map<String, Object> properties, String name) {
|
private static short getShort(Map<String, Object> properties, String name) {
|
||||||
Object value = properties.get(name);
|
Object value = properties.get(name);
|
||||||
@ -348,14 +348,15 @@ public final class CellUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method that returns the named boolean value form the given map.
|
* Utility method that returns the named boolean value form the given map.
|
||||||
* @return false if the property does not exist, or is not a {@link Boolean}.
|
|
||||||
*
|
*
|
||||||
* @param properties map of properties (String -> Object)
|
* @param properties map of properties (String -> Object)
|
||||||
* @param name property name
|
* @param name property name
|
||||||
* @return property value, or false
|
* @return false if the property does not exist, or is not a {@link Boolean},
|
||||||
|
* true otherwise
|
||||||
*/
|
*/
|
||||||
private static boolean getBoolean(Map<String, Object> properties, String name) {
|
private static boolean getBoolean(Map<String, Object> properties, String name) {
|
||||||
Object value = properties.get(name);
|
Object value = properties.get(name);
|
||||||
|
//noinspection SimplifiableIfStatement
|
||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean) {
|
||||||
return ((Boolean) value).booleanValue();
|
return ((Boolean) value).booleanValue();
|
||||||
}
|
}
|
||||||
@ -397,10 +398,9 @@ public final class CellUtil {
|
|||||||
boolean foundUnicode = false;
|
boolean foundUnicode = false;
|
||||||
String lowerCaseStr = s.toLowerCase(Locale.ROOT);
|
String lowerCaseStr = s.toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
for (int i = 0; i < unicodeMappings.length; i++) {
|
for (UnicodeMapping entry : unicodeMappings) {
|
||||||
UnicodeMapping entry = unicodeMappings[i];
|
|
||||||
String key = entry.entityName;
|
String key = entry.entityName;
|
||||||
if (lowerCaseStr.indexOf(key) != -1) {
|
if (lowerCaseStr.contains(key)) {
|
||||||
s = s.replaceAll(key, entry.resolvedValue);
|
s = s.replaceAll(key, entry.resolvedValue);
|
||||||
foundUnicode = true;
|
foundUnicode = true;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
((XSSFRow)row).onDocumentWrite();
|
((XSSFRow)row).onDocumentWrite();
|
||||||
|
|
||||||
for(Cell cell : row) {
|
for(Cell cell : row) {
|
||||||
cell.toString();
|
assertNotNull(cell.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,8 +453,8 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodingbeloAscii() throws IOException {
|
public void testEncodingBelowAscii() throws IOException {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
// test all possible characters
|
// test all possible characters
|
||||||
for(int i = 0; i < Character.MAX_VALUE; i++) {
|
for(int i = 0; i < Character.MAX_VALUE; i++) {
|
||||||
sb.append((char)i);
|
sb.append((char)i);
|
||||||
@ -466,10 +466,10 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
while(pos < strAll.length()) {
|
while(pos < strAll.length()) {
|
||||||
String str = strAll.substring(pos, Math.min(strAll.length(), pos+SpreadsheetVersion.EXCEL2007.getMaxTextLength()));
|
String str = strAll.substring(pos, Math.min(strAll.length(), pos+SpreadsheetVersion.EXCEL2007.getMaxTextLength()));
|
||||||
|
|
||||||
Workbook wb = HSSFITestDataProvider.instance.createWorkbook();
|
Workbook wb = HSSFITestDataProvider.instance.createWorkbook();
|
||||||
Cell cell = wb.createSheet().createRow(0).createCell(0);
|
Cell cell = wb.createSheet().createRow(0).createCell(0);
|
||||||
|
|
||||||
Workbook xwb = XSSFITestDataProvider.instance.createWorkbook();
|
Workbook xwb = XSSFITestDataProvider.instance.createWorkbook();
|
||||||
Cell xCell = xwb.createSheet().createRow(0).createCell(0);
|
Cell xCell = xwb.createSheet().createRow(0).createCell(0);
|
||||||
|
|
||||||
@ -482,19 +482,19 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
assertEquals(str, xCell.getStringCellValue());
|
assertEquals(str, xCell.getStringCellValue());
|
||||||
sCell.setCellValue(str);
|
sCell.setCellValue(str);
|
||||||
assertEquals(str, sCell.getStringCellValue());
|
assertEquals(str, sCell.getStringCellValue());
|
||||||
|
|
||||||
Workbook wbBack = HSSFITestDataProvider.instance.writeOutAndReadBack(wb);
|
Workbook wbBack = HSSFITestDataProvider.instance.writeOutAndReadBack(wb);
|
||||||
Workbook xwbBack = XSSFITestDataProvider.instance.writeOutAndReadBack(xwb);
|
Workbook xwbBack = XSSFITestDataProvider.instance.writeOutAndReadBack(xwb);
|
||||||
Workbook swbBack = SXSSFITestDataProvider.instance.writeOutAndReadBack(swb);
|
Workbook swbBack = SXSSFITestDataProvider.instance.writeOutAndReadBack(swb);
|
||||||
cell = wbBack.getSheetAt(0).createRow(0).createCell(0);
|
cell = wbBack.getSheetAt(0).createRow(0).createCell(0);
|
||||||
xCell = xwbBack.getSheetAt(0).createRow(0).createCell(0);
|
xCell = xwbBack.getSheetAt(0).createRow(0).createCell(0);
|
||||||
sCell = swbBack.getSheetAt(0).createRow(0).createCell(0);
|
sCell = swbBack.getSheetAt(0).createRow(0).createCell(0);
|
||||||
|
|
||||||
assertEquals(cell.getStringCellValue(), xCell.getStringCellValue());
|
assertEquals(cell.getStringCellValue(), xCell.getStringCellValue());
|
||||||
assertEquals(cell.getStringCellValue(), sCell.getStringCellValue());
|
assertEquals(cell.getStringCellValue(), sCell.getStringCellValue());
|
||||||
|
|
||||||
pos += SpreadsheetVersion.EXCEL97.getMaxTextLength();
|
pos += SpreadsheetVersion.EXCEL97.getMaxTextLength();
|
||||||
|
|
||||||
swbBack.close();
|
swbBack.close();
|
||||||
xwbBack.close();
|
xwbBack.close();
|
||||||
wbBack.close();
|
wbBack.close();
|
||||||
@ -647,7 +647,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void setUp_testCopyCellFrom_CellCopyPolicy() {
|
private void setUp_testCopyCellFrom_CellCopyPolicy() {
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
final XSSFWorkbook wb = new XSSFWorkbook();
|
final XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
final XSSFRow row = wb.createSheet("Sheet1").createRow(0);
|
final XSSFRow row = wb.createSheet("Sheet1").createRow(0);
|
||||||
|
@ -308,8 +308,8 @@ public final class TestHSSFCell extends BaseTestCell {
|
|||||||
// expected during successful test
|
// expected during successful test
|
||||||
}
|
}
|
||||||
|
|
||||||
HSSFCell cellA = wbA.createSheet().createRow(0).createCell(0);
|
Cell cellA = wbA.createSheet().createRow(0).createCell(0);
|
||||||
HSSFCell cellB = wbB.createSheet().createRow(0).createCell(0);
|
Cell cellB = wbB.createSheet().createRow(0).createCell(0);
|
||||||
|
|
||||||
cellA.setCellStyle(styA);
|
cellA.setCellStyle(styA);
|
||||||
cellB.setCellStyle(styB);
|
cellB.setCellStyle(styB);
|
||||||
@ -378,7 +378,7 @@ public final class TestHSSFCell extends BaseTestCell {
|
|||||||
} else {
|
} else {
|
||||||
assertFalse(StringRecord.class == recs[index].getClass());
|
assertFalse(StringRecord.class == recs[index].getClass());
|
||||||
}
|
}
|
||||||
Record dbcr = recs[index++];
|
Record dbcr = recs[index];
|
||||||
assertEquals(DBCellRecord.class, dbcr.getClass());
|
assertEquals(DBCellRecord.class, dbcr.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,12 +417,14 @@ public final class TestHSSFCell extends BaseTestCell {
|
|||||||
cell.getCachedFormulaResultType();
|
cell.getCachedFormulaResultType();
|
||||||
fail("Should catch exception");
|
fail("Should catch exception");
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
|
// expected here
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assertNotNull(new HSSFCell(wb, sheet, 0, (short)0, Cell.CELL_TYPE_ERROR+1 ));
|
assertNotNull(new HSSFCell(wb, sheet, 0, (short)0, Cell.CELL_TYPE_ERROR+1 ));
|
||||||
fail("Should catch exception");
|
fail("Should catch exception");
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
// expected here
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.removeCellComment();
|
cell.removeCellComment();
|
||||||
|
Loading…
Reference in New Issue
Block a user