diff --git a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java index af2a1da2fb..bae9056c95 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java +++ b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java @@ -338,17 +338,17 @@ public class ToCSV { for(File excelFile : filesList) { // Open the workbook this.openWorkbook(excelFile); - + // Convert it's contents into a CSV file this.convertToCSV(); - + // Build the name of the csv folder from that of the Excel workbook. // Simply replace the .xls or .xlsx file extension with .csv destinationFilename = excelFile.getName(); destinationFilename = destinationFilename.substring( 0, destinationFilename.lastIndexOf(".")) + ToCSV.CSV_FILE_EXTENSION; - + // Save the CSV file away using the newly constricted file name // and to the specified directory. this.saveCSVFile(new File(destination, destinationFilename)); @@ -649,7 +649,7 @@ public class ToCSV { // passed to the main method. converter.convertExcelToCSV(args[0], args[1]); } - else if(args.length == 3){ + else if(args.length == 3) { // The Source File/Folder, Destination Folder and Separator // were passed to the main method. converter.convertExcelToCSV(args[0], args[1], args[2]); @@ -699,9 +699,9 @@ public class ToCSV { ex.printStackTrace(System.out); converted = false; } - + if (converted) { - System.out.println("Conversion took " + + System.out.println("Conversion took " + ((System.currentTimeMillis() - startTime)/1000) + " seconds"); } } @@ -711,7 +711,7 @@ public class ToCSV { * be a call to the listFiles() method when made on an instance of the * File class and that object refers to a folder/directory */ - class ExcelFilenameFilter implements FilenameFilter { + static class ExcelFilenameFilter implements FilenameFilter { /** * Determine those files that will be returned by a call to the diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 84d13ca0b9..c47cc1c6ac 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -63,7 +63,6 @@ import org.apache.poi.ss.formula.ptg.UnionPtg; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellRange; import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationHelper; import org.apache.poi.ss.usermodel.Row; @@ -1452,15 +1451,15 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * Sets desktop window pane display area, when the * file is first opened in a viewer. * - * @param toprow the top row to show in desktop window pane - * @param leftcol the left column to show in desktop window pane + * @param topRow the top row to show in desktop window pane + * @param leftCol the left column to show in desktop window pane */ @Override - public void showInPane(int toprow, int leftcol) { + public void showInPane(int topRow, int leftCol) { int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex(); - if (toprow > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow); + if (topRow > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow); - showInPane((short)toprow, (short)leftcol); + showInPane((short) topRow, (short) leftCol); } /** * Sets desktop window pane display area, when the @@ -1748,11 +1747,10 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * For n < 0, it will shift columns left. * Additionally adjusts formulas. * Probably should also process other features (hyperlinks, comments...) in the way analog to shiftRows method - * @param startRow the row to start shifting - * @param endRow the row to end shifting - * @param n the number of rows to shift + * @param startColumn the column to start shifting + * @param endColumn the column to end shifting + * @param n the number of columns to shift */ - @Beta @Override public void shiftColumns(int startColumn, int endColumn, int n){ @@ -2454,9 +2452,9 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { for (Object object : container.getChildren()) { HSSFShape shape = (HSSFShape) object; if (shape instanceof HSSFShapeGroup) { - HSSFShape res = lookForComment((HSSFShapeContainer) shape, row, column); + HSSFComment res = lookForComment((HSSFShapeContainer) shape, row, column); if (null != res) { - return (HSSFComment) res; + return res; } continue; } diff --git a/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java b/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java index 12654a7944..45c9b92f68 100644 --- a/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java +++ b/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java @@ -176,7 +176,6 @@ public class CellElapsedFormatter extends CellFormatter { case 'h': return 24; case 'm': - return 60; case 's': return 60; case '0': diff --git a/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java b/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java index 926a0a1854..65ef78c205 100644 --- a/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java +++ b/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java @@ -28,10 +28,10 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.util.Internal; /** - * Manages a collection of {@link WorkbookEvaluator}s, in order to support + * Manages a collection of {@link WorkbookEvaluator}s, in order to support * evaluation of formulas across spreadsheets. * - *
For POI internal use only - use
+ *For POI internal use only - use
*/ @Internal public final class CollaboratingWorkbooksEnvironment { @@ -70,8 +70,8 @@ public final class CollaboratingWorkbooksEnvironment { if (evaluatorsByName.size() < 1) { throw new IllegalArgumentException("Must provide at least one collaborating worbook"); } - WorkbookEvaluator[] evaluators = - evaluatorsByName.values().toArray(new WorkbookEvaluator[0]); + WorkbookEvaluator[] evaluators = + evaluatorsByName.values().toArray(new WorkbookEvaluator[0]); new CollaboratingWorkbooksEnvironment(evaluatorsByName, evaluators); } public static void setupFormulaEvaluator(Map
@@ -266,7 +266,7 @@ public interface Sheet extends Iterablenull
to remove protection
*/
- public void protectSheet(String password);
+ void protectSheet(String password);
/**
* Answer whether scenario protection is enabled or disabled
@@ -642,7 +642,7 @@ public interface Sheet extends IterableA1
.
@@ -1181,7 +1181,7 @@ public interface Sheet extends IterableA1
.
* @since 3.14beta1
*/
- public void setActiveCell(CellAddress address);
+ void setActiveCell(CellAddress address);
}
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java b/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
index dbdd5c0a14..d972476d63 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
@@ -35,6 +35,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.SecureRandom;
@@ -381,7 +382,7 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
xo.setSaveNoXmlDecl();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
- bos.write("\r\n".getBytes("UTF-8"));
+ bos.write("\r\n".getBytes(StandardCharsets.UTF_8));
ed.save(bos, xo);
bos.writeTo(os);
} catch (IOException e) {
diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
index c7dbc40afe..2139111f5d 100644
--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
@@ -915,13 +915,13 @@ public class SXSSFSheet implements Sheet
* Sets desktop window pane display area, when the
* file is first opened in a viewer.
*
- * @param toprow the top row to show in desktop window pane
- * @param leftcol the left column to show in desktop window pane
+ * @param topRow the top row to show in desktop window pane
+ * @param leftCol the left column to show in desktop window pane
*/
@Override
- public void showInPane(int toprow, int leftcol)
+ public void showInPane(int topRow, int leftCol)
{
- _sh.showInPane(toprow, leftcol);
+ _sh.showInPane(topRow, leftCol);
}
/**
diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
index 30a9c4ec62..560dae8c23 100644
--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
@@ -29,6 +29,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
+import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Cell;
@@ -103,7 +104,7 @@ public class SheetDataWriter implements Closeable {
throw e;
}
return new BufferedWriter(
- new OutputStreamWriter(decorated, "UTF-8"));
+ new OutputStreamWriter(decorated, StandardCharsets.UTF_8));
}
/**
@@ -113,7 +114,7 @@ public class SheetDataWriter implements Closeable {
*
* @param fos the stream to decorate
* @return a decorated stream
- * @throws IOException
+ * @throws IOException if decorating the stream fails
* @see #decorateInputStream(FileInputStream)
*/
protected OutputStream decorateOutputStream(FileOutputStream fos) throws IOException {
@@ -154,7 +155,7 @@ public class SheetDataWriter implements Closeable {
*
* @param fis the stream to decorate
* @return a decorated stream
- * @throws IOException
+ * @throws IOException if decorating the stream fails
* @see #decorateOutputStream(FileOutputStream)
*/
protected InputStream decorateInputStream(FileInputStream fis) throws IOException {
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
index cc29353371..dcbe55cbd2 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
@@ -267,6 +267,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
for (CTRow row : worksheetParam.getSheetData().getRowArray()) {
XSSFRow r = new XSSFRow(row, this);
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
+ //noinspection UnnecessaryBoxing
final Integer rownumI = Integer.valueOf(r.getRowNum()); // NOSONAR
_rows.put(rownumI, r);
}
@@ -756,6 +757,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
@Override
public XSSFRow createRow(int rownum) {
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
+ //noinspection UnnecessaryBoxing
final Integer rownumI = Integer.valueOf(rownum); // NOSONAR
CTRow ctRow;
XSSFRow prev = _rows.get(rownumI);
@@ -1073,7 +1075,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
@Override
public boolean isDisplayZeros(){
final CTSheetView dsv = getDefaultSheetView(false);
- return (dsv != null) ? dsv.getShowZeros() : true;
+ return (dsv == null) || dsv.getShowZeros();
}
/**
@@ -1380,7 +1382,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
if (pane.isSetTopLeftCell()) {
final CellReference cellRef = new CellReference(pane.getTopLeftCell());
row = (short)cellRef.getRow();
- col = (short)cellRef.getCol();
+ col = cellRef.getCol();
}
final short x = (short)pane.getXSplit();
@@ -1477,6 +1479,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
@Override
public XSSFRow getRow(int rownum) {
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
+ //noinspection UnnecessaryBoxing
final Integer rownumI = Integer.valueOf(rownum); // NOSONAR
return _rows.get(rownumI);
}
@@ -1509,7 +1512,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
}
else {
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
+ //noinspection UnnecessaryBoxing
final Integer startI = Integer.valueOf(startRowNum); // NOSONAR
+ //noinspection UnnecessaryBoxing
final Integer endI = Integer.valueOf(endRowNum+1); // NOSONAR
final Collection