2ronwalf/*
2ronwalf * Created on Dec 28, 2004
2ronwalf */
2ronwalfpackage impl.swrl;
2ronwalf
38daenzeroramaimport org.mindswap.owl.EntityFactory;
2ronwalfimport org.mindswap.owl.OWLIndividual;
38daenzeroramaimport org.mindswap.owl.vocabulary.OWL;
2ronwalfimport org.mindswap.owl.vocabulary.SWRL;
38daenzeroramaimport org.mindswap.owls.vocabulary.OWLS;
38daenzeroramaimport org.mindswap.query.ValueMap;
2ronwalfimport org.mindswap.swrl.SWRLIndividualObject;
2ronwalfimport org.mindswap.swrl.SWRLObject;
2ronwalfimport org.mindswap.swrl.SameIndividualAtom;
38daenzeroramaimport org.mindswap.swrl.Variable;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf *
2ronwalf */
2ronwalfpublic class SameIndividualAtomImpl extends AtomImpl implements SameIndividualAtom {
2ronwalf public SameIndividualAtomImpl(OWLIndividual ind) {
22daenzerorama super(ind);
2ronwalf }
2ronwalf
2ronwalf public SWRLIndividualObject getArgument1() {
2ronwalf return (SWRLIndividualObject) getPropertyAs(SWRL.argument1, SWRLIndividualObject.class);
2ronwalf }
2ronwalf
2ronwalf public SWRLIndividualObject getArgument2() {
2ronwalf return (SWRLIndividualObject) getPropertyAs(SWRL.argument2, SWRLIndividualObject.class);
2ronwalf }
2ronwalf
2ronwalf public int getArgumentCount() {
2ronwalf return 2;
2ronwalf }
2ronwalf
2ronwalf public SWRLObject getArgument(int index) {
2ronwalf if( index == 0 )
2ronwalf return getArgument1();
2ronwalf
2ronwalf if( index == 1 )
2ronwalf return getArgument2();
2ronwalf
2ronwalf throw new IndexOutOfBoundsException("Illegal argument index: "+index+" for a SameIndividualAtom");
2ronwalf }
2ronwalf
2ronwalf public void setArgument(int index, SWRLObject obj) {
2ronwalf if( index > 1 )
2ronwalf throw new IndexOutOfBoundsException("Illegal argument index: "+index+" for a SameIndividualAtom");
2ronwalf
2ronwalf if(obj instanceof SWRLIndividualObject) {
2ronwalf if( index == 0 )
2ronwalf setArgument1((SWRLIndividualObject) obj);
2ronwalf else
2ronwalf setArgument2((SWRLIndividualObject) obj);
2ronwalf }
2ronwalf else
2ronwalf throw new IllegalArgumentException("SameIndividualAtom argument should be a SWRLIndivdiualObject");
2ronwalf }
2ronwalf
2ronwalf public void setArgument1(SWRLIndividualObject obj) {
2ronwalf setProperty(SWRL.argument1, obj);
2ronwalf }
2ronwalf
2ronwalf public void setArgument2(SWRLIndividualObject obj) {
2ronwalf setProperty(SWRL.argument2, obj);
2ronwalf }
2ronwalf
2ronwalf public String toString() {
2ronwalf return "sameAs(" + getArgument1().debugString() + ", " + getArgument2().debugString() + ")";
2ronwalf }
38daenzerorama
38daenzerorama public void evaluate(ValueMap values) {
38daenzerorama OWLIndividual ind1 = getArgument1();
38daenzerorama if (ind1.isType(OWLS.Process.Parameter))
38daenzerorama ind1 = values.getIndividualValue((Variable) ind1);
38daenzerorama
38daenzerorama OWLIndividual ind2 = getArgument2();
38daenzerorama if (ind2.isType(OWLS.Process.Parameter))
38daenzerorama ind2 = values.getIndividualValue((Variable) ind2);
38daenzerorama
38daenzerorama ind1.setProperty(EntityFactory.createObjectProperty(OWL.sameAs), ind2);
38daenzerorama }
2ronwalf}