klute 2004/08/31 13:45:00
Modified: src/java/org/apache/poi/hpsf Property.java
Log:
- 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.
Revision Changes Path
1.20 +19 -5 jakarta-poi/src/java/org/apache/poi/hpsf/Property.java
Index: Property.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/Property.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Property.java 22 Jun 2004 16:11:39 -0000 1.19
+++ Property.java 31 Aug 2004 20:45:00 -0000 1.20
@@ -275,9 +275,11 @@
/**
- * <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 @@
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;
@@ -306,6 +308,18 @@
return Util.equal((byte[]) value, (byte[]) pValue);
return value.equals(pValue);
+ }
+
+
+
+ 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;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]