aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/ss
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2020-05-16 13:06:20 +0000
committerDominik Stadler <centic@apache.org>2020-05-16 13:06:20 +0000
commitc61cd6fa03f519eb706e1e3efa3cdf742c5aae29 (patch)
tree6547bf11e6fd6bda9a096e14971eb8a28e4b8581 /src/java/org/apache/poi/ss
parenteb497bac7901dff141f614b57ce7794a7fda44a5 (diff)
downloadpoi-c61cd6fa03f519eb706e1e3efa3cdf742c5aae29.tar.gz
poi-c61cd6fa03f519eb706e1e3efa3cdf742c5aae29.zip
Fix some IDE warnings, make lock-objects final, use generics, remove unused allocated fields to reduce memory overhead of DocumentInputStream
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1877818 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/ss')
-rw-r--r--src/java/org/apache/poi/ss/formula/functions/DateValue.java6
-rw-r--r--src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java11
2 files changed, 9 insertions, 8 deletions
diff --git a/src/java/org/apache/poi/ss/formula/functions/DateValue.java b/src/java/org/apache/poi/ss/formula/functions/DateValue.java
index f513237abe..ea62ee156d 100644
--- a/src/java/org/apache/poi/ss/formula/functions/DateValue.java
+++ b/src/java/org/apache/poi/ss/formula/functions/DateValue.java
@@ -101,10 +101,10 @@ public class DateValue extends Fixed1ArgFunction {
groups.add(matchResult.group(i));
}
int year = format.hasYear
- ? Integer.valueOf(groups.get(format.yearIndex))
+ ? Integer.parseInt(groups.get(format.yearIndex))
: LocalDate.now(LocaleUtil.getUserTimeZone().toZoneId()).getYear();
int month = parseMonth(groups.get(format.monthIndex));
- int day = Integer.valueOf(groups.get(format.dayIndex));
+ int day = Integer.parseInt(groups.get(format.dayIndex));
return new NumberEval(DateUtil.getExcelDate(LocalDate.of(year, month, day)));
}
@@ -120,7 +120,7 @@ public class DateValue extends Fixed1ArgFunction {
private int parseMonth(String monthPart) {
try {
- return Integer.valueOf(monthPart);
+ return Integer.parseInt(monthPart);
} catch (NumberFormatException ignored) {
}
diff --git a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
index 450d21232c..ad5a8446ea 100644
--- a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
+++ b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
@@ -53,8 +53,9 @@ public abstract class WorkbookFactory {
Workbook apply(T t, U u) throws IOException;
}
- private static Object hssfLock = new Object();
- private static Object xssfLock = new Object();
+ private static final Object hssfLock = new Object();
+ private static final Object xssfLock = new Object();
+
protected static CreateWorkbook0 createHssfFromScratch;
protected static CreateWorkbook1<DirectoryNode> createHssfByNode;
@@ -338,7 +339,7 @@ public abstract class WorkbookFactory {
synchronized (xssfLock) {
if (createXssfFromScratch == null) {
String factoryClass = "org.apache.poi.xssf.usermodel.XSSFWorkbookFactory";
- Class cls = initFactory(factoryClass, "poi-ooxml-*.jar");
+ Class<?> cls = initFactory(factoryClass, "poi-ooxml-*.jar");
try {
cls.getMethod("init").invoke(null);
} catch (Exception e) {
@@ -355,7 +356,7 @@ public abstract class WorkbookFactory {
synchronized (hssfLock) {
if (createHssfFromScratch == null) {
String factoryClass = "org.apache.poi.hssf.usermodel.HSSFWorkbookFactory";
- Class cls = initFactory(factoryClass, "poi-*.jar");
+ Class<?> cls = initFactory(factoryClass, "poi-*.jar");
try {
cls.getMethod("init").invoke(null);
} catch (Exception e) {
@@ -366,7 +367,7 @@ public abstract class WorkbookFactory {
}
}
- private static Class initFactory(String factoryClass, String jar) throws IOException {
+ private static Class<?> initFactory(String factoryClass, String jar) throws IOException {
try {
return Class.forName(factoryClass, true, WorkbookFactory.class.getClassLoader());
} catch (ClassNotFoundException e) {