remove some casts to short

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1825749 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2018-03-03 01:48:46 +00:00
parent 2688ce9d82
commit 8d4f3fde68
7 changed files with 20 additions and 20 deletions

View File

@ -958,8 +958,8 @@ public final class PropertyTemplate {
* @return short value, or 0 if not a short * @return short value, or 0 if not a short
*/ */
private static short getShort(Object value) { private static short getShort(Object value) {
if (value instanceof Short) { if (value instanceof Number) {
return ((Short) value).shortValue(); return ((Number) value).shortValue();
} }
return 0; return 0;
} }

View File

@ -42,7 +42,7 @@ public final class RegionUtil {
public CellPropertySetter(String propertyName, int value) { public CellPropertySetter(String propertyName, int value) {
_propertyName = propertyName; _propertyName = propertyName;
_propertyValue = Short.valueOf((short) value); _propertyValue = Integer.valueOf(value);
} }
public CellPropertySetter(String propertyName, BorderStyle value) { public CellPropertySetter(String propertyName, BorderStyle value) {
_propertyName = propertyName; _propertyName = propertyName;

View File

@ -613,7 +613,7 @@ public class SXSSFCell implements Cell {
{ {
if(_style == null){ if(_style == null){
SXSSFWorkbook wb = (SXSSFWorkbook)getRow().getSheet().getWorkbook(); SXSSFWorkbook wb = (SXSSFWorkbook)getRow().getSheet().getWorkbook();
return wb.getCellStyleAt((short)0); return wb.getCellStyleAt(0);
} else { } else {
return _style; return _style;
} }

View File

@ -138,7 +138,7 @@ public class XSSFFontFormatting implements FontFormatting {
if(_font.sizeOfSzArray() == 0) return -1; if(_font.sizeOfSzArray() == 0) return -1;
CTFontSize sz = _font.getSzArray(0); CTFontSize sz = _font.getSzArray(0);
return (short)(20*sz.getVal()); return (int)(20*sz.getVal());
} }
/** /**

View File

@ -876,7 +876,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
font1.setColor((short) 20); font1.setColor((short) 20);
Font font2 = wb1.createFont(); Font font2 = wb1.createFont();
font2.setColor(Font.COLOR_RED); font2.setColor(Font.COLOR_RED);
Font font3 = wb1.getFontAt((short) 0); Font font3 = wb1.getFontAt(0);
XSSFRow row = sheet.createRow(2); XSSFRow row = sheet.createRow(2);
XSSFCell cell = row.createCell(2); XSSFCell cell = row.createCell(2);
@ -1750,9 +1750,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
// run some method on the font to verify if it is "disconnected" already // run some method on the font to verify if it is "disconnected" already
//for(short i = 0;i < 256;i++) //for(short i = 0;i < 256;i++)
{ {
Font font = wb.getFontAt((short) 0); Font font = wb.getFontAt(0);
if (font instanceof XSSFFont) { if (font instanceof XSSFFont) {
XSSFFont xfont = (XSSFFont) wb.getFontAt((short) 0); XSSFFont xfont = (XSSFFont) wb.getFontAt(0);
CTFontImpl ctFont = (CTFontImpl) xfont.getCTFont(); CTFontImpl ctFont = (CTFontImpl) xfont.getCTFont();
assertEquals(0, ctFont.sizeOfBArray()); assertEquals(0, ctFont.sizeOfBArray());
} }

View File

@ -35,7 +35,7 @@ public final class TestXSSFColor {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
// Check the CTColor is as expected // Check the CTColor is as expected
XSSFColor indexed = wb.getCellStyleAt((short)1).getFillBackgroundXSSFColor(); XSSFColor indexed = wb.getCellStyleAt(1).getFillBackgroundXSSFColor();
assertEquals(true, indexed.getCTColor().isSetIndexed()); assertEquals(true, indexed.getCTColor().isSetIndexed());
assertEquals(64, indexed.getCTColor().getIndexed()); assertEquals(64, indexed.getCTColor().getIndexed());
assertEquals(false, indexed.getCTColor().isSetRgb()); assertEquals(false, indexed.getCTColor().isSetRgb());

View File

@ -323,7 +323,7 @@ public final class TestXSSFFont extends BaseTestFont{
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
// cannot check on result because on some machines we get back false here! // cannot check on result because on some machines we get back false here!
SheetUtil.canComputeColumnWidth(wb.getFontAt((short)0)); SheetUtil.canComputeColumnWidth(wb.getFontAt(0));
wb.close(); wb.close();
} }
@ -354,16 +354,16 @@ public final class TestXSSFFont extends BaseTestFont{
assertEquals(1, wb.getNumberOfFonts()); assertEquals(1, wb.getNumberOfFonts());
XSSFFont f1 = wb.getFontAt((short) 0); XSSFFont f1 = wb.getFontAt(0);
assertFalse(f1.getBold()); assertFalse(f1.getBold());
// Check that asking for the same font // Check that asking for the same font
// multiple times gives you the same thing. // multiple times gives you the same thing.
// Otherwise, our tests wouldn't work! // Otherwise, our tests wouldn't work!
assertSame(wb.getFontAt((short) 0), wb.getFontAt((short) 0)); assertSame(wb.getFontAt(0), wb.getFontAt(0));
assertEquals( assertEquals(
wb.getFontAt((short) 0), wb.getFontAt(0),
wb.getFontAt((short) 0) wb.getFontAt(0)
); );
// Look for a new font we have // Look for a new font we have
@ -384,8 +384,8 @@ public final class TestXSSFFont extends BaseTestFont{
XSSFFont nf = wb.createFont(); XSSFFont nf = wb.createFont();
assertEquals(2, wb.getNumberOfFonts()); assertEquals(2, wb.getNumberOfFonts());
assertEquals(1, nf.getIndex()); assertEquals(1, nf.getIndexAsInt());
assertEquals(nf, wb.getFontAt((short) 1)); assertEquals(nf, wb.getFontAt(1));
nf.setBold(false); nf.setBold(false);
nf.setColor(IndexedColors.INDIGO.getIndex()); nf.setColor(IndexedColors.INDIGO.getIndex());
@ -397,12 +397,12 @@ public final class TestXSSFFont extends BaseTestFont{
nf.setUnderline((byte) 2); nf.setUnderline((byte) 2);
assertEquals(2, wb.getNumberOfFonts()); assertEquals(2, wb.getNumberOfFonts());
assertEquals(nf, wb.getFontAt((short) 1)); assertEquals(nf, wb.getFontAt(1));
assertTrue( assertTrue(
wb.getFontAt((short) 0) wb.getFontAt(0)
!= !=
wb.getFontAt((short) 1) wb.getFontAt(1)
); );
// Find it now // Find it now
@ -426,7 +426,7 @@ public final class TestXSSFFont extends BaseTestFont{
assertNotNull(font); assertNotNull(font);
assertEquals( assertEquals(
1, 1,
font.getIndex() font.getIndexAsInt()
); );
assertEquals(nf, assertEquals(nf,
wb.findFont( wb.findFont(