List of usage examples for org.apache.poi.hpsf PropertySet equals
@Override public boolean equals(final Object o)
From source file:poi.hpsf.examples.CopyCompare.java
License:Apache License
/** * <p>Compares two {@link DocumentEntry} instances of a POI file system. * Documents that are not property set streams must be bitwise identical. * Property set streams must be logically equal.</p> * * @param d1 The first document./*from ww w . jav a 2 s .c o m*/ * @param d2 The second document. * @param msg The method may append human-readable comparison messages to * this string buffer. * @return <code>true</code> if the documents are equal, else * <code>false</code>. * @exception MarkUnsupportedException if a POI document stream does not * support the mark() operation. * @exception NoPropertySetStreamException if the application tries to * create a property set from a POI document stream that is not a property * set stream. * @throws java.io.UnsupportedEncodingException * @exception java.io.IOException if any I/O exception occurs. */ private static boolean equal(final DocumentEntry d1, final DocumentEntry d2, final StringBuffer msg) throws NoPropertySetStreamException, MarkUnsupportedException, UnsupportedEncodingException, IOException { boolean equal = true; final DocumentInputStream dis1 = new DocumentInputStream(d1); final DocumentInputStream dis2 = new DocumentInputStream(d2); if (PropertySet.isPropertySetStream(dis1) && PropertySet.isPropertySetStream(dis2)) { final PropertySet ps1 = PropertySetFactory.create(dis1); final PropertySet ps2 = PropertySetFactory.create(dis2); equal = ps1.equals(ps2); if (!equal) { msg.append("Property sets are not equal.\n"); return equal; } } else { int i1; int i2; do { i1 = dis1.read(); i2 = dis2.read(); if (i1 != i2) { equal = false; msg.append("Documents are not equal.\n"); break; } } while (equal && i1 == -1); } return true; }