org.semwebcentral.sweetrules.ruleml
Class SweetEqualityChecker

java.lang.Object
  extended byorg.semwebcentral.sweetrules.ruleml.SweetEqualityChecker

public class SweetEqualityChecker
extends java.lang.Object

Created on Oct 30, 2004 A utility class to check if two elements in the RuleML object representation are equal in terms of their content. Note:
1) If List type arguments are being compared then their orders should be the same

2) The top level element currently supported is a fact

3) Due to translation issues from RuleML -> Jess we are not comparing the rulelabels on Facts

Author:
Shashidhara K Ganjugunte, Dr. Benjamin Grosof, Dr. Said Tabet, Chitravanu Neogy

Field Summary
private static SweetEqualityChecker sweetEqualityChecker
          The singleton instance
 
Constructor Summary
private SweetEqualityChecker()
          The private constructor for this Singleton class
 
Method Summary
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndhType andh1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndhType andh2)
          Compares two andh elements for equality
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType atom1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType atom2)
          Compares two atoms for equality
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CslitType cslit1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CslitType cslit2)
          Compares two csliteral for equality
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CtermType cterm1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CtermType cterm2)
          Compares the two Cterms to see if they are same
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.FactType fact1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.FactType fact2)
          Checks if the two input facts are equal.
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType head1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType head2)
          Compares for the equality of two heads
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.IndType ind1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.IndType ind2)
          Compares two ind values for equality
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.OprType opr1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.OprType opr2)
          Compares two oprs
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RelType rel1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RelType rel2)
          Compares two rel values
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RlabType rlab1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RlabType rlab2)
          Compares two rule labels
 boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.Var var1, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.Var var2)
          Compares two variables for equality
 boolean areSameTerms(java.util.List indOrVarOrCtermList1, java.util.List indOrVarOrCtermList2)
          Compares two term lists for equality
 boolean bothObjectsNull(java.lang.Object obj1, java.lang.Object obj2)
          Compares two objects for nullity
static SweetEqualityChecker getInstance()
          Accessor method for the single ton class
 boolean onlyOneObjectNull(java.lang.Object obj1, java.lang.Object obj2)
          Checks if only one of the objects is null and the other isn't
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sweetEqualityChecker

private static SweetEqualityChecker sweetEqualityChecker
The singleton instance

Constructor Detail

SweetEqualityChecker

private SweetEqualityChecker()
The private constructor for this Singleton class

Method Detail

getInstance

public static SweetEqualityChecker getInstance()
Accessor method for the single ton class

Returns:
The singleton instance

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.FactType fact1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.FactType fact2)
Checks if the two input facts are equal. For now we are not comparing the rule labels for facts

Parameters:
fact1 - The first fact
fact2 - The second fact
Returns:
true if the facts are equal

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RlabType rlab1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RlabType rlab2)
Compares two rule labels

Parameters:
rlab1 - First rule label
rlab2 - Second rule label
Returns:
true if both rule labels are same

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType head1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType head2)
Compares for the equality of two heads

Parameters:
head1 - The first head argument
head2 - The second head argument
Returns:
true if both the head arguments are equal

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType atom1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType atom2)
Compares two atoms for equality

Parameters:
atom1 - The first atom
atom2 - The second atom
Returns:
true if both the atoms are equal

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.OprType opr1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.OprType opr2)
Compares two oprs

Parameters:
opr1 - The first opr
opr2 - The second opr
Returns:
true if both the oprs are the same

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RelType rel1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RelType rel2)
Compares two rel values

Parameters:
rel1 - The first rel value
rel2 - The second rel value
Returns:
true if both the rel values are equal

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CslitType cslit1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CslitType cslit2)
Compares two csliteral for equality

Parameters:
cslit1 - The first cslit
cslit2 - The second cslit
Returns:
true if the cslits are equal

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndhType andh1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndhType andh2)
Compares two andh elements for equality

Parameters:
andh1 - The first andh element
andh2 - The second andh element
Returns:
true if both are equal

areSameTerms

public boolean areSameTerms(java.util.List indOrVarOrCtermList1,
                            java.util.List indOrVarOrCtermList2)
Compares two term lists for equality

Parameters:
indOrVarOrCtermList1 - The first term list
indOrVarOrCtermList2 - The second term list
Returns:
true if they are equal

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.IndType ind1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.IndType ind2)
Compares two ind values for equality

Parameters:
ind1 - The first ind value
ind2 - The second ind value
Returns:
true if both ind values are equal

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CtermType cterm1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CtermType cterm2)
Compares the two Cterms to see if they are same

Parameters:
cterm1 - The first cterm
cterm2 - The second cterm
Returns:
if the names of the cterms are the same then true is returned, false otherwise

areSame

public boolean areSame(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.Var var1,
                       org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.Var var2)
Compares two variables for equality

Parameters:
var1 - The first variable
var2 - The second variable
Returns:
true if two variables are same

bothObjectsNull

public boolean bothObjectsNull(java.lang.Object obj1,
                               java.lang.Object obj2)
Compares two objects for nullity

Parameters:
obj1 - The first object
obj2 - The second object
Returns:
true if both objects are null, false otherwise

onlyOneObjectNull

public boolean onlyOneObjectNull(java.lang.Object obj1,
                                 java.lang.Object obj2)
Checks if only one of the objects is null and the other isn't

Parameters:
obj1 - The first object
obj2 - The second object
Returns:
true if only one of the objects is null, false otherwise