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
This commit is contained in:
Rainer Klute 2004-08-15 13:43:35 +00:00
parent 6ebe97796b
commit 14befc7fea
2 changed files with 25 additions and 4 deletions

View File

@ -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());

View File

@ -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());