Some IDE warning fixes and unit test adjustments

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763482 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-10-05 19:59:44 +00:00
parent d0bb2912ec
commit 924a1a96d9
3 changed files with 24 additions and 26 deletions

View File

@ -205,9 +205,9 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* records too.
*/
protected void removeAllCells() {
for(int i=0; i<cells.length; i++) {
if(cells[i] != null) {
removeCell(cells[i], true);
for (HSSFCell cell : cells) {
if (cell != null) {
removeCell(cell, true);
}
}
cells=new HSSFCell[INITIAL_CAPACITY];
@ -232,9 +232,9 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
row.setFirstCol(colIx);
} else if (colIx > row.getLastCol()) {
row.setLastCol(colIx + 1);
} else {
} /*else {
// added cell is within first and last cells
}
}*/
}
// TODO - RowRecord column boundaries need to be updated for cell comments too
return hcell;
@ -446,12 +446,11 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
@Override
public int getPhysicalNumberOfCells()
{
int count=0;
for(int i=0;i<cells.length;i++)
{
if(cells[i]!=null) count++;
}
return count;
int count = 0;
for (HSSFCell cell : cells) {
if (cell != null) count++;
}
return count;
}
/**

View File

@ -64,10 +64,8 @@ public final class NumberEval implements NumericValueEval, StringValueEval {
return _stringValue;
}
public final String toString() {
StringBuffer sb = new StringBuffer(64);
sb.append(getClass().getName()).append(" [");
sb.append(getStringValue());
sb.append("]");
return sb.toString();
return getClass().getName() + " [" +
getStringValue() +
"]";
}
}

View File

@ -27,14 +27,7 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.List;
import org.apache.poi.ddf.EscherBoolProperty;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherTextboxRecord;
import org.apache.poi.ddf.*;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
import org.apache.poi.hssf.record.EscherAggregate;
@ -160,6 +153,9 @@ public class TestDrawingShapes {
HSSFClientAnchor anchor = new HSSFClientAnchor(10, 10, 50, 50, (short) 2, 2, (short) 4, 4);
anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE);
assertEquals(AnchorType.MOVE_DONT_RESIZE, anchor.getAnchorType());
//noinspection deprecation
anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE.value);
assertEquals(AnchorType.MOVE_DONT_RESIZE, anchor.getAnchorType());
HSSFSimpleShape rectangle = drawing.createSimpleShape(anchor);
rectangle.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
@ -175,8 +171,13 @@ public class TestDrawingShapes {
rectangle.setWrapText(HSSFSimpleShape.WRAP_NONE);
rectangle.setString(new HSSFRichTextString("teeeest"));
assertEquals(rectangle.getLineStyleColor(), 1111);
assertEquals(((EscherSimpleProperty)((EscherOptRecord)HSSFTestHelper.getEscherContainer(rectangle).getChildById(EscherOptRecord.RECORD_ID))
.lookup(EscherProperties.TEXT__TEXTID)).getPropertyValue(), "teeeest".hashCode());
EscherContainerRecord escherContainer = HSSFTestHelper.getEscherContainer(rectangle);
assertNotNull(escherContainer);
EscherRecord childById = escherContainer.getChildById(EscherOptRecord.RECORD_ID);
assertNotNull(childById);
EscherProperty lookup = ((EscherOptRecord) childById).lookup(EscherProperties.TEXT__TEXTID);
assertNotNull(lookup);
assertEquals(((EscherSimpleProperty) lookup).getPropertyValue(), "teeeest".hashCode());
assertEquals(rectangle.isNoFill(), true);
assertEquals(rectangle.getWrapText(), HSSFSimpleShape.WRAP_NONE);
assertEquals(rectangle.getString().getString(), "teeeest");