aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Klute <klute@apache.org>2004-08-15 13:43:35 +0000
committerRainer Klute <klute@apache.org>2004-08-15 13:43:35 +0000
commit14befc7fea60ad714815b35afb75105458b819e3 (patch)
treedd661ab25b03b1abde58ad6da6dbc0a2a4c03676
parent6ebe97796b1b5fb696c24385f2dbad5efc4fa5bf (diff)
downloadpoi-14befc7fea60ad714815b35afb75105458b819e3.tar.gz
poi-14befc7fea60ad714815b35afb75105458b819e3.zip
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
-rw-r--r--src/java/org/apache/poi/hpsf/PropertySet.java2
-rw-r--r--src/java/org/apache/poi/hpsf/Section.java27
2 files changed, 25 insertions, 4 deletions
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
/**
- * <p>Checks whether this section is equal to another object.</p>
+ * <p>Checks whether this section is equal to another object. The result is
+ * <code>false</code> if one of the the following conditions holds:</p>
+ *
+ * <ul>
+ *
+ * <li><p>The other object is not a {@link Section}.</p></li>
+ *
+ * <li><p>The format IDs of the two sections are not equal.</p></li>
+ *
+ * <li><p>The sections have a different number of properties. However,
+ * properties with ID 1 (codepage) are not counted.</p></li>
+ *
+ * <li><p>The other object is not a {@link Section}.</p></li>
+ *
+ * <li><p>The properties have different values. The order of the properties
+ * is irrelevant.</p></li>
+ *
+ * </ul>
*
* @param o The object to compare this section with
* @return <code>true</code> if the objects are equal, <code>false</code> 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());