From: Rainer Klute Date: Sun, 15 Aug 2004 13:43:35 +0000 (+0000) Subject: Fixed a bug where the logical comparison of two sections returned false only because... X-Git-Tag: PERF_BEFORE_MERGE~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=14befc7fea60ad714815b35afb75105458b819e3;p=poi.git Fixed a bug where the logical comparison of two sections returned false only because one of them had property 1 (codepage) and the other had not. Now two sections are equal if their property values are equal disregarding property 1. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353583 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hpsf/PropertySet.java b/src/java/org/apache/poi/hpsf/PropertySet.java index 30b6823922..8095ab19a7 100644 --- a/src/java/org/apache/poi/hpsf/PropertySet.java +++ b/src/java/org/apache/poi/hpsf/PropertySet.java @@ -673,7 +673,7 @@ public class PropertySet b.append(getOSVersion()); b.append(", sectionCount: "); b.append(sectionCount); - b.append(", sections: ["); + b.append(", sections: [\n"); final List sections = getSections(); for (int i = 0; i < sectionCount; i++) b.append(((Section) sections.get(0)).toString()); diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java index fd9e020c4a..913fc9116b 100644 --- a/src/java/org/apache/poi/hpsf/Section.java +++ b/src/java/org/apache/poi/hpsf/Section.java @@ -448,7 +448,24 @@ public class Section /** - *

Checks whether this section is equal to another object.

+ *

Checks whether this section is equal to another object. The result is + * false if one of the the following conditions holds:

+ * + * * * @param o The object to compare this section with * @return true if the objects are equal, false if @@ -461,8 +478,6 @@ public class Section final Section s = (Section) o; if (!s.getFormatID().equals(getFormatID())) return false; - if (s.getPropertyCount() != getPropertyCount()) - return false; /* Compare all properties except 0 and 1 as they must be handled * specially. */ @@ -508,6 +523,12 @@ public class Section } } + /* If the number of properties (not counting property 1) is unequal the + * sections are unequal. */ + if (pa1.length != pa2.length) + return false; + + /* If the dictionaries are unequal the sections are unequal. */ boolean dictionaryEqual = true; if (p10 != null && p20 != null) dictionaryEqual = p10.getValue().equals(p20.getValue());