You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2017/09/16 08:29:21 UTC
svn commit: r1808522 - in /poi/trunk/src: java/org/apache/poi/ddf/
java/org/apache/poi/ss/formula/ java/org/apache/poi/ss/util/
ooxml/java/org/apache/poi/xssf/util/
scratchpad/src/org/apache/poi/hsmf/datatypes/
scratchpad/src/org/apache/poi/hsmf/dev/ s...
Author: centic
Date: Sat Sep 16 08:29:20 2017
New Revision: 1808522
URL: http://svn.apache.org/viewvc?rev=1808522&view=rev
Log:
Use Integer.compare() where possible
Modified:
poi/trunk/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java
poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
poi/trunk/src/java/org/apache/poi/ss/util/NumberComparer.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/dev/TypesLister.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/FieldsImpl.java
poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java
Modified: poi/trunk/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java Sat Sep 16 08:29:20 2017
@@ -142,7 +142,7 @@ public abstract class AbstractEscherOptR
{
short s1 = p1.getPropertyNumber();
short s2 = p2.getPropertyNumber();
- return s1 < s2 ? -1 : s1 == s2 ? 0 : 1;
+ return Short.compare(s1, s2);
}
} );
}
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java Sat Sep 16 08:29:20 2017
@@ -242,16 +242,16 @@ public class EvaluationConditionalFormat
final int x = getPriority();
final int y = o.getPriority();
// logic from Integer.compare()
- cmp = (x < y) ? -1 : ((x == y) ? 0 : 1);
+ cmp = Integer.compare(x, y);
if (cmp != 0) {
return cmp;
}
- cmp = new Integer(getFormattingIndex()).compareTo(new Integer(o.getFormattingIndex()));
+ cmp = Integer.compare(getFormattingIndex(), o.getFormattingIndex());
if (cmp != 0) {
return cmp;
}
- return new Integer(getRuleIndex()).compareTo(new Integer(o.getRuleIndex()));
+ return Integer.compare(getRuleIndex(), o.getRuleIndex());
}
@Override
Modified: poi/trunk/src/java/org/apache/poi/ss/util/NumberComparer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/NumberComparer.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/NumberComparer.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/NumberComparer.java Sat Sep 16 08:29:20 2017
@@ -131,7 +131,7 @@ public final class NumberComparer {
* If both numbers are subnormal, Excel seems to use standard comparison rules
*/
private static int compareSubnormalNumbers(long fracA, long fracB, boolean isNegative) {
- int cmp = fracA > fracB ? +1 : fracA < fracB ? -1 : 0;
+ int cmp = Long.compare(fracA, fracB);
return isNegative ? -cmp : cmp;
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/CTColComparator.java Sat Sep 16 08:29:20 2017
@@ -30,7 +30,7 @@ public class CTColComparator {
public int compare(CTCol col1, CTCol col2) {
long col1max = col1.getMax();
long col2max = col2.getMax();
- return col1max < col2max ? -1 : col1max > col2max ? 1 : 0;
+ return Long.compare(col1max, col2max);
}
};
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java Sat Sep 16 08:29:20 2017
@@ -222,13 +222,7 @@ public final class RecipientChunks imple
implements Comparator<RecipientChunks>, Serializable {
@Override
public int compare(RecipientChunks a, RecipientChunks b) {
- if (a.recipientNumber < b.recipientNumber) {
- return -1;
- }
- if (a.recipientNumber > b.recipientNumber) {
- return +1;
- }
- return 0;
+ return Integer.compare(a.recipientNumber, b.recipientNumber);
}
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/dev/TypesLister.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/dev/TypesLister.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/dev/TypesLister.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/dev/TypesLister.java Sat Sep 16 08:29:20 2017
@@ -43,9 +43,7 @@ public class TypesLister {
ArrayList<MAPIProperty> all = new ArrayList<>(MAPIProperty.getAll());
Collections.sort(all, new Comparator<MAPIProperty>() {
public int compare(MAPIProperty a, MAPIProperty b) {
- if(a.id < b.id) return -1;
- if(a.id > b.id) return +1;
- return 0;
+ return Integer.compare(a.id, b.id);
}
});
list(all, out);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java Sat Sep 16 08:29:20 2017
@@ -102,7 +102,7 @@ public abstract class AbstractWordConver
public int compareTo( Structure o )
{
- return start < o.start ? -1 : start == o.start ? 0 : 1;
+ return Integer.compare(start, o.start);
}
@Override
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java Sat Sep 16 08:29:20 2017
@@ -43,8 +43,7 @@ public abstract class PropertyNode<T ext
public int compare(PropertyNode<?> o1, PropertyNode<?> o2) {
int thisVal = o1.getEnd();
int anotherVal = o2.getEnd();
- return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0
- : 1));
+ return (Integer.compare(thisVal, anotherVal));
}
}
@@ -55,8 +54,7 @@ public abstract class PropertyNode<T ext
public int compare(PropertyNode<?> o1, PropertyNode<?> o2) {
int thisVal = o1.getStart();
int anotherVal = o2.getStart();
- return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0
- : 1));
+ return (Integer.compare(thisVal, anotherVal));
}
}
@@ -175,12 +173,6 @@ public abstract class PropertyNode<T ext
*/
public int compareTo(T o) {
int cpEnd = o.getEnd();
- if (_cpEnd == cpEnd) {
- return 0;
- } else if (_cpEnd < cpEnd) {
- return -1;
- } else {
- return 1;
- }
+ return Integer.compare(_cpEnd, cpEnd);
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java Sat Sep 16 08:29:20 2017
@@ -449,15 +449,8 @@ public class TextPieceTable implements C
protected static class FCComparator implements Comparator<TextPiece>, Serializable {
public int compare(TextPiece textPiece, TextPiece textPiece1) {
- if (textPiece.getPieceDescriptor().fc > textPiece1
- .getPieceDescriptor().fc) {
- return 1;
- } else if (textPiece.getPieceDescriptor().fc < textPiece1
- .getPieceDescriptor().fc) {
- return -1;
- } else {
- return 0;
- }
+ return Integer.compare(textPiece.getPieceDescriptor().fc, textPiece1
+ .getPieceDescriptor().fc);
}
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/FieldsImpl.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/FieldsImpl.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/FieldsImpl.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/FieldsImpl.java Sat Sep 16 08:29:20 2017
@@ -267,7 +267,7 @@ public class FieldsImpl implements Field
{
int thisVal = o1.getFcStart();
int anotherVal = o2.getFcStart();
- return thisVal < anotherVal ? -1 : thisVal == anotherVal ? 0 : 1;
+ return Integer.compare(thisVal, anotherVal);
}
}
Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java?rev=1808522&r1=1808521&r2=1808522&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java Sat Sep 16 08:29:20 2017
@@ -93,7 +93,7 @@ public final class TestNumberComparer {
private static boolean confirm(int i, double a, double b, int expRes) {
int actRes = NumberComparer.compare(a, b);
- int sgnActRes = actRes < 0 ? -1 : actRes > 0 ? +1 : 0;
+ int sgnActRes = Integer.compare(actRes, 0);
if (sgnActRes != expRes) {
System.err.println("Mismatch example[" + i + "] ("
+ formatDoubleAsHex(a) + ", " + formatDoubleAsHex(b) + ") expected "
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org