From 63b0cd28025c5cf9d3b2664c0b4afe80b57c0304 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Wed, 5 Jun 2013 02:03:07 +0000 Subject: [PATCH] fixed compatibility issues with JDK 1.5 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1489685 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/ss/formula/functions/Complex.java | 2 +- .../poi/ss/formula/functions/Quotient.java | 2 +- .../apache/poi/ss/formula/functions/Rept.java | 1 - .../poi/hwpf/model/UnhandledDataStructure.java | 16 +++++++++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/poi/ss/formula/functions/Complex.java b/src/java/org/apache/poi/ss/formula/functions/Complex.java index 171898112e..51c1770b1d 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Complex.java +++ b/src/java/org/apache/poi/ss/formula/functions/Complex.java @@ -70,7 +70,7 @@ public class Complex extends Var2or3ArgFunction implements FreeRefFunction { } String suffixValue = OperandResolver.coerceValueToString(suffix); - if (suffixValue.isEmpty()) { + if (suffixValue.length() == 0) { suffixValue = DEFAULT_SUFFIX; } if (suffixValue.equals(DEFAULT_SUFFIX.toUpperCase()) || suffixValue.equals(SUPPORTED_SUFFIX.toUpperCase())) { diff --git a/src/java/org/apache/poi/ss/formula/functions/Quotient.java b/src/java/org/apache/poi/ss/formula/functions/Quotient.java index b314f2f264..f1ed483ad5 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Quotient.java +++ b/src/java/org/apache/poi/ss/formula/functions/Quotient.java @@ -23,7 +23,7 @@ import org.apache.poi.ss.formula.eval.*; * @author cedric dot walter @ gmail dot com */ public class Quotient extends Fixed2ArgFunction { - @Override + public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval venumerator, ValueEval vedenominator) { double enumerator = 0; diff --git a/src/java/org/apache/poi/ss/formula/functions/Rept.java b/src/java/org/apache/poi/ss/formula/functions/Rept.java index a971e6b6d6..b93d96915d 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Rept.java +++ b/src/java/org/apache/poi/ss/formula/functions/Rept.java @@ -42,7 +42,6 @@ import java.math.BigDecimal; public class Rept extends Fixed2ArgFunction { - @Override public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval text, ValueEval number_times) { ValueEval veText1; diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java b/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java index 967f46e803..ac11f4b8b3 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/UnhandledDataStructure.java @@ -48,9 +48,23 @@ public final class UnhandledDataStructure } // Save that requested portion of the data - _buf = Arrays.copyOfRange(buf, offset, offsetEnd); + _buf = copyOfRange(buf, offset, offsetEnd); + } + /** + * YK: Arrays.copyOfRange is not in JDK 1.5 + */ + static byte[] copyOfRange(byte[] original, int from, int to) { + int newLength = to - from; + if (newLength < 0) + throw new IllegalArgumentException(from + " > " + to); + byte[] copy = new byte[newLength]; + System.arraycopy(original, from, copy, 0, + Math.min(original.length - from, newLength)); + return copy; + } + byte[] getBuf() { return _buf;