{
boolean equal = true;
/* Iterate over d1 and compare each entry with its counterpart in d2. */
for (final Iterator i = d1.getEntries(); equal && i.hasNext();)
{
final Entry e1 = (Entry) i.next();
final String n1 = e1.getName();
Entry e2 = null;
try
{
e2 = d2.getEntry(n1);
}
catch (FileNotFoundException ex)
{
msg.append("Document \"" + e1 + "\" exists, document \"" +
e2 + "\" does not.\n");
equal = false;
break;
}
if (e1.isDirectoryEntry() && e2.isDirectoryEntry())
equal = equal((DirectoryEntry) e1, (DirectoryEntry) e2, msg);
else if (e1.isDocumentEntry() && e2.isDocumentEntry())
equal = equal((DocumentEntry) e1, (DocumentEntry) e2, msg);
else
{
msg.append("One of \"" + e1 + "\" and \"" + e2 + "\" is a " +
"document while the other one is a directory.\n");
equal = false;
}
}
/* Iterate over d2 just to make sure that there are no entries in d2
* that are not in d1. */
for (final Iterator i = d2.getEntries(); equal && i.hasNext();)
{
final Entry e2 = (Entry) i.next();
final String n2 = e2.getName();
Entry e1 = null;
try
{
e1 = d1.getEntry(n2);
}
catch (FileNotFoundException ex)