/**
* 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 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) {
Object value = properties.get(name);
/**
* 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 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) {
Object value = properties.get(name);
+ //noinspection SimplifiableIfStatement
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue();
}
boolean foundUnicode = false;
String lowerCaseStr = s.toLowerCase(Locale.ROOT);
- for (int i = 0; i < unicodeMappings.length; i++) {
- UnicodeMapping entry = unicodeMappings[i];
+ for (UnicodeMapping entry : unicodeMappings) {
String key = entry.entityName;
- if (lowerCaseStr.indexOf(key) != -1) {
+ if (lowerCaseStr.contains(key)) {
s = s.replaceAll(key, entry.resolvedValue);
foundUnicode = true;
}
((XSSFRow)row).onDocumentWrite();
for(Cell cell : row) {
- cell.toString();
+ assertNotNull(cell.toString());
}
}
}
@Test
- public void testEncodingbeloAscii() throws IOException {
- StringBuffer sb = new StringBuffer();
+ public void testEncodingBelowAscii() throws IOException {
+ StringBuilder sb = new StringBuilder();
// test all possible characters
for(int i = 0; i < Character.MAX_VALUE; i++) {
sb.append((char)i);
int pos = 0;
while(pos < strAll.length()) {
String str = strAll.substring(pos, Math.min(strAll.length(), pos+SpreadsheetVersion.EXCEL2007.getMaxTextLength()));
-
+
Workbook wb = HSSFITestDataProvider.instance.createWorkbook();
Cell cell = wb.createSheet().createRow(0).createCell(0);
-
+
Workbook xwb = XSSFITestDataProvider.instance.createWorkbook();
Cell xCell = xwb.createSheet().createRow(0).createCell(0);
assertEquals(str, xCell.getStringCellValue());
sCell.setCellValue(str);
assertEquals(str, sCell.getStringCellValue());
-
+
Workbook wbBack = HSSFITestDataProvider.instance.writeOutAndReadBack(wb);
Workbook xwbBack = XSSFITestDataProvider.instance.writeOutAndReadBack(xwb);
Workbook swbBack = SXSSFITestDataProvider.instance.writeOutAndReadBack(swb);
cell = wbBack.getSheetAt(0).createRow(0).createCell(0);
xCell = xwbBack.getSheetAt(0).createRow(0).createCell(0);
sCell = swbBack.getSheetAt(0).createRow(0).createCell(0);
-
+
assertEquals(cell.getStringCellValue(), xCell.getStringCellValue());
assertEquals(cell.getStringCellValue(), sCell.getStringCellValue());
-
+
pos += SpreadsheetVersion.EXCEL97.getMaxTextLength();
-
+
swbBack.close();
xwbBack.close();
wbBack.close();
wb.close();
}
- private final void setUp_testCopyCellFrom_CellCopyPolicy() {
+ private void setUp_testCopyCellFrom_CellCopyPolicy() {
@SuppressWarnings("resource")
final XSSFWorkbook wb = new XSSFWorkbook();
final XSSFRow row = wb.createSheet("Sheet1").createRow(0);
// expected during successful test
}
- HSSFCell cellA = wbA.createSheet().createRow(0).createCell(0);
- HSSFCell cellB = wbB.createSheet().createRow(0).createCell(0);
+ Cell cellA = wbA.createSheet().createRow(0).createCell(0);
+ Cell cellB = wbB.createSheet().createRow(0).createCell(0);
cellA.setCellStyle(styA);
cellB.setCellStyle(styB);
} else {
assertFalse(StringRecord.class == recs[index].getClass());
}
- Record dbcr = recs[index++];
+ Record dbcr = recs[index];
assertEquals(DBCellRecord.class, dbcr.getClass());
}
cell.getCachedFormulaResultType();
fail("Should catch exception");
} catch (IllegalStateException e) {
+ // expected here
}
try {
assertNotNull(new HSSFCell(wb, sheet, 0, (short)0, Cell.CELL_TYPE_ERROR+1 ));
fail("Should catch exception");
} catch (RuntimeException e) {
+ // expected here
}
cell.removeCellComment();