/*
* JBoss, Home of Professional Open Source
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags.
* See the copyright.txt in the distribution for a full listing
* of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License, v. 2.0.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License,
* v. 2.0 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* (C) 2005-2006,
* @author JBoss Inc.
*/
/*
* Copyright (C) 2002,
*
* Arjuna Technologies Limited,
* Newcastle upon Tyne,
* Tyne and Wear,
* UK.
*
* $Id: DocComparitor.java,v 1.4 2005/05/19 12:13:39 nmcl Exp $
*/
package com.arjuna.mwlabs.wscf.utils;
import com.arjuna.mw.wscf.logging.wscfLogger;
import com.arjuna.mw.wscf.utils.CoordinationXML;
/**
* The DocComparitor takes two XML documents describing a coordinator's protocol
* and tests for equality. Two documents are equal if the have exactly the same
* elements and attributes, no matter what the order of occurrence.
*
* The comapritor may be extended to allow subset or superset comparisons.
*
* @author Mark Little (mark.little@arjuna.com)
* @version $Id: DocComparitor.java,v 1.4 2005/05/19 12:13:39 nmcl Exp $
* @since 1.0.
*/
public class DocComparitor
{
public DocComparitor ()
{
}
/**
* Are the two documents equal? We assume that the protocol names are
* unique, so can check for equality simply on that. If we want to check
* individual elements and attributes then we could.
*
* @message com.arjuna.mwlabs.wscf.utils.DocComparitor_1
* [com.arjuna.mwlabs.wscf.utils.DocComparitor_1] - First parameter
* is null!
* @message com.arjuna.mwlabs.wscf.utils.DocComparitor_2
* [com.arjuna.mwlabs.wscf.utils.DocComparitor_2] - Second
* parameter is null!
*/
public boolean equals (org.w3c.dom.Document doc1, org.w3c.dom.Document doc2)
{
if (doc1 == null)
throw new IllegalArgumentException(wscfLogger.log_mesg
.getString("com.arjuna.mwlabs.wscf.utils.DocComparitor_1"));
if (doc2 == null)
throw new IllegalArgumentException(wscfLogger.log_mesg
.getString("com.arjuna.mwlabs.wscf.utils.DocComparitor_2"));
CoordinationXML protocol1 = new CoordinationXML(doc1);
CoordinationXML protocol2 = new CoordinationXML(doc2);
return protocol1.equals(protocol2);
}
}
|