Bug 57480: Fix some unnecessary casts, generics, Eclipse warnings, ...

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1658594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2015-02-09 22:33:24 +00:00
parent a27718e373
commit 6f4b4816a8
26 changed files with 45 additions and 54 deletions

View File

@ -154,7 +154,7 @@ public class RecordLister
return s.toString();
}
private static String byteToHex(byte b) {
int i = (int)b;
int i = b;
if(i<0) {
i += 256;
}

View File

@ -92,11 +92,10 @@ public class HSSFRequest {
* @throws HSSFUserException User exception condition
*/
protected short processRecord(Record rec) throws HSSFUserException {
Object obj = _records.get(Short.valueOf(rec.getSid()));
List<HSSFListener> listeners = _records.get(Short.valueOf(rec.getSid()));
short userCode = 0;
if (obj != null) {
List listeners = (List) obj;
if (listeners != null) {
for (int k = 0; k < listeners.size(); k++) {
Object listenObj = listeners.get(k);

View File

@ -68,7 +68,6 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor implements or
* @deprecated Use {@link #EventBasedExcelExtractor(DirectoryNode)} instead
*/
@Deprecated
@SuppressWarnings( "unused" )
public EventBasedExcelExtractor( DirectoryNode dir, POIFSFileSystem fs )
{
this( dir );

View File

@ -72,7 +72,6 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
* @deprecated Use {@link #ExcelExtractor(DirectoryNode)} instead
*/
@Deprecated
@SuppressWarnings( "unused" )
public ExcelExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
this( dir );
}
@ -241,6 +240,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
extractor.setIncludeBlankCells(cmdArgs.shouldShowBlankCells());
extractor.setIncludeHeadersFooters(cmdArgs.shouldIncludeHeadersFooters());
System.out.println(extractor.getText());
extractor.close();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);

View File

@ -29,7 +29,7 @@ import java.util.HashMap;
public class DrawingManager
{
EscherDggRecord dgg;
Map dgMap = new HashMap(); // key = Short(drawingId), value=EscherDgRecord
Map<Short, EscherDgRecord> dgMap = new HashMap<Short, EscherDgRecord>(); // key = Short(drawingId), value=EscherDgRecord
public DrawingManager( EscherDggRecord dgg )
{
@ -46,7 +46,7 @@ public class DrawingManager
dg.setLastMSOSPID( -1 );
dgg.addCluster( dgId, 0 );
dgg.setDrawingsSaved( dgg.getDrawingsSaved() + 1 );
dgMap.put( Short.valueOf( dgId ), dg );
dgMap.put( dgId, dg );
return dg;
}
@ -58,7 +58,7 @@ public class DrawingManager
public int allocateShapeId(short drawingGroupId)
{
// Get the last shape id for this drawing group.
EscherDgRecord dg = (EscherDgRecord) dgMap.get(Short.valueOf(drawingGroupId));
EscherDgRecord dg = dgMap.get(drawingGroupId);
int lastShapeId = dg.getLastMSOSPID();

View File

@ -36,7 +36,7 @@ import org.apache.poi.ss.util.CellReference;
*/
public final class RowBlocksReader {
private final List _plainRecords;
private final List<Record> _plainRecords;
private final SharedValueManager _sfm;
private final MergeCellsRecord[] _mergedCellsRecords;

View File

@ -19,7 +19,6 @@ package org.apache.poi.hssf.record;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.NullEscherSerializationListener;
import org.apache.poi.util.ArrayUtil;
import org.apache.poi.util.LittleEndian;
import java.util.Iterator;
@ -60,9 +59,9 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
}
byte[] buffer = new byte[getRawDataSize()];
int pos = 0;
for ( Iterator iterator = getEscherRecords().iterator(); iterator.hasNext(); )
for ( Iterator<EscherRecord> iterator = getEscherRecords().iterator(); iterator.hasNext(); )
{
EscherRecord r = (EscherRecord) iterator.next();
EscherRecord r = iterator.next();
pos += r.serialize(pos, buffer, new NullEscherSerializationListener() );
}
@ -85,16 +84,16 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
}
private int getRawDataSize() {
List escherRecords = getEscherRecords();
List<EscherRecord> escherRecords = getEscherRecords();
byte[] rawData = getRawData();
if (escherRecords.size() == 0 && rawData != null)
{
return rawData.length;
}
int size = 0;
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
for ( Iterator<EscherRecord> iterator = escherRecords.iterator(); iterator.hasNext(); )
{
EscherRecord r = (EscherRecord) iterator.next();
EscherRecord r = iterator.next();
size += r.getRecordSize();
}
return size;

View File

@ -50,9 +50,9 @@ public final class HorizontalPageBreakRecord extends PageBreakRecord {
public Object clone() {
PageBreakRecord result = new HorizontalPageBreakRecord();
Iterator iterator = getBreaksIterator();
Iterator<Break> iterator = getBreaksIterator();
while (iterator.hasNext()) {
Break original = (Break) iterator.next();
Break original = iterator.next();
result.addBreak(original.main, original.subFrom, original.subTo);
}
return result;

View File

@ -49,9 +49,9 @@ public final class VerticalPageBreakRecord extends PageBreakRecord {
public Object clone() {
PageBreakRecord result = new VerticalPageBreakRecord();
Iterator iterator = getBreaksIterator();
Iterator<Break> iterator = getBreaksIterator();
while (iterator.hasNext()) {
Break original = (Break) iterator.next();
Break original = iterator.next();
result.addBreak(original.main, original.subFrom, original.subTo);
}
return result;

View File

@ -32,13 +32,13 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public final class MergedCellsTable extends RecordAggregate {
private static int MAX_MERGED_REGIONS = 1027; // enforced by the 8224 byte limit
private final List _mergedRegions;
private final List<CellRangeAddress> _mergedRegions;
/**
* Creates an empty aggregate
*/
public MergedCellsTable() {
_mergedRegions = new ArrayList();
_mergedRegions = new ArrayList<CellRangeAddress>();
}
/**
@ -46,7 +46,7 @@ public final class MergedCellsTable extends RecordAggregate {
* @param rs
*/
public void read(RecordStream rs) {
List temp = _mergedRegions;
List<CellRangeAddress> temp = _mergedRegions;
while (rs.peekNextClass() == MergeCellsRecord.class) {
MergeCellsRecord mcr = (MergeCellsRecord) rs.getNext();
int nRegions = mcr.getNumAreas();
@ -110,7 +110,7 @@ public final class MergedCellsTable extends RecordAggregate {
public CellRangeAddress get(int index) {
checkIndex(index);
return (CellRangeAddress) _mergedRegions.get(index);
return _mergedRegions.get(index);
}
public void remove(int index) {

View File

@ -38,11 +38,6 @@ public class ChartTitleFormatRecord extends StandardRecord {
private int _offset;
private int _fontIndex;
protected CTFormat(short offset,short fontIdx){
_offset = offset;
_fontIndex = fontIdx;
}
public CTFormat(RecordInputStream in) {
_offset = in.readShort();
_fontIndex = in.readShort();

View File

@ -42,7 +42,7 @@ public class DummyGraphics2d
g2D = (Graphics2D)img.getGraphics();
}
public void addRenderingHints(Map hints)
public void addRenderingHints(Map<?,?> hints)
{
System.out.println( "addRenderingHinds(Map):" );
System.out.println( " hints = " + hints );
@ -275,7 +275,7 @@ public class DummyGraphics2d
g2D.setRenderingHint( hintKey, hintValue );
}
public void setRenderingHints(Map hints)
public void setRenderingHints(Map<?,?> hints)
{
System.out.println( "setRenderingHints(Map):" );
System.out.println( "hints = " + hints );

View File

@ -431,7 +431,6 @@ public class EscherGraphics
return null;
}
@SuppressWarnings("deprecation")
public Rectangle getClipRect()
{
return getClipBounds();

View File

@ -89,7 +89,7 @@ public final class EscherGraphics2d extends Graphics2D {
setColor(Color.black);
}
public void addRenderingHints(Map map)
public void addRenderingHints(Map<?, ?> map)
{
getG2D().addRenderingHints(map);
}
@ -514,7 +514,7 @@ public final class EscherGraphics2d extends Graphics2D {
getG2D().setRenderingHint(key, obj);
}
public void setRenderingHints(Map map)
public void setRenderingHints(Map<?, ?> map)
{
getG2D().setRenderingHints(map);
}

View File

@ -63,7 +63,6 @@ public final class HSSFDataFormat implements DataFormat {
HSSFDataFormat(InternalWorkbook workbook) {
_workbook = workbook;
@SuppressWarnings("unchecked")
Iterator<FormatRecord> i = workbook.getFormats().iterator();
while (i.hasNext()) {
FormatRecord r = i.next();

View File

@ -309,7 +309,7 @@ public final class HSSFFont implements Font {
{
byte charset = font.getCharset();
if(charset >= 0) {
return (int)charset;
return charset;
} else {
return charset + 256;
}

View File

@ -134,7 +134,7 @@ public final class HSSFPalette {
* 0 and 255, so distance calculations work as expected.
*/
private int unsignedInt(byte b) {
return 0xFF & ((int) b);
return 0xFF & b;
}
/**

View File

@ -617,7 +617,7 @@ public final class HSSFRow implements Row {
* Alias for {@link #cellIterator} to allow
* foreach loops
*/
public Iterator iterator() {
public Iterator<Cell> iterator() {
return cellIterator();
}

View File

@ -305,8 +305,8 @@ public class HSSFShapeGroup extends HSSFShape implements HSSFShapeContainer {
*/
public int countOfAllChildren() {
int count = shapes.size();
for (Iterator iterator = shapes.iterator(); iterator.hasNext(); ) {
HSSFShape shape = (HSSFShape) iterator.next();
for (Iterator<HSSFShape> iterator = shapes.iterator(); iterator.hasNext(); ) {
HSSFShape shape = iterator.next();
count += shape.countOfAllChildren();
}
return count;

View File

@ -75,7 +75,7 @@ public class HSSFColor implements Color {
Integer index1 = Integer.valueOf(color.getIndex());
if (result.containsKey(index1)) {
HSSFColor prevColor = (HSSFColor)result.get(index1);
HSSFColor prevColor = result.get(index1);
throw new RuntimeException("Dup color index (" + index1
+ ") for colors (" + prevColor.getClass().getName()
+ "),(" + color.getClass().getName() + ")");

View File

@ -46,7 +46,7 @@ public class Code extends Fixed1ArgFunction {
return ErrorEval.VALUE_INVALID;
}
int code = (int)text.charAt(0);
int code = text.charAt(0);
return new StringEval(String.valueOf(code));
}

View File

@ -17,11 +17,14 @@
package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
* Implementation for Excel ImReal() function.<p/>

View File

@ -19,8 +19,6 @@
package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.*;
import org.apache.poi.ss.formula.functions.*;
import org.apache.poi.ss.formula.eval.*;
/**

View File

@ -182,7 +182,7 @@ public abstract class TextFunction implements Function {
* @return whether the character is printable
*/
private boolean isPrintable(char c){
int charCode = (int)c ;
int charCode = c;
return charCode >= 32;
}
};

View File

@ -130,7 +130,7 @@ public class FractionFormat extends Format {
if (exactDenom > 0){
fract = SimpleFraction.buildFractionExactDenominator(decPart, exactDenom);
} else {
fract = SimpleFraction.buildFractionMaxDenominator((double)decPart, maxDenom);
fract = SimpleFraction.buildFractionMaxDenominator(decPart, maxDenom);
}
} catch (RuntimeException e){
e.printStackTrace();

View File

@ -29,17 +29,17 @@ import java.util.Map;
*/
public class SheetReferences
{
Map map;
Map<Integer, String> map;
public SheetReferences()
{
map = new HashMap(5);
map = new HashMap<Integer, String>(5);
}
public void addSheetReference(String sheetName, int number) {
map.put(Integer.valueOf(number), sheetName);
map.put(number, sheetName);
}
public String getSheetName(int number) {
return (String)map.get(Integer.valueOf(number));
return map.get(number);
}
}