Skip to content

Commit

Permalink
FindBugs fix
Browse files Browse the repository at this point in the history
- fixed "Equals method should not assume anything about the type of its argument"
- see http://findbugs.sourceforge.net/bugDescriptions.html#BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1568861 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
kiwiwings committed Feb 16, 2014
1 parent c144310 commit 2cfc8db
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
Expand Up @@ -83,9 +83,8 @@ public void serialize(LittleEndianOutput out) {


@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof GUID)) return false;
GUID other = (GUID) obj; GUID other = (GUID) obj;
if (obj == null || !(obj instanceof GUID))
return false;
return _d1 == other._d1 && _d2 == other._d2 return _d1 == other._d1 && _d2 == other._d2
&& _d3 == other._d3 && _d4 == other._d4; && _d3 == other._d3 && _d4 == other._d4;
} }
Expand Down
3 changes: 2 additions & 1 deletion src/java/org/apache/poi/poifs/filesystem/Ole10Native.java
Expand Up @@ -98,7 +98,8 @@ public static Ole10Native createFromEmbeddedOleObject(DirectoryNode directory) t
DocumentEntry nativeEntry = DocumentEntry nativeEntry =
(DocumentEntry)directory.getEntry(OLE10_NATIVE); (DocumentEntry)directory.getEntry(OLE10_NATIVE);
byte[] data = new byte[nativeEntry.getSize()]; byte[] data = new byte[nativeEntry.getSize()];
directory.createDocumentInputStream(nativeEntry).read(data); int readBytes = directory.createDocumentInputStream(nativeEntry).read(data);
assert(readBytes == data.length);


return new Ole10Native(data, 0); return new Ole10Native(data, 0);
} }
Expand Down
6 changes: 3 additions & 3 deletions src/java/org/apache/poi/ss/format/CellNumberFormatter.java
Expand Up @@ -16,8 +16,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more
==================================================================== */ ==================================================================== */
package org.apache.poi.ss.format; package org.apache.poi.ss.format;


import org.apache.poi.ss.format.CellFormatPart.PartHandler;

import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.FieldPosition; import java.text.FieldPosition;
import java.util.BitSet; import java.util.BitSet;
Expand All @@ -31,6 +29,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import java.util.TreeSet; import java.util.TreeSet;
import java.util.regex.Matcher; import java.util.regex.Matcher;


import org.apache.poi.ss.format.CellFormatPart.PartHandler;

/** /**
* This class implements printing out a value using a number format. * This class implements printing out a value using a number format.
* *
Expand Down Expand Up @@ -658,7 +658,7 @@ public void formatValue(StringBuffer toAppendTo, Object valueObject) {
delEndPos + adjust; // delete end point in current delEndPos + adjust; // delete end point in current


if (modPos < modEndPos) { if (modPos < modEndPos) {
if (nextChange.toAdd == "") if ("".equals(nextChange.toAdd))
output.delete(modPos, modEndPos); output.delete(modPos, modEndPos);
else { else {
char fillCh = nextChange.toAdd.charAt(0); char fillCh = nextChange.toAdd.charAt(0);
Expand Down
2 changes: 1 addition & 1 deletion src/resources/devtools/findbugs-filters.xml
Expand Up @@ -19,6 +19,6 @@
--> -->
<FindBugsFilter> <FindBugsFilter>
<Match> <Match>
<Bug pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE,MS_PKGPROTECT,MS_MUTABLE_ARRAY"/> <Bug code="EI,EI2" pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE,MS_PKGPROTECT,MS_MUTABLE_ARRAY"/>
</Match> </Match>
</FindBugsFilter> </FindBugsFilter>
Expand Up @@ -44,10 +44,7 @@ public ListFormatOverrideLevel( byte[] buf, int offset )


public boolean equals( Object obj ) public boolean equals( Object obj )
{ {
if ( obj == null ) if (!(obj instanceof ListFormatOverrideLevel)) return false;
{
return false;
}
ListFormatOverrideLevel lfolvl = (ListFormatOverrideLevel) obj; ListFormatOverrideLevel lfolvl = (ListFormatOverrideLevel) obj;
boolean lvlEquality = false; boolean lvlEquality = false;
if ( _lvl != null ) if ( _lvl != null )
Expand Down
3 changes: 1 addition & 2 deletions src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
Expand Up @@ -104,8 +104,7 @@ public ListLevel( int startAt, int numberFormatCode, int alignment,
@Override @Override
public boolean equals( Object obj ) public boolean equals( Object obj )
{ {
if ( obj == null ) if (!(obj instanceof ListLevel)) return false;
return false;


ListLevel lvl = (ListLevel) obj; ListLevel lvl = (ListLevel) obj;
return lvl._lvlf.equals( this._lvlf ) return lvl._lvlf.equals( this._lvlf )
Expand Down
1 change: 1 addition & 0 deletions src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java
Expand Up @@ -67,6 +67,7 @@ public SectionProperties getSectionProperties()
@Override @Override
public boolean equals( Object o ) public boolean equals( Object o )
{ {
if (!(o instanceof SEPX)) return false;
SEPX sepx = (SEPX) o; SEPX sepx = (SEPX) o;
if ( super.equals( o ) ) if ( super.equals( o ) )
{ {
Expand Down

0 comments on commit 2cfc8db

Please sign in to comment.