aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2014-02-09 21:19:20 +0000
committerAndreas Beeker <kiwiwings@apache.org>2014-02-09 21:19:20 +0000
commit4b9d47af5a000ad70e8befdac6a27164f122e1b6 (patch)
tree30c3a90ba5d7bbf414d3cbc92f009c9fe09c2e2c /src/scratchpad
parent71d856448e1ccc41cf80a40d172d09b9ea502dae (diff)
downloadpoi-4b9d47af5a000ad70e8befdac6a27164f122e1b6.tar.gz
poi-4b9d47af5a000ad70e8befdac6a27164f122e1b6.zip
FindBugs fix
- fixed "Class defines equals() and uses Object.hashCode()" - see http://findbugs.sourceforge.net/bugDescriptions.html#HE_EQUALS_USE_HASHCODE - implemented UnicodeString.ExtRst.hashCode() + junit-test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1566427 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/Ffn.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java9
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/ParagraphHeight.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/SectionDescriptor.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java9
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/UPX.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/usermodel/BorderCode.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/usermodel/DateAndTime.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/usermodel/LineSpacingDescriptor.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java8
15 files changed, 108 insertions, 5 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/Ffn.java b/src/scratchpad/src/org/apache/poi/hwpf/model/Ffn.java
index e4b4e61f4d..6c8666f7aa 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/Ffn.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/Ffn.java
@@ -181,7 +181,8 @@ public final class Ffn
}
- public boolean equals(Object o)
+ @Override
+ public boolean equals(Object o)
{
boolean retVal = true;
@@ -227,6 +228,11 @@ public final class Ffn
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
index 55bad615a0..0abd236a07 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
@@ -137,6 +137,7 @@ public final class FontTable
}
+ @Override
public boolean equals(Object o)
{
boolean retVal = true;
@@ -162,8 +163,10 @@ public final class FontTable
return retVal;
}
-
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}
-
-
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java b/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
index 7bdd1fcd9a..3de08d8d43 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
@@ -101,6 +101,7 @@ public final class ListLevel
_xst = new Xst(numberText);
}
+ @Override
public boolean equals( Object obj )
{
if ( obj == null )
@@ -113,6 +114,12 @@ public final class ListLevel
&& lvl._xst.equals( this._xst );
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
/**
* "Alignment (left, right, or centered) of the paragraph number."
*/
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java
index bfaa8a9e31..837b83b97f 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java
@@ -155,6 +155,7 @@ public final class PAPX extends BytePropertyNode<PAPX> {
return props;
}
+ @Override
public boolean equals(Object o)
{
if (super.equals(o))
@@ -164,6 +165,12 @@ public final class PAPX extends BytePropertyNode<PAPX> {
return false;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public String toString()
{
return "PAPX from " + getStart() + " to " + getEnd() + " (in bytes "
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/ParagraphHeight.java b/src/scratchpad/src/org/apache/poi/hwpf/model/ParagraphHeight.java
index 993f1a21b6..8cff9a5c64 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/ParagraphHeight.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/ParagraphHeight.java
@@ -81,4 +81,11 @@ public final class ParagraphHeight
return infoField == ph.infoField && reserved == ph.reserved &&
dxaCol == ph.dxaCol && dymLineOrHeight == ph.dymLineOrHeight;
}
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java
index 4e1c0ce73f..ccf56cfe05 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java
@@ -64,6 +64,7 @@ public final class SEPX extends PropertyNode<SEPX>
return sectionProperties;
}
+ @Override
public boolean equals( Object o )
{
SEPX sepx = (SEPX) o;
@@ -74,6 +75,12 @@ public final class SEPX extends PropertyNode<SEPX>
return false;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public String toString()
{
return "SEPX from " + getStart() + " to " + getEnd();
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/SectionDescriptor.java b/src/scratchpad/src/org/apache/poi/hwpf/model/SectionDescriptor.java
index 0486fa8517..bdddac7f3e 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/SectionDescriptor.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/SectionDescriptor.java
@@ -77,12 +77,19 @@ public final class SectionDescriptor
this.fcSepx = fc;
}
+ @Override
public boolean equals(Object o)
{
SectionDescriptor sed = (SectionDescriptor)o;
return sed.fn == fn && sed.fnMpr == fnMpr;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public byte[] toByteArray()
{
int offset = 0;
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java b/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
index c6891a7e3d..98df05f956 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
@@ -174,6 +174,8 @@ public final class StyleSheet implements HDFType {
}
}
}
+
+ @Override
public boolean equals(Object o)
{
StyleSheet ss = (StyleSheet)o;
@@ -199,6 +201,13 @@ public final class StyleSheet implements HDFType {
}
return false;
}
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
/**
* Creates a PartagraphProperties object from a papx stored in the
* StyleDescription at the index istd in the StyleDescription array. The PAP
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java b/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
index 42e4b3793d..0c3e8c3725 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
@@ -201,6 +201,7 @@ public class TextPiece extends PropertyNode<TextPiece>
return (getEnd() - getStart()) * (_usesUnicode ? 2 : 1);
}
+ @Override
public boolean equals(Object o)
{
if (limitsAreEqual(o))
@@ -212,6 +213,12 @@ public class TextPiece extends PropertyNode<TextPiece>
return false;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
/**
* Returns the character position we start at.
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/UPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/UPX.java
index 69214348c6..95dd00bc30 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/UPX.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/UPX.java
@@ -40,12 +40,19 @@ public final class UPX
return _upx.length;
}
+ @Override
public boolean equals(Object o)
{
UPX upx = (UPX)o;
return Arrays.equals(_upx, upx._upx);
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
@Override
public String toString()
{
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java b/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java
index a41b525a2c..440c666403 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmBuffer.java
@@ -150,12 +150,20 @@ public final class SprmBuffer implements Cloneable
_buf = newBuf;
}
}
+
+ @Override
public boolean equals(Object obj)
{
SprmBuffer sprmBuf = (SprmBuffer)obj;
return (Arrays.equals(_buf, sprmBuf._buf));
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public SprmOperation findSprm( short opcode )
{
int operation = SprmOperation.getOperationFromOpcode( opcode );
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/BorderCode.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/BorderCode.java
index 4526c052fa..47e3b352f9 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/BorderCode.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/BorderCode.java
@@ -68,12 +68,19 @@ public final class BorderCode implements Cloneable {
return _info == 0 && _info2 == 0 || _info == -1;
}
+ @Override
public boolean equals(Object o)
{
BorderCode brc = (BorderCode)o;
return _info == brc._info && _info2 == brc._info2;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public Object clone()
throws CloneNotSupportedException
{
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/DateAndTime.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/DateAndTime.java
index be988043b3..9000cc1ec8 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/DateAndTime.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/DateAndTime.java
@@ -72,12 +72,19 @@ public final class DateAndTime
LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE, _info2);
}
+ @Override
public boolean equals(Object o)
{
DateAndTime dttm = (DateAndTime)o;
return _info == dttm._info && _info2 == dttm._info2;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public Object clone()
throws CloneNotSupportedException
{
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/LineSpacingDescriptor.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/LineSpacingDescriptor.java
index 94c8f0eb16..e327f039ce 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/LineSpacingDescriptor.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/LineSpacingDescriptor.java
@@ -71,6 +71,8 @@ public final class LineSpacingDescriptor
{
_dyaLine = dyaLine;
}
+
+ @Override
public boolean equals(Object o)
{
LineSpacingDescriptor lspd = (LineSpacingDescriptor)o;
@@ -78,6 +80,12 @@ public final class LineSpacingDescriptor
return _dyaLine == lspd._dyaLine && _fMultiLinespace == lspd._fMultiLinespace;
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
public boolean isEmpty()
{
return _dyaLine == 0 && _fMultiLinespace == 0;
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java
index 776015cc7f..8205e6be5d 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/SectionProperties.java
@@ -45,7 +45,8 @@ public final class SectionProperties extends SEPAbstractType
return copy;
}
-
+
+ @Override
public boolean equals( Object obj )
{
Field[] fields = SectionProperties.class.getSuperclass()
@@ -74,4 +75,9 @@ public final class SectionProperties extends SEPAbstractType
}
}
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
}