- Two properties are regarded as equal now if one of them is a Variant.VT_LPWSTR and the other is a Variant.VT_LPSTR but their values are equal.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Klute 2004-08-31 20:45:00 +00:00
parent 740965126b
commit 4827806018

View File

@ -275,9 +275,11 @@ public class Property
/**
* <p>Compares two properties. Please beware that a property with ID == 0 is
* a special case: It does not have a type, and its value is the section's
* dictionary.</p>
* <p>Compares two properties.</p>
*
* <p>Please beware that a property with ID == 0 is a special case: It does not have a type, and its value is the section's
* dictionary. Another special case are strings: Two properties may have
* the different types Variant.VT_LPSTR and Variant.VT_LPWSTR;</p>
*
* @see Object#equals(java.lang.Object)
*/
@ -288,7 +290,7 @@ public class Property
final Property p = (Property) o;
final Object pValue = p.getValue();
final long pId = p.getID();
if (id != pId || (id != 0 && type != p.getType()))
if (id != pId || (id != 0 && !typesAreEqual(type, p.getType())))
return false;
if (value == null && pValue == null)
return true;
@ -310,6 +312,18 @@ public class Property
private boolean typesAreEqual(final long t1, final long t2)
{
if (t1 == t2 ||
(t1 == Variant.VT_LPSTR && t2 == Variant.VT_LPWSTR) ||
(t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR))
return true;
else
return false;
}
/**
* @see Object#hashCode()
*/