summaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-12-29 17:18:44 +0000
committerPJ Fanning <fanningpj@apache.org>2021-12-29 17:18:44 +0000
commitefe404a2c74acc7241fff63d57d2d04ebd101d5c (patch)
treee629f8b47bc71a396ad5d1f0415cac2e2372c272 /poi
parent2e52cb7452dae78ae4a0450ab939c3c29679a15d (diff)
downloadpoi-efe404a2c74acc7241fff63d57d2d04ebd101d5c.tar.gz
poi-efe404a2c74acc7241fff63d57d2d04ebd101d5c.zip
sonar issues
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896511 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java7
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java6
2 files changed, 7 insertions, 6 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java b/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java
index 2fdc7cb096..3eeea4eebe 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java
@@ -32,7 +32,7 @@ enum OperatorEnum {
NO_COMPARISON(OperatorEnum::noComp, false),
BETWEEN(OperatorEnum::between, false),
NOT_BETWEEN(OperatorEnum::notBetween, true),
- EQUAL(OperatorEnum::equal, false),
+ EQUAL(OperatorEnum::equalCheck, false),
NOT_EQUAL(OperatorEnum::notEqual, true),
GREATER_THAN(OperatorEnum::greaterThan, false),
LESS_THAN(OperatorEnum::lessThan, false),
@@ -111,7 +111,7 @@ enum OperatorEnum {
return cellValue.compareTo(v1) < 0 || cellValue.compareTo(v2) > 0;
}
- private static <C extends Comparable<C>> boolean equal(C cellValue, C v1, C v2) {
+ private static <C extends Comparable<C>> boolean equalCheck(C cellValue, C v1, C v2) {
if (v1 == null) {
if (cellValue instanceof Number) {
// use zero for null
@@ -121,8 +121,7 @@ enum OperatorEnum {
} else if (cellValue instanceof Boolean) return false;
return false; // just in case - not a typical possibility
}
- // need to avoid instanceof, to work around a 1.6 compiler bug
- if (cellValue.getClass() == String.class) {
+ if (cellValue instanceof String) {
return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0;
}
return cellValue.compareTo(v1) == 0;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java
index b8d6f51c83..fa21d33531 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java
@@ -114,7 +114,7 @@ public final class LookupUtils {
default Iterator<Integer> indexIterator() {
return new Iterator<Integer>() {
- int pos = 0;
+ private int pos = 0;
@Override
public boolean hasNext() {
@@ -123,7 +123,9 @@ public final class LookupUtils {
@Override
public Integer next() {
- return pos++;
+ pos++;
+ if (pos > getSize()) throw new NoSuchElementException();
+ return pos;
}
};
}