From: Rainer Klute Date: Tue, 31 Aug 2004 20:45:00 +0000 (+0000) Subject: - Two properties are regarded as equal now if one of them is a Variant.VT_LPWSTR... X-Git-Tag: BEFORE_RICHTEXT~173 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=55e91fa7e29931c73767cc181f6bbc7cfb16aca6;p=poi.git - 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 --- diff --git a/src/java/org/apache/poi/hpsf/Property.java b/src/java/org/apache/poi/hpsf/Property.java index a517758db2..a82aec30a4 100644 --- a/src/java/org/apache/poi/hpsf/Property.java +++ b/src/java/org/apache/poi/hpsf/Property.java @@ -275,9 +275,11 @@ public class Property /** - *

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.

+ *

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. Another special case are strings: Two properties may have + * the different types Variant.VT_LPSTR and Variant.VT_LPWSTR;

* * @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() */