aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2017-09-16 08:21:28 +0000
committerDominik Stadler <centic@apache.org>2017-09-16 08:21:28 +0000
commit037800436a6998fbc0c20727a87e928e58a7b163 (patch)
tree011dd4c5ca80bfed01b0c74f20dc7aaab3b34ca6 /src/java
parentc2cf6e7a8ed14d14fdf31dc9df97f10602683c1f (diff)
downloadpoi-037800436a6998fbc0c20727a87e928e58a7b163.tar.gz
poi-037800436a6998fbc0c20727a87e928e58a7b163.zip
Let IntelliJ cleanup some code-warnings across the whole code-base: unnecessary casts
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808508 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/hssf/dev/FormulaViewer.java2
-rw-r--r--src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java2
-rw-r--r--src/java/org/apache/poi/hssf/model/InternalWorkbook.java2
-rw-r--r--src/java/org/apache/poi/hssf/record/EscherAggregate.java6
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java2
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java2
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java2
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java2
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java4
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/EntryUtils.java33
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java6
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java8
-rw-r--r--src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java4
-rw-r--r--src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java2
-rw-r--r--src/java/org/apache/poi/ss/usermodel/DateUtil.java4
15 files changed, 30 insertions, 51 deletions
diff --git a/src/java/org/apache/poi/hssf/dev/FormulaViewer.java b/src/java/org/apache/poi/hssf/dev/FormulaViewer.java
index 4bf221f4de..4ef3ede77a 100644
--- a/src/java/org/apache/poi/hssf/dev/FormulaViewer.java
+++ b/src/java/org/apache/poi/hssf/dev/FormulaViewer.java
@@ -185,7 +185,7 @@ public class FormulaViewer
private static String composeFormula(FormulaRecord record)
{
- return HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, record.getParsedExpression());
+ return HSSFFormulaParser.toFormulaString(null, record.getParsedExpression());
}
/**
diff --git a/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
index 107602d1c0..f5475507a5 100644
--- a/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
+++ b/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java
@@ -203,7 +203,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor implements or
thisRow = frec.getRow();
if(_formulasNotResults) {
- thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression());
+ thisText = HSSFFormulaParser.toFormulaString(null, frec.getParsedExpression());
} else {
if(frec.hasCachedResultString()) {
// Formula result is a string
diff --git a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java
index 9137e69843..72aa94696c 100644
--- a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java
+++ b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java
@@ -2169,7 +2169,7 @@ public final class InternalWorkbook {
sp.setShapeId(shapeId);
} else if (recordId == EscherOptRecord.RECORD_ID){
EscherOptRecord opt = (EscherOptRecord)shapeChildRecord;
- EscherSimpleProperty prop = (EscherSimpleProperty)opt.lookup(
+ EscherSimpleProperty prop = opt.lookup(
EscherProperties.BLIP__BLIPTODISPLAY );
if (prop != null){
int pictureIndex = prop.getPropertyValue();
diff --git a/src/java/org/apache/poi/hssf/record/EscherAggregate.java b/src/java/org/apache/poi/hssf/record/EscherAggregate.java
index 1fe343eb37..033b4a25a6 100644
--- a/src/java/org/apache/poi/hssf/record/EscherAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/EscherAggregate.java
@@ -522,7 +522,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
}
for (NoteRecord noteRecord : tailRec.values()) {
- Record rec = (Record) noteRecord;
+ Record rec = noteRecord;
pos += rec.serialize(pos, data);
}
int bytesWritten = pos - offset;
@@ -747,9 +747,9 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
*/
public void setMainSpRecordId(int shapeId) {
EscherContainerRecord dgContainer = getEscherContainer();
- EscherContainerRecord spgrConatiner = (EscherContainerRecord) dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER);
+ EscherContainerRecord spgrConatiner = dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER);
EscherContainerRecord spContainer = (EscherContainerRecord) spgrConatiner.getChild(0);
- EscherSpRecord sp = (EscherSpRecord) spContainer.getChildById(EscherSpRecord.RECORD_ID);
+ EscherSpRecord sp = spContainer.getChildById(EscherSpRecord.RECORD_ID);
sp.setShapeId(shapeId);
}
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
index 106da8b998..ac72b997ce 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
@@ -275,7 +275,7 @@ public final class ValueRecordsAggregate implements Iterable<CellValueRecordInte
short[] xfs = new short[nBlank];
for (int i = 0; i < xfs.length; i++) {
- xfs[i] = ((BlankRecord)cellValues[startIx + i]).getXFIndex();
+ xfs[i] = cellValues[startIx + i].getXFIndex();
}
int rowIx = cellValues[startIx].getRow();
return new MulBlankRecord(rowIx, startIx, xfs);
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
index ef66389c5c..c3d9fdafe2 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
@@ -247,7 +247,7 @@ public class HSSFPicture extends HSSFSimpleShape implements Picture {
* The filename of the embedded image
*/
public String getFileName() {
- EscherComplexProperty propFile = (EscherComplexProperty) getOptRecord().lookup(
+ EscherComplexProperty propFile = getOptRecord().lookup(
EscherProperties.BLIP__BLIPFILENAME);
return (null == propFile)
? ""
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
index 7898317e8d..6e029b2385 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java
@@ -174,7 +174,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
*/
public void applyFont(int startIndex, int endIndex, Font font)
{
- applyFont(startIndex, endIndex, ((HSSFFont) font).getIndex());
+ applyFont(startIndex, endIndex, font.getIndex());
}
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
index 08f304ad64..3a01126d43 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
@@ -2130,7 +2130,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
*/
@Override
public void setDefaultColumnStyle(int column, CellStyle style) {
- _sheet.setDefaultColumnStyle(column, ((HSSFCellStyle) style).getIndex());
+ _sheet.setDefaultColumnStyle(column, style.getIndex());
}
/**
diff --git a/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java b/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
index ccb008507b..b38881021b 100644
--- a/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
+++ b/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
@@ -69,7 +69,7 @@ public class DirectoryNode
final OPOIFSFileSystem filesystem,
final DirectoryNode parent)
{
- this(property, parent, filesystem, (NPOIFSFileSystem)null);
+ this(property, parent, filesystem, null);
}
/**
@@ -84,7 +84,7 @@ public class DirectoryNode
final NPOIFSFileSystem nfilesystem,
final DirectoryNode parent)
{
- this(property, parent, (OPOIFSFileSystem)null, nfilesystem);
+ this(property, parent, null, nfilesystem);
}
private DirectoryNode(final DirectoryProperty property,
diff --git a/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java b/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java
index 18140d9df8..3d9b9c6615 100644
--- a/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java
+++ b/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java
@@ -34,25 +34,19 @@ public class EntryUtils
*/
@Internal
public static void copyNodeRecursively( Entry entry, DirectoryEntry target )
- throws IOException
- {
+ throws IOException {
// logger.log( POILogger.ERROR, "copyNodeRecursively called with "+entry.getName()+
// ","+target.getName());
- DirectoryEntry newTarget = null;
- if ( entry.isDirectoryEntry() )
- {
+ if ( entry.isDirectoryEntry() ) {
DirectoryEntry dirEntry = (DirectoryEntry)entry;
- newTarget = target.createDirectory( entry.getName() );
+ DirectoryEntry newTarget = target.createDirectory( entry.getName() );
newTarget.setStorageClsid( dirEntry.getStorageClsid() );
Iterator<Entry> entries = dirEntry.getEntries();
- while ( entries.hasNext() )
- {
+ while ( entries.hasNext() ) {
copyNodeRecursively( entries.next(), newTarget );
}
- }
- else
- {
+ } else {
DocumentEntry dentry = (DocumentEntry) entry;
DocumentInputStream dstream = new DocumentInputStream( dentry );
target.createDocument( dentry.getName(), dstream );
@@ -69,28 +63,13 @@ public class EntryUtils
* is the target Directory to copy to
*/
public static void copyNodes(DirectoryEntry sourceRoot,
- DirectoryEntry targetRoot) throws IOException
- {
+ DirectoryEntry targetRoot) throws IOException {
for (Entry entry : sourceRoot) {
copyNodeRecursively( entry, targetRoot );
}
}
/**
- * Copies nodes from one Directory to the other minus the excepts
- *
- * @param filteredSource The filtering source Directory to copy from
- * @param filteredTarget The filtering target Directory to copy to
- */
- public static void copyNodes( FilteringDirectoryNode filteredSource,
- FilteringDirectoryNode filteredTarget ) throws IOException
- {
- // Nothing special here, just overloaded types to make the
- // recommended new way to handle this clearer
- copyNodes( (DirectoryEntry)filteredSource, (DirectoryEntry)filteredTarget );
- }
-
- /**
* Copies all nodes from one POIFS to the other
*
* @param source
diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
index 99a104ca80..fdd8647a72 100644
--- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
+++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
@@ -927,7 +927,7 @@ public class NPOIFSFileSystem extends BlockStore
{
if (preferArray())
{
- return (( POIFSViewable ) getRoot()).getViewableArray();
+ return getRoot().getViewableArray();
}
return new Object[ 0 ];
}
@@ -944,7 +944,7 @@ public class NPOIFSFileSystem extends BlockStore
{
if (!preferArray())
{
- return (( POIFSViewable ) getRoot()).getViewableIterator();
+ return getRoot().getViewableIterator();
}
return Collections.emptyList().iterator();
}
@@ -959,7 +959,7 @@ public class NPOIFSFileSystem extends BlockStore
public boolean preferArray()
{
- return (( POIFSViewable ) getRoot()).preferArray();
+ return getRoot().preferArray();
}
/**
diff --git a/src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java
index 0dc1798328..071288c2ac 100644
--- a/src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java
+++ b/src/java/org/apache/poi/poifs/filesystem/OPOIFSFileSystem.java
@@ -494,7 +494,7 @@ public class OPOIFSFileSystem
Property property = properties.next();
String name = property.getName();
DirectoryNode parent = (dir == null)
- ? (( DirectoryNode ) getRoot())
+ ? getRoot()
: dir;
if (property.isDirectory())
@@ -547,7 +547,7 @@ public class OPOIFSFileSystem
{
if (preferArray())
{
- return (( POIFSViewable ) getRoot()).getViewableArray();
+ return getRoot().getViewableArray();
}
return new Object[ 0 ];
}
@@ -564,7 +564,7 @@ public class OPOIFSFileSystem
{
if (!preferArray())
{
- return (( POIFSViewable ) getRoot()).getViewableIterator();
+ return getRoot().getViewableIterator();
}
return Collections.emptyList().iterator();
}
@@ -579,7 +579,7 @@ public class OPOIFSFileSystem
public boolean preferArray()
{
- return (( POIFSViewable ) getRoot()).preferArray();
+ return getRoot().preferArray();
}
/**
diff --git a/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java b/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
index 4b1fc7479e..8f418dba77 100644
--- a/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
+++ b/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
@@ -209,14 +209,14 @@ public final class OperationEvaluationContext {
SheetRangeEvaluator sre = new SheetRangeEvaluator(_sheetIndex, se);
// ugly typecast - TODO - make spreadsheet version more easily accessible
- SpreadsheetVersion ssVersion = ((FormulaParsingWorkbook)_workbook).getSpreadsheetVersion();
+ SpreadsheetVersion ssVersion = _workbook.getSpreadsheetVersion();
NameType part1refType = classifyCellReference(refStrPart1, ssVersion);
switch (part1refType) {
case BAD_CELL_OR_NAMED_RANGE:
return ErrorEval.REF_INVALID;
case NAMED_RANGE:
- EvaluationName nm = ((FormulaParsingWorkbook)_workbook).getName(refStrPart1, _sheetIndex);
+ EvaluationName nm = _workbook.getName(refStrPart1, _sheetIndex);
if(!nm.isRange()){
throw new RuntimeException("Specified name '" + refStrPart1 + "' is not a range as expected.");
}
diff --git a/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java b/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java
index 1dcf023b68..e7e300e5a3 100644
--- a/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java
+++ b/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java
@@ -191,7 +191,7 @@ public final class ArrayPtg extends Ptg {
throw new RuntimeException("Array item cannot be null");
}
if (o instanceof String) {
- return "\"" + (String)o + "\"";
+ return "\"" + o + "\"";
}
if (o instanceof Double) {
return NumberToTextConverter.toText(((Double)o).doubleValue());
diff --git a/src/java/org/apache/poi/ss/usermodel/DateUtil.java b/src/java/org/apache/poi/ss/usermodel/DateUtil.java
index 8483340393..ffaaa0f1ba 100644
--- a/src/java/org/apache/poi/ss/usermodel/DateUtil.java
+++ b/src/java/org/apache/poi/ss/usermodel/DateUtil.java
@@ -258,7 +258,7 @@ public class DateUtil {
* @return Java representation of the date, or null if date is not a valid Excel date
*/
public static Calendar getJavaCalendar(double date) {
- return getJavaCalendar(date, false, (TimeZone)null, false);
+ return getJavaCalendar(date, false, null, false);
}
/**
@@ -270,7 +270,7 @@ public class DateUtil {
* @return Java representation of the date, or null if date is not a valid Excel date
*/
public static Calendar getJavaCalendar(double date, boolean use1904windowing) {
- return getJavaCalendar(date, use1904windowing, (TimeZone)null, false);
+ return getJavaCalendar(date, use1904windowing, null, false);
}
/**