01: /**
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */package com.tc.config.schema.utils;
04:
05: import org.apache.xmlbeans.XmlObject;
06:
07: /**
08: * An {@link XmlObjectComparator} that simply calls {@link Object#equals(Object)} to compare its arguments. Note that
09: * this should <strong>NEVER</strong> be used on real {@link XmlObject}s, as they don't implement
10: * {@link Object#equals(Object)} correctly. Rather, this is used only for tests.
11: */
12: public class ObjectEqualsXmlObjectComparator implements
13: XmlObjectComparator {
14:
15: public boolean equals(XmlObject one, XmlObject two) {
16: try {
17: checkEquals(one, two);
18: return true;
19: } catch (NotEqualException nee) {
20: return false;
21: }
22: }
23:
24: public void checkEquals(XmlObject one, XmlObject two)
25: throws NotEqualException {
26: if ((one == null) != (two == null))
27: throw new NotEqualException("nullness not the same");
28: if (one == null)
29: return;
30: if (!one.equals(two))
31: throw new NotEqualException("not equal");
32: }
33:
34: }
|