klute 2004/08/15 06:43:35
Modified: src/java/org/apache/poi/hpsf PropertySet.java Section.java
Log:
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.
Revision Changes Path
1.18 +2 -2 jakarta-poi/src/java/org/apache/poi/hpsf/PropertySet.java
Index: PropertySet.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/PropertySet.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- PropertySet.java 22 Jun 2004 16:11:39 -0000 1.17
+++ PropertySet.java 15 Aug 2004 13:43:35 -0000 1.18
@@ -673,7 +673,7 @@
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());
1.24 +25 -4 jakarta-poi/src/java/org/apache/poi/hpsf/Section.java
Index: Section.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/Section.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Section.java 22 Jun 2004 16:11:39 -0000 1.23
+++ Section.java 15 Aug 2004 13:43:35 -0000 1.24
@@ -448,7 +448,24 @@
/**
- * <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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 @@
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 @@
}
}
+ /* 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());
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]